Re: How to make reference to widget from another file?



On Tue, 2006-10-24 at 20:50 -0700, bluelarva wrote:
> Hi,
> 
> I am using Glade 2.
> 
> Let's say my app got two buttons, one combo, one label, and one textentry.
> 
> When either of the button get clicked, the combo, label and textentry will
> fill with hardcorded sentence.
> The content of callbacks.c is as following:
>     static void
>     on_button1_clicked (GtkButton *button, GtkComboBox *combobox)
>     {
>       fillCombo ();
>       setLabel();
>       setEntry();
>     }
> 
>     static void
>     on_button2_clicked (GtkButton *button, GtkComboBox *combobox)
>     {
>       fillCombo ();
>       setLabel();
>       setEntry();
>     }
> 
> 
> I have some common function stored in another file, called utils.c. 
> the functions of utils.c are
> 
> void      fillCombo ();
> void      setLabel();
> void      setEntry();
> 
> The problem here is, how do I make reference to widget from another file? I
> got 5 files, main.c, interface.c, callbacks.c, support.c, and utils.c. The
> widgets are created in interface.c. How to access the widgets from utils.c?

You can probably pass the widgets you need to reference as arguments to
the functions in util.c that need them (if they are too many, make a
struct with pointers to them, and pass that)

You should consider _not_ using glade to generate code, but using
libglade instead. There are many reasons for this (cf., for example,
<http://lists.ximian.com/pipermail/glade-devel/2003-February/000015.html>)


Cheers,

-- m




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