Re: porting to new gtk widgets



Hey James,

On Fri, 2003-10-24 at 04:23, James Henstridge wrote:
> On 24/10/2003 12:21 AM, Mark McLoughlin wrote:
> 
> >Hey,	
> >	So I decided to port the panel from the APIs that are deprecated in
> >gtk+ HEAD. I thought it would be an easy enough job until I hit the
> >first deprecated widget in a glade file :-)
> >
> >	We can't really hope to port from things like GtkOptionMenu to
> >GtkComboBox if glade/libglade does not yet support GtkComboBox. So if
> >someone is looking for a really helpful, but pretty straightforward
> >project, then this is it ! We really need support for those new APIs in
> >glade ...
> >  
> >
> Sure.  I will have to do a bit more hacking on libglade to bring it up 
> to speed for gtk 2.4.  

	Okay, here's a patch for GtkExpander support. I've a glade patch which
I'm going to send off too.

	Okay to branch and commit ?

Cheers,
Mark.

P.S. - I made the version number 2.3.0 instead of 2.5.0 - I thought it
made more sense to keep the glade/libglade version numbers in sync with
gtk+, right ?

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libglade/ChangeLog,v
retrieving revision 1.296
diff -u -p -r1.296 ChangeLog
--- ChangeLog	23 Jul 2003 14:48:47 -0000	1.296
+++ ChangeLog	24 Oct 2003 10:09:57 -0000
@@ -0,0 +1,10 @@
+2003-10-24  Mark McLoughlin  <mark skynet ie>
+
+	* configure.in: bump version to 2.3.0 (in sync with
+	gtk+), require gtk+ 2.3.0 and kill the crufty
+	development branch warning.
+	
+	* glade/glade-gtk.c: (expander_build_children),
+	(_glade_init_gtk_widgets): implement support
+	for GtkExpander.
+
Index: configure.in
===================================================================
RCS file: /cvs/gnome/libglade/configure.in,v
retrieving revision 1.88
diff -u -p -r1.88 configure.in
--- configure.in	26 Feb 2003 14:22:54 -0000	1.88
+++ configure.in	24 Oct 2003 10:09:57 -0000
@@ -1,6 +1,6 @@
 -*- mode: autoconf -*-
 AC_PREREQ(2.52)
-AC_INIT(libglade, 2.0.1,
+AC_INIT(libglade, 2.3.0,
         [http://bugzilla.gnome.org/enter_bug.cgi?product=libglade])
 
 AC_CONFIG_SRCDIR([test-libglade.c])
@@ -27,7 +27,7 @@ AC_HEADER_STDC
 AC_LIBTOOL_WIN32_DLL
 AM_PROG_LIBTOOL
 
-AM_PATH_GTK_2_0(2.0.0)
+AM_PATH_GTK_2_0(2.3.0)
 
 save_LIBS=$LIBS
 LIBS="$GTK_LIBS $LIBS"
@@ -37,7 +37,7 @@ LIBS=$save_LIBS
 
 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
 
-PKG_CHECK_MODULES(LIBGLADE, libxml-2.0 >= 2.4.10 atk >= 1.0.0 gtk+-2.0 >= 2.0.0)
+PKG_CHECK_MODULES(LIBGLADE, libxml-2.0 >= 2.4.10 atk >= 1.0.0 gtk+-2.0 >= 2.3.0)
 AC_SUBST(LIBGLADE_LIBS)
 AC_SUBST(LIBGLADE_CFLAGS)
 
@@ -163,13 +163,6 @@ libglade-convert
 ])
 
 rm -f po/po2tbl.sed
-
-echo
-echo "This is the development branch of libglade"
-echo "If you want something that works with gtk+ 1.2, checkout the"
-echo "libglade-1-0 branch with the following command"
-echo "  cvs update -r libglade-1-0 ."
-echo
 
 if test -z "$jh_cv_path_python"; then
   echo "*****************************************************"
Index: glade/glade-gtk.c
===================================================================
RCS file: /cvs/gnome/libglade/glade/glade-gtk.c,v
retrieving revision 1.100
diff -u -p -r1.100 glade-gtk.c
--- glade/glade-gtk.c	23 Jul 2003 14:48:48 -0000	1.100
+++ glade/glade-gtk.c	24 Oct 2003 10:09:57 -0000
@@ -518,6 +518,41 @@ frame_build_children(GladeXML *self, Gtk
 }
 
 static void
+expander_build_children (GladeXML        *self,
+			 GtkWidget       *parent,
+			 GladeWidgetInfo *info)
+{
+    int i;
+
+    g_object_ref (parent);
+    for (i = 0; i < info->n_children; i++) {
+	GladeWidgetInfo *childinfo = info->children [i].child;
+	GtkWidget       *child;
+	gboolean         label_item = FALSE;
+	int              j;
+	
+	child = glade_xml_build_widget (self, childinfo);
+
+	/* there should really only be 2 children */
+	for (j = 0; j < info->children [i].n_properties; j++) {
+	    if (!strcmp (info->children [i].properties[j].name, "type")) {
+		const char *value = info->children [i].properties [j].value;
+
+		if (!strcmp (value, "label_item"))
+		    label_item = TRUE;
+		break;
+	    }
+	}
+
+	if (label_item)
+	    gtk_expander_set_label_widget (GTK_EXPANDER (parent), child);
+	else
+	    gtk_container_add (GTK_CONTAINER (parent), child);
+    }
+    g_object_unref (parent);
+}
+
+static void
 notebook_build_children(GladeXML *self, GtkWidget *parent,
 			GladeWidgetInfo *info)
 {
@@ -1070,6 +1105,8 @@ _glade_init_gtk_widgets(void)
 			   NULL, NULL);
     glade_register_widget (GTK_TYPE_EVENT_BOX, glade_standard_build_widget,
 			   glade_standard_build_children, NULL);
+    glade_register_widget (GTK_TYPE_EXPANDER, glade_standard_build_widget,
+			   expander_build_children, NULL);
     glade_register_widget (GTK_TYPE_FILE_SELECTION, NULL,
 			   glade_standard_build_children, filesel_find_internal_child);
     glade_register_widget (GTK_TYPE_FIXED, glade_standard_build_widget,






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]