From: Matthias Clasen Date: Sun, 21 Sep 2003 22:04:48 +0000 (+0000) Subject: Changes to make cross-process merging feasible: X-Git-Url: http://pileus.org/git/?a=commitdiff_plain;h=d381967d5ccb39a1b5dc94cbc01379143c917eb8;p=~andy%2Fgtk Changes to make cross-process merging feasible: 2003-09-21 Matthias Clasen Changes to make cross-process merging feasible: * gtk/gtkuimanager.[hc]: Add a readonly "ui" property which holds the merged UI definition. Remove the "changed" signal, since its role is now filled by "notify::ui". Instead add a "actions-changed" signal which gets emitted when the set of actions changes. * gtk/gtktoggleactionprivate.h: * gtk/gtktoggleaction.[hc] (gtk_toggle_action_[sg]et_draw_as_radio): Add a "draw_as_radio" property to toggle actions so that they can be used as proxies for radio actions much like the "draw_as_radio" property on check menu items enables them to operate as proxies for radio actions. Prevent the "show_all" trap for action-based menus (see http://mail.gnome.org/archives/gtk-devel-list/2003-September/ msg00260.html): * gtk/gtkmenu.c (gtk_menu_{hide,show}_all): Remove g_return_if_fail() calls from static functions. * gtk/gtkuimanager.c (update_node): * gtk/gtkaction.c (connect_proxy): Set "no_show_all" on constructed widgets whose visibility is externally controlled. * gtk/gtkwidget.[hc] (gtk_widget_[gs]et_no_show_all): Add a boolean "no_show_all" property with setter and getter. When TRUE, it keeps gtk_widget_{hide,show}_all() from modifying the visibility of the widget and its children. --- diff --git a/ChangeLog b/ChangeLog index 5e58a8ce0..fb03cd1d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2003-09-21 Matthias Clasen + + Changes to make cross-process merging feasible: + + * gtk/gtkuimanager.[hc]: Add a readonly "ui" property which holds the + merged UI definition. Remove the "changed" signal, since its role + is now filled by "notify::ui". Instead add a "actions-changed" signal + which gets emitted when the set of actions changes. + + * gtk/gtktoggleactionprivate.h: + * gtk/gtktoggleaction.[hc] (gtk_toggle_action_[sg]et_draw_as_radio): + Add a "draw_as_radio" property to toggle actions so that they can be + used as proxies for radio actions much like the "draw_as_radio" + property on check menu items enables them to operate as proxies for + radio actions. + + Prevent the "show_all" trap for action-based menus (see + http://mail.gnome.org/archives/gtk-devel-list/2003-September/ + msg00260.html): + + * gtk/gtkmenu.c (gtk_menu_{hide,show}_all): Remove g_return_if_fail() + calls from static functions. + + * gtk/gtkuimanager.c (update_node): + * gtk/gtkaction.c (connect_proxy): Set "no_show_all" on constructed + widgets whose visibility is externally controlled. + + * gtk/gtkwidget.[hc] (gtk_widget_[gs]et_no_show_all): Add a boolean + "no_show_all" property with setter and getter. When TRUE, it keeps + gtk_widget_{hide,show}_all() from modifying the visibility of the + widget and its children. + Sun Sep 21 23:13:37 2003 Soeren Sandmann * gtk/gtktextview.[ch]: Add new "tab moves focus" property (#122709) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 5e58a8ce0..fb03cd1d9 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,35 @@ +2003-09-21 Matthias Clasen + + Changes to make cross-process merging feasible: + + * gtk/gtkuimanager.[hc]: Add a readonly "ui" property which holds the + merged UI definition. Remove the "changed" signal, since its role + is now filled by "notify::ui". Instead add a "actions-changed" signal + which gets emitted when the set of actions changes. + + * gtk/gtktoggleactionprivate.h: + * gtk/gtktoggleaction.[hc] (gtk_toggle_action_[sg]et_draw_as_radio): + Add a "draw_as_radio" property to toggle actions so that they can be + used as proxies for radio actions much like the "draw_as_radio" + property on check menu items enables them to operate as proxies for + radio actions. + + Prevent the "show_all" trap for action-based menus (see + http://mail.gnome.org/archives/gtk-devel-list/2003-September/ + msg00260.html): + + * gtk/gtkmenu.c (gtk_menu_{hide,show}_all): Remove g_return_if_fail() + calls from static functions. + + * gtk/gtkuimanager.c (update_node): + * gtk/gtkaction.c (connect_proxy): Set "no_show_all" on constructed + widgets whose visibility is externally controlled. + + * gtk/gtkwidget.[hc] (gtk_widget_[gs]et_no_show_all): Add a boolean + "no_show_all" property with setter and getter. When TRUE, it keeps + gtk_widget_{hide,show}_all() from modifying the visibility of the + widget and its children. + Sun Sep 21 23:13:37 2003 Soeren Sandmann * gtk/gtktextview.[ch]: Add new "tab moves focus" property (#122709) diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 5e58a8ce0..fb03cd1d9 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,35 @@ +2003-09-21 Matthias Clasen + + Changes to make cross-process merging feasible: + + * gtk/gtkuimanager.[hc]: Add a readonly "ui" property which holds the + merged UI definition. Remove the "changed" signal, since its role + is now filled by "notify::ui". Instead add a "actions-changed" signal + which gets emitted when the set of actions changes. + + * gtk/gtktoggleactionprivate.h: + * gtk/gtktoggleaction.[hc] (gtk_toggle_action_[sg]et_draw_as_radio): + Add a "draw_as_radio" property to toggle actions so that they can be + used as proxies for radio actions much like the "draw_as_radio" + property on check menu items enables them to operate as proxies for + radio actions. + + Prevent the "show_all" trap for action-based menus (see + http://mail.gnome.org/archives/gtk-devel-list/2003-September/ + msg00260.html): + + * gtk/gtkmenu.c (gtk_menu_{hide,show}_all): Remove g_return_if_fail() + calls from static functions. + + * gtk/gtkuimanager.c (update_node): + * gtk/gtkaction.c (connect_proxy): Set "no_show_all" on constructed + widgets whose visibility is externally controlled. + + * gtk/gtkwidget.[hc] (gtk_widget_[gs]et_no_show_all): Add a boolean + "no_show_all" property with setter and getter. When TRUE, it keeps + gtk_widget_{hide,show}_all() from modifying the visibility of the + widget and its children. + Sun Sep 21 23:13:37 2003 Soeren Sandmann * gtk/gtktextview.[ch]: Add new "tab moves focus" property (#122709) diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 5e58a8ce0..fb03cd1d9 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,35 @@ +2003-09-21 Matthias Clasen + + Changes to make cross-process merging feasible: + + * gtk/gtkuimanager.[hc]: Add a readonly "ui" property which holds the + merged UI definition. Remove the "changed" signal, since its role + is now filled by "notify::ui". Instead add a "actions-changed" signal + which gets emitted when the set of actions changes. + + * gtk/gtktoggleactionprivate.h: + * gtk/gtktoggleaction.[hc] (gtk_toggle_action_[sg]et_draw_as_radio): + Add a "draw_as_radio" property to toggle actions so that they can be + used as proxies for radio actions much like the "draw_as_radio" + property on check menu items enables them to operate as proxies for + radio actions. + + Prevent the "show_all" trap for action-based menus (see + http://mail.gnome.org/archives/gtk-devel-list/2003-September/ + msg00260.html): + + * gtk/gtkmenu.c (gtk_menu_{hide,show}_all): Remove g_return_if_fail() + calls from static functions. + + * gtk/gtkuimanager.c (update_node): + * gtk/gtkaction.c (connect_proxy): Set "no_show_all" on constructed + widgets whose visibility is externally controlled. + + * gtk/gtkwidget.[hc] (gtk_widget_[gs]et_no_show_all): Add a boolean + "no_show_all" property with setter and getter. When TRUE, it keeps + gtk_widget_{hide,show}_all() from modifying the visibility of the + widget and its children. + Sun Sep 21 23:13:37 2003 Soeren Sandmann * gtk/gtktextview.[ch]: Add new "tab moves focus" property (#122709) diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 5e58a8ce0..fb03cd1d9 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,35 @@ +2003-09-21 Matthias Clasen + + Changes to make cross-process merging feasible: + + * gtk/gtkuimanager.[hc]: Add a readonly "ui" property which holds the + merged UI definition. Remove the "changed" signal, since its role + is now filled by "notify::ui". Instead add a "actions-changed" signal + which gets emitted when the set of actions changes. + + * gtk/gtktoggleactionprivate.h: + * gtk/gtktoggleaction.[hc] (gtk_toggle_action_[sg]et_draw_as_radio): + Add a "draw_as_radio" property to toggle actions so that they can be + used as proxies for radio actions much like the "draw_as_radio" + property on check menu items enables them to operate as proxies for + radio actions. + + Prevent the "show_all" trap for action-based menus (see + http://mail.gnome.org/archives/gtk-devel-list/2003-September/ + msg00260.html): + + * gtk/gtkmenu.c (gtk_menu_{hide,show}_all): Remove g_return_if_fail() + calls from static functions. + + * gtk/gtkuimanager.c (update_node): + * gtk/gtkaction.c (connect_proxy): Set "no_show_all" on constructed + widgets whose visibility is externally controlled. + + * gtk/gtkwidget.[hc] (gtk_widget_[gs]et_no_show_all): Add a boolean + "no_show_all" property with setter and getter. When TRUE, it keeps + gtk_widget_{hide,show}_all() from modifying the visibility of the + widget and its children. + Sun Sep 21 23:13:37 2003 Soeren Sandmann * gtk/gtktextview.[ch]: Add new "tab moves focus" property (#122709) diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 90e865517..39f267b1c 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,8 @@ +2003-09-21 Matthias Clasen + + * gtk/gtk-sections.txt: Add gtk_widget_[gs]et_no_show_all. + Add gtk_toggle_action_[gs]et_draw_as_radio. + 2003-09-18 Matthias Clasen * gtk/gtk-sections.txt: diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index 6b396f55e..5f2044fe7 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -2893,6 +2893,9 @@ GtkToggleAction gtk_toggle_action_toggled gtk_toggle_action_set_active gtk_toggle_action_get_active +gtk_toggle_action_set_draw_as_radio +gtk_toggle_action_get_draw_as_radio + GTK_TYPE_TOGGLE_ACTION GTK_TOGGLE_ACTION @@ -4032,6 +4035,8 @@ gtk_widget_set_default_visual gtk_widget_set_size_request gtk_widget_set_visual gtk_widget_thaw_child_notify +gtk_widget_set_no_show_all +gtk_widget_get_no_show_all gtk_requisition_copy gtk_requisition_free diff --git a/gtk/gtkaction.c b/gtk/gtkaction.c index adb3c9524..e3ce12e87 100644 --- a/gtk/gtkaction.c +++ b/gtk/gtkaction.c @@ -568,6 +568,7 @@ connect_proxy (GtkAction *action, gtk_widget_show (proxy); else gtk_widget_hide (proxy); + gtk_widget_set_no_show_all (proxy, TRUE); if (GTK_IS_MENU_ITEM (proxy)) { diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index ed0b2e3a3..0c0277a72 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -3540,8 +3540,6 @@ gtk_menu_reparent (GtkMenu *menu, static void gtk_menu_show_all (GtkWidget *widget) { - g_return_if_fail (GTK_IS_MENU (widget)); - /* Show children, but not self. */ gtk_container_foreach (GTK_CONTAINER (widget), (GtkCallback) gtk_widget_show_all, NULL); } @@ -3550,8 +3548,6 @@ gtk_menu_show_all (GtkWidget *widget) static void gtk_menu_hide_all (GtkWidget *widget) { - g_return_if_fail (GTK_IS_MENU (widget)); - /* Hide children, but not self. */ gtk_container_foreach (GTK_CONTAINER (widget), (GtkCallback) gtk_widget_hide_all, NULL); } diff --git a/gtk/gtktoggleaction.c b/gtk/gtktoggleaction.c index 51f5113e5..ec41db5eb 100644 --- a/gtk/gtktoggleaction.c +++ b/gtk/gtktoggleaction.c @@ -30,6 +30,7 @@ #include +#include "gtkintl.h" #include "gtktoggleaction.h" #include "gtktoggleactionprivate.h" #include "gtktoggletoolbutton.h" @@ -42,6 +43,11 @@ enum LAST_SIGNAL }; +enum { + PROP_0, + PROP_DRAW_AS_RADIO +}; + static void gtk_toggle_action_init (GtkToggleAction *action); static void gtk_toggle_action_class_init (GtkToggleActionClass *class); @@ -73,12 +79,22 @@ gtk_toggle_action_get_type (void) return type; } -static void gtk_toggle_action_activate (GtkAction *action); +static void gtk_toggle_action_activate (GtkAction *action); static void gtk_toggle_action_real_toggled (GtkToggleAction *action); -static void connect_proxy (GtkAction *action, - GtkWidget *proxy); -static void disconnect_proxy (GtkAction *action, - GtkWidget *proxy); +static void connect_proxy (GtkAction *action, + GtkWidget *proxy); +static void disconnect_proxy (GtkAction *action, + GtkWidget *proxy); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static GtkWidget *create_menu_item (GtkAction *action); + static GObjectClass *parent_class = NULL; static guint action_signals[LAST_SIGNAL] = { 0 }; @@ -93,6 +109,9 @@ gtk_toggle_action_class_init (GtkToggleActionClass *klass) gobject_class = G_OBJECT_CLASS (klass); action_class = GTK_ACTION_CLASS (klass); + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + action_class->activate = gtk_toggle_action_activate; action_class->connect_proxy = connect_proxy; action_class->disconnect_proxy = disconnect_proxy; @@ -100,8 +119,18 @@ gtk_toggle_action_class_init (GtkToggleActionClass *klass) action_class->menu_item_type = GTK_TYPE_CHECK_MENU_ITEM; action_class->toolbar_item_type = GTK_TYPE_TOGGLE_TOOL_BUTTON; + action_class->create_menu_item = create_menu_item; + klass->toggled = gtk_toggle_action_real_toggled; + g_object_class_install_property (gobject_class, + PROP_DRAW_AS_RADIO, + g_param_spec_boolean ("draw_as_radio", + _("Create the same proxies as a radio action"), + _("Whether the proxies for this action look like radio action proxies"), + FALSE, + G_PARAM_READWRITE)); + action_signals[TOGGLED] = g_signal_new ("toggled", G_OBJECT_CLASS_TYPE (klass), @@ -119,6 +148,46 @@ gtk_toggle_action_init (GtkToggleAction *action) { action->private_data = GTK_TOGGLE_ACTION_GET_PRIVATE (action); action->private_data->active = FALSE; + action->private_data->draw_as_radio = FALSE; +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GtkToggleAction *action = GTK_TOGGLE_ACTION (object); + + switch (prop_id) + { + case PROP_DRAW_AS_RADIO: + g_value_set_boolean (value, gtk_toggle_action_get_draw_as_radio (action)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkToggleAction *action = GTK_TOGGLE_ACTION (object); + + switch (prop_id) + { + case PROP_DRAW_AS_RADIO: + gtk_toggle_action_set_draw_as_radio (action, g_value_get_boolean (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } static void @@ -251,3 +320,56 @@ gtk_toggle_action_get_active (GtkToggleAction *action) return action->private_data->active; } + + +/** + * gtk_toggle_action_set_draw_as_radio: + * @action: the action object + * @draw_as_radio: whether the action should have proxies like a radio + * action + * + * Sets whether the action should have proxies like a radio action. + * + * Since: 2.4 + */ +void +gtk_toggle_action_set_draw_as_radio (GtkToggleAction *action, + gboolean draw_as_radio) +{ + g_return_if_fail (GTK_IS_TOGGLE_ACTION (action)); + + draw_as_radio = draw_as_radio != FALSE; + + if (action->private_data->draw_as_radio != draw_as_radio) + { + action->private_data->draw_as_radio = draw_as_radio; + + g_object_notify (G_OBJECT (action), "draw_as_radio"); + } +} + +/** + * gtk_toggle_action_get_draw_as_radio: + * @action: the action object + * + * Returns: whether the action should have proxies like a radio action. + * + * Since: 2.4 + */ +gboolean +gtk_toggle_action_get_draw_as_radio (GtkToggleAction *action) +{ + g_return_val_if_fail (GTK_IS_TOGGLE_ACTION (action), FALSE); + + return action->private_data->draw_as_radio; +} + +static GtkWidget * +create_menu_item (GtkAction *action) +{ + GtkToggleAction *toggle_action = GTK_TOGGLE_ACTION (action); + + return g_object_new (GTK_TYPE_CHECK_MENU_ITEM, + "draw_as_radio", toggle_action->private_data->draw_as_radio, + NULL); +} diff --git a/gtk/gtktoggleaction.h b/gtk/gtktoggleaction.h index 6c63df832..b4e20f48c 100644 --- a/gtk/gtktoggleaction.h +++ b/gtk/gtktoggleaction.h @@ -65,12 +65,14 @@ struct _GtkToggleActionClass void (*_gtk_reserved4) (void); }; -GType gtk_toggle_action_get_type (void); - -void gtk_toggle_action_toggled (GtkToggleAction *action); -void gtk_toggle_action_set_active (GtkToggleAction *action, - gboolean is_active); -gboolean gtk_toggle_action_get_active (GtkToggleAction *action); +GType gtk_toggle_action_get_type (void); +void gtk_toggle_action_toggled (GtkToggleAction *action); +void gtk_toggle_action_set_active (GtkToggleAction *action, + gboolean is_active); +gboolean gtk_toggle_action_get_active (GtkToggleAction *action); +void gtk_toggle_action_set_draw_as_radio (GtkToggleAction *action, + gboolean draw_as_radio); +gboolean gtk_toggle_action_get_draw_as_radio (GtkToggleAction *action); #endif /* __GTK_TOGGLE_ACTION_H__ */ diff --git a/gtk/gtktoggleactionprivate.h b/gtk/gtktoggleactionprivate.h index 46be800a6..9e1841ad8 100644 --- a/gtk/gtktoggleactionprivate.h +++ b/gtk/gtktoggleactionprivate.h @@ -36,7 +36,8 @@ struct _GtkToggleActionPrivate { - guint active : 1; + guint active : 1; + guint draw_as_radio : 1; }; #endif /* __GTK_TOGGLE_ACTION_PRIVATE_H__ */ diff --git a/gtk/gtkuimanager.c b/gtk/gtkuimanager.c index 203604712..bdb68279c 100644 --- a/gtk/gtkuimanager.c +++ b/gtk/gtkuimanager.c @@ -139,14 +139,15 @@ static void node_remove_ui_reference (Node *node, enum { ADD_WIDGET, - CHANGED, + ACTIONS_CHANGED, LAST_SIGNAL }; enum { PROP_0, - PROP_ADD_TEAROFFS + PROP_ADD_TEAROFFS, + PROP_UI }; static guint merge_signals[LAST_SIGNAL] = { 0 }; @@ -213,8 +214,17 @@ gtk_ui_manager_class_init (GtkUIManagerClass *klass) _("Add tearoffs to menus"), _("Whether tearoff menu items should be added to menus"), FALSE, - G_PARAM_READABLE | G_PARAM_WRITABLE)); - + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_UI, + g_param_spec_string ("ui", + _("Merged UI definition"), + _("An XML string describing the merged UI"), + NULL, + G_PARAM_READABLE)); + + /** * GtkUIManager::add-widget: * @merge: a #GtkUIManager @@ -236,18 +246,20 @@ gtk_ui_manager_class_init (GtkUIManagerClass *klass) GTK_TYPE_WIDGET); /** - * GtkUIManager::changed: + * GtkUIManager::actions-changed: * @merge: a #GtkUIManager * - * The "changed" signal is emitted whenever the merged UI changes. + * The "actions-changed" signal is emitted whenever the set of actions + * changes. * * Since: 2.4 */ - merge_signals[CHANGED] = - g_signal_new ("changed", + merge_signals[ACTIONS_CHANGED] = + g_signal_new ("actions_changed", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (GtkUIManagerClass, changed), NULL, NULL, + G_STRUCT_OFFSET (GtkUIManagerClass, actions_changed), + NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); @@ -335,6 +347,9 @@ gtk_ui_manager_get_property (GObject *object, case PROP_ADD_TEAROFFS: g_value_set_boolean (value, self->private_data->add_tearoffs); break; + case PROP_UI: + g_value_set_string (value, gtk_ui_manager_get_ui (self)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -437,6 +452,8 @@ gtk_ui_manager_insert_action_group (GtkUIManager *self, /* dirty all nodes, as action bindings may change */ dirty_all_nodes (self); + + g_signal_emit (self, merge_signals[ACTIONS_CHANGED], 0); } /** @@ -464,6 +481,8 @@ gtk_ui_manager_remove_action_group (GtkUIManager *self, /* dirty all nodes, as action bindings may change */ dirty_all_nodes (self); + + g_signal_emit (self, merge_signals[ACTIONS_CHANGED], 0); } /** @@ -1185,7 +1204,7 @@ add_ui_from_string (GtkUIManager *self, queue_update (self); - g_signal_emit (self, merge_signals[CHANGED], 0); + g_object_notify (G_OBJECT (self), "ui"); return ctx.merge_id; @@ -1416,7 +1435,7 @@ gtk_ui_manager_add_ui (GtkUIManager *self, queue_update (self); - g_signal_emit (self, merge_signals[CHANGED], 0); + g_object_notify (G_OBJECT (self), "ui"); } static gboolean @@ -1449,7 +1468,7 @@ gtk_ui_manager_remove_ui (GtkUIManager *self, queue_update (self); - g_signal_emit (self, merge_signals[CHANGED], 0); + g_object_notify (G_OBJECT (self), "ui"); } /* -------------------- Updates -------------------- */ @@ -1457,7 +1476,7 @@ gtk_ui_manager_remove_ui (GtkUIManager *self, static GtkAction * get_action_by_name (GtkUIManager *merge, - const char *action_name) + const gchar *action_name) { GList *tmp; @@ -1826,6 +1845,7 @@ update_node (GtkUIManager *self, info->proxy = gtk_action_create_menu_item (action); menu = gtk_menu_new (); tearoff = gtk_tearoff_menu_item_new (); + gtk_widget_set_no_show_all (tearoff, TRUE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), tearoff); gtk_menu_item_set_submenu (GTK_MENU_ITEM (info->proxy), menu); gtk_menu_shell_insert (GTK_MENU_SHELL (menushell), info->proxy, pos); @@ -2036,6 +2056,7 @@ update_node (GtkUIManager *self, GtkToolItem *item = gtk_separator_tool_item_new (); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos); info->proxy = GTK_WIDGET (item); + gtk_widget_set_no_show_all (info->proxy, TRUE); g_object_set_data (G_OBJECT (info->proxy), "gtk-separator-mode", GINT_TO_POINTER (SEPARATOR_MODE_SMART)); @@ -2057,6 +2078,7 @@ update_node (GtkUIManager *self, if (find_menu_position (node, &menushell, &pos)) { info->proxy = gtk_separator_menu_item_new (); + gtk_widget_set_no_show_all (info->proxy, TRUE); g_object_set_data (G_OBJECT (info->proxy), "gtk-separator-mode", GINT_TO_POINTER (SEPARATOR_MODE_SMART)); diff --git a/gtk/gtkuimanager.h b/gtk/gtkuimanager.h index 169415941..ee9013f06 100644 --- a/gtk/gtkuimanager.h +++ b/gtk/gtkuimanager.h @@ -61,9 +61,9 @@ struct _GtkUIManager { struct _GtkUIManagerClass { GObjectClass parent_class; - void (* add_widget) (GtkUIManager *merge, - GtkWidget *widget); - void (* changed) (GtkUIManager *merge); + void (* add_widget) (GtkUIManager *merge, + GtkWidget *widget); + void (* actions_changed) (GtkUIManager *merge); /* Padding for future expansion */ void (*_gtk_reserved1) (void); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index f66760307..7edaa5715 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -138,7 +138,8 @@ enum { PROP_COMPOSITE_CHILD, PROP_STYLE, PROP_EVENTS, - PROP_EXTENSION_EVENTS + PROP_EXTENSION_EVENTS, + PROP_NO_SHOW_ALL }; typedef struct _GtkStateData GtkStateData; @@ -521,6 +522,13 @@ gtk_widget_class_init (GtkWidgetClass *klass) GDK_TYPE_EXTENSION_MODE, GDK_EXTENSION_EVENTS_NONE, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_NO_SHOW_ALL, + g_param_spec_boolean ("no_show_all", + _("No show all"), + _("Whether gtk_widget_show_all() should not affect this widget"), + FALSE, + G_PARAM_READWRITE)); widget_signals[SHOW] = g_signal_new ("show", G_TYPE_FROM_CLASS (gobject_class), @@ -1453,6 +1461,9 @@ gtk_widget_set_property (GObject *object, case PROP_EXTENSION_EVENTS: gtk_widget_set_extension_events (widget, g_value_get_enum (value)); break; + case PROP_NO_SHOW_ALL: + gtk_widget_set_no_show_all (widget, g_value_get_boolean (value)); + break; default: break; } @@ -1544,6 +1555,9 @@ gtk_widget_get_property (GObject *object, else g_value_set_enum (value, (GdkExtensionMode) *modep); break; + case PROP_NO_SHOW_ALL: + g_value_set_boolean (value, gtk_widget_get_no_show_all (widget)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -2052,6 +2066,9 @@ gtk_widget_show_all (GtkWidget *widget) g_return_if_fail (GTK_IS_WIDGET (widget)); + if ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0) + return; + class = GTK_WIDGET_GET_CLASS (widget); if (class->show_all) @@ -2071,6 +2088,9 @@ gtk_widget_hide_all (GtkWidget *widget) g_return_if_fail (GTK_IS_WIDGET (widget)); + if ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0) + return; + class = GTK_WIDGET_GET_CLASS (widget); if (class->hide_all) @@ -7210,3 +7230,55 @@ gtk_widget_get_clipboard (GtkWidget *widget, GdkAtom selection) return gtk_clipboard_get_for_display (gtk_widget_get_display (widget), selection); } + +/** + * gtk_widget_get_no_show_all: + * @widget: a #GtkWidget + * + * Returns the current value of the "no_show_all" property, which determines + * whether calls to gtk_widget_show_all() and gtk_widget_hide_all() + * will affect this widget. + * + * Return value: the current value of the "no_show_all" property. + * + * Since: 2.4 + **/ +gboolean +gtk_widget_get_no_show_all (GtkWidget *widget) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); + + return (GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0; +} + +/** + * gtk_widget_set_no_show_all: + * @widget: a #GtkWidget + * @no_show_all: the new value for the "no_show_all" property + * + * Sets the "no_show_all" property, which determines whether calls to + * gtk_widget_show_all() and gtk_widget_hide_all() will affect this widget. + * + * This is mostly for use in constructing widget hierarchies with externally + * controlled visibility, see #GtkUIManager. + * + * Since: 2.4 + **/ +void +gtk_widget_set_no_show_all (GtkWidget *widget, + gboolean no_show_all) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + + no_show_all = (no_show_all != FALSE); + + if (no_show_all == ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0)) + return; + + if (no_show_all) + GTK_WIDGET_SET_FLAGS (widget, GTK_NO_SHOW_ALL); + else + GTK_WIDGET_UNSET_FLAGS (widget, GTK_NO_SHOW_ALL); + + g_object_notify (G_OBJECT (widget), "no_show_all"); +} diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index e2778b397..7aaba5217 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -76,7 +76,8 @@ typedef enum */ GTK_RECEIVES_DEFAULT = 1 << 20, - GTK_DOUBLE_BUFFERED = 1 << 21 + GTK_DOUBLE_BUFFERED = 1 << 21, + GTK_NO_SHOW_ALL = 1 << 22 } GtkWidgetFlags; /* Kinds of widget-specific help */ @@ -449,6 +450,9 @@ void gtk_widget_show_now (GtkWidget *widget); void gtk_widget_hide (GtkWidget *widget); void gtk_widget_show_all (GtkWidget *widget); void gtk_widget_hide_all (GtkWidget *widget); +void gtk_widget_set_no_show_all (GtkWidget *widget, + gboolean no_show_all); +gboolean gtk_widget_get_no_show_all (GtkWidget *widget); void gtk_widget_map (GtkWidget *widget); void gtk_widget_unmap (GtkWidget *widget); void gtk_widget_realize (GtkWidget *widget);