[Gtk-sharp-list] Glade# signal/handler pass object

Mono-Dev-List lists@davidmaddison.com
Mon, 24 Nov 2003 12:20:14 +0000


Hi Leo,

I'm also new to Gnome Development, C# etc (and this is my first post),
but I think I can help you here.

To change the given code in Glade you simply set up a SignalHandler for
the signal 'clicked' on the corresponding button called OnButtonClicked.

In you C# code you then connect the Glade UI to your handler code using
something like this :
        Glade.XML gxml = new Glade.XML ("test.glade", "mainWindow",
null);
                gxml.Autoconnect (this);

The Autoconnect is the magic method that connects your code to Glade.

Hope this helps,

Dave Maddison
(codemonk)

On Mon, 2003-11-24 at 07:01, Leo Spalteholz wrote:
> On November 23, 2003 10:37 pm, Leo Spalteholz wrote:
> > On November 23, 2003 04:16 pm, Alejandro Sánchez wrote:
> > > I have a glade object
> > >
> > > <widget class="GtkButton" id="button">
> > >   <property name="width_request">15</property>
> > >   <property name="height_request">15</property>
> > >   <property name="visible">True</property>
> > >   <property name="relief">GTK_RELIEF_NONE</property>
> > >   <signal name="clicked" handler="OnButtonClicked" object="widget"
> > > last_modification_time="Sat, 22 Nov 2003 15:56:35 GMT"/>
> > >
> > > How would be OnButtonClicked declaration in C#? How to retrieve object
> > > "widget" in the function?
> > >
> > > And with all in C# code?
> > >
> > > Button button = new Button;
> >
> > should be: Button button = new Button();
> >
> > > button.Clicked += new EventHandler(OnButtonClicked);
> >
> > void OnButtonClicked(object obj, EventArgs args) {
> > 	// get widget, in this case your button
> > 	Button button = (Button)(obj);
> > }
> >
> > Leo
> 
> On second read..  Did you want the pure C# way of doing it or how to do it 
> with glade#?  Well the above is how to do it in C#...   Sorry, I don't 
> know anything about glade#.
> 
> leo
> 
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list