diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-08-12 03:26:24 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-08-12 03:26:24 +0800 |
commit | 1ae9e642b53c3668c4b74e0b043ee6cf861a2b11 (patch) | |
tree | e1b69cae65c218df1894dd800430f7769fb8fcdc /lib | |
parent | f36ca5abdf24b9562532e8743e6069dcb85866f5 (diff) | |
download | gsoc2013-epiphany-1ae9e642b53c3668c4b74e0b043ee6cf861a2b11.tar gsoc2013-epiphany-1ae9e642b53c3668c4b74e0b043ee6cf861a2b11.tar.gz gsoc2013-epiphany-1ae9e642b53c3668c4b74e0b043ee6cf861a2b11.tar.bz2 gsoc2013-epiphany-1ae9e642b53c3668c4b74e0b043ee6cf861a2b11.tar.lz gsoc2013-epiphany-1ae9e642b53c3668c4b74e0b043ee6cf861a2b11.tar.xz gsoc2013-epiphany-1ae9e642b53c3668c4b74e0b043ee6cf861a2b11.tar.zst gsoc2013-epiphany-1ae9e642b53c3668c4b74e0b043ee6cf861a2b11.zip |
Respect priority text preference. Ported from gtk.
2003-08-11 Marco Pesenti Gritti <marco@it.gnome.org>
* lib/egg/egg-action.c: (egg_action_class_init), (egg_action_init),
(egg_action_set_property), (egg_action_get_property),
(egg_action_sync_important), (connect_proxy):
* lib/egg/egg-action.h:
* lib/egg/eggtoolbar.c: (toolbar_item_is_homogeneous),
(egg_toolbar_size_request), (get_item_size):
* lib/egg/eggtoolbutton.c: (egg_tool_button_property_notify),
(egg_tool_button_class_init), (egg_tool_button_construct_contents):
* lib/egg/eggtoolitem.c: (egg_tool_item_class_init),
(egg_tool_item_get_is_important), (egg_tool_item_set_is_important),
(egg_tool_item_set_property), (egg_tool_item_get_property):
* lib/egg/eggtoolitem.h:
* src/ephy-window.c: (setup_window):
* src/toolbar.c: (toolbar_setup_actions):
Respect priority text preference. Ported from gtk.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/egg/egg-action.c | 27 | ||||
-rw-r--r-- | lib/egg/egg-action.h | 1 | ||||
-rw-r--r-- | lib/egg/eggtoolbar.c | 25 | ||||
-rw-r--r-- | lib/egg/eggtoolbutton.c | 28 | ||||
-rw-r--r-- | lib/egg/eggtoolitem.c | 41 | ||||
-rw-r--r-- | lib/egg/eggtoolitem.h | 4 |
6 files changed, 120 insertions, 6 deletions
diff --git a/lib/egg/egg-action.c b/lib/egg/egg-action.c index 054159f45..1fbf44b5b 100644 --- a/lib/egg/egg-action.c +++ b/lib/egg/egg-action.c @@ -26,6 +26,7 @@ enum { PROP_STOCK_ID, PROP_SENSITIVE, PROP_VISIBLE, + PROP_IMPORTANT }; static void egg_action_init (EggAction *action); @@ -152,6 +153,14 @@ egg_action_class_init (EggActionClass *class) G_PARAM_READWRITE)); g_object_class_install_property (object_class, + PROP_IMPORTANT, + g_param_spec_boolean ("important", + _("Important"), + _("Important."), + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_VISIBLE, g_param_spec_boolean ("visible", _("Visible"), @@ -182,6 +191,7 @@ egg_action_init (EggAction *action) action->sensitive = TRUE; action->visible = TRUE; + action->important = FALSE; action->label_set = FALSE; action->short_label_set = FALSE; @@ -296,6 +306,10 @@ egg_action_set_property (GObject *object, case PROP_VISIBLE: action->visible = g_value_get_boolean (value); break; + case PROP_IMPORTANT: + action->important = g_value_get_boolean (value); + g_object_notify(object, "important"); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -335,6 +349,9 @@ egg_action_get_property (GObject *object, case PROP_VISIBLE: g_value_set_boolean (value, action->visible); break; + case PROP_IMPORTANT: + g_value_set_boolean (value, action->important); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -384,6 +401,12 @@ egg_action_sync_property (EggAction *action, GParamSpec *pspec, } static void +egg_action_sync_important (EggAction *action, GParamSpec *pspec, GtkWidget *proxy) +{ + egg_tool_item_set_is_important (EGG_TOOL_ITEM (proxy), action->important); +} + +static void egg_action_sync_tooltip (EggAction *action, GParamSpec *pspec, GtkWidget *proxy) { if (action->tooltip != NULL) @@ -550,6 +573,10 @@ connect_proxy (EggAction *action, GtkWidget *proxy) G_CALLBACK (egg_action_sync_short_label), proxy, 0); + egg_action_sync_important (action, NULL, proxy); + g_signal_connect_object (action, "notify::important", + G_CALLBACK (egg_action_sync_important), proxy, 0); + g_object_set (G_OBJECT (proxy), "stock_id", action->stock_id, NULL); g_signal_connect_object (action, "notify::stock_id", G_CALLBACK (egg_action_sync_property), proxy, 0); diff --git a/lib/egg/egg-action.h b/lib/egg/egg-action.h index 0b678d208..994d4f846 100644 --- a/lib/egg/egg-action.h +++ b/lib/egg/egg-action.h @@ -23,6 +23,7 @@ struct _EggAction gchar *tooltip; gchar *stock_id; /* icon */ + guint important : 1; guint sensitive : 1; guint visible : 1; guint label_set : 1; /* these two used so we can set label */ diff --git a/lib/egg/eggtoolbar.c b/lib/egg/eggtoolbar.c index 87e3fa592..dcad2f9f6 100644 --- a/lib/egg/eggtoolbar.c +++ b/lib/egg/eggtoolbar.c @@ -579,6 +579,25 @@ toolbar_item_visible (EggToolbar *toolbar, return FALSE; } +static gboolean +toolbar_item_is_homogeneous (EggToolbar *toolbar, + EggToolItem *item) +{ + gboolean result = FALSE; + + if (item->homogeneous && !EGG_IS_SEPARATOR_TOOL_ITEM (item)) + result = TRUE; + + if (item->is_important && + toolbar->style == GTK_TOOLBAR_BOTH_HORIZ && + toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) + { + result = FALSE; + } + + return result; +} + static void egg_toolbar_set_property (GObject *object, guint prop_id, @@ -839,7 +858,7 @@ egg_toolbar_size_request (GtkWidget *widget, max_child_width = MAX (max_child_width, requisition.width); max_child_height = MAX (max_child_height, requisition.height); - if (EGG_TOOL_ITEM (item)->homogeneous && GTK_BIN (item)->child) + if (toolbar_item_is_homogeneous (toolbar, item) && GTK_BIN (item)->child) { max_homogeneous_child_width = MAX (max_homogeneous_child_width, requisition.width); max_homogeneous_child_height = MAX (max_homogeneous_child_height, requisition.height); @@ -965,14 +984,14 @@ get_item_size (EggToolbar *toolbar, if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) { - if (item->homogeneous) + if (toolbar_item_is_homogeneous (toolbar, item)) return toolbar->button_maxw; else return requisition.width; } else { - if (item->homogeneous) + if (toolbar_item_is_homogeneous (toolbar, item)) return toolbar->button_maxh; else return requisition.height; diff --git a/lib/egg/eggtoolbutton.c b/lib/egg/eggtoolbutton.c index 4b786db3c..293e65ee9 100644 --- a/lib/egg/eggtoolbutton.c +++ b/lib/egg/eggtoolbutton.c @@ -107,6 +107,14 @@ egg_tool_button_get_type (void) } static void +egg_tool_button_property_notify (GObject *object, + GParamSpec *pspec) +{ + if (strcmp (pspec->name, "is_important")) + egg_tool_button_construct_contents (EGG_TOOL_ITEM (object)); +} + +static void egg_tool_button_class_init (EggToolButtonClass *klass) { GObjectClass *object_class; @@ -122,6 +130,7 @@ egg_tool_button_class_init (EggToolButtonClass *klass) object_class->set_property = egg_tool_button_set_property; object_class->get_property = egg_tool_button_get_property; object_class->finalize = egg_tool_button_finalize; + object_class->notify = egg_tool_button_property_notify; widget_class->size_request = egg_tool_button_size_request; widget_class->size_allocate = egg_tool_button_size_allocate; @@ -324,7 +333,19 @@ egg_tool_button_construct_contents (EggToolItem *tool_item) if (style != GTK_TOOLBAR_TEXT) need_icon = TRUE; - if (style != GTK_TOOLBAR_ICONS) + if (style != GTK_TOOLBAR_ICONS && style != GTK_TOOLBAR_BOTH_HORIZ) + need_label = TRUE; + + if (style == GTK_TOOLBAR_BOTH_HORIZ && + (EGG_TOOL_ITEM (button)->is_important || + egg_tool_item_get_orientation (EGG_TOOL_ITEM (button)) == GTK_ORIENTATION_VERTICAL)) + { + need_label = TRUE; + } + + if (style != GTK_TOOLBAR_ICONS && + ((style != GTK_TOOLBAR_BOTH_HORIZ || + EGG_TOOL_ITEM (button)->is_important))) need_label = TRUE; if (need_label) @@ -420,8 +441,9 @@ egg_tool_button_construct_contents (EggToolItem *tool_item) case GTK_TOOLBAR_BOTH_HORIZ: box = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), icon, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 0); + if (label) + gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (button->button), box); break; diff --git a/lib/egg/eggtoolitem.c b/lib/egg/eggtoolitem.c index b66376d36..85b32e7c6 100644 --- a/lib/egg/eggtoolitem.c +++ b/lib/egg/eggtoolitem.c @@ -42,6 +42,7 @@ enum { PROP_0, PROP_VISIBLE_HORIZONTAL, PROP_VISIBLE_VERTICAL, + PROP_IS_IMPORTANT }; static void egg_tool_item_init (EggToolItem *toolitem); @@ -159,6 +160,15 @@ egg_tool_item_class_init (EggToolItemClass *klass) _("Whether the toolbar item is visible when the toolbar is in a vertical orientation."), TRUE, G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_IS_IMPORTANT, + g_param_spec_boolean ("is_important", + _("Is important"), + _("Whether the toolbar item is considered important. When TRUE, toolbar buttons show text in GTK_TOOLBAR_BOTH_HORIZ mode"), + FALSE, + G_PARAM_READWRITE)); + toolitem_signals[CREATE_MENU_PROXY] = g_signal_new ("create_menu_proxy", G_OBJECT_CLASS_TYPE (klass), @@ -222,6 +232,31 @@ egg_tool_item_parent_set (GtkWidget *toolitem, egg_tool_item_toolbar_reconfigured (EGG_TOOL_ITEM (toolitem)); } +gboolean +egg_tool_item_get_is_important (EggToolItem *tool_item) +{ + g_return_val_if_fail (EGG_IS_TOOL_ITEM (tool_item), FALSE); + + return tool_item->is_important; +} + +void +egg_tool_item_set_is_important (EggToolItem *tool_item, gboolean is_important) +{ + g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item)); + + is_important = is_important != FALSE; + + if (is_important != tool_item->is_important) + { + tool_item->is_important = is_important; + + gtk_widget_queue_resize (GTK_WIDGET (tool_item)); + + g_object_notify (G_OBJECT (tool_item), "is_important"); + } +} + static void egg_tool_item_set_property (GObject *object, guint prop_id, @@ -238,6 +273,9 @@ egg_tool_item_set_property (GObject *object, case PROP_VISIBLE_VERTICAL: egg_tool_item_set_visible_horizontal (toolitem, g_value_get_boolean (value)); break; + case PROP_IS_IMPORTANT: + egg_tool_item_set_is_important (toolitem, g_value_get_boolean (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -259,6 +297,9 @@ egg_tool_item_get_property (GObject *object, case PROP_VISIBLE_VERTICAL: g_value_set_boolean (value, toolitem->visible_vertical); break; + case PROP_IS_IMPORTANT: + g_value_set_boolean (value, toolitem->is_important); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } diff --git a/lib/egg/eggtoolitem.h b/lib/egg/eggtoolitem.h index 584a241b9..97a725638 100644 --- a/lib/egg/eggtoolitem.h +++ b/lib/egg/eggtoolitem.h @@ -52,6 +52,7 @@ struct _EggToolItem guint pack_end : 1; guint use_drag_window : 1; guint overflow_item : 1; + guint is_important : 1; GtkWidget *menu_item; gchar *menu_item_id; @@ -102,6 +103,9 @@ GtkWidget * egg_tool_item_get_proxy_menu_item (EggToolItem *tool_item, void egg_tool_item_set_proxy_menu_item (EggToolItem *tool_item, const gchar *menu_item_id, GtkWidget *menu_item); +gboolean egg_tool_item_get_is_important (EggToolItem *tool_item); +void egg_tool_item_set_is_important (EggToolItem *tool_item, + gboolean is_important); #endif /* __EGG_TOOL_ITEM_H__ */ |