diff options
author | Jody Goldberg <jody@gnome.org> | 2004-01-02 23:14:28 +0000 |
---|---|---|
committer | Jody Goldberg <jody@src.gnome.org> | 2004-01-02 23:14:28 +0000 |
commit | 9acc941959dfb420645e8ba033a2b15ce0821c16 (patch) | |
tree | 7ef30ec4135c6be6dbc3a8f734af0c25ecdda9db /gtk | |
parent | df6a099ea9c099e304af7e75fc22d00a1c538b54 (diff) | |
download | gtk+-9acc941959dfb420645e8ba033a2b15ce0821c16.tar.gz |
add visible_horizontal, visible_vertical. (gtk_action_class_init) : here.
2004-01-01 Jody Goldberg <jody@gnome.org>
* gtk/gtkaction.c (_GtkActionPrivate) : add visible_horizontal,
visible_vertical.
(gtk_action_class_init) : here.
(gtk_action_init) : here.
(gtk_action_set_property) : here.
(gtk_action_get_property) : here.
(connect_proxy) : and here.
2003-12-30 Jody Goldberg <jody@gnome.org>
* gtk/gtkactiongroup.c (gtk_action_group_add_action_with_accel) : new
utility routine for use in derived GtkActions with the replicated code
from.
(gtk_action_group_add_actions_full) : here.
(gtk_action_group_add_toggle_actions_full) : here.
(gtk_action_group_add_radio_actions_full) : and here.
2003-12-24 Jody Goldberg <jody@gnome.org>
* gtk/gtkactiongroup.h : Add some const to the char * in
GtkActionEntry*. We're reccomending people pass static strings to
them, and not freeing them. This stems to flood of warnings that
result.
* gtk/gtkactiongroup.c (gtk_action_group_add_actions_full) : change
temp vars to const to match above.
(gtk_action_group_add_toggle_actions_full) : ditto.
(gtk_action_group_add_radio_actions_full) : ditto.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkaction.c | 40 | ||||
-rw-r--r-- | gtk/gtkactiongroup.c | 147 | ||||
-rw-r--r-- | gtk/gtkactiongroup.h | 36 |
3 files changed, 129 insertions, 94 deletions
diff --git a/gtk/gtkaction.c b/gtk/gtkaction.c index 19730370f6..b0db28361a 100644 --- a/gtk/gtkaction.c +++ b/gtk/gtkaction.c @@ -59,6 +59,8 @@ struct _GtkActionPrivate guint visible : 1; guint label_set : 1; /* these two used so we can set label */ guint short_label_set : 1; /* based on stock id */ + guint visible_horizontal : 1; + guint visible_vertical : 1; guint is_important : 1; guint hide_if_empty : 1; @@ -88,6 +90,8 @@ enum PROP_SHORT_LABEL, PROP_TOOLTIP, PROP_STOCK_ID, + PROP_VISIBLE_HORIZONTAL, + PROP_VISIBLE_VERTICAL, PROP_IS_IMPORTANT, PROP_HIDE_IF_EMPTY, PROP_SENSITIVE, @@ -216,6 +220,20 @@ gtk_action_class_init (GtkActionClass *klass) NULL, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, + PROP_VISIBLE_HORIZONTAL, + g_param_spec_boolean ("visible_horizontal", + _("Visible when horizontal"), + _("Whether the toolbar item is visible when the toolbar is in a horizontal orientation."), + TRUE, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_VISIBLE_VERTICAL, + g_param_spec_boolean ("visible_vertical", + _("Visible when vertical"), + _("Whether the toolbar item is visible when the toolbar is in a vertical orientation."), + TRUE, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, PROP_IS_IMPORTANT, g_param_spec_boolean ("is_important", _("Is important"), @@ -315,6 +333,8 @@ gtk_action_init (GtkAction *action) action->private_data->short_label = NULL; action->private_data->tooltip = NULL; action->private_data->stock_id = NULL; + action->private_data->visible_horizontal = TRUE; + action->private_data->visible_vertical = TRUE; action->private_data->is_important = FALSE; action->private_data->hide_if_empty = TRUE; @@ -436,6 +456,12 @@ gtk_action_set_property (GObject *object, g_object_notify (object, "short_label"); } break; + case PROP_VISIBLE_HORIZONTAL: + action->private_data->visible_horizontal = g_value_get_boolean (value); + break; + case PROP_VISIBLE_VERTICAL: + action->private_data->visible_vertical = g_value_get_boolean (value); + break; case PROP_IS_IMPORTANT: action->private_data->is_important = g_value_get_boolean (value); break; @@ -481,6 +507,12 @@ gtk_action_get_property (GObject *object, case PROP_STOCK_ID: g_value_set_string (value, action->private_data->stock_id); break; + case PROP_VISIBLE_HORIZONTAL: + g_value_set_boolean (value, action->private_data->visible_horizontal); + break; + case PROP_VISIBLE_VERTICAL: + g_value_set_boolean (value, action->private_data->visible_vertical); + break; case PROP_IS_IMPORTANT: g_value_set_boolean (value, action->private_data->is_important); break; @@ -782,6 +814,8 @@ connect_proxy (GtkAction *action, "label", action->private_data->short_label, "use_underline", TRUE, "stock_id", action->private_data->stock_id, + "visible_horizontal", action->private_data->visible_horizontal, + "visible_vertical", action->private_data->visible_vertical, "is_important", action->private_data->is_important, NULL); /* FIXME: we should set the tooltip here, but the current api @@ -793,6 +827,12 @@ connect_proxy (GtkAction *action, g_signal_connect_object (action, "notify::stock_id", G_CALLBACK (gtk_action_sync_property), proxy, 0); + g_signal_connect_object (action, "notify::visible_horizontal", + G_CALLBACK (gtk_action_sync_property), + proxy, 0); + g_signal_connect_object (action, "notify::visible_vertical", + G_CALLBACK (gtk_action_sync_property), + proxy, 0); g_signal_connect_object (action, "notify::is_important", G_CALLBACK (gtk_action_sync_property), proxy, 0); diff --git a/gtk/gtkactiongroup.c b/gtk/gtkactiongroup.c index 83768473c7..bac151efdc 100644 --- a/gtk/gtkactiongroup.c +++ b/gtk/gtkactiongroup.c @@ -294,6 +294,56 @@ gtk_action_group_add_action (GtkActionGroup *action_group, } /** + * gtk_action_group_add_action_with_accel: + * @action_group: the action group (#GtkActionGroup) + * @action : the action to add (#GtkAction) + * @name : + * @accelerator : + * @stock_id : + * + * Adds an action object to the action group and sets up the accelerator. + * + * If @accelerator is NULL, attempt to use the accelerator associated with + * @stock_id. + * + * accel paths are set to + * <literal><Actions>/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>. + * + * Since: 2.4 + */ +void +gtk_action_group_add_action_with_accel (GtkActionGroup *action_group, + GtkAction *action, + const char *name, + const char *accelerator, + const char *stock_id) +{ + gchar *accel_path; + guint accel_key = 0; + GdkModifierType accel_mods; + GtkStockItem stock_item; + + accel_path = g_strconcat ("<Actions>/", + action_group->private_data->name, "/", name, NULL); + + if (accelerator) + gtk_accelerator_parse (accelerator, &accel_key, &accel_mods); + else if (stock_id && gtk_stock_lookup (stock_id, &stock_item)) + { + accel_key = stock_item.keyval; + accel_mods = stock_item.modifier; + } + + if (accel_key) + gtk_accel_map_add_entry (accel_path, accel_key, accel_mods); + + gtk_action_set_accel_path (action, accel_path); + g_free (accel_path); + + gtk_action_group_add_action (action_group, action); +} + +/** * gtk_action_group_remove_action: * @action_group: the action group * @action: an action @@ -412,12 +462,8 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group, for (i = 0; i < n_entries; i++) { GtkAction *action; - gchar *accel_path; - guint accel_key = 0; - GdkModifierType accel_mods; - GtkStockItem stock_item; - gchar *label; - gchar *tooltip; + const gchar *label; + const gchar *tooltip; if (translate_func) { @@ -442,26 +488,10 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group, entries[i].callback, user_data, (GClosureNotify)destroy, 0); - /* set the accel path for the menu item */ - accel_path = g_strconcat ("<Actions>/", action_group->private_data->name, "/", - entries[i].name, NULL); - - if (entries[i].accelerator) - gtk_accelerator_parse (entries[i].accelerator, &accel_key, &accel_mods); - else if (entries[i].stock_id && - gtk_stock_lookup (entries[i].stock_id, &stock_item)) - { - accel_key = stock_item.keyval; - accel_mods = stock_item.modifier; - } - - if (accel_key) - gtk_accel_map_add_entry (accel_path, accel_key, accel_mods); - - gtk_action_set_accel_path (action, accel_path); - g_free (accel_path); - - gtk_action_group_add_action (action_group, action); + gtk_action_group_add_action_with_accel (action_group, action, + entries[i].name, + entries[i].accelerator, + entries[i].stock_id); g_object_unref (action); } } @@ -529,12 +559,8 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group, for (i = 0; i < n_entries; i++) { GtkAction *action; - gchar *accel_path; - guint accel_key = 0; - GdkModifierType accel_mods; - GtkStockItem stock_item; - gchar *label; - gchar *tooltip; + const gchar *label; + const gchar *tooltip; if (translate_func) { @@ -562,26 +588,10 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group, entries[i].callback, user_data, (GClosureNotify)destroy, 0); - /* set the accel path for the menu item */ - accel_path = g_strconcat ("<Actions>/", action_group->private_data->name, "/", - entries[i].name, NULL); - - if (entries[i].accelerator) - gtk_accelerator_parse (entries[i].accelerator, &accel_key, &accel_mods); - else if (entries[i].stock_id && - gtk_stock_lookup (entries[i].stock_id, &stock_item)) - { - accel_key = stock_item.keyval; - accel_mods = stock_item.modifier; - } - - if (accel_key) - gtk_accel_map_add_entry (accel_path, accel_key, accel_mods); - - gtk_action_set_accel_path (action, accel_path); - g_free (accel_path); - - gtk_action_group_add_action (action_group, action); + gtk_action_group_add_action_with_accel (action_group, action, + entries[i].name, + entries[i].accelerator, + entries[i].stock_id); g_object_unref (action); } } @@ -661,12 +671,8 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group, for (i = 0; i < n_entries; i++) { GtkAction *action; - gchar *accel_path; - guint accel_key = 0; - GdkModifierType accel_mods; - GtkStockItem stock_item; - gchar *label; - gchar *tooltip; + const gchar *label; + const gchar *tooltip; if (translate_func) { @@ -695,28 +701,11 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group, if (value == entries[i].value) gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); - - /* set the accel path for the menu item */ - accel_path = g_strconcat ("<Actions>/", - action_group->private_data->name, "/", - entries[i].name, NULL); - - if (entries[i].accelerator) - gtk_accelerator_parse (entries[i].accelerator, &accel_key, &accel_mods); - else if (entries[i].stock_id && - gtk_stock_lookup (entries[i].stock_id, &stock_item)) - { - accel_key = stock_item.keyval; - accel_mods = stock_item.modifier; - } - if (accel_key) - gtk_accel_map_add_entry (accel_path, accel_key, accel_mods); - - gtk_action_set_accel_path (action, accel_path); - g_free (accel_path); - - gtk_action_group_add_action (action_group, action); + gtk_action_group_add_action_with_accel (action_group, action, + entries[i].name, + entries[i].accelerator, + entries[i].stock_id); g_object_unref (action); } diff --git a/gtk/gtkactiongroup.h b/gtk/gtkactiongroup.h index 7d8b4be203..bd4ff94f69 100644 --- a/gtk/gtkactiongroup.h +++ b/gtk/gtkactiongroup.h @@ -74,32 +74,32 @@ struct _GtkActionGroupClass struct _GtkActionEntry { - gchar *name; - gchar *stock_id; - gchar *label; - gchar *accelerator; - gchar *tooltip; + const gchar *name; + const gchar *stock_id; + const gchar *label; + const gchar *accelerator; + const gchar *tooltip; GCallback callback; }; struct _GtkToggleActionEntry { - gchar *name; - gchar *stock_id; - gchar *label; - gchar *accelerator; - gchar *tooltip; + const gchar *name; + const gchar *stock_id; + const gchar *label; + const gchar *accelerator; + const gchar *tooltip; GCallback callback; gboolean is_active; }; struct _GtkRadioActionEntry { - gchar *name; - gchar *stock_id; - gchar *label; - gchar *accelerator; - gchar *tooltip; + const gchar *name; + const gchar *stock_id; + const gchar *label; + const gchar *accelerator; + const gchar *tooltip; gint value; }; @@ -111,6 +111,12 @@ GtkAction *gtk_action_group_get_action (GtkActionGroup * GList *gtk_action_group_list_actions (GtkActionGroup *action_group); void gtk_action_group_add_action (GtkActionGroup *action_group, GtkAction *action); +void gtk_action_group_add_action_with_accel (GtkActionGroup *action_group, + GtkAction *action, + const char *name, + const char *accelerator, + const char *stock_id); + void gtk_action_group_remove_action (GtkActionGroup *action_group, GtkAction *action); void gtk_action_group_add_actions (GtkActionGroup *action_group, |