Beyond the Examples

View: New views
4 Messages — Rating Filter:   Alert me  

Beyond the Examples

by Alex-440 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm writing a somewhat complex gui application with gtkmm and glade,
and I've run into a design problem that I'm unsure of how to solve.
Rather than kludging together a solution that simply works, I figured
it would be a good idea to consult the experts.

Consider the following situation: I have a program with a main window
class. Upon starting, an object of class MainWindow is created, and
that is passed to kit.run(). MainWindow includes all of its widgets as
private members, including some derived widgets (such as a secondary
window that can be opened or closed from MainWindow.)

Now, here's the problem: I need to figure out how to get widgets in my
secondary window to interact with widgets in MainWindow, and vice
versa. I could define and attach all the signals from within the
MainWindow class, but defining secondary window's signal handlers
there seems cumbersome and incorrect. How should I go about this?

I haven't included any code because I feel that this is more of a
conceptual/structural problem, but if anyone wants me to include that
or any other information, I'd be willing to oblige, as the above
description may not be sufficient.
-Alex
_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Beyond the Examples

by Bernd Robertz-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

if I understand your problem, your window wich opens a secondary window,
needs to be instantiated in the main window.
So you could connect a signal in the mainwindow wich executes a slot in
the sec-window.

In the basics that should work. I have solved problems like this, with
this solution in earlier projects.

If you need to interact with the widgets, you can write get and set
methods wich do what you want with the widgets in the other window.

Perhaps there are better solutions, but this is how I did it.

Many greetings

Bernd


Am Sonntag, den 04.10.2009, 08:04 -0400 schrieb Alex:

> I'm writing a somewhat complex gui application with gtkmm and glade,
> and I've run into a design problem that I'm unsure of how to solve.
> Rather than kludging together a solution that simply works, I figured
> it would be a good idea to consult the experts.
>
> Consider the following situation: I have a program with a main window
> class. Upon starting, an object of class MainWindow is created, and
> that is passed to kit.run(). MainWindow includes all of its widgets as
> private members, including some derived widgets (such as a secondary
> window that can be opened or closed from MainWindow.)
>
> Now, here's the problem: I need to figure out how to get widgets in my
> secondary window to interact with widgets in MainWindow, and vice
> versa. I could define and attach all the signals from within the
> MainWindow class, but defining secondary window's signal handlers
> there seems cumbersome and incorrect. How should I go about this?
>
> I haven't included any code because I feel that this is more of a
> conceptual/structural problem, but if anyone wants me to include that
> or any other information, I'd be willing to oblige, as the above
> description may not be sufficient.
> -Alex
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list@...
> http://mail.gnome.org/mailman/listinfo/gtkmm-list

_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Beyond the Examples

by Alex-440 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> If you need to interact with the widgets, you can write get and set
> methods wich do what you want with the widgets in the other window.

That's a good idea. I'll still need to connect a signal inside
MainWindow to handle when the secondary window is closed, but that
seems sane enough. Having getters and setters to handle the widgets
inside the secondary window will make the rest of the solution much
simpler. Thanks for the help!
-Alex
_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Beyond the Examples

by Bernd Robertz-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You are welcome,

I´m glad that I could help.

Hope it works like you need it.

Bernd


Am Sonntag, den 04.10.2009, 12:18 -0400 schrieb Alex:
> > If you need to interact with the widgets, you can write get and set
> > methods wich do what you want with the widgets in the other window.
>
> That's a good idea. I'll still need to connect a signal inside
> MainWindow to handle when the secondary window is closed, but that
> seems sane enough. Having getters and setters to handle the widgets
> inside the secondary window will make the rest of the solution much
> simpler. Thanks for the help!
> -Alex

_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list