aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-01-18 04:06:17 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-01-18 04:06:17 +0800
commitc22126d54f0cf0637e3d5ddd5d78b3ff5d111582 (patch)
tree64f296a85dd817e3184159126e8dbde39c173363 /widgets
parent4d07d219d1f18aeba2c16317ade4b4004d8934b9 (diff)
downloadgsoc2013-evolution-c22126d54f0cf0637e3d5ddd5d78b3ff5d111582.tar.gz
gsoc2013-evolution-c22126d54f0cf0637e3d5ddd5d78b3ff5d111582.tar.zst
gsoc2013-evolution-c22126d54f0cf0637e3d5ddd5d78b3ff5d111582.zip
Hack GtkIconTheme so we can reference category icons as named icons.
Necessary for EActionComboBox, since GtkActions can only handle named or stock icons. Hopefully this is just a temporary hack. Eventually we should make the category icons themeable. Kill the "mail-account-disable" plugin and integrate it properly. More dead plugins to follow... Don't show disabled menu items in pop-up context menus. It does the user no good to see things he CAN'T do with the object he clicked on. svn path=/branches/kill-bonobo/; revision=37093
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/e-action-combo-box.c54
1 files changed, 46 insertions, 8 deletions
diff --git a/widgets/misc/e-action-combo-box.c b/widgets/misc/e-action-combo-box.c
index b3bc5a78a9..977ac06ade 100644
--- a/widgets/misc/e-action-combo-box.c
+++ b/widgets/misc/e-action-combo-box.c
@@ -43,6 +43,7 @@ struct _EActionComboBoxPrivate {
guint changed_handler_id; /* action::changed */
guint group_sensitive_handler_id; /* action-group::sensitive */
guint group_visible_handler_id; /* action-group::visible */
+ gboolean group_has_icons : 1;
};
static gpointer parent_class;
@@ -95,9 +96,14 @@ action_combo_box_render_pixbuf (GtkCellLayout *layout,
gchar *stock_id;
gboolean sensitive;
gboolean visible;
+ gint width;
gtk_tree_model_get (model, iter, COLUMN_ACTION, &action, -1);
+ /* Do any of the actions have an icon? */
+ if (!combo_box->priv->group_has_icons)
+ return;
+
/* A NULL action means the row is a separator. */
if (action == NULL)
return;
@@ -110,14 +116,31 @@ action_combo_box_render_pixbuf (GtkCellLayout *layout,
"visible", &visible,
NULL);
- g_object_set (
- G_OBJECT (renderer),
- "icon-name", icon_name,
- "sensitive", sensitive,
- "stock-id", stock_id,
- "stock-size", GTK_ICON_SIZE_MENU,
- "visible", visible,
- NULL);
+ /* Keep the pixbuf renderer a fixed size for proper alignment. */
+ gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, NULL);
+
+ /* We can't set both "icon-name" and "stock-id" because setting
+ * one unsets the other. So pick the one that has a non-NULL
+ * value. If both are non-NULL, "stock-id" wins. */
+
+ if (stock_id != NULL)
+ g_object_set (
+ G_OBJECT (renderer),
+ "sensitive", sensitive,
+ "stock-id", stock_id,
+ "stock-size", GTK_ICON_SIZE_MENU,
+ "visible", visible,
+ "width", width,
+ NULL);
+ else
+ g_object_set (
+ G_OBJECT (renderer),
+ "icon-name", icon_name,
+ "sensitive", sensitive,
+ "stock-size", GTK_ICON_SIZE_MENU,
+ "visible", visible,
+ "width", width,
+ NULL);
g_free (icon_name);
g_free (stock_id);
@@ -135,6 +158,7 @@ action_combo_box_render_text (GtkCellLayout *layout,
gchar *label;
gboolean sensitive;
gboolean visible;
+ gint xpad;
gtk_tree_model_get (model, iter, COLUMN_ACTION, &action, -1);
@@ -155,11 +179,14 @@ action_combo_box_render_text (GtkCellLayout *layout,
label = g_strjoinv (NULL, strv);
g_strfreev (strv);
+ xpad = combo_box->priv->group_has_icons ? 3 : 0;
+
g_object_set (
G_OBJECT (renderer),
"sensitive", sensitive,
"text", label,
"visible", visible,
+ "xpad", xpad,
NULL);
g_free (label);
@@ -201,14 +228,25 @@ action_combo_box_update_model (EActionComboBox *combo_box)
2, GTK_TYPE_RADIO_ACTION, G_TYPE_FLOAT);
list = gtk_radio_action_get_group (combo_box->priv->action);
+ combo_box->priv->group_has_icons = FALSE;
while (list != NULL) {
GtkTreeRowReference *reference;
GtkRadioAction *action = list->data;
GtkTreePath *path;
GtkTreeIter iter;
+ gchar *icon_name;
+ gchar *stock_id;
gint value;
+ g_object_get (
+ action, "icon-name", &icon_name,
+ "stock-id", &stock_id, NULL);
+ combo_box->priv->group_has_icons |=
+ (icon_name != NULL || stock_id != NULL);
+ g_free (icon_name);
+ g_free (stock_id);
+
gtk_list_store_append (list_store, &iter);
g_object_get (G_OBJECT (action), "value", &value, NULL);
gtk_list_store_set (