Re: libglade custom properties
- From: jacob berkman <jacob ximian com>
- To: James Henstridge <james daa com au>
- Cc: gnome-2-0 <gnome-2-0-list gnome org>
- Subject: Re: libglade custom properties
- Date: 26 Nov 2001 18:14:46 -0500
On Thu, 2001-11-22 at 22:57, James Henstridge wrote:
> Hi Jacob,
>
> Sorry for not getting round to going over your patch earlier. I ended
> up with a slightly different API to your suggestion. The API in CVS now is:
>
> typedef void (* GladeApplyCustomPropFunc)(GladeXML *xml,
> GtkWidget *widget,
> const gchar *propname,
> const gchar *value);
> As an example of its use, I added the following code to glade-gtk.c, so
> that tooltips work in libglade again:
>
> static void
> set_tooltip(GladeXML *xml, GtkWidget *widget,
> const gchar *prop_name, const gchar *prop_value)
> {
> gtk_tooltips_set_tip(xml->priv->tooltips, widget, prop_value, NULL);
> }
this is fairly evil, as it uses glade-private.h. libglade support in
other libraries cannot touch this, so it's not really fair to allow
glade-gtk.c to.
> Does this API cover what you needed? Again, sorry for being a bit
> unresponsive about your patch.
for gtk, yes, although the calendar stuff is a bit poor. i'll be
getting to the other libraries shortly.
anyway, here is my patch to fixup gtk support in glade. it also adds
Custom widget support - did you have other plans for implementing it?
also i'm throwing in my current libglade-convert diff.
i also have some other changes to the check programs, but you need a
patch against gtk for it to pass, so i'll leave that out for now.
jacob
--
"In fact, can you imagine anything more terrifying than a zombie clown?"
-- moby
? glade-xml.c.mine
? group
Index: glade-gtk.c
===================================================================
RCS file: /cvs/gnome/libglade/glade/glade-gtk.c,v
retrieving revision 1.76
diff -u -r1.76 glade-gtk.c
--- glade-gtk.c 2001/11/23 03:45:05 1.76
+++ glade-gtk.c 2001/11/26 23:13:33
@@ -22,7 +22,6 @@
#include <string.h>
#include <stdlib.h>
-#include <ctype.h>
#include <glade/glade.h>
#include <glade/glade-build.h>
#include <glade/glade-private.h>
@@ -40,6 +39,222 @@
gtk_tooltips_set_tip(xml->priv->tooltips, widget, prop_value, NULL);
}
+static void
+pixmap_set_build_insensitive (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ gtk_pixmap_set_build_insensitive (GTK_PIXMAP (w),
+ *value == 'T' || *value == 'y');
+}
+
+static void
+pixmap_set_filename (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ GdkPixbuf *pb;
+ char *file;
+ GdkPixmap *pixmap = NULL;
+ GdkBitmap *bitmap = NULL;
+
+ file = glade_xml_relative_file (xml, value);
+ pb = gdk_pixbuf_new_from_file (file, NULL);
+ g_free (file);
+
+ if (!pb)
+ return;
+
+ gdk_pixbuf_render_pixmap_and_mask (pb, &pixmap, &bitmap, 127);
+ gtk_pixmap_set (GTK_PIXMAP (w), pixmap, bitmap);
+
+ if (pixmap) gdk_pixmap_unref (pixmap);
+ if (bitmap) gdk_bitmap_unref (bitmap);
+
+ gdk_pixbuf_unref (pb);
+}
+
+static void
+progress_set_format (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ gtk_progress_set_format_string (GTK_PROGRESS (w), value);
+}
+
+static void
+option_menu_set_history (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ gtk_option_menu_set_history (GTK_OPTION_MENU (w),
+ strtol (value, NULL, 10));
+}
+
+static void
+text_view_set_text (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ GtkTextBuffer *buffy;
+
+ buffy = gtk_text_buffer_new (NULL);
+ gtk_text_buffer_set_text (buffy, value, strlen (value));
+ gtk_text_view_set_buffer (GTK_TEXT_VIEW (w), buffy);
+ g_object_unref (G_OBJECT (buffy));
+}
+
+static void
+calendar_display_options (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ GtkCalendarDisplayOptions options;
+ GtkCalendarDisplayOptions new_options;
+
+ if (!strcmp (name, "show_heading")) {
+ options = GTK_CALENDAR_SHOW_HEADING;
+ } else if (!strcmp (name, "show_day_names")) {
+ options = GTK_CALENDAR_SHOW_DAY_NAMES;
+ } else if (!strcmp (name, "no_month_change")) {
+ options = GTK_CALENDAR_NO_MONTH_CHANGE;
+ } else if (!strcmp (name, "show_week_numbers")) {
+ options = GTK_CALENDAR_SHOW_WEEK_NUMBERS;
+ } else if (!strcmp (name, "week_start_monday")) {
+ options = GTK_CALENDAR_WEEK_START_MONDAY;
+ } else {
+ g_warning ("Unknown calendar option \"%s\".", name);
+ return;
+ }
+
+ new_options = GTK_CALENDAR (w)->display_flags;
+
+ if (*value == 'T' || *value == 'y')
+ new_options |= options;
+ else
+ new_options &= ~options;
+
+ gtk_calendar_display_options (GTK_CALENDAR (w), new_options);
+}
+
+static void
+clist_set_column_widths (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ char *pos = (char *)value;
+ int cols = 0;
+ while (pos && *pos) {
+ int width = strtol (pos, &pos, 10);
+ if (*pos == ',') pos++;
+ gtk_clist_set_column_width (GTK_CLIST (w), cols++, width);
+ }
+}
+
+static void
+clist_set_selection_mode (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ gtk_clist_set_selection_mode (
+ GTK_CLIST (w),
+ glade_enum_from_string (GTK_TYPE_SELECTION_MODE,
+ value));
+}
+
+static void
+clist_set_shadow_type (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ gtk_clist_set_shadow_type (
+ GTK_CLIST (w),
+ glade_enum_from_string (GTK_TYPE_SHADOW_TYPE,
+ value));
+}
+
+static void
+clist_set_show_titles (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ if (*value == 'T' || *value == 'y')
+ gtk_clist_column_titles_show (GTK_CLIST (w));
+ else
+ gtk_clist_column_titles_hide (GTK_CLIST (w));
+}
+
+static void
+tree_set_selection_mode (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ gtk_tree_set_selection_mode (
+ GTK_TREE (w),
+ glade_enum_from_string (GTK_TYPE_SELECTION_MODE, value));
+}
+
+static void
+tree_set_view_mode (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ gtk_tree_set_view_mode (
+ GTK_TREE (w),
+ glade_enum_from_string (GTK_TYPE_TREE_VIEW_MODE, value));
+}
+
+static void
+tree_set_view_line (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ gtk_tree_set_view_lines (GTK_TREE (w), *value == 'T' || *value == 'y');
+}
+
+static void
+list_set_selection_mode (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ gtk_list_set_selection_mode (
+ GTK_LIST (w),
+ glade_enum_from_string (GTK_TYPE_SELECTION_MODE, value));
+}
+
+static void
+check_menu_item_set_always_show_toggle (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (w),
+ *value == 'T' || *value == 'y');
+}
+
+static void
+text_set_text (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ int pos = 0;
+
+ gtk_editable_insert_text (GTK_EDITABLE (w), value, -1, &pos);
+}
+
+static void
+radio_menu_item_set_group (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ GtkWidget *group;
+
+ group = glade_xml_get_widget (xml, value);
+ if (!group) {
+ g_warning ("Radio button group %s could not be found", value);
+ return;
+ }
+
+ if (group == w) {
+ g_message ("Group is self, skipping.");
+ return;
+ }
+
+ gtk_radio_menu_item_set_group (
+ GTK_RADIO_MENU_ITEM (w),
+ gtk_radio_menu_item_get_group (
+ GTK_RADIO_MENU_ITEM (group)));
+}
+
+static void
+toolbar_set_tooltips (GladeXML *xml, GtkWidget *w,
+ const char *name, const char *value)
+{
+ gtk_toolbar_set_tooltips (GTK_TOOLBAR (w), *value == 'T' || *value == 'y');
+}
+
static GtkWidget *
build_window(GladeXML *xml, GType widget_type, GladeWidgetInfo *info)
{
@@ -154,148 +369,30 @@
}
static GtkWidget *
-build_progress (GladeXML *xml, GType widget_type,
- GladeWidgetInfo *info)
+build_preview (GladeXML *xml, GType widget_type,
+ GladeWidgetInfo *info)
{
- GtkWidget *pbar;
- char *format = NULL;
- int i;
+ GtkWidget *preview;
- for (i = 0; i < info->n_properties; i++) {
- if (!strcmp (info->properties[i].name, "format")) {
- format = info->properties[i].value;
- break;
- }
- }
-
- g_message ("ignore warnings about the following: format");
-
- pbar = glade_standard_build_widget (xml, widget_type, info);
-
- if (format && *format)
- gtk_progress_set_format_string (GTK_PROGRESS (pbar), format);
-
- return pbar;
-}
+ GtkPreviewType type = GTK_PREVIEW_COLOR;
+ gboolean expand = TRUE;
-static GtkWidget *
-build_option_menu (GladeXML *xml, GType widget_type,
- GladeWidgetInfo *info)
-{
- GtkWidget *option_menu;
- int i, history = 0;
-
- for (i = 0; i < info->n_properties; i++) {
- if (!strcmp (info->properties[i].name, "history")) {
- history = strtol (info->properties[i].value, NULL, 10);
- break;
- }
- }
-
- g_message ("ignore warnings about the following: history");
-
- option_menu = glade_standard_build_widget (xml, widget_type, info);
-
- if (history)
- gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), history);
-
- return option_menu;
-}
-
-static GtkWidget *
-build_text_view (GladeXML *xml, GType widget_type,
- GladeWidgetInfo *info)
-{
- GtkWidget *text_view;
- char *text = NULL;
int i;
for (i = 0; i < info->n_properties; i++) {
- if (!strcmp (info->properties[i].name, "text")) {
- text = info->properties[i].value;
- break;
- }
- }
+ const char *name = info->properties[i].name;
+ const char *value = info->properties[i].value;
- g_message ("ignore warnings about the following: text");
-
- text_view = glade_standard_build_widget (xml, widget_type, info);
-
- if (text && *text) {
- GtkTextBuffer *buffy;
-
- buffy = gtk_text_buffer_new (NULL);
- gtk_text_buffer_set_text (buffy, text, strlen (text));
- gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), buffy);
- g_object_unref (G_OBJECT (buffy));
- }
-
- return text_view;
-}
-
-static GtkWidget *
-build_clist (GladeXML *xml, GType widget_type,
- GladeWidgetInfo *info)
-{
- GtkWidget *clist;
- int cols = 1;
- int i;
-
- const char *name, *value;
-
- /* "fake" properties */
- char *column_widths = NULL;
- GtkSelectionMode selection_mode = GTK_SELECTION_SINGLE;
- GtkShadowType shadow_type = GTK_SHADOW_IN;
- gboolean show_titles = TRUE;
-
- /* collect our custom properties */
- for (i = 0; i < info->n_properties; i++) {
- name = info->properties[i].name;
- value = info->properties[i].value;
-
- if (!strcmp (name, "column_widths"))
- column_widths = g_strdup (value);
-
- else if (!strcmp (name, "columns"))
- cols = strtol (value, NULL, 0);
-
- else if (!strcmp (name, "selection_mode"))
- selection_mode = glade_enum_from_string (
- GTK_TYPE_SELECTION_MODE, value);
-
- else if (!strcmp (name, "shadow_type"))
- shadow_type = glade_enum_from_string (
- GTK_TYPE_SHADOW_TYPE, value);
-
- else if (!strcmp (name, "show_titles"))
- show_titles =
- (tolower(value[0]) == 't' || tolower(value[0]) == 'y' || atoi(value));
+ if (!strcmp (name, "expand"))
+ expand = (*value == 'T' || *value == 'y');
+ else if (!strcmp (name, "type"))
+ type = glade_enum_from_string (GTK_TYPE_PREVIEW_TYPE, value);
}
-
- g_message ("ignore warnings about the following: column_widths, columns, selection_mode, shadow_type, show_titles");
- clist = glade_standard_build_widget (xml, widget_type, info);
-
- if (column_widths) {
- 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);
- }
- g_free (column_widths);
- }
+ preview = gtk_preview_new (type);
+ gtk_preview_set_expand (GTK_PREVIEW (preview), expand);
- 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));
-
- return clist;
+ return preview;
}
static void
@@ -320,6 +417,8 @@
if (!strcmp (childinfo->properties[j].name, "label")) {
label = childinfo->properties[j].value;
break;
+ } else {
+ g_warning ("Unknown CList child property: %s", childinfo->properties[j].name);
}
}
@@ -341,6 +440,154 @@
g_object_unref (G_OBJECT (parent));
}
+static void
+toolbar_build_children (GladeXML *xml, GtkWidget *parent,
+ GladeWidgetInfo *info)
+{
+ int i;
+
+ g_object_ref (G_OBJECT (parent));
+
+ for (i = 0; i < info->n_children; i++) {
+ GladeChildInfo *childinfo;
+ GtkWidget *child = NULL;
+
+ childinfo = &info->children[i];
+
+ if (!strcmp (childinfo->child->class, "toggle") ||
+ !strcmp (childinfo->child->class, "radio") ||
+ !strcmp (childinfo->child->class, "button")) {
+ const char *label = NULL, *stock = NULL, *group_name = NULL;
+ char *icon = NULL;
+ gboolean active = FALSE, new_group = FALSE;
+ GtkWidget *iconw = NULL;
+ int j;
+
+ for (j = 0; j < childinfo->child->n_properties; j++) {
+ const char *name = childinfo->child->properties[j].name;
+ const char *value = childinfo->child->properties[j].value;
+
+ if (!strcmp (name, "label")) {
+ label = value;
+ } else if (!strcmp (name, "icon")) {
+ g_free (icon);
+ stock = NULL;
+ icon = glade_xml_relative_file (xml, value);
+ } else if (!strcmp (name, "stock_pixmap")) {
+ g_free (icon);
+ icon = NULL;
+ stock = value;
+ } else if (!strcmp (name, "active")) {
+ active = (*value == 'T' || *value == 'y');
+ } else if (!strcmp (name, "group")) {
+ group_name = value;
+ } else if (!strcmp (name, "new_group")) {
+ new_group = (*value == 'T' || *value == 'y');
+ } else if (!strcmp (name, "visible")) {
+ /* ignore for now */
+ } else {
+ g_warning ("Unknown GtkToolbar child property: %s", name);
+ }
+ }
+
+ if (stock) {
+ iconw = gtk_image_new_from_stock (
+ stock, GTK_TOOLBAR (parent)->icon_size);
+ if (!iconw)
+ g_warning ("Could not create stock item: %s", stock);
+ } else if (icon) {
+ iconw = gtk_image_new_from_file (icon);
+ }
+
+ if (iconw)
+ gtk_widget_show (iconw);
+
+ if (new_group)
+ gtk_toolbar_append_space (GTK_TOOLBAR (parent));
+
+ /* FIXME: these should be translated */
+ if (!strcmp (childinfo->child->class, "toggle")) {
+ child = gtk_toolbar_append_element (
+ GTK_TOOLBAR (parent),
+ GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL,
+ label, NULL, NULL, iconw, NULL, NULL);
+ gtk_toggle_button_set_active(
+ GTK_TOGGLE_BUTTON (child), active);
+ } else if (!strcmp (childinfo->child->class, "radio")) {
+ child = gtk_toolbar_append_element (
+ GTK_TOOLBAR (parent),
+ GTK_TOOLBAR_CHILD_RADIOBUTTON, NULL,
+ label, NULL, NULL, iconw, NULL, NULL);
+
+ if (group_name) {
+ g_object_set (G_OBJECT (child),
+ "group", glade_xml_get_widget (xml, group_name),
+ NULL);
+ }
+ } else
+ child = gtk_toolbar_append_item (
+ GTK_TOOLBAR (parent),
+ label, NULL, NULL, iconw, NULL, NULL);
+
+ glade_xml_set_common_params (xml, child, childinfo->child);
+ } else {
+ child = glade_xml_build_widget (xml, childinfo->child);
+ gtk_toolbar_append_widget (GTK_TOOLBAR (parent), child, NULL, NULL);
+ }
+ }
+}
+
+static void
+paned_build_children (GladeXML *xml, GtkWidget *w, GladeWidgetInfo *info)
+{
+ int i;
+ GtkWidget *child;
+ gboolean resize, shrink;
+ GladeChildInfo *cinfo;
+
+ if (info->n_children == 0)
+ return;
+
+ cinfo = &info->children[0];
+ child = glade_xml_build_widget (xml, cinfo->child);
+
+ resize = FALSE; shrink = TRUE;
+ for (i = 0; i < cinfo->n_properties; i++) {
+ const char *name = cinfo->properties[i].name;
+ const char *value = cinfo->properties[i].value;
+
+ if (!strcmp (name, "resize"))
+ resize = (*value == 'T' || *value == 'y');
+ else if (!strcmp (name, "shrink"))
+ shrink = (*value == 'T' || *value == 'y');
+ else
+ g_warning ("Unknown GtkPaned child property: %s", name);
+ }
+
+ gtk_paned_pack1 (GTK_PANED(w), child, resize, shrink);
+
+ if (info->n_children == 1)
+ return;
+
+ cinfo = &info->children[1];
+ child = glade_xml_build_widget (xml, cinfo->child);
+ resize = TRUE; shrink = TRUE;
+
+ for (i = 0; i < cinfo->n_properties; i++) {
+ const char *name = cinfo->properties[i].name;
+ const char *value = cinfo->properties[i].value;
+
+ if (!strcmp (name, "resize"))
+ resize = (*value == 'T' || *value == 'y');
+ else if (!strcmp (name, "shrink"))
+ shrink = (*value == 'T' || *value == 'y');
+ else
+ g_warning ("Unknown GtkPaned child property: %s", name);
+ }
+
+ gtk_paned_pack2 (GTK_PANED(w), child, resize, shrink);
+}
+
static GtkWidget *
build_button(GladeXML *xml, GType widget_type,
GladeWidgetInfo *info)
@@ -483,7 +730,7 @@
return GTK_COMBO(parent)->button;
if (!strcmp(childname, "popup"))
return GTK_COMBO(parent)->popup;
- if (!strcmp(childname, "pupwin"))
+ if (!strcmp(childname, "popwin"))
return GTK_COMBO(parent)->popwin;
if (!strcmp(childname, "list"))
return GTK_COMBO(parent)->list;
@@ -494,6 +741,30 @@
_glade_init_gtk_widgets(void)
{
glade_register_custom_prop (GTK_TYPE_WIDGET, "tooltip", set_tooltip);
+ glade_register_custom_prop (GTK_TYPE_PIXMAP, "build_insensitive", pixmap_set_build_insensitive);
+ glade_register_custom_prop (GTK_TYPE_PIXMAP, "filename", pixmap_set_filename);
+ glade_register_custom_prop (GTK_TYPE_PROGRESS, "format", progress_set_format);
+ glade_register_custom_prop (GTK_TYPE_OPTION_MENU, "history", option_menu_set_history);
+ glade_register_custom_prop (GTK_TYPE_TEXT_VIEW, "text", text_view_set_text);
+ glade_register_custom_prop (GTK_TYPE_CALENDAR, "show_heading", calendar_display_options);
+ glade_register_custom_prop (GTK_TYPE_CALENDAR, "show_day_names", calendar_display_options);
+ glade_register_custom_prop (GTK_TYPE_CALENDAR, "no_month_change", calendar_display_options);
+ glade_register_custom_prop (GTK_TYPE_CALENDAR, "show_week_numbers", calendar_display_options);
+ glade_register_custom_prop (GTK_TYPE_CALENDAR, "week_start_monday", calendar_display_options);
+ glade_register_custom_prop (GTK_TYPE_CLIST, "column_widths", clist_set_column_widths);
+ glade_register_custom_prop (GTK_TYPE_CLIST, "selection_mode", clist_set_selection_mode);
+ glade_register_custom_prop (GTK_TYPE_CLIST, "shadow_type", clist_set_shadow_type);
+ glade_register_custom_prop (GTK_TYPE_CLIST, "show_titles", clist_set_show_titles);
+ glade_register_custom_prop (GTK_TYPE_TREE, "selection_mode", tree_set_selection_mode);
+ glade_register_custom_prop (GTK_TYPE_TREE, "view_mode", tree_set_view_mode);
+ glade_register_custom_prop (GTK_TYPE_TREE, "view_line", tree_set_view_line);
+ glade_register_custom_prop (GTK_TYPE_LIST, "selection_mode", list_set_selection_mode);
+ glade_register_custom_prop (GTK_TYPE_CHECK_MENU_ITEM, "always_show_toggle",
+ check_menu_item_set_always_show_toggle);
+ glade_register_custom_prop (GTK_TYPE_TEXT, "text", text_set_text);
+ glade_register_custom_prop (GTK_TYPE_RADIO_MENU_ITEM, "group",
+ radio_menu_item_set_group);
+ glade_register_custom_prop (GTK_TYPE_TOOLBAR, "tooltips", toolbar_set_tooltips);
glade_register_widget (GTK_TYPE_ACCEL_LABEL, glade_standard_build_widget,
NULL, NULL);
@@ -511,7 +782,7 @@
glade_standard_build_children, NULL);
glade_register_widget (GTK_TYPE_CHECK_MENU_ITEM, glade_standard_build_widget,
menuitem_build_children, NULL);
- glade_register_widget (GTK_TYPE_CLIST, build_clist,
+ glade_register_widget (GTK_TYPE_CLIST, glade_standard_build_widget,
clist_build_children, NULL);
glade_register_widget (GTK_TYPE_COLOR_SELECTION, glade_standard_build_widget,
NULL, NULL);
@@ -519,7 +790,7 @@
glade_standard_build_children, colorseldlg_find_internal_child);
glade_register_widget (GTK_TYPE_COMBO, glade_standard_build_widget,
glade_standard_build_children, combo_find_internal_child);
- glade_register_widget (GTK_TYPE_CTREE, build_clist,
+ glade_register_widget (GTK_TYPE_CTREE, glade_standard_build_widget,
clist_build_children, NULL);
glade_register_widget (GTK_TYPE_CURVE, glade_standard_build_widget,
NULL, NULL);
@@ -550,7 +821,7 @@
glade_register_widget (GTK_TYPE_HBOX, glade_standard_build_widget,
glade_standard_build_children, NULL);
glade_register_widget (GTK_TYPE_HPANED, glade_standard_build_widget,
- glade_standard_build_children, NULL);
+ paned_build_children, NULL);
glade_register_widget (GTK_TYPE_HRULER, glade_standard_build_widget,
NULL, NULL);
glade_register_widget (GTK_TYPE_HSCALE, glade_standard_build_widget,
@@ -583,16 +854,18 @@
glade_standard_build_children, NULL);
glade_register_widget (GTK_TYPE_NOTEBOOK, glade_standard_build_widget,
notebook_build_children, NULL);
- glade_register_widget (GTK_TYPE_OPTION_MENU, build_option_menu,
+ glade_register_widget (GTK_TYPE_OPTION_MENU, glade_standard_build_widget,
glade_standard_build_children, option_menu_find_internal_child);
glade_register_widget (GTK_TYPE_PIXMAP, glade_standard_build_widget,
NULL, NULL);
glade_register_widget (GTK_TYPE_PLUG, build_window,
NULL, NULL);
- glade_register_widget (GTK_TYPE_PROGRESS, build_progress,
+ glade_register_widget (GTK_TYPE_PREVIEW, build_preview,
NULL, NULL);
- glade_register_widget (GTK_TYPE_PROGRESS_BAR, build_progress,
+ glade_register_widget (GTK_TYPE_PROGRESS, glade_standard_build_widget,
NULL, NULL);
+ glade_register_widget (GTK_TYPE_PROGRESS_BAR, glade_standard_build_widget,
+ NULL, NULL);
glade_register_widget (GTK_TYPE_RADIO_BUTTON, glade_standard_build_widget,
glade_standard_build_children, NULL);
glade_register_widget (GTK_TYPE_RADIO_MENU_ITEM, glade_standard_build_widget,
@@ -612,14 +885,14 @@
NULL, NULL);
glade_register_widget (GTK_TYPE_TEXT, glade_standard_build_widget,
NULL, NULL);
- glade_register_widget (GTK_TYPE_TEXT_VIEW, build_text_view,
+ glade_register_widget (GTK_TYPE_TEXT_VIEW, glade_standard_build_widget,
NULL, NULL);
glade_register_widget (GTK_TYPE_TIPS_QUERY, glade_standard_build_widget,
NULL, NULL);
glade_register_widget (GTK_TYPE_TOGGLE_BUTTON, glade_standard_build_widget,
glade_standard_build_children, NULL);
glade_register_widget (GTK_TYPE_TOOLBAR, glade_standard_build_widget,
- glade_standard_build_children, NULL);
+ toolbar_build_children, NULL);
glade_register_widget (GTK_TYPE_TREE, glade_standard_build_widget,
NULL, NULL);
glade_register_widget (GTK_TYPE_TREE_VIEW, glade_standard_build_widget,
@@ -629,7 +902,7 @@
glade_register_widget (GTK_TYPE_VBOX, glade_standard_build_widget,
glade_standard_build_children, NULL);
glade_register_widget (GTK_TYPE_VPANED, glade_standard_build_widget,
- glade_standard_build_children, NULL);
+ paned_build_children, NULL);
glade_register_widget (GTK_TYPE_VRULER, glade_standard_build_widget,
NULL, NULL);
glade_register_widget (GTK_TYPE_VSCALE, glade_standard_build_widget,
Index: glade-xml.c
===================================================================
RCS file: /cvs/gnome/libglade/glade/glade-xml.c,v
retrieving revision 1.82
diff -u -r1.82 glade-xml.c
--- glade-xml.c 2001/11/23 03:45:05 1.82
+++ glade-xml.c 2001/11/26 23:13:33
@@ -1067,6 +1067,37 @@
int1, int2, custom_user_data);
}
+static GtkWidget *
+custom_new (GladeXML *xml, GladeWidgetInfo *info)
+{
+ GtkWidget *wid = NULL;
+ gchar *func_name = NULL, *string1 = NULL, *string2 = NULL;
+ gint int1 = 0, int2 = 0;
+ int i;
+
+ for (i = 0; i < info->n_properties; i++) {
+ char *name = info->properties[i].name;
+ char *value = info->properties[i].value;
+
+ if (!strcmp(name, "creation_function"))
+ func_name = value;
+ else if (!strcmp(name, "string1"))
+ string1 = value;
+ else if (!strcmp(name, "string2"))
+ string2 = value;
+ else if (!strcmp(name, "int1"))
+ int1 = strtol(value, NULL, 0);
+ else if (!strcmp(name, "int2"))
+ int2 = strtol(value, NULL, 0);
+ }
+ wid = glade_create_custom(xml, func_name, info->name, string1,
+ string2, int1, int2);
+ /* fallback to prevent segfault */
+ if (wid == NULL)
+ wid = gtk_label_new("[custom widget creation failed]");
+ return wid;
+}
+
/**
* glade_enum_from_string
* @type: the GType for this enum type.
@@ -1823,6 +1854,8 @@
ret = gtk_label_new("[placeholder]");
gtk_widget_show(ret);
return ret;
+ } else if (!strcmp (info->class, "Custom")) {
+ return custom_new (self, info);
}
type = g_type_from_name(info->class);
if (type == G_TYPE_INVALID) {
Index: libglade-convert.in
===================================================================
RCS file: /cvs/gnome/libglade/libglade-convert.in,v
retrieving revision 1.1
diff -u -r1.1 libglade-convert.in
--- libglade-convert.in 2001/11/21 12:29:14 1.1
+++ libglade-convert.in 2001/11/26 23:17:40
@@ -286,10 +286,15 @@
'GtkVRuler': [ 'metric' ],
'GnomeFileEntry' : [ 'max_saved' ],
'GnomeEntry' : [ 'max_saved' ],
+ 'GtkMenuBar' : [ 'shadow_type' ],
+ 'GtkToolbar' : [ 'space_size', 'space_style', 'relief', 'tooltips' ],
+ 'GtkImage' : [ 'image_width', 'image_height', 'image_visual', 'image_type'],
+ 'GtkColorSelection' : [ 'policy' ],
+ 'GtkColorSelectionDialog' : [ 'policy' ],
}
renamed_props = {
- 'GtkWindow': [ ('position', 'window-position') ],
+ 'GtkWindow': [ ('position', 'window-position') ],
'GtkEntry': [ ('text_max_length', 'max-length'),
('text_visible', 'visibility') ],
'GtkFrame': [ ('shadow_type', 'shadow') ],
@@ -304,7 +309,11 @@
'GnomeFileEntry' : [ ( 'directory', 'directory_entry' ) ],
'GtkLabel' : [ ('default_focus_target', 'mnemonic_widget') ],
'GtkCList' : [ ('columns', 'n_columns') ],
- 'GtkCTree' : [ ('columns', 'n_columns') ]
+ 'GtkCTree' : [ ('columns', 'n_columns') ],
+ 'GtkToolbar': [ ('type', 'toolbar-style') ],
+ 'GtkOptionMenu' : [ ('initial_choice', 'history') ],
+ 'GtkLayout' : [ ('area_width', 'width'), ('area_height', 'height') ],
+ 'GtkFileSelection' : [ ('show_file_op_buttons', 'show-fileops') ],
}
# child properties to change on specific widgets
@@ -365,10 +374,14 @@
'GtkCheckMenuItem' : 'GtkMenuItem',
'GtkRadioMenuItem' : 'GtkMenuItem',
'GtkImageMenuItem' : 'GtkMenuItem',
+ 'GtkFileSelection' : 'GtkDialog',
'GtkFontSelectionDialog' : 'GtkDialog',
'GnomeColorPicker' : 'GtkButton',
'GtkToggleButton' : 'GtkButton',
'GtkCheckButton' : 'GtkToggleButton',
+ 'GtkColorSelectionDialog': 'GtkDialog',
+ 'GtkFontSelectionDialog': 'GtkDialog',
+
}
global_group_map = { }
@@ -398,7 +411,7 @@
label['xalign'] = '0.0'
if class_type == 'GtkAccelLabel':
- label['accel-object'] = accel_object
+ label['accel-widget'] = accel_object
label['use-underline'] = 'yes'
return label
@@ -490,6 +503,15 @@
else:
return old_name
+def stock_pixmap_translate(old_name):
+ if re.match ('GNOME_STOCK_PIXMAP_.*', old_name):
+ name = re.sub('GNOME_STOCK_PIXMAP_', '', old_name)
+ try:
+ return stock_pixmaps[name]
+ except KeyError:
+ name = re.sub('_', '-', name)
+ return 'gtk-' + name.lower ()
+
def fixup_as_type(widget, type):
# table based property removals/renames
@@ -571,9 +593,33 @@
del childdef.widget['child_name']
childdef['type'] = 'tab';
else:
- print >> sys.stderr , 'Unknown child_name', \
+ print >> sys.stderr , 'Unknown child_name ' \
childdef.widget['child_name']
+ if type == 'GtkFileSelection':
+ for childdef in widget.children:
+ if childdef.widget.has_prop ('child_name'):
+ if re.match ('FileSel:.*', childdef.widget['child_name']):
+ name = re.sub ('FileSel:', '', childdef.widget['child_name'])
+ del childdef.widget['child_name']
+ childdef.internal_child = name
+
+ if type == 'GtkColorSelectionDialog':
+ for childdef in widget.children:
+ if childdef.widget.has_prop ('child_name'):
+ if re.match ('ColorSel:.*', childdef.widget['child_name']):
+ name = re.sub ('ColorSel:', '', childdef.widget['child_name'])
+ del childdef.widget['child_name']
+ childdef.internal_child = name
+
+ if type == 'GtkFontSelectionDialog':
+ for childdef in widget.children:
+ if childdef.widget.has_prop ('child_name'):
+ if re.match ('FontSel:.*', childdef.widget['child_name']):
+ name = re.sub ('FontSel:', '', childdef.widget['child_name'])
+ del childdef.widget['child_name']
+ childdef.internal_child = name
+
# fix up adjustment properties
if type in ('GtkHScale', 'GtkHScrollbar',
'GtkVScale', 'GtkVScrollbar',
@@ -614,17 +660,18 @@
if type == 'GtkDialog':
childdef = widget.children[0]
- childdef.internal_child = 'vbox'
- del childdef.widget['child_name']
+ if childdef.widget.has_prop ('child_name'):
+ childdef.internal_child = 'vbox'
+ del childdef.widget['child_name']
- try:
- childdef = filter(lambda x: x.widget.has_prop('child_name'),
- childdef.widget.children)[0]
- except IndexError:
- return 0
- childdef.widget['class'] = 'GtkHButtonBox'
- childdef.internal_child = 'action_area'
- del childdef.widget['child_name']
+ try:
+ childdef = filter(lambda x: x.widget.has_prop('child_name'),
+ childdef.widget.children)[0]
+ except IndexError:
+ return 0
+ childdef.widget['class'] = 'GtkHButtonBox'
+ childdef.internal_child = 'action_area'
+ del childdef.widget['child_name']
if type == 'GtkOptionMenu':
if widget.has_prop('items'):
@@ -644,9 +691,7 @@
new_label ('GtkMenuItem', \
item, widget['name']))
del widget['items']
- if widget.has_prop('initial_choice'):
- widget['history'] = widget['initial_choice']
- del widget['initial_choice']
+
if type == 'GtkScrolledWindow':
if widget.has_prop ('hupdate_policy'):
@@ -686,7 +731,7 @@
if type in ('GtkCList', 'GtkCTree'):
for childdef in widget.children:
- childdef.internal_child = 'title'
+ childdef.internal_child = childdef.widget['child_name']
del childdef.widget['child_name']
if type == 'GtkLabel' or type == 'GtkButton':
@@ -721,6 +766,22 @@
global_group_map[widget['group']] = widget['name']
del widget['group']
+ if type == 'GtkToolbar':
+ for childdef in widget.children:
+ if childdef.widget.has_prop('child_name'):
+ if childdef.widget['child_name'] == 'Toolbar:button':
+ if childdef.widget['class'] == 'GtkButton':
+ childdef.widget['class'] = 'button'
+ elif childdef.widget['class'] == 'GtkToggleButton':
+ childdef.widget['class'] = 'toggle'
+ elif childdef.widget['class'] == 'GtkRadioButton':
+ childdef.widget['class'] = 'radio'
+ del childdef.widget['child_name']
+ if childdef.widget.has_prop('stock_pixmap'):
+ name = stock_pixmap_translate (childdef.widget['stock_pixmap'])
+ childdef.widget['stock_pixmap'] = name
+
+
return 0
# upgrade widgets to their gtk/gnome 2.0 equivalents
@@ -749,7 +810,7 @@
if parent['class'] == 'GtkScrolledWindow':
parent['shadow_type'] = 'GTK_SHADOW_IN'
- elif widget['class'] in ('GtkCList', 'GtkCTree'):
+ elif widget['class'] in ('GtkCList', 'GtkCTree', 'GtkList', 'GtkTree'):
widget['class'] = 'GtkTreeView'
parent = widget['parent']
if parent['class'] == 'GtkScrolledWindow':
@@ -759,6 +820,8 @@
widget.remove_prop('columns')
widget.remove_prop('column_widths')
widget.remove_prop('selection_mode')
+ widget.remove_prop('view_mode')
+ widget.remove_prop('view_line')
if do_children:
for childdef in widget.children:
@@ -775,7 +838,8 @@
'GtkPixmap': 'deprecated',
'GnomePixmap': 'deprecated',
'GnomeFontPicker': 'removed',
- 'GtkPixmapMenuItem': 'removed'
+ 'GtkPixmapMenuItem': 'removed',
+ 'GtkPacker': 'removed',
}
def check_widget(widget, requirelist=[]):
try:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]