diff options
author | Matthias Clasen <maclas@gmx.de> | 2003-09-21 22:04:48 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2003-09-21 22:04:48 +0000 |
commit | d381967d5ccb39a1b5dc94cbc01379143c917eb8 (patch) | |
tree | 8256261a7140d2f49e5c371e6ef613d1f58785a6 /gtk/gtktoggleaction.c | |
parent | 8be8d7f61dd77ae9331c92ec692350e7947c6340 (diff) | |
download | gtk+-d381967d5ccb39a1b5dc94cbc01379143c917eb8.tar.gz |
Changes to make cross-process merging feasible:
2003-09-21 Matthias Clasen <maclas@gmx.de>
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.
Diffstat (limited to 'gtk/gtktoggleaction.c')
-rw-r--r-- | gtk/gtktoggleaction.c | 132 |
1 files changed, 127 insertions, 5 deletions
diff --git a/gtk/gtktoggleaction.c b/gtk/gtktoggleaction.c index 51f5113e50..ec41db5ebc 100644 --- a/gtk/gtktoggleaction.c +++ b/gtk/gtktoggleaction.c @@ -30,6 +30,7 @@ #include <config.h> +#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); +} |