[Glade-devel] Extending glade
- From: james daa com au (James Henstridge)
- Subject: [Glade-devel] Extending glade
- Date: Mon, 12 May 2003 09:08:19 +0800
Alberto Mardegan wrote:
Hi all!
I'm quite new to Glade and Gtk+ in general, and I don't know much of
how they work.
I'd like to add some custom widgets (a date/time widget comes to mind)
to glade (and therefore libglade, since I intend to keep the interface
part on the XML file), but I don't know what's the best way to do it
actually.
Googling around, I've come to this page of the libglade manual,
http://developer.gnome.org/doc/API/libglade/libglade-extending.html
which states that, except using the custom widget class (which I won't
do), the solution is modifying the libglade sources.
I've looked at the source code of both glade and libglade, and it seems
to me that modifying the sources to add my widgets will not be very
difficult, since there is not too much work to be done.
But is there a way to avoid modifying the sources?
Isn't there a way in Gtk+ to create a widget from a class name, i.e.
a function like
GtkWidget *gtk_new(const gchar *classname)
and then retrieve the modifiable properties of the newly created object,
in order to let the user change them in glade?
I found some old discussion about something like that, but they are old:
http://rpmfind.net/tools/glade/messages/2431.html
http://lists.ximian.com/archives/public/glade-users/2000-November/000233.html
What is the actual status of these ideas?
First off, I assume you are using GTK 2.x (as opposed to 1.2.x). If you
aren't, then switch now.
Libglade 2.0.x makes heavy use of the property system of GTK. This
means that if you expose all the functionality of your new widget as
properties (ie. implement the get_property method), and make sure the
widget is in a valid state after construction with g_object_new(), then
libglade can support your widget with no additional code.
Simply make sure the _get_type() function for your widget has been
called before calling glade_xml_new(). Then libglade will be able to
construct widgets of that type if it finds them in the input file.
This doesn't give you a nice UI to build your widget in glade, but you
can easily hand edit the .glade file afterwards. The glade-3 project is
working on a rewrite of glade that also makes use of properties, which
should make it a lot easier to support custom widgets like this.
James.
--
Email: james daa com au
WWW: http://www.daa.com.au/~james/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]