diff options
author | Tristan Van Berkom <tvb@src.gnome.org> | 2006-10-19 17:15:10 +0000 |
---|---|---|
committer | Tristan Van Berkom <tvb@src.gnome.org> | 2006-10-19 17:15:10 +0000 |
commit | 266771b18bc353a253ef18b223551e8b62f8b19f (patch) | |
tree | e7177866b13bb286a356b774635c0f3d92556d7c | |
parent | 8fddd5af80a3c8c33f8205513563fc094bc93dd4 (diff) | |
download | glade-266771b18bc353a253ef18b223551e8b62f8b19f.tar.gz |
Added glade-widget-adaptor.[ch], removed glade-widget-class.[ch].
Added glade-widget-adaptor.[ch], removed glade-widget-class.[ch].
Modified most sources to cope with the major api change.
44 files changed, 3903 insertions, 3699 deletions
@@ -1,3 +1,25 @@ +2006-10-18 Tristan Van Berkom <tvb@gnome.org> + + * src/Makefile.am src/glade-app.c src/glade-base-editor.c + src/glade-catalog.c src/glade-catalog.h src/glade-clipboard-view.c + src/glade-clipboard.c src/glade-command.c src/glade-command.h + src/glade-cursor.c src/glade-editor-property.c + src/glade-editor.c src/glade-editor.h src/glade-fixed.c + src/glade-fixed.h src/glade-gnome.c src/glade-gtk.c + src/glade-palette-item.c src/glade-palette-item.h + src/glade-palette.c src/glade-palette.h + src/glade-placeholder.c src/glade-popup.c + src/glade-project-view.c src/glade-project.c + src/glade-property-class.c src/glade-property.c + src/glade-property.h src/glade-signal-editor.c + src/glade-signal-editor.h src/glade-signal.h src/glade-utils.c + src/glade-widget.c src/glade-widget.h src/glade.h src/main.c + widgets/bonobo.xml.in widgets/gnome.xml.in widgets/gtk+.xml.in: + + Added glade-widget-adaptor.[ch], removed glade-widget-class.[ch]. + + Modified most sources to cope with the major api change. + 2006-10-18 Vincent Geddes <vincent.geddes@gmail.com> * Makefile.am: Update icon theme cache on uninstall. diff --git a/src/Makefile.am b/src/Makefile.am index f6e47754..99179b43 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,13 +52,13 @@ libgladegtkinclude_HEADERS = glade-gtk.h # The glade-3 core library libgladeui_1_la_SOURCES = \ + glade-widget-adaptor.c \ glade-debug.c \ glade-project.c \ glade-parameter.c \ glade-placeholder.c \ glade-custom.c \ glade-project-view.c \ - glade-widget-class.c \ glade-xml-utils.c \ glade-palette.c \ glade-palette-item.c \ @@ -116,7 +116,7 @@ libgladeuiinclude_HEADERS = \ glade-palette-expander.h \ glade-cursor.h \ glade-widget.h \ - glade-widget-class.h \ + glade-widget-adaptor.h \ glade-property.h \ glade-property-class.h \ glade-popup.h \ diff --git a/src/glade-app.c b/src/glade-app.c index f6baeeb9..e709dcaf 100644 --- a/src/glade-app.c +++ b/src/glade-app.c @@ -35,7 +35,6 @@ #include "glade-clipboard.h" #include "glade-clipboard-view.h" #include "glade-widget.h" -#include "glade-widget-class.h" #include "glade-property.h" #include "glade-property-class.h" #include "glade-project.h" @@ -264,19 +263,19 @@ glade_app_update_ui_default (GladeApp *app) static void on_palette_button_clicked (GladePalette *palette, GladeApp *app) { - GladeWidgetClass *class; - GladeWidget *widget; + GladeWidgetAdaptor *adaptor; + GladeWidget *widget; g_return_if_fail (GLADE_IS_PALETTE (palette)); - class = glade_palette_get_current_item_class (palette); + adaptor = glade_palette_get_current_item (palette); /* class may be NULL if the selector was pressed */ - if (class && class->toplevel) + if (adaptor && GWA_IS_TOPLEVEL (adaptor)) { - widget = glade_command_create (class, NULL, NULL, app->priv->active_project); + widget = glade_command_create (adaptor, NULL, NULL, app->priv->active_project); /* if this is a top level widget set the accel group */ - if (app->priv->accel_group && GTK_IS_WINDOW (widget->object)) + if (widget && app->priv->accel_group && GTK_IS_WINDOW (widget->object)) { gtk_window_add_accel_group (GTK_WINDOW (widget->object), app->priv->accel_group); diff --git a/src/glade-base-editor.c b/src/glade-base-editor.c index 3485fa6a..3a336782 100644 --- a/src/glade-base-editor.c +++ b/src/glade-base-editor.c @@ -211,8 +211,8 @@ glade_base_editor_fill_store_real (GladeBaseEditor *e, GList *children, *l; GtkTreeIter iter; - children = l = glade_widget_class_container_get_children (gwidget->widget_class, - G_OBJECT (widget)); + children = l = glade_widget_adaptor_get_children (gwidget->adaptor, + G_OBJECT (widget)); while (l) { @@ -1057,12 +1057,12 @@ glade_base_editor_change_type (GladeBaseEditor *editor, GType type) { GladeBaseEditorPrivate *e = editor->priv; - GladeWidgetClass *klass = glade_widget_class_get_by_type (type); - GladeWidget *parent, *gchild_new; - GList list = {0, }, *children, *l; - GObject *child, *child_new; - GtkTreeIter iter; - gchar *name, *class_name; + GladeWidgetAdaptor *adaptor = glade_widget_adaptor_get_by_type (type); + GladeWidget *parent, *gchild_new; + GList list = {0, }, *children, *l; + GObject *child, *child_new; + GtkTreeIter iter; + gchar *name, *class_name; if (glade_base_editor_get_type_info (editor, NULL, type, GLADE_BASE_EDITOR_NAME, &class_name, @@ -1075,11 +1075,11 @@ glade_base_editor_change_type (GladeBaseEditor *editor, glade_base_editor_find_child (editor, gchild, &iter); /* Create new widget */ - gchild_new = glade_command_create (klass, parent, NULL, e->project); + gchild_new = glade_command_create (adaptor, parent, NULL, e->project); child_new = glade_widget_get_object (gchild_new); /* Cut and Paste childrens */ - if ((children = glade_widget_class_container_get_children (klass, child))) + if ((children = glade_widget_adaptor_get_children (adaptor, child))) { GList *gchildren = NULL; @@ -1151,7 +1151,7 @@ glade_base_editor_build_child (GladeBaseEditor *editor, GladeWidget *gparent, GType type) { - return glade_command_create (glade_widget_class_get_by_type (type), + return glade_command_create (glade_widget_adaptor_get_by_type (type), gparent, NULL, glade_widget_get_project (gparent)); } diff --git a/src/glade-catalog.c b/src/glade-catalog.c index 66b46826..ec707003 100644 --- a/src/glade-catalog.c +++ b/src/glade-catalog.c @@ -35,7 +35,7 @@ #include "glade.h" #include "glade-catalog.h" -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" typedef void (*GladeCatalogInitFunc) (void); @@ -57,7 +57,7 @@ struct _GladeCatalog */ GList *widget_groups; /* List of widget groups (palette) */ - GList *widget_classes; /* List of widget classes (all) */ + GList *adaptors; /* List of widget class adaptors (all) */ GladeXmlContext *context;/* Xml context is stored after open * before classes are loaded */ @@ -75,7 +75,7 @@ struct _GladeWidgetGroup gboolean expanded; /* Whether group is expanded in the palette */ - GList *widget_classes; /* List of classes in the palette */ + GList *adaptors; /* List of class adaptors in the palette */ }; static void catalog_load (GladeCatalog *catalog); @@ -263,20 +263,19 @@ catalog_load_classes (GladeCatalog *catalog, GladeXmlNode *widgets_node) node = glade_xml_node_get_children (widgets_node); for (; node; node = glade_xml_node_next (node)) { - const gchar *node_name; - GladeWidgetClass *widget_class; + const gchar *node_name; + GladeWidgetAdaptor *adaptor; node_name = glade_xml_node_get_name (node); if (strcmp (node_name, GLADE_TAG_GLADE_WIDGET_CLASS) != 0) continue; - widget_class = glade_widget_class_new + adaptor = glade_widget_adaptor_from_catalog (node, catalog->name, catalog->library, catalog->domain ? catalog->domain : catalog->library, catalog->book); - catalog->widget_classes = g_list_prepend (catalog->widget_classes, - widget_class); + catalog->adaptors = g_list_prepend (catalog->adaptors, adaptor); } return TRUE; @@ -319,38 +318,37 @@ catalog_load_group (GladeCatalog *catalog, GladeXmlNode *group_node) catalog->domain : catalog->library, group->title); - group->widget_classes = NULL; + group->adaptors = NULL; node = glade_xml_node_get_children (group_node); for (; node; node = glade_xml_node_next (node)) { - const gchar *node_name; - GladeWidgetClass *widget_class; - gchar *name; + const gchar *node_name; + GladeWidgetAdaptor *adaptor; + gchar *name; node_name = glade_xml_node_get_name (node); if (strcmp (node_name, GLADE_TAG_GLADE_WIDGET_CLASS_REF) == 0) { - name = glade_xml_get_property_string (node, GLADE_TAG_NAME); - if (!name) + if ((name = + glade_xml_get_property_string (node, GLADE_TAG_NAME)) == NULL) { g_warning ("Couldn't find required property on %s", GLADE_TAG_GLADE_WIDGET_CLASS); continue; } - widget_class = glade_widget_class_get_by_name (name); - if (!widget_class) + if ((adaptor = glade_widget_adaptor_get_by_name (name)) == NULL) { - g_warning ("Tried to include undefined widget class '%s' in a widget group", name); + g_warning ("Tried to include undefined widget " + "class '%s' in a widget group", name); g_free (name); continue; } g_free (name); - group->widget_classes = g_list_prepend (group->widget_classes, - widget_class); + group->adaptors = g_list_prepend (group->adaptors, adaptor); } else if (strcmp (node_name, GLADE_TAG_DEFAULT_PALETTE_STATE) == 0) @@ -361,7 +359,7 @@ catalog_load_group (GladeCatalog *catalog, GladeXmlNode *group_node) } } - group->widget_classes = g_list_reverse (group->widget_classes); + group->adaptors = g_list_reverse (group->adaptors); catalog->widget_groups = g_list_prepend (catalog->widget_groups, group); @@ -378,7 +376,7 @@ widget_group_free (GladeWidgetGroup *group) g_free (group->title); /* The actual widget classes will be free elsewhere */ - g_list_free (group->widget_classes); + g_list_free (group->adaptors); } GList * @@ -459,11 +457,11 @@ glade_catalog_get_widget_groups (GladeCatalog *catalog) } GList * -glade_catalog_get_widget_classes (GladeCatalog *catalog) +glade_catalog_get_adaptors (GladeCatalog *catalog) { g_return_val_if_fail (catalog != NULL, NULL); - return catalog->widget_classes; + return catalog->adaptors; } void @@ -478,10 +476,10 @@ glade_catalog_free (GladeCatalog *catalog) if (catalog->book) g_free (catalog->book); - for (list = catalog->widget_classes; list; list = list->next) - glade_widget_class_free (GLADE_WIDGET_CLASS (list->data)); + for (list = catalog->adaptors; list; list = list->next) + g_object_unref (list->data); - g_list_free (catalog->widget_classes); + g_list_free (catalog->adaptors); for (list = catalog->widget_groups; list; list = list->next) widget_group_free (GLADE_WIDGET_GROUP (list->data)); @@ -516,11 +514,11 @@ glade_widget_group_get_expanded (GladeWidgetGroup *group) } GList * -glade_widget_group_get_widget_classes (GladeWidgetGroup *group) +glade_widget_group_get_adaptors (GladeWidgetGroup *group) { g_return_val_if_fail (group != NULL, NULL); - return group->widget_classes; + return group->adaptors; } gboolean diff --git a/src/glade-catalog.h b/src/glade-catalog.h index f2eccfee..dc944f06 100644 --- a/src/glade-catalog.h +++ b/src/glade-catalog.h @@ -41,7 +41,7 @@ const gchar * glade_catalog_get_name (GladeCatalog *catalog); LIBGLADEUI_API GList * glade_catalog_get_widget_groups (GladeCatalog *catalog); LIBGLADEUI_API -GList * glade_catalog_get_widget_classes (GladeCatalog *catalog); +GList * glade_catalog_get_adaptors (GladeCatalog *catalog); LIBGLADEUI_API void glade_catalog_free (GladeCatalog *catalog); @@ -53,7 +53,7 @@ const gchar * glade_widget_group_get_title (GladeWidgetGroup *group); LIBGLADEUI_API gboolean glade_widget_group_get_expanded (GladeWidgetGroup *group); LIBGLADEUI_API -GList * glade_widget_group_get_widget_classes (GladeWidgetGroup *group); +GList * glade_widget_group_get_adaptors (GladeWidgetGroup *group); LIBGLADEUI_API void glade_widget_group_free (GladeWidgetGroup *group); diff --git a/src/glade-clipboard-view.c b/src/glade-clipboard-view.c index de913b9d..1a775c4d 100644 --- a/src/glade-clipboard-view.c +++ b/src/glade-clipboard-view.c @@ -32,7 +32,7 @@ #include "glade-clipboard.h" #include "glade-clipboard-view.h" #include "glade-widget.h" -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" #include "glade-popup.h" @@ -130,24 +130,28 @@ glade_clipboard_view_cell_function (GtkTreeViewColumn *tree_column, GtkTreeIter *iter, gpointer data) { - gboolean is_icon = GPOINTER_TO_INT (data); + gboolean is_icon = GPOINTER_TO_INT (data); GladeWidget *widget; + GdkPixbuf *pixbuf = NULL; gtk_tree_model_get (tree_model, iter, 0, &widget, -1); g_return_if_fail (GLADE_IS_WIDGET (widget)); g_return_if_fail (widget->name != NULL); - g_return_if_fail (widget->widget_class != NULL); - g_return_if_fail (widget->widget_class->small_icon != NULL); + + g_object_get (widget->adaptor, "small-icon", &pixbuf, NULL); + g_return_if_fail (pixbuf != NULL); if (is_icon) g_object_set (G_OBJECT (cell), - "pixbuf", widget->widget_class->small_icon, + "pixbuf", pixbuf, NULL); else g_object_set (G_OBJECT (cell), "text", widget->name, NULL); + + g_object_unref (pixbuf); } static gint diff --git a/src/glade-clipboard.c b/src/glade-clipboard.c index 407159b5..2b4182d8 100644 --- a/src/glade-clipboard.c +++ b/src/glade-clipboard.c @@ -27,7 +27,6 @@ #include "glade-clipboard-view.h" #include "glade-clipboard.h" #include "glade-widget.h" -#include "glade-widget-class.h" #include "glade-placeholder.h" #include "glade-project.h" diff --git a/src/glade-command.c b/src/glade-command.c index c63943aa..35ae2ca3 100644 --- a/src/glade-command.c +++ b/src/glade-command.c @@ -31,7 +31,6 @@ #include "glade-project.h" #include "glade-xml-utils.h" #include "glade-widget.h" -#include "glade-widget-class.h" #include "glade-palette.h" #include "glade-command.h" #include "glade-property.h" @@ -1139,28 +1138,28 @@ glade_command_delete (GList *widgets) /** * glade_command_create: - * @class: the class of the widget (GtkWindow or GtkButton) + * @adaptor: A #GladeWidgetAdaptor * @placeholder: the placeholder which will be substituted by the widget * @project: the project his widget belongs to. * - * Creates a new widget of @class and put in place of the @placeholder + * Creates a new widget using @adaptor and put in place of the @placeholder * in the @project * * Returns the newly created widget. */ GladeWidget * -glade_command_create (GladeWidgetClass *class, - GladeWidget *parent, - GladePlaceholder *placeholder, - GladeProject *project) +glade_command_create (GladeWidgetAdaptor *adaptor, + GladeWidget *parent, + GladePlaceholder *placeholder, + GladeProject *project) { GladeCommandCreateDelete *me; CommandData *cdata; GladeWidget *widget; - g_return_val_if_fail (class != NULL, NULL); + g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL); g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL); - if (class->toplevel == FALSE) + if (GWA_IS_TOPLEVEL (adaptor) == FALSE) g_return_val_if_fail (GLADE_IS_WIDGET (parent), NULL); me = g_object_new (GLADE_COMMAND_CREATE_DELETE_TYPE, NULL); @@ -1173,10 +1172,10 @@ glade_command_create (GladeWidgetClass *class, me->widgets = g_list_append (me->widgets, cdata); - widget = glade_widget_class_create_widget (class, TRUE, - "parent", parent, - "project", project, - NULL); + widget = glade_widget_adaptor_create_widget (adaptor, TRUE, + "parent", parent, + "project", project, + NULL); /* widget may be null, e.g. the user clicked cancel on a query */ if ((cdata->widget = widget) == NULL) @@ -1675,8 +1674,8 @@ glade_command_cut_copy_paste_common (GList *widgets, glade_command_placeholder_connect (cdata, GLADE_PLACEHOLDER (child)); } - else if ((children = glade_widget_class_container_get_children - (cdata->parent->widget_class, cdata->parent->object)) != NULL) + else if ((children = glade_widget_adaptor_get_children + (cdata->parent->adaptor, cdata->parent->object)) != NULL) { for (l = children; l && l->data; l = l->next) { diff --git a/src/glade-command.h b/src/glade-command.h index eb46a725..caddeda9 100644 --- a/src/glade-command.h +++ b/src/glade-command.h @@ -96,12 +96,12 @@ void glade_command_set_name (GladeWidget *glade_widget, con /************************ create/delete ******************************/ LIBGLADEUI_API -void glade_command_delete (GList *widgets); +void glade_command_delete (GList *widgets); LIBGLADEUI_API -GladeWidget *glade_command_create (GladeWidgetClass *class, - GladeWidget *parent, - GladePlaceholder *placeholder, - GladeProject *project); +GladeWidget *glade_command_create (GladeWidgetAdaptor *adaptor, + GladeWidget *parent, + GladePlaceholder *placeholder, + GladeProject *project); /************************ cut/copy/paste ******************************/ LIBGLADEUI_API diff --git a/src/glade-cursor.c b/src/glade-cursor.c index 1375ac52..14a759f1 100644 --- a/src/glade-cursor.c +++ b/src/glade-cursor.c @@ -24,7 +24,7 @@ #include "glade-app.h" #include "glade-palette.h" #include "glade-cursor.h" -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" #include <glib.h> #include <glib/gi18n.h> @@ -94,8 +94,8 @@ set_cursor (GdkCursor *gdk_cursor) void glade_cursor_set (GdkWindow *window, GladeCursorType type) { - GladeWidgetClass *widget_class; - GdkCursor *the_cursor = NULL; + GladeWidgetAdaptor *adaptor; + GdkCursor *the_cursor = NULL; g_return_if_fail (cursor != NULL); switch (type) { @@ -104,20 +104,17 @@ glade_cursor_set (GdkWindow *window, GladeCursorType type) gdk_window_set_cursor (window, cursor->selector); break; case GLADE_CURSOR_ADD_WIDGET: - - widget_class = glade_palette_get_current_item_class (glade_app_get_palette ()); - - if (widget_class != NULL) + if ((adaptor = + glade_palette_get_current_item (glade_app_get_palette ())) != NULL) { - if (widget_class->cursor != NULL) - the_cursor = widget_class->cursor; - else + g_object_get (adaptor, "cursor", &the_cursor, NULL); + + if (the_cursor == NULL) the_cursor = cursor->add_widget; + } else - { the_cursor = cursor->add_widget; - } break; case GLADE_CURSOR_RESIZE_TOP_LEFT: the_cursor = cursor->resize_top_left; diff --git a/src/glade-editor-property.c b/src/glade-editor-property.c index 6c2f9cf4..7fd43955 100644 --- a/src/glade-editor-property.c +++ b/src/glade-editor-property.c @@ -241,17 +241,20 @@ static void glade_editor_property_info_clicked_cb (GtkWidget *info, GladeEditorProperty *eprop) { - GladeWidgetClass *wclass; - gchar *search; + GladeWidgetAdaptor *adaptor; + gchar *search, *book; - wclass = glade_widget_class_from_pclass (eprop->class); - search = g_strdup_printf ("The %s property", eprop->class->id); + adaptor = glade_widget_adaptor_from_pclass (eprop->class); + search = g_strdup_printf ("The %s property", eprop->class->id); + + g_object_get (adaptor, "book", &book, NULL); g_signal_emit (G_OBJECT (eprop), glade_editor_property_signals[GTK_DOC_SEARCH], - 0, wclass->book, + 0, book, g_type_name (eprop->class->pspec->owner_type), search); + g_free (book); g_free (search); } @@ -2123,7 +2126,7 @@ glade_eprop_object_populate_view_real (GladeEditorProperty *eprop, (GLADE_PARAM_SPEC_OBJECTS(eprop->class->pspec))); good_type = glade_util_class_implements_interface - (widget->widget_class->type, + (widget->adaptor->type, glade_param_spec_objects_get_type (GLADE_PARAM_SPEC_OBJECTS(eprop->class->pspec))); } @@ -2132,7 +2135,7 @@ glade_eprop_object_populate_view_real (GladeEditorProperty *eprop, has_decendant = glade_widget_has_decendant (widget, eprop->class->pspec->value_type); - good_type = g_type_is_a (widget->widget_class->type, + good_type = g_type_is_a (widget->adaptor->type, eprop->class->pspec->value_type); } @@ -2146,7 +2149,7 @@ glade_eprop_object_populate_view_real (GladeEditorProperty *eprop, OBJ_COLUMN_WIDGET_NAME, glade_eprop_object_name (widget->name, model, parent_iter), OBJ_COLUMN_WIDGET_CLASS, - widget->widget_class->palette_name, + widget->adaptor->title, /* Selectable if its a compatible type and * its not itself. */ @@ -2158,8 +2161,8 @@ glade_eprop_object_populate_view_real (GladeEditorProperty *eprop, } if (has_decendant && - (children = glade_widget_class_container_get_children - (widget->widget_class, widget->object)) != NULL) + (children = glade_widget_adaptor_get_children + (widget->adaptor, widget->object)) != NULL) { GtkTreeIter *copy = NULL; @@ -2339,8 +2342,8 @@ glade_eprop_object_view (GladeEditorProperty *eprop, static gchar * glade_eprop_object_dialog_title (GladeEditorProperty *eprop) { - GladeWidgetClass *klass; - const gchar *format = + GladeWidgetAdaptor *adaptor; + const gchar *format = GLADE_IS_PARAM_SPEC_OBJECTS (eprop->class->pspec) ? _("Choose %s implementors") : _("Choose a %s in this project"); @@ -2348,10 +2351,10 @@ glade_eprop_object_dialog_title (GladeEditorProperty *eprop) return g_strdup_printf (format, g_type_name (glade_param_spec_objects_get_type (GLADE_PARAM_SPEC_OBJECTS (eprop->class->pspec)))); - else if ((klass = - glade_widget_class_get_by_type + else if ((adaptor = + glade_widget_adaptor_get_by_type (eprop->class->pspec->value_type)) != NULL) - return g_strdup_printf (format, klass->palette_name); + return g_strdup_printf (format, adaptor->title); /* Fallback on type name (which would look like "GtkButton" * instead of "Button" and maybe not translated). @@ -3098,21 +3101,21 @@ static void glade_eprop_accel_populate_view (GladeEditorProperty *eprop, GtkTreeView *view) { - GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop); - GladeSignalClass *sclass; - GladeWidgetClass *wclass = glade_widget_class_from_pclass (eprop->class); - GtkTreeStore *model = (GtkTreeStore *)gtk_tree_view_get_model (view); - GtkTreeIter iter; - GladeEpropIterTab *parent_tab; - GladeAccelInfo *info; - GList *list, *l, *found, *accelerators; - gchar *name; + GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop); + GladeSignalClass *sclass; + GladeWidgetAdaptor *adaptor = glade_widget_adaptor_from_pclass (eprop->class); + GtkTreeStore *model = (GtkTreeStore *)gtk_tree_view_get_model (view); + GtkTreeIter iter; + GladeEpropIterTab *parent_tab; + GladeAccelInfo *info; + GList *list, *l, *found, *accelerators; + gchar *name; accelerators = g_value_get_boxed (eprop->property->value); /* First make parent iters... */ - for (list = wclass->signals; list; list = list->next) + for (list = adaptor->signals; list; list = list->next) { sclass = list->data; @@ -3143,7 +3146,7 @@ glade_eprop_accel_populate_view (GladeEditorProperty *eprop, /* Now we populate... */ - for (list = wclass->signals; list; list = list->next) + for (list = adaptor->signals; list; list = list->next) { sclass = list->data; @@ -3795,14 +3798,17 @@ glade_editor_property_load_by_widget (GladeEditorProperty *eprop, void glade_editor_property_show_info (GladeEditorProperty *eprop) { - GladeWidgetClass *wclass; + GladeWidgetAdaptor *adaptor; + gchar *book; g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop)); - wclass = glade_widget_class_from_pclass (eprop->class); + adaptor = glade_widget_adaptor_from_pclass (eprop->class); + + g_object_get (adaptor, "book", &book, NULL); if (eprop->class->virtual == FALSE && - wclass->book != NULL) + book != NULL) gtk_widget_show (eprop->info); else { @@ -3813,6 +3819,7 @@ glade_editor_property_show_info (GladeEditorProperty *eprop) gtk_widget_set_sensitive (eprop->info, FALSE); } + g_free (book); eprop->show_info = TRUE; g_object_notify (G_OBJECT (eprop), "show-info"); } diff --git a/src/glade-editor.c b/src/glade-editor.c index c593aa80..f21ad012 100644 --- a/src/glade-editor.c +++ b/src/glade-editor.c @@ -31,7 +31,7 @@ #include "glade.h" #include "glade-widget.h" -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" #include "glade-editor.h" #include "glade-signal-editor.h" #include "glade-parameter.h" @@ -254,11 +254,16 @@ static void glade_editor_on_docs_click (GtkButton *button, GladeEditor *editor) { + gchar *book; + if (editor->loaded_widget) + { + g_object_get (editor->loaded_widget->adaptor, "book", &book, NULL); g_signal_emit (G_OBJECT (editor), glade_editor_signals[GTK_DOC_SEARCH], - 0, editor->loaded_widget->widget_class->book, - editor->loaded_widget->widget_class->name, NULL); + 0, book, editor->loaded_widget->adaptor->name, NULL); + g_free (book); + } } @@ -508,7 +513,7 @@ glade_editor_table_append_class_field (GladeEditorTable *table) gtk_widget_show (label); class_entry = gtk_entry_new (); - gtk_entry_set_text (GTK_ENTRY (class_entry), table->glade_widget_class->name); + gtk_entry_set_text (GTK_ENTRY (class_entry), table->adaptor->name); gtk_editable_set_editable (GTK_EDITABLE (class_entry), FALSE); gtk_widget_show (class_entry); @@ -538,11 +543,11 @@ glade_editor_property_class_comp (gconstpointer a, gconstpointer b) } static GList * -glade_editor_widget_class_get_sorted_properties (GladeWidgetClass *class) +glade_editor_get_sorted_properties (GladeWidgetAdaptor *adaptor) { GList *l, *a = NULL, *b = NULL; - for (l = class->properties; l && l->data; l = g_list_next (l)) + for (l = adaptor->properties; l && l->data; l = g_list_next (l)) { GladePropertyClass *class = l->data; @@ -559,15 +564,15 @@ glade_editor_widget_class_get_sorted_properties (GladeWidgetClass *class) } static gboolean -glade_editor_table_append_items (GladeEditorTable *table, - GladeWidgetClass *class, - GladeEditorTableType type) +glade_editor_table_append_items (GladeEditorTable *table, + GladeWidgetAdaptor *adaptor, + GladeEditorTableType type) { GladeEditorProperty *property; GladePropertyClass *property_class; GList *list, *sorted_list; - sorted_list = glade_editor_widget_class_get_sorted_properties (class); + sorted_list = glade_editor_get_sorted_properties (adaptor); for (list = sorted_list; list != NULL; list = list->next) { @@ -622,18 +627,18 @@ glade_editor_table_free (GladeEditorTable *etable) } static GladeEditorTable * -glade_editor_table_create (GladeEditor *editor, - GladeWidgetClass *class, - GladeEditorTableType type) +glade_editor_table_create (GladeEditor *editor, + GladeWidgetAdaptor *adaptor, + GladeEditorTableType type) { GladeEditorTable *table; g_return_val_if_fail (GLADE_IS_EDITOR (editor), NULL); - g_return_val_if_fail (GLADE_IS_WIDGET_CLASS (class), NULL); + g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL); table = glade_editor_table_new (); table->editor = editor; - table->glade_widget_class = class; + table->adaptor = adaptor; table->type = type; if (type == TABLE_TYPE_GENERAL) @@ -642,7 +647,7 @@ glade_editor_table_create (GladeEditor *editor, glade_editor_table_append_name_field (table); } - if (!glade_editor_table_append_items (table, class, type)) + if (!glade_editor_table_append_items (table, adaptor, type)) return NULL; gtk_widget_show (table->table_widget); @@ -652,7 +657,7 @@ glade_editor_table_create (GladeEditor *editor, static GladeEditorTable * glade_editor_get_table_from_class (GladeEditor *editor, - GladeWidgetClass *class, + GladeWidgetAdaptor *adaptor, GladeEditorTableType type) { GladeEditorTable *table; @@ -663,11 +668,11 @@ glade_editor_get_table_from_class (GladeEditor *editor, table = list->data; if (type != table->type) continue; - if (table->glade_widget_class == class) + if (table->adaptor == adaptor) return table; } - table = glade_editor_table_create (editor, class, type); + table = glade_editor_table_create (editor, adaptor, type); g_return_val_if_fail (table != NULL, NULL); editor->widget_tables = g_list_prepend (editor->widget_tables, table); @@ -677,7 +682,7 @@ glade_editor_get_table_from_class (GladeEditor *editor, static void glade_editor_load_page (GladeEditor *editor, - GladeWidgetClass *class, + GladeWidgetAdaptor *adaptor, GladeEditorTableType type) { GladeEditorTable *table; @@ -714,10 +719,10 @@ glade_editor_load_page (GladeEditor *editor, } g_list_free (children); - if (!class) + if (!adaptor) return; - table = glade_editor_get_table_from_class (editor, class, type); + table = glade_editor_get_table_from_class (editor, adaptor, type); /* Attach the new table */ gtk_container_add (GTK_CONTAINER (container), table->table_widget); @@ -754,7 +759,7 @@ void glade_editor_update_widget_name (GladeEditor *editor) { GladeEditorTable *table = glade_editor_get_table_from_class - (editor, editor->loaded_class, TABLE_TYPE_GENERAL); + (editor, editor->loaded_adaptor, TABLE_TYPE_GENERAL); g_signal_handlers_block_by_func (G_OBJECT (table->name_entry), glade_editor_widget_name_changed, editor); gtk_entry_set_text (GTK_ENTRY (table->name_entry), editor->loaded_widget->name); @@ -762,7 +767,7 @@ glade_editor_update_widget_name (GladeEditor *editor) } static void -glade_editor_load_signal_page (GladeEditor *editor, GladeWidgetClass *class) +glade_editor_load_signal_page (GladeEditor *editor) { if (editor->signal_editor == NULL) { editor->signal_editor = glade_signal_editor_new ((gpointer) editor); @@ -772,15 +777,15 @@ glade_editor_load_signal_page (GladeEditor *editor, GladeWidgetClass *class) } static void -glade_editor_load_widget_class (GladeEditor *editor, GladeWidgetClass *class) +glade_editor_load_widget_class (GladeEditor *editor, GladeWidgetAdaptor *adaptor) { - glade_editor_load_page (editor, class, TABLE_TYPE_GENERAL); - glade_editor_load_page (editor, class, TABLE_TYPE_COMMON); - glade_editor_load_page (editor, class, TABLE_TYPE_ATK); + glade_editor_load_page (editor, adaptor, TABLE_TYPE_GENERAL); + glade_editor_load_page (editor, adaptor, TABLE_TYPE_COMMON); + glade_editor_load_page (editor, adaptor, TABLE_TYPE_ATK); - glade_editor_load_signal_page (editor, class); + glade_editor_load_signal_page (editor); - editor->loaded_class = class; + editor->loaded_adaptor = adaptor; } static gint @@ -868,7 +873,7 @@ glade_editor_load_table (GladeEditor *editor, GList *list; table = glade_editor_get_table_from_class - (editor, widget->widget_class, type); + (editor, widget->adaptor, type); if (table->name_entry) gtk_entry_set_text (GTK_ENTRY (table->name_entry), widget->name); @@ -882,8 +887,9 @@ glade_editor_load_table (GladeEditor *editor, static void glade_editor_load_widget_real (GladeEditor *editor, GladeWidget *widget) { - GladeWidgetClass *class; - GladeProject *project; + GladeWidgetAdaptor *adaptor; + GladeProject *project; + gchar *book; /* Disconnect from last widget */ if (editor->loaded_widget != NULL) @@ -893,9 +899,9 @@ glade_editor_load_widget_real (GladeEditor *editor, GladeWidget *widget) editor->project_closed_signal_id); } /* Load the GladeWidgetClass */ - class = widget ? widget->widget_class : NULL; - if (editor->loaded_class != class || class == NULL) - glade_editor_load_widget_class (editor, class); + adaptor = widget ? widget->adaptor : NULL; + if (editor->loaded_adaptor != adaptor || adaptor == NULL) + glade_editor_load_widget_class (editor, adaptor); glade_editor_load_packing_page (editor, widget); glade_signal_editor_load_widget (editor->signal_editor, widget); @@ -918,8 +924,9 @@ glade_editor_load_widget_real (GladeEditor *editor, GladeWidget *widget) } gtk_widget_set_sensitive (editor->reset_button, TRUE); - gtk_widget_set_sensitive (editor->info_button, - editor->loaded_class->book != NULL); + g_object_get (editor->loaded_adaptor, "book", &book, NULL); + gtk_widget_set_sensitive (editor->info_button, book != NULL); + g_free (book); editor->loading = TRUE; @@ -981,7 +988,7 @@ glade_editor_query_dialog (GladeEditor *editor, GladeWidget *widget) gint answer; gboolean retval = TRUE; - title = g_strdup_printf (_("Create a %s"), widget->widget_class->name); + title = g_strdup_printf (_("Create a %s"), widget->adaptor->name); dialog = gtk_dialog_new_with_buttons (title, NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | @@ -993,7 +1000,7 @@ glade_editor_query_dialog (GladeEditor *editor, GladeWidget *widget) g_free (title); table = glade_editor_get_table_from_class (editor, - widget->widget_class, + widget->adaptor, TABLE_TYPE_QUERY); diff --git a/src/glade-editor.h b/src/glade-editor.h index 0f28de24..03fa927f 100644 --- a/src/glade-editor.h +++ b/src/glade-editor.h @@ -46,20 +46,20 @@ struct _GladeEditor * if no widgets are selected */ - GladeWidgetClass *loaded_class; /* A pointer to the loaded - * GladeWidgetClass. Note that we can - * have a class loaded without a - * loaded_widget. For this reason we - * can't use loaded_widget->class. - * When a widget is selected we load - * this class in the editor first and - * then fill the values of the inputs - * with the GladeProperty items. - * This is usefull for not having - * to redraw/container_add the widgets - * when we switch from widgets of the - * same class - */ + GladeWidgetAdaptor *loaded_adaptor; /* A pointer to the loaded + * GladeWidgetAdaptor. Note that we can + * have a class loaded without a + * loaded_widget. For this reason we + * can't use loaded_widget->adaptor. + * When a widget is selected we load + * this class in the editor first and + * then fill the values of the inputs + * with the GladeProperty items. + * This is usefull for not having + * to redraw/container_add the widgets + * when we switch from widgets of the + * same class + */ /* The editor has (at this moment) four tabs; these are pointers to the @@ -150,9 +150,9 @@ struct _GladeEditorTable * editor arround. */ - GladeWidgetClass *glade_widget_class; /* The GladeWidgetClass this - * table belongs to. - */ + GladeWidgetAdaptor *adaptor; /* The GladeWidgetAdaptor this + * table belongs to. + */ GtkWidget *table_widget; /* This widget is a gtk_vbox that is displayed * in the glade-editor when a widget of this diff --git a/src/glade-fixed.c b/src/glade-fixed.c index ee6665a4..14ad97d1 100644 --- a/src/glade-fixed.c +++ b/src/glade-fixed.c @@ -656,7 +656,7 @@ glade_fixed_child_event (GladeWidget *gwidget, */ if ((GLADE_IS_PLACEHOLDER (event_widget) || GLADE_IS_FIXED (event_gwidget)) && - glade_palette_get_current_item_class (glade_app_get_palette ()) != NULL) + glade_palette_get_current_item (glade_app_get_palette ()) != NULL) { glade_cursor_set (((GdkEventAny *)event)->window, GLADE_CURSOR_ADD_WIDGET); @@ -684,7 +684,7 @@ glade_fixed_add_child_impl (GladeWidget *gwidget_fixed, g_return_if_fail (GLADE_IS_WIDGET (child)); /* Chain up for the basic parenting */ - GLADE_WIDGET_KLASS (parent_class)->add_child + GLADE_WIDGET_CLASS (parent_class)->add_child (GLADE_WIDGET (fixed), child, at_mouse); /* Could be a delagate object that is not a widget or a special @@ -742,7 +742,7 @@ glade_fixed_remove_child_impl (GladeWidget *fixed, glade_fixed_disconnect_child (GLADE_FIXED (fixed), child); /* Chain up for the basic unparenting */ - GLADE_WIDGET_KLASS (parent_class)->remove_child + GLADE_WIDGET_CLASS (parent_class)->remove_child (GLADE_WIDGET (fixed), child); } @@ -758,7 +758,7 @@ glade_fixed_replace_child_impl (GladeWidget *fixed, glade_fixed_disconnect_child (GLADE_FIXED (fixed), gold_widget); /* Chain up for the basic reparenting */ - GLADE_WIDGET_KLASS (parent_class)->replace_child + GLADE_WIDGET_CLASS (parent_class)->replace_child (GLADE_WIDGET (fixed), old_object, new_object); if (gnew_widget) @@ -770,15 +770,15 @@ glade_fixed_event (GtkWidget *widget, GdkEvent *event, GladeWidget *gwidget_fixed) { - GladeFixed *fixed = GLADE_FIXED (gwidget_fixed); - GladeWidgetClass *item_class; - GtkWidget *event_widget; - gboolean handled = FALSE; - GladeWidget *event_gwidget, *search; + GladeFixed *fixed = GLADE_FIXED (gwidget_fixed); + GladeWidgetAdaptor *adaptor; + GtkWidget *event_widget; + gboolean handled = FALSE; + GladeWidget *event_gwidget, *search; gdk_window_get_pointer (widget->window, NULL, NULL, NULL); - item_class = glade_palette_get_current_item_class (glade_app_get_palette ()); + adaptor = glade_palette_get_current_item (glade_app_get_palette ()); /* Get the event widget and the deep widget */ gdk_window_get_user_data (((GdkEventAny *)event)->window, (gpointer)&event_widget); @@ -786,7 +786,7 @@ glade_fixed_event (GtkWidget *widget, /* If the GladeWidget used this event... let it slide. */ - if (GLADE_WIDGET_KLASS (parent_class)->event (widget, event, gwidget_fixed)) + if (GLADE_WIDGET_CLASS (parent_class)->event (widget, event, gwidget_fixed)) return TRUE; g_return_val_if_fail (GLADE_IS_WIDGET (event_gwidget), FALSE); @@ -817,7 +817,7 @@ glade_fixed_event (GtkWidget *widget, /* Early return for placeholders with selection in * the palette. */ - if (item_class) + if (adaptor) { glade_cursor_set (((GdkEventAny *)event)->window, GLADE_CURSOR_ADD_WIDGET); @@ -870,13 +870,13 @@ glade_fixed_event (GtkWidget *widget, if (((GdkEventButton *) event)->button == 1) { - if (item_class != NULL) + if (adaptor != NULL) { /* A widget type is selected in the palette. * Add a new widget of that type. */ fixed->creating = TRUE; - glade_command_create (item_class, + glade_command_create (adaptor, GLADE_WIDGET (fixed), NULL, GLADE_WIDGET (fixed)->project); fixed->creating = FALSE; @@ -889,7 +889,7 @@ glade_fixed_event (GtkWidget *widget, break; case GDK_ENTER_NOTIFY: case GDK_MOTION_NOTIFY: - if (item_class != NULL) + if (adaptor != NULL) { glade_cursor_set (((GdkEventAny *)event)->window, GLADE_CURSOR_ADD_WIDGET); @@ -1000,7 +1000,7 @@ static void glade_fixed_class_init (GladeFixedClass *fixed_class) { GObjectClass *gobject_class = G_OBJECT_CLASS (fixed_class); - GladeWidgetKlass *gwidget_class = GLADE_WIDGET_KLASS (fixed_class); + GladeWidgetClass *gwidget_class = GLADE_WIDGET_CLASS (fixed_class); parent_class = G_OBJECT_CLASS diff --git a/src/glade-fixed.h b/src/glade-fixed.h index 87705d59..7a43e094 100644 --- a/src/glade-fixed.h +++ b/src/glade-fixed.h @@ -75,7 +75,7 @@ struct _GladeFixed { }; struct _GladeFixedClass { - GladeWidgetKlass parent_class; + GladeWidgetClass parent_class; gboolean (* configure_child) (GladeFixed *, GladeWidget *, GdkRectangle *); gboolean (* configure_begin) (GladeFixed *, GladeWidget *); diff --git a/src/glade-gnome.c b/src/glade-gnome.c index 93fb1914..17f5ebaf 100644 --- a/src/glade-gnome.c +++ b/src/glade-gnome.c @@ -87,9 +87,11 @@ glade_gnomeui_init () /* GnomeApp */ void GLADEGNOME_API -glade_gnome_app_post_create (GObject *object, GladeCreateReason reason) +glade_gnome_app_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { - static GladeWidgetClass *menubar_class = NULL, *dock_item_class; + static GladeWidgetAdaptor *menubar_adaptor = NULL, *dock_item_adaptor; GladeWidget *gapp, *gdock, *gdock_item, *gmenubar; GladeProject *project; GnomeApp *app; @@ -104,7 +106,7 @@ glade_gnome_app_post_create (GObject *object, GladeCreateReason reason) project = glade_widget_get_project (gapp); /* Add BonoboDock */ - gdock = glade_widget_class_create_internal + gdock = glade_widget_adaptor_create_internal (gapp, G_OBJECT (app->dock), "dock", glade_widget_get_name (gapp), @@ -114,25 +116,25 @@ glade_gnome_app_post_create (GObject *object, GladeCreateReason reason) if (reason != GLADE_CREATE_USER) return; /* Add MenuBar */ - if (menubar_class == NULL) + if (menubar_adaptor == NULL) { - dock_item_class = glade_widget_class_get_by_type (BONOBO_TYPE_DOCK_ITEM); - menubar_class = glade_widget_class_get_by_type (GTK_TYPE_MENU_BAR); + dock_item_adaptor = glade_widget_adaptor_get_by_type (BONOBO_TYPE_DOCK_ITEM); + menubar_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_MENU_BAR); } /* DockItem */ - gdock_item = glade_widget_class_create_widget (dock_item_class, FALSE, - "parent", gdock, - "project", project, NULL); + gdock_item = glade_widget_adaptor_create_widget (dock_item_adaptor, FALSE, + "parent", gdock, + "project", project, NULL); glade_widget_add_child (gdock, gdock_item, FALSE); glade_widget_pack_property_set (gdock_item, "behavior", BONOBO_DOCK_ITEM_BEH_EXCLUSIVE | BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL | BONOBO_DOCK_ITEM_BEH_LOCKED); /* MenuBar */ - gmenubar = glade_widget_class_create_widget (menubar_class, FALSE, - "parent", gdock_item, - "project", project, NULL); + gmenubar = glade_widget_adaptor_create_widget (menubar_adaptor, FALSE, + "parent", gdock_item, + "project", project, NULL); glade_widget_add_child (gdock_item, gmenubar, FALSE); @@ -144,36 +146,39 @@ glade_gnome_app_post_create (GObject *object, GladeCreateReason reason) glade_widget_property_set (gapp, "has-statusbar", TRUE); } -void GLADEGNOME_API -glade_gnome_app_get_internal_child (GObject *object, - const gchar *name, - GObject **child) +GObject * GLADEGNOME_API +glade_gnome_app_get_internal_child (GladeWidgetAdaptor *adaptor, + GObject *object, + const gchar *name) { - GnomeApp *app; + GObject *child = NULL; + GnomeApp *app; GladeWidget *gapp; - g_return_if_fail (GNOME_IS_APP (object)); + g_return_val_if_fail (GNOME_IS_APP (object), NULL); app = GNOME_APP (object); gapp = glade_widget_get_from_gobject (object); if (strcmp ("dock", name) == 0) - *child = G_OBJECT (app->dock); + child = G_OBJECT (app->dock); else if (strcmp ("appbar", name) == 0) { - *child = G_OBJECT (app->statusbar); - if (*child == NULL) + child = G_OBJECT (app->statusbar); + if (child == NULL) { + /* XXX Is this appropriate ? */ glade_widget_property_set (gapp, "has-statusbar", TRUE); - *child = G_OBJECT (app->statusbar); + child = G_OBJECT (app->statusbar); } } - else - *child = NULL; + + return child; } GList * GLADEGNOME_API -glade_gnome_app_get_children (GObject *object) +glade_gnome_app_get_children (GladeWidgetAdaptor *adaptor, + GObject *object) { GList *list = NULL; GnomeApp *app; @@ -190,10 +195,11 @@ glade_gnome_app_get_children (GObject *object) } void GLADEGNOME_API -glade_gnome_app_set_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gnome_app_set_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { GnomeApp *app; @@ -211,10 +217,11 @@ glade_gnome_app_set_child_property (GObject *container, } void GLADEGNOME_API -glade_gnome_app_get_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gnome_app_get_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { GnomeApp *app; @@ -251,7 +258,7 @@ glade_gnome_app_set_has_statusbar (GObject *object, GValue *value) gnome_app_set_statusbar (app, bar); - gbar = glade_widget_class_create_internal + gbar = glade_widget_adaptor_create_internal (gapp, G_OBJECT (bar), "appbar", glade_widget_get_name (gapp), FALSE, GLADE_CREATE_USER); @@ -281,7 +288,9 @@ gnome_app_bar_get_type () } void GLADEGNOME_API -glade_gnome_app_bar_post_create (GObject *object, GladeCreateReason reason) +glade_gnome_app_bar_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { g_return_if_fail (GNOME_IS_APPBAR (object)); gnome_appbar_set_status (GNOME_APPBAR (object), _("Status Message.")); @@ -295,7 +304,9 @@ glade_gnome_date_edit_set_no_show_all (GtkWidget *widget, gpointer data) } void GLADEGNOME_API -glade_gnome_date_edit_post_create (GObject *object, GladeCreateReason reason) +glade_gnome_date_edit_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { g_return_if_fail (GNOME_IS_DATE_EDIT (object)); @@ -312,18 +323,18 @@ static GladeWidget * glade_gnome_druid_add_page (GladeWidget *gdruid, gboolean edge) { GladeWidget *gpage; - static GladeWidgetClass *dps_class = NULL, *dpe_class; + static GladeWidgetAdaptor *dps_adaptor = NULL, *dpe_adaptor; GladeProject *project = glade_widget_get_project (gdruid); - if (dps_class == NULL) + if (dps_adaptor == NULL) { - dps_class = glade_widget_class_get_by_type (GNOME_TYPE_DRUID_PAGE_STANDARD); - dpe_class = glade_widget_class_get_by_type (GNOME_TYPE_DRUID_PAGE_EDGE); + dps_adaptor = glade_widget_adaptor_get_by_type (GNOME_TYPE_DRUID_PAGE_STANDARD); + dpe_adaptor = glade_widget_adaptor_get_by_type (GNOME_TYPE_DRUID_PAGE_EDGE); } - gpage = glade_widget_class_create_widget (edge ? dpe_class : dps_class, FALSE, - "parent", gdruid, - "project", project, NULL); + gpage = glade_widget_adaptor_create_widget (edge ? dpe_adaptor : dps_adaptor, FALSE, + "parent", gdruid, + "project", project, NULL); glade_widget_add_child (gdruid, gpage, FALSE); @@ -331,7 +342,9 @@ glade_gnome_druid_add_page (GladeWidget *gdruid, gboolean edge) } void GLADEGNOME_API -glade_gnome_druid_post_create (GObject *object, GladeCreateReason reason) +glade_gnome_druid_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GladeWidget *gdruid, *gpage; @@ -394,11 +407,14 @@ glade_gnome_druid_page_cb (GnomeDruidPage *druidpage, } void GLADEGNOME_API -glade_gnome_druid_add_child (GObject *container, GObject *child) +glade_gnome_druid_add_child (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child) { g_return_if_fail (GNOME_IS_DRUID (container)); g_return_if_fail (GNOME_IS_DRUID_PAGE (child)); + /* XXX This needed ? */ g_signal_handlers_disconnect_matched (child, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, glade_gnome_druid_page_cb, NULL); @@ -411,10 +427,15 @@ glade_gnome_druid_add_child (GObject *container, GObject *child) } void GLADEGNOME_API -glade_gnome_druid_remove_child (GObject *container, GObject *child) +glade_gnome_druid_remove_child (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child) { g_return_if_fail (GNOME_IS_DRUID (container)); g_return_if_fail (GNOME_IS_DRUID_PAGE (child)); + + g_signal_handlers_disconnect_matched (child, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, + glade_gnome_druid_page_cb, NULL); gtk_container_remove (GTK_CONTAINER (container), GTK_WIDGET (child)); } @@ -464,10 +485,11 @@ glade_gnome_druid_get_page_position (GnomeDruid *druid, GnomeDruidPage *page) } void GLADEGNOME_API -glade_gnome_druid_set_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gnome_druid_set_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { g_return_if_fail (GNOME_IS_DRUID (container)); g_return_if_fail (GNOME_IS_DRUID_PAGE (child)); @@ -493,17 +515,20 @@ glade_gnome_druid_set_child_property (GObject *container, } else /* Chain Up */ - gtk_container_child_set_property (GTK_CONTAINER (container), - GTK_WIDGET (child), - property_name, - value); + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->child_set_property (adaptor, + GTK_CONTAINER (container), + GTK_WIDGET (child), + property_name, + value); } void GLADEGNOME_API -glade_gnome_druid_get_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gnome_druid_get_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { g_return_if_fail (GNOME_IS_DRUID (container)); g_return_if_fail (GNOME_IS_DRUID_PAGE (child)); @@ -514,15 +539,19 @@ glade_gnome_druid_get_child_property (GObject *container, GNOME_DRUID_PAGE (child))); else /* Chain Up */ - gtk_container_child_get_property (GTK_CONTAINER (container), - GTK_WIDGET (child), - property_name, - value); + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->child_get_property (adaptor, + GTK_CONTAINER (container), + GTK_WIDGET (child), + property_name, + value); } /* GnomeDruidPageStandard */ void GLADEGNOME_API -glade_gnome_dps_post_create (GObject *object, GladeCreateReason reason) +glade_gnome_dps_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GladeWidget *gpage, *gvbox; GObject *vbox; @@ -531,29 +560,32 @@ glade_gnome_dps_post_create (GObject *object, GladeCreateReason reason) gpage = glade_widget_get_from_gobject (object); vbox = G_OBJECT (GNOME_DRUID_PAGE_STANDARD (object)->vbox); - gvbox = glade_widget_class_create_internal (gpage, vbox, "vbox", - glade_widget_get_name (gpage), - FALSE, GLADE_CREATE_LOAD); + gvbox = glade_widget_adaptor_create_internal (gpage, vbox, "vbox", + glade_widget_get_name (gpage), + FALSE, GLADE_CREATE_LOAD); if (reason == GLADE_CREATE_USER) glade_widget_property_set (gvbox, "size", 1); } -void GLADEGNOME_API -glade_gnome_dps_get_internal_child (GObject *object, - const gchar *name, - GObject **child) +GObject * GLADEGNOME_API +glade_gnome_dps_get_internal_child (GladeWidgetAdaptor *adaptor, + GObject *object, + const gchar *name) { - g_return_if_fail (GNOME_IS_DRUID_PAGE_STANDARD (object)); + GObject *child = NULL; + + g_return_val_if_fail (GNOME_IS_DRUID_PAGE_STANDARD (object), NULL); if (strcmp (name, "vbox") == 0) - *child = G_OBJECT (GNOME_DRUID_PAGE_STANDARD (object)->vbox); - else - *child = NULL; + child = G_OBJECT (GNOME_DRUID_PAGE_STANDARD (object)->vbox); + + return child; } GList * GLADEGNOME_API -glade_gnome_dps_get_children (GObject *object) +glade_gnome_dps_get_children (GladeWidgetAdaptor *adaptor, + GObject *object) { GList *list = NULL; GnomeDruidPageStandard *page; @@ -844,18 +876,18 @@ glade_gnome_dialog_add_button (GladeWidget *gaction_area, const gchar *stock) { GladeProject *project = glade_widget_get_project (gaction_area); - static GladeWidgetClass *button_class = NULL; + static GladeWidgetAdaptor *button_adaptor = NULL; GladeWidget *gbutton; GObject *button; GEnumClass *eclass; GEnumValue *eval; - if (button_class == NULL) - button_class = glade_widget_class_get_by_type (GTK_TYPE_BUTTON); + if (button_adaptor == NULL) + button_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_BUTTON); - gbutton = glade_widget_class_create_widget (button_class, FALSE, - "parent", gaction_area, - "project", project, FALSE); + gbutton = glade_widget_adaptor_create_widget (button_adaptor, FALSE, + "parent", gaction_area, + "project", project, FALSE); eclass = g_type_class_ref (glade_standard_stock_get_type ()); if ((eval = g_enum_get_value_by_nick (eclass, stock)) != NULL) @@ -867,12 +899,14 @@ glade_gnome_dialog_add_button (GladeWidget *gaction_area, button = glade_widget_get_object (gbutton); - glade_widget_class_container_add (glade_widget_get_class (gaction_area), - action_area, button); + glade_widget_adaptor_add (glade_widget_get_adaptor (gaction_area), + action_area, button); } void GLADEGNOME_API -glade_gnome_dialog_post_create (GObject *object, GladeCreateReason reason) +glade_gnome_dialog_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GladeWidget *gdialog, *gvbox, *gaction_area; GtkWidget *separator; @@ -890,7 +924,7 @@ glade_gnome_dialog_post_create (GObject *object, GladeCreateReason reason) { GnomePropertyBox *pbox = GNOME_PROPERTY_BOX (object); - gaction_area = glade_widget_class_create_internal + gaction_area = glade_widget_adaptor_create_internal (gdialog, G_OBJECT (pbox->notebook), "notebook", glade_widget_get_name (gdialog), FALSE, GLADE_CREATE_LOAD); @@ -900,7 +934,7 @@ glade_gnome_dialog_post_create (GObject *object, GladeCreateReason reason) } /* vbox internal child */ - gvbox = glade_widget_class_create_internal + gvbox = glade_widget_adaptor_create_internal (gdialog, G_OBJECT (dialog->vbox), "vbox", glade_widget_get_name (gdialog), FALSE, GLADE_CREATE_LOAD); @@ -924,11 +958,11 @@ glade_gnome_dialog_post_create (GObject *object, GladeCreateReason reason) /* action area internal child */ gaction_area = - glade_widget_class_create_internal (gvbox, - G_OBJECT (dialog->action_area), - "action_area", - glade_widget_get_name (gvbox), - FALSE, GLADE_CREATE_LOAD); + glade_widget_adaptor_create_internal (gvbox, + G_OBJECT (dialog->action_area), + "action_area", + glade_widget_get_name (gvbox), + FALSE, GLADE_CREATE_LOAD); glade_widget_property_set (gaction_area, "size", 0); @@ -955,24 +989,26 @@ glade_gnome_dialog_post_create (GObject *object, GladeCreateReason reason) } } -void GLADEGNOME_API -glade_gnome_dialog_get_internal_child (GObject *object, - const gchar *name, - GObject **child) +GObject * GLADEGNOME_API +glade_gnome_dialog_get_internal_child (GladeWidgetAdaptor *adaptor, + GObject *object, + const gchar *name) { - g_return_if_fail (GNOME_IS_DIALOG (object)); + GObject *child = NULL; + + g_return_val_if_fail (GNOME_IS_DIALOG (object), NULL); if (strcmp (name, "vbox") == 0) - *child = G_OBJECT (GNOME_DIALOG (object)->vbox); - else - if (GNOME_IS_PROPERTY_BOX (object) && strcmp (name, "notebook") == 0) - *child = G_OBJECT (GNOME_PROPERTY_BOX (object)->notebook); - else - *child = NULL; + child = G_OBJECT (GNOME_DIALOG (object)->vbox); + else if (GNOME_IS_PROPERTY_BOX (object) && strcmp (name, "notebook") == 0) + child = G_OBJECT (GNOME_PROPERTY_BOX (object)->notebook); + + return child; } GList * GLADEGNOME_API -glade_gnome_dialog_get_children (GObject *object) +glade_gnome_dialog_get_children (GladeWidgetAdaptor *adaptor, + GObject *object) { GList *list = NULL; GnomeDialog *dialog; @@ -995,15 +1031,19 @@ glade_gnome_dialog_get_children (GObject *object) /* GnomeAbout */ void GLADEGNOME_API -glade_gnome_about_dialog_post_create (GObject *object, GladeCreateReason reason) +glade_gnome_about_dialog_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { g_return_if_fail (GNOME_IS_ABOUT (object)); gtk_dialog_set_response_sensitive (GTK_DIALOG (object), GTK_RESPONSE_CLOSE, FALSE); } GList * GLADEGNOME_API -glade_gnome_about_dialog_get_children (GObject *object) +glade_gnome_about_dialog_get_children (GladeWidgetAdaptor *adaptor, + GObject *object) { + /* XXX Why this ? */ return NULL; } @@ -1027,7 +1067,9 @@ glade_gnome_about_set_version (GObject *object, GValue *value) /* GnomeIconList */ void GLADEGNOME_API -glade_gnome_icon_list_post_create (GObject *object, GladeCreateReason reason) +glade_gnome_icon_list_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { g_return_if_fail (GNOME_IS_ICON_LIST (object)); /* Freeze the widget so we dont get the signals that cause a segfault */ @@ -1146,43 +1188,49 @@ glade_gnome_message_box_set_message (GObject *object, GValue *value) /* GnomeEntry & GnomeFileEntry */ /* GnomeFileEntry is not derived from GnomeEntry... but hey!!! they should :) */ -void GLADEGNOME_API -glade_gnome_entry_get_internal_child (GObject *object, - const gchar *name, - GObject **child) +GObject * GLADEGNOME_API +glade_gnome_entry_get_internal_child (GladeWidgetAdaptor *adaptor, + GObject *object, + const gchar *name) { - g_return_if_fail (GNOME_IS_ENTRY (object) || GNOME_IS_FILE_ENTRY (object)); + GObject *child = NULL; + + g_return_val_if_fail (GNOME_IS_ENTRY (object) || + GNOME_IS_FILE_ENTRY (object), NULL); if (strcmp (name, "entry") == 0) { if (GNOME_IS_ENTRY (object)) - *child = G_OBJECT (gnome_entry_gtk_entry (GNOME_ENTRY (object))); + child = G_OBJECT (gnome_entry_gtk_entry (GNOME_ENTRY (object))); else - *child = G_OBJECT (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (object))); + child = G_OBJECT (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (object))); } - else - *child = NULL; + + return child; } void GLADEGNOME_API -glade_gnome_entry_post_create (GObject *object, GladeCreateReason reason) +glade_gnome_entry_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GladeWidget *gentry; GObject *child; g_return_if_fail (GNOME_IS_ENTRY (object) || GNOME_IS_FILE_ENTRY (object)); - glade_gnome_entry_get_internal_child (object, "entry", &child); + child = glade_gnome_entry_get_internal_child (adaptor, object, "entry"); gentry = glade_widget_get_from_gobject (object); - glade_widget_class_create_internal (gentry, - child, "entry", - glade_widget_get_name (gentry), - FALSE, reason); + glade_widget_adaptor_create_internal (gentry, + child, "entry", + glade_widget_get_name (gentry), + FALSE, reason); } GList * GLADEGNOME_API -glade_gnome_entry_get_children (GObject *object) +glade_gnome_entry_get_children (GladeWidgetAdaptor *adaptor, + GObject *object) { GList *list = NULL; GtkWidget *entry; @@ -1263,7 +1311,8 @@ glade_gnome_font_picker_set_mode (GObject *object, GValue *value) } GList * GLADEGNOME_API -glade_gnome_font_picker_get_children (GObject *object) +glade_gnome_font_picker_get_children (GladeWidgetAdaptor *adaptor, + GObject *object) { GtkWidget *child; @@ -1276,23 +1325,28 @@ glade_gnome_font_picker_get_children (GObject *object) } void GLADEGNOME_API -glade_gnome_font_picker_add_child (GtkWidget *container, GtkWidget *child) +glade_gnome_font_picker_add_child (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *child) { g_return_if_fail (GNOME_IS_FONT_PICKER (container)); gnome_font_picker_uw_set_widget (GNOME_FONT_PICKER (container), child); } void GLADEGNOME_API -glade_gnome_font_picker_remove_child (GtkWidget *container, GtkWidget *child) +glade_gnome_font_picker_remove_child (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *child) { g_return_if_fail (GNOME_IS_FONT_PICKER (container)); gnome_font_picker_uw_set_widget (GNOME_FONT_PICKER (container), glade_placeholder_new ()); } void GLADEGNOME_API -glade_gnome_font_picker_replace_child (GtkWidget *container, - GtkWidget *current, - GtkWidget *new) +glade_gnome_font_picker_replace_child (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *current, + GtkWidget *new) { g_return_if_fail (GNOME_IS_FONT_PICKER (container)); gnome_font_picker_uw_set_widget (GNOME_FONT_PICKER (container), new); @@ -1563,17 +1617,24 @@ glade_gnome_bd_get_band (BonoboDock *dock, GtkWidget *widget) /* BonoboDock */ void GLADEGNOME_API -glade_gnome_bonobodock_add_item (GObject *object, GObject *child) +glade_gnome_bonobodock_add_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { g_return_if_fail (BONOBO_IS_DOCK (object)); - g_return_if_fail (BONOBO_IS_DOCK_ITEM (child)); - bonobo_dock_add_item (BONOBO_DOCK (object), BONOBO_DOCK_ITEM (child), - 0,0,0,0, TRUE); + + if (BONOBO_IS_DOCK_ITEM (child)) + bonobo_dock_add_item (BONOBO_DOCK (object), BONOBO_DOCK_ITEM (child), + 0,0,0,0, TRUE); + else if (GTK_IS_WIDGET (child)) + bonobo_dock_set_client_area (BONOBO_DOCK (object), GTK_WIDGET (child)); } void GLADEGNOME_API -glade_gnome_bonobodock_remove_item (GObject *object, GObject *child) +glade_gnome_bonobodock_remove_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { BonoboDockBand *band; @@ -1584,50 +1645,36 @@ glade_gnome_bonobodock_remove_item (GObject *object, GObject *child) gtk_container_remove (GTK_CONTAINER (band), GTK_WIDGET (child)); } -void GLADEGNOME_API -glade_gnome_bonobodock_add_client_area (GObject *object, GObject *child) -{ - g_return_if_fail (BONOBO_IS_DOCK (object)); - bonobo_dock_set_client_area (BONOBO_DOCK (object), GTK_WIDGET (child)); -} - GList * GLADEGNOME_API -glade_gnome_bonobodock_get_children (GObject *object) +glade_gnome_bonobodock_get_children (GladeWidgetAdaptor *adaptor, + GObject *object) { - GList *list = NULL, *l; + GList *list = NULL, *l; + GtkWidget *client_area; BonoboDockLayout *layout; g_return_val_if_fail (BONOBO_IS_DOCK (object), NULL); - layout = bonobo_dock_get_layout (BONOBO_DOCK (object)); + layout = bonobo_dock_get_layout (BONOBO_DOCK (object)); + client_area = bonobo_dock_get_client_area (BONOBO_DOCK (object)); for (l = layout->items; l; l = l->next) { BonoboDockLayoutItem *li = (BonoboDockLayoutItem *) l->data; list = g_list_prepend (list, li->item); } - - return list; -} -GList * GLADEGNOME_API -glade_gnome_bonobodock_get_client_area (GObject *object) -{ - GtkWidget *client_area; - - g_return_val_if_fail (BONOBO_IS_DOCK (object), NULL); - - client_area = bonobo_dock_get_client_area (BONOBO_DOCK (object)); - - if (client_area) return g_list_append (NULL, client_area); + if (client_area) + list = g_list_prepend (list, client_area); - return NULL; + return g_list_reverse (list); } void GLADEGNOME_API -glade_gnome_bonobodock_replace_client_area (GtkWidget *container, - GtkWidget *current, - GtkWidget *new) +glade_gnome_bonobodock_replace_child (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *current, + GtkWidget *new) { g_return_if_fail (BONOBO_IS_DOCK (container)); bonobo_dock_set_client_area (BONOBO_DOCK (container), new); @@ -1662,10 +1709,11 @@ glade_gnome_bonobodockitem_get_props (BonoboDock *doc, } void GLADEGNOME_API -glade_gnome_bonobodock_set_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gnome_bonobodock_set_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { BonoboDock *dock; BonoboDockItem *item; @@ -1726,10 +1774,11 @@ glade_gnome_bonobodock_set_child_property (GObject *container, } void GLADEGNOME_API -glade_gnome_bonobodock_get_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gnome_bonobodock_get_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { BonoboDockPlacement placement; guint band_num, band_position, offset; @@ -1765,12 +1814,3 @@ glade_gnome_bonobodock_set_allow_floating (GObject *object, GValue *value) g_value_get_boolean (value)); } -/* BonoboDockItem */ -void GLADEGNOME_API -glade_gnome_bonobodockitem_post_create (GObject *object, GladeCreateReason reason) -{ - if (reason != GLADE_CREATE_USER) return; - g_return_if_fail (BONOBO_IS_DOCK_ITEM (object)); - - gtk_container_add (GTK_CONTAINER (object), glade_placeholder_new ()); -} diff --git a/src/glade-gtk.c b/src/glade-gtk.c index 9a2c3652..0570640b 100644 --- a/src/glade-gtk.c +++ b/src/glade-gtk.c @@ -18,6 +18,8 @@ * * Authors: * Chema Celorio <chema@celorio.com> + * Tristan Van Berkom <tvb@gnome.org> + * Juan Pablo Ugarte <juanpablougarte@gmail.com> */ #include <string.h> @@ -269,7 +271,9 @@ glade_gtk_widget_get_tooltip (GObject *object, GValue *value) /* ----------------------------- GtkContainer ------------------------------ */ void GLADEGTK_API -glade_gtk_container_post_create (GObject *container, GladeCreateReason reason) +glade_gtk_container_post_create (GladeWidgetAdaptor *adaptor, + GObject *container, + GladeCreateReason reason) { GList *children; g_return_if_fail (GTK_IS_CONTAINER (container)); @@ -284,9 +288,10 @@ glade_gtk_container_post_create (GObject *container, GladeCreateReason reason) } void GLADEGTK_API -glade_gtk_container_replace_child (GtkWidget *container, - GtkWidget *current, - GtkWidget *new) +glade_gtk_container_replace_child (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *current, + GtkWidget *new) { GParamSpec **param_spec; GValue *value; @@ -322,8 +327,9 @@ glade_gtk_container_replace_child (GtkWidget *container, } void GLADEGTK_API -glade_gtk_container_add_child (GtkWidget *container, - GtkWidget *child) +glade_gtk_container_add_child (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *child) { /* Get a placeholder out of the way before adding the child if its a GtkBin */ @@ -335,8 +341,9 @@ glade_gtk_container_add_child (GtkWidget *container, } void GLADEGTK_API -glade_gtk_container_remove_child (GtkWidget *container, - GtkWidget *child) +glade_gtk_container_remove_child (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *child) { gtk_container_remove (GTK_CONTAINER (container), child); @@ -346,6 +353,38 @@ glade_gtk_container_remove_child (GtkWidget *container, gtk_container_add (GTK_CONTAINER (container), glade_placeholder_new ()); } +void GLADEGTK_API +glade_gtk_container_set_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + const GValue *value) +{ + gtk_container_child_set_property (GTK_CONTAINER (container), + GTK_WIDGET (child), + property_name, value); +} + +void GLADEGTK_API +glade_gtk_container_get_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) +{ + gtk_container_child_get_property (GTK_CONTAINER (container), + GTK_WIDGET (child), + property_name, value); +} + + +GList * GLADEGTK_API +glade_gtk_container_get_children (GladeWidgetAdaptor *adaptor, + GtkContainer *container) +{ + return glade_util_container_get_all_children (container); +} + /* ----------------------------- GtkBox ------------------------------ */ typedef struct { GtkWidget *widget; @@ -549,7 +588,9 @@ glade_gtk_box_configure_end (GladeFixed *fixed, } void GLADEGTK_API -glade_gtk_box_post_create (GObject *container, GladeCreateReason reason) +glade_gtk_box_post_create (GladeWidgetAdaptor *adaptor, + GObject *container, + GladeCreateReason reason) { GladeWidget *gwidget = glade_widget_get_from_gobject (container); @@ -605,10 +646,11 @@ sort_box_children (GtkWidget *widget_a, GtkWidget *widget_b) } void GLADEGTK_API -glade_gtk_box_set_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gtk_box_set_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { GladeWidget *gbox, *gchild, *gchild_iter; GList *children, *list; @@ -640,8 +682,8 @@ glade_gtk_box_set_child_property (GObject *container, if (is_position && recursion == FALSE) { - children = glade_widget_class_container_get_children - (gbox->widget_class, container); + children = glade_widget_adaptor_get_children + (gbox->adaptor, container); children = g_list_sort (children, (GCompareFunc)sort_box_children); @@ -704,11 +746,12 @@ glade_gtk_box_set_child_property (GObject *container, /* Chain Up */ if (is_position == FALSE) - gtk_container_child_set_property (GTK_CONTAINER (container), - GTK_WIDGET (child), - property_name, - value); - + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->child_set_property (adaptor, + container, + child, + property_name, + value); gtk_container_check_resize (GTK_CONTAINER (container)); @@ -822,7 +865,9 @@ glade_gtk_box_verify_size (GObject *object, GValue *value) } void GLADEGTK_API -glade_gtk_box_add_child (GObject *object, GObject *child) +glade_gtk_box_add_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { GladeWidget *gbox, *gchild; GladeProject *project; @@ -867,33 +912,39 @@ glade_gtk_box_add_child (GObject *object, GObject *child) glade_widget_pack_property_set (gchild, "position", num_children - 1); } -void GLADEGTK_API -glade_gtk_box_get_internal_child (GObject *object, - const gchar *name, - GObject **child) +GObject * GLADEGTK_API +glade_gtk_box_get_internal_child (GladeWidgetAdaptor *adaptor, + GObject *object, + const gchar *name) { - GList *children, *l; - - g_return_if_fail (GTK_IS_BOX (object)); + GList *children, *l; + GObject *child = NULL; + + g_return_val_if_fail (GTK_IS_BOX (object), NULL); children = l = gtk_container_get_children (GTK_CONTAINER (object)); - *child = NULL; while (l) { GladeWidget *gw = glade_widget_get_from_gobject (l->data); if (gw && gw->internal && strcmp (gw->internal, name) == 0) - *child = G_OBJECT (l->data); + { + child = G_OBJECT (l->data); + break; + } l= l->next; } - g_list_free (children); + + return child; } void GLADEGTK_API -glade_gtk_box_remove_child (GObject *object, GObject *child) +glade_gtk_box_remove_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { GladeWidget *gbox; gint size; @@ -1328,7 +1379,9 @@ glade_gtk_table_configure_end (GladeFixed *fixed, } void GLADEGTK_API -glade_gtk_table_post_create (GObject *container, GladeCreateReason reason) +glade_gtk_table_post_create (GladeWidgetAdaptor *adaptor, + GObject *container, + GladeCreateReason reason) { GladeWidget *gwidget = glade_widget_get_from_gobject (container); @@ -1410,7 +1463,9 @@ glade_gtk_table_refresh_placeholders (GtkTable *table) void GLADEGTK_API -glade_gtk_table_add_child (GObject *object, GObject *child) +glade_gtk_table_add_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { g_return_if_fail (GTK_IS_TABLE (object)); g_return_if_fail (GTK_IS_WIDGET (child)); @@ -1421,7 +1476,9 @@ glade_gtk_table_add_child (GObject *object, GObject *child) } void GLADEGTK_API -glade_gtk_table_remove_child (GObject *object, GObject *child) +glade_gtk_table_remove_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { g_return_if_fail (GTK_IS_TABLE (object)); g_return_if_fail (GTK_IS_WIDGET (child)); @@ -1432,17 +1489,22 @@ glade_gtk_table_remove_child (GObject *object, GObject *child) } void GLADEGTK_API -glade_gtk_table_replace_child (GtkWidget *container, - GtkWidget *current, - GtkWidget *new) +glade_gtk_table_replace_child (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *current, + GtkWidget *new) { g_return_if_fail (GTK_IS_TABLE (container)); g_return_if_fail (GTK_IS_WIDGET (current)); g_return_if_fail (GTK_IS_WIDGET (new)); /* Chain Up */ - glade_gtk_container_replace_child (container, current, new); - + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->replace_child (adaptor, + G_OBJECT (container), + G_OBJECT (current), + G_OBJECT (new)); + /* If we are replacing a GladeWidget, we must refresh placeholders * because the widget may have spanned multiple rows/columns, we must * not do so in the case we are pasting multiple widgets into a table, @@ -1578,20 +1640,21 @@ glade_gtk_table_verify_n_columns (GObject *object, GValue *value) } void GLADEGTK_API -glade_gtk_table_set_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gtk_table_set_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { g_return_if_fail (GTK_IS_TABLE (container)); g_return_if_fail (GTK_IS_WIDGET (child)); g_return_if_fail (property_name != NULL && value != NULL); - gtk_container_child_set_property (GTK_CONTAINER (container), - GTK_WIDGET (child), - property_name, - value); - + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->child_set_property (adaptor, + container, child, + property_name, value); + if (strcmp (property_name, "bottom-attach") == 0 || strcmp (property_name, "left-attach") == 0 || strcmp (property_name, "right-attach") == 0 || @@ -1702,9 +1765,11 @@ glade_gtk_table_verify_bottom_attach (GObject *object, GValue *value) /* ----------------------------- GtkFrame ------------------------------ */ void GLADEGTK_API -glade_gtk_frame_post_create (GObject *frame, GladeCreateReason reason) +glade_gtk_frame_post_create (GladeWidgetAdaptor *adaptor, + GObject *frame, + GladeCreateReason reason) { - static GladeWidgetClass *label_class = NULL, *alignment_class = NULL; + static GladeWidgetAdaptor *label_adaptor = NULL, *alignment_adaptor = NULL; GladeWidget *gframe, *glabel, *galignment; GtkWidget *label; gchar *label_text; @@ -1722,13 +1787,13 @@ glade_gtk_frame_post_create (GObject *frame, GladeCreateReason reason) (GTK_IS_ASPECT_FRAME (frame) == FALSE)) { - if (label_class == NULL) - label_class = glade_widget_class_get_by_type (GTK_TYPE_LABEL); - if (alignment_class == NULL) - alignment_class = glade_widget_class_get_by_type (GTK_TYPE_ALIGNMENT); + if (label_adaptor == NULL) + label_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_LABEL); + if (alignment_adaptor == NULL) + alignment_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_ALIGNMENT); /* add label (as an internal child) */ - glabel = glade_widget_class_create_widget (label_class, FALSE, + glabel = glade_widget_adaptor_create_widget (label_adaptor, FALSE, "parent", gframe, "project", glade_widget_get_project (gframe), NULL); @@ -1744,7 +1809,7 @@ glade_gtk_frame_post_create (GObject *frame, GladeCreateReason reason) g_free (label_text); /* add alignment */ - galignment = glade_widget_class_create_widget (alignment_class, FALSE, + galignment = glade_widget_adaptor_create_widget (alignment_adaptor, FALSE, "parent", gframe, "project", glade_widget_get_project (gframe), NULL); @@ -1754,13 +1819,15 @@ glade_gtk_frame_post_create (GObject *frame, GladeCreateReason reason) gtk_widget_show (GTK_WIDGET (galignment->object)); } - glade_gtk_container_post_create (frame, reason); + /* Chain Up */ + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->post_create (adaptor, frame, reason); } void GLADEGTK_API -glade_gtk_frame_replace_child (GtkWidget *container, - GtkWidget *current, - GtkWidget *new) +glade_gtk_frame_replace_child (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *current, + GtkWidget *new) { gchar *special_child_type; @@ -1774,11 +1841,18 @@ glade_gtk_frame_replace_child (GtkWidget *container, return; } - glade_gtk_container_replace_child (container, current, new); + /* Chain Up */ + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->replace_child (adaptor, + G_OBJECT (container), + G_OBJECT (current), + G_OBJECT (new)); } void GLADEGTK_API -glade_gtk_frame_add_child (GObject *object, GObject *child) +glade_gtk_frame_add_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { gchar *special_child_type; @@ -2070,7 +2144,9 @@ glade_gtk_notebook_switch_page (GtkNotebook *notebook, void GLADEGTK_API -glade_gtk_notebook_post_create (GObject *notebook, GladeCreateReason reason) +glade_gtk_notebook_post_create (GladeWidgetAdaptor *adaptor, + GObject *notebook, + GladeCreateReason reason) { gtk_notebook_popup_disable (GTK_NOTEBOOK (notebook)); @@ -2185,7 +2261,9 @@ glade_gtk_notebook_verify_n_pages (GObject *object, GValue *value) } void GLADEGTK_API -glade_gtk_notebook_add_child (GObject *object, GObject *child) +glade_gtk_notebook_add_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { GtkNotebook *notebook; gint num_page, position = 0; @@ -2282,7 +2360,9 @@ glade_gtk_notebook_add_child (GObject *object, GObject *child) } void GLADEGTK_API -glade_gtk_notebook_remove_child (GObject *object, GObject *child) +glade_gtk_notebook_remove_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { NotebookChildren *nchildren; @@ -2318,9 +2398,10 @@ glade_gtk_notebook_remove_child (GObject *object, GObject *child) } void GLADEGTK_API -glade_gtk_notebook_replace_child (GtkWidget *container, - GtkWidget *current, - GtkWidget *new) +glade_gtk_notebook_replace_child (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *current, + GtkWidget *new) { GtkNotebook *notebook; GladeWidget *gcurrent, *gnew; @@ -2344,13 +2425,17 @@ glade_gtk_notebook_replace_child (GtkWidget *container, if (g_object_get_data (G_OBJECT (current), "special-child-type")) g_object_set_data (G_OBJECT (new), "special-child-type", "tab"); - glade_gtk_notebook_remove_child (G_OBJECT (container), G_OBJECT (current)); + glade_gtk_notebook_remove_child (adaptor, + G_OBJECT (container), + G_OBJECT (current)); if (GLADE_IS_PLACEHOLDER (new) == FALSE) { gnew = glade_widget_get_from_gobject (new); - glade_gtk_notebook_add_child (G_OBJECT (container), G_OBJECT (new)); + glade_gtk_notebook_add_child (adaptor, + G_OBJECT (container), + G_OBJECT (new)); if (glade_widget_pack_property_set (gnew, "position", position) == FALSE) g_critical ("No position property found on new widget"); @@ -2376,10 +2461,11 @@ glade_gtk_notebook_verify_position (GObject *object, GValue *value) } void GLADEGTK_API -glade_gtk_notebook_set_child_property (GObject *container, - GObject *child, - const gchar *property_name, - const GValue *value) +glade_gtk_notebook_set_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + const GValue *value) { NotebookChildren *nchildren; @@ -2396,17 +2482,18 @@ glade_gtk_notebook_set_child_property (GObject *container, } /* packing properties are unsupported on tabs ... except "position" */ else if (g_object_get_data (child, "special-child-type") == NULL) - gtk_container_child_set_property (GTK_CONTAINER (container), - GTK_WIDGET (child), - property_name, - value); + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->child_set_property (adaptor, + container, child, + property_name, value); } void GLADEGTK_API -glade_gtk_notebook_get_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gtk_notebook_get_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { gint position; @@ -2438,7 +2525,9 @@ glade_gtk_notebook_get_child_property (GObject *container, /* ----------------------------- GtkPaned ------------------------------ */ void GLADEGTK_API -glade_gtk_paned_post_create (GObject *paned, GladeCreateReason reason) +glade_gtk_paned_post_create (GladeWidgetAdaptor *adaptor, + GObject *paned, + GladeCreateReason reason) { g_return_if_fail (GTK_IS_PANED (paned)); @@ -2450,7 +2539,9 @@ glade_gtk_paned_post_create (GObject *paned, GladeCreateReason reason) } void GLADEGTK_API -glade_gtk_paned_add_child (GObject *object, GObject *child) +glade_gtk_paned_add_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { GtkPaned *paned; GtkWidget *child1, *child2; @@ -2500,18 +2591,21 @@ glade_gtk_paned_add_child (GObject *object, GObject *child) } void GLADEGTK_API -glade_gtk_paned_remove_child (GObject *object, GObject *child) +glade_gtk_paned_remove_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child)); - glade_gtk_paned_post_create (object, GLADE_CREATE_USER); + glade_gtk_paned_post_create (adaptor, object, GLADE_CREATE_USER); } void GLADEGTK_API -glade_gtk_paned_set_child_property (GObject *container, - GObject *child, - const gchar *property_name, - const GValue *value) +glade_gtk_paned_set_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + const GValue *value) { if (strcmp (property_name, "first") == 0) { @@ -2541,36 +2635,43 @@ glade_gtk_paned_set_child_property (GObject *container, gtk_paned_add2 (paned, glade_placeholder_new ()); } else - gtk_container_child_set_property (GTK_CONTAINER (container), - GTK_WIDGET (child), - property_name, value); + /* Chain Up */ + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->child_set_property (adaptor, + container, child, + property_name, value); } void GLADEGTK_API -glade_gtk_paned_get_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gtk_paned_get_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { if (strcmp (property_name, "first") == 0) g_value_set_boolean (value, GTK_WIDGET (child) == gtk_paned_get_child1 (GTK_PANED (container))); else - gtk_container_child_get_property (GTK_CONTAINER (container), - GTK_WIDGET (child), - property_name, value); + /* Chain Up */ + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->child_get_property (adaptor, + container, child, + property_name, value); } /* ----------------------------- GtkExpander ------------------------------ */ void GLADEGTK_API -glade_gtk_expander_post_create (GObject *expander, GladeCreateReason reason) +glade_gtk_expander_post_create (GladeWidgetAdaptor *adaptor, + GObject *expander, + GladeCreateReason reason) { - static GladeWidgetClass *wclass = NULL; + static GladeWidgetAdaptor *wadaptor = NULL; GladeWidget *gexpander, *glabel; GtkWidget *label; - if (wclass == NULL) - wclass = glade_widget_class_get_by_type (GTK_TYPE_LABEL); + if (wadaptor == NULL) + wadaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_LABEL); if (reason != GLADE_CREATE_USER) return; @@ -2582,7 +2683,7 @@ glade_gtk_expander_post_create (GObject *expander, GladeCreateReason reason) if ((label = gtk_expander_get_label_widget (GTK_EXPANDER (expander))) == NULL || (glade_widget_get_from_gobject (label) == NULL)) { - glabel = glade_widget_class_create_widget (wclass, FALSE, + glabel = glade_widget_adaptor_create_widget (wadaptor, FALSE, "parent", gexpander, "project", glade_widget_get_project (gexpander), NULL); @@ -2603,9 +2704,10 @@ glade_gtk_expander_post_create (GObject *expander, GladeCreateReason reason) } void GLADEGTK_API -glade_gtk_expander_replace_child (GtkWidget *container, - GtkWidget *current, - GtkWidget *new) +glade_gtk_expander_replace_child (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *current, + GtkWidget *new) { gchar *special_child_type; @@ -2619,12 +2721,19 @@ glade_gtk_expander_replace_child (GtkWidget *container, return; } - glade_gtk_container_replace_child (container, current, new); + /* Chain Up */ + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->replace_child (adaptor, + G_OBJECT (container), + G_OBJECT (current), + G_OBJECT (new)); } void GLADEGTK_API -glade_gtk_expander_add_child (GObject *object, GObject *child) +glade_gtk_expander_add_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { gchar *special_child_type; @@ -2636,14 +2745,14 @@ glade_gtk_expander_add_child (GObject *object, GObject *child) GTK_WIDGET (child)); } else - { - glade_gtk_container_add_child (GTK_WIDGET (object), - GTK_WIDGET (child)); - } + /* Chain Up */ + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->add (adaptor, object, child); } void GLADEGTK_API -glade_gtk_expander_remove_child (GObject *object, GObject *child) +glade_gtk_expander_remove_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { gchar *special_child_type; @@ -2680,7 +2789,9 @@ glade_gtk_entry_changed (GtkEditable *editable, GladeWidget *gentry) } void GLADEGTK_API -glade_gtk_entry_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_entry_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GladeWidget *gentry; @@ -2718,7 +2829,9 @@ glade_gtk_fixed_layout_realize (GtkWidget *widget) } void GLADEGTK_API -glade_gtk_fixed_layout_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_fixed_layout_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { /* This is needed at least to set a backing pixmap. */ GTK_WIDGET_UNSET_FLAGS(object, GTK_NO_WINDOW); @@ -2729,24 +2842,49 @@ glade_gtk_fixed_layout_post_create (GObject *object, GladeCreateReason reason) G_CALLBACK(glade_gtk_fixed_layout_realize), NULL); } +void GLADEGTK_API +glade_gtk_fixed_layout_add_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) +{ + g_return_if_fail (GTK_IS_CONTAINER (object)); + g_return_if_fail (GTK_IS_WIDGET (child)); + + gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child)); +} + +void GLADEGTK_API +glade_gtk_fixed_layout_remove_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) +{ + g_return_if_fail (GTK_IS_CONTAINER (object)); + g_return_if_fail (GTK_IS_WIDGET (child)); + + gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child)); +} /* ----------------------------- GtkWindow ------------------------------ */ void GLADEGTK_API -glade_gtk_window_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_window_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GtkWindow *window = GTK_WINDOW (object); g_return_if_fail (GTK_IS_WINDOW (window)); /* Chain her up first */ - glade_gtk_container_post_create (object, reason); + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->post_create (adaptor, object, reason); gtk_window_set_default_size (window, 440, 250); } /* ----------------------------- GtkDialog(s) ------------------------------ */ void GLADEGTK_API -glade_gtk_dialog_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_dialog_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GtkDialog *dialog = GTK_DIALOG (object); GladeWidget *widget; @@ -2769,40 +2907,40 @@ glade_gtk_dialog_post_create (GObject *object, GladeCreateReason reason) if (GTK_IS_INPUT_DIALOG (object)) { - save_button = glade_widget_class_create_internal + save_button = glade_widget_adaptor_create_internal (widget, G_OBJECT (GTK_INPUT_DIALOG (dialog)->save_button), "save_button", "inputdialog", FALSE, reason); - close_button = glade_widget_class_create_internal + close_button = glade_widget_adaptor_create_internal (widget, G_OBJECT (GTK_INPUT_DIALOG (dialog)->close_button), "close_button", "inputdialog", FALSE, reason); } else if (GTK_IS_FILE_SELECTION (object)) { - ok_button = glade_widget_class_create_internal + ok_button = glade_widget_adaptor_create_internal (widget, G_OBJECT (GTK_FILE_SELECTION (object)->ok_button), "ok_button", "filesel", FALSE, reason); - cancel_button = glade_widget_class_create_internal + cancel_button = glade_widget_adaptor_create_internal (widget, G_OBJECT (GTK_FILE_SELECTION (object)->cancel_button), "cancel_button", "filesel", FALSE, reason); } else if (GTK_IS_COLOR_SELECTION_DIALOG (object)) { - ok_button = glade_widget_class_create_internal + ok_button = glade_widget_adaptor_create_internal (widget, G_OBJECT (GTK_COLOR_SELECTION_DIALOG (object)->ok_button), "ok_button", "colorsel", FALSE, reason); - cancel_button = glade_widget_class_create_internal + cancel_button = glade_widget_adaptor_create_internal (widget, G_OBJECT (GTK_COLOR_SELECTION_DIALOG (object)->cancel_button), "cancel_button", "colorsel", FALSE, reason); - help_button = glade_widget_class_create_internal + help_button = glade_widget_adaptor_create_internal (widget, G_OBJECT (GTK_COLOR_SELECTION_DIALOG (object)->help_button), "help_button", "colorsel", FALSE, reason); - colorsel = glade_widget_class_create_internal + colorsel = glade_widget_adaptor_create_internal (widget, G_OBJECT (GTK_COLOR_SELECTION_DIALOG (object)->colorsel), "color_selection", "colorsel", FALSE, reason); @@ -2816,19 +2954,19 @@ glade_gtk_dialog_post_create (GObject *object, GladeCreateReason reason) } else if (GTK_IS_FONT_SELECTION_DIALOG (object)) { - ok_button = glade_widget_class_create_internal + ok_button = glade_widget_adaptor_create_internal (widget, G_OBJECT (GTK_FONT_SELECTION_DIALOG (object)->ok_button), "ok_button", "fontsel", FALSE, reason); - apply_button = glade_widget_class_create_internal + apply_button = glade_widget_adaptor_create_internal (widget, G_OBJECT (GTK_FONT_SELECTION_DIALOG (object)->apply_button), "apply_button", "fontsel", FALSE, reason); - cancel_button = glade_widget_class_create_internal + cancel_button = glade_widget_adaptor_create_internal (widget, G_OBJECT (GTK_FONT_SELECTION_DIALOG (object)->cancel_button), "cancel_button", "fontsel", FALSE, reason); - fontsel = glade_widget_class_create_internal + fontsel = glade_widget_adaptor_create_internal (widget, G_OBJECT (GTK_FONT_SELECTION_DIALOG (object)->fontsel), "font_selection", "fontsel", FALSE, reason); @@ -2841,11 +2979,11 @@ glade_gtk_dialog_post_create (GObject *object, GladeCreateReason reason) } else { - vbox_widget = glade_widget_class_create_internal + vbox_widget = glade_widget_adaptor_create_internal (widget, G_OBJECT(dialog->vbox), "vbox", "dialog", FALSE, reason); - actionarea_widget = glade_widget_class_create_internal + actionarea_widget = glade_widget_adaptor_create_internal (vbox_widget, G_OBJECT(dialog->action_area), "action_area", "dialog", FALSE, reason); @@ -2886,73 +3024,67 @@ glade_gtk_dialog_post_create (GObject *object, GladeCreateReason reason) } -void GLADEGTK_API -glade_gtk_dialog_get_internal_child (GtkDialog *dialog, - const gchar *name, - GtkWidget **child) +GtkWidget * GLADEGTK_API +glade_gtk_dialog_get_internal_child (GladeWidgetAdaptor *adaptor, + GtkDialog *dialog, + const gchar *name) { - g_return_if_fail (GTK_IS_DIALOG (dialog)); - + GtkWidget *child = NULL; + + g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL); if (GTK_IS_INPUT_DIALOG (dialog)) { if (strcmp ("close_button", name) == 0) - *child = GTK_INPUT_DIALOG (dialog)->close_button; + child = GTK_INPUT_DIALOG (dialog)->close_button; else if (strcmp ("save_button", name) == 0) - *child = GTK_INPUT_DIALOG (dialog)->save_button; - else - *child = NULL; + child = GTK_INPUT_DIALOG (dialog)->save_button; } else if (GTK_IS_FILE_SELECTION (dialog)) { if (strcmp ("ok_button", name) == 0) - *child = GTK_FILE_SELECTION (dialog)->ok_button; + child = GTK_FILE_SELECTION (dialog)->ok_button; else if (strcmp ("cancel_button", name) == 0) - *child = GTK_FILE_SELECTION (dialog)->cancel_button; - else - *child = NULL; + child = GTK_FILE_SELECTION (dialog)->cancel_button; } else if (GTK_IS_COLOR_SELECTION_DIALOG (dialog)) { if (strcmp ("ok_button", name) == 0) - *child = GTK_COLOR_SELECTION_DIALOG (dialog)->ok_button; + child = GTK_COLOR_SELECTION_DIALOG (dialog)->ok_button; else if (strcmp ("cancel_button", name) == 0) - *child = GTK_COLOR_SELECTION_DIALOG (dialog)->cancel_button; + child = GTK_COLOR_SELECTION_DIALOG (dialog)->cancel_button; else if (strcmp ("help_button", name) == 0) - *child = GTK_COLOR_SELECTION_DIALOG (dialog)->help_button; + child = GTK_COLOR_SELECTION_DIALOG (dialog)->help_button; else if (strcmp ("color_selection", name) == 0) - *child = GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel; - else - *child = NULL; + child = GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel; } else if (GTK_IS_FONT_SELECTION_DIALOG (dialog)) { if (strcmp ("ok_button", name) == 0) - *child = GTK_FONT_SELECTION_DIALOG (dialog)->ok_button; + child = GTK_FONT_SELECTION_DIALOG (dialog)->ok_button; else if (strcmp ("apply_button", name) == 0) - *child = GTK_FONT_SELECTION_DIALOG (dialog)->apply_button; + child = GTK_FONT_SELECTION_DIALOG (dialog)->apply_button; else if (strcmp ("cancel_button", name) == 0) - *child = GTK_FONT_SELECTION_DIALOG (dialog)->cancel_button; + child = GTK_FONT_SELECTION_DIALOG (dialog)->cancel_button; else if (strcmp ("font_selection", name) == 0) - *child = GTK_FONT_SELECTION_DIALOG (dialog)->fontsel; - else - *child = NULL; + child = GTK_FONT_SELECTION_DIALOG (dialog)->fontsel; } else { /* Default generic dialog handling */ if (strcmp ("vbox", name) == 0) - *child = dialog->vbox; + child = dialog->vbox; else if (strcmp ("action_area", name) == 0) - *child = dialog->action_area; - else - *child = NULL; + child = dialog->action_area; } + + return child; } GList * GLADEGTK_API -glade_gtk_dialog_get_children (GtkDialog *dialog) +glade_gtk_dialog_get_children (GladeWidgetAdaptor *adaptor, + GtkDialog *dialog) { GList *list = NULL; @@ -3100,7 +3232,9 @@ glade_gtk_button_post_create_parse_finished (GladeProject *project, } void GLADEGTK_API -glade_gtk_button_post_create (GObject *button, GladeCreateReason reason) +glade_gtk_button_post_create (GladeWidgetAdaptor *adaptor, + GObject *button, + GladeCreateReason reason) { GladeWidget *gbutton = glade_widget_get_from_gobject (button); @@ -3258,14 +3392,20 @@ glade_gtk_button_set_stock (GObject *object, GValue *value) } void GLADEGTK_API -glade_gtk_button_replace_child (GtkWidget *container, - GtkWidget *current, - GtkWidget *new) +glade_gtk_button_replace_child (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *current, + GtkWidget *new) { GladeWidget *gbutton = glade_widget_get_from_gobject (container); g_return_if_fail (GLADE_IS_WIDGET (gbutton)); - glade_gtk_container_replace_child (container, current, new); + + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->replace_child (adaptor, + G_OBJECT (container), + G_OBJECT (current), + G_OBJECT (new)); if (GLADE_IS_PLACEHOLDER (new)) glade_widget_property_set_sensitive (gbutton, "glade-type", TRUE, NULL); @@ -3277,7 +3417,9 @@ glade_gtk_button_replace_child (GtkWidget *container, } void GLADEGTK_API -glade_gtk_button_add_child (GObject *object, GObject *child) +glade_gtk_button_add_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { GladeWidget *gwidget; @@ -3297,7 +3439,9 @@ glade_gtk_button_add_child (GObject *object, GObject *child) } void GLADEGTK_API -glade_gtk_button_remove_child (GObject *object, GObject *child) +glade_gtk_button_remove_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { GladeWidget *gwidget = glade_widget_get_from_gobject (object); @@ -3375,7 +3519,9 @@ glade_gtk_image_parse_finished (GladeProject *project, GladeWidget *gimage) } void GLADEGTK_API -glade_gtk_image_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_image_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GladeWidget *gimage; @@ -3459,14 +3605,14 @@ void GLADEGTK_API glade_gtk_image_set_stock (GObject *object, GValue *value) { GladeWidget *gwidget; - const gchar *str; - gint icon_size; + gchar *str; + gint icon_size; g_return_if_fail (GTK_IS_IMAGE (object)); gwidget = glade_widget_get_from_gobject (object); g_return_if_fail (GLADE_IS_WIDGET (gwidget)); - if ((str = g_value_get_string (value)) && + if ((str = g_value_dup_string (value)) && glade_util_object_is_loading (object)) { GEnumClass *eclass = g_type_class_ref (GLADE_TYPE_STOCK); @@ -3483,6 +3629,11 @@ glade_gtk_image_set_stock (GObject *object, GValue *value) /* Set the real property */ glade_widget_property_get (gwidget, "icon-size", &icon_size); gtk_image_set_from_stock (GTK_IMAGE (object), str, icon_size); + + /* Sometimes it gets recursive around here, valgrind says + * we should dup a string for this purpose ;-) + */ + g_free (str); } void GLADEGTK_API @@ -3513,7 +3664,9 @@ glade_gtk_image_set_glade_stock (GObject *object, GValue *value) /* ----------------------------- GtkMenuShell ------------------------------ */ void GLADEGTK_API -glade_gtk_menu_shell_add_item (GObject *object, GObject *child) +glade_gtk_menu_shell_add_item (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { g_return_if_fail (GTK_IS_MENU_SHELL (object)); @@ -3524,7 +3677,9 @@ glade_gtk_menu_shell_add_item (GObject *object, GObject *child) void GLADEGTK_API -glade_gtk_menu_shell_remove_item (GObject *object, GObject *child) +glade_gtk_menu_shell_remove_item (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) { g_return_if_fail (GTK_IS_MENU_SHELL (object)); g_return_if_fail (GTK_IS_MENU_ITEM (child)); @@ -3550,10 +3705,11 @@ glade_gtk_menu_shell_get_item_position (GObject *container, GObject *child) } void GLADEGTK_API -glade_gtk_menu_shell_get_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gtk_menu_shell_get_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { g_return_if_fail (GTK_IS_MENU_SHELL (container)); g_return_if_fail (GTK_IS_MENU_ITEM (child)); @@ -3566,16 +3722,20 @@ glade_gtk_menu_shell_get_child_property (GObject *container, } else /* Chain Up */ - gtk_container_child_get_property (GTK_CONTAINER (container), - GTK_WIDGET (child), - property_name, value); + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->child_get_property (adaptor, + container, + child, + property_name, + value); } void GLADEGTK_API -glade_gtk_menu_shell_set_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gtk_menu_shell_set_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { g_return_if_fail (GTK_IS_MENU_SHELL (container)); g_return_if_fail (GTK_IS_MENU_ITEM (child)); @@ -3605,10 +3765,10 @@ glade_gtk_menu_shell_set_child_property (GObject *container, } else /* Chain Up */ - gtk_container_child_set_property (GTK_CONTAINER (container), - GTK_WIDGET (child), - property_name, - value); + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->child_set_property (adaptor, + container, child, + property_name, value); } static gchar * glade_gtk_menu_shell_get_display_name (GladeBaseEditor *editor, @@ -3634,7 +3794,7 @@ glade_gtk_menu_shell_item_get_parent (GladeWidget *gparent, GObject *parent) if ((submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (parent)))) gparent = glade_widget_get_from_gobject (submenu); else - gparent = glade_command_create (glade_widget_class_get_by_type (GTK_TYPE_MENU), + gparent = glade_command_create (glade_widget_adaptor_get_by_type (GTK_TYPE_MENU), gparent, NULL, glade_widget_get_project (gparent)); return gparent; } @@ -3656,7 +3816,7 @@ glade_gtk_menu_shell_build_child (GladeBaseEditor *editor, gparent = glade_gtk_menu_shell_item_get_parent (gparent, parent); /* Build child */ - gitem_new = glade_command_create (glade_widget_class_get_by_type (type), + gitem_new = glade_command_create (glade_widget_adaptor_get_by_type (type), gparent, NULL, glade_widget_get_project (gparent)); @@ -3826,7 +3986,8 @@ glade_gtk_menu_shell_launch_editor (GObject *object, gchar *title) /* ----------------------------- GtkMenuItem(s) ------------------------------ */ GList * GLADEGTK_API -glade_gtk_menu_item_get_submenu (GObject *object) +glade_gtk_menu_item_get_submenu (GladeWidgetAdaptor *adaptor, + GObject *object) { GList *list = NULL; GtkWidget *child; @@ -3841,7 +4002,8 @@ glade_gtk_menu_item_get_submenu (GObject *object) } void GLADEGTK_API -glade_gtk_menu_item_add_submenu (GObject *object, GObject *child) +glade_gtk_menu_item_add_submenu (GladeWidgetAdaptor *adaptor, + GObject *object, GObject *child) { g_return_if_fail (GTK_IS_MENU_ITEM (object)); g_return_if_fail (GTK_IS_MENU (child)); @@ -3856,7 +4018,8 @@ glade_gtk_menu_item_add_submenu (GObject *object, GObject *child) } void GLADEGTK_API -glade_gtk_menu_item_remove_submenu (GObject *object, GObject *child) +glade_gtk_menu_item_remove_submenu (GladeWidgetAdaptor *adaptor, + GObject *object, GObject *child) { g_return_if_fail (GTK_IS_MENU_ITEM (object)); g_return_if_fail (GTK_IS_MENU (child)); @@ -3868,7 +4031,9 @@ glade_gtk_menu_item_remove_submenu (GObject *object, GObject *child) if ((v) == GPOINTER_TO_INT (g_object_get_data (G_OBJECT (o), p))) return; g_object_set_data (G_OBJECT (o), p, GINT_TO_POINTER ((v))) void GLADEGTK_API -glade_gtk_menu_item_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_menu_item_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GladeWidget *gitem, *gimage; @@ -3911,7 +4076,7 @@ glade_gtk_menu_item_post_create (GObject *object, GladeCreateReason reason) { GtkWidget *image = gtk_image_new (); - gimage = glade_widget_class_create_internal + gimage = glade_widget_adaptor_create_internal (gitem, G_OBJECT (image), "image", "menu-item", FALSE, reason); gtk_image_menu_item_set_image @@ -3991,13 +4156,14 @@ glade_gtk_menu_item_set_use_underline (GObject *object, GValue *value) gtk_label_set_use_underline (GTK_LABEL (label), g_value_get_boolean (value)); } -void GLADEGTK_API -glade_gtk_image_menu_item_get_internal_child (GObject *parent, - const gchar *name, - GObject **child) +GObject * GLADEGTK_API +glade_gtk_image_menu_item_get_internal_child (GladeWidgetAdaptor *adaptor, + GObject *parent, + const gchar *name) { GtkWidget *image; - + GObject *child = NULL; + if (GTK_IS_IMAGE_MENU_ITEM (parent) && strcmp (name, "image") == 0) { image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (parent)); @@ -4010,15 +4176,14 @@ glade_gtk_image_menu_item_get_internal_child (GObject *parent, gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (parent), image); - gimage = glade_widget_class_create_internal + gimage = glade_widget_adaptor_create_internal (gitem, G_OBJECT (image), "image", "menu-item", FALSE, GLADE_CREATE_LOAD); } - *child = G_OBJECT (image); + child = G_OBJECT (image); } - else *child = NULL; - return; + return child; } void GLADEGTK_API @@ -4052,7 +4217,7 @@ glade_gtk_image_menu_item_set_use_stock (GObject *object, GValue *value) { image = gtk_image_new (); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (object), image); - gimage = glade_widget_class_create_internal + gimage = glade_widget_adaptor_create_internal (gitem, G_OBJECT (image), "image", "menu-item", FALSE, GLADE_CREATE_LOAD); glade_project_add_object (glade_widget_get_project (gitem), @@ -4208,7 +4373,9 @@ glade_gtk_menu_item_set_stock_item (GObject *object, GValue *value) eval = g_enum_get_value_by_nick (eclass, icon); g_type_class_unref (eclass); - glade_gtk_image_menu_item_get_internal_child (object, "image", &image); + image = glade_gtk_image_menu_item_get_internal_child + (gitem->adaptor, object, "image"); + gimage = glade_widget_get_from_gobject (image); glade_widget_property_set (gimage, "icon-size", GTK_ICON_SIZE_MENU); glade_widget_property_set (gimage, "glade-stock", eval->value); @@ -4237,13 +4404,13 @@ glade_gtk_radio_menu_item_set_group (GObject *object, GValue *value) static GladeWidget * glade_gtk_menu_bar_append_new_submenu (GladeWidget *parent, GladeProject *project) { - static GladeWidgetClass *submenu_class = NULL; + static GladeWidgetAdaptor *submenu_adaptor = NULL; GladeWidget *gsubmenu; - if (submenu_class == NULL) - submenu_class = glade_widget_class_get_by_type (GTK_TYPE_MENU); + if (submenu_adaptor == NULL) + submenu_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_MENU); - gsubmenu = glade_widget_class_create_widget (submenu_class, FALSE, + gsubmenu = glade_widget_adaptor_create_widget (submenu_adaptor, FALSE, "parent", parent, "project", project, NULL); @@ -4259,19 +4426,19 @@ glade_gtk_menu_bar_append_new_item (GladeWidget *parent, const gchar *label, gboolean use_stock) { - static GladeWidgetClass *item_class = NULL, *image_item_class, *separator_class; + static GladeWidgetAdaptor *item_adaptor = NULL, *image_item_adaptor, *separator_adaptor; GladeWidget *gitem; - if (item_class == NULL) + if (item_adaptor == NULL) { - item_class = glade_widget_class_get_by_type (GTK_TYPE_MENU_ITEM); - image_item_class = glade_widget_class_get_by_type (GTK_TYPE_IMAGE_MENU_ITEM); - separator_class = glade_widget_class_get_by_type (GTK_TYPE_SEPARATOR_MENU_ITEM); + item_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_MENU_ITEM); + image_item_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_IMAGE_MENU_ITEM); + separator_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_SEPARATOR_MENU_ITEM); } if (label) { - gitem = glade_widget_class_create_widget ((use_stock) ? image_item_class : item_class, + gitem = glade_widget_adaptor_create_widget ((use_stock) ? image_item_adaptor : item_adaptor, FALSE, "parent", parent, "project", project, NULL); @@ -4298,7 +4465,7 @@ glade_gtk_menu_bar_append_new_item (GladeWidget *parent, } else { - gitem = glade_widget_class_create_widget (separator_class, + gitem = glade_widget_adaptor_create_widget (separator_adaptor, FALSE, "parent", parent, "project", project, NULL); @@ -4310,7 +4477,9 @@ glade_gtk_menu_bar_append_new_item (GladeWidget *parent, } void GLADEGTK_API -glade_gtk_menu_bar_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_menu_bar_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GladeProject *project; GladeWidget *gmenubar, *gitem, *gsubmenu; @@ -4351,24 +4520,25 @@ glade_gtk_menu_bar_post_create (GObject *object, GladeCreateReason reason) } void GLADEGTK_API -glade_gtk_menu_bar_launch_editor (GObject *menubar) +glade_gtk_menu_bar_launch_editor (GladeWidgetAdaptor *adaptor, GObject *menubar) { glade_gtk_menu_shell_launch_editor (menubar, _("Menu Bar Editor")); } /* ------------------------------ GtkMenu -------------------------------- */ void GLADEGTK_API -glade_gtk_menu_launch_editor (GObject *menu) +glade_gtk_menu_launch_editor (GladeWidgetAdaptor *adaptor, GObject *menu) { glade_gtk_menu_shell_launch_editor (menu, _("Menu Editor")); } /* ----------------------------- GtkToolBar ------------------------------ */ void GLADEGTK_API -glade_gtk_toolbar_get_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gtk_toolbar_get_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { g_return_if_fail (GTK_IS_TOOLBAR (container)); if (GTK_IS_TOOL_ITEM (child) == FALSE) return; @@ -4381,16 +4551,18 @@ glade_gtk_toolbar_get_child_property (GObject *container, } else /* Chain Up */ - gtk_container_child_get_property (GTK_CONTAINER (container), - GTK_WIDGET (child), - property_name, value); + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->child_get_property (adaptor, + container, child, + property_name, value); } void GLADEGTK_API -glade_gtk_toolbar_set_child_property (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) +glade_gtk_toolbar_set_child_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) { g_return_if_fail (GTK_IS_TOOLBAR (container)); g_return_if_fail (GTK_IS_TOOL_ITEM (child)); @@ -4414,14 +4586,15 @@ glade_gtk_toolbar_set_child_property (GObject *container, } else /* Chain Up */ - gtk_container_child_set_property (GTK_CONTAINER (container), - GTK_WIDGET (child), - property_name, - value); + GWA_GET_CLASS + (GTK_TYPE_CONTAINER)->child_set_property (adaptor, + container, child, + property_name, value); } void GLADEGTK_API -glade_gtk_toolbar_add_child (GObject *object, GObject *child) +glade_gtk_toolbar_add_child (GladeWidgetAdaptor *adaptor, + GObject *object, GObject *child) { GtkToolbar *toolbar; GtkToolItem *item; @@ -4446,7 +4619,8 @@ glade_gtk_toolbar_add_child (GObject *object, GObject *child) } void GLADEGTK_API -glade_gtk_toolbar_remove_child (GObject *object, GObject *child) +glade_gtk_toolbar_remove_child (GladeWidgetAdaptor *adaptor, + GObject *object, GObject *child) { gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child)); } @@ -4510,7 +4684,8 @@ glade_gtk_toolbar_child_selected (GladeBaseEditor *editor, } void GLADEGTK_API -glade_gtk_toolbar_launch_editor (GObject *toolbar) +glade_gtk_toolbar_launch_editor (GladeWidgetAdaptor *adaptor, + GObject *toolbar) { GladeBaseEditor *editor; GtkWidget *window; @@ -4544,7 +4719,9 @@ glade_gtk_toolbar_launch_editor (GObject *toolbar) /* ----------------------------- GtkToolItem ------------------------------ */ void GLADEGTK_API -glade_gtk_tool_item_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_tool_item_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { g_return_if_fail (GTK_IS_TOOL_ITEM (object)); @@ -4765,7 +4942,9 @@ glade_gtk_text_view_stop_double_click (GtkWidget *widget, } void GLADEGTK_API -glade_gtk_text_view_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_text_view_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GtkTextBuffer *buffy = gtk_text_buffer_new (NULL); GladeWidget *gtext; @@ -4810,7 +4989,9 @@ glade_gtk_text_view_set_text (GObject *object, GValue *value) /* ----------------------------- GtkComboBox ------------------------------ */ void GLADEGTK_API -glade_gtk_combo_box_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_combo_box_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GtkCellRenderer *cell; GtkListStore *store; @@ -4855,29 +5036,32 @@ glade_gtk_combo_box_set_items (GObject *object, GValue *value) /* ----------------------------- GtkComboBoxEntry ------------------------------ */ void GLADEGTK_API -glade_gtk_combo_box_entry_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_combo_box_entry_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GladeWidget *gcombo = glade_widget_get_from_gobject (object); /* Chain up */ - glade_gtk_combo_box_post_create (object, reason); + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->post_create (adaptor, object, reason); - glade_widget_class_create_internal + glade_widget_adaptor_create_internal (gcombo, G_OBJECT (GTK_BIN (object)->child), "entry", "comboboxentry", FALSE, reason); } -void GLADEGTK_API -glade_gtk_combo_box_entry_get_internal_child (GObject *object, - const gchar *name, - GObject **child) +GObject * GLADEGTK_API +glade_gtk_combo_box_entry_get_internal_child (GladeWidgetAdaptor *adaptor, + GObject *object, + const gchar *name) { - g_return_if_fail (GTK_IS_COMBO_BOX_ENTRY (object)); + GObject *child = NULL; + g_return_val_if_fail (GTK_IS_COMBO_BOX_ENTRY (object), NULL); if (strcmp ("entry", name) == 0) - *child = G_OBJECT (gtk_bin_get_child (GTK_BIN (object))); - else - *child = NULL; + child = G_OBJECT (gtk_bin_get_child (GTK_BIN (object))); + + return child; } /* ----------------------------- GtkOptionMenu ------------------------------ */ @@ -4954,7 +5138,9 @@ glade_gtk_spin_button_set_adjustment (GObject *object, GValue *value) /* ----------------------------- GtkTreeView ------------------------------ */ void GLADEGTK_API -glade_gtk_tree_view_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_tree_view_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GtkWidget *tree_view = GTK_WIDGET (object); GtkTreeStore *store; @@ -4980,7 +5166,9 @@ glade_gtk_tree_view_post_create (GObject *object, GladeCreateReason reason) /* ----------------------------- GtkCombo ------------------------------ */ void GLADEGTK_API -glade_gtk_combo_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_combo_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GladeWidget *gcombo, *gentry, *glist; @@ -4989,30 +5177,32 @@ glade_gtk_combo_post_create (GObject *object, GladeCreateReason reason) if ((gcombo = glade_widget_get_from_gobject (object)) == NULL) return; - gentry = glade_widget_class_create_internal + gentry = glade_widget_adaptor_create_internal (gcombo, G_OBJECT (GTK_COMBO (object)->entry), "entry", "combo", FALSE, reason); /* We mark this 'anarchist' since its outside of the hierarchy */ - glist = glade_widget_class_create_internal + glist = glade_widget_adaptor_create_internal (gcombo, G_OBJECT (GTK_COMBO (object)->list), "list", "combo", TRUE, reason); } -void GLADEGTK_API -glade_gtk_combo_get_internal_child (GtkCombo *combo, - const gchar *name, - GtkWidget **child) +GObject * GLADEGTK_API +glade_gtk_combo_get_internal_child (GladeWidgetAdaptor *adaptor, + GtkCombo *combo, + const gchar *name) { - g_return_if_fail (GTK_IS_COMBO (combo)); + GObject *child = NULL; + + g_return_val_if_fail (GTK_IS_COMBO (combo), NULL); if (strcmp ("list", name) == 0) - *child = combo->list; + child = G_OBJECT (combo->list); else if (strcmp ("entry", name) == 0) - *child = combo->entry; - else - *child = NULL; + child = G_OBJECT (combo->entry); + + return child; } GList * GLADEGTK_API @@ -5033,7 +5223,9 @@ glade_gtk_combo_get_children (GtkCombo *combo) /* ----------------------------- GtkListItem ------------------------------ */ void GLADEGTK_API -glade_gtk_list_item_post_create (GObject *object, GladeCreateReason reason) +glade_gtk_list_item_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) { GtkWidget *label; @@ -5070,3 +5262,26 @@ glade_gtk_list_item_get_label (GObject *object, GValue *value) g_value_set_string (value, gtk_label_get_text (GTK_LABEL (label))); } + + +void GLADEGTK_API +glade_gtk_listitem_add_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) +{ + g_return_if_fail (GTK_IS_CONTAINER (object)); + g_return_if_fail (GTK_IS_WIDGET (child)); + + gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child)); +} + +void GLADEGTK_API +glade_gtk_listitem_remove_child (GladeWidgetAdaptor *adaptor, + GObject *object, + GObject *child) +{ + g_return_if_fail (GTK_IS_CONTAINER (object)); + g_return_if_fail (GTK_IS_WIDGET (child)); + + gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child)); +} diff --git a/src/glade-palette-item.c b/src/glade-palette-item.c index ca9b09d1..5125c36f 100644 --- a/src/glade-palette-item.c +++ b/src/glade-palette-item.c @@ -48,13 +48,15 @@ struct _GladePaletteItemPrivate gboolean use_small_icon; - const GladeWidgetClass *widget_class; /* The widget class associated with this item */ + GladeWidgetAdaptor *adaptor; /* The widget class adaptor associated + * with this item + */ }; enum { PROP_0, - PROP_WIDGET_CLASS, + PROP_ADAPTOR, PROP_APPEARANCE, PROP_USE_SMALL_ICON }; @@ -133,6 +135,8 @@ void glade_palette_item_set_use_small_icon (GladePaletteItem *item, gboolean use_small_icon) { GladePaletteItemPrivate *priv; + GdkPixbuf *pixbuf = NULL; + g_return_if_fail (GLADE_IS_PALETTE_ITEM (item)); priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item); @@ -142,12 +146,13 @@ glade_palette_item_set_use_small_icon (GladePaletteItem *item, gboolean use_smal priv->use_small_icon = use_small_icon; if (use_small_icon != FALSE) - gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon), - priv->widget_class->small_icon); + g_object_get (priv->adaptor, "small-icon", &pixbuf, NULL); else - gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon), - priv->widget_class->large_icon); + g_object_get (priv->adaptor, "large-icon", &pixbuf, NULL); + gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon), pixbuf); + g_object_unref (G_OBJECT (pixbuf)); + g_object_notify (G_OBJECT (item), "use-small-icon"); } } @@ -169,8 +174,8 @@ glade_palette_item_set_property (GObject *object, switch (prop_id) { - case PROP_WIDGET_CLASS: - priv->widget_class = (const GladeWidgetClass *) g_value_get_pointer (value); + case PROP_ADAPTOR: + priv->adaptor = g_value_get_object (value); break; case PROP_APPEARANCE: glade_palette_item_set_appearance (item, g_value_get_enum (value)); @@ -195,8 +200,8 @@ glade_palette_item_get_property (GObject *object, switch (prop_id) { - case PROP_WIDGET_CLASS: - g_value_set_pointer (value, (gpointer) priv->widget_class); + case PROP_ADAPTOR: + g_value_set_pointer (value, (gpointer) priv->adaptor); break; case PROP_APPEARANCE: g_value_set_enum (value, priv->appearance); @@ -241,11 +246,12 @@ glade_palette_item_class_init (GladePaletteItemClass *class) object_class->dispose = glade_palette_item_dispose; g_object_class_install_property (object_class, - PROP_WIDGET_CLASS, - g_param_spec_pointer ("widget-class", - "Widget Class", - "The widget class associated with this item", - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE )); + PROP_ADAPTOR, + g_param_spec_object ("adaptor", + "Adaptor", + "The widget adaptor associated with this item", + GLADE_TYPE_WIDGET_ADAPTOR, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE )); g_object_class_install_property (object_class, PROP_APPEARANCE, @@ -276,7 +282,7 @@ glade_palette_item_init (GladePaletteItem *item) priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item); priv->label = NULL; - priv->widget_class = NULL; + priv->adaptor = NULL; priv->use_small_icon = FALSE; priv->appearance = 0; @@ -334,23 +340,24 @@ glade_palette_item_get_type (void) /** * glade_palette_item_new: - * @widget_class: A #GladeWidgetClass + * @adaptor: A #GladeWidgetAdaptor * @group: The group to add this item to. * @appearance: The appearance of the item * * Returns: A #GtkWidget */ GtkWidget* -glade_palette_item_new (const GladeWidgetClass *widget_class, GtkRadioButton *group) +glade_palette_item_new (GladeWidgetAdaptor *adaptor, GtkRadioButton *group) { - GladePaletteItem *item; + GladePaletteItem *item; GladePaletteItemPrivate *priv; + GdkPixbuf *pixbuf = NULL; - g_return_val_if_fail (widget_class != NULL, NULL); + g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL); item = g_object_new (GLADE_TYPE_PALETTE_ITEM, "group", group, - "widget-class", widget_class, + "adaptor", adaptor, "appearance", GLADE_ITEM_ICON_ONLY, NULL); @@ -358,8 +365,15 @@ glade_palette_item_new (const GladeWidgetClass *widget_class, GtkRadioButton *gr priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item); - gtk_label_set_text (GTK_LABEL (priv->label), widget_class->palette_name); - gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon), widget_class->large_icon); + gtk_label_set_text (GTK_LABEL (priv->label), adaptor->title); + + g_object_get (G_OBJECT (adaptor), "large-icon", &pixbuf, NULL); + if (pixbuf) + { + gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon), pixbuf); + g_object_unref (G_OBJECT (pixbuf)); + } else + g_warning ("couldnt get an icon from adaptor %s\n", adaptor->name); return GTK_WIDGET (item); } @@ -393,17 +407,17 @@ glade_palette_item_get_use_small_icon (GladePaletteItem *item) } /** - * glade_palette_item_get_widget_class: + * glade_palette_item_get_adaptor: * @palette: A #GladePaletteItem * * Returns: the #GladeWidgetClass associated with this item. */ -GladeWidgetClass* -glade_palette_item_get_widget_class (GladePaletteItem *item) +GladeWidgetAdaptor * +glade_palette_item_get_adaptor (GladePaletteItem *item) { GladePaletteItemPrivate *priv; g_return_val_if_fail (GLADE_IS_PALETTE_ITEM (item), NULL); priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item); - return (GladeWidgetClass *) priv->widget_class; + return priv->adaptor; } diff --git a/src/glade-palette-item.h b/src/glade-palette-item.h index f3e5ea80..1da37d60 100644 --- a/src/glade-palette-item.h +++ b/src/glade-palette-item.h @@ -29,7 +29,7 @@ #include "glade.h" #include "glade-palette.h" -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" #include <gtk/gtkradiobutton.h> @@ -70,10 +70,10 @@ struct _GladePaletteItemClass GType glade_palette_item_get_type (void) G_GNUC_CONST; -GtkWidget *glade_palette_item_new (const GladeWidgetClass* widget_class, - GtkRadioButton *group); +GtkWidget *glade_palette_item_new (GladeWidgetAdaptor *adaptor, + GtkRadioButton *group); -GladeWidgetClass* glade_palette_item_get_widget_class (GladePaletteItem *item) G_GNUC_CONST; +GladeWidgetAdaptor *glade_palette_item_get_adaptor (GladePaletteItem *item) G_GNUC_CONST; GladeItemAppearance glade_palette_item_get_appearance (GladePaletteItem *item) G_GNUC_CONST; diff --git a/src/glade-palette.c b/src/glade-palette.c index e6c801c3..5aa44ab4 100644 --- a/src/glade-palette.c +++ b/src/glade-palette.c @@ -38,7 +38,7 @@ #include "glade-catalog.h" #include "glade-project.h" #include "glade-widget.h" -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" #include <glib/gi18n-lib.h> #include <gdk/gdk.h> @@ -53,7 +53,7 @@ struct _GladePalettePrivate GtkWidget *selector; /* Selector item button */ GtkWidget *tray; /* Where all the item groups are contained */ - GladeWidgetClass *current_item_class; /* The currently selected item class */ + GladeWidgetAdaptor *current_item; /* The currently selected item adaptor */ GSList *sections; /* List of GladePaletteExpanders */ GSList *items_radio_group; /* Radio group for palette item buttons */ @@ -78,7 +78,7 @@ enum enum { PROP_0, - PROP_CURRENT_ITEM_CLASS, + PROP_CURRENT_ITEM, PROP_ITEM_APPEARANCE, PROP_USE_SMALL_ITEM_ICONS }; @@ -175,8 +175,8 @@ glade_palette_get_property (GObject *object, switch (prop_id) { - case PROP_CURRENT_ITEM_CLASS: - g_value_set_pointer (value, (gpointer) priv->current_item_class); + case PROP_CURRENT_ITEM: + g_value_set_pointer (value, (gpointer) priv->current_item); break; case PROP_USE_SMALL_ITEM_ICONS: g_value_set_boolean (value, priv->use_small_item_icons); @@ -266,10 +266,10 @@ glade_palette_class_init (GladePaletteClass *class) G_PARAM_READWRITE)); g_object_class_install_property (object_class, - PROP_CURRENT_ITEM_CLASS, - g_param_spec_pointer ("current-item-class", + PROP_CURRENT_ITEM, + g_param_spec_pointer ("current-item", "Current Item Class", - "The GladeWidgetClass of the currently selected item", + "The GladeWidgetAdaptor of the currently selected item", G_PARAM_READABLE)); g_type_class_add_private (object_class, sizeof (GladePalettePrivate)); @@ -291,40 +291,40 @@ glade_palette_on_button_toggled (GtkWidget *button, GladePalette *palette) if (button == priv->selector) { - priv->current_item_class = NULL; + priv->current_item = NULL; priv->locked = FALSE; } else { GdkModifierType mask; - priv->current_item_class = - glade_palette_item_get_widget_class (GLADE_PALETTE_ITEM (button)); + priv->current_item = + glade_palette_item_get_adaptor (GLADE_PALETTE_ITEM (button)); gdk_window_get_pointer (button->window, NULL, NULL, &mask); priv->locked = - (!priv->current_item_class->toplevel) && (mask & GDK_CONTROL_MASK); + (! GWA_IS_TOPLEVEL (priv->current_item)) && (mask & GDK_CONTROL_MASK); } g_signal_emit (G_OBJECT (palette), glade_palette_signals[TOGGLED], 0); } static GtkWidget* -glade_palette_new_item (GladePalette *palette, GladeWidgetClass *widget_class) +glade_palette_new_item (GladePalette *palette, GladeWidgetAdaptor *adaptor) { GladePalettePrivate *priv; GtkWidget *item; g_return_val_if_fail (GLADE_IS_PALETTE (palette), NULL); - g_return_val_if_fail (GLADE_IS_WIDGET_CLASS (widget_class), NULL); + g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL); priv = GLADE_PALETTE_GET_PRIVATE (palette); - item = glade_palette_item_new (widget_class, GTK_RADIO_BUTTON (priv->selector)); + item = glade_palette_item_new (adaptor, GTK_RADIO_BUTTON (priv->selector)); glade_palette_item_set_appearance (GLADE_PALETTE_ITEM (item), priv->item_appearance); - gtk_tooltips_set_tip (priv->tooltips, item, widget_class->palette_name, NULL); + gtk_tooltips_set_tip (priv->tooltips, item, adaptor->title, NULL); g_signal_connect (G_OBJECT (item), "toggled", G_CALLBACK (glade_palette_on_button_toggled), palette); @@ -349,12 +349,12 @@ glade_palette_new_item_group (GladePalette *palette, GladeWidgetGroup *group) box = glade_palette_box_new (); /* Go through all the widget classes in this catalog. */ - for (l = glade_widget_group_get_widget_classes (group); l; l = l->next) + for (l = glade_widget_group_get_adaptors (group); l; l = l->next) { - GladeWidgetClass *class = GLADE_WIDGET_CLASS (l->data); + GladeWidgetAdaptor *adaptor = GLADE_WIDGET_ADAPTOR (l->data); /* Create new item */ - item = glade_palette_new_item (palette, class); + item = glade_palette_new_item (palette, adaptor); gtk_size_group_add_widget (priv->size_group, GTK_WIDGET (item)); gtk_container_add (GTK_CONTAINER (box), item); @@ -490,7 +490,7 @@ glade_palette_init (GladePalette *palette) priv = GLADE_PALETTE_GET_PRIVATE (palette); priv->catalogs = NULL; - priv->current_item_class = NULL; + priv->current_item = NULL; priv->items_radio_group = NULL; priv->sections = NULL; priv->item_appearance = GLADE_ITEM_ICON_ONLY; @@ -550,23 +550,23 @@ glade_palette_get_type (void) } /** - * glade_palette_get_current_item_class: + * glade_palette_get_current_item: * @palette: a #GladePalette * - * Gets the #GladeWidgetClass of the currently selected item. + * Gets the #GladeWidgetAdaptor of the currently selected item. * - * Returns: the #GladeWidgetClass of currently selected item, or NULL + * Returns: the #GladeWidgetAdaptor of currently selected item, or NULL * if no item is selected. */ -GladeWidgetClass * -glade_palette_get_current_item_class (GladePalette *palette) +GladeWidgetAdaptor * +glade_palette_get_current_item (GladePalette *palette) { GladePalettePrivate *priv; g_return_val_if_fail (GLADE_IS_PALETTE (palette), NULL); priv = GLADE_PALETTE_GET_PRIVATE (palette); - return priv->current_item_class; + return priv->current_item; } @@ -608,7 +608,7 @@ glade_palette_new (const GList *catalogs, GladeItemAppearance item_appearance) { GladeWidgetGroup *group = GLADE_WIDGET_GROUP (groups->data); - if (glade_widget_group_get_widget_classes (group)) + if (glade_widget_group_get_adaptors (group)) glade_palette_append_item_group (palette, group); } } diff --git a/src/glade-palette.h b/src/glade-palette.h index 973344fc..f6501d76 100644 --- a/src/glade-palette.h +++ b/src/glade-palette.h @@ -71,7 +71,7 @@ LIBGLADEUI_API void glade_palette_deselect_current_item (GladePalette *palette); LIBGLADEUI_API -GladeWidgetClass *glade_palette_get_current_item_class (GladePalette *palette) G_GNUC_CONST; +GladeWidgetAdaptor *glade_palette_get_current_item (GladePalette *palette) G_GNUC_CONST; LIBGLADEUI_API GladeItemAppearance glade_palette_get_item_appearance (GladePalette *palette) G_GNUC_CONST; diff --git a/src/glade-placeholder.c b/src/glade-placeholder.c index 7bd6195d..19d81d8b 100644 --- a/src/glade-placeholder.c +++ b/src/glade-placeholder.c @@ -276,15 +276,15 @@ glade_placeholder_expose (GtkWidget *widget, GdkEventExpose *event) static gboolean glade_placeholder_motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { - GladeWidgetClass *item_class; - GladeWidget *gparent; + GladeWidgetAdaptor *adaptor; + GladeWidget *gparent; g_return_val_if_fail (GLADE_IS_PLACEHOLDER (widget), FALSE); - gparent = glade_placeholder_get_parent (GLADE_PLACEHOLDER (widget)); - item_class = glade_palette_get_current_item_class (glade_app_get_palette ()); + gparent = glade_placeholder_get_parent (GLADE_PLACEHOLDER (widget)); + adaptor = glade_palette_get_current_item (glade_app_get_palette ()); - if (item_class == NULL && + if (adaptor == NULL && /* If we are the child of a widget that is in a GladeFixed, then * we are the means of drag/resize and we dont want to fight for * the cursor (ideally; GladeCursor should somehow deal with such @@ -293,7 +293,7 @@ glade_placeholder_motion_notify_event (GtkWidget *widget, GdkEventMotion *event) (gparent->parent && GLADE_IS_FIXED (gparent->parent)) == FALSE) glade_cursor_set (event->window, GLADE_CURSOR_SELECTOR); - else if (item_class) + else if (adaptor) glade_cursor_set (event->window, GLADE_CURSOR_ADD_WIDGET); return FALSE; @@ -302,15 +302,15 @@ glade_placeholder_motion_notify_event (GtkWidget *widget, GdkEventMotion *event) static gboolean glade_placeholder_button_press (GtkWidget *widget, GdkEventButton *event) { - GladePlaceholder *placeholder; - GladeProject *project; - GladeWidgetClass *item_class; - GladePalette *palette; - gboolean handled = FALSE; + GladePlaceholder *placeholder; + GladeProject *project; + GladeWidgetAdaptor *adaptor; + GladePalette *palette; + gboolean handled = FALSE; g_return_val_if_fail (GLADE_IS_PLACEHOLDER (widget), FALSE); - item_class = glade_palette_get_current_item_class (glade_app_get_palette ()); + adaptor = glade_palette_get_current_item (glade_app_get_palette ()); palette = glade_app_get_palette (); placeholder = GLADE_PLACEHOLDER (widget); @@ -321,13 +321,13 @@ glade_placeholder_button_press (GtkWidget *widget, GdkEventButton *event) if (event->button == 1 && event->type == GDK_BUTTON_PRESS) { - if (item_class != NULL) + if (adaptor != NULL) { /* A widget type is selected in the palette. * Add a new widget of that type. */ glade_command_create - (item_class, + (adaptor, glade_placeholder_get_parent (placeholder), placeholder, project); diff --git a/src/glade-popup.c b/src/glade-popup.c index ba3e6340..fc7ce332 100644 --- a/src/glade-popup.c +++ b/src/glade-popup.c @@ -28,7 +28,7 @@ #include "glade.h" #include "glade-widget.h" -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" #include "glade-popup.h" #include "glade-placeholder.h" #include "glade-clipboard.h" @@ -105,20 +105,6 @@ glade_popup_delete_cb (GtkMenuItem *item, GladeWidget *widget) glade_app_command_delete (); } - -static void -glade_popup_add_item_cb (GtkMenuItem *item, - GladeWidget *widget) -{ - GladeWidgetClass *class; - - if ((class = - g_object_get_data (G_OBJECT (item), "widget_class")) != NULL) - glade_command_create (class, widget, NULL, - glade_app_get_project ()); -} - - /******************************************************** PLACEHOLDER POPUP *******************************************************/ @@ -219,46 +205,6 @@ glade_popup_populate_childs (GtkWidget* popup_menu, GladeWidget* parent) } } -static void -glade_popup_add_children (GtkWidget* popup_menu, GladeWidget *widget) -{ - GtkWidget *menu_item = - gtk_image_menu_item_new_from_stock (GTK_STOCK_ADD, NULL); - GtkWidget *add_menu = gtk_menu_new (); - GList *list, *types, *l; - - gtk_widget_show (menu_item); - gtk_widget_show (add_menu); - - gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), menu_item); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), add_menu); - - for (list = widget->widget_class->children; - list && list->data; list = list->next) - { - GladeSupportedChild *support = list->data; - - if (support->type == GTK_TYPE_WIDGET) - continue; - - if ((types = - glade_widget_class_get_derived_types (support->type)) != NULL) - { - for (l = types; l && l->data; l = l->next) - { - GladeWidgetClass *class = l->data; - GtkWidget *item = - glade_popup_append_item - (add_menu, NULL, g_type_name (class->type), - TRUE, glade_popup_add_item_cb, widget); - g_object_set_data (G_OBJECT (item), - "widget_class", class); - - } - g_list_free (types); - } - } -} static GtkWidget * glade_popup_create_menu (GladeWidget *widget, gboolean add_childs) @@ -284,11 +230,8 @@ glade_popup_create_menu (GladeWidget *widget, gboolean add_childs) glade_popup_append_item (popup_menu, GTK_STOCK_PROPERTIES, NULL, TRUE, glade_popup_properties_cb, widget); - if (glade_widget_class_contains_extra (widget->widget_class)) - glade_popup_add_children (popup_menu, widget); - if (add_childs && - !g_type_is_a (widget->widget_class->type, GTK_TYPE_WINDOW)) { + !g_type_is_a (widget->adaptor->type, GTK_TYPE_WINDOW)) { GladeWidget *parent = glade_widget_get_parent (widget); g_return_val_if_fail (GLADE_IS_WIDGET (parent), popup_menu); glade_popup_populate_childs(popup_menu, parent); diff --git a/src/glade-project-view.c b/src/glade-project-view.c index b6684694..cd9e3c08 100644 --- a/src/glade-project-view.c +++ b/src/glade-project-view.c @@ -29,7 +29,7 @@ #include "glade.h" #include "glade-widget.h" #include "glade-project.h" -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" #include "glade-project-view.h" #include "glade-popup.h" #include "glade-app.h" @@ -138,8 +138,8 @@ glade_project_view_populate_model_real (GtkTreeStore *model, gtk_tree_store_set (model, &iter, WIDGET_COLUMN, widget, -1); if (add_childs && - (children = glade_widget_class_container_get_children - (widget->widget_class, widget->object)) != NULL) + (children = glade_widget_adaptor_get_children + (widget->adaptor, widget->object)) != NULL) { GtkTreeIter *copy = NULL; @@ -220,11 +220,8 @@ static void glade_project_view_remove_item (GladeProjectView *view, GladeWidget *widget) { - GladeWidgetClass *class; - GtkTreeModel *model; - GtkTreeIter *iter; - - class = glade_widget_get_class (widget); + GtkTreeModel *model; + GtkTreeIter *iter; model = GTK_TREE_MODEL (view->priv->model); @@ -260,7 +257,6 @@ glade_project_view_selection_update (GladeProjectView *view, GladeProject *project) { GladeWidget *widget; - GladeWidgetClass *class; GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter *iter; @@ -286,8 +282,6 @@ glade_project_view_selection_update (GladeProjectView *view, if ((widget = glade_widget_get_from_gobject (G_OBJECT (list->data))) != NULL) { - class = glade_widget_get_class (widget); - if ((iter = glade_util_find_iter_by_widget (model, widget, WIDGET_COLUMN)) != NULL) { @@ -615,24 +609,26 @@ glade_project_view_cell_function (GtkTreeViewColumn *tree_column, gpointer data) { GPVCellType type = GPOINTER_TO_INT (data); + GdkPixbuf *small_icon = NULL; GladeWidget *widget; gchar *text = NULL, *child_type; gtk_tree_model_get (tree_model, iter, WIDGET_COLUMN, &widget, -1); /* The cell exists, but not widget has been asociated with it */ - if (!widget) return; + if (!GLADE_IS_WIDGET (widget)) return; g_return_if_fail (widget->name != NULL); - g_return_if_fail (widget->widget_class != NULL); - g_return_if_fail (widget->widget_class->name != NULL); - g_return_if_fail (widget->widget_class->small_icon != NULL); + g_return_if_fail (widget->adaptor != NULL); + g_return_if_fail (widget->adaptor->name != NULL); + + g_object_get (widget->adaptor, "small-icon", &small_icon, NULL); + g_return_if_fail (small_icon != NULL); switch (type) { case CELL_ICON: - g_object_set (G_OBJECT (cell), "pixbuf", - widget->widget_class->small_icon, NULL); + g_object_set (G_OBJECT (cell), "pixbuf", small_icon, NULL); break; case CELL_NAME: g_object_set (G_OBJECT (cell), "text", widget->name, NULL); @@ -652,6 +648,8 @@ glade_project_view_cell_function (GtkTreeViewColumn *tree_column, default: break; } + + g_object_unref (small_icon); } static void diff --git a/src/glade-project.c b/src/glade-project.c index add6cd86..78a021fc 100644 --- a/src/glade-project.c +++ b/src/glade-project.c @@ -31,18 +31,13 @@ #include <glib/gstdio.h> #include "glade.h" -#include "glade-project.h" -#include "glade-widget.h" -#include "glade-widget-class.h" -#include "glade-xml-utils.h" #include "glade-widget.h" -#include "glade-placeholder.h" -#include "glade-editor.h" -#include "glade-utils.h" #include "glade-id-allocator.h" #include "glade-app.h" -#include "glade-catalog.h" #include "glade-marshallers.h" +#include "glade-catalog.h" + +#include "glade-project.h" enum { @@ -116,9 +111,9 @@ glade_project_dispose (GObject *object) gwidget = glade_widget_get_from_gobject (list->data); if (gwidget->parent && - glade_widget_class_container_has_child (gwidget->parent->widget_class, - gwidget->parent->object, - gwidget->object)) + glade_widget_adaptor_has_child (gwidget->parent->adaptor, + gwidget->parent->object, + gwidget->object)) glade_widget_remove_child (gwidget->parent, gwidget); } @@ -792,8 +787,8 @@ glade_project_sync_resources_for_widget (GladeProject *project, GList *children, *l; GladeWidget *gchild; - children = glade_widget_class_container_get_children - (gwidget->widget_class, gwidget->object); + children = glade_widget_adaptor_get_children + (gwidget->adaptor, gwidget->object); for (l = children; l; l = l->next) if ((gchild = @@ -842,8 +837,8 @@ glade_project_add_object (GladeProject *project, /* Code body starts here */ reentrancy_count++; - if ((children = glade_widget_class_container_get_children - (gwidget->widget_class, gwidget->object)) != NULL) + if ((children = glade_widget_adaptor_get_children + (gwidget->adaptor, gwidget->object)) != NULL) { for (list = children; list && list->data; list = list->next) glade_project_add_object @@ -978,8 +973,9 @@ glade_project_remove_object (GladeProject *project, GObject *object) /* Notify widget is being removed from the project */ glade_widget_project_notify (gwidget, NULL); - if ((children = glade_widget_class_container_get_children (gwidget->widget_class, - gwidget->object)) != NULL) + if ((children = + glade_widget_adaptor_get_children (gwidget->adaptor, + gwidget->object)) != NULL) { for (list = children; list && list->data; list = list->next) glade_project_remove_object (project, G_OBJECT (list->data)); @@ -1304,23 +1300,25 @@ glade_project_required_libs (GladeProject *project) for (l = project->objects; l; l = l->next) { + gchar *catalog = NULL; + gwidget = glade_widget_get_from_gobject (l->data); g_assert (gwidget); - if (gwidget->widget_class->catalog) + g_object_get (gwidget->adaptor, "catalog", &catalog, NULL); + + if (catalog) { listed = FALSE; for (ll = required; ll; ll = ll->next) - if (!strcmp ((gchar *)ll->data, - gwidget->widget_class->catalog)) + if (!strcmp ((gchar *)ll->data, catalog)) { listed = TRUE; break; } if (!listed) - required = g_list_prepend - (required, gwidget->widget_class->catalog); + required = g_list_prepend (required, catalog); } } return required; @@ -1397,7 +1395,7 @@ glade_project_write (GladeProject *project) { strv = g_malloc0 (g_list_length (required) * sizeof (char *)); for (i = 0, list = required; list; i++, list = list->next) - strv[i] = g_strdup (list->data); + strv[i] = list->data; /* list->data is allocated for us */ interface->n_requires = g_list_length (required); interface->requires = strv; diff --git a/src/glade-property-class.c b/src/glade-property-class.c index e836430f..34624428 100644 --- a/src/glade-property-class.c +++ b/src/glade-property-class.c @@ -31,7 +31,6 @@ #include "glade.h" #include "glade-widget.h" -#include "glade-widget-class.h" #include "glade-parameter.h" #include "glade-property.h" #include "glade-property-class.h" diff --git a/src/glade-property.c b/src/glade-property.c index ea6baeda..edb7a5a8 100644 --- a/src/glade-property.c +++ b/src/glade-property.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright (C) 2001 Ximian, Inc. + * Copyright (C) 2006 The GNOME Foundation. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -37,7 +38,7 @@ #include "glade-property-class.h" #include "glade-parameter.h" #include "glade-project.h" -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" #include "glade-debug.h" #include "glade-app.h" #include "glade-editor.h" @@ -141,8 +142,8 @@ glade_property_sync_property (GladeProperty *property, const GValue *value) { GladeWidget *parent = glade_widget_get_parent (property->widget); GladeWidget *child = property->widget; - glade_widget_class_container_set_property - (parent->widget_class, parent->object, child->object, + glade_widget_adaptor_child_set_property + (parent->adaptor, parent->object, child->object, property->class->id, value); } else diff --git a/src/glade-property.h b/src/glade-property.h index 7916f744..86dd09d9 100644 --- a/src/glade-property.h +++ b/src/glade-property.h @@ -80,7 +80,7 @@ struct _GladePropertyKlass }; LIBGLADEUI_API -GType glade_property_get_type (void); +GType glade_property_get_type (void) G_GNUC_CONST; LIBGLADEUI_API GladeProperty *glade_property_new (GladePropertyClass *class, GladeWidget *widget, diff --git a/src/glade-signal-editor.c b/src/glade-signal-editor.c index 723550f6..f6c939bd 100644 --- a/src/glade-signal-editor.c +++ b/src/glade-signal-editor.c @@ -29,7 +29,7 @@ #include "glade.h" #include "glade-widget.h" -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" #include "glade-signal.h" #include "glade-signal-editor.h" #include "glade-editor.h" @@ -840,14 +840,14 @@ glade_signal_editor_load_widget (GladeSignalEditor *editor, gtk_tree_store_clear (editor->model); editor->widget = widget; - editor->class = widget ? widget->widget_class : NULL; + editor->adaptor = widget ? widget->adaptor : NULL; if (!widget) return; /* Loop over every signal type */ - for (list = editor->class->signals; list; list = list->next) + for (list = editor->adaptor->signals; list; list = list->next) { GladeSignalClass *signal = (GladeSignalClass *) list->data; diff --git a/src/glade-signal-editor.h b/src/glade-signal-editor.h index 060bb0ec..43834bdc 100644 --- a/src/glade-signal-editor.h +++ b/src/glade-signal-editor.h @@ -21,7 +21,7 @@ struct _GladeSignalEditor GtkWidget *main_window; /* A vbox where all the widgets are added */ GladeWidget *widget; - GladeWidgetClass *class; + GladeWidgetAdaptor *adaptor; gpointer *editor; diff --git a/src/glade-signal.h b/src/glade-signal.h index c23a4b2b..0c2ff3ac 100644 --- a/src/glade-signal.h +++ b/src/glade-signal.h @@ -2,6 +2,8 @@ #ifndef __GLADE_SIGNAL_H__ #define __GLADE_SIGNAL_H__ +#include "glade-parser.h" + G_BEGIN_DECLS diff --git a/src/glade-utils.c b/src/glade-utils.c index 1ecd0a46..67e97910 100644 --- a/src/glade-utils.c +++ b/src/glade-utils.c @@ -38,7 +38,7 @@ #include "glade-debug.h" #include "glade-placeholder.h" #include "glade-widget.h" -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" #include "glade-property.h" #include "glade-property-class.h" #include "glade-clipboard.h" @@ -125,11 +125,12 @@ glade_util_compose_get_type_func (const gchar *name) /** * glade_util_get_type_from_name: - * @name: + * @name: the name of the #GType - like 'GtkWidget'. * - * TODO: write me + * Looks up the type registering function from a plugin + * and initializes & returns the type for @name. * - * Returns: + * Returns: the new #GType */ GType glade_util_get_type_from_name (const gchar *name) @@ -1003,13 +1004,11 @@ glade_util_container_get_all_children (GtkContainer *container) gboolean glade_util_gtkcontainer_relation (GladeWidget *parent, GladeWidget *widget) { - GladeSupportedChild *support; g_return_val_if_fail (GLADE_IS_WIDGET (parent), FALSE); g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE); - return (GTK_IS_CONTAINER (parent->object) && - (support = glade_widget_class_get_child_support - (parent->widget_class, widget->widget_class->type)) && - (support->type == GTK_TYPE_WIDGET)); + + return (GTK_IS_CONTAINER (parent->object) && + GTK_IS_WIDGET (widget->object)); } /** @@ -1044,9 +1043,9 @@ glade_util_widget_pastable (GladeWidget *child, { g_return_val_if_fail (GLADE_IS_WIDGET (child), FALSE); g_return_val_if_fail (GLADE_IS_WIDGET (parent), FALSE); - return (glade_widget_class_get_child_support - (parent->widget_class, - child->widget_class->type) != NULL) ? TRUE : FALSE; + + /* FIXME: what to do now ? */ + return TRUE; } /** @@ -1062,8 +1061,8 @@ glade_util_count_placeholders (GladeWidget *parent) GList *list, *children; /* count placeholders */ - if ((children = glade_widget_class_container_get_children - (parent->widget_class, parent->object)) != NULL) + if ((children = glade_widget_adaptor_get_children + (parent->adaptor, parent->object)) != NULL) { for (list = children; list && list->data; list = list->next) { @@ -1686,7 +1685,7 @@ glade_util_deep_fixed_event (GtkWidget *widget, search = search->parent); if (search && GLADE_IS_FIXED (search) && search != gwidget) - return GLADE_WIDGET_GET_KLASS (search)->event (widget, event, search); + return GLADE_WIDGET_GET_CLASS (search)->event (widget, event, search); return FALSE; } diff --git a/src/glade-widget-adaptor.c b/src/glade-widget-adaptor.c new file mode 100644 index 00000000..2bf87e19 --- /dev/null +++ b/src/glade-widget-adaptor.c @@ -0,0 +1,1938 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2001 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Authors: + * Tristan Van Berkom <tvb@gnome.org> + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +/* For g_file_exists */ +#include <sys/types.h> +#include <string.h> + +#include <glib/gdir.h> +#include <gmodule.h> +#include <ctype.h> + +#include <glib/gi18n-lib.h> + +#include "glade.h" +#include "glade-widget-adaptor.h" +#include "glade-xml-utils.h" +#include "glade-property-class.h" +#include "glade-signal.h" + +struct _GladeWidgetAdaptorPriv { + + gchar *catalog; /* The name of the widget catalog this class + * was declared by. + */ + + gchar *book; /* DevHelp search namespace for this widget class + */ + + GdkPixbuf *large_icon; /* The 22x22 icon for the widget */ + GdkPixbuf *small_icon; /* The 16x16 icon for the widget */ + + GdkCursor *cursor; /* a cursor for inserting widgets */ + + + GModule *module; /* Module with the (optional) special functions + * needed for placeholder_replace, post_create_function + * and the set & get functions of the properties + * of this class. + */ + + gchar *special_child_type; /* Special case code for children that + * are special children (like notebook tab + * widgets for example). + */ +}; + +struct _GladeChildPacking { + gchar *parent_name; + GList *packing_defaults; +}; + +enum { + PROP_0, + PROP_NAME, + PROP_TYPE, + PROP_TITLE, + PROP_GENERIC_NAME, + PROP_CATALOG, + PROP_BOOK, + PROP_SPECIAL_TYPE, + PROP_SMALL_ICON, + PROP_LARGE_ICON, + PROP_CURSOR +}; + +typedef struct _GladeChildPacking GladeChildPacking; + + +static GObjectClass *parent_class = NULL; +static GHashTable *adaptor_hash = NULL; + + +/******************************************************************************* + Helper functions + *******************************************************************************/ +static GladeWidgetAdaptor * +gwa_get_parent_adaptor (GladeWidgetAdaptor *adaptor) +{ + GladeWidgetAdaptor *parent_adaptor = NULL; + GType iter_type; + + for (iter_type = g_type_parent (adaptor->type); + iter_type > 0; + iter_type = g_type_parent (iter_type)) + { + if ((parent_adaptor = + glade_widget_adaptor_get_by_type (iter_type)) != NULL) + return parent_adaptor; + } + + return NULL; +} + +/* + This function assignes "weight" to each property in its natural order staring from 1. + If parent is 0 weight will be set for every GladePropertyClass in the list. + This function will not override weight if it is already set (weight >= 0.0) +*/ +static void +gwa_properties_set_weight (GList **properties, GType parent) +{ + gint normal = 0, common = 0, packing = 0; + GList *l; + + for (l = *properties; l && l->data; l = g_list_next (l)) + { + GladePropertyClass *class = l->data; + GPCType type = class->type; + + if (class->visible && + (parent) ? parent == class->pspec->owner_type : TRUE && + (type == GPC_NORMAL || type == GPC_ACCEL_PROPERTY)) + { + /* Use a different counter for each tab (common, packing and normal) */ + if (class->common) common++; + else if (class->packing) packing++; + else normal++; + + /* Skip if it is already set */ + if (class->weight >= 0.0) continue; + + /* Special-casing weight of properties for seperate tabs */ + if (class->common) class->weight = common; + else if (class->packing) class->weight = packing; + else class->weight = normal; + } + } +} + +static void +gwa_load_icons (GladeWidgetAdaptor *adaptor) +{ + GError *error = NULL; + gchar *icon_path; + + /* only certain widget classes need to have icons */ + if (G_TYPE_IS_INSTANTIATABLE (adaptor->type) == FALSE || + G_TYPE_IS_ABSTRACT (adaptor->type) != FALSE || + adaptor->generic_name == NULL) + return; + + /* load large 22x22 icon */ + icon_path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S + GLADE_LARGE_ICON_SUBDIR + G_DIR_SEPARATOR_S "%s.png", + glade_pixmaps_dir, + adaptor->generic_name); + + adaptor->priv->large_icon = + gdk_pixbuf_new_from_file_at_size (icon_path, + GLADE_LARGE_ICON_SIZE, + GLADE_LARGE_ICON_SIZE, + &error); + + if (adaptor->priv->large_icon == NULL) + { + g_warning (_("Unable to load icon for %s (%s)"), + adaptor->name, error->message); + + g_error_free (error); + error = NULL; + + /* use stock missing icon */ + adaptor->priv->large_icon = + gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + GTK_STOCK_MISSING_IMAGE, + GLADE_LARGE_ICON_SIZE, + GTK_ICON_LOOKUP_USE_BUILTIN, + &error); + if (adaptor->priv->large_icon == NULL) + { + g_critical (_("Unable to load stock icon (%s)"), + error->message); + + g_error_free (error); + error = NULL; + } + } + g_free (icon_path); + + + /* load small 16x16 icon */ + icon_path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S + GLADE_SMALL_ICON_SUBDIR + G_DIR_SEPARATOR_S "%s.png", + glade_pixmaps_dir, + adaptor->generic_name); + + adaptor->priv->small_icon = + gdk_pixbuf_new_from_file_at_size (icon_path, + GLADE_SMALL_ICON_SIZE, + GLADE_SMALL_ICON_SIZE, + &error); + + if (adaptor->priv->small_icon == NULL) + { + g_warning (_("Unable to load icon for %s (%s)"), + adaptor->name, error->message); + + g_error_free (error); + error = NULL; + + /* use stock missing icon */ + adaptor->priv->small_icon = + gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + GTK_STOCK_MISSING_IMAGE, + GLADE_SMALL_ICON_SIZE, + GTK_ICON_LOOKUP_USE_BUILTIN, + &error); + if (adaptor->priv->small_icon == NULL) + { + g_critical (_("Unable to load stock icon (%s)"), + error->message); + + g_error_free (error); + error = NULL; + } + } + + g_free (icon_path); + +} + +static void +gwa_create_cursor (GladeWidgetAdaptor *adaptor) +{ + GdkPixbuf *tmp_pixbuf; + const GdkPixbuf *add_pixbuf; + GdkDisplay *display; + + /* only certain widget classes need to have cursors */ + if (G_TYPE_IS_INSTANTIATABLE (adaptor->type) == FALSE || + G_TYPE_IS_ABSTRACT (adaptor->type) != FALSE || + adaptor->generic_name == NULL) + return; + + /* cannot continue if 'add widget' cursor pixbuf has not been loaded for any reason */ + if ((add_pixbuf = glade_cursor_get_add_widget_pixbuf ()) == NULL) + return; + + display = gdk_display_get_default (); + + /* create a temporary pixbuf clear to transparent black*/ + tmp_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 32, 32); + gdk_pixbuf_fill (tmp_pixbuf, 0x00000000); + + + /* composite pixbufs */ + gdk_pixbuf_composite (adaptor->priv->large_icon, tmp_pixbuf, + 8, 8, 22, 22, + 8, 8, 1, 1, + GDK_INTERP_NEAREST, 255); + + gdk_pixbuf_composite (add_pixbuf, tmp_pixbuf, + 0, 0, 12, 12, + 0, 0, 1, 1, + GDK_INTERP_NEAREST, 255); + + + adaptor->priv->cursor = gdk_cursor_new_from_pixbuf (display, tmp_pixbuf, 6, 6); + + g_object_unref(tmp_pixbuf); +} + + + +static gboolean +gwa_gtype_equal (gconstpointer v1, + gconstpointer v2) +{ + return *((const GType*) v1) == *((const GType*) v2); +} + +static guint +gwa_gtype_hash (gconstpointer v) +{ + return *(const GType*) v; +} + + +/******************************************************************************* + Base Object Implementation detail + *******************************************************************************/ +static gint +gwa_signal_comp (gconstpointer a, gconstpointer b) +{ + const GladeSignalClass *signal_a = a, *signal_b = b; + return strcmp (signal_b->query.signal_name, signal_a->query.signal_name); +} + +static void +gwa_add_signals (GList **signals, GType type) +{ + guint count, *sig_ids, num_signals; + GladeSignalClass *cur; + GList *list = NULL; + + if (G_TYPE_IS_INSTANTIATABLE (type) || G_TYPE_IS_INTERFACE (type)) + { + sig_ids = g_signal_list_ids (type, &num_signals); + + for (count = 0; count < num_signals; count++) + { + cur = g_new0 (GladeSignalClass, 1); + + g_signal_query (sig_ids[count], &(cur->query)); + + /* Since glib gave us this signal id... it should + * exist no matter what. + */ + g_assert (cur->query.signal_id != 0); + + cur->name = (cur->query.signal_name); + cur->type = (gchar *) g_type_name (type); + + list = g_list_prepend (list, cur); + } + g_free (sig_ids); + + list = g_list_sort (list, gwa_signal_comp); + *signals = g_list_concat (list, *signals); + } +} + +static GList * +gwa_list_signals (GladeWidgetAdaptor *adaptor) +{ + GList *signals = NULL; + GType type, parent, *i, *p; + + g_return_val_if_fail (adaptor->type != 0, NULL); + + for (type = adaptor->type; g_type_is_a (type, G_TYPE_OBJECT); type = parent) + { + parent = g_type_parent (type); + + /* Add class signals */ + gwa_add_signals (&signals, type); + + /* Add class interfaces signals */ + for (i = p = g_type_interfaces (type, NULL); *i; i++) + if (!glade_util_class_implements_interface (parent, *i)) + gwa_add_signals (&signals, *i); + + g_free (p); + } + + return g_list_reverse (signals); +} + +static GList * +gwa_clone_parent_properties (GladeWidgetAdaptor *adaptor, gboolean is_packing) +{ + GladeWidgetAdaptor *parent_adaptor; + GList *properties = NULL, *list, *proplist; + + if ((parent_adaptor = gwa_get_parent_adaptor (adaptor)) != NULL) + { + proplist = is_packing ? + parent_adaptor->packing_props : + parent_adaptor->properties; + + for (list = proplist; list; list = list->next) + { + GladePropertyClass *pclass = + glade_property_class_clone (list->data); + properties = g_list_prepend (properties, pclass); + } + } + + return g_list_reverse (properties); +} + +static void +gwa_setup_introspected_props_from_pspecs (GladeWidgetAdaptor *adaptor, + GParamSpec **specs, + gint n_specs, + gboolean is_packing) +{ + GladePropertyClass *property_class; + gint i; + GList *list = NULL; + + for (i = 0; i < n_specs; i++) + { + /* Only create properties that dont exist on the adaptor yet */ + if (specs[i]->owner_type != adaptor->type) + continue; + + if ((property_class = + glade_property_class_new_from_spec (adaptor, specs[i])) != NULL) + list = g_list_prepend (list, property_class); + } + + if (is_packing) + adaptor->packing_props = + g_list_concat (adaptor->packing_props, + g_list_reverse (list)); + else + adaptor->properties = + g_list_concat (adaptor->properties, + g_list_reverse (list)); +} + +/* XXX Atk relations and accel props disregarded - they should + * be implemented from the gtk+ catalog instead I think. + */ +static void +gwa_setup_properties (GladeWidgetAdaptor *adaptor, + gboolean is_packing) +{ + GObjectClass *object_class; + GParamSpec **specs = NULL; + guint n_specs = 0; + GList *l; + + /* only GtkContainer child propeties can be introspected */ + if (is_packing && !g_type_is_a (adaptor->type, GTK_TYPE_CONTAINER)) + return; + + /* Let it leek */ + if ((object_class = g_type_class_ref (adaptor->type)) == NULL) + { + g_critical ("Failed to get class for type %s\n", + g_type_name (adaptor->type)); + return; + } + + /* First clone the parents properties */ + if (is_packing) + adaptor->packing_props = gwa_clone_parent_properties (adaptor, is_packing); + else + adaptor->properties = gwa_clone_parent_properties (adaptor, is_packing); + + /* Now automaticly introspect new properties added in this class, + * allow the class writer to decide what to override in the resulting + * list of properties. + */ + if (is_packing) + specs = gtk_container_class_list_child_properties (object_class, &n_specs); + else + specs = g_object_class_list_properties (object_class, &n_specs); + gwa_setup_introspected_props_from_pspecs (adaptor, specs, n_specs, is_packing); + g_free (specs); + + if (is_packing) + { + /* We have to mark packing properties from GladeWidgetAdaptor + * because GladePropertyClass doesnt have a valid parent GType + * to introspect it. + * + * (which could be used to call gtk_container_class_find_child_property() + * and properly introspect whether or not its a packing property). + */ + for (l = adaptor->packing_props; l; l = l->next) + { + GladePropertyClass *property_class = l->data; + property_class->packing = TRUE; + } + } +} + +static GList * +gwa_inherit_child_packing (GladeWidgetAdaptor *adaptor) +{ + GladeWidgetAdaptor *parent_adaptor; + GList *child_packings = NULL, *packing_list, *default_list; + + if ((parent_adaptor = gwa_get_parent_adaptor (adaptor)) != NULL) + { + for (packing_list = parent_adaptor->child_packings; + packing_list; packing_list = packing_list->next) + { + GladeChildPacking *packing = packing_list->data; + GladeChildPacking *packing_dup = g_new0 (GladeChildPacking, 1); + + packing_dup->parent_name = g_strdup (packing->parent_name); + + for (default_list = packing->packing_defaults; + default_list; default_list = default_list->next) + { + GladePackingDefault *def = default_list->data; + GladePackingDefault *def_dup = g_new0 (GladePackingDefault, 1); + + def_dup->id = g_strdup (def->id); + def_dup->value = g_strdup (def->value); + + packing_dup->packing_defaults = + g_list_prepend (packing_dup->packing_defaults, def_dup); + } + + child_packings = g_list_prepend (child_packings, packing_dup); + } + } + return child_packings; +} + +static GObject * +glade_widget_adaptor_constructor (GType type, + guint n_construct_properties, + GObjectConstructParam *construct_properties) +{ + GladeWidgetAdaptor *adaptor; + GObject *ret_obj; + + ret_obj = G_OBJECT_CLASS (parent_class)->constructor + (type, n_construct_properties, construct_properties); + + adaptor = GLADE_WIDGET_ADAPTOR (ret_obj); + + if (adaptor->type == G_TYPE_NONE) + g_warning ("Adaptor created without a type"); + if (adaptor->name == NULL) + g_warning ("Adaptor created without a name"); + + /* Build decorations */ + gwa_load_icons (adaptor); + gwa_create_cursor (adaptor); + + /* Build signals & properties */ + adaptor->signals = gwa_list_signals (adaptor); + gwa_setup_properties (adaptor, FALSE); + gwa_setup_properties (adaptor, TRUE); + + /* Inherit packing defaults here */ + adaptor->child_packings = gwa_inherit_child_packing (adaptor); + + return ret_obj; +} + +static void +gwa_packing_default_free (GladePackingDefault *def) +{ + g_free (def->id); + g_free (def->value); +} + +static void +gwa_child_packing_free (GladeChildPacking *packing) +{ + g_free (packing->parent_name); + + g_list_foreach (packing->packing_defaults, + (GFunc) gwa_packing_default_free, NULL); + g_list_free (packing->packing_defaults); +} + +static void +glade_widget_adaptor_finalize (GObject *object) +{ + GladeWidgetAdaptor *adaptor = GLADE_WIDGET_ADAPTOR (object); + + /* Free properties and signals */ + g_list_foreach (adaptor->properties, (GFunc) glade_property_class_free, NULL); + g_list_free (adaptor->properties); + + g_list_foreach (adaptor->packing_props, (GFunc) glade_property_class_free, NULL); + g_list_free (adaptor->packing_props); + + g_list_foreach (adaptor->signals, (GFunc) glade_signal_free, NULL); + g_list_free (adaptor->signals); + + + /* Free child packings */ + g_list_foreach (adaptor->child_packings, + (GFunc) gwa_child_packing_free, + NULL); + g_list_free (adaptor->child_packings); + + if (adaptor->priv->book) g_free (adaptor->priv->book); + if (adaptor->priv->catalog) g_free (adaptor->priv->catalog); + if (adaptor->priv->special_child_type) + g_free (adaptor->priv->special_child_type); + + if (adaptor->priv->module) + if (!g_module_close (adaptor->priv->module)) + g_warning ("Module error while finalizing adaptor %s (%s)\n", + adaptor->name, g_module_error()); + + if (adaptor->priv->cursor != NULL) + gdk_cursor_unref (adaptor->priv->cursor); + + if (adaptor->priv->large_icon != NULL) + g_object_unref (G_OBJECT (adaptor->priv->large_icon)); + + if (adaptor->priv->small_icon != NULL) + g_object_unref (G_OBJECT (adaptor->priv->small_icon)); + + if (adaptor->name) g_free (adaptor->name); + if (adaptor->generic_name) g_free (adaptor->generic_name); + if (adaptor->title) g_free (adaptor->title); + + g_free (adaptor->priv); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +glade_widget_adaptor_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GladeWidgetAdaptor *adaptor; + + adaptor = GLADE_WIDGET_ADAPTOR (object); + + switch (prop_id) + { + case PROP_NAME: + /* assume once (construct-only) */ + adaptor->name = g_value_dup_string (value); + break; + case PROP_TYPE: + adaptor->type = g_value_get_gtype (value); + break; + case PROP_TITLE: + if (adaptor->title) g_free (adaptor->title); + adaptor->title = g_value_dup_string (value); + break; + case PROP_GENERIC_NAME: + if (adaptor->generic_name) g_free (adaptor->generic_name); + adaptor->generic_name = g_value_dup_string (value); + break; + case PROP_CATALOG: + /* assume once (construct-only) */ + adaptor->priv->catalog = g_value_dup_string (value); + break; + case PROP_BOOK: + /* assume once (construct-only) */ + adaptor->priv->book = g_value_dup_string (value); + break; + case PROP_SPECIAL_TYPE: + /* assume once (construct-only) */ + adaptor->priv->special_child_type = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +glade_widget_adaptor_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + + GladeWidgetAdaptor *adaptor; + + adaptor = GLADE_WIDGET_ADAPTOR (object); + + switch (prop_id) + { + case PROP_NAME: g_value_set_string (value, adaptor->name); break; + case PROP_TYPE: g_value_set_gtype (value, adaptor->type); break; + case PROP_TITLE: g_value_set_string (value, adaptor->title); break; + case PROP_GENERIC_NAME: g_value_set_string (value, adaptor->generic_name); break; + case PROP_CATALOG: g_value_set_string (value, adaptor->priv->catalog); break; + case PROP_BOOK: g_value_set_string (value, adaptor->priv->book); break; + case PROP_SPECIAL_TYPE: + g_value_set_string (value, adaptor->priv->special_child_type); + break; + case PROP_SMALL_ICON: g_value_set_object (value, adaptor->priv->small_icon); break; + case PROP_LARGE_ICON: g_value_set_object (value, adaptor->priv->large_icon); break; + case PROP_CURSOR: g_value_set_pointer (value, adaptor->priv->cursor); break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +glade_widget_adaptor_init (GladeWidgetAdaptor *adaptor) +{ + adaptor->priv = g_new0 (GladeWidgetAdaptorPriv, 1); +} + +static void +glade_widget_adaptor_class_init (GladeWidgetAdaptorClass *adaptor_class) +{ + GObjectClass *object_class; + g_return_if_fail (adaptor_class != NULL); + + parent_class = g_type_class_peek_parent (adaptor_class); + object_class = G_OBJECT_CLASS (adaptor_class); + + /* GObjectClass */ + object_class->constructor = glade_widget_adaptor_constructor; + object_class->finalize = glade_widget_adaptor_finalize; + object_class->set_property = glade_widget_adaptor_set_property; + object_class->get_property = glade_widget_adaptor_get_property; + + /* Class methods */ + adaptor_class->post_create = NULL; + adaptor_class->launch_editor = NULL; + adaptor_class->get_internal_child = NULL; + adaptor_class->add = NULL; + adaptor_class->remove = NULL; + adaptor_class->replace_child = NULL; + adaptor_class->get_children = NULL; + adaptor_class->child_set_property = NULL; + adaptor_class->child_get_property = NULL; + + /* Properties */ + g_object_class_install_property + (object_class, PROP_NAME, + g_param_spec_string + ("name", _("Name"), + _("Name of the class"), + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_TYPE, + g_param_spec_gtype + ("type", _("Type"), + _("GType of the class"), + G_TYPE_NONE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_TITLE, + g_param_spec_string + ("title", _("Title"), + _("Translated title for the class used in the glade UI"), + NULL, + G_PARAM_READWRITE)); + + g_object_class_install_property + (object_class, PROP_GENERIC_NAME, + g_param_spec_string + ("generic-name", _("Generic Name"), + _("Used to generate names of new widgets"), + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_CATALOG, + g_param_spec_string + ("catalog", _("Catalog"), + _("The name of the widget catalog this class was declared by"), + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_BOOK, + g_param_spec_string + ("book", _("Book"), + _("DevHelp search namespace for this widget class"), + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_SPECIAL_TYPE, + g_param_spec_string + ("special-child-type", _("Special Child Type"), + _("Holds the name of the packing property to depict " + "special children for this container class"), + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_LARGE_ICON, + g_param_spec_object + ("large-icon", _("Large Icon"), + _("The 22x22 icon for this widget class"), + GDK_TYPE_PIXBUF, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_SMALL_ICON, + g_param_spec_object + ("small-icon", _("Small Icon"), + _("The 16x16 icon for this widget class"), + GDK_TYPE_PIXBUF, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_CURSOR, + g_param_spec_pointer + ("cursor", _("Cursor"), + _("A cursor for inserting widgets in the UI"), + G_PARAM_READABLE)); +} + +GType +glade_widget_adaptor_get_type (void) +{ + static GType adaptor_type = 0; + + if (!adaptor_type) + { + static const GTypeInfo adaptor_info = + { + sizeof (GladeWidgetAdaptorClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) glade_widget_adaptor_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (GladeWidgetAdaptor), + 0, /* n_preallocs */ + (GInstanceInitFunc) glade_widget_adaptor_init, + }; + adaptor_type = + g_type_register_static (G_TYPE_OBJECT, + "GladeGObjectAdaptor", + &adaptor_info, 0); + } + return adaptor_type; +} + + +/******************************************************************************* + Synthetic Object Derivation + *******************************************************************************/ +static void +gwa_derived_init (GladeWidgetAdaptor *adaptor) +{ + +} + +static void +gwa_derived_class_init (GladeWidgetAdaptorClass *adaptor_class) +{ + +} + +static GType +gwa_derive_adaptor_for_type (GType object_type) +{ + GladeWidgetAdaptor *adaptor; + GType iter_type, derived_type; + GType parent_type = GLADE_TYPE_WIDGET_ADAPTOR; + gchar *type_name; + + for (iter_type = g_type_parent (object_type); + iter_type > 0; + iter_type = g_type_parent (iter_type)) + { + if ((adaptor = + glade_widget_adaptor_get_by_type (iter_type)) != NULL) + { + parent_type = G_TYPE_FROM_INSTANCE (adaptor); + break; + } + } + + /* Note that we must pass ownership of the type_name string + * to the type system + */ + type_name = g_strdup_printf ("Glade%sAdaptor", g_type_name (object_type)); + derived_type = + g_type_register_static_simple (parent_type, type_name, + sizeof (GladeWidgetAdaptorClass), + (GClassInitFunc)gwa_derived_class_init, + sizeof (GladeWidgetAdaptor), + (GInstanceInitFunc)gwa_derived_init, 0); + return derived_type; +} + + +/******************************************************************************* + API + *******************************************************************************/ + +/** + * glade_widget_adaptor_register: + * @adaptor: A #GladeWidgetAdaptor + * + * Registers @adaptor into the Glade core (every supported + * object type must have a registered adaptor). + */ +void +glade_widget_adaptor_register (GladeWidgetAdaptor *adaptor) +{ + + g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor)); + + if (glade_widget_adaptor_get_by_name (adaptor->name)) + { + g_warning ("Adaptor class for '%s' already registered", + adaptor->name); + return; + } + + if (!adaptor_hash) + adaptor_hash = g_hash_table_new_full (gwa_gtype_hash, gwa_gtype_equal, + g_free, g_object_unref); + + g_hash_table_insert (adaptor_hash, + g_memdup (&adaptor->type, + sizeof (GType)), adaptor); +} + +static GladePackingDefault * +gwa_default_from_child_packing (GladeChildPacking *packing, const gchar *id) +{ + GList *list; + + for (list = packing->packing_defaults; list; list = list->next) + { + GladePackingDefault *def = list->data; + + if (id && !strcmp (id, def->id)) + return def; + } + + return NULL; +} + +static GladeChildPacking * +glade_widget_adaptor_get_child_packing (GladeWidgetAdaptor *child_adaptor, + const gchar *parent_name) +{ + GList *l; + + for (l = child_adaptor->child_packings; l; l = l->next) + { + GladeChildPacking *packing; + + packing = (GladeChildPacking *) l->data; + + if (!strcmp (packing->parent_name, parent_name)) + return packing; + } + + return NULL; +} + +static void +gwa_set_packing_defaults_from_node (GladeWidgetAdaptor *adaptor, + GladeXmlNode *node) +{ + GladeXmlNode *child; + + for (child = glade_xml_node_get_children (node); + child; child = glade_xml_node_next (child)) + { + gchar *name; + GladeXmlNode *prop_node; + GladeChildPacking *packing; + + if (!glade_xml_node_verify (child, GLADE_TAG_PARENT_CLASS)) + continue; + + if ((name = glade_xml_get_property_string_required + (child, GLADE_TAG_NAME, adaptor->name)) == NULL) + continue; + + /* If a GladeChildPacking exists for this parent, use it - + * otherwise prepend a new one + */ + if ((packing = + glade_widget_adaptor_get_child_packing (adaptor, name)) == NULL) + { + + packing = g_new0 (GladeChildPacking, 1); + packing->parent_name = name; + + adaptor->child_packings = + g_list_prepend (adaptor->child_packings, packing); + + } + + for (prop_node = glade_xml_node_get_children (child); + prop_node; prop_node = glade_xml_node_next (prop_node)) + { + GladePackingDefault *def; + gchar *id; + gchar *value; + + if ((id = + glade_xml_get_property_string_required + (prop_node, GLADE_TAG_ID, adaptor->name)) == NULL) + continue; + + if ((value = + glade_xml_get_property_string_required + (prop_node, GLADE_TAG_DEFAULT, adaptor->name)) == NULL) + { + g_free (id); + continue; + } + + if ((def = gwa_default_from_child_packing (packing, id)) == NULL) + { + def = g_new0 (GladePackingDefault, 1); + def->id = id; + def->value = value; + + packing->packing_defaults = + g_list_prepend (packing->packing_defaults, def); + } + else + { + g_free (id); + g_free (def->value); + def->value = value; + } + + adaptor->child_packings = + g_list_prepend (adaptor->child_packings, packing); + + } + } +} + +static void +gwa_update_properties_from_node (GladeWidgetAdaptor *adaptor, + GladeXmlNode *node, + GList **properties, + const gchar *domain) +{ + GladeXmlNode *child; + + for (child = glade_xml_node_get_children (node); + child; child = glade_xml_node_next (child)) + { + gchar *id; + GList *list; + GladePropertyClass *property_class; + gboolean updated; + + if (!glade_xml_node_verify (child, GLADE_TAG_PROPERTY)) + continue; + + id = glade_xml_get_property_string_required + (child, GLADE_TAG_ID, adaptor->name); + if (!id) + continue; + + /* property names from catalogs also need to have the '-' form */ + glade_util_replace (id, '_', '-'); + + /* find the property in our list, if not found append a new property */ + for (list = *properties; list && list->data; list = list->next) + { + property_class = GLADE_PROPERTY_CLASS (list->data); + if (property_class->id != NULL && + g_ascii_strcasecmp (id, property_class->id) == 0) + break; + } + + if (list) + { + property_class = GLADE_PROPERTY_CLASS (list->data); + } + else + { + property_class = glade_property_class_new (adaptor); + property_class->id = g_strdup (id); + *properties = g_list_append (*properties, property_class); + list = g_list_last (*properties); + } + + if ((updated = glade_property_class_update_from_node + (child, adaptor->priv->module, adaptor->type, + &property_class, domain)) == FALSE) + { + g_warning ("failed to update %s property of %s from xml", + id, adaptor->name); + g_free (id); + continue; + } + + /* the property has Disabled=TRUE ... */ + if (!property_class) + *properties = g_list_delete_link (*properties, list); + + g_free (id); + } +} + + +static gboolean +gwa_extend_with_node (GladeWidgetAdaptor *adaptor, + GladeXmlNode *node, + const gchar *domain) +{ + GladeWidgetAdaptorClass *adaptor_class = + GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor); + GladeXmlNode *child; + + if (adaptor->priv->module) + { + glade_xml_load_sym_from_node (node, adaptor->priv->module, + GLADE_TAG_POST_CREATE_FUNCTION, + (gpointer *)&adaptor_class->post_create); + + glade_xml_load_sym_from_node (node, adaptor->priv->module, + GLADE_TAG_GET_INTERNAL_CHILD_FUNCTION, + (gpointer *)&adaptor_class->get_internal_child); + + glade_xml_load_sym_from_node (node, adaptor->priv->module, + GLADE_TAG_LAUNCH_EDITOR_FUNCTION, + (gpointer *)&adaptor_class->launch_editor); + + glade_xml_load_sym_from_node (node, adaptor->priv->module, + GLADE_TAG_ADD_CHILD_FUNCTION, + (gpointer *)&adaptor_class->add); + + glade_xml_load_sym_from_node (node, adaptor->priv->module, + GLADE_TAG_REMOVE_CHILD_FUNCTION, + (gpointer *)&adaptor_class->remove); + + glade_xml_load_sym_from_node (node, adaptor->priv->module, + GLADE_TAG_GET_CHILDREN_FUNCTION, + (gpointer *)&adaptor_class->get_children); + + glade_xml_load_sym_from_node (node, adaptor->priv->module, + GLADE_TAG_CHILD_SET_PROP_FUNCTION, + (gpointer *)&adaptor_class->child_set_property); + + glade_xml_load_sym_from_node (node, adaptor->priv->module, + GLADE_TAG_CHILD_GET_PROP_FUNCTION, + (gpointer *)&adaptor_class->child_get_property); + + glade_xml_load_sym_from_node (node, adaptor->priv->module, + GLADE_TAG_REPLACE_CHILD_FUNCTION, + (gpointer *)&adaptor_class->replace_child); + + } + adaptor_class->fixed = + glade_xml_get_property_boolean + (node, GLADE_TAG_FIXED, adaptor_class->fixed); + + /* Check if this class is toplevel */ + adaptor_class->toplevel = + glade_xml_get_property_boolean + (node, GLADE_XML_TAG_TOPLEVEL, adaptor_class->toplevel); + + /* if we found a <properties> tag on the xml file, we add the properties + * that we read from the xml file to the class. + */ + if ((child = + glade_xml_search_child (node, GLADE_TAG_PROPERTIES)) != NULL) + gwa_update_properties_from_node + (adaptor, child, &adaptor->properties, domain); + + if ((child = + glade_xml_search_child (node, GLADE_TAG_PACKING_PROPERTIES)) != NULL) + gwa_update_properties_from_node + (adaptor, child, &adaptor->packing_props, domain); + + if ((child = + glade_xml_search_child (node, GLADE_TAG_PACKING_DEFAULTS)) != NULL) + gwa_set_packing_defaults_from_node (adaptor, child); + + return TRUE; +} + + + +/** + * glade_widget_adaptor_from_catalog: + * @class_node: A #GladeXmlNode + * @catname: the name of the owning catalog + * @library: the name of the library used to load class methods from + * @domain: the domain to translate strings from this plugin from + * @book: the devhelp search domain for the owning catalog. + * + * Dynamicly creates a subclass of #GladeWidgetAdaptor and subclasses + * the closest parent adaptor (parent class adapters must be creates/registerd + * prior to child classes, otherwise inheritance wont work) and parses in + * the relevent catalog info. + */ +GladeWidgetAdaptor * +glade_widget_adaptor_from_catalog (GladeXmlNode *class_node, + const gchar *catname, + const gchar *library, + const gchar *domain, + const gchar *book) +{ + GladeWidgetAdaptor *adaptor = NULL; + gchar *name, *generic_name; + GModule *module = NULL; + GType object_type, adaptor_type, parent_type; + + if (!glade_xml_node_verify (class_node, GLADE_TAG_GLADE_WIDGET_CLASS)) + { + g_warning ("Widget class node is not '%s'", + GLADE_TAG_GLADE_WIDGET_CLASS); + return NULL; + } + + if ((name = glade_xml_get_property_string_required + (class_node, GLADE_TAG_NAME, NULL)) == NULL) + return NULL; + + if (library) + { + module = glade_util_load_library (library); + if (!module) + { + g_warning ("Failed to load external library '%s'", + library); + g_free (name); + return NULL; + } + } + + if ((object_type = glade_util_get_type_from_name (name)) == 0) + { + g_warning ("Failed to load the GType for '%s'", name); + g_free (name); + return NULL; + } + + if (glade_widget_adaptor_get_by_type (object_type)) + { + g_warning ("Adaptor class for '%s' already defined", + g_type_name (object_type)); + return NULL; + } + + adaptor_type = gwa_derive_adaptor_for_type (object_type); + generic_name = glade_xml_get_property_string (class_node, GLADE_TAG_GENERIC_NAME); + adaptor = g_object_new (adaptor_type, + "type", object_type, + "name", name, + "generic-name", generic_name, + NULL); + if (generic_name) + g_free (generic_name); + + adaptor->priv->module = module; + + if ((adaptor->title = glade_xml_get_property_string_required + (class_node, GLADE_TAG_TITLE, + "This value is needed to display object class names in the UI")) == NULL) + { + g_warning ("Class '%s' built without a '%s'", name, GLADE_TAG_TITLE); + adaptor->title = g_strdup (name); + } + + /* Translate title */ + if (adaptor->title != dgettext (domain, adaptor->title)) + { + gchar *ptr = dgettext (domain, adaptor->title); + g_free (adaptor->title); + adaptor->title = ptr; + } + + if (G_TYPE_IS_INSTANTIATABLE (adaptor->type) && + G_TYPE_IS_ABSTRACT (adaptor->type) == FALSE && + adaptor->generic_name == NULL) + { + g_warning ("Instantiatable class '%s' built without a '%s'", + name, GLADE_TAG_GENERIC_NAME); + } + + /* Perform a stoopid fallback just incase */ + if (adaptor->generic_name == NULL) + adaptor->generic_name = g_strdup ("widget"); + + /* Dont mention gtk+ as a required lib in the generated glade file */ + if (strcmp (catname, "gtk+")) + adaptor->priv->catalog = g_strdup (catname); + + if (book) + adaptor->priv->book = g_strdup (book); + + gwa_extend_with_node (adaptor, class_node, domain); + + /* Set default weight on properties */ + for (parent_type = adaptor->type; + parent_type != 0; + parent_type = g_type_parent (parent_type)) + { + gwa_properties_set_weight (&adaptor->properties, parent_type); + gwa_properties_set_weight (&adaptor->packing_props, parent_type); + } + + glade_widget_adaptor_register (adaptor); + + return adaptor; + + + +} + +/** + * glade_widget_adaptor_create_internal: + * @parent: The parent #GladeWidget, or %NULL for children + * outside of the hierarchy. + * @internal_object: the #GObject + * @internal_name: a string identifier for this internal widget. + * @anarchist: Whether or not this widget is a widget outside + * of the parent's hierarchy (like a popup window) + * @reason: The #GladeCreateReason for which this internal widget + * was created (usually just pass the reason from the post_create + * function; note also this is used only by the plugin code so + * pass something usefull here). + * + * A convenienve function to create a #GladeWidget of the prescribed type + * for internal widgets. + * + * Returns: a freshly created #GladeWidget wrapper object for the + * @internal_object of name @internal_name + */ +GladeWidget * +glade_widget_adaptor_create_internal (GladeWidget *parent, + GObject *internal_object, + const gchar *internal_name, + const gchar *parent_name, + gboolean anarchist, + GladeCreateReason reason) +{ + GladeWidgetAdaptor *adaptor; + GladeProject *project; + + g_return_val_if_fail (GLADE_IS_WIDGET (parent), NULL); + project = glade_widget_get_project (parent); + + if ((adaptor = glade_widget_adaptor_get_by_name + (G_OBJECT_TYPE_NAME (internal_object))) == NULL) + { + g_critical ("Unable to find widget class for type %s", + G_OBJECT_TYPE_NAME (internal_object)); + return NULL; + } + + return glade_widget_adaptor_create_widget (adaptor, FALSE, + "anarchist", anarchist, + "parent", parent, + "project", project, + "internal", internal_name, + "internal-name", parent_name, + "reason", reason, + "object", internal_object, + NULL); +} + +/** + * glade_widget_adaptor_create_widget: + * @adaptor: a #GladeWidgetAdaptor + * @query: whether to display query dialogs if + * applicable to the class + * @...: a %NULL terminated list of string/value pairs of #GladeWidget + * properties + * + * + * This factory function returns a new #GladeWidget of the correct type/class + * with the properties defined in @... and queries the user if nescisary. + * + * The resulting object will have all default properties applied to it + * including the overrides specified in the catalog, unless the catalog + * has specified 'ignore' for that property. + * + * Note that the widget class must be fed twice; once as the + * leading arg... and also as the property for the #GladeWidget + * + * this macro returns the newly created #GladeWidget + */ +GladeWidget * +glade_widget_adaptor_create_widget_real (gboolean query, + const gchar *first_property, + ...) +{ + GladeWidgetAdaptor *adaptor; + GType gwidget_type; + GladeWidget *gwidget; + va_list vl, vl_copy; + + g_return_val_if_fail (strcmp (first_property, "adaptor") == 0, NULL); + + va_start (vl, first_property); + va_copy (vl_copy, vl); + + adaptor = va_arg (vl, GladeWidgetAdaptor *); + + va_end (vl); + + if (GLADE_IS_WIDGET_ADAPTOR (adaptor) == FALSE) + { + g_critical ("No adaptor found in glade_widget_adaptor_create_widget_real args"); + va_end (vl_copy); + return NULL; + } + + if (GWA_IS_FIXED (adaptor)) + gwidget_type = GLADE_TYPE_FIXED; + else + gwidget_type = GLADE_TYPE_WIDGET; + + + gwidget = (GladeWidget *)g_object_new_valist (gwidget_type, + first_property, + vl_copy); + va_end (vl_copy); + + if (query && glade_widget_adaptor_query (adaptor)) + { + GladeEditor *editor = glade_app_get_editor (); + + /* If user pressed cancel on query popup. */ + if (!glade_editor_query_dialog (editor, gwidget)) + { + g_object_unref (G_OBJECT (gwidget)); + return NULL; + } + } + + return gwidget; +} + +typedef struct +{ + const gchar *name; + GladeWidgetAdaptor *adaptor; +} GladeAdaptorSearchPair; + + +static void +search_adaptor_by_name (GType *type, + GladeWidgetAdaptor *adaptor, + GladeAdaptorSearchPair *pair) +{ + if (!strcmp (adaptor->name, pair->name)) + pair->adaptor = adaptor; +} + +/** + * glade_widget_adaptor_get_by_name: + * @name: name of the widget class (for instance: GtkButton) + * + * Returns: an existing #GladeWidgetAdaptor with the name equaling @name, + * or %NULL if such a class doesn't exist + **/ +GladeWidgetAdaptor * +glade_widget_adaptor_get_by_name (const gchar *name) +{ + + + GladeAdaptorSearchPair pair = { name, NULL }; + + if (adaptor_hash != NULL) + { + g_hash_table_foreach (adaptor_hash, + (GHFunc)search_adaptor_by_name, &pair); + } + return pair.adaptor; +} + + +/** + * glade_widget_adaptor_get_by_type: + * @type: the #GType of an object class + * + * Returns: an existing #GladeWidgetAdaptor with the type equaling @type, + * or %NULL if such a class doesn't exist + **/ +GladeWidgetAdaptor * +glade_widget_adaptor_get_by_type (GType type) +{ + if (adaptor_hash != NULL) + return g_hash_table_lookup (adaptor_hash, &type); + else + return NULL; +} + +/** + * glade_widget_adaptor_get_property_class: + * @adaptor: a #GladeWidgetAdaptor + * @name: a string + * + * Retrieves the #GladePropertyClass for @name in @adaptor + * + * Returns: A #GladePropertyClass object + */ +GladePropertyClass * +glade_widget_adaptor_get_property_class (GladeWidgetAdaptor *adaptor, + const gchar *name) +{ + GList *list; + GladePropertyClass *pclass; + + for (list = adaptor->properties; list && list->data; list = list->next) + { + pclass = list->data; + if (strcmp (pclass->id, name) == 0) + return pclass; + } + return NULL; +} + +/** + * glade_widget_adaptor_get_pack_property_class: + * @adaptor: a #GladeWidgetAdaptor + * @name: a string + * + * Retrieves the #GladePropertyClass for @name in + * @adaptor's child properties + * + * Returns: A #GladePropertyClass object + */ +GladePropertyClass * +glade_widget_adaptor_get_pack_property_class (GladeWidgetAdaptor *adaptor, + const gchar *name) +{ + GList *list; + GladePropertyClass *pclass; + + for (list = adaptor->packing_props; list && list->data; list = list->next) + { + pclass = list->data; + if (strcmp (pclass->id, name) == 0) + return pclass; + } + return NULL; +} + +/** + * glade_widget_class_default_params: + * @adaptor: a #GladeWidgetAdaptor + * @construct: whether to return construct params or not construct params + * @n_params: return location if any defaults are specified for this class. + * + * Returns: A list of params for use in g_object_newv () + */ +GParameter * +glade_widget_adaptor_default_params (GladeWidgetAdaptor *adaptor, + gboolean construct, + guint *n_params) +{ + GArray *params; + GObjectClass *oclass; + GParamSpec **pspec; + GladePropertyClass *pclass; + guint n_props, i; + + g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL); + g_return_val_if_fail (n_params != NULL, NULL); + + /* As a slight optimization, we never unref the class + */ + oclass = g_type_class_ref (adaptor->type); + pspec = g_object_class_list_properties (oclass, &n_props); + params = g_array_new (FALSE, FALSE, sizeof (GParameter)); + + for (i = 0; i < n_props; i++) + { + GParameter parameter = { 0, }; + + pclass = glade_widget_adaptor_get_property_class + (adaptor, pspec[i]->name); + + /* Ignore properties based on some criteria + */ + if (pclass == NULL || /* Unaccounted for in the builder */ + pclass->set_function || /* should not be set before + GladeWidget wrapper exists */ + pclass->ignore) /* Catalog explicitly ignores the object */ + continue; + + if (construct && + (pspec[i]->flags & + (G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) == 0) + continue; + else if (!construct && + (pspec[i]->flags & + (G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) != 0) + continue; + + + if (g_value_type_compatible (G_VALUE_TYPE (pclass->def), + pspec[i]->value_type) == FALSE) + { + g_critical ("Type mismatch on %s property of %s", + parameter.name, adaptor->name); + continue; + } + + if (g_param_values_cmp (pspec[i], + pclass->def, + pclass->orig_def) == 0) + continue; + + parameter.name = pspec[i]->name; /* These are not copied/freed */ + g_value_init (¶meter.value, pspec[i]->value_type); + g_value_copy (pclass->def, ¶meter.value); + + g_array_append_val (params, parameter); + } + g_free (pspec); + + *n_params = params->len; + return (GParameter *)g_array_free (params, FALSE); +} + + +/** + * glade_widget_adaptor_post_create: + * @adaptor: A #GladeWidgetAdaptor + * @object: The #GObject + * @reason: The #GladeCreateReason that @object was created for + * + * An adaptor function to be called after the object is created + */ +void +glade_widget_adaptor_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) +{ + g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor)); + g_return_if_fail (G_IS_OBJECT (object)); + + if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->post_create) + GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->post_create (adaptor, object, reason); + /* XXX Dont complain here if no implementation is found */ +} + +/** + * glade_widget_adaptor_get_internal_child: + * @adaptor: A #GladeWidgetAdaptor + * @object: The #GObject + * @internal_name: The string identifier of the internal object + * + * Retrieves the internal object @internal_name from @object + * + * Returns: The internal #GObject + */ +GObject * +glade_widget_adaptor_get_internal_child (GladeWidgetAdaptor *adaptor, + GObject *object, + const gchar *internal_name) +{ + g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL); + g_return_val_if_fail (G_IS_OBJECT (object), NULL); + g_return_val_if_fail (internal_name != NULL, NULL); + + if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->get_internal_child) + return GLADE_WIDGET_ADAPTOR_GET_CLASS + (adaptor)->get_internal_child (adaptor, object, internal_name); + else + g_critical ("No get_internal_child() support in adaptor %s", adaptor->name); + + return NULL; +} + +/** + * glade_widget_adaptor_launch_editor: + * @adaptor: A #GladeWidgetAdaptor + * @object: The #GObject + * + * Launches a custom object editor for @object. + */ +void +glade_widget_adaptor_launch_editor (GladeWidgetAdaptor *adaptor, + GObject *object) +{ + g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor)); + g_return_if_fail (G_IS_OBJECT (object)); + + if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->launch_editor) + GLADE_WIDGET_ADAPTOR_GET_CLASS + (adaptor)->launch_editor (adaptor, object); + else + g_critical ("No launch_editor() support in adaptor %s", adaptor->name); +} + +/** + * glade_widget_adaptor_add: + * @adaptor: A #GladeWidgetAdaptor + * @container: The #GObject container + * @child: The #GObject child + * + * Adds @child to @container. + */ +void +glade_widget_adaptor_add (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child) +{ + g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor)); + g_return_if_fail (G_IS_OBJECT (container)); + g_return_if_fail (G_IS_OBJECT (child)); + + if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->add) + GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->add (adaptor, container, child); + else + g_critical ("No add() support in adaptor %s", adaptor->name); +} + + +/** + * glade_widget_adaptor_remove: + * @adaptor: A #GladeWidgetAdaptor + * @container: The #GObject container + * @child: The #GObject child + * + * Removes @child from @container. + */ +void +glade_widget_adaptor_remove (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child) +{ + g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor)); + g_return_if_fail (G_IS_OBJECT (container)); + g_return_if_fail (G_IS_OBJECT (child)); + + if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->remove) + GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->remove (adaptor, container, child); + else + g_critical ("No remove() support in adaptor %s", adaptor->name); +} + +/** + * glade_widget_adaptor_remove: + * @adaptor: A #GladeWidgetAdaptor + * @container: The #GObject container + * + * Lists the children of @container. + * + * Returns: A #GList of children + */ +GList * +glade_widget_adaptor_get_children (GladeWidgetAdaptor *adaptor, + GObject *container) +{ + g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL); + g_return_val_if_fail (G_IS_OBJECT (container), NULL); + + if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->get_children) + return GLADE_WIDGET_ADAPTOR_GET_CLASS + (adaptor)->get_children (adaptor, container); + + /* XXX Dont complain here if no implementation is found */ + + return NULL; +} + +/** + * glade_widget_adaptor_has_child: + * @adaptor: A #GladeWidgetAdaptor + * @container: The #GObject container + * @child: The #GObject child + * + * Returns whether @child is infact inside @container. + */ +gboolean +glade_widget_adaptor_has_child (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child) +{ + GList *list, *children = NULL; + gboolean found = FALSE; + + children = glade_widget_adaptor_get_children (adaptor, container); + + for (list = children; list && list->data; list = list->next) + { + if (list->data == child) + { + found = TRUE; + break; + } + } + + g_list_free (children); + return found; +} + +/** + * glade_widget_adaptor_child_set_property: + * @adaptor: A #GladeWidgetAdaptor + * @container: The #GObject container + * @child: The #GObject child + * @property_name: The id of the property + * @value: The @GValue + * + * Sets @child's packing property identified by @property_name to @value. + */ +void +glade_widget_adaptor_child_set_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + const GValue *value) +{ + g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor)); + g_return_if_fail (G_IS_OBJECT (container)); + g_return_if_fail (G_IS_OBJECT (child)); + g_return_if_fail (property_name != NULL && value != NULL); + + if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->child_set_property) + GLADE_WIDGET_ADAPTOR_GET_CLASS + (adaptor)->child_set_property (adaptor, container, child, + property_name, value); + else + g_critical ("No child_set_property() support in adaptor %s", adaptor->name); + +} + +/** + * glade_widget_adaptor_child_set_property: + * @adaptor: A #GladeWidgetAdaptor + * @container: The #GObject container + * @child: The #GObject child + * @property_name: The id of the property + * @value: The @GValue + * + * Gets @child's packing property identified by @property_name. + */ +void +glade_widget_adaptor_child_get_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value) +{ + g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor)); + g_return_if_fail (G_IS_OBJECT (container)); + g_return_if_fail (G_IS_OBJECT (child)); + g_return_if_fail (property_name != NULL && value != NULL); + + if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->child_get_property) + GLADE_WIDGET_ADAPTOR_GET_CLASS + (adaptor)->child_get_property (adaptor, container, child, + property_name, value); + else + g_critical ("No child_set_property() support in adaptor %s", adaptor->name); +} + +/** + * glade_widget_adaptor_replace_child: + * @adaptor: A #GladeWidgetAdaptor + * @container: The #GObject container + * @old: The old #GObject child + * @new: The new #GObject child + * + * Replaces @old with @new in @container while positioning + * @new where @old was and assigning it appropriate packing + * property values. + */ +void +glade_widget_adaptor_replace_child (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *old, + GObject *new) +{ + g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor)); + g_return_if_fail (G_IS_OBJECT (container)); + g_return_if_fail (G_IS_OBJECT (old)); + g_return_if_fail (G_IS_OBJECT (new)); + + if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->replace_child) + GLADE_WIDGET_ADAPTOR_GET_CLASS + (adaptor)->replace_child (adaptor, container, old, new); + else + g_critical ("No replace_child() support in adaptor %s", adaptor->name); +} + +/** + * glade_widget_adaptor_query: + * @adaptor: A #GladeWidgetAdaptor + * + * Returns: whether the user needs to be queried for + * certain properties upon creation of this class. + */ +gboolean +glade_widget_adaptor_query (GladeWidgetAdaptor *adaptor) +{ + GladePropertyClass *pclass; + GList *l; + + for (l = adaptor->properties; l; l = l->next) + { + pclass = l->data; + + if (pclass->query) + return TRUE; + } + + return FALSE; +} + +/** + * glade_widget_adaptor_get_packing_default: + * @child_adaptor: A #GladeWidgetAdaptor + * @parent_adaptor: The #GladeWidgetAdaptor for the parent object + * @property_id: The string property identifier + * + * Gets the default value for @property_id on a widget governed by + * @child_adaptor when parented in a widget governed by @parent_adaptor + * + * Returns: a string representing the default value for @property_id + */ +G_CONST_RETURN gchar * +glade_widget_adaptor_get_packing_default (GladeWidgetAdaptor *child_adaptor, + GladeWidgetAdaptor *container_adaptor, + const gchar *id) +{ + GladeChildPacking *packing = NULL; + GList *l; + + if ((packing = + glade_widget_adaptor_get_child_packing (child_adaptor, + container_adaptor->name)) != NULL) + { + for (l = packing->packing_defaults; l; l = l->next) + { + GladePackingDefault *def = l->data; + + if (strcmp (def->id, id) == 0) + return def->value; + } + } + return NULL; +} diff --git a/src/glade-widget-adaptor.h b/src/glade-widget-adaptor.h new file mode 100644 index 00000000..3570c7ec --- /dev/null +++ b/src/glade-widget-adaptor.h @@ -0,0 +1,402 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +#ifndef __GLADE_WIDGET_ADAPTOR_H__ +#define __GLADE_WIDGET_ADAPTOR_H__ + +#include <glib-object.h> +#include <gmodule.h> +#include <gtk/gtk.h> +#include "glade-xml-utils.h" +#include "glade-property-class.h" + +G_BEGIN_DECLS + +#define GLADE_TYPE_WIDGET_ADAPTOR (glade_widget_adaptor_get_type()) +#define GLADE_WIDGET_ADAPTOR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_WIDGET_ADAPTOR, GladeWidgetAdaptor)) +#define GLADE_WIDGET_ADAPTOR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_WIDGET_ADAPTOR, GladeWidgetAdaptorClass)) +#define GLADE_IS_WIDGET_ADAPTOR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_WIDGET_ADAPTOR)) +#define GLADE_IS_WIDGET_ADAPTOR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_WIDGET_ADAPTOR)) +#define GLADE_WIDGET_ADAPTOR_GET_CLASS(o) \ + (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_WIDGET_ADAPTOR, GladeWidgetAdaptorClass)) + +typedef struct _GladeWidgetAdaptor GladeWidgetAdaptor; +typedef struct _GladeWidgetAdaptorClass GladeWidgetAdaptorClass; +typedef struct _GladeWidgetAdaptorPriv GladeWidgetAdaptorPriv; +typedef struct _GladeSignalClass GladeSignalClass; + +/** + * GWA_IS_FIXED: + * @obj: A #GladeWidgetAdaptor + * + * Checks whether this widget adaptor should be handled + * as a free-form container + */ +#define GWA_IS_FIXED(obj) \ + ((obj) ? GLADE_WIDGET_ADAPTOR_GET_CLASS(obj)->fixed : FALSE) + +/** + * GWA_IS_TOPLEVEL: + * @obj: A #GladeWidgetAdaptor + * + * Checks whether this widget class has been marked as + * a toplevel one. + */ +#define GWA_IS_TOPLEVEL(obj) \ + ((obj) ? GLADE_WIDGET_ADAPTOR_GET_CLASS(obj)->toplevel : FALSE) + + +/** + * GWA_GET_CLASS: + * @type: A #GType + * + * Shorthand for referencing glade adaptor classes from + * the plugin eg. GWA_GET_CLASS (GTK_TYPE_CONTAINER)->post_create (adaptor... + */ +#define GWA_GET_CLASS(type) \ + GLADE_WIDGET_ADAPTOR_GET_CLASS (glade_widget_adaptor_get_by_type(type)) + + +#define GLADE_VALID_CREATE_REASON(reason) (reason >= 0 && reason < GLADE_CREATE_REASONS) + +/** + * GladeCreateReason: + * @GLADE_CREATE_USER: Was created at the user's request + * (this is a good time to set any properties + * or add children to the project; like GtkFrame's + * label for example). + * @GLADE_CREATE_COPY: Was created as a result of the copy/paste + * mechanism, at this point you can count on glade + * to follow up with properties and children on + * its own. + * @GLADE_CREATE_LOAD: Was created during the load process. + * @GLADE_CREATE_REBUILD: Was created as a replacement for another project + * object; this only happens when the user is + * changing a property that is marked by the type + * system as G_PARAM_SPEC_CONSTRUCT_ONLY. + * @GLADE_CREATE_REASONS: Never used. + * + * These are the reasons your #GladePostCreateFunc can be called. + */ +typedef enum _GladeCreateReason +{ + GLADE_CREATE_USER = 0, + GLADE_CREATE_COPY, + GLADE_CREATE_LOAD, + GLADE_CREATE_REBUILD, + GLADE_CREATE_REASONS +} GladeCreateReason; + +/** + * GladeChildSetPropertyFunc: + * @adaptor: A #GladeWidgetAdaptor + * @container: A #GObject container + * @child: The #GObject child + * @property_name: The property name + * @value: The #GValue + * + * Called to set the packing property @property_name to @value + * on the @child object of @container. + */ +typedef void (* GladeChildSetPropertyFunc) (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + const GValue *value); + +/** + * GladeChildGetPropertyFunc: + * @container: A #GObject container + * @child: The #GObject child + * @property_name: The property name + * @value: The #GValue + * + * Called to get the packing property @property_name + * on the @child object of @container into @value. + */ +typedef void (* GladeChildGetPropertyFunc) (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value); + +/** + * GladeGetChildrenFunc: + * @container: A #GObject container + * @Returns: A #GList of #GObject children. + * + * A function called to get @containers children. + */ +typedef GList *(* GladeGetChildrenFunc) (GladeWidgetAdaptor *adaptor, + GObject *container); + +/** + * GladeAddChildFunc: + * @parent: A #GObject container + * @child: A #GObject child + * + * Called to add @child to @parent. + */ +typedef void (* GladeAddChildFunc) (GladeWidgetAdaptor *adaptor, + GObject *parent, + GObject *child); +/** + * GladeRemoveChildFunc: + * @parent: A #GObject container + * @child: A #GObject child + * + * Called to remove @child from @parent. + */ +typedef void (* GladeRemoveChildFunc) (GladeWidgetAdaptor *adaptor, + GObject *parent, + GObject *child); + +/** + * GladeReplaceChildFunc: + * @container: A #GObject container + * @old: The old #GObject child + * @new: The new #GObject child to take its place + * + * Called to swap placeholders with project objects + * in containers. + */ +typedef void (* GladeReplaceChildFunc) (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *old, + GObject *new); + +/** + * GladePostCreateFunc: + * @object: a #GObject + * @reason: a #GladeCreateReason + * + * This function is called exactly once for any project object + * instance and can be for any #GladeCreateReason. + */ +typedef void (* GladePostCreateFunc) (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason); + +/** + * GladeGetInternalFunc: + * @parent: A #GObject composite object + * @name: A string identifier + * @child: A return location for a #GObject + * + * Called to lookup @child in composite object @parent by @name. + */ +typedef GObject *(* GladeGetInternalFunc) (GladeWidgetAdaptor *adaptor, + GObject *parent, + const gchar *name); + + +/** + * GladeEditorLaunchFunc: + * @object: A #GObject + * + * Called to launch a custom editor for @object + */ +typedef void (* GladeEditorLaunchFunc) (GladeWidgetAdaptor *adaptor, + GObject *object); + + +/* GladeSignalClass contains all the info we need for a given signal, such as + * the signal name, and maybe more in the future + */ +struct _GladeSignalClass +{ + GSignalQuery query; + + const gchar *name; /* Name of the signal, eg clicked */ + gchar *type; /* Name of the object class that this signal belongs to + * eg GtkButton */ + +}; + +/* Note that everything that must be processed at the creation of + * every instance is managed on the instance structure, and everywhere + * that we want to take advantage of inheritance is handled in the class + * structure. + */ +struct _GladeWidgetAdaptor +{ + GObject parent_instance; + + GType type; /* GType of the widget */ + + gchar *name; /* Name of the widget, for example GtkButton */ + + + gchar *generic_name; /* Used to generate names of new widgets, for + * example "button" so that we generate button1, + * button2, buttonX .. + */ + + gchar *title; /* Translated class name used in the UI */ + + GList *properties; /* List of GladePropertyClass objects. + * [see glade-property.h] this list contains + * properties about the widget that we are going + * to modify. Like "title", "label", "rows" . + * Each property creates an input in the propety + * editor. + */ + GList *packing_props; /* List of GladePropertyClass objects that describe + * properties for child objects packing definition - + * note there may be more than one type of child supported + * by a widget and thus they may have different sets + * of properties for each type - this association is + * managed on the GladePropertyClass proper. + */ + + GList *signals; /* List of GladeSignalClass objects */ + + GList *child_packings; /* Default packing property values */ + + + GladeWidgetAdaptorPriv *priv; + +}; + +struct _GladeWidgetAdaptorClass +{ + GObjectClass parent_class; + + gboolean fixed; /* If this is a GtkContainer, use free-form + * placement with drag/resize/paste at mouse... + */ + gboolean toplevel; /* If this class is toplevel */ + + + GladePostCreateFunc post_create; /* Executed after widget creation: + * plugins use this to setup various + * support codes. + */ + + GladeGetInternalFunc get_internal_child; /* Retrieves the the internal child + * of the given name. + */ + + GladeEditorLaunchFunc launch_editor; /* Entry point for custom editors. */ + + GladeAddChildFunc add; /* Adds a new child of this type */ + GladeRemoveChildFunc remove; /* Removes a child from the container */ + GladeGetChildrenFunc get_children; /* Returns a list of direct children for + * this support type. + */ + + GladeChildSetPropertyFunc child_set_property; /* Sets/Gets a packing property */ + GladeChildGetPropertyFunc child_get_property; /* for this child */ + + GladeReplaceChildFunc replace_child; /* This method replaces a + * child widget with + * another one: it's used to + * replace a placeholder with + * a widget and viceversa. + */ +}; + +#define glade_widget_adaptor_create_widget(adaptor, query, ...) \ + (glade_widget_adaptor_create_widget_real (query, "adaptor", adaptor, __VA_ARGS__)); + +#define glade_widget_adaptor_from_pclass(pclass) \ + ((pclass) ? (GladeWidgetAdaptor *)((GladePropertyClass *)(pclass))->handle : NULL) + +LIBGLADEUI_API +GType glade_widget_adaptor_get_type (void) G_GNUC_CONST; + + +LIBGLADEUI_API +GladeWidgetAdaptor *glade_widget_adaptor_from_catalog (GladeXmlNode *class_node, + const gchar *catname, + const gchar *library, + const gchar *domain, + const gchar *book); +LIBGLADEUI_API +void glade_widget_adaptor_register (GladeWidgetAdaptor *adaptor); +LIBGLADEUI_API +GladeWidget *glade_widget_adaptor_create_internal (GladeWidget *parent, + GObject *internal_object, + const gchar *internal_name, + const gchar *parent_name, + gboolean anarchist, + GladeCreateReason reason); +LIBGLADEUI_API +GladeWidget *glade_widget_adaptor_create_widget_real (gboolean query, + const gchar *first_property, + ...); + +LIBGLADEUI_API +GladeWidgetAdaptor *glade_widget_adaptor_get_by_name (const gchar *name); +LIBGLADEUI_API +GladeWidgetAdaptor *glade_widget_adaptor_get_by_type (GType type); +LIBGLADEUI_API +GList *glade_widget_adaptor_get_derived_adaptors (GType type); +LIBGLADEUI_API +GladePropertyClass *glade_widget_adaptor_get_property_class (GladeWidgetAdaptor *adaptor, + const gchar *name); +LIBGLADEUI_API +GladePropertyClass *glade_widget_adaptor_get_pack_property_class (GladeWidgetAdaptor *adaptor, + const gchar *name); +LIBGLADEUI_API +GParameter *glade_widget_adaptor_default_params (GladeWidgetAdaptor *adaptor, + gboolean construct, + guint *n_params); +LIBGLADEUI_API +void glade_widget_adaptor_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason); +LIBGLADEUI_API +GObject *glade_widget_adaptor_get_internal_child (GladeWidgetAdaptor *adaptor, + GObject *object, + const gchar *internal_name); +LIBGLADEUI_API +void glade_widget_adaptor_launch_editor (GladeWidgetAdaptor *adaptor, + GObject *object); +LIBGLADEUI_API +void glade_widget_adaptor_add (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child); +LIBGLADEUI_API +void glade_widget_adaptor_remove (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child); +LIBGLADEUI_API +GList *glade_widget_adaptor_get_children (GladeWidgetAdaptor *adaptor, + GObject *container); +LIBGLADEUI_API +gboolean glade_widget_adaptor_has_child (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child); +LIBGLADEUI_API +void glade_widget_adaptor_child_set_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + const GValue *value); +LIBGLADEUI_API +void glade_widget_adaptor_child_get_property (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *child, + const gchar *property_name, + GValue *value); +LIBGLADEUI_API +void glade_widget_adaptor_replace_child (GladeWidgetAdaptor *adaptor, + GObject *container, + GObject *old, + GObject *new); +LIBGLADEUI_API +gboolean glade_widget_adaptor_contains_extra (GladeWidgetAdaptor *adaptor); +LIBGLADEUI_API +gboolean glade_widget_adaptor_query (GladeWidgetAdaptor *adaptor); + +LIBGLADEUI_API G_CONST_RETURN +gchar *glade_widget_adaptor_get_packing_default(GladeWidgetAdaptor *child_adaptor, + GladeWidgetAdaptor *parent_adaptor, + const gchar *propert_id); + +G_END_DECLS + +#endif /* __GLADE_WIDGET_ADAPTOR_H__ */ diff --git a/src/glade-widget-class.c b/src/glade-widget-class.c deleted file mode 100644 index 8a24b0c6..00000000 --- a/src/glade-widget-class.c +++ /dev/null @@ -1,1871 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001 Ximian, Inc. - * Copyright (C) 2004 Imendio AB - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Authors: - * Chema Celorio <chema@celorio.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -/* For g_file_exists */ -#include <sys/types.h> -#include <string.h> - -#include <glib/gdir.h> -#include <gmodule.h> -#include <ctype.h> - -#include <glib/gi18n-lib.h> -#include <gtk/gtkenums.h> /* This should go away. Chema */ - -#include "glade.h" -#include "glade-widget-class.h" -#include "glade-xml-utils.h" -#include "glade-property.h" -#include "glade-property-class.h" -#include "glade-signal.h" -#include "glade-parameter.h" -#include "glade-debug.h" -#include "glade-fixed.h" - -/* hash table that will contain all the GtkWidgetClass'es created, indexed by its name */ -static GHashTable *widget_classes = NULL; - - -#define GLADE_LARGE_ICON_SUBDIR "22x22" -#define GLADE_LARGE_ICON_SIZE 22 - -#define GLADE_SMALL_ICON_SUBDIR "16x16" -#define GLADE_SMALL_ICON_SIZE 16 - - -typedef struct { - gchar *parent_name; - GList *packing_defaults; -} GladeChildPacking; - -static void -glade_widget_class_free_child (GladeSupportedChild *child) -{ - g_list_foreach (child->properties, (GFunc) glade_property_class_free, NULL); - g_list_free (child->properties); - g_free (child); -} - -static void -glade_widget_class_packing_default_free (GladePackingDefault *def) -{ - g_free (def->id); - g_free (def->value); -} - -static void -glade_widget_class_child_packing_free (GladeChildPacking *packing) -{ - g_free (packing->parent_name); - - g_list_foreach (packing->packing_defaults, - (GFunc) glade_widget_class_packing_default_free, NULL); - g_list_free (packing->packing_defaults); -} - -/** - * glade_widget_class_free: - * @widget_class: a #GladeWidgetClass - * - * Frees @widget_class and its associated memory. - */ -void -glade_widget_class_free (GladeWidgetClass *widget_class) -{ - if (widget_class == NULL) - return; - - g_free (widget_class->generic_name); - g_free (widget_class->name); - g_free (widget_class->catalog); - if (widget_class->book) - g_free (widget_class->book); - - g_list_foreach (widget_class->properties, (GFunc) glade_property_class_free, NULL); - g_list_free (widget_class->properties); - - g_list_foreach (widget_class->children, (GFunc) glade_widget_class_free_child, NULL); - g_list_free (widget_class->children); - - g_list_foreach (widget_class->child_packings, - (GFunc) glade_widget_class_child_packing_free, - NULL); - - g_list_free (widget_class->child_packings); - - g_list_foreach (widget_class->signals, (GFunc) glade_signal_free, NULL); - g_list_free (widget_class->signals); - - if (widget_class->cursor != NULL) - gdk_cursor_unref (widget_class->cursor); - - if (widget_class->large_icon != NULL) - g_object_unref (G_OBJECT (widget_class->large_icon)); - - if (widget_class->small_icon != NULL) - g_object_unref (G_OBJECT (widget_class->small_icon)); - -} - -static GList * -gwc_props_from_pspecs (GladeWidgetClass *class, - GParamSpec **specs, - gint n_specs) -{ - GladePropertyClass *property_class; - gint i; - GList *list = NULL; - - for (i = 0; i < n_specs; i++) - { - if ((property_class = - glade_property_class_new_from_spec (class, specs[i])) != NULL) - list = g_list_prepend (list, property_class); - } - return g_list_reverse (list); -} - -static GList * -glade_widget_class_list_properties (GladeWidgetClass *class) -{ - GObjectClass *object_class; - GParamSpec **specs = NULL; - guint n_specs = 0; - GList *list, *atk_list = NULL; - - g_return_val_if_fail (GLADE_IS_WIDGET_CLASS (class), NULL); - - /* Let it leek */ - if ((object_class = g_type_class_ref (class->type)) == NULL) - { - g_critical ("Failed to get class for type %s\n", - g_type_name (class->type)); - return NULL; - } - - /* list class properties */ - specs = g_object_class_list_properties (object_class, &n_specs); - list = gwc_props_from_pspecs (class, specs, n_specs); - g_free (specs); - - /* GtkWidgetClass & descendants have accelerators */ - if (g_type_is_a (class->type, GTK_TYPE_WIDGET)) - list = g_list_append (list, glade_property_class_accel_property - (class, class->type)); - - /* list the (hard-coded) atk relation properties if applicable */ - if (glade_util_class_implements_interface (class->type, - ATK_TYPE_IMPLEMENTOR)) - atk_list = glade_property_class_list_atk_relations (class, class->type); - - return g_list_concat (list, atk_list); -} - -/* -This function assignes "weight" to each property in its natural order staring from 1. -If @parent is 0 weight will be set for every GladePropertyClass in the list. -This function will not override weight if it is already set (weight >= 0.0) -*/ -static void -glade_widget_class_properties_set_weight (GList **properties, GType parent) -{ - gint normal = 0, common = 0, packing = 0; - GList *l; - - for (l = *properties; l && l->data; l = g_list_next (l)) - { - GladePropertyClass *class = l->data; - GPCType type = class->type; - - if (class->visible && - (parent) ? parent == class->pspec->owner_type : TRUE && - (type == GPC_NORMAL || type == GPC_ACCEL_PROPERTY)) - { - /* Use a different counter for each tab (common, packing and normal) */ - if (class->common) common++; - else if (class->packing) packing++; - else normal++; - - /* Skip if it is already set */ - if (class->weight >= 0.0) continue; - - /* Special-casing weight of properties for seperate tabs */ - if (class->common) class->weight = common; - else if (class->packing) class->weight = packing; - else class->weight = normal; - } - } -} - -static GList * -glade_widget_class_list_child_properties (GladeWidgetClass *class) -{ - GladePropertyClass *property_class; - GObjectClass *object_class; - GParamSpec **specs = NULL; - guint n_specs = 0; - GList *list = NULL, *l; - - g_return_val_if_fail (GLADE_IS_WIDGET_CLASS (class), NULL); - - /* only GtkContainer child propeties can be introspected */ - if (!g_type_is_a (class->type, GTK_TYPE_CONTAINER)) - return NULL; - - /* Let it leek */ - if ((object_class = g_type_class_ref (class->type)) == NULL) - { - g_warning ("Failed to get class for type %s\n", - g_type_name (class->type)); - return NULL; - } - - specs = gtk_container_class_list_child_properties (object_class, &n_specs); - list = gwc_props_from_pspecs (class, specs, n_specs); - g_free (specs); - - /* We have to mark packing properties from GladeWidgetClass - * because GladePropertyClass doesnt have a valid parent GType - * to introspect it. - * - * (which could be used to call gtk_container_class_find_child_property() - * and properly introspect whether or not its a packing property). - */ - for (l = list; l; l = l->next) - { - property_class = l->data; - property_class->packing = TRUE; - } - - /* Set default weight on packing properties */ - glade_widget_class_properties_set_weight (&list, 0); - - return list; -} - -static GList * -glade_widget_class_list_children (GladeWidgetClass *class) -{ - GladeSupportedChild *child; - GList *children = NULL; - - /* Implicitly handle GtkContainer and derivitive types and retrieve packing properties. - */ - if (g_type_is_a (class->type, GTK_TYPE_CONTAINER)) - { - child = g_new0 (GladeSupportedChild, 1); - child->type = GTK_TYPE_WIDGET; - child->properties = glade_widget_class_list_child_properties (class); - - if (class->type == GTK_TYPE_CONTAINER) - { - child->add = (GladeAddChildFunc) gtk_container_add; - child->remove = (GladeRemoveChildFunc) gtk_container_remove; - child->get_children = - (GladeGetChildrenFunc) glade_util_container_get_all_children; - child->set_property = - (GladeChildSetPropertyFunc) gtk_container_child_set_property; - child->get_property = - (GladeChildGetPropertyFunc) gtk_container_child_get_property; - } - - children = g_list_append (children, child); - } - return children; -} - -static gint -glade_widget_class_signal_comp (gconstpointer a, gconstpointer b) -{ - const GladeSignalClass *signal_a = a, *signal_b = b; - return strcmp (signal_b->query.signal_name, signal_a->query.signal_name); -} - -static void -glade_widget_class_add_signals (GList **signals, GType type) -{ - guint count, *sig_ids, num_signals; - GladeSignalClass *cur; - GList *list = NULL; - - if (G_TYPE_IS_INSTANTIATABLE (type) || G_TYPE_IS_INTERFACE (type)) - { - sig_ids = g_signal_list_ids (type, &num_signals); - - for (count = 0; count < num_signals; count++) - { - cur = g_new0 (GladeSignalClass, 1); - - g_signal_query (sig_ids[count], &(cur->query)); - - /* Since glib gave us this signal id... it should - * exist no matter what. - */ - g_assert (cur->query.signal_id != 0); - - cur->name = (cur->query.signal_name); - cur->type = (gchar *) g_type_name (type); - - list = g_list_prepend (list, cur); - } - g_free (sig_ids); - - list = g_list_sort (list, glade_widget_class_signal_comp); - *signals = g_list_concat (list, *signals); - } -} - -static GList * -glade_widget_class_list_signals (GladeWidgetClass *class) -{ - GList *signals = NULL; - GType type, parent, *i, *p; - - g_return_val_if_fail (class->type != 0, NULL); - - for (type = class->type; g_type_is_a (type, G_TYPE_OBJECT); type = parent) - { - parent = g_type_parent (type); - - /* Add class signals */ - glade_widget_class_add_signals (&signals, type); - - /* Add class interfaces signals */ - for (i = p = g_type_interfaces (type, NULL); *i; i++) - if (!glade_util_class_implements_interface (parent, *i)) - glade_widget_class_add_signals (&signals, *i); - - g_free (p); - } - - return g_list_reverse (signals); -} - -static void -glade_widget_class_load_icons (GladeWidgetClass *class) -{ - GError *error = NULL; - gchar *icon_path; - - - /* only certain widget classes need to have icons */ - if (G_TYPE_IS_INSTANTIATABLE (class->type) == FALSE || - G_TYPE_IS_ABSTRACT (class->type) != FALSE || - class->generic_name == NULL) - { - return; - } - - /* load large 22x22 icon */ - icon_path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S GLADE_LARGE_ICON_SUBDIR G_DIR_SEPARATOR_S "%s.png", - glade_pixmaps_dir, - class->generic_name); - - class->large_icon = gdk_pixbuf_new_from_file_at_size (icon_path, - GLADE_LARGE_ICON_SIZE, - GLADE_LARGE_ICON_SIZE, - &error); - - if (class->large_icon == NULL) - { - g_warning (_("Unable to load icon for %s (%s)"), class->name, error->message); - - g_error_free (error); - error = NULL; - - /* use stock missing icon */ - class->large_icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), - GTK_STOCK_MISSING_IMAGE, - GLADE_LARGE_ICON_SIZE, - GTK_ICON_LOOKUP_USE_BUILTIN, &error); - if (class->large_icon == NULL) - { - g_critical (_("Unable to load stock icon (%s)"), - error->message); - - g_error_free (error); - error = NULL; - } - } - g_free (icon_path); - - - /* load small 16x16 icon */ - icon_path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S GLADE_SMALL_ICON_SUBDIR G_DIR_SEPARATOR_S "%s.png", - glade_pixmaps_dir, - class->generic_name); - - class->small_icon = gdk_pixbuf_new_from_file_at_size (icon_path, - GLADE_SMALL_ICON_SIZE, - GLADE_SMALL_ICON_SIZE, - &error); - - if (class->small_icon == NULL) - { - g_warning (_("Unable to load icon for %s (%s)"), class->name, error->message); - - g_error_free (error); - error = NULL; - - /* use stock missing icon */ - class->small_icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), - GTK_STOCK_MISSING_IMAGE, - GLADE_SMALL_ICON_SIZE, - GTK_ICON_LOOKUP_USE_BUILTIN, &error); - if (class->small_icon == NULL) - { - g_critical (_("Unable to load stock icon (%s)"), - error->message); - - g_error_free (error); - error = NULL; - } - } - - g_free (icon_path); - -} - -static void -glade_widget_class_create_cursor (GladeWidgetClass *widget_class) -{ - GdkPixbuf *tmp_pixbuf; - const GdkPixbuf *add_pixbuf; - GdkDisplay *display; - - /* only certain widget classes need to have cursors */ - if (G_TYPE_IS_INSTANTIATABLE (widget_class->type) == FALSE || - G_TYPE_IS_ABSTRACT (widget_class->type) != FALSE || - widget_class->generic_name == NULL) - return; - - /* cannot continue if 'add widget' cursor pixbuf has not been loaded for any reason */ - if ((add_pixbuf = glade_cursor_get_add_widget_pixbuf ()) == NULL) - return; - - display = gdk_display_get_default (); - - /* create a temporary pixbuf clear to transparent black*/ - tmp_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 32, 32); - gdk_pixbuf_fill (tmp_pixbuf, 0x00000000); - - - /* composite pixbufs */ - gdk_pixbuf_composite (widget_class->large_icon, tmp_pixbuf, - 8, 8, 22, 22, - 8, 8, 1, 1, - GDK_INTERP_NEAREST, 255); - - gdk_pixbuf_composite (add_pixbuf, tmp_pixbuf, - 0, 0, 12, 12, - 0, 0, 1, 1, - GDK_INTERP_NEAREST, 255); - - - widget_class->cursor = gdk_cursor_new_from_pixbuf (display, tmp_pixbuf, 6, 6); - - g_object_unref(tmp_pixbuf); -} - -static void -glade_widget_class_update_properties_from_node (GladeXmlNode *node, - GladeWidgetClass *widget_class, - GList **properties, - const gchar *domain) -{ - GladeXmlNode *child; - - for (child = glade_xml_node_get_children (node); - child; child = glade_xml_node_next (child)) - { - gchar *id; - GList *list; - GladePropertyClass *property_class; - gboolean updated; - - if (!glade_xml_node_verify (child, GLADE_TAG_PROPERTY)) - continue; - - id = glade_xml_get_property_string_required - (child, GLADE_TAG_ID, widget_class->name); - if (!id) - continue; - - /* property names from catalogs also need to have the '-' form */ - glade_util_replace (id, '_', '-'); - - /* find the property in our list, if not found append a new property */ - for (list = *properties; list && list->data; list = list->next) - { - property_class = GLADE_PROPERTY_CLASS (list->data); - if (property_class->id != NULL && - g_ascii_strcasecmp (id, property_class->id) == 0) - break; - } - - if (list) - { - property_class = GLADE_PROPERTY_CLASS (list->data); - } - else - { - property_class = glade_property_class_new (widget_class); - property_class->id = g_strdup (id); - *properties = g_list_append (*properties, property_class); - list = g_list_last (*properties); - } - - updated = glade_property_class_update_from_node - (child, widget_class->module, - widget_class->type, - &property_class, domain); - if (!updated) - { - g_warning ("failed to update %s property of %s from xml", - id, widget_class->name); - g_free (id); - continue; - } - - /* the property has Disabled=TRUE ... */ - if (!property_class) - *properties = g_list_delete_link (*properties, list); - - g_free (id); - } -} - -static void -glade_widget_class_set_packing_defaults_from_node (GladeXmlNode *node, - GladeWidgetClass *widget_class) -{ - GladeXmlNode *child; - - child = glade_xml_node_get_children (node); - for (; child; child = glade_xml_node_next (child)) - { - gchar *name; - GladeXmlNode *prop_node; - GladeChildPacking *packing; - - if (!glade_xml_node_verify (child, GLADE_TAG_PARENT_CLASS)) - continue; - - name = glade_xml_get_property_string_required (child, - GLADE_TAG_NAME, - widget_class->name); - - if (!name) - continue; - - packing = g_new0 (GladeChildPacking, 1); - packing->parent_name = name; - packing->packing_defaults = NULL; - - widget_class->child_packings = g_list_prepend (widget_class->child_packings, packing); - - prop_node = glade_xml_node_get_children (child); - for (; prop_node; prop_node = glade_xml_node_next (prop_node)) - { - GladePackingDefault *def; - gchar *id; - gchar *value; - - id = glade_xml_get_property_string_required (prop_node, - GLADE_TAG_ID, - widget_class->name); - if (!id) - continue; - - value = glade_xml_get_property_string_required (prop_node, - GLADE_TAG_DEFAULT, - widget_class->name); - if (!value) - { - g_free (id); - continue; - } - - def = g_new0 (GladePackingDefault, 1); - def->id = id; - def->value = value; - - packing->packing_defaults = g_list_prepend (packing->packing_defaults, - def); - } - } -} - -static gint -glade_widget_class_find_child_by_type (GladeSupportedChild *child, GType type) -{ - return child->type - type; -} - -static void -glade_widget_class_update_children_from_node (GladeXmlNode *node, - GladeWidgetClass *widget_class, - const gchar *domain) -{ - GladeSupportedChild *child; - GladeXmlNode *child_node, *properties; - gchar *buff; - GList *list; - GType type; - - for (child_node = glade_xml_node_get_children (node); - child_node; - child_node = glade_xml_node_next (child_node)) - { - - if (!glade_xml_node_verify (child_node, GLADE_TAG_CHILD)) - continue; - - /* Use alot of emacs realastate to ensure that we have a type. */ - if ((buff = glade_xml_get_value_string (child_node, GLADE_TAG_TYPE)) != NULL) - { - if ((type = glade_util_get_type_from_name (buff)) == 0) - { - g_free (buff); - continue; - } - g_free (buff); - } else { - g_warning ("Child specified without a type, ignoring"); - continue; - } - - if (widget_class->children && - (list = g_list_find_custom - (widget_class->children, GINT_TO_POINTER(type), - (GCompareFunc)glade_widget_class_find_child_by_type)) != NULL) - { - child = (GladeSupportedChild *)list->data; - } - else - { - child = g_new0 (GladeSupportedChild, 1); - child->type = type; - widget_class->children = g_list_append (widget_class->children, child); - } - - if ((buff = - glade_xml_get_value_string (child_node, - GLADE_TAG_SPECIAL_CHILD_TYPE)) != NULL) - { - g_free (child->special_child_type); - child->special_child_type = buff; - } - - if (widget_class->module) - { - glade_xml_load_sym_from_node (child_node, widget_class->module, - GLADE_TAG_ADD_CHILD_FUNCTION, - (gpointer *)&child->add); - glade_xml_load_sym_from_node (child_node, widget_class->module, - GLADE_TAG_REMOVE_CHILD_FUNCTION, - (gpointer *)&child->remove); - glade_xml_load_sym_from_node (child_node, widget_class->module, - GLADE_TAG_GET_CHILDREN_FUNCTION, - (gpointer *)&child->get_children); - glade_xml_load_sym_from_node (child_node, widget_class->module, - GLADE_TAG_CHILD_SET_PROP_FUNCTION, - (gpointer *)&child->set_property); - glade_xml_load_sym_from_node (child_node, widget_class->module, - GLADE_TAG_CHILD_GET_PROP_FUNCTION, - (gpointer *)&child->get_property); - glade_xml_load_sym_from_node (child_node, widget_class->module, - GLADE_TAG_REPLACE_CHILD_FUNCTION, - (gpointer *)&child->replace_child); - } - - /* if we found a <Properties> tag on the xml file, we add the - * properties that we read from the xml file to the class. - */ - if ((properties = - glade_xml_search_child (child_node, GLADE_TAG_PROPERTIES)) != NULL) - { - glade_widget_class_update_properties_from_node - (properties, widget_class, &child->properties, domain); - - for (list = child->properties; list != NULL; list = list->next) - ((GladePropertyClass *)list->data)->packing = TRUE; - } - } -} - -static gboolean -glade_widget_class_extend_with_node (GladeWidgetClass *widget_class, - GladeXmlNode *node, - const gchar *domain) -{ - GladeXmlNode *child; - - g_return_val_if_fail (widget_class != NULL, FALSE); - g_return_val_if_fail (node != NULL, FALSE); - - if (widget_class->module) - { - glade_xml_load_sym_from_node (node, widget_class->module, - GLADE_TAG_POST_CREATE_FUNCTION, - (void **)&widget_class->post_create_function); - - glade_xml_load_sym_from_node (node, widget_class->module, - GLADE_TAG_GET_INTERNAL_CHILD_FUNCTION, - (void **)&widget_class->get_internal_child); - - glade_xml_load_sym_from_node (node, widget_class->module, - GLADE_TAG_LAUNCH_EDITOR_FUNCTION, - (void **) - &widget_class->launch_editor); - } - widget_class->fixed = - glade_xml_get_property_boolean (node, GLADE_TAG_FIXED, widget_class->fixed); - - /* Check if this class is toplevel */ - widget_class->toplevel = - glade_xml_get_property_boolean (node, GLADE_XML_TAG_TOPLEVEL, - widget_class->toplevel); - - /* if we found a <properties> tag on the xml file, we add the properties - * that we read from the xml file to the class. - */ - child = glade_xml_search_child (node, GLADE_TAG_PROPERTIES); - if (child) - { - glade_widget_class_update_properties_from_node - (child, widget_class, &widget_class->properties, domain); - } - - child = glade_xml_search_child (node, GLADE_TAG_CHILDREN); - if (child) - { - glade_widget_class_update_children_from_node - (child, widget_class, domain); - } - - child = glade_xml_search_child (node, GLADE_TAG_PACKING_DEFAULTS); - if (child) - { - glade_widget_class_set_packing_defaults_from_node (child, - widget_class); - } - - return TRUE; -} - -/** - * glade_widget_class_get_by_name: - * @name: name of the widget class (for instance: GtkButton) - * - * Returns: an existing #GladeWidgetClass with the name equaling @name, - * or %NULL if such a class doesn't exist - **/ -GladeWidgetClass * -glade_widget_class_get_by_name (const char *name) -{ - if (widget_classes != NULL) - return g_hash_table_lookup (widget_classes, name); - else - return NULL; -} - -typedef struct -{ - GType type; - GladeWidgetClass *class; -} GladeClassSearchPair; - -static void -search_class_by_type (gchar *name, - GladeWidgetClass *class, - GladeClassSearchPair *pair) -{ - if (class->type == pair->type) - pair->class = class; -} - -GladeWidgetClass * -glade_widget_class_get_by_type (GType type) -{ - GladeClassSearchPair pair = { type, NULL }; - - if (widget_classes != NULL) - { - g_hash_table_foreach (widget_classes, (GHFunc)search_class_by_type, &pair); - } - return pair.class; -} - -typedef struct -{ - GType type; - GList *list; -} GladeClassAccumPair; - -static void -accum_class_by_type (gchar *name, - GladeWidgetClass *class, - GladeClassAccumPair *pair) -{ - if (g_type_is_a (class->type, pair->type)) - pair->list = g_list_prepend (pair->list, class); -} - -GList * -glade_widget_class_get_derived_types (GType type) -{ - GladeClassAccumPair pair = { type, NULL }; - - if (widget_classes) - g_hash_table_foreach (widget_classes, (GHFunc) accum_class_by_type, &pair); - - return pair.list; -} - - -/** - * glade_widget_class_merge_properties: - * @widget_properties: Pointer to the list of properties in the widget. - * @parent_class: List of properties in the parent. - * - * Merges the properties found in the parent_properties list with the - * properties found in the @widget_properties list. - * The properties in the parent_properties will be prepended to - * @widget_properties. - **/ -static void -glade_widget_class_merge_properties (GType parent_type, - GList **widget_properties, - GList *parent_properties) -{ - GladePropertyClass *property_class; - GObjectClass *object_class; - GParamSpec **specs = NULL, *spec; - GList *list, *list2, *remove; - guint i, n_specs; - gboolean found; - - for (list = parent_properties; list; list = list->next) - { - GladePropertyClass *parent_p_class = list->data; - GladePropertyClass *child_p_class; - - - /* search the child's properties for one with the same id */ - for (list2 = *widget_properties; list2; list2 = list2->next) - { - child_p_class = list2->data; - if (strcmp (parent_p_class->id, child_p_class->id) == 0) - break; - } - - /* if not found, append a clone of the parent's one; if found - * but the parent one was modified (and not the child one) - * substitute it (note it is importand to *append* and not prepend - * since this would screw up the order of custom properties in - * derived objects). - */ - if (!list2) - { - property_class = glade_property_class_clone (parent_p_class); - *widget_properties = g_list_append (*widget_properties, property_class); - } - else if (parent_p_class->is_modified && !child_p_class->is_modified) - { - glade_property_class_free (child_p_class); - list2->data = glade_property_class_clone (parent_p_class); - } - } - - /* Remove any properties found in widget_properties not found in parent_properties - * if parent_properties should have it through introspection - */ - object_class = g_type_class_ref (parent_type); /* Let it leek please */ - specs = g_object_class_list_properties (object_class, &n_specs); - - for (i = 0; i < n_specs; i++) - { - spec = specs[i]; - found = FALSE; - - for (list = parent_properties; list; list = list->next) - { - property_class = list->data; - - /* We only use the writable properties */ - if ((spec->flags & G_PARAM_WRITABLE) && - !strcmp (property_class->id, spec->name)) - { - found = TRUE; - break; - } - } - - /* If we didnt find a property in the parents properties thats - * listed in its real properties, remove those properties from - * the child properties. - */ - if (!found) - { - remove = NULL; - for (list = *widget_properties; list; list = list->next) - { - property_class = list->data; - - if (!strcmp (property_class->id, spec->name)) - { - remove = g_list_prepend (remove, list); - break; - } - } - for (list = remove; list; list = list->next) - { - *widget_properties = - g_list_delete_link (*widget_properties, - (GList *)list->data); - } - g_list_free (remove); - } - } // for i in specs - g_free (specs); -} - -static GladeSupportedChild * -glade_widget_class_clone_child (GladeSupportedChild *child, - GladeWidgetClass *parent_class) -{ - GladeSupportedChild *clone; - - clone = g_new0 (GladeSupportedChild, 1); - - clone->type = child->type; - clone->add = child->add; - clone->remove = child->remove; - clone->get_children = child->get_children; - clone->set_property = child->set_property; - clone->get_property = child->get_property; - clone->replace_child = child->replace_child; - - clone->properties = glade_widget_class_list_child_properties (parent_class); - glade_widget_class_merge_properties - (parent_class->type, &clone->properties, child->properties); - - return clone; -} - -static void -glade_widget_class_merge_child (GladeSupportedChild *widgets_child, - GladeSupportedChild *parents_child) -{ - if (!widgets_child->add) - widgets_child->add = parents_child->add; - if (!widgets_child->remove) - widgets_child->remove = parents_child->remove; - if (!widgets_child->get_children) - widgets_child->get_children = parents_child->get_children; - if (!widgets_child->set_property) - widgets_child->set_property = parents_child->set_property; - if (!widgets_child->get_property) - widgets_child->get_property = parents_child->get_property; - if (!widgets_child->replace_child) - widgets_child->replace_child = parents_child->replace_child; - - glade_widget_class_merge_properties - (parents_child->type, - &widgets_child->properties, parents_child->properties); -} - -static void -glade_widget_class_merge_children (GList **widget_children, - GList *parent_children, - GladeWidgetClass *widget_class) -{ - GList *list; - GList *list2; - - for (list = parent_children; list && list->data; list = list->next) - { - GladeSupportedChild *parents_child = list->data; - GladeSupportedChild *widgets_child = NULL; - - for (list2 = *widget_children; list2 && list2->data; list2 = list2->next) - { - widgets_child = list2->data; - if (widgets_child->type == parents_child->type) - break; - } - - /* if not found, prepend a clone of the parent's one; if found - * but the parent one was modified (and not the child one) - * substitute it. - */ - if (!list2) - { - *widget_children = - g_list_prepend (*widget_children, - glade_widget_class_clone_child (parents_child, - widget_class)); - } - else - { - glade_widget_class_merge_child (widgets_child, parents_child); - } - } -} - - -/** - * glade_widget_class_merge: - * @widget_class: main class. - * @parent_class: secondary class. - * - * Merges the contents of the @parent_class on the @widget_class. - * The properties of the @parent_class will be prepended to - * those of @widget_class. - */ -static void -glade_widget_class_merge (GladeWidgetClass *widget_class, - GladeWidgetClass *parent_class) -{ - g_return_if_fail (GLADE_IS_WIDGET_CLASS (widget_class)); - g_return_if_fail (GLADE_IS_WIDGET_CLASS (parent_class)); - - if (widget_class->fixed == FALSE) - widget_class->fixed = parent_class->fixed; - - if (widget_class->post_create_function == NULL) - widget_class->post_create_function = parent_class->post_create_function; - - if (widget_class->get_internal_child == NULL) - widget_class->get_internal_child = parent_class->get_internal_child; - - if (widget_class->launch_editor == NULL) - widget_class->launch_editor = parent_class->launch_editor; - - if (widget_class->toplevel == FALSE) - widget_class->toplevel = parent_class->toplevel; - - /* merge the parent's properties */ - glade_widget_class_merge_properties - (parent_class->type, - &widget_class->properties, parent_class->properties); - - /* merge the parent's supported children */ - glade_widget_class_merge_children - (&widget_class->children, parent_class->children, widget_class); -} - -/** - * glade_widget_class_new: - * @class_node: A #GladeXmlNode - * @catname: the name of the owning catalog - * @library: the name of the library used to load class methods from - * @domain: the domain to translate strings from this plugin from - * @book: the devhelp search domain for the owning catalog. - * - * Merges the contents of the @parent_class on the @widget_class. - * The properties of the @parent_class will be prepended to - * those of @widget_class. - */ -GladeWidgetClass * -glade_widget_class_new (GladeXmlNode *class_node, - const gchar *catname, - const gchar *library, - const gchar *domain, - const gchar *book) -{ - GladeWidgetClass *widget_class; - gchar *name, *generic_name, *ptr; - gchar *title; - GModule *module; - GType parent_type; - - if (!glade_xml_node_verify (class_node, GLADE_TAG_GLADE_WIDGET_CLASS)) - { - g_warning ("Widget class node is not '%s'", - GLADE_TAG_GLADE_WIDGET_CLASS); - return NULL; - } - - if ((name = glade_xml_get_property_string_required - (class_node, GLADE_TAG_NAME, NULL)) == NULL) - return NULL; - - if (glade_widget_class_get_by_name (name)) - { - g_warning ("Widget class '%s' already defined", name); - - g_free (name); - return NULL; - } - - /* Perform a stupid fallback as generic_name is not required - * for uninstantiatable classes - */ - generic_name = glade_xml_get_property_string - (class_node, GLADE_TAG_GENERIC_NAME); - - if ((title = glade_xml_get_property_string_required - (class_node, GLADE_TAG_TITLE, - "This value is needed to display object class names in the UI")) == NULL) - { - g_warning ("Class '%s' built without a '%s'", name, GLADE_TAG_TITLE); - title = g_strdup (name); - } - - /* Translate title */ - if (title != dgettext (domain, title)) - { - ptr = dgettext (domain, title); - g_free (title); - title = ptr; - } - - module = NULL; - if (library) - { - module = glade_util_load_library (library); - if (!module) - { - g_warning ("Failed to load external library '%s'", - library); - g_free (name); - g_free (generic_name); - g_free (title); - return NULL; - } - } - - widget_class = g_new0 (GladeWidgetClass, 1); - widget_class->name = name; - widget_class->module = module; - widget_class->generic_name = generic_name; - widget_class->palette_name = title; - widget_class->type = glade_util_get_type_from_name (name); - widget_class->cursor = NULL; - widget_class->large_icon = NULL; - widget_class->small_icon = NULL; - widget_class->toplevel = FALSE; - - if (G_TYPE_IS_INSTANTIATABLE (widget_class->type) && - G_TYPE_IS_ABSTRACT (widget_class->type) == FALSE && - widget_class->generic_name == NULL) - { - g_warning ("Instantiatable class '%s' built without a '%s'", - name, GLADE_TAG_GENERIC_NAME); - } - - /* Perform a stoopid fallback just incase */ - if (widget_class->generic_name == NULL) - widget_class->generic_name = g_strdup ("widget"); - - - /* Dont mention gtk+ as a required lib in the generated glade file */ - if (strcmp (catname, "gtk+")) - widget_class->catalog = g_strdup (catname); - - if (book) - widget_class->book = g_strdup (book); - - if (widget_class->type == 0) - { - glade_widget_class_free (widget_class); - return NULL; - } - - widget_class->properties = glade_widget_class_list_properties (widget_class); - widget_class->signals = glade_widget_class_list_signals (widget_class); - widget_class->children = glade_widget_class_list_children (widget_class); - - glade_widget_class_load_icons (widget_class); - glade_widget_class_create_cursor (widget_class); - - for (parent_type = g_type_parent (widget_class->type); - parent_type != 0; - parent_type = g_type_parent (parent_type)) - { - const gchar *parent_name; - GladeWidgetClass *parent_class; - - parent_name = g_type_name (parent_type); - parent_class = glade_widget_class_get_by_name (parent_name); - - if (parent_class) - glade_widget_class_merge (widget_class, parent_class); - } - - glade_widget_class_extend_with_node (widget_class, class_node, domain); - - /* store the GladeWidgetClass on the cache, - * if it's the first time we store a widget class, then - * initialize the global widget_classes hash. - */ - if (!widget_classes) - widget_classes = g_hash_table_new (g_str_hash, g_str_equal); - g_hash_table_insert (widget_classes, widget_class->name, widget_class); - - /* Set default weight on properties */ - for (parent_type = widget_class->type; - parent_type != 0; - parent_type = g_type_parent (parent_type)) - glade_widget_class_properties_set_weight (&widget_class->properties, - parent_type); - - return widget_class; -} - -/** - * glade_widget_class_get_name: - * @widget: a #GladeWidgetClass - * - * Returns: the name of @widget - */ -const gchar * -glade_widget_class_get_name (GladeWidgetClass *widget) -{ - return widget->name; -} - -/** - * glade_widget_class_get_type: - * @widget: a #GladeWidgetClass - * - * Returns: the #GType of @widget - */ -GType -glade_widget_class_get_type (GladeWidgetClass *widget) -{ - return widget->type; -} - -/** - * glade_widget_class_get_property_class: - * @class: a #GladeWidgetClass - * @name: a string - * - * Returns: The #GladePropertyClass object if there is one associated to this widget - * class. - */ -GladePropertyClass * -glade_widget_class_get_property_class (GladeWidgetClass *class, - const gchar *name) -{ - GList *list, *l; - GladePropertyClass *pclass; - - for (list = class->properties; list && list->data; list = list->next) - { - pclass = list->data; - if (strcmp (pclass->id, name) == 0) - return pclass; - } - - for (list = class->children; list && list->data; list = list->next) - { - GladeSupportedChild *support = list->data; - - for (l = support->properties; l && l->data; l = l->next) - { - pclass = l->data; - if (strcmp (pclass->id, name) == 0) - return pclass; - } - } - - return NULL; -} - -/** - * glade_widget_class_dump_param_specs: - * @class: a #GladeWidgetClass - * - * Dump to the console the properties of @class as specified - * by gtk+. You can also run glade3 with : "glade-3 --dump GtkWindow" to - * get dump a widget class properties. - */ -void -glade_widget_class_dump_param_specs (GladeWidgetClass *class) -{ - GObjectClass *object_class; - GParamSpec **specs = NULL; - GParamSpec *spec; - GType last; - guint n_specs = 0; - gint i; - - g_return_if_fail (GLADE_IS_WIDGET_CLASS (class)); - - g_type_class_ref (class->type); /* hmm */ - /* We count on the fact we have an instance, or else we'd have - * to use g_type_class_ref (); - */ - - object_class = g_type_class_peek (class->type); - if (!object_class) - { - g_warning ("Class peek failed\n"); - return; - } - - specs = g_object_class_list_properties (object_class, &n_specs); - - g_print ("\nDumping ParamSpec for %s\n", class->name); - - last = 0; - for (i = 0; i < n_specs; i++) - { - spec = specs[i]; - if (last != spec->owner_type) - g_print ("\n -- %s -- \n", - g_type_name (spec->owner_type)); - g_print ("%02d - %-25s %-25s (%s)\n", - i, - spec->name, - g_type_name (spec->value_type), - (spec->flags & G_PARAM_WRITABLE) ? "Writable" : "ReadOnly"); - last = spec->owner_type; - } - g_print ("\n"); - - g_free (specs); -} - -/** - * glade_widget_class_get_child_support: - * @class: a #GladeWidgetClass - * @child_type: a #GType - * - * Returns: The #GladeSupportedChild object appropriate to use for - * container vfuncs for this child_type if this child type is supported, - * otherwise NULL. - * - */ -GladeSupportedChild * -glade_widget_class_get_child_support (GladeWidgetClass *class, - GType child_type) -{ - GList *list; - GladeSupportedChild *child, *ret = NULL; - - for (list = class->children; list && list->data; list = list->next) - { - child = list->data; - if (g_type_is_a (child_type, child->type)) - { - if (ret == NULL) - ret = child; - else if (g_type_depth (ret->type) < - g_type_depth (child->type)) - ret = child; - } - } - return ret; -} - - -/** - * glade_widget_class_default_params: - * @class: a #GladeWidgetClass - * @construct: whether to return construct params or not construct params - * @n_params: return location if any defaults are specified for this class. - * - * Returns: A list of params for use in g_object_newv () - */ -GParameter * -glade_widget_class_default_params (GladeWidgetClass *class, - gboolean construct, - guint *n_params) -{ - GArray *params; - GObjectClass *oclass; - GParamSpec **pspec; - GladePropertyClass *pclass; - guint n_props, i; - - g_return_val_if_fail (GLADE_IS_WIDGET_CLASS (class), NULL); - g_return_val_if_fail (n_params != NULL, NULL); - - /* As a slight optimization, we never unref the class - */ - oclass = g_type_class_ref (class->type); - pspec = g_object_class_list_properties (oclass, &n_props); - params = g_array_new (FALSE, FALSE, sizeof (GParameter)); - - for (i = 0; i < n_props; i++) - { - GParameter parameter = { 0, }; - - pclass = glade_widget_class_get_property_class - (class, pspec[i]->name); - - /* Ignore properties based on some criteria - */ - if (pclass == NULL || /* Unaccounted for in the builder */ - pclass->set_function || /* should not be set before - GladeWidget wrapper exists */ - pclass->ignore) /* Catalog explicitly ignores the object */ - continue; - - if (construct && - (pspec[i]->flags & - (G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) == 0) - continue; - else if (!construct && - (pspec[i]->flags & - (G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) != 0) - continue; - - - if (g_value_type_compatible (G_VALUE_TYPE (pclass->def), - pspec[i]->value_type) == FALSE) - { - g_critical ("Type mismatch on %s property of %s", - parameter.name, class->name); - continue; - } - - if (g_param_values_cmp (pspec[i], - pclass->def, - pclass->orig_def) == 0) - continue; - - parameter.name = pspec[i]->name; /* These are not copied/freed */ - g_value_init (¶meter.value, pspec[i]->value_type); - g_value_copy (pclass->def, ¶meter.value); - - g_array_append_val (params, parameter); - } - g_free (pspec); - - *n_params = params->len; - return (GParameter *)g_array_free (params, FALSE); -} - -void -glade_widget_class_container_add (GladeWidgetClass *class, - GObject *container, - GObject *child) -{ - GladeSupportedChild *support; - - if ((support = - glade_widget_class_get_child_support (class, G_OBJECT_TYPE (child))) != NULL) - { - if (support->add) - support->add (container, child); - else - g_warning ("No add support for type %s in %s", - g_type_name (support->type), - class->name); - } - else - g_warning ("No support for type %s in %s", - g_type_name (G_OBJECT_TYPE (child)), - class->name); -} - -void -glade_widget_class_container_remove (GladeWidgetClass *class, - GObject *container, - GObject *child) -{ - GladeSupportedChild *support; - - if ((support = - glade_widget_class_get_child_support (class, G_OBJECT_TYPE (child))) != NULL) - { - if (support->remove) - support->remove (container, child); - else - g_warning ("No remove support for type %s in %s", - g_type_name (support->type), - class->name); - } - else - g_warning ("No support for type %s in %s", - g_type_name (G_OBJECT_TYPE (child)), - class->name); -} - -gboolean -glade_widget_class_container_has_child (GladeWidgetClass *class, - GObject *container, - GObject *child) -{ - GList *list, *children = NULL; - gboolean found = FALSE; - - for (list = class->children; list && list->data; list = list->next) - { - GladeSupportedChild *support = list->data; - if (support->get_children) - children = g_list_concat (children, support->get_children (container)); - } - - for (list = children; list && list->data; list = list->next) - { - if (list->data == child) - { - found = TRUE; - break; - } - } - g_list_free (children); - return found; -} - -GList * -glade_widget_class_container_get_children (GladeWidgetClass *class, - GObject *container) -{ - GList *list, *children = NULL; - - for (list = class->children; list && list->data; list = list->next) - { - GladeSupportedChild *support = list->data; - if (support->get_children) - children = g_list_concat - (children, support->get_children (container)); - } - - /* Remove duplicates */ - return glade_util_purify_list (children); -} - -void -glade_widget_class_container_set_property (GladeWidgetClass *class, - GObject *container, - GObject *child, - const gchar *property_name, - const GValue *value) -{ - GladeSupportedChild *support; - - if ((support = - glade_widget_class_get_child_support (class, G_OBJECT_TYPE (child))) != NULL) - { - if (support->set_property) - support->set_property (container, child, - property_name, value); - else - g_warning ("No set_property support for type %s in %s", - g_type_name (support->type), class->name); - } - else - g_warning ("No support for type %s in %s", - g_type_name (G_OBJECT_TYPE (child)), - class->name); -} - - -void -glade_widget_class_container_get_property (GladeWidgetClass *class, - GObject *container, - GObject *child, - const gchar *property_name, - GValue *value) -{ - GladeSupportedChild *support; - - if ((support = - glade_widget_class_get_child_support (class, G_OBJECT_TYPE (child))) != NULL) - { - if (support->get_property) - support->get_property (container, child, - property_name, value); - else - g_warning ("No get_property support for type %s in %s", - g_type_name (support->type), class->name); - } - else - g_warning ("No support for type %s in %s", - g_type_name (G_OBJECT_TYPE (child)), - class->name); -} - -void -glade_widget_class_container_replace_child (GladeWidgetClass *class, - GObject *container, - GObject *old, - GObject *new) -{ - GladeSupportedChild *support; - - if ((support = - glade_widget_class_get_child_support (class, G_OBJECT_TYPE (old))) != NULL) - { - if (support->replace_child) - support->replace_child (container, old, new); - else - g_warning ("No replace_child support for type %s in %s", - g_type_name (support->type), class->name); - } - else - g_warning ("No support for type %s in %s", - g_type_name (G_OBJECT_TYPE (old)), class->name); -} - -gboolean -glade_widget_class_contains_extra (GladeWidgetClass *class) -{ - GList *list; - for (list = class->children; list && list->data; list = list->next) - { - GladeSupportedChild *support = list->data; - if (support->type != GTK_TYPE_WIDGET) - return TRUE; - } - return FALSE; -} - -static GladeChildPacking * -glade_widget_class_get_child_packing (GladeWidgetClass *child_class, - GladeWidgetClass *parent_class) -{ - GList *l; - - for (l = child_class->child_packings; l; l = l->next) - { - GladeChildPacking *packing; - - packing = (GladeChildPacking *) l->data; - - if (strcmp (packing->parent_name, parent_class->name) == 0) - return packing; - } - - return NULL; -} - -static GladePackingDefault * -glade_widget_class_get_packing_default_internal (GladeChildPacking *packing, - const gchar *id) -{ - GList *l; - - for (l = packing->packing_defaults; l; l = l->next) - { - GladePackingDefault *def; - - def = (GladePackingDefault *) l->data; - - if (strcmp (def->id, id) == 0) - return def; - } - - return NULL; -} - -GladePackingDefault * -glade_widget_class_get_packing_default (GladeWidgetClass *child_class, - GladeWidgetClass *container_class, - const gchar *id) -{ - GladeChildPacking *packing = NULL; - GladeWidgetClass *p_class; - GType p_type; - - p_type = container_class->type; - p_class = container_class; - while (p_class) - { - GType old_p_type; - - packing = glade_widget_class_get_child_packing (child_class, - p_class); - if (packing) - { - GladePackingDefault *def; - - def = glade_widget_class_get_packing_default_internal (packing, id); - if (def) - return def; - } - - old_p_type = p_type; - p_type = g_type_parent (p_type); - - if (!p_type) - break; - - p_class = glade_widget_class_get_by_type (p_type); - } - - return NULL; -} - -/** - * glade_widget_class_query: - * @class: A #GladeWidgetClass - * - * Returns: whether the user needs to be queried for - * certain properties upon creation of this class. - */ -gboolean -glade_widget_class_query (GladeWidgetClass *class) -{ - GladePropertyClass *pclass; - GList *l; - - for (l = class->properties; l; l = l->next) - { - pclass = l->data; - - if (pclass->query) - return TRUE; - } - - return FALSE; -} - -/** - * glade_widget_class_create_widget: - * @class: a #GladeWidgetClass - * @query: whether to display query dialogs if - * applicable to the class - * @...: a %NULL terminated list of string/value pairs of #GladeWidget - * properties - * - * - * This factory function returns a new #GladeWidget of the correct type/class - * with the properties defined in @... and queries the user if nescisary. - * - * The resulting object will have all default properties applied to it - * including the overrides specified in the catalog, unless the catalog - * has specified 'ignore' for that property. - * - * Note that the widget class must be fed twice; once as the - * leading arg... and also as the property for the #GladeWidget - * - * this macro returns the newly created #GladeWidget - */ -GladeWidget * -glade_widget_class_create_widget_real (gboolean query, - const gchar *first_property, - ...) -{ - GladeWidgetClass *widget_class; - GType gwidget_type; - GladeWidget *gwidget; - va_list vl, vl_copy; - - g_return_val_if_fail (strcmp (first_property, "class") == 0, NULL); - - va_start (vl, first_property); - va_copy (vl_copy, vl); - - widget_class = va_arg (vl, GladeWidgetClass *); - - va_end (vl); - - if (GLADE_IS_WIDGET_CLASS (widget_class) == FALSE) - { - g_critical ("No class found in glade_widget_class_create_widget_real args"); - va_end (vl_copy); - return NULL; - } - - if (widget_class->fixed) - gwidget_type = GLADE_TYPE_FIXED; - else - gwidget_type = GLADE_TYPE_WIDGET; - - - gwidget = (GladeWidget *)g_object_new_valist (gwidget_type, - first_property, - vl_copy); - va_end (vl_copy); - - if (query && glade_widget_class_query (widget_class)) - { - GladeEditor *editor = glade_app_get_editor (); - - /* If user pressed cancel on query popup. */ - if (!glade_editor_query_dialog (editor, gwidget)) - { - g_object_unref (G_OBJECT (gwidget)); - return NULL; - } - } - - return gwidget; -} - - - -/** - * glade_widget_class_create_internal: - * @parent: The parent #GladeWidget, or %NULL for children - * outside of the hierarchy. - * @internal_object: the #GObject - * @internal_name: a string identifier for this internal widget. - * @anarchist: Whether or not this widget is a widget outside - * of the parent's hierarchy (like a popup window) - * @reason: The #GladeCreateReason for which this internal widget - * was created (usually just pass the reason from the post_create - * function; note also this is used only by the plugin code so - * pass something usefull here). - * - * A convenienve function to create a #GladeWidget of the prescribed type - * for internal widgets. - * - * Returns: a freshly created #GladeWidget wrapper object for the - * @internal_object of name @internal_name - */ -GladeWidget * -glade_widget_class_create_internal (GladeWidget *parent, - GObject *internal_object, - const gchar *internal_name, - const gchar *parent_name, - gboolean anarchist, - GladeCreateReason reason) -{ - GladeWidgetClass *class; - GladeProject *project; - - g_return_val_if_fail (GLADE_IS_WIDGET (parent), NULL); - project = glade_widget_get_project (parent); - - if ((class = glade_widget_class_get_by_name - (G_OBJECT_TYPE_NAME (internal_object))) == NULL) - { - g_critical ("Unable to find widget class for type %s", - G_OBJECT_TYPE_NAME (internal_object)); - return NULL; - } - - return glade_widget_class_create_widget (class, FALSE, - "anarchist", anarchist, - "parent", parent, - "project", project, - "internal", internal_name, - "internal-name", parent_name, - "reason", reason, - "object", internal_object, - NULL); -} diff --git a/src/glade-widget-class.h b/src/glade-widget-class.h deleted file mode 100644 index 26fb864d..00000000 --- a/src/glade-widget-class.h +++ /dev/null @@ -1,366 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef __GLADE_WIDGET_CLASS_H__ -#define __GLADE_WIDGET_CLASS_H__ - -#include <glib-object.h> -#include <gmodule.h> -#include <gtk/gtk.h> -#include "glade-xml-utils.h" -#include "glade-property-class.h" - -G_BEGIN_DECLS - -#define GLADE_WIDGET_CLASS(gwc) ((GladeWidgetClass *) gwc) -#define GLADE_IS_WIDGET_CLASS(gwc) (gwc != NULL) -#define GLADE_VALID_CREATE_REASON(reason) (reason >= 0 && reason < GLADE_CREATE_REASONS) - -typedef struct _GladeWidgetClass GladeWidgetClass; -typedef struct _GladeSupportedChild GladeSupportedChild; -typedef struct _GladeSignalClass GladeSignalClass; - - -/** - * GladeCreateReason: - * @GLADE_CREATE_USER: Was created at the user's request - * (this is a good time to set any properties - * or add children to the project; like GtkFrame's - * label for example). - * @GLADE_CREATE_COPY: Was created as a result of the copy/paste - * mechanism, at this point you can count on glade - * to follow up with properties and children on - * its own. - * @GLADE_CREATE_LOAD: Was created during the load process. - * @GLADE_CREATE_REBUILD: Was created as a replacement for another project - * object; this only happens when the user is - * changing a property that is marked by the type - * system as G_PARAM_SPEC_CONSTRUCT_ONLY. - * @GLADE_CREATE_REASONS: Never used. - * - * These are the reasons your #GladePostCreateFunc can be called. - */ -typedef enum _GladeCreateReason -{ - GLADE_CREATE_USER = 0, - GLADE_CREATE_COPY, - GLADE_CREATE_LOAD, - GLADE_CREATE_REBUILD, - GLADE_CREATE_REASONS -} GladeCreateReason; - -/** - * GladeChildSetPropertyFunc: - * @container: A #GObject container - * @child: The #GObject child - * @property_name: The property name - * @value: The #GValue - * - * Called to set the packing property @property_name to @value - * on the @child object of @container. - */ -typedef void (* GladeChildSetPropertyFunc) (GObject *container, - GObject *child, - const gchar *property_name, - const GValue *value); - -/** - * GladeChildGetPropertyFunc: - * @container: A #GObject container - * @child: The #GObject child - * @property_name: The property name - * @value: The #GValue - * - * Called to get the packing property @property_name - * on the @child object of @container into @value. - */ -typedef void (* GladeChildGetPropertyFunc) (GObject *container, - GObject *child, - const gchar *property_name, - GValue *value); - - -/** - * GladeGetChildrenFunc: - * @container: A #GObject container - * @Returns: A #GList of #GObject children. - * - * A function called to get @containers children. - */ -typedef GList *(* GladeGetChildrenFunc) (GObject *container); - -/** - * GladeAddChildFunc: - * @parent: A #GObject container - * @child: A #GObject child - * - * Called to add @child to @parent. - */ -typedef void (* GladeAddChildFunc) (GObject *parent, - GObject *child); -/** - * GladeRemoveChildFunc: - * @parent: A #GObject container - * @child: A #GObject child - * - * Called to remove @child from @parent. - */ -typedef void (* GladeRemoveChildFunc) (GObject *parent, - GObject *child); - -/** - * GladeReplaceChildFunc: - * @container: A #GObject container - * @old: The old #GObject child - * @new: The new #GObject child to take its place - * - * Called to swap placeholders with project objects - * in containers. - */ -typedef void (* GladeReplaceChildFunc) (GObject *container, - GObject *old, - GObject *new); - -/** - * GladePostCreateFunc: - * @object: a #GObject - * @reason: a #GladeCreateReason - * - * This function is called exactly once for any project object - * instance and can be for any #GladeCreateReason. - */ -typedef void (* GladePostCreateFunc) (GObject *object, - GladeCreateReason reason); - -/** - * GladeGetInternalFunc: - * @parent: A #GObject composite object - * @name: A string identifier - * @child: A return location for a #GObject - * - * Called to lookup @child in composite object @parent by @name. - */ -typedef void (* GladeGetInternalFunc) (GObject *parent, - const gchar *name, - GObject **child); - - -/** - * GladeEditorLaunchFunc: - * @object: A #GObject - * - * Called to launch a custom editor for @object - */ -typedef void (* GladeEditorLaunchFunc) (GObject *object); - - -/* GladeWidgetClass contains all the information we need regarding an widget - * type. It is also used to store information that has been loaded to memory - * for that object like the icon/mask. - */ -struct _GladeWidgetClass -{ - GType type; /* GType of the widget */ - - gchar *name; /* Name of the widget, for example GtkButton */ - - gchar *catalog; /* The name of the widget catalog this class - * was declared by. - */ - - gchar *book; /* Devhelp search namespace - */ - - GdkPixbuf *large_icon; /* The 22x22 icon for the widget */ - - GdkPixbuf *small_icon; /* The 16x16 icon for the widget */ - - - GdkCursor *cursor; /* a cursor for inserting widgets */ - - - gboolean fixed; /* If this is a GtkContainer, use free-form - * placement with drag/resize/paste at mouse... - */ - - gchar *generic_name; /* Use to generate names of new widgets, for - * example "button" so that we generate button1, - * button2, buttonX .. - */ - - gchar *palette_name; /* Name used in the palette */ - - GList *properties; /* List of GladePropertyClass objects. - * [see glade-property.h ] this list contains - * properties about the widget that we are going - * to modify. Like "title", "label", "rows" . - * Each property creates an input in the propety - * editor. - */ - - GList *signals; /* List of GladeSignalClass objects */ - - - GList *children; /* List of GladeSupportedChild objects */ - - GList *child_packings; /* Default packing property values */ - - GModule *module; /* Module with the (optional) special functions - * needed for placeholder_replace, post_create_function - * and the set & get functions of the properties - * of this class. - */ - - gboolean toplevel; /* If this class is toplevel */ - - /* Executed after widget creation: it takes care of creating the - * GladeWidgets associated with internal children. It's also the place - * to set sane defaults, e.g. set the size of a window. - */ - GladePostCreateFunc post_create_function; - - /* Retrieves the the internal child of the given name. - */ - GladeGetInternalFunc get_internal_child; - - /* Entry point for custom editors. - */ - GladeEditorLaunchFunc launch_editor; -}; - -struct _GladeSupportedChild -{ - GType type; /* This supported child type */ - - GList *properties; /* List of GladePropertyClass objects representing - * child_properties of a container (the list is empty if - * this container has no child_properties) - * Note that the actual GladeProperty corresponding to - * each class end up in the packing_properties list of - * each _child_ of the container and thus are edited - * when the _child_ is selected. - */ - - GladeAddChildFunc add; /* Adds a new child of this type */ - GladeRemoveChildFunc remove; /* Removes a child from the container */ - GladeGetChildrenFunc get_children; /* Returns a list of direct children for - * this support type. - */ - - GladeChildSetPropertyFunc set_property; /* Sets/Gets a packing property */ - GladeChildGetPropertyFunc get_property; /* for this child */ - - GladeReplaceChildFunc replace_child; /* This method replaces a - * child widget with - * another one: it's used to - * replace a placeholder with - * a widget and viceversa. - */ - - gchar *special_child_type; /* Special case code for children that - * are special children (like notebook tab - * widgets for example). - */ -}; - - -/* GladeSignalClass contains all the info we need for a given signal, such as - * the signal name, and maybe more in the future - */ -struct _GladeSignalClass -{ - GSignalQuery query; - - const gchar *name; /* Name of the signal, eg clicked */ - gchar *type; /* Name of the object class that this signal belongs to - * eg GtkButton */ - -}; - -#define glade_widget_class_create_widget(class, query, ...) \ - (glade_widget_class_create_widget_real (query, "class", class, __VA_ARGS__)); - -LIBGLADEUI_API -GladeWidgetClass *glade_widget_class_new (GladeXmlNode *class_node, - const gchar *catname, - const gchar *library, - const gchar *domain, - const gchar *book); -LIBGLADEUI_API -GladeWidget *glade_widget_class_create_internal (GladeWidget *parent, - GObject *internal_object, - const gchar *internal_name, - const gchar *parent_name, - gboolean anarchist, - GladeCreateReason reason); -LIBGLADEUI_API -GladeWidget *glade_widget_class_create_widget_real (gboolean query, - const gchar *first_property, - ...); -LIBGLADEUI_API -void glade_widget_class_free (GladeWidgetClass *widget_class); -LIBGLADEUI_API -GladeWidgetClass *glade_widget_class_get_by_name (const char *name); -LIBGLADEUI_API -GladeWidgetClass *glade_widget_class_get_by_type (GType type); -LIBGLADEUI_API -GList *glade_widget_class_get_derived_types (GType type); -LIBGLADEUI_API -GType glade_widget_class_get_type (GladeWidgetClass *class); -LIBGLADEUI_API -void glade_widget_class_dump_param_specs (GladeWidgetClass *class); -LIBGLADEUI_API -GladePropertyClass *glade_widget_class_get_property_class (GladeWidgetClass *class, - const gchar *name); -LIBGLADEUI_API -GladeSupportedChild *glade_widget_class_get_child_support (GladeWidgetClass *class, - GType child_type); -LIBGLADEUI_API -GParameter *glade_widget_class_default_params (GladeWidgetClass *class, - gboolean construct, - guint *n_params); -LIBGLADEUI_API -void glade_widget_class_container_add (GladeWidgetClass *class, - GObject *container, - GObject *child); -LIBGLADEUI_API -void glade_widget_class_container_remove (GladeWidgetClass *class, - GObject *container, - GObject *child); -LIBGLADEUI_API -gboolean glade_widget_class_container_has_child (GladeWidgetClass *class, - GObject *container, - GObject *child); -LIBGLADEUI_API -GList *glade_widget_class_container_get_children (GladeWidgetClass *class, - GObject *container); -LIBGLADEUI_API -void glade_widget_class_container_set_property (GladeWidgetClass *class, - GObject *container, - GObject *child, - const gchar *property_name, - const GValue *value); -LIBGLADEUI_API -void glade_widget_class_container_get_property (GladeWidgetClass *class, - GObject *container, - GObject *child, - const gchar *property_name, - GValue *value); -LIBGLADEUI_API -void glade_widget_class_container_replace_child (GladeWidgetClass *class, - GObject *container, - GObject *old, - GObject *new); -LIBGLADEUI_API -gboolean glade_widget_class_contains_extra (GladeWidgetClass *class); -LIBGLADEUI_API -gboolean glade_widget_class_query (GladeWidgetClass *class); -LIBGLADEUI_API -GladePackingDefault *glade_widget_class_get_packing_default (GladeWidgetClass *child_class, - GladeWidgetClass *container_class, - const gchar *propert_id); - -#define glade_widget_class_from_pclass(pclass) \ - ((pclass) ? (GladeWidgetClass *)((GladePropertyClass *)(pclass))->handle : NULL) - -G_END_DECLS - -#endif /* __GLADE_WIDGET_CLASS_H__ */ diff --git a/src/glade-widget.c b/src/glade-widget.c index 65273e9d..5d048ece 100644 --- a/src/glade-widget.c +++ b/src/glade-widget.c @@ -34,7 +34,7 @@ #include "glade.h" #include "glade-accumulators.h" #include "glade-project.h" -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" #include "glade-widget.h" #include "glade-marshallers.h" #include "glade-property.h" @@ -46,11 +46,11 @@ #include "glade-app.h" -static void glade_widget_set_class (GladeWidget *widget, - GladeWidgetClass *klass); +static void glade_widget_set_adaptor (GladeWidget *widget, + GladeWidgetAdaptor *adaptor); static void glade_widget_set_properties (GladeWidget *widget, GList *properties); -static GParameter *glade_widget_info_params (GladeWidgetClass *widget_class, +static GParameter *glade_widget_info_params (GladeWidgetAdaptor *adaptor, GladeWidgetInfo *info, gboolean construct, guint *n_params); @@ -80,7 +80,7 @@ enum PROP_INTERNAL, PROP_ANARCHIST, PROP_OBJECT, - PROP_CLASS, + PROP_ADAPTOR, PROP_PROJECT, PROP_PROPERTIES, PROP_PARENT, @@ -118,8 +118,8 @@ glade_widget_add_child_impl (GladeWidget *widget, */ glade_widget_set_parent (child, widget); - glade_widget_class_container_add - (widget->widget_class, widget->object, child->object); + glade_widget_adaptor_add + (widget->adaptor, widget->object, child->object); glade_widget_set_packing_properties (child, widget); } @@ -128,8 +128,8 @@ static void glade_widget_remove_child_impl (GladeWidget *widget, GladeWidget *child) { - glade_widget_class_container_remove - (widget->widget_class, widget->object, child->object); + glade_widget_adaptor_remove + (widget->adaptor, widget->object, child->object); } static void @@ -151,8 +151,8 @@ glade_widget_replace_child_impl (GladeWidget *widget, glade_widget_set_packing_properties (gnew_widget, widget); - glade_widget_class_container_replace_child - (widget->widget_class, widget->object, + glade_widget_adaptor_replace_child + (widget->adaptor, widget->object, old_object, new_object); /* Setup packing properties here again so we can introspect the new @@ -518,7 +518,7 @@ glade_widget_event_private (GtkWidget *widget, /* Run the real class handler now. */ - handled = GLADE_WIDGET_GET_KLASS (gwidget)->event (widget, event, gwidget); + handled = GLADE_WIDGET_GET_CLASS (gwidget)->event (widget, event, gwidget); #if 0 if (event->type != GDK_EXPOSE) @@ -535,7 +535,7 @@ glade_widget_event_private (GtkWidget *widget, /* * This function creates new GObject parameters based on the GType of the - * GladeWidgetClass and its default values. + * GladeWidgetAdaptor and its default values. * * If a GladeWidget is specified, it will be used to apply the * values currently in use. @@ -545,7 +545,7 @@ glade_widget_template_params (GladeWidget *widget, gboolean construct, guint *n_params) { - GladeWidgetClass *klass; + GladeWidgetAdaptor *klass; GArray *params; GObjectClass *oclass; GParamSpec **pspec; @@ -556,7 +556,7 @@ glade_widget_template_params (GladeWidget *widget, g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL); g_return_val_if_fail (n_params != NULL, NULL); - klass = widget->widget_class; + klass = widget->adaptor; /* As a slight optimization, we never unref the class */ @@ -628,7 +628,7 @@ free_params (GParameter *params, guint n_params) } static GObject * -glade_widget_build_object (GladeWidgetClass *klass, GladeWidget *widget, GladeWidgetInfo *info) +glade_widget_build_object (GladeWidgetAdaptor *adaptor, GladeWidget *widget, GladeWidgetInfo *info) { GParameter *params; GObject *object; @@ -637,22 +637,22 @@ glade_widget_build_object (GladeWidgetClass *klass, GladeWidget *widget, GladeWi if (widget) params = glade_widget_template_params (widget, TRUE, &n_params); else if (info) - params = glade_widget_info_params (klass, info, TRUE, &n_params); + params = glade_widget_info_params (adaptor, info, TRUE, &n_params); else - params = glade_widget_class_default_params (klass, TRUE, &n_params); + params = glade_widget_adaptor_default_params (adaptor, TRUE, &n_params); /* Create the new object with the correct parameters. */ - object = g_object_newv (klass->type, n_params, params); + object = g_object_newv (adaptor->type, n_params, params); free_params (params, n_params); if (widget) params = glade_widget_template_params (widget, FALSE, &n_params); else if (info) - params = glade_widget_info_params (klass, info, FALSE, &n_params); + params = glade_widget_info_params (adaptor, info, FALSE, &n_params); else - params = glade_widget_class_default_params (klass, FALSE, &n_params); + params = glade_widget_adaptor_default_params (adaptor, FALSE, &n_params); for (i = 0; i < n_params; i++) { @@ -782,10 +782,10 @@ glade_widget_constructor (GType type, else if (gwidget->project) gwidget->name = glade_project_new_widget_name (GLADE_PROJECT (gwidget->project), - gwidget->widget_class->generic_name); + gwidget->adaptor->generic_name); else gwidget->name = - g_strdup (gwidget->widget_class->generic_name); + g_strdup (gwidget->adaptor->generic_name); } if (gwidget->construct_template) @@ -798,7 +798,7 @@ glade_widget_constructor (GType type, if (gwidget->object == NULL) { - object = glade_widget_build_object(gwidget->widget_class, + object = glade_widget_build_object(gwidget->adaptor, gwidget->construct_template, gwidget->construct_info); glade_widget_set_object (gwidget, object); @@ -816,9 +816,9 @@ glade_widget_constructor (GType type, /* Only call this once the GladeWidget is completely built * (but before calling custom handlers...) */ - if (gwidget->widget_class->post_create_function) - gwidget->widget_class->post_create_function - (gwidget->object, gwidget->construct_reason); + glade_widget_adaptor_post_create (gwidget->adaptor, + gwidget->object, + gwidget->construct_reason); /* Properties that have custom set_functions on them need to be * explicitly synchronized. @@ -910,9 +910,9 @@ glade_widget_set_real_property (GObject *object, case PROP_PROJECT: glade_widget_set_project (widget, GLADE_PROJECT (g_value_get_object (value))); break; - case PROP_CLASS: - glade_widget_set_class (widget, GLADE_WIDGET_CLASS - (g_value_get_pointer (value))); + case PROP_ADAPTOR: + glade_widget_set_adaptor (widget, GLADE_WIDGET_ADAPTOR + (g_value_get_object (value))); break; case PROP_PROPERTIES: glade_widget_set_properties (widget, (GList *)g_value_get_pointer (value)); @@ -960,8 +960,8 @@ glade_widget_get_real_property (GObject *object, case PROP_ANARCHIST: g_value_set_boolean (value, widget->anarchist); break; - case PROP_CLASS: - g_value_set_pointer (value, widget->widget_class); + case PROP_ADAPTOR: + g_value_set_object (value, widget->adaptor); break; case PROP_PROJECT: g_value_set_object (value, G_OBJECT (widget->project)); @@ -1003,7 +1003,7 @@ free_signals (gpointer value) static void glade_widget_init (GladeWidget *widget) { - widget->widget_class = NULL; + widget->adaptor = NULL; widget->project = NULL; widget->name = NULL; widget->internal = NULL; @@ -1019,7 +1019,7 @@ glade_widget_init (GladeWidget *widget) } static void -glade_widget_class_init (GladeWidgetKlass *klass) +glade_widget_class_init (GladeWidgetClass *klass) { GObjectClass *object_class; @@ -1083,12 +1083,12 @@ glade_widget_class_init (GladeWidgetKlass *klass) G_PARAM_CONSTRUCT)); g_object_class_install_property - (object_class, PROP_CLASS, - g_param_spec_pointer ("class", _("Class"), - _("The class of the associated" - " gtk+ widget"), - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); + (object_class, PROP_ADAPTOR, + g_param_spec_object ("adaptor", _("Adaptor"), + _("The class adaptor for the associated widget"), + GLADE_TYPE_WIDGET_ADAPTOR, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_PROJECT, @@ -1151,7 +1151,7 @@ glade_widget_class_init (GladeWidgetKlass *klass) g_signal_new ("add-signal-handler", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GladeWidgetKlass, add_signal_handler), + G_STRUCT_OFFSET (GladeWidgetClass, add_signal_handler), NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, @@ -1167,7 +1167,7 @@ glade_widget_class_init (GladeWidgetKlass *klass) g_signal_new ("remove-signal-handler", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GladeWidgetKlass, remove_signal_handler), + G_STRUCT_OFFSET (GladeWidgetClass, remove_signal_handler), NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, @@ -1185,7 +1185,7 @@ glade_widget_class_init (GladeWidgetKlass *klass) g_signal_new ("change-signal-handler", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GladeWidgetKlass, change_signal_handler), + G_STRUCT_OFFSET (GladeWidgetClass, change_signal_handler), NULL, NULL, glade_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, @@ -1202,7 +1202,7 @@ glade_widget_class_init (GladeWidgetKlass *klass) g_signal_new ("button-press-event", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GladeWidgetKlass, button_press_event), + G_STRUCT_OFFSET (GladeWidgetClass, button_press_event), glade_boolean_handled_accumulator, NULL, glade_marshal_BOOLEAN__BOXED, G_TYPE_BOOLEAN, 1, @@ -1217,7 +1217,7 @@ glade_widget_class_init (GladeWidgetKlass *klass) g_signal_new ("button-release-event", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GladeWidgetKlass, button_release_event), + G_STRUCT_OFFSET (GladeWidgetClass, button_release_event), glade_boolean_handled_accumulator, NULL, glade_marshal_BOOLEAN__BOXED, G_TYPE_BOOLEAN, 1, @@ -1233,7 +1233,7 @@ glade_widget_class_init (GladeWidgetKlass *klass) g_signal_new ("motion-notify-event", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GladeWidgetKlass, motion_notify_event), + G_STRUCT_OFFSET (GladeWidgetClass, motion_notify_event), glade_boolean_handled_accumulator, NULL, glade_marshal_BOOLEAN__BOXED, G_TYPE_BOOLEAN, 1, @@ -1249,7 +1249,7 @@ glade_widget_class_init (GladeWidgetKlass *klass) g_signal_new ("enter-notify-event", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GladeWidgetKlass, enter_notify_event), + G_STRUCT_OFFSET (GladeWidgetClass, enter_notify_event), glade_boolean_handled_accumulator, NULL, glade_marshal_BOOLEAN__BOXED, G_TYPE_BOOLEAN, 1, @@ -1265,7 +1265,7 @@ glade_widget_get_type (void) { static const GTypeInfo widget_info = { - sizeof (GladeWidgetKlass), + sizeof (GladeWidgetClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc) glade_widget_class_init, @@ -1311,43 +1311,32 @@ static void glade_widget_set_default_packing_properties (GladeWidget *container, GladeWidget *child) { - GladeSupportedChild *support; - - support = glade_widget_class_get_child_support (container->widget_class, - child->widget_class->type); - - if (support) { - GladePropertyClass *property_class; - GList *l; - - for (l = support->properties; l; l = l->next) - { - GladePackingDefault *def; - GValue *value; - - property_class = l->data; - - def = glade_widget_class_get_packing_default (child->widget_class, - container->widget_class, - property_class->id); - - if (!def) - continue; + GladePropertyClass *property_class; + GList *l; - /* Check value type */ - value = glade_property_class_make_gvalue_from_string (property_class, - def->value, - child->project); + for (l = container->adaptor->packing_props; l; l = l->next) + { + const gchar *def; + GValue *value; - glade_widget_class_container_set_property (container->widget_class, - container->object, - child->object, - property_class->id, - value); + property_class = l->data; - g_value_unset (value); - g_free (value); - } + if ((def = + glade_widget_adaptor_get_packing_default + (child->adaptor, container->adaptor, property_class->id)) == NULL) + continue; + + value = glade_property_class_make_gvalue_from_string (property_class, + def, + child->project); + + glade_widget_adaptor_child_set_property (container->adaptor, + container->object, + child->object, + property_class->id, + value); + g_value_unset (value); + g_free (value); } } @@ -1360,14 +1349,13 @@ glade_widget_get_internal_child (GladeWidget *parent, { while (parent) { - if (parent->widget_class->get_internal_child) - { - GObject *object; - parent->widget_class->get_internal_child (parent->object, - internal, - &object); - return object; - } + GladeWidgetAdaptorClass *adaptor_class = + GLADE_WIDGET_ADAPTOR_GET_CLASS (parent->adaptor); + + if (adaptor_class->get_internal_child) + return glade_widget_adaptor_get_internal_child + (parent->adaptor, parent->object, internal); + parent = glade_widget_get_parent (parent); } return NULL; @@ -1380,18 +1368,20 @@ glade_widget_get_internal_func (GladeWidget *parent, GladeWidget **parent_ret) g_return_val_if_fail (GLADE_IS_WIDGET (parent), NULL); - gwidget = parent; - while (gwidget && gwidget->widget_class->get_internal_child == NULL) - gwidget = gwidget->parent; - - if (gwidget && gwidget->widget_class->get_internal_child) + for (gwidget = parent; gwidget; gwidget = gwidget->parent) { - if (parent_ret) *parent_ret = gwidget; - return gwidget->widget_class->get_internal_child; + GladeWidgetAdaptorClass *adaptor_class = + GLADE_WIDGET_ADAPTOR_GET_CLASS (gwidget->adaptor); + + if (adaptor_class->get_internal_child) + { + if (parent_ret) *parent_ret = gwidget; + return adaptor_class->get_internal_child; + } } g_error ("No internal child search function " "provided for widget class %s (or any parents)", - parent->widget_class->name); + parent->adaptor->name); return NULL; } @@ -1422,7 +1412,9 @@ glade_widget_dup_internal (GladeWidget *parent, GladeWidget *template) * the "parent" that has `get_internal_child' support (i.e. internal children * may have depth). */ - get_internal (internal_parent->object, template->internal, &internal_object); + internal_object = get_internal (internal_parent->adaptor, + internal_parent->object, + template->internal); g_assert (internal_object); gwidget = glade_widget_get_from_gobject (internal_object); @@ -1432,8 +1424,8 @@ glade_widget_dup_internal (GladeWidget *parent, GladeWidget *template) else { gchar *name = glade_project_new_widget_name (template->project, template->name); - gwidget = glade_widget_class_create_widget - (template->widget_class, FALSE, + gwidget = glade_widget_adaptor_create_widget + (template->adaptor, FALSE, "name", name, "parent", parent, "project", template->project, @@ -1443,8 +1435,8 @@ glade_widget_dup_internal (GladeWidget *parent, GladeWidget *template) } if ((children = - glade_widget_class_container_get_children (template->widget_class, - template->object)) != NULL) + glade_widget_adaptor_get_children (template->adaptor, + template->object)) != NULL) { for (list = children; list && list->data; list = list->next) { @@ -1466,10 +1458,9 @@ glade_widget_dup_internal (GladeWidget *parent, GladeWidget *template) g_strdup (child_type), g_free); - glade_widget_class_container_add - (gwidget->widget_class, - gwidget->object, - G_OBJECT (placeholder)); + glade_widget_adaptor_add (gwidget->adaptor, + gwidget->object, + G_OBJECT (placeholder)); } } else @@ -1491,9 +1482,9 @@ glade_widget_dup_internal (GladeWidget *parent, GladeWidget *template) * need to avoid copying these packing props (like popup windows * created on behalf of composite widgets). */ - if (glade_widget_class_container_has_child (gwidget->widget_class, - gwidget->object, - child_dup->object)) + if (glade_widget_adaptor_has_child (gwidget->adaptor, + gwidget->object, + child_dup->object)) glade_widget_copy_packing_props (gwidget, child_dup, child_gwidget); @@ -1547,8 +1538,8 @@ glade_widget_extract_children (GladeWidget *gwidget) GList *extract_list = NULL; GList *children, *list; - children = glade_widget_class_container_get_children - (gwidget->widget_class, gwidget->object); + children = glade_widget_adaptor_get_children + (gwidget->adaptor, gwidget->object); for (list = children; list && list->data; list = list->next) { @@ -1594,9 +1585,8 @@ glade_widget_extract_children (GladeWidget *gwidget) { /* need to handle placeholders by hand here */ extract->placeholder = g_object_ref (child); - glade_widget_class_container_remove - (gwidget->widget_class, - gwidget->object, child); + glade_widget_adaptor_remove (gwidget->adaptor, + gwidget->object, child); } extract_list = g_list_prepend (extract_list, extract); @@ -1633,9 +1623,9 @@ glade_widget_insert_children (GladeWidget *gwidget, GList *children) get_internal = glade_widget_get_internal_func (gwidget, &internal_parent); - get_internal (internal_parent->object, - extract->internal_name, - &internal_object); + internal_object = get_internal (internal_parent->adaptor, + internal_parent->object, + extract->internal_name); gchild = glade_widget_get_from_gobject (internal_object); @@ -1689,10 +1679,9 @@ glade_widget_insert_children (GladeWidget *gwidget, GList *children) } else { - glade_widget_class_container_add - (gwidget->widget_class, - gwidget->object, - G_OBJECT (extract->placeholder)); + glade_widget_adaptor_add (gwidget->adaptor, + gwidget->object, + G_OBJECT (extract->placeholder)); g_object_unref (extract->placeholder); } g_free (extract); @@ -1727,24 +1716,24 @@ glade_widget_set_properties (GladeWidget *widget, GList *properties) } static void -glade_widget_set_class (GladeWidget *widget, GladeWidgetClass *klass) +glade_widget_set_adaptor (GladeWidget *widget, GladeWidgetAdaptor *adaptor) { GladePropertyClass *property_class; GladeProperty *property; GList *list; g_return_if_fail (GLADE_IS_WIDGET (widget)); - g_return_if_fail (GLADE_IS_WIDGET_CLASS (klass)); + g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor)); /* calling set_class out of the constructor? */ - g_return_if_fail (widget->widget_class == NULL); + g_return_if_fail (widget->adaptor == NULL); - widget->widget_class = klass; + widget->adaptor = adaptor; /* If we have no properties; we are not in the process of loading */ if (!widget->properties) { - for (list = klass->properties; list; list = list->next) + for (list = adaptor->properties; list; list = list->next) { property_class = GLADE_PROPERTY_CLASS(list->data); if ((property = glade_property_new (property_class, @@ -1793,7 +1782,7 @@ glade_widget_connect_signal_handlers (GtkWidget *widget_gtk, { for (list = children; list; list = list->next) { - GLADE_WIDGET_GET_KLASS (gwidget)->setup_events + GLADE_WIDGET_GET_CLASS (gwidget)->setup_events (gwidget, GTK_WIDGET (list->data)); glade_widget_connect_signal_handlers @@ -1811,22 +1800,21 @@ glade_widget_connect_signal_handlers (GtkWidget *widget_gtk, static GList * glade_widget_create_packing_properties (GladeWidget *container, GladeWidget *widget) { - GladeSupportedChild *support; GladePropertyClass *property_class; GladeProperty *property; GList *list, *packing_props = NULL; - if ((support = - glade_widget_class_get_child_support - (container->widget_class, widget->widget_class->type)) != NULL) + /* XXX TODO: by checking with some GladePropertyClass metadata, decide + * which packing properties go on which type of children. + */ + for (list = container->adaptor->packing_props; + list && list->data; list = list->next) { - for (list = support->properties; list && list->data; list = list->next) - { - property_class = list->data; - property = glade_property_new - (property_class, widget, NULL, TRUE); - packing_props = g_list_prepend (packing_props, property); - } + property_class = list->data; + property = glade_property_new + (property_class, widget, NULL, TRUE); + packing_props = g_list_prepend (packing_props, property); + } return g_list_reverse (packing_props); } @@ -1835,24 +1823,25 @@ glade_widget_create_packing_properties (GladeWidget *container, GladeWidget *wid GladeInterface Parsing code *******************************************************************************/ static gint -glade_widget_set_child_type_from_child_info (GladeChildInfo *child_info, - GladeWidgetClass *parent_class, +glade_widget_set_child_type_from_child_info (GladeChildInfo *child_info, + GladeWidgetAdaptor *parent_adaptor, GObject *child) { - guint i; - GladePropInfo *prop_info; - GladeSupportedChild *support; + guint i; + GladePropInfo *prop_info; + gchar *special_child_type; + + g_object_get (parent_adaptor, "special-child-type", &special_child_type, NULL); - support = glade_widget_class_get_child_support (parent_class, - G_OBJECT_TYPE (child)); - if (!support || !support->special_child_type) + if (!special_child_type) return -1; for (i = 0; i < child_info->n_properties; ++i) { prop_info = child_info->properties + i; - if (!strcmp (prop_info->name, support->special_child_type)) + if (!strcmp (prop_info->name, special_child_type)) { + g_free (special_child_type); g_object_set_data_full (child, "special-child-type", g_strdup (prop_info->value), @@ -1860,6 +1849,7 @@ glade_widget_set_child_type_from_child_info (GladeChildInfo *child_info, return i; } } + g_free (special_child_type); return -1; } @@ -1879,10 +1869,10 @@ glade_widget_new_child_from_child_info (GladeChildInfo *info, { GObject *palaceholder = G_OBJECT (glade_placeholder_new ()); glade_widget_set_child_type_from_child_info - (info, parent->widget_class, palaceholder); - glade_widget_class_container_add (parent->widget_class, - parent->object, - palaceholder); + (info, parent->adaptor, palaceholder); + glade_widget_adaptor_add (parent->adaptor, + parent->object, + palaceholder); return TRUE; } @@ -1917,7 +1907,7 @@ glade_widget_new_child_from_child_info (GladeChildInfo *info, child->parent = parent; glade_widget_set_child_type_from_child_info - (info, parent->widget_class, child->object); + (info, parent->adaptor, child->object); glade_widget_add_child (parent, child, FALSE); @@ -1946,7 +1936,7 @@ glade_widget_fill_from_widget_info (GladeWidgetInfo *info, g_return_if_fail (GLADE_IS_WIDGET (widget)); g_return_if_fail (info != NULL); - g_assert (strcmp (info->classname, widget->widget_class->name) == 0); + g_assert (strcmp (info->classname, widget->adaptor->name) == 0); /* Children */ for (i = 0; i < info->n_children; ++i) @@ -1989,7 +1979,7 @@ glade_widget_fill_from_widget_info (GladeWidgetInfo *info, static GList * -glade_widget_properties_from_widget_info (GladeWidgetClass *class, +glade_widget_properties_from_widget_info (GladeWidgetAdaptor *class, GladeWidgetInfo *info) { GList *properties = NULL, *list; @@ -2018,23 +2008,23 @@ glade_widget_new_from_widget_info (GladeWidgetInfo *info, GladeProject *project, GladeWidget *parent) { - GladeWidgetClass *klass; - GladeWidget *widget; - GList *properties; + GladeWidgetAdaptor *adaptor; + GladeWidget *widget; + GList *properties; g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (project != NULL, NULL); - klass = glade_widget_class_get_by_name (info->classname); - if (!klass) + if ((adaptor = + glade_widget_adaptor_get_by_name (info->classname)) == NULL) { g_warning ("Widget class %s unknown.", info->classname); return NULL; } - properties = glade_widget_properties_from_widget_info (klass, info); - widget = glade_widget_class_create_widget - (klass, FALSE, + properties = glade_widget_properties_from_widget_info (adaptor, info); + widget = glade_widget_adaptor_create_widget + (adaptor, FALSE, "name", info->name, "parent", parent, "project", project, @@ -2059,10 +2049,10 @@ glade_widget_new_from_widget_info (GladeWidgetInfo *info, } static GParameter * -glade_widget_info_params (GladeWidgetClass *widget_class, - GladeWidgetInfo *info, - gboolean construct, - guint *n_params) +glade_widget_info_params (GladeWidgetAdaptor *adaptor, + GladeWidgetInfo *info, + gboolean construct, + guint *n_params) { GladePropertyClass *glade_property_class; GObjectClass *oclass; @@ -2070,7 +2060,7 @@ glade_widget_info_params (GladeWidgetClass *widget_class, GArray *params; guint i, n_props; - oclass = g_type_class_ref (widget_class->type); + oclass = g_type_class_ref (adaptor->type); pspec = g_object_class_list_properties (oclass, &n_props); params = g_array_new (FALSE, FALSE, sizeof (GParameter)); @@ -2081,8 +2071,8 @@ glade_widget_info_params (GladeWidgetClass *widget_class, GValue *value; glade_property_class = - glade_widget_class_get_property_class (widget_class, - pspec[i]->name); + glade_widget_adaptor_get_property_class (adaptor, + pspec[i]->name); if (glade_property_class == NULL || glade_property_class->set_function || glade_property_class->ignore) @@ -2367,7 +2357,7 @@ glade_widget_add_child (GladeWidget *parent, g_return_if_fail (GLADE_IS_WIDGET (parent)); g_return_if_fail (GLADE_IS_WIDGET (child)); - GLADE_WIDGET_GET_KLASS (parent)->add_child (parent, child, at_mouse); + GLADE_WIDGET_GET_CLASS (parent)->add_child (parent, child, at_mouse); } /** @@ -2384,7 +2374,7 @@ glade_widget_remove_child (GladeWidget *parent, g_return_if_fail (GLADE_IS_WIDGET (parent)); g_return_if_fail (GLADE_IS_WIDGET (child)); - GLADE_WIDGET_GET_KLASS (parent)->remove_child (parent, child); + GLADE_WIDGET_GET_CLASS (parent)->remove_child (parent, child); } /** @@ -2421,13 +2411,13 @@ glade_widget_dup (GladeWidget *template) void glade_widget_rebuild (GladeWidget *glade_widget) { - GObject *new_object, *old_object; - GladeWidgetClass *klass; - GList *children; + GObject *new_object, *old_object; + GladeWidgetAdaptor *adaptor; + GList *children; g_return_if_fail (GLADE_IS_WIDGET (glade_widget)); - klass = glade_widget->widget_class; + adaptor = glade_widget->adaptor; /* Save coordinates incase its a toplevel */ glade_widget_save_coords (glade_widget); @@ -2438,14 +2428,13 @@ glade_widget_rebuild (GladeWidget *glade_widget) /* Hold a reference to the old widget while we transport properties * and children from it */ - new_object = glade_widget_build_object(klass, glade_widget, NULL); + new_object = glade_widget_build_object(adaptor, glade_widget, NULL); old_object = g_object_ref(glade_widget_get_object(glade_widget)); glade_widget_set_object(glade_widget, new_object); /* Only call this once the object has a proper GladeWidget */ - if (klass->post_create_function) - klass->post_create_function (G_OBJECT(new_object), GLADE_CREATE_REBUILD); + glade_widget_adaptor_post_create (adaptor, new_object, GLADE_CREATE_REBUILD); /* Replace old object with new object in parent */ @@ -2469,7 +2458,7 @@ glade_widget_rebuild (GladeWidget *glade_widget) */ glade_widget_sync_packing_props (glade_widget); - if (g_type_is_a (klass->type, GTK_TYPE_WIDGET)) + if (g_type_is_a (adaptor->type, GTK_TYPE_WIDGET)) { /* Must use gtk_widget_destroy here for cases like dialogs and toplevels * (otherwise I'd prefer g_object_unref() ) @@ -2613,16 +2602,16 @@ glade_widget_get_internal (GladeWidget *widget) } /** - * glade_widget_get_class: + * glade_widget_get_adaptor: * @widget: a #GladeWidget * - * Returns: the #GladeWidgetclass of @widget + * Returns: the #GladeWidgetAdaptor of @widget */ -GladeWidgetClass * -glade_widget_get_class (GladeWidget *widget) +GladeWidgetAdaptor * +glade_widget_get_adaptor (GladeWidget *widget) { g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL); - return widget->widget_class; + return widget->adaptor; } /** @@ -3056,27 +3045,27 @@ glade_widget_pack_property_default (GladeWidget *widget, void glade_widget_set_object (GladeWidget *gwidget, GObject *new_object) { - GladeWidgetClass *klass; - GObject *old_object; + GladeWidgetAdaptor *adaptor; + GObject *old_object; g_return_if_fail (GLADE_IS_WIDGET (gwidget)); g_return_if_fail (G_IS_OBJECT (new_object)); g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (new_object), - gwidget->widget_class->type)); + gwidget->adaptor->type)); - klass = gwidget->widget_class; + adaptor = gwidget->adaptor; old_object = gwidget->object; /* Add internal reference to new widget */ gwidget->object = g_object_ref (G_OBJECT(new_object)); g_object_set_qdata (G_OBJECT (new_object), glade_widget_name_quark, gwidget); - if (g_type_is_a (gwidget->widget_class->type, GTK_TYPE_WIDGET)) + if (g_type_is_a (gwidget->adaptor->type, GTK_TYPE_WIDGET)) { /* Make sure dialogs and such have close buttons. */ - if (g_type_is_a (gwidget->widget_class->type, GTK_TYPE_WINDOW)) + if (g_type_is_a (gwidget->adaptor->type, GTK_TYPE_WINDOW)) gtk_window_set_decorated (GTK_WINDOW (new_object), TRUE); /* Disable any built-in DnD @@ -3086,7 +3075,7 @@ glade_widget_set_object (GladeWidget *gwidget, GObject *new_object) /* Take care of events and toolkit signals. */ - GLADE_WIDGET_GET_KLASS (gwidget)->setup_events + GLADE_WIDGET_GET_CLASS (gwidget)->setup_events (gwidget, GTK_WIDGET (new_object)); if (GTK_WIDGET_TOPLEVEL (new_object)) @@ -3158,11 +3147,11 @@ glade_widget_set_parent (GladeWidget *widget, * (a subsequent call should come from glade_command after parenting). */ if (widget->object && parent != NULL && - glade_widget_class_container_has_child - (parent->widget_class, parent->object, widget->object)) + glade_widget_adaptor_has_child + (parent->adaptor, parent->object, widget->object)) { if (old_parent == NULL || widget->packing_properties == NULL || - old_parent->widget_class->type != parent->widget_class->type) + old_parent->adaptor->type != parent->adaptor->type) glade_widget_set_packing_properties (widget, parent); else glade_widget_sync_packing_props (widget); @@ -3204,9 +3193,9 @@ glade_widget_set_packing_properties (GladeWidget *widget, /* Dont introspect on properties that are not parented yet. */ - if (glade_widget_class_container_has_child (container->widget_class, - container->object, - widget->object)) + if (glade_widget_adaptor_has_child (container->adaptor, + container->object, + widget->object)) { glade_widget_set_default_packing_properties (container, widget); @@ -3217,8 +3206,8 @@ glade_widget_set_packing_properties (GladeWidget *widget, { GladeProperty *property = list->data; g_value_reset (property->value); - glade_widget_class_container_get_property - (container->widget_class, + glade_widget_adaptor_child_get_property + (container->adaptor, container->object, widget->object, property->class->id, @@ -3244,14 +3233,14 @@ glade_widget_has_decendant (GladeWidget *widget, GType type) if (G_TYPE_IS_INTERFACE (type) && glade_util_class_implements_interface - (widget->widget_class->type, type)) + (widget->adaptor->type, type)) return TRUE; else if (G_TYPE_IS_INTERFACE (type) == FALSE && - g_type_is_a (widget->widget_class->type, type)) + g_type_is_a (widget->adaptor->type, type)) return TRUE; - if ((children = glade_widget_class_container_get_children - (widget->widget_class, widget->object)) != NULL) + if ((children = glade_widget_adaptor_get_children + (widget->adaptor, widget->object)) != NULL) { for (l = children; l; l = l->next) if ((child = glade_widget_get_from_gobject (l->data)) != NULL && @@ -3298,7 +3287,7 @@ glade_widget_replace (GladeWidget *parent, GObject *old_object, GObject *new_obj g_return_if_fail (G_IS_OBJECT (old_object)); g_return_if_fail (G_IS_OBJECT (new_object)); - GLADE_WIDGET_GET_KLASS (parent)->replace_child (parent, old_object, new_object); + GLADE_WIDGET_GET_CLASS (parent)->replace_child (parent, old_object, new_object); } /* XML Serialization */ @@ -3353,8 +3342,8 @@ glade_widget_write (GladeWidget *widget, GladeInterface *interface) info = g_new0 (GladeWidgetInfo, 1); - info->classname = glade_xml_alloc_string (interface, widget->widget_class->name); - info->name = glade_xml_alloc_string (interface, widget->name); + info->classname = glade_xml_alloc_string (interface, widget->adaptor->name); + info->name = glade_xml_alloc_string (interface, widget->name); /* Write the properties */ props = g_array_new (FALSE, FALSE, sizeof (GladePropInfo)); @@ -3432,8 +3421,8 @@ glade_widget_write (GladeWidget *widget, GladeInterface *interface) /* Children */ if ((list = - glade_widget_class_container_get_children (widget->widget_class, - widget->object)) != NULL) + glade_widget_adaptor_get_children (widget->adaptor, + widget->object)) != NULL) { children = g_array_new (FALSE, FALSE, sizeof (GladeChildInfo)); while (list && list->data) @@ -3461,19 +3450,23 @@ glade_widget_write_special_child_prop (GArray *props, GladeInterface *interface) { GladePropInfo info = { 0 }; - gchar *buff; - GladeSupportedChild *support; + gchar *buff, *special_child_type; - support = glade_widget_class_get_child_support (parent->widget_class, G_OBJECT_TYPE (object)); - buff = g_object_get_data (object, "special-child-type"); + buff = g_object_get_data (object, "special-child-type"); - if (support && support->special_child_type && buff) + g_object_get (parent->adaptor, "special-child-type", &special_child_type, NULL); + + if (special_child_type && buff) { - info.name = glade_xml_alloc_propname (interface, support->special_child_type); + info.name = glade_xml_alloc_propname (interface, + special_child_type); info.value = glade_xml_alloc_string (interface, buff); g_array_append_val (props, info); + + g_free (special_child_type); return TRUE; } + g_free (special_child_type); return FALSE; } @@ -3593,7 +3586,10 @@ glade_widget_has_launcher (GladeWidget *widget) parent = widget; do { - if (parent->widget_class->launch_editor != NULL) + GladeWidgetAdaptorClass *adaptor_class = + GLADE_WIDGET_ADAPTOR_GET_CLASS (parent->adaptor); + + if (adaptor_class->launch_editor != NULL) return TRUE; } while ((parent = parent->parent) != NULL); return FALSE; @@ -3614,9 +3610,13 @@ glade_widget_launch_editor (GladeWidget *widget) parent = widget; do { - if (parent->widget_class->launch_editor != NULL) + GladeWidgetAdaptorClass *adaptor_class = + GLADE_WIDGET_ADAPTOR_GET_CLASS (parent->adaptor); + + if (adaptor_class->launch_editor != NULL) { - parent->widget_class->launch_editor (parent->object); + glade_widget_adaptor_launch_editor (parent->adaptor, + parent->object); break; } } while ((parent = parent->parent) != NULL); diff --git a/src/glade-widget.h b/src/glade-widget.h index abfcec11..5096a195 100644 --- a/src/glade-widget.h +++ b/src/glade-widget.h @@ -5,7 +5,7 @@ #include <glib.h> #include <glib-object.h> -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" #include "glade-signal.h" #include "glade-property.h" @@ -13,19 +13,21 @@ G_BEGIN_DECLS #define GLADE_TYPE_WIDGET (glade_widget_get_type ()) #define GLADE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_WIDGET, GladeWidget)) -#define GLADE_WIDGET_KLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_WIDGET, GladeWidgetKlass)) +#define GLADE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_WIDGET, GladeWidgetClass)) #define GLADE_IS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_WIDGET)) -#define GLADE_IS_WIDGET_KLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_WIDGET)) -#define GLADE_WIDGET_GET_KLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_WIDGET, GladeWidgetKlass)) +#define GLADE_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_WIDGET)) +#define GLADE_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_WIDGET, GladeWidgetClass)) -typedef struct _GladeWidgetKlass GladeWidgetKlass; +typedef struct _GladeWidgetClass GladeWidgetClass; struct _GladeWidget { GObject parent_instance; - GladeWidgetClass *widget_class; - GladeProject *project; /* A pointer to the project that this widget belongs to. */ + GladeWidgetAdaptor *adaptor; /* An adaptor class for the object type */ + + GladeProject *project; /* A pointer to the project that this + widget currently belongs to. */ GladeWidget *parent; /* A pointer to the parent widget in the hierarchy */ @@ -95,7 +97,7 @@ struct _GladeWidget gchar *construct_internal; }; -struct _GladeWidgetKlass +struct _GladeWidgetClass { GObjectClass parent_class; @@ -279,7 +281,7 @@ void glade_widget_set_project (GladeWidget *widget, LIBGLADEUI_API GladeProject *glade_widget_get_project (GladeWidget *widget); LIBGLADEUI_API -GladeWidgetClass *glade_widget_get_class (GladeWidget *widget); +GladeWidgetAdaptor *glade_widget_get_adaptor (GladeWidget *widget); LIBGLADEUI_API GladeWidget *glade_widget_get_parent (GladeWidget *widget); LIBGLADEUI_API diff --git a/src/glade.h b/src/glade.h index c8df5c1c..bfd9d77e 100644 --- a/src/glade.h +++ b/src/glade.h @@ -34,7 +34,7 @@ typedef struct _GladeProperty GladeProperty; typedef struct _GladeProject GladeProject; typedef enum _GladeItemAppearance GladeItemAppearance; -#include "glade-widget-class.h" +#include "glade-widget-adaptor.h" #include "glade-widget.h" #include "glade-property-class.h" #include "glade-property.h" @@ -57,6 +57,13 @@ typedef enum _GladeItemAppearance GladeItemAppearance; #define GLADE_TAG_NO "No" #define GLADE_ENUM_DATA_TAG "GladeEnumDataTag" +#define GLADE_LARGE_ICON_SUBDIR "22x22" +#define GLADE_LARGE_ICON_SIZE 22 + +#define GLADE_SMALL_ICON_SUBDIR "16x16" +#define GLADE_SMALL_ICON_SIZE 16 + + #define GLADE_TAG_EVENT_HANDLER_CONNECTED "EventHandlerConnected" #define GLADE_XML_TAG_PROJECT "glade-interface" @@ -101,6 +108,7 @@ typedef enum _GladeItemAppearance GladeItemAppearance; #define GLADE_TAG_CHILD_SET_PROP_FUNCTION "child-set-property-function" #define GLADE_TAG_CHILD_GET_PROP_FUNCTION "child-get-property-function" #define GLADE_TAG_PROPERTIES "properties" +#define GLADE_TAG_PACKING_PROPERTIES "packing-properties" #define GLADE_TAG_PROPERTY "property" #define GLADE_TAG_TYPE "type" #define GLADE_TAG_SPEC "spec" @@ -122,8 +130,6 @@ typedef enum _GladeItemAppearance GladeItemAppearance; #define GLADE_TAG_ID "id" #define GLADE_TAG_KEY "key" #define GLADE_TAG_VALUE "value" -#define GLADE_TAG_CHILD "child" -#define GLADE_TAG_CHILDREN "children" #define GLADE_TAG_TRANSLATABLE "translatable" #define GLADE_TAG_PACKING_DEFAULTS "packing-defaults" #define GLADE_TAG_PARENT_CLASS "parent-class" @@ -53,12 +53,10 @@ static GOptionEntry option_entries[] = }; /* Debugging arguments */ -static gchar *widget_name = NULL; static gboolean verbose = FALSE; static GOptionEntry debug_option_entries[] = { - { "dump", 'd', 0, G_OPTION_ARG_STRING, &widget_name, "dump the properties of a widget", "GTKWIDGET" }, { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "be verbose", NULL }, { NULL } }; @@ -148,14 +146,6 @@ main (int argc, char *argv[]) if (without_devhelp == FALSE) glade_project_window_check_devhelp (project_window); - if (widget_name != NULL) - { - GladeWidgetClass *class; - class = glade_widget_class_get_by_name (widget_name); - if (class) - glade_widget_class_dump_param_specs (class); - return 0; - } /* load files specified on commandline */ if (files != NULL) diff --git a/widgets/bonobo.xml.in b/widgets/bonobo.xml.in index 754604f0..5cfa79bb 100644 --- a/widgets/bonobo.xml.in +++ b/widgets/bonobo.xml.in @@ -1,6 +1,11 @@ <glade-catalog name="bonobo" library="gladegnome" depends="gnome" domain="glade-3"> <glade-widget-classes> <glade-widget-class name="BonoboDock" generic-name="bonobodock" title="Bonobo Dock"> + <add-child-function>glade_gnome_bonobodock_add_child</add-child-function> + <remove-child-function>glade_gnome_bonobodock_remove_child</remove-child-function> + <get-children-function>glade_gnome_bonobodock_get_children</get-children-function> + <child-set-property-function>glade_gnome_bonobodock_set_child_property</child-set-property-function> + <child-get-property-function>glade_gnome_bonobodock_get_child_property</child-get-property-function> <properties> <property id="allow-floating" name="Allow Floating"> <tooltip>If floating dock iteam are allowed</tooltip> @@ -8,56 +13,40 @@ <set-function>glade_gnome_bonobodock_set_allow_floating</set-function> </property> </properties> - <children> - <child> - <type>BonoboDockItem</type> - <add-child-function>glade_gnome_bonobodock_add_item</add-child-function> - <remove-child-function>glade_gnome_bonobodock_remove_item</remove-child-function> - <get-children-function>glade_gnome_bonobodock_get_children</get-children-function> - <child-set-property-function>glade_gnome_bonobodock_set_child_property</child-set-property-function> - <child-get-property-function>glade_gnome_bonobodock_get_child_property</child-get-property-function> - <properties> - <property id="placement"> - <spec>glade_gnome_bonobo_dock_placement_spec</spec> - <displayable-values> - <value id="BONOBO_DOCK_LEFT" _name="Left"/> - <value id="BONOBO_DOCK_RIGHT" _name="Right"/> - <value id="BONOBO_DOCK_TOP" _name="Top"/> - <value id="BONOBO_DOCK_BOTTOM" _name="Bottom"/> - <value id="BONOBO_DOCK_FLOATING" _name="Floating"/> - </displayable-values> - </property> - <property id="band" name="Band"> - <spec>glade_standard_int_spec</spec> - </property> - <property id="position" name="Position"> - <spec>glade_standard_int_spec</spec> - </property> - <property id="offset" name="Offset"> - <spec>glade_standard_int_spec</spec> - </property> - <property id="behavior"> - <spec>glade_gnome_bonobo_dock_item_behavior_spec</spec> - <displayable-values> - <value id="BONOBO_DOCK_ITEM_BEH_EXCLUSIVE" _name="Exclusive"/> - <value id="BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING" _name="Never Floating"/> - <value id="BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL" _name="Never Vertical"/> - <value id="BONOBO_DOCK_ITEM_BEH_NEVER_HORIZONTAL" _name="Never Horizontal"/> - <value id="BONOBO_DOCK_ITEM_BEH_LOCKED" _name="Locked"/> - </displayable-values> - </property> - </properties> - </child> - <child> - <type>GtkWidget</type> - <add-child-function>glade_gnome_bonobodock_add_client_area</add-child-function> - <get-children-function>glade_gnome_bonobodock_get_client_area</get-children-function> - <replace-child-function>glade_gnome_bonobodock_replace_client_area</replace-child-function> - </child> - </children> + + <packing-properties> + <property id="placement"> + <spec>glade_gnome_bonobo_dock_placement_spec</spec> + <displayable-values> + <value id="BONOBO_DOCK_LEFT" _name="Left"/> + <value id="BONOBO_DOCK_RIGHT" _name="Right"/> + <value id="BONOBO_DOCK_TOP" _name="Top"/> + <value id="BONOBO_DOCK_BOTTOM" _name="Bottom"/> + <value id="BONOBO_DOCK_FLOATING" _name="Floating"/> + </displayable-values> + </property> + <property id="band" name="Band"> + <spec>glade_standard_int_spec</spec> + </property> + <property id="position" name="Position"> + <spec>glade_standard_int_spec</spec> + </property> + <property id="offset" name="Offset"> + <spec>glade_standard_int_spec</spec> + </property> + <property id="behavior"> + <spec>glade_gnome_bonobo_dock_item_behavior_spec</spec> + <displayable-values> + <value id="BONOBO_DOCK_ITEM_BEH_EXCLUSIVE" _name="Exclusive"/> + <value id="BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING" _name="Never Floating"/> + <value id="BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL" _name="Never Vertical"/> + <value id="BONOBO_DOCK_ITEM_BEH_NEVER_HORIZONTAL" _name="Never Horizontal"/> + <value id="BONOBO_DOCK_ITEM_BEH_LOCKED" _name="Locked"/> + </displayable-values> + </property> + </packing-properties> </glade-widget-class> <glade-widget-class name="BonoboDockItem" generic-name="bonobodockitem" title="Bonobo Dock Item"> - <post-create-function>glade_gnome_bonobodockitem_post_create</post-create-function> <properties> <property id="shadow"> <displayable-values> diff --git a/widgets/gnome.xml.in b/widgets/gnome.xml.in index d36d003e..0fdc72a1 100644 --- a/widgets/gnome.xml.in +++ b/widgets/gnome.xml.in @@ -4,6 +4,10 @@ <glade-widget-class name="GnomeApp" generic-name="gnomeapp" title="Gnome App"> <post-create-function>glade_gnome_app_post_create</post-create-function> <get-internal-child-function>glade_gnome_app_get_internal_child</get-internal-child-function> + <get-children-function>glade_gnome_app_get_children</get-children-function> + <child-set-property-function>glade_gnome_app_set_child_property</child-set-property-function> + <child-get-property-function>glade_gnome_app_get_child_property</child-get-property-function> + <properties> <property id="has-statusbar" _name="StatusBar" save="False"> <tooltip>If the window has a statusbar</tooltip> @@ -15,53 +19,41 @@ <spec>glade_standard_boolean_spec</spec> </property> </properties> - <children> - <child> - <type>GtkWidget</type> - <get-children-function>glade_gnome_app_get_children</get-children-function> - <child-set-property-function>glade_gnome_app_set_child_property</child-set-property-function> - <child-get-property-function>glade_gnome_app_get_child_property</child-get-property-function> - <properties> - <property id="position" _name="Position"> - <spec>glade_standard_int_spec</spec> - </property> - <property id="padding" _name="Padding"> - <spec>glade_standard_int_spec</spec> - </property> - <property id="expand" _name="Expand"> - <spec>glade_standard_boolean_spec</spec> - </property> - <property id="fill" _name="Fill"> - <spec>glade_standard_boolean_spec</spec> - </property> - <property id="pack-type"> - <spec>glade_gnome_gtk_pack_type_spec</spec> - <displayable-values> - <value id="GTK_PACK_START" _name="Start"/> - <value id="GTK_PACK_END" _name="End"/> - </displayable-values> - </property> - </properties> - </child> - </children> + <packing-properties> + <property id="position" _name="Position"> + <spec>glade_standard_int_spec</spec> + </property> + <property id="padding" _name="Padding"> + <spec>glade_standard_int_spec</spec> + </property> + <property id="expand" _name="Expand"> + <spec>glade_standard_boolean_spec</spec> + </property> + <property id="fill" _name="Fill"> + <spec>glade_standard_boolean_spec</spec> + </property> + <property id="pack-type"> + <spec>glade_gnome_gtk_pack_type_spec</spec> + <displayable-values> + <value id="GTK_PACK_START" _name="Start"/> + <value id="GTK_PACK_END" _name="End"/> + </displayable-values> + </property> + </packing-properties> </glade-widget-class> <glade-widget-class name="GnomeDruid" generic-name="gnomedruid" title="Gnome Druid"> <post-create-function>glade_gnome_druid_post_create</post-create-function> - <children> - <child> - <type>GnomeDruidPage</type> - <add-child-function>glade_gnome_druid_add_child</add-child-function> - <remove-child-function>glade_gnome_druid_remove_child</remove-child-function> - <child-set-property-function>glade_gnome_druid_set_child_property</child-set-property-function> - <child-get-property-function>glade_gnome_druid_get_child_property</child-get-property-function> - <properties> - <property id="position" _name="Position" default="-1" save="False"> - <spec>glade_standard_int_spec</spec> - </property> - </properties> - </child> - </children> + <add-child-function>glade_gnome_druid_add_child</add-child-function> + <remove-child-function>glade_gnome_druid_remove_child</remove-child-function> + <child-set-property-function>glade_gnome_druid_set_child_property</child-set-property-function> + <child-get-property-function>glade_gnome_druid_get_child_property</child-get-property-function> + + <packing-properties> + <property id="position" _name="Position" default="-1" save="False"> + <spec>glade_standard_int_spec</spec> + </property> + </packing-properties> </glade-widget-class> <glade-widget-class name="GnomeDruidPageEdge" generic-name="gnomedruidpageedge" title="Gnome Druid Page Edge"> @@ -124,6 +116,8 @@ <glade-widget-class name="GnomeDruidPageStandard" generic-name="gnomedruidpagestandard" title="Gnome Druid Page Standard"> <post-create-function>glade_gnome_dps_post_create</post-create-function> <get-internal-child-function>glade_gnome_dps_get_internal_child</get-internal-child-function> + <get-children-function>glade_gnome_dps_get_children</get-children-function> + <properties> <property id="title" translatable="True"> <visible-lines>2</visible-lines> @@ -146,12 +140,6 @@ <set-function>glade_gnome_dps_set_title_foreground</set-function> </property> </properties> - <children> - <child> - <type>GtkWidget</type> - <get-children-function>glade_gnome_dps_get_children</get-children-function> - </child> - </children> </glade-widget-class> @@ -208,16 +196,12 @@ <glade-widget-class name="GnomeDialog" generic-name="gnomedialog" title="Gnome Dialog"> <post-create-function>glade_gnome_dialog_post_create</post-create-function> <get-internal-child-function>glade_gnome_dialog_get_internal_child</get-internal-child-function> - <children> - <child> - <type>GtkWidget</type> - <get-children-function>glade_gnome_dialog_get_children</get-children-function> - </child> - </children> + <get-children-function>glade_gnome_dialog_get_children</get-children-function> </glade-widget-class> <glade-widget-class name="GnomeAbout" generic-name="gnomeabout" title="Gnome About"> - <post-create-function>glade_gnome_about_dialog_post_create</post-create-function> + <post-create-function>glade_gnome_about_dialog_post_create</post-create-function> + <get-children-function>glade_gnome_about_dialog_get_children</get-children-function> <properties> <property id="name" _name="Program Name"> <set-function>glade_gnome_about_set_name</set-function> @@ -235,12 +219,6 @@ <visible-lines>4</visible-lines> </property> </properties> - <children> - <child> - <type>GtkWidget</type> <!-- Skip GtkDialog internal widgets --> - <get-children-function>glade_gnome_about_dialog_get_children</get-children-function> - </child> - </children> </glade-widget-class> <glade-widget-class name="GnomeMessageBox" generic-name="gnomemessagebox" title="Gnome Message Box"> @@ -268,6 +246,7 @@ <glade-widget-class name="GnomeEntry" generic-name="gnomeentry" title="Gnome Entry"> <post-create-function>glade_gnome_entry_post_create</post-create-function> <get-internal-child-function>glade_gnome_entry_get_internal_child</get-internal-child-function> + <get-children-function>glade_gnome_entry_get_children</get-children-function> <properties> <property id="gtk-entry" disabled="True"/> <property id="max-saved" _name="Max Saved"> @@ -277,24 +256,20 @@ </property> <property id="size" visible="False" query="False" ignore="True"/> </properties> - <children> - <child> - <type>GtkWidget</type> - <get-children-function>glade_gnome_entry_get_children</get-children-function> - <properties> - <property id="expand" disabled="True"/> - <property id="fill" disabled="True"/> - <property id="pack-type" disabled="True"/> - <property id="padding" disabled="True"/> - <property id="position" disabled="True"/> - </properties> - </child> - </children> + + <packing-properties> + <property id="expand" disabled="True"/> + <property id="fill" disabled="True"/> + <property id="pack-type" disabled="True"/> + <property id="padding" disabled="True"/> + <property id="position" disabled="True"/> + </packing-properties> </glade-widget-class> <glade-widget-class name="GnomeFileEntry" generic-name="gnomefileentry" title="Gnome File Entry"> <post-create-function>glade_gnome_entry_post_create</post-create-function> <get-internal-child-function>glade_gnome_entry_get_internal_child</get-internal-child-function> + <get-children-function>glade_gnome_entry_get_children</get-children-function> <properties> <property id="max-saved" _name="Max Saved"> <spec>glade_standard_int_spec</spec> @@ -311,34 +286,23 @@ </displayable-values> </property> </properties> - <children> - <child> - <type>GtkWidget</type> - <get-children-function>glade_gnome_entry_get_children</get-children-function> - <properties> - <property id="expand" disabled="True"/> - <property id="fill" disabled="True"/> - <property id="pack-type" disabled="True"/> - <property id="padding" disabled="True"/> - <property id="position" disabled="True"/> - </properties> - </child> - </children> + <packing-properties> + <property id="expand" disabled="True"/> + <property id="fill" disabled="True"/> + <property id="pack-type" disabled="True"/> + <property id="padding" disabled="True"/> + <property id="position" disabled="True"/> + </packing-properties> </glade-widget-class> <glade-widget-class name="GnomePixmapEntry" generic-name="gnomepixmapentry" title="Gnome Pixmap Entry"> - <children> - <child> - <type>GtkWidget</type> - <properties> - <property id="expand" disabled="True"/> - <property id="fill" disabled="True"/> - <property id="pack-type" disabled="True"/> - <property id="padding" disabled="True"/> - <property id="position" disabled="True"/> - </properties> - </child> - </children> + <packing-properties> + <property id="expand" disabled="True"/> + <property id="fill" disabled="True"/> + <property id="pack-type" disabled="True"/> + <property id="padding" disabled="True"/> + <property id="position" disabled="True"/> + </packing-properties> </glade-widget-class> <glade-widget-class name="GnomeColorPicker" generic-name="gnomecolorpicker" title="Gnome Color Picker"> @@ -360,6 +324,11 @@ <glade-widget-class name="GnomeFontPicker" generic-name="gnomefontpicker" title="Gnome Font Picker"> <post-create-function>empty</post-create-function> + <get-children-function>glade_gnome_font_picker_get_children</get-children-function> + <add-child-function>glade_gnome_font_picker_add_child</add-child-function> + <remove-child-function>glade_gnome_font_picker_remove_child</remove-child-function> + <replace-child-function>glade_gnome_font_picker_replace_child</replace-child-function> + <properties> <property id="use-underline" disabled="True"/> <property id="label" disabled="True"/> @@ -376,15 +345,6 @@ </displayable-values> </property> </properties> - <children> - <child> - <type>GtkWidget</type> - <get-children-function>glade_gnome_font_picker_get_children</get-children-function> - <add-child-function>glade_gnome_font_picker_add_child</add-child-function> - <remove-child-function>glade_gnome_font_picker_remove_child</remove-child-function> - <replace-child-function>glade_gnome_font_picker_replace_child</replace-child-function> - </child> - </children> </glade-widget-class> <glade-widget-class name="GnomePixmap" generic-name="gnomepixmap" title="Gnome Pixmap"> diff --git a/widgets/gtk+.xml.in b/widgets/gtk+.xml.in index 82846dab..988ed4dd 100644 --- a/widgets/gtk+.xml.in +++ b/widgets/gtk+.xml.in @@ -74,14 +74,14 @@ <glade-widget-class name="GtkContainer" _title="Container"> <post-create-function>glade_gtk_container_post_create</post-create-function> - <children> - <child> - <type>GtkWidget</type> - <add-child-function>glade_gtk_container_add_child</add-child-function> - <remove-child-function>glade_gtk_container_remove_child</remove-child-function> - <replace-child-function>glade_gtk_container_replace_child</replace-child-function> - </child> - </children> + + <add-child-function>glade_gtk_container_add_child</add-child-function> + <remove-child-function>glade_gtk_container_remove_child</remove-child-function> + <replace-child-function>glade_gtk_container_replace_child</replace-child-function> + <child-set-property-function>glade_gtk_container_set_child_property</child-set-property-function> + <child-get-property-function>glade_gtk_container_get_child_property</child-get-property-function> + <get-children-function>glade_gtk_container_get_children</get-children-function> + <properties> <property id="resize-mode"> <displayable-values> @@ -97,6 +97,10 @@ <glade-widget-class name="GtkBox" _title="Box" fixed="True"> <post-create-function>glade_gtk_box_post_create</post-create-function> <get-internal-child-function>glade_gtk_box_get_internal_child</get-internal-child-function> + <add-child-function>glade_gtk_box_add_child</add-child-function> + <remove-child-function>glade_gtk_box_remove_child</remove-child-function> + <child-set-property-function>glade_gtk_box_set_child_property</child-set-property-function> + <properties> <property id="size" _name="Number of items" query="True" default="3" save="False"> <spec>glade_standard_int_spec</spec> @@ -107,26 +111,18 @@ </property> </properties> - <children> - <child> - <type>GtkWidget</type> - <add-child-function>glade_gtk_box_add_child</add-child-function> - <remove-child-function>glade_gtk_box_remove_child</remove-child-function> - <child-set-property-function>glade_gtk_box_set_child_property</child-set-property-function> - <properties> - <property id="position" weight="0"/> - <property id="padding" transfer-on-paste="True" weight="0.5"/> - <property id="expand" transfer-on-paste="True"/> - <property id="fill" transfer-on-paste="True"/> - <property id="pack-type" transfer-on-paste="True"> - <displayable-values> - <value id="GTK_PACK_START" _name="Start"/> - <value id="GTK_PACK_END" _name="End"/> - </displayable-values> - </property> - </properties> - </child> - </children> + <packing-properties> + <property id="position" weight="0"/> + <property id="padding" transfer-on-paste="True" weight="0.5"/> + <property id="expand" transfer-on-paste="True"/> + <property id="fill" transfer-on-paste="True"/> + <property id="pack-type" transfer-on-paste="True"> + <displayable-values> + <value id="GTK_PACK_START" _name="Start"/> + <value id="GTK_PACK_END" _name="End"/> + </displayable-values> + </property> + </packing-properties> </glade-widget-class> <glade-widget-class name="GtkWindow" generic-name="window" _title="Window" toplevel="True"> @@ -192,25 +188,23 @@ <glade-widget-class name="GtkMenuShell" _title="Menu Shell"> <post-create-function>empty</post-create-function> - <children> - <child> - <type>GtkMenuItem</type> - <add-child-function>glade_gtk_menu_shell_add_item</add-child-function> - <remove-child-function>glade_gtk_menu_shell_remove_item</remove-child-function> - <child-set-property-function>glade_gtk_menu_shell_set_child_property</child-set-property-function> - <child-get-property-function>glade_gtk_menu_shell_get_child_property</child-get-property-function> - <properties> - <property id="position" _name="Position" default="-1" save="False"> - <spec>glade_standard_int_spec</spec> - <_tooltip>The position of the menu item in the menu shell</_tooltip> - </property> - </properties> - </child> - </children> + <add-child-function>glade_gtk_menu_shell_add_item</add-child-function> + <remove-child-function>glade_gtk_menu_shell_remove_item</remove-child-function> + <child-set-property-function>glade_gtk_menu_shell_set_child_property</child-set-property-function> + <child-get-property-function>glade_gtk_menu_shell_get_child_property</child-get-property-function> + <packing-properties> + <property id="position" _name="Position" default="-1" save="False"> + <spec>glade_standard_int_spec</spec> + <_tooltip>The position of the menu item in the menu shell</_tooltip> + </property> + </packing-properties> </glade-widget-class> <glade-widget-class name="GtkMenuItem" generic-name="menuitem" _title="Menu Item"> <post-create-function>glade_gtk_menu_item_post_create</post-create-function> + <get-children-function>glade_gtk_menu_item_get_submenu</get-children-function> + <add-child-function>glade_gtk_menu_item_add_submenu</add-child-function> + <remove-child-function>glade_gtk_menu_item_remove_submenu</remove-child-function> <properties> <property id="label" _name="Label" translatable="True"> <_tooltip>The text of the menu item</_tooltip> @@ -237,14 +231,6 @@ <set-function>glade_gtk_menu_item_set_stock_item</set-function> </property> </properties> - <children> - <child> - <type>GtkMenu</type> - <get-children-function>glade_gtk_menu_item_get_submenu</get-children-function> - <add-child-function>glade_gtk_menu_item_add_submenu</add-child-function> - <remove-child-function>glade_gtk_menu_item_remove_submenu</remove-child-function> - </child> - </children> </glade-widget-class> <glade-widget-class name="GtkCheckMenuItem" generic-name="checkmenuitem" _title="Check Menu Item"/> @@ -314,6 +300,11 @@ <glade-widget-class name="GtkToolbar" generic-name="toolbar" _title="Tool Bar"> <post-create-function>empty</post-create-function> <launch-editor-function>glade_gtk_toolbar_launch_editor</launch-editor-function> + <add-child-function>glade_gtk_toolbar_add_child</add-child-function> + <remove-child-function>glade_gtk_toolbar_remove_child</remove-child-function> + <child-set-property-function>glade_gtk_toolbar_set_child_property</child-set-property-function> + <child-get-property-function>glade_gtk_toolbar_get_child_property</child-get-property-function> + <properties> <property id="orientation"> <displayable-values> @@ -330,23 +321,15 @@ </displayable-values> </property> </properties> - <children> - <child> - <type>GtkToolItem</type> - <add-child-function>glade_gtk_toolbar_add_child</add-child-function> - <remove-child-function>glade_gtk_toolbar_remove_child</remove-child-function> - <child-set-property-function>glade_gtk_toolbar_set_child_property</child-set-property-function> - <child-get-property-function>glade_gtk_toolbar_get_child_property</child-get-property-function> - <properties> - <property id="position" _name="Position" default="-1" save="False"> - <spec>glade_standard_int_spec</spec> - <_tooltip>The position of the tool item in the toolbar</_tooltip> - </property> - <property id="expand" transfer-on-paste="True"/> - <property id="homogeneous" transfer-on-paste="True"/> - </properties> - </child> - </children> + + <packing-properties> + <property id="position" _name="Position" default="-1" save="False"> + <spec>glade_standard_int_spec</spec> + <_tooltip>The position of the tool item in the toolbar</_tooltip> + </property> + <property id="expand" transfer-on-paste="True"/> + <property id="homogeneous" transfer-on-paste="True"/> + </packing-properties> <packing-defaults> <parent-class name="GtkVBox"> @@ -500,6 +483,9 @@ <glade-widget-class name="GtkButton" generic-name="button" _title="Button"> <post-create-function>glade_gtk_button_post_create</post-create-function> + <add-child-function>glade_gtk_button_add_child</add-child-function> + <remove-child-function>glade_gtk_button_remove_child</remove-child-function> + <replace-child-function>glade_gtk_button_replace_child</replace-child-function> <properties> <property id="image" disabled="True"/> <property id="use-stock" visible="False"/> @@ -556,14 +542,6 @@ </property> </properties> - <children> - <child> - <type>GtkWidget</type> - <add-child-function>glade_gtk_button_add_child</add-child-function> - <remove-child-function>glade_gtk_button_remove_child</remove-child-function> - <replace-child-function>glade_gtk_button_replace_child</replace-child-function> - </child> - </children> </glade-widget-class> <glade-widget-class name="GtkToggleButton" generic-name="togglebutton" _title="Toggle Button"> @@ -755,35 +733,14 @@ <glade-widget-class name="GtkDialog" generic-name="dialog" _title="Dialog Box"> <post-create-function>glade_gtk_dialog_post_create</post-create-function> <get-internal-child-function>glade_gtk_dialog_get_internal_child</get-internal-child-function> + <get-children-function>glade_gtk_dialog_get_children</get-children-function> + <properties> <property id="default-width" default="0" optional="True" optional-default="False"/> <property id="default-height" default="0" optional="True" optional-default="False"/> <property id="has-separator" default="False"/> </properties> - <children> - <child> - <type>GtkWidget</type> - - <!-- Return dialog buttons through here --> - <get-children-function>glade_gtk_dialog_get_children</get-children-function> - - <!-- That's supported, and IMO is the right way to handle --> - <!-- response-id (and it works), but it's not backwards compatible --> - <!-- with response-id being a property as in glade-2. So by now we --> - <!-- will just add a fake response-id property to buttons --> - <!-- - <properties> - <property id="response-id" _name="Response ID" default="0" common="False"> - <spec>glade_standard_int_spec</spec> - <_tooltip>The response ID of this button in the dialog</_tooltip> - <set-function>ignore</set-function> - <get-function>ignore</get-function> - </property> - </properties> - --> - </child> - </children> </glade-widget-class> <glade-widget-class name="GtkHBox" generic-name="hbox" _title="Horizontal Box"/> @@ -791,6 +748,11 @@ <glade-widget-class name="GtkTable" generic-name="table" _title="Table" fixed="True"> <post-create-function>glade_gtk_table_post_create</post-create-function> + <child-set-property-function>glade_gtk_table_set_child_property</child-set-property-function> + <add-child-function>glade_gtk_table_add_child</add-child-function> + <remove-child-function>glade_gtk_table_remove_child</remove-child-function> + <replace-child-function>glade_gtk_table_replace_child</replace-child-function> + <properties> <property id="n-rows" default="3" query="True"> <set-function>glade_gtk_table_set_n_rows</set-function> @@ -802,69 +764,55 @@ </property> </properties> - <children> - <child> - <type>GtkWidget</type> - <child-set-property-function>glade_gtk_table_set_child_property</child-set-property-function> - <add-child-function>glade_gtk_table_add_child</add-child-function> - <remove-child-function>glade_gtk_table_remove_child</remove-child-function> - <replace-child-function>glade_gtk_table_replace_child</replace-child-function> - <properties> - <property id="x-options" transfer-on-paste="True"> - <displayable-values> - <value id="GTK_EXPAND" _name="Expand"/> - <value id="GTK_SHRINK" _name="Shrink"/> - <value id="GTK_FILL" _name="Fill"/> - </displayable-values> - </property> - <property id="y-options" transfer-on-paste="True"> - <displayable-values> - <value id="GTK_EXPAND" _name="Expand"/> - <value id="GTK_SHRINK" _name="Shrink"/> - <value id="GTK_FILL" _name="Fill"/> - </displayable-values> - </property> - <property id="x-padding" transfer-on-paste="True"/> - <property id="y-padding" transfer-on-paste="True"/> - <property id="right-attach"> - <verify-function>glade_gtk_table_verify_right_attach</verify-function> - </property> - <property id="left-attach"> - <verify-function>glade_gtk_table_verify_left_attach</verify-function> - </property> - <property id="bottom-attach"> - <verify-function>glade_gtk_table_verify_bottom_attach</verify-function> - </property> - <property id="top-attach"> - <verify-function>glade_gtk_table_verify_top_attach</verify-function> - </property> - </properties> - </child> - </children> + <packing-properties> + <property id="x-options" transfer-on-paste="True"> + <displayable-values> + <value id="GTK_EXPAND" _name="Expand"/> + <value id="GTK_SHRINK" _name="Shrink"/> + <value id="GTK_FILL" _name="Fill"/> + </displayable-values> + </property> + <property id="y-options" transfer-on-paste="True"> + <displayable-values> + <value id="GTK_EXPAND" _name="Expand"/> + <value id="GTK_SHRINK" _name="Shrink"/> + <value id="GTK_FILL" _name="Fill"/> + </displayable-values> + </property> + <property id="x-padding" transfer-on-paste="True"/> + <property id="y-padding" transfer-on-paste="True"/> + <property id="right-attach"> + <verify-function>glade_gtk_table_verify_right_attach</verify-function> + </property> + <property id="left-attach"> + <verify-function>glade_gtk_table_verify_left_attach</verify-function> + </property> + <property id="bottom-attach"> + <verify-function>glade_gtk_table_verify_bottom_attach</verify-function> + </property> + <property id="top-attach"> + <verify-function>glade_gtk_table_verify_top_attach</verify-function> + </property> + </packing-properties> </glade-widget-class> <glade-widget-class name="GtkPaned" _title="Paned"> <post-create-function>glade_gtk_paned_post_create</post-create-function> - <children> - <child> - <type>GtkWidget</type> - <add-child-function>glade_gtk_paned_add_child</add-child-function> - <remove-child-function>glade_gtk_paned_remove_child</remove-child-function> - <child-set-property-function>glade_gtk_paned_set_child_property</child-set-property-function> - <child-get-property-function>glade_gtk_paned_get_child_property</child-get-property-function> - <properties> - <property id="resize" transfer-on-paste="True"/> - <property id="shrink" transfer-on-paste="True"/> - <!-- - Whether to add the child to the top/left or bottom/right pane. - This virtual property is used to remember child position in undo/redo. - --> - <property id="first" save="False" visible="False"> - <spec>glade_standard_boolean_spec</spec> - </property> - </properties> - </child> - </children> + <add-child-function>glade_gtk_paned_add_child</add-child-function> + <remove-child-function>glade_gtk_paned_remove_child</remove-child-function> + <child-set-property-function>glade_gtk_paned_set_child_property</child-set-property-function> + <child-get-property-function>glade_gtk_paned_get_child_property</child-get-property-function> + <packing-properties> + <property id="resize" transfer-on-paste="True"/> + <property id="shrink" transfer-on-paste="True"/> + <!-- + Whether to add the child to the top/left or bottom/right pane. + This virtual property is used to remember child position in undo/redo. + --> + <property id="first" save="False" visible="False"> + <spec>glade_standard_boolean_spec</spec> + </property> + </packing-properties> </glade-widget-class> <glade-widget-class name="GtkHPaned" generic-name="hpaned" _title="Horizontal Panes"/> @@ -873,6 +821,13 @@ <glade-widget-class name="GtkNotebook" generic-name="notebook" _title="Notebook"> <post-create-function>glade_gtk_notebook_post_create</post-create-function> + <add-child-function>glade_gtk_notebook_add_child</add-child-function> + <remove-child-function>glade_gtk_notebook_remove_child</remove-child-function> + <replace-child-function>glade_gtk_notebook_replace_child</replace-child-function> + <child-set-property-function>glade_gtk_notebook_set_child_property</child-set-property-function> + <child-get-property-function>glade_gtk_notebook_get_child_property</child-get-property-function> + <special-child-type>type</special-child-type> + <properties> <property id="page" save="False"> <_tooltip>Set the current page (strictly for editing purposes)</_tooltip> @@ -894,29 +849,18 @@ </property> </properties> - <children> - <child> - <type>GtkWidget</type> - <special-child-type>type</special-child-type> - <add-child-function>glade_gtk_notebook_add_child</add-child-function> - <remove-child-function>glade_gtk_notebook_remove_child</remove-child-function> - <replace-child-function>glade_gtk_notebook_replace_child</replace-child-function> - <child-set-property-function>glade_gtk_notebook_set_child_property</child-set-property-function> - <child-get-property-function>glade_gtk_notebook_get_child_property</child-get-property-function> - <properties> - <property id="tab-label" disabled="True"/> - <property id="tab-pack"> - <displayable-values> - <value id="GTK_PACK_START" _name="Start"/> - <value id="GTK_PACK_END" _name="End"/> - </displayable-values> - </property> - <property id="position"> - <verify-function>glade_gtk_notebook_verify_position</verify-function> - </property> - </properties> - </child> - </children> + <packing-properties> + <property id="tab-label" disabled="True"/> + <property id="tab-pack"> + <displayable-values> + <value id="GTK_PACK_START" _name="Start"/> + <value id="GTK_PACK_END" _name="End"/> + </displayable-values> + </property> + <property id="position"> + <verify-function>glade_gtk_notebook_verify_position</verify-function> + </property> + </packing-properties> </glade-widget-class> @@ -924,6 +868,10 @@ <glade-widget-class name="GtkFrame" generic-name="frame" _title="Frame"> <post-create-function>glade_gtk_frame_post_create</post-create-function> + <add-child-function>glade_gtk_frame_add_child</add-child-function> + <replace-child-function>glade_gtk_frame_replace_child</replace-child-function> + <special-child-type>type</special-child-type> + <properties> <property id="label" disabled="True"/> <property id="shadow" disabled="True"/> @@ -939,14 +887,6 @@ </displayable-values> </property> </properties> - <children> - <child> - <type>GtkWidget</type> - <special-child-type>type</special-child-type> - <add-child-function>glade_gtk_frame_add_child</add-child-function> - <replace-child-function>glade_gtk_frame_replace_child</replace-child-function> - </child> - </children> </glade-widget-class> <glade-widget-class name="GtkAspectFrame" generic-name="aspectframe" _title="Aspect Frame"/> @@ -1064,30 +1004,18 @@ <glade-widget-class name="GtkLayout" generic-name="layout" _title="Layout" fixed="True"> <post-create-function>glade_gtk_fixed_layout_post_create</post-create-function> + <add-child-function>glade_gtk_fixed_layout_add_child</add-child-function> + <remove-child-function>glade_gtk_fixed_layout_remove_child</remove-child-function> <properties> <property id="hadjustment" disabled="True"/> <property id="vadjustment" disabled="True"/> </properties> - <children> - <!-- This will unset any custom handler defined in the plugin for _add() --> - <child> - <type>GtkWidget</type> - <add-child-function>gtk_container_add</add-child-function> - <remove-child-function>gtk_container_remove</remove-child-function> - </child> - </children> </glade-widget-class> <glade-widget-class name="GtkFixed" generic-name="fixed" _title="Fixed" fixed="True"> <post-create-function>glade_gtk_fixed_layout_post_create</post-create-function> - <children> - <!-- This will unset any custom handler defined in the plugin for _add() --> - <child> - <type>GtkWidget</type> - <add-child-function>gtk_container_add</add-child-function> - <remove-child-function>gtk_container_remove</remove-child-function> - </child> - </children> + <add-child-function>glade_gtk_fixed_layout_add_child</add-child-function> + <remove-child-function>glade_gtk_fixed_layout_remove_child</remove-child-function> </glade-widget-class> <glade-widget-class name="GtkDrawingArea" generic-name="drawingarea" _title="Drawing Area"/> @@ -1096,6 +1024,11 @@ <glade-widget-class name="GtkExpander" generic-name="expander" _title="Expander"> <post-create-function>glade_gtk_expander_post_create</post-create-function> + <add-child-function>glade_gtk_expander_add_child</add-child-function> + <remove-child-function>glade_gtk_expander_remove_child</remove-child-function> + <replace-child-function>glade_gtk_expander_replace_child</replace-child-function> + <special-child-type>type</special-child-type> + <properties> <property id="label" visible="False"/> <property id="label-widget" disabled="True"/> @@ -1107,17 +1040,7 @@ <visible-lines>2</visible-lines> </property> </properties> - <children> - <child> - <type>GtkWidget</type> - <special-child-type>type</special-child-type> - <add-child-function>glade_gtk_expander_add_child</add-child-function> - <remove-child-function>glade_gtk_expander_remove_child</remove-child-function> - <replace-child-function>glade_gtk_expander_replace_child</replace-child-function> - </child> - </children> </glade-widget-class> - <glade-widget-class name="GtkViewport" generic-name="viewport" _title="Viewport"> <properties> @@ -1268,6 +1191,8 @@ <glade-widget-class name="GtkCombo" generic-name="combo" _title="Combo"> <post-create-function>glade_gtk_combo_post_create</post-create-function> <get-internal-child-function>glade_gtk_combo_get_internal_child</get-internal-child-function> + <get-children-function>glade_gtk_combo_get_children</get-children-function> + <properties> <property id="size" disabled="True"/> @@ -1279,12 +1204,6 @@ </property> </properties> - <children> - <child> - <type>GtkWidget</type> - <get-children-function>glade_gtk_combo_get_children</get-children-function> - </child> - </children> </glade-widget-class> <glade-widget-class name="GtkOptionMenu" generic-name="optionmenu" _title="Option Menu"> @@ -1299,14 +1218,8 @@ </glade-widget-class> <glade-widget-class name="GtkList" generic-name="list" _title="List"> - <children> - <!-- This will unset any custom handler defined in the plugin for _add() --> - <child> - <type>GtkListItem</type> - <add-child-function>gtk_container_add</add-child-function> - <remove-child-function>gtk_container_remove</remove-child-function> - </child> - </children> + <add-child-function>glade_gtk_listitem_add_child</add-child-function> + <remove-child-function>glade_gtk_listitem_remove_child</remove-child-function> </glade-widget-class> <glade-widget-class name="GtkListItem" generic-name="listitem" _title="List Item"> |