Reputation: 682
In certain applications from GNOME, like EasyTAG
, in their source code they have constructs like G_DEFINE_TYPE
, and et_application_get_type
(from EasyTAG
). They use GAction
varibles to represent actions that are run from the menubar, eg. for the Quit
item, they would represent it in the GAction array of possible actions.
In other applications, like LXTask
, GManEdit
, they use signal handlers to call the function that processes the request (to quit, maybe).
Which should I use: The first or second.
I have noticed that if you use the first way, the source files are divided into files named window
, application_window
, preferences_window
, eg. The second method uses the prenamed callbacks.c
, interface.c
always.
When browsing source code, I find the second method easier to read, because if I want to look for some functionality, i know which file to look in. The first method is not so easy because it is named after window elements, not preset filenames.
Maybe the first method is more efficient for the compiler...Any idea?
Upvotes: 0
Views: 70
Reputation: 57860
The callbacks.c
/interface.c
files used to be generated from a very old version of Glade 2.x, only for GTK 2.x, when GtkApplication didn't exist. This organization isn't really used anymore.
It's recommended to use GtkApplication; there is a how-to. You'll notice that the C example there doesn't use G_DEFINE_TYPE
to inherit from GtkApplication, but instead uses signal handlers. The Python and JS examples do define a class that inherits from Gtk.Application
. In C it's often more convenient to use signal handlers instead of inheritance, but you could do either one. They are mostly equivalent.
Upvotes: 1