Re: interaction between widgets



--- Axel <axel azerty netcourrier com> wrote:
> On Thu, 20 Mar 2003 08:07:13 -0800 (PST)
> Harring Figueiredo <harringf yahoo com> wrote:
> 
> > 
> > 
> >  When you create your signal fucntion, you can pass a pointer to whatever
> > widget you want.
> >   Something like this:
> > 
> >  g_signal_connect(button_on_toolbar, button_callback_handler, "activate",
> > (gpointer) my_notebook);
> > 
> > 
> 
> ok, but, the my_notebook pointer isn' t in the create_menubar() function
> 
> I use some functions to create widgets, but where should I put the
> g_signal_connect ?
> In the same function?
> 
> for the case of the menubar, which have a lot of use in the application,
> should I put all the g_signal_connect in the same fonction which create the
> menubar ?the problem is that if I want interaction with outside widgets, I
> should pass all the pointer to these widgets as parameter in the function
> which create the menu bar.It isn' t very clean I think.
> What advice can you give me ?
> 

  Well, a solution then would be something like:

  typedef _MainWin MainWin;

  struct _MainWin{
     GtkWidget* menubar;
     GtkWidget* notebook;
      GtkWidget* some_more_widget;
  };


  Then you can have:

  MainWin* create_main_win(){
       MainWin* w = g_new(MainWin, 1);

       w->menubar = create_menubar();
       w->notebook = create_notbook;

       /* connect the signals here */

       g_signal_connect( win->somebutton, callbackfunc, "activate" ,
win->notebook);
       g_signal_connect (.. other callback funcs....);
  }


  The above example is just a example -- you can have one fucntion that creates
all the interface (Like Glade does) and there is nothing wrong with that.  

  Perhaps you are trying to abstract too much, and thus, limiting yourself on
what you should do. Remember: you are NOT building a library, you are building
an application -- it is ok for things to be coupled. I think you are getting
stuck on this.

  Hope this helps.


Harring.





__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]