my libglade hacks



these are the hacks i have to libglade to make it run bug-buddy.

i'm not yet sure if GtkText and GtkCList should be autoconverted or not.

(obviously i'd rather have the canvas support in the canvas)

will be comitting the bug-buddy bits shortly.

any problems with committing this?

jacob
-- 
? autom4te.cache
? libglade.diff
? doc/libglade-symbols.txt
? glade/glade-canvas.c
Index: acconfig.h
===================================================================
RCS file: /cvs/gnome/libglade/acconfig.h,v
retrieving revision 1.9
diff -u -r1.9 acconfig.h
--- acconfig.h	2001/10/09 02:26:12	1.9
+++ acconfig.h	2001/10/23 18:32:26
@@ -4,3 +4,4 @@
 #undef HAVE_LC_MESSAGES
 #undef WITH_GNOME
 #undef WITH_BONOBO
+#undef WITH_CANVAS
Index: configure.in
===================================================================
RCS file: /cvs/gnome/libglade/configure.in,v
retrieving revision 1.57
diff -u -r1.57 configure.in
--- configure.in	2001/10/09 02:26:12	1.57
+++ configure.in	2001/10/23 18:32:26
@@ -54,12 +54,12 @@
     AC_DEFINE(WITH_BONOBO)
 fi
 
-dnl checks for the bonobo module ...
+dnl checks for the gnome module ...
 AC_ARG_ENABLE(gnome,
   AC_HELP_STRING([--enable-gnome], [enable gnome support (yes/no/auto)]),,
   [enable_gnome=auto])
 build_gnome=false
-if test "x$gnome_gnome" != xno; then
+if test "x$enable_gnome" != xno; then
   PKG_CHECK_MODULES(LIBGLADE_GNOME,
     [libgnomeui-2.0 >= 1.103.0 libxml-2.0 >= 2.4.1 atk >= 0.6],
     build_gnome=true,
@@ -72,6 +72,26 @@
 AM_CONDITIONAL(BUILD_GNOME, $build_gnome)
 if $build_gnome; then
     AC_DEFINE(WITH_GNOME)
+fi
+
+dnl checks for the canvas module ...
+AC_ARG_ENABLE(canvas,
+  AC_HELP_STRING([--enable-canvas], [enable canvas support (yes/no/auto)]),,
+  [enable_canvas=auto])
+build_canvas=false
+if test "x$enable_canvas" != xno; then
+  PKG_CHECK_MODULES(LIBGLADE_CANVAS,
+    [libgnomecanvas-2.0 >= 1.103.0],
+    build_canvas=true,
+    [if test "x$enable_canvas" = xyes; then
+       AC_MSG_ERROR([Canvas support requested but libgnomecanvas-2.0 not found])
+     fi])
+fi
+AC_SUBST(LIBGLADE_CANVAS_CFLAGS)
+AC_SUBST(LIBGLADE_CANVAS_LIBS)
+AM_CONDITIONAL(BUILD_CANVAS, $build_canvas)
+if $build_canvas; then
+    AC_DEFINE(WITH_CANVAS)
 fi
 
 AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)
Index: libglade-convert
===================================================================
RCS file: /cvs/gnome/libglade/libglade-convert,v
retrieving revision 1.21
diff -u -r1.21 libglade-convert
--- libglade-convert	2001/10/22 02:51:33	1.21
+++ libglade-convert	2001/10/23 18:32:26
@@ -293,6 +293,7 @@
                    ('ok_if_empty', 'allow_empty') ],
     'GnomeFileEntry' : [ ( 'directory', 'directory_entry' ) ],
     'GtkLabel' : [ ('default_focus_target', 'mnemonic_widget') ],
+    'GtkCList' : [ ('columns', 'n_columns' ) ],
 }
 
 # child properties to change on specific widgets
@@ -386,17 +387,90 @@
 
     return label
 
+stock_pixmaps = {
+    'REVERT':      'gtk-revert-to-saved',
+    'SCORES':      'gnome-stock-scores',
+    'SEARCH':      'gtk-find',
+    'SEARCHRPL':   'gtk-find-and-replace',
+    'BACK':        'gtk-go-back',
+    'FORWARD':     'gtk-go-forward',
+    'FIRST':       'gtk-goto-first',
+    'LAST':        'gtk-goto-last',
+    'TIMER':       'gnome-stock-timer',
+    'TIMER_STOP':  'gnome-stock-timer-stop',
+    'MAIL':        'gnome-stock-mail',
+    'MAIL_RCV':    'gnome-stock-mail-rcv',
+    'MAIL_SND':    'gnome-stock-mail-send',
+    'MAIL_RPL':    'gnome-stock-mail-rply',
+    'MAIL_FWD':    'gnome-stock-mail-fwd',
+    'MAIL_NEW':    'gnome-stock-mail-new',
+    'TRASH':       'gnome-stock-trash',
+    'TRASH_FULL':  'gnome-stock-trash-full',
+    'SPELLCHECK':  'gtk-spell-check',
+    'MIC':         'gnome-stock-mic',
+    'LINE_IN':     'gnome-stock-line-in',
+    'VOLUME':      'gnome-stock-volume',
+    'MIDI':        'gnome-stock-midi',
+    'BOOK_RED':    'gnome-stock-book-red',
+    'BOOK_GREEN':  'gnome-stock-book-green',
+    'BOOK_BLUE':   'gnome-stock-book-blue',
+    'BOOK_YELLOW': 'gnome-stock-book-yellow',
+    'BOOK_OPEN':   'gnome-stock-book-open',
+    'ABOUT':       'gnome-stock-about',
+    'MULTIPLE':    'gnome-stock-multiple-file',
+    'NOT':         'gnome-stock-not',
+    'UP':          'gtk-go-up',
+    'DOWN':        'gtk-go-down',
+    'TOP':         'gtk-goto-top',
+    'BOTTOM':      'gtk-goto-bottom',
+    'ATTACH':      'gnome-stock-attach',
+    'FONT':        'gtk-select-font',
+    'EXEC':        'gtk-execute',
+
+    'ALIGN_LEFT':    'gtk-justify-left',
+    'ALIGN_RIGHT':   'gtk-justify-right',
+    'ALIGN_CENTER':  'gtk-justify-center',
+    'ALIGN_JUSTIFY': 'gtk-justify-fill',
+
+    'TEXT_BOLD':      'gtk-bold',
+    'TEXT_ITALIC':    'gtk-italic',
+    'TEXT_UNDERLINE': 'gtk-underline',
+    'TEXT_STRIKEOUT': 'gtk-strikethrough',
+
+    'TEXT_INDENT':    'gnome-stock-text-indent',
+    'TEXT_UNINDENT':  'gnome-stock-text-unindent',
+    'EXIT':           'gtk-quit',
+    'COLORSELECTOR':  'gtk-select-color',
+
+    'TABLE_BORDERS':  'gnome-stock-table-borders',
+    'TABLE_FILL':     'gnome-stock-table-fill',
+
+    'TEXT_BULLETED_LIST': 'gnome-stock-text-bulleted-list',
+    'TEXT_NUMBERED_LIST': 'gnome-stock-text-numbered-list',
+
+    'NEXT': 'gtk-go-forward',
+    'PREV': 'gtk-go-back'
+    }
+
 def stock_icon_translate(old_name):
     if re.match ('GNOME_STOCK_MENU_.*', old_name):
-        name = re.sub('GNOME_STOCK_MENU_', 'gtk-', old_name)
-        return name.lower ()
+        name = re.sub('GNOME_STOCK_MENU_', '', old_name, 1)
+        try:
+            return stock_pixmaps[name]
+        except KeyError:
+            name = re.sub('_', '-', name)
+            return 'gtk-' + name.lowere ()
     else:
         return old_name
 
 def stock_button_translate(old_name):
     if re.match ('GNOME_STOCK_BUTTON_.*', old_name):
-        name = re.sub('GNOME_STOCK_BUTTON_', 'gtk-', old_name)
-        return name.lower ()
+        name = re.sub('GNOME_STOCK_BUTTON_', '', old_name)
+        try:
+            return stock_pixmaps[name]
+        except KeyError:
+            name = re.sub('_', '-', name)
+            return 'gtk-' + name.lower ()
     else:
         return old_name
 
@@ -585,11 +659,21 @@
                 list.add_child(listitem)
                 listitem.add_child (new_label ('GtkLabel', item, ''))
 
+    if type == 'GtkCList':
+        for childdef in widget.children:
+            childdef.internal_child = 'title'
+            del childdef.widget['child_name']
+
     if type == 'GtkLabel' or type == 'GtkButton':
         if widget.has_prop('label'):
             if re.match('.*_.*', widget['label']):
                 widget['use_underline'] = 'yes'
 
+    if type == 'GnomeFileEntry':
+        childdef = widget.children[0]
+        childdef.internal_child = 'entry'
+        del childdef.widget['child_name']
+
     if type == 'GnomePropertyBox':
         childdef = widget.children[0]
         childdef.internal_child = 'notebook'
@@ -656,9 +740,13 @@
                 widget.mark_obsolete ()
     except KeyError:
         pass
-    if widget['class'][:5] == 'Gnome' and 'gnome' not in requirelist:
+
+    if widget['class'] == 'GnomeCanvas':
+        if 'canvas' not in requirelist:
+            requirelist.append('canvas')
+    elif widget['class'][:5] == 'Gnome' and 'gnome' not in requirelist:
         requirelist.append('gnome')
-    if widget['class'][:6] == 'Bonobo' and 'bonobo' not in requirelist:
+    elif widget['class'][:6] == 'Bonobo' and 'bonobo' not in requirelist:
         requirelist.append('bonobo')
 
     for childdef in widget.children:
Index: glade/Makefile.am
===================================================================
RCS file: /cvs/gnome/libglade/glade/Makefile.am,v
retrieving revision 1.43
diff -u -r1.43 Makefile.am
--- glade/Makefile.am	2001/10/19 02:28:41	1.43
+++ glade/Makefile.am	2001/10/23 18:32:26
@@ -18,12 +18,17 @@
 if BUILD_BONOBO
 bonobo_la = bonobo.la
 endif
+
 if BUILD_GNOME
 gnome_la = gnome.la
 endif
 
+if BUILD_CANVAS
+canvas_la = canvas.la
+endif
+
 lib_LTLIBRARIES = libglade-2.0.la
-glademodule_LTLIBRARIES = $(bonobo_la) $(gnome_la)
+glademodule_LTLIBRARIES = $(bonobo_la) $(gnome_la) $(canvas_la)
 
 gladeincludedir      = $(includedir)/libglade-2.0/glade
 gladeinclude_HEADERS = \
@@ -51,6 +56,10 @@
 gnome_la_SOURCES = glade-gnome.c
 gnome_la_LIBADD = libglade-2.0.la $(LIBGLADE_GNOME_LIBS)
 gnome_la_LDFLAGS = -export-dynamic -module -avoid-version
+
+canvas_la_SOURCES = glade-canvas.c
+canvas_la_LIBADD = libglade-2.0.la $(LIBGLADE_CANVAS_LIBS)
+canvas_la_LDFLAGS = -export-dynamic -module -avoid-version
 
 EXTRA_DIST = $(gladeinclude_HEADERS) \
 	makefile.mingw	\
Index: glade/glade-gnome.c
===================================================================
RCS file: /cvs/gnome/libglade/glade/glade-gnome.c,v
retrieving revision 1.47
diff -u -r1.47 glade-gnome.c
--- glade/glade-gnome.c	2001/10/19 02:28:41	1.47
+++ glade/glade-gnome.c	2001/10/23 18:32:26
@@ -55,6 +55,19 @@
 entry_find_internal_child(GladeXML *xml, GtkWidget *parent,
 			  const gchar *childname)
 {
+    if (!strcmp (childname, "entry"))
+	return gnome_entry_gtk_entry (GNOME_ENTRY (parent));
+
+    return NULL;
+}
+
+static GtkWidget *
+file_entry_find_internal_chid(GladeXML *xml, GtkWidget *parent,
+			      const gchar *childname)
+{
+    if (!strcmp (childname, "entry"))
+	return gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (parent));
+
     return NULL;
 }
 
@@ -103,8 +116,8 @@
       gnome_druid_page_standard_get_type, 0, druidpagestandard_find_internal_child },
     { "GnomeEntry", glade_standard_build_widget, glade_standard_build_children,
       gnome_entry_get_type, 0, entry_find_internal_child },
-    { "GnomeFileEntry", glade_standard_build_widget, NULL,
-      gnome_file_entry_get_type },
+    { "GnomeFileEntry", glade_standard_build_widget, glade_standard_build_children,
+      gnome_file_entry_get_type, 0, file_entry_find_internal_chid },
     { "GnomeHRef", glade_standard_build_widget, NULL,
       gnome_href_get_type },
     { "GnomeIconEntry", glade_standard_build_widget, NULL,
Index: glade/glade-gtk.c
===================================================================
RCS file: /cvs/gnome/libglade/glade/glade-gtk.c,v
retrieving revision 1.70
diff -u -r1.70 glade-gtk.c
--- glade/glade-gtk.c	2001/10/19 02:28:41	1.70
+++ glade/glade-gtk.c	2001/10/23 18:32:26
@@ -22,9 +22,13 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include <ctype.h>
 #include <glade/glade.h>
 #include <glade/glade-build.h>
 #include <glade/glade-private.h>
+
+/* for GtkText et all */
+#define GTK_ENABLE_BROKEN
 #include <gtk/gtk.h>
 
 void _glade_init_gtk_widgets(void);
@@ -143,6 +147,181 @@
 }
 
 static GtkWidget *
+clist_new (GladeXML *xml, GType widget_type,
+	   GladeWidgetInfo *info)
+{
+    GtkWidget *clist;
+    int cols = 1;
+    int i;
+
+    const char *name, *value;
+
+    static GArray *props_array = NULL;
+    GObjectClass *oclass;
+    GList *deferred_props = NULL, *tmp;
+
+    /* "fake" properties */
+    const char *column_widths = NULL;
+    GtkSelectionMode selection_mode = GTK_SELECTION_SINGLE;
+    GtkShadowType shadow_type = GTK_SHADOW_IN;
+    gboolean show_titles = TRUE;
+
+    if (!props_array)
+	props_array = g_array_new(FALSE, FALSE, sizeof(GParameter));
+
+    /* we ref the class here as a slight optimisation */
+    oclass = g_type_class_ref(widget_type);
+
+    /* collect properties */
+    for (i = 0; i < info->n_properties; i++) {
+	GParameter param = { NULL };
+	GParamSpec *pspec;
+
+	pspec = g_object_class_find_property(oclass, info->properties[i].name);
+
+	name = info->properties[i].name;
+	value = info->properties[i].value;
+
+	if (!pspec) {
+	    switch (name[0]) {
+	    case 'c':
+		if (!strcmp (name, "column_widths")) {
+		    column_widths = g_strdup (value);
+		    continue;
+		} else 	if (!strcmp (name, "columns")) {
+		    g_warning ("columns!");
+		    cols = strtol (value, NULL, 0);
+		    continue;
+		}
+		break;
+	    case 's':
+		if (!strcmp (name, "selection_mode")) {
+		    selection_mode = glade_enum_from_string (
+			GTK_TYPE_SELECTION_MODE, value);
+		    continue;
+		} else if (!strcmp (name, "shadow_type")) {
+		    shadow_type = glade_enum_from_string (
+			GTK_TYPE_SHADOW_TYPE, value);
+		    continue;
+		} else if (!strcmp (name, "show_titles")) {
+		    show_titles = 
+			(tolower(value[0]) == 't' || tolower(value[0]) == 'y' || atoi(value));
+		    continue;
+		}
+		break;
+	    }
+
+	    g_warning("unknown property `%s' for class `%s'",
+		      info->properties[i].name, g_type_name(widget_type));
+	    continue;
+	}
+
+	/* this should catch all properties wanting a GtkWidget
+         * subclass.  We also look for types that could hold a
+         * GtkWidget in order to catch things like the
+         * GtkAccelLabel::accel_object property.  Since we don't do
+         * any handling of GObject or GtkObject directly in
+         * glade_xml_set_value_from_string, this shouldn't be a
+         * problem. */
+	if (g_type_is_a(GTK_TYPE_WIDGET, G_PARAM_SPEC_VALUE_TYPE(pspec)) ||
+	    g_type_is_a(G_PARAM_SPEC_VALUE_TYPE(pspec), GTK_TYPE_WIDGET)) {
+	    deferred_props = g_list_prepend(deferred_props,
+					    &info->properties[i]);
+	    continue;
+	}
+
+	if (glade_xml_set_value_from_string(xml, pspec,
+					    info->properties[i].value,
+					    &param.value)) {
+	    param.name = info->properties[i].name;
+	    g_array_append_val(props_array, param);
+	}
+    }
+
+    clist = g_object_newv(widget_type, props_array->len,
+			   (GParameter *)props_array->data);
+
+    /* clean up props_array */
+    for (i = 0; i < props_array->len; i++) {
+	g_array_index(props_array, GParameter, i).name = NULL;
+	g_value_unset(&g_array_index(props_array, GParameter, i).value);
+    }
+
+    if (column_widths) {
+	const char *pos = column_widths;
+	while (pos && *pos) {
+	    int width = strtol (pos, &pos, 0);
+	    if (*pos == ',') pos++;
+	    gtk_clist_set_column_width (GTK_CLIST (clist), cols++, width);
+	}
+    }
+
+    gtk_clist_set_selection_mode (GTK_CLIST (clist), selection_mode);
+    gtk_clist_set_shadow_type (GTK_CLIST (clist), shadow_type);
+
+    if (show_titles)
+	gtk_clist_column_titles_show (GTK_CLIST (clist));
+    else
+	gtk_clist_column_titles_hide (GTK_CLIST (clist));
+
+    /* handle deferred properties */
+    for (tmp = deferred_props; tmp; tmp = tmp->next) {
+	GladeProperty *prop = tmp->data;
+
+	glade_xml_handle_widget_prop(xml, clist, prop->name, prop->value);
+    }
+    g_list_free(tmp);
+
+    g_array_set_size(props_array, 0);
+    g_type_class_unref(oclass);
+
+    return clist;
+}
+
+static void
+clist_build_children(GladeXML *self, GtkWidget *parent,
+		     GladeWidgetInfo *info)
+{
+    int i;
+
+    g_object_ref (G_OBJECT (parent));
+    for (i = 0; i < info->n_children; i++) {
+	GladeWidgetInfo *childinfo;
+	GtkWidget *child = NULL;
+
+	childinfo = info->children[i].child;
+
+	/* treat GtkLabels specially */
+	if (!strcmp (childinfo->class, "GtkLabel")) {
+	    int j;
+	    const char *label = NULL;
+
+	    for (j = 0; j < childinfo->n_properties; j++) {
+		if (!strcmp (childinfo->properties[j].name, "label")) {
+		    label = childinfo->properties[j].value;
+		    break;
+		}
+	    }
+
+	    if (label) {
+		/* FIXME: translate ? */
+		gtk_clist_set_column_title (GTK_CLIST(parent), i, label);
+		child = gtk_clist_get_column_widget (GTK_CLIST (parent), i);
+		child = GTK_BIN(child)->child;
+		glade_xml_set_common_params(self, child, childinfo);
+	    }
+	}
+
+	if (!child) {
+	    child = glade_xml_build_widget (self, childinfo);
+	    gtk_clist_set_column_widget (GTK_CLIST (parent), i, child);
+	}
+    }
+
+    g_object_unref (G_OBJECT (parent));
+}
+
+static GtkWidget *
 build_button(GladeXML *xml, GType widget_type,
 	     GladeWidgetInfo *info)
 {
@@ -308,7 +487,7 @@
       gtk_check_button_get_type },
     { "GtkCheckMenuItem", glade_standard_build_widget, menuitem_build_children,
       gtk_check_menu_item_get_type },
-    { "GtkCList", glade_standard_build_widget, glade_standard_build_children,
+    { "GtkCList", clist_new, clist_build_children,
       gtk_clist_get_type },
     { "GtkColorSelection", glade_standard_build_widget, NULL,
       gtk_color_selection_get_type },
@@ -316,7 +495,7 @@
       gtk_color_selection_dialog_get_type, 0, colorseldlg_find_internal_child },
     { "GtkCombo", glade_standard_build_widget, glade_standard_build_children,
       gtk_combo_get_type, 0, combo_find_internal_child },
-    { "GtkCTree", glade_standard_build_widget, glade_standard_build_children,
+    { "GtkCTree", clist_new, clist_build_children,
       gtk_ctree_get_type },
     { "GtkCurve", glade_standard_build_widget, NULL,
       gtk_curve_get_type },
@@ -410,6 +589,8 @@
       gtk_table_get_type },
     { "GtkTearoffMenuItem", glade_standard_build_widget, NULL,
       gtk_tearoff_menu_item_get_type },
+    { "GtkText", glade_standard_build_widget, NULL,
+      gtk_text_get_type },
     { "GtkTextView", glade_standard_build_widget, NULL,
       gtk_text_view_get_type },
     { "GtkTipsQuery", glade_standard_build_widget, NULL,
@@ -418,6 +599,8 @@
       gtk_toggle_button_get_type },
     { "GtkToolbar", glade_standard_build_widget, glade_standard_build_children,
       gtk_toolbar_get_type },
+    { "GtkTree", glade_standard_build_widget, NULL,
+      gtk_tree_get_type },
     { "GtkTreeView", glade_standard_build_widget, NULL,
       gtk_tree_view_get_type },
     { "GtkVButtonBox", glade_standard_build_widget, glade_standard_build_children,


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