74876

How do I connect glade signals using GtkBuilder in C#?

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#?

Answer1:

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

Answer2:

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(); }

Recommend

  • display only value fields from the msg.payload in node red
  • Git will escape the backslash on my remote path for Network
  • Ionic run error exit code 1 device communication timed out
  • How can I read out the “glade ID” of a gtk3 object
  • android Wear 5.0 can't resolve host (Http , AsyncClient ETC. )
  • NodeMCU SMTP Email
  • Adding custom widget to GLADE
  • Passing parameters to SQL Server stored procedures with PHP PDO
  • Python timer script doesn't run when set to long periods later
  • Retrieve Windows Update history using WUAPILib from a remote machine
  • VSTS build failed with Git fetch failed with exit code: 128
  • R mlogit on my data giving error 'system is computationally singular?
  • Is it OK to write code after [super dealloc]?
  • iAd works in iPhone but not iPad
  • rselenium | get youtube page source
  • Query pkg-config variable through autotools
  • is there a way to update filter with async data
  • DateTime.Today for a specific time zone
  • Doctrine/Symfony entity generator and generating entity from one table
  • Casting between Interfaces and Classes
  • jwtBearer bearer token with rc-1 update to ASP.Net 5
  • Enabling DTD support in Sql Server
  • Convert SQLite database to XML
  • WPF Visiblity Binding to Boolean Expression with multiple Variables
  • Conversion from string “a” to type 'Boolean' is not valid
  • How to determine if there are bytes available to be read from boost:asio:serial_port
  • MVC3 Razor - ListBox pre-select not working
  • Play WS (2.2.1): post/put large request
  • Unity3D & Android: Difference between “UnityMain” and “main” threads?
  • Spray.io: When (not) to use non-blocking route handling?
  • JavaScriptCore crash on iOS9
  • Javascript Callbacks with Object constructor
  • Deserializing XML into class C#
  • SVN: Merging two branches together
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Arrays break string types in Julia
  • Is there a mandatory requirement to switch app.yaml?
  • Transpose CSV data with awk (pivot transformation)
  • Free memory of cv::Mat loaded using FileStorage API
  • How to Embed XSL into XML