In python, I could just do builder.connect_signals(self)
. It doesn't seem like this method exists in C#, and after looking at the GtkBuilder documentation, it looks like python is the exception, rather than the rule. How would I accomplish the same thing in C#?
Asked
Active
Viewed 2,072 times
2

Matthew
- 28,056
- 26
- 104
- 170
2 Answers
1
Right now Gtk.Builder is not fully implemented in the current version of Gtk# (2.12). This thread explains the current situation. So once Gtk# 2.14 is released, you can just do:
builder.Autoconnect (this);
In the meantime you could use Glade.XML, and then convert your code (and glade files) as described here: http://lists.ximian.com/pipermail/gtk-sharp-list/2008-October/009157.html

Isaiah
- 4,201
- 4
- 27
- 40
-
Thanks, that's good to know. Any word on when 2.14 will be released? – Matthew Nov 07 '09 at 23:40
-
1Hmm this makes it sound like they're skipping 2.14+ in favor of 3.x: http://www.mono-project.com/GtkSharpPlan#Release_plan – Matthew Nov 07 '09 at 23:46
0
You can connect your signals using method Autoconnect
, but method that represent a signal in c# must be in form:
static void customMethod(object sender, EventArgs args);
So each field of class that you use in such method must be declared as static
. It robs you of creating another instance of your class.
There is another way of connecting signals:
Builder builder = new Builder();
builder.AddFromFile("custom.glade");
Button button = (Button)builder.GetObject("closeButton");
button.Clicked += delegate {
Application.Quit();
}

MBean
- 1
- 2
-
1Welcome to StackOverflow and thanks for your participation. Code-only answers are discouraged here as they do not provide much value for further reasers, so could you please explain why and how it works? – flotothemoon Sep 05 '14 at 11:49