[glade] * gladeui/glade-xml-utils.h, gladeui/glade-widget-adaptor.[ch], gladeui/glade-widget.[ch]: Added
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] * gladeui/glade-xml-utils.h, gladeui/glade-widget-adaptor.[ch], gladeui/glade-widget.[ch]: Added
- Date: Fri, 28 Jan 2011 09:08:44 +0000 (UTC)
commit 379eb29560b7030e88a6d865a6bf2e72415db8bf
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Fri Jan 28 18:16:06 2011 +0900
* gladeui/glade-xml-utils.h, gladeui/glade-widget-adaptor.[ch], gladeui/glade-widget.[ch]:
Added <add-child-verify-function> semantics to query the plugin if it's ok to add
a said "child" to an adaptors widget "parent" and warn the user about it in context.
* gladeui/glade-project.c: Check glade_widget_add_verify() when pasting widgets
* gladeui/glade-command.c: Check glade_widget_add_verify() from glade_command_create()
* gladeui/glade-popup.c: Allow "Add widget here" action to appear for any project object
and rely on glade_command_create() to warn the user via glade_widget_add_verify() if
adding the widget fails.
* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: Added <add-child-verify-function> support to
GtkContainer, GtkMenuShell, GtkMenuItem, GtkToolBar, GtkToolItem, GtkToolPalette, GtkToolItemGroup,
GtkActionGroup, GtkTextTagTable adaptors.
ChangeLog | 18 ++
gladeui/glade-command.c | 7 +
gladeui/glade-popup.c | 62 ++------
gladeui/glade-project.c | 15 ++
gladeui/glade-widget-adaptor.c | 49 ++++++
gladeui/glade-widget-adaptor.h | 32 ++++
gladeui/glade-widget.c | 30 ++++
gladeui/glade-widget.h | 4 +
gladeui/glade-xml-utils.h | 1 +
plugins/gtk+/glade-gtk.c | 336 ++++++++++++++++++++++++++++++++++------
plugins/gtk+/gtk+.xml.in | 16 ++-
11 files changed, 471 insertions(+), 99 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 33b55f8..17b88ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2011-01-28 Tristan Van Berkom <tristanvb openismus com>
+
+ * gladeui/glade-xml-utils.h, gladeui/glade-widget-adaptor.[ch], gladeui/glade-widget.[ch]:
+ Added <add-child-verify-function> semantics to query the plugin if it's ok to add
+ a said "child" to an adaptors widget "parent" and warn the user about it in context.
+
+ * gladeui/glade-project.c: Check glade_widget_add_verify() when pasting widgets
+
+ * gladeui/glade-command.c: Check glade_widget_add_verify() from glade_command_create()
+
+ * gladeui/glade-popup.c: Allow "Add widget here" action to appear for any project object
+ and rely on glade_command_create() to warn the user via glade_widget_add_verify() if
+ adding the widget fails.
+
+ * plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: Added <add-child-verify-function> support to
+ GtkContainer, GtkMenuShell, GtkMenuItem, GtkToolBar, GtkToolItem, GtkToolPalette, GtkToolItemGroup,
+ GtkActionGroup, GtkTextTagTable adaptors.
+
2011-01-27 Tristan Van Berkom <tristanvb openismus com>
* plugins/gtk+/gtk+.xml.in, plugins/gtk+/glade-gtk.c: Added support for GtkRecentFilter
diff --git a/gladeui/glade-command.c b/gladeui/glade-command.c
index 6343fe1..930691d 100644
--- a/gladeui/glade-command.c
+++ b/gladeui/glade-command.c
@@ -1581,6 +1581,13 @@ glade_command_create (GladeWidgetAdaptor * adaptor, GladeWidget * parent,
return NULL;
}
+ if (parent && !glade_widget_add_verify (parent, widget, TRUE))
+ {
+ g_object_ref_sink (widget);
+ g_object_unref (widget);
+ return NULL;
+ }
+
widgets = g_list_prepend (widgets, widget);
glade_command_push_group (_("Create %s"), glade_widget_get_name (widget));
glade_command_add (widgets, parent, placeholder, project, FALSE);
diff --git a/gladeui/glade-popup.c b/gladeui/glade-popup.c
index a15c8cd..072ea58 100644
--- a/gladeui/glade-popup.c
+++ b/gladeui/glade-popup.c
@@ -58,57 +58,23 @@ glade_popup_select_cb (GtkMenuItem * item, GladeWidget * widget)
glade_widget_get_object (widget), TRUE);
}
-static GladePlaceholder *
-find_placeholder (GObject * object)
-{
- GtkContainer *container;
- GladePlaceholder *retval = NULL;
- GtkWidget *child;
- GList *c, *l;
-
- if (!GTK_IS_CONTAINER (object))
- return NULL;
-
- container = GTK_CONTAINER (object);
-
- for (c = l = glade_util_container_get_all_children (container);
- l; l = g_list_next (l))
- {
- child = l->data;
-
- if (GLADE_IS_PLACEHOLDER (child))
- {
- retval = GLADE_PLACEHOLDER (child);
- break;
- }
- }
-
- g_list_free (c);
-
- return retval;
-}
-
static void
-glade_popup_placeholder_add_cb (GtkMenuItem * item,
- GladePlaceholder * placeholder)
+glade_popup_widget_add_cb (GtkMenuItem * item,
+ GladeWidget * widget)
{
+ GladeProject *project;
GladeWidgetAdaptor *adaptor;
- GladeWidget *parent;
- GladeProject *project;
-
- parent = glade_placeholder_get_parent (placeholder);
- project = glade_placeholder_get_project (placeholder);
+ project = glade_widget_get_project (widget);
adaptor = glade_project_get_add_item (project);
g_return_if_fail (adaptor != NULL);
if (!glade_util_check_and_warn_scrollable
- (parent, adaptor, glade_app_get_window ()))
+ (widget, adaptor, glade_app_get_window ()))
{
- glade_command_create (adaptor, parent,
- placeholder,
- project);
+ if (glade_command_create (adaptor, widget,
+ NULL, project))
glade_project_set_add_item (project, NULL);
}
@@ -423,7 +389,6 @@ glade_popup_create_menu (GladeWidget *widget,
GtkWidget *popup_menu;
GtkWidget *separator;
gboolean sensitive;
- GladePlaceholder *tmp_placeholder;
GladeWidgetAdaptor *adaptor;
gchar *book;
@@ -433,21 +398,20 @@ glade_popup_create_menu (GladeWidget *widget,
if (adaptor)
{
+ GladeWidget *parent;
RootAddData *data = g_new (RootAddData, 1);
+ parent = placeholder ? glade_placeholder_get_parent (placeholder) : widget;
+
data->adaptor = adaptor;
data->project = project;
g_object_set_data_full (G_OBJECT (popup_menu), "root-data-destroy-me",
data, (GDestroyNotify)g_free);
- tmp_placeholder = placeholder;
- if (!tmp_placeholder && widget)
- tmp_placeholder = find_placeholder (glade_widget_get_object (widget));
-
glade_popup_append_item (popup_menu, NULL, _("_Add widget here"),
- NULL, tmp_placeholder != NULL,
- glade_popup_placeholder_add_cb,
- tmp_placeholder);
+ NULL, parent != NULL,
+ glade_popup_widget_add_cb,
+ parent);
glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"),
NULL, TRUE, glade_popup_root_add_cb, data);
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 69ebcc4..5a36957 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -4619,6 +4619,19 @@ glade_project_command_paste (GladeProject *project,
return;
}
+ /* Check that the underlying adaptor allows the paste */
+ if (parent)
+ {
+ for (list = glade_clipboard_widgets (clipboard); list && list->data; list = list->next)
+ {
+ widget = list->data;
+
+ if (!glade_widget_add_verify (parent, widget, TRUE))
+ return;
+ }
+ }
+
+
/* Check that we have compatible heirarchies */
for (list = glade_clipboard_widgets (clipboard); list && list->data; list = list->next)
{
@@ -4637,6 +4650,8 @@ glade_project_command_paste (GladeProject *project,
/* A GladeWidget that doesnt use placeholders can only paste one
* at a time
+ *
+ * XXX: Not sure if this has to be true.
*/
if (GTK_IS_WIDGET (glade_widget_get_object (widget)) &&
parent && !GWA_USE_PLACEHOLDERS (glade_widget_get_adaptor (parent)) &&
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index ef06f80..5cdd210 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -812,6 +812,20 @@ glade_widget_adaptor_object_construct_object (GladeWidgetAdaptor * adaptor,
return g_object_newv (adaptor->priv->type, n_parameters, parameters);
}
+static gboolean
+glade_widget_adaptor_object_add_verify (GladeWidgetAdaptor *adaptor,
+ GObject *parent,
+ GObject *child,
+ gboolean user_feedback)
+{
+ if (user_feedback)
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("%s does not support adding any children."),
+ adaptor->priv->title);
+
+ return FALSE;
+}
static void
glade_widget_adaptor_object_set_property (GladeWidgetAdaptor * adaptor,
@@ -1208,6 +1222,7 @@ glade_widget_adaptor_class_init (GladeWidgetAdaptorClass * adaptor_class)
adaptor_class->verify_property = NULL;
adaptor_class->set_property = glade_widget_adaptor_object_set_property;
adaptor_class->get_property = glade_widget_adaptor_object_get_property;
+ adaptor_class->add_verify = glade_widget_adaptor_object_add_verify;
adaptor_class->add = NULL;
adaptor_class->remove = NULL;
adaptor_class->replace_child = NULL;
@@ -1410,6 +1425,10 @@ gwa_extend_with_node_load_sym (GladeWidgetAdaptorClass * klass,
klass->verify_property = symbol;
if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_ADD_CHILD_VERIFY_FUNCTION, &symbol))
+ klass->add_verify = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
GLADE_TAG_ADD_CHILD_FUNCTION, &symbol))
klass->add = symbol;
@@ -3064,6 +3083,36 @@ glade_widget_adaptor_verify_property (GladeWidgetAdaptor * adaptor,
}
/**
+ * glade_widget_adaptor_add_verify:
+ * @adaptor: A #GladeWidgetAdaptor
+ * @parent: A #GObject container
+ * @child: A #GObject child
+ * @user_feedback: whether a notification dialog should be
+ * presented in the case that the child cannot not be added.
+ *
+ * Checks whether @child can be added to @parent.
+ *
+ * If @user_feedback is %TRUE and @child cannot be
+ * added then this shows a notification dialog to the user
+ * explaining why.
+ *
+ * Returns: whether @child can be added to @parent.
+ */
+gboolean
+glade_widget_adaptor_add_verify (GladeWidgetAdaptor *adaptor,
+ GObject *container,
+ GObject *child,
+ gboolean user_feedback)
+{
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
+ g_return_val_if_fail (G_IS_OBJECT (container), FALSE);
+ g_return_val_if_fail (G_IS_OBJECT (child), FALSE);
+ g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->priv->type), FALSE);
+
+ return GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->add_verify (adaptor, container, child, user_feedback);
+}
+
+/**
* glade_widget_adaptor_add:
* @adaptor: A #GladeWidgetAdaptor
* @container: The #GObject container
diff --git a/gladeui/glade-widget-adaptor.h b/gladeui/glade-widget-adaptor.h
index b08ec66..1997258 100644
--- a/gladeui/glade-widget-adaptor.h
+++ b/gladeui/glade-widget-adaptor.h
@@ -295,9 +295,30 @@ typedef gboolean (* GladeChildVerifyPropertyFunc) (GladeWidgetAdaptor *adaptor,
const gchar *property_name,
const GValue *value);
+/**
+ * GladeAddChildVerifyFunc:
+ * @adaptor: A #GladeWidgetAdaptor
+ * @parent: A #GObject container
+ * @child: A #GObject child
+ * @user_feedback: whether a notification dialog should be
+ * presented in the case that the child cannot not be added.
+ *
+ * Checks whether @child can be added to @parent.
+ *
+ * If @user_feedback is %TRUE and @child cannot be
+ * added then this shows a notification dialog to the user
+ * explaining why.
+ *
+ * Returns: whether @child can be added to @parent.
+ */
+typedef gboolean (* GladeAddChildVerifyFunc) (GladeWidgetAdaptor *adaptor,
+ GObject *parent,
+ GObject *child,
+ gboolean user_feedback);
/**
* GladeGetChildrenFunc:
+ * @adaptor: A #GladeWidgetAdaptor
* @container: A #GObject container
*
* A function called to get @containers children.
@@ -309,6 +330,7 @@ typedef GList *(* GladeGetChildrenFunc) (GladeWidgetAdaptor *adaptor,
/**
* GladeAddChildFunc:
+ * @adaptor: A #GladeWidgetAdaptor
* @parent: A #GObject container
* @child: A #GObject child
*
@@ -317,8 +339,10 @@ typedef GList *(* GladeGetChildrenFunc) (GladeWidgetAdaptor *adaptor,
typedef void (* GladeAddChildFunc) (GladeWidgetAdaptor *adaptor,
GObject *parent,
GObject *child);
+
/**
* GladeRemoveChildFunc:
+ * @adaptor: A #GladeWidgetAdaptor
* @parent: A #GObject container
* @child: A #GObject child
*
@@ -330,6 +354,7 @@ typedef void (* GladeRemoveChildFunc) (GladeWidgetAdaptor *adaptor,
/**
* GladeReplaceChildFunc:
+ * @adaptor: A #GladeWidgetAdaptor
* @container: A #GObject container
* @old_obj: The old #GObject child
* @new_obj: The new #GObject child to take its place
@@ -364,6 +389,7 @@ typedef GObject *(* GladeConstructObjectFunc) (GladeWidgetAdaptor *adaptor,
/**
* GladePostCreateFunc:
+ * @adaptor: A #GladeWidgetAdaptor
* @object: a #GObject
* @reason: a #GladeCreateReason
*
@@ -376,6 +402,7 @@ typedef void (* GladePostCreateFunc) (GladeWidgetAdaptor *adaptor,
/**
* GladeGetInternalFunc:
+ * @adaptor: A #GladeWidgetAdaptor
* @parent: A #GObject composite object
* @name: A string identifier
*
@@ -601,6 +628,7 @@ struct _GladeWidgetAdaptorClass
*/
GladeGetPropertyFunc get_property;
+ GladeAddChildVerifyFunc add_verify; /* Checks if a child can be added */
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
@@ -713,6 +741,10 @@ gboolean glade_widget_adaptor_verify_property (GladeWidgetAdapto
GObject *object,
const gchar *property_name,
const GValue *value);
+gboolean glade_widget_adaptor_add_verify (GladeWidgetAdaptor *adaptor,
+ GObject *container,
+ GObject *child,
+ gboolean user_feedback);
void glade_widget_adaptor_add (GladeWidgetAdaptor *adaptor,
GObject *container,
GObject *child);
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index bfef754..e8d983e 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -2304,6 +2304,36 @@ glade_widget_copy_properties (GladeWidget * widget,
}
}
+
+/**
+ * glade_widget_add_verify:
+ * @widget: A #GladeWidget
+ * @child: The child #GladeWidget to add
+ * @user_feedback: whether a notification dialog should be
+ * presented in the case that the child cannot not be added.
+ *
+ * Checks whether @child can be added to @parent.
+ *
+ * If @user_feedback is %TRUE and @child cannot be
+ * added then this shows a notification dialog to the user
+ * explaining why.
+ *
+ * Returns: whether @child can be added to @widget.
+ */
+gboolean
+glade_widget_add_verify (GladeWidget *widget,
+ GladeWidget *child,
+ gboolean user_feedback)
+{
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET (child), FALSE);
+
+ return glade_widget_adaptor_add_verify (widget->priv->adaptor,
+ widget->priv->object,
+ child->priv->object,
+ user_feedback);
+}
+
/**
* glade_widget_add_child:
* @parent: A #GladeWidget
diff --git a/gladeui/glade-widget.h b/gladeui/glade-widget.h
index 0786a25..091a31d 100644
--- a/gladeui/glade-widget.h
+++ b/gladeui/glade-widget.h
@@ -69,6 +69,10 @@ GType glade_widget_get_type (void);
GladeWidget *glade_widget_get_from_gobject (gpointer object);
+gboolean glade_widget_add_verify (GladeWidget *parent,
+ GladeWidget *child,
+ gboolean user_feedback);
+
void glade_widget_add_child (GladeWidget *parent,
GladeWidget *child,
gboolean at_mouse);
diff --git a/gladeui/glade-xml-utils.h b/gladeui/glade-xml-utils.h
index f369ea2..e08bd1b 100644
--- a/gladeui/glade-xml-utils.h
+++ b/gladeui/glade-xml-utils.h
@@ -93,6 +93,7 @@ typedef struct _GladeProject GladeProject;
#define GLADE_TAG_POST_CREATE_FUNCTION "post-create-function"
#define GLADE_TAG_GET_INTERNAL_CHILD_FUNCTION "get-internal-child-function"
#define GLADE_TAG_ADD_CHILD_FUNCTION "add-child-function"
+#define GLADE_TAG_ADD_CHILD_VERIFY_FUNCTION "add-child-verify-function"
#define GLADE_TAG_REMOVE_CHILD_FUNCTION "remove-child-function"
#define GLADE_TAG_GET_CHILDREN_FUNCTION "get-children-function"
#define GLADE_TAG_CHILD_SET_PROP_FUNCTION "child-set-property-function"
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index f39b981..333e4dc 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -1071,6 +1071,50 @@ glade_gtk_container_post_create (GladeWidgetAdaptor * adaptor,
}
}
+gboolean
+glade_gtk_container_add_verify (GladeWidgetAdaptor *adaptor,
+ GtkWidget *container,
+ GtkWidget *child,
+ gboolean user_feedback)
+{
+ GladeWidget *gwidget = glade_widget_get_from_gobject (container);
+
+ if (GTK_IS_WINDOW (child))
+ {
+ if (user_feedback)
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Cannot add a toplevel window to a containter."));
+
+ return FALSE;
+ }
+ else if (!GTK_IS_WIDGET (child) ||
+ GTK_IS_TOOL_ITEM (child) ||
+ GTK_IS_MENU_ITEM (child))
+ {
+ if (user_feedback)
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Only widgets can be added to a %s."),
+ glade_widget_adaptor_get_title (adaptor));
+
+ return FALSE;
+ }
+ else if (GWA_USE_PLACEHOLDERS (adaptor) &&
+ glade_util_count_placeholders (gwidget) == 0)
+ {
+ if (user_feedback)
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("This %s has no placeholders available to add children."),
+ glade_widget_adaptor_get_title (adaptor));
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
glade_gtk_container_replace_child (GladeWidgetAdaptor * adaptor,
GtkWidget * container,
@@ -6045,6 +6089,32 @@ glade_gtk_menu_constructor (GType type,
}
/* ----------------------------- GtkMenuShell ------------------------------ */
+gboolean
+glade_gtk_menu_shell_add_verify (GladeWidgetAdaptor *adaptor,
+ GtkWidget *container,
+ GtkWidget *child,
+ gboolean user_feedback)
+{
+ if (!GTK_IS_MENU_ITEM (child))
+ {
+ if (user_feedback)
+ {
+ GladeWidgetAdaptor *menu_item_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_MENU_ITEM);
+
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Only a %s can be added to a %s."),
+ glade_widget_adaptor_get_title (menu_item_adaptor),
+ glade_widget_adaptor_get_title (adaptor));
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
glade_gtk_menu_shell_add_child (GladeWidgetAdaptor * adaptor,
GObject * object, GObject * child)
@@ -6645,6 +6715,44 @@ glade_gtk_menu_item_get_children (GladeWidgetAdaptor * adaptor,
return list;
}
+gboolean
+glade_gtk_menu_item_add_verify (GladeWidgetAdaptor *adaptor,
+ GtkWidget *container,
+ GtkWidget *child,
+ gboolean user_feedback)
+{
+ if (!GTK_IS_MENU (child))
+ {
+ if (user_feedback)
+ {
+ GladeWidgetAdaptor *menu_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_MENU);
+
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Only a %s can be added to a %s."),
+ glade_widget_adaptor_get_title (menu_adaptor),
+ glade_widget_adaptor_get_title (adaptor));
+ }
+
+ return FALSE;
+ }
+ else if (GTK_IS_SEPARATOR_MENU_ITEM (container))
+ {
+ if (user_feedback)
+ {
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("A %s cannot have any children."),
+ glade_widget_adaptor_get_title (adaptor));
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
glade_gtk_menu_item_add_child (GladeWidgetAdaptor * adaptor,
GObject * object, GObject * child)
@@ -6724,48 +6832,6 @@ glade_gtk_menu_item_set_property (GladeWidgetAdaptor * adaptor,
}
/* ----------------------------- GtkImageMenuItem ------------------------------ */
-
-GList *
-glade_gtk_image_menu_item_get_children (GladeWidgetAdaptor * adaptor,
- GObject * object)
-{
- GList *list = NULL;
- GtkWidget *child;
- GladeWidget *gitem;
-
- gitem = glade_widget_get_from_gobject (object);
-
- if ((child = gtk_menu_item_get_submenu (GTK_MENU_ITEM (object))))
- list = g_list_append (list, child);
-
- return list;
-}
-
-void
-glade_gtk_image_menu_item_add_child (GladeWidgetAdaptor * adaptor,
- GObject * object, GObject * child)
-{
- g_return_if_fail (GTK_IS_MENU_ITEM (object));
-
- if (GTK_IS_IMAGE (child))
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (object),
- GTK_WIDGET (child));
- else
- GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->add (adaptor, object, child);
-}
-
-void
-glade_gtk_image_menu_item_remove_child (GladeWidgetAdaptor * adaptor,
- GObject * object, GObject * child)
-{
- g_return_if_fail (GTK_IS_MENU_ITEM (object));
-
- if (GTK_IS_IMAGE (child))
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (object), NULL);
- else
- GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->remove (adaptor, object, child);
-}
-
static void
glade_gtk_image_menu_item_set_use_stock (GObject * object, const GValue * value)
{
@@ -7248,6 +7314,32 @@ glade_gtk_toolbar_set_child_property (GladeWidgetAdaptor * adaptor,
property_name, value);
}
+gboolean
+glade_gtk_toolbar_add_verify (GladeWidgetAdaptor *adaptor,
+ GtkWidget *container,
+ GtkWidget *child,
+ gboolean user_feedback)
+{
+ if (!GTK_IS_TOOL_ITEM (child))
+ {
+ if (user_feedback)
+ {
+ GladeWidgetAdaptor *tool_item_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_TOOL_ITEM);
+
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Only a %s can be added to a %s."),
+ glade_widget_adaptor_get_title (tool_item_adaptor),
+ glade_widget_adaptor_get_title (adaptor));
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
glade_gtk_toolbar_add_child (GladeWidgetAdaptor * adaptor,
GObject * object, GObject * child)
@@ -7416,6 +7508,32 @@ glade_gtk_tool_palette_set_child_property (GladeWidgetAdaptor * adaptor,
property_name, value);
}
+gboolean
+glade_gtk_tool_palette_add_verify (GladeWidgetAdaptor *adaptor,
+ GtkWidget *container,
+ GtkWidget *child,
+ gboolean user_feedback)
+{
+ if (!GTK_IS_TOOL_ITEM_GROUP (child))
+ {
+ if (user_feedback)
+ {
+ GladeWidgetAdaptor *tool_item_group_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_TOOL_ITEM_GROUP);
+
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Only a %s can be added to a %s."),
+ glade_widget_adaptor_get_title (tool_item_group_adaptor),
+ glade_widget_adaptor_get_title (adaptor));
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
glade_gtk_tool_palette_add_child (GladeWidgetAdaptor * adaptor,
GObject * object, GObject * child)
@@ -7521,6 +7639,32 @@ glade_gtk_tool_palette_action_activate (GladeWidgetAdaptor * adaptor,
}
/* ----------------------------- GtkToolItemGroup ------------------------------ */
+gboolean
+glade_gtk_tool_item_group_add_verify (GladeWidgetAdaptor *adaptor,
+ GtkWidget *container,
+ GtkWidget *child,
+ gboolean user_feedback)
+{
+ if (!GTK_IS_TOOL_ITEM (child))
+ {
+ if (user_feedback)
+ {
+ GladeWidgetAdaptor *tool_item_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_TOOL_ITEM);
+
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Only a %s can be added to a %s."),
+ glade_widget_adaptor_get_title (tool_item_adaptor),
+ glade_widget_adaptor_get_title (adaptor));
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
glade_gtk_tool_item_group_add_child (GladeWidgetAdaptor * adaptor,
GObject * object, GObject * child)
@@ -7890,6 +8034,32 @@ glade_gtk_menu_tool_button_get_children (GladeWidgetAdaptor * adaptor,
return list;
}
+gboolean
+glade_gtk_menu_tool_button_add_verify (GladeWidgetAdaptor *adaptor,
+ GtkWidget *container,
+ GtkWidget *child,
+ gboolean user_feedback)
+{
+ if (!GTK_IS_MENU (child))
+ {
+ if (user_feedback)
+ {
+ GladeWidgetAdaptor *menu_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_MENU);
+
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Only a %s can be added to a %s."),
+ glade_widget_adaptor_get_title (menu_adaptor),
+ glade_widget_adaptor_get_title (adaptor));
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
glade_gtk_menu_tool_button_add_child (GladeWidgetAdaptor * adaptor,
GObject * object, GObject * child)
@@ -7901,8 +8071,6 @@ glade_gtk_menu_tool_button_add_child (GladeWidgetAdaptor * adaptor,
gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (object),
GTK_WIDGET (child));
}
- else
- GWA_GET_CLASS (GTK_TYPE_TOOL_BUTTON)->add (adaptor, object, child);
}
void
@@ -7915,8 +8083,6 @@ glade_gtk_menu_tool_button_remove_child (GladeWidgetAdaptor * adaptor,
g_object_set_data (child, "special-child-type", NULL);
}
- else
- GWA_GET_CLASS (GTK_TYPE_TOOL_BUTTON)->remove (adaptor, object, child);
}
void
@@ -10939,6 +11105,32 @@ glade_gtk_cell_renderer_read_widget (GladeWidgetAdaptor * adaptor,
}
/*--------------------------- GtkCellLayout ---------------------------------*/
+gboolean
+glade_gtk_cell_layout_add_verify (GladeWidgetAdaptor *adaptor,
+ GtkWidget *container,
+ GtkWidget *child,
+ gboolean user_feedback)
+{
+ if (!GTK_IS_CELL_RENDERER (child))
+ {
+ if (user_feedback)
+ {
+ GladeWidgetAdaptor *cell_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_CELL_RENDERER);
+
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Only a %s can be added to a %s."),
+ glade_widget_adaptor_get_title (cell_adaptor),
+ glade_widget_adaptor_get_title (adaptor));
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
glade_gtk_cell_layout_add_child (GladeWidgetAdaptor * adaptor,
GObject * container, GObject * child)
@@ -11659,6 +11851,32 @@ glade_gtk_action_post_create (GladeWidgetAdaptor * adaptor,
}
/*--------------------------- GtkActionGroup ---------------------------------*/
+gboolean
+glade_gtk_action_group_add_verify (GladeWidgetAdaptor *adaptor,
+ GtkWidget *container,
+ GtkWidget *child,
+ gboolean user_feedback)
+{
+ if (!GTK_IS_ACTION (child))
+ {
+ if (user_feedback)
+ {
+ GladeWidgetAdaptor *action_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_ACTION);
+
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Only a %s can be added to a %s."),
+ glade_widget_adaptor_get_title (action_adaptor),
+ glade_widget_adaptor_get_title (adaptor));
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
glade_gtk_action_group_add_child (GladeWidgetAdaptor * adaptor,
GObject * container, GObject * child)
@@ -11837,6 +12055,32 @@ glade_gtk_action_action_activate (GladeWidgetAdaptor *adaptor,
/*--------------------------- GtkTextTagTable ---------------------------------*/
+gboolean
+glade_gtk_text_tag_table_add_verify (GladeWidgetAdaptor *adaptor,
+ GtkWidget *container,
+ GtkWidget *child,
+ gboolean user_feedback)
+{
+ if (!GTK_IS_TEXT_TAG (child))
+ {
+ if (user_feedback)
+ {
+ GladeWidgetAdaptor *tag_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_TEXT_TAG);
+
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Only a %s can be added to a %s."),
+ glade_widget_adaptor_get_title (tag_adaptor),
+ glade_widget_adaptor_get_title (adaptor));
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
glade_gtk_text_tag_table_add_child (GladeWidgetAdaptor * adaptor,
GObject * container, GObject * child)
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 63cd97c..639a356 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -281,7 +281,7 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkContainer" _title="Container" use-placeholders="True">
<post-create-function>glade_gtk_container_post_create</post-create-function>
-
+ <add-child-verify-function>glade_gtk_container_add_verify</add-child-verify-function>
<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>
@@ -443,6 +443,7 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkMenuShell" _title="Menu Shell" use-placeholders="False" since="2.16">
<post-create-function>empty</post-create-function>
+ <add-child-verify-function>glade_gtk_menu_shell_add_verify</add-child-verify-function>
<add-child-function>glade_gtk_menu_shell_add_child</add-child-function>
<remove-child-function>glade_gtk_menu_shell_remove_child</remove-child-function>
<child-set-property-function>glade_gtk_menu_shell_set_child_property</child-set-property-function>
@@ -470,6 +471,7 @@ embedded in another object</_tooltip>
<post-create-function>glade_gtk_menu_item_post_create</post-create-function>
<get-children-function>glade_gtk_menu_item_get_children</get-children-function>
<set-property-function>glade_gtk_menu_item_set_property</set-property-function>
+ <add-child-verify-function>glade_gtk_menu_item_add_verify</add-child-verify-function>
<add-child-function>glade_gtk_menu_item_add_child</add-child-function>
<remove-child-function>glade_gtk_menu_item_remove_child</remove-child-function>
<action-activate-function>glade_gtk_menu_item_action_activate</action-activate-function>
@@ -507,9 +509,6 @@ embedded in another object</_tooltip>
<read-widget-function>glade_gtk_image_menu_item_read_widget</read-widget-function>
<write-widget-function>glade_gtk_image_menu_item_write_widget</write-widget-function>
<set-property-function>glade_gtk_image_menu_item_set_property</set-property-function>
- <get-children-function>glade_gtk_image_menu_item_get_children</get-children-function>
- <add-child-function>glade_gtk_image_menu_item_add_child</add-child-function>
- <remove-child-function>glade_gtk_image_menu_item_remove_child</remove-child-function>
<create-editable-function>glade_gtk_image_menu_item_create_editable</create-editable-function>
<properties>
<property id="use-stock" default="True" visible="False" save-always="True" since="2.16"/>
@@ -569,6 +568,7 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkToolbar" generic-name="toolbar" _title="Tool Bar" use-placeholders="False">
<post-create-function>glade_gtk_toolbar_post_create</post-create-function>
+ <add-child-verify-function>glade_gtk_toolbar_add_verify</add-child-verify-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>
@@ -619,6 +619,7 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkToolPalette" generic-name="toolpalette" _title="Tool Palette"
use-placeholders="False" since="2.20">
<post-create-function>glade_gtk_toolbar_post_create</post-create-function>
+ <add-child-verify-function>glade_gtk_tool_palette_add_verify</add-child-verify-function>
<add-child-function>glade_gtk_tool_palette_add_child</add-child-function>
<remove-child-function>glade_gtk_tool_palette_remove_child</remove-child-function>
<child-set-property-function>glade_gtk_tool_palette_set_child_property</child-set-property-function>
@@ -661,6 +662,7 @@ embedded in another object</_tooltip>
use-placeholders="False" since="2.20">
<post-create-function>empty</post-create-function>
<set-property-function>glade_gtk_tool_item_group_set_property</set-property-function>
+ <add-child-verify-function>glade_gtk_tool_item_group_add_verify</add-child-verify-function>
<add-child-function>glade_gtk_tool_item_group_add_child</add-child-function>
<remove-child-function>glade_gtk_tool_item_group_remove_child</remove-child-function>
<create-editable-function>glade_gtk_tool_item_group_create_editable</create-editable-function>
@@ -754,6 +756,7 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkMenuToolButton" generic-name="menutoolbutton" use-placeholders="False"
_title="Menu Tool Button">
+ <add-child-verify-function>glade_gtk_menu_tool_button_add_verify</add-child-verify-function>
<add-child-function>glade_gtk_menu_tool_button_add_child</add-child-function>
<remove-child-function>glade_gtk_menu_tool_button_remove_child</remove-child-function>
<replace-child-function>glade_gtk_menu_tool_button_replace_child</replace-child-function>
@@ -1155,6 +1158,7 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkComboBox" generic-name="combobox" _title="Combo Box">
<post-create-function>glade_gtk_combo_box_post_create</post-create-function>
<set-property-function>glade_gtk_combo_box_set_property</set-property-function>
+ <add-child-verify-function>glade_gtk_cell_layout_add_verify</add-child-verify-function>
<add-child-function>glade_gtk_cell_layout_add_child</add-child-function>
<remove-child-function>glade_gtk_cell_layout_remove_child</remove-child-function>
<get-children-function>glade_gtk_combo_box_get_children</get-children-function>
@@ -1925,6 +1929,7 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkActionGroup" generic-name="actiongroup" _title="Action Group"
toplevel="True" use-placeholders="False">
+ <add-child-verify-function>glade_gtk_action_group_add_verify</add-child-verify-function>
<add-child-function>glade_gtk_action_group_add_child</add-child-function>
<remove-child-function>glade_gtk_action_group_remove_child</remove-child-function>
<get-children-function>glade_gtk_action_group_get_children</get-children-function>
@@ -2060,6 +2065,7 @@ embedded in another object</_tooltip>
</glade-widget-class>
<glade-widget-class name="GtkTreeViewColumn" generic-name="treeviewcolumn" _title="Tree View Column">
+ <add-child-verify-function>glade_gtk_cell_layout_add_verify</add-child-verify-function>
<add-child-function>glade_gtk_cell_layout_add_child</add-child-function>
<remove-child-function>glade_gtk_cell_layout_remove_child</remove-child-function>
<get-children-function>glade_gtk_cell_layout_get_children</get-children-function>
@@ -2102,6 +2108,7 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkIconView" generic-name="iconview" _title="Icon View">
<post-create-function>empty</post-create-function>
+ <add-child-verify-function>glade_gtk_cell_layout_add_verify</add-child-verify-function>
<add-child-function>glade_gtk_cell_layout_add_child</add-child-function>
<remove-child-function>glade_gtk_cell_layout_remove_child</remove-child-function>
<get-children-function>glade_gtk_cell_layout_get_children</get-children-function>
@@ -3355,6 +3362,7 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkTextTagTable" generic-name="texttagtable" _title="Text Tag Table"
toplevel="True">
+ <add-child-verify-function>glade_gtk_text_tag_table_add_verify</add-child-verify-function>
<add-child-function>glade_gtk_text_tag_table_add_child</add-child-function>
<remove-child-function>glade_gtk_text_tag_table_remove_child</remove-child-function>
<get-children-function>glade_gtk_text_tag_table_get_children</get-children-function>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]