diff options
author | Larry Ewing <lewing@ximian.com> | 2004-06-12 02:01:25 +0800 |
---|---|---|
committer | Larry Ewing <lewing@src.gnome.org> | 2004-06-12 02:01:25 +0800 |
commit | ef03909b1598cf22e9b36f431339cbe07f8e1bc6 (patch) | |
tree | ba43e23bea905a761de93dc3257fc9ac1e8bf3ad /widgets/misc | |
parent | dfea2682ce1283f50465246789720feb40a77c68 (diff) | |
download | gsoc2013-evolution-ef03909b1598cf22e9b36f431339cbe07f8e1bc6.tar.gz gsoc2013-evolution-ef03909b1598cf22e9b36f431339cbe07f8e1bc6.tar.zst gsoc2013-evolution-ef03909b1598cf22e9b36f431339cbe07f8e1bc6.zip |
make the source selector use a colock block instead of setting the
2004-06-11 Larry Ewing <lewing@ximian.com>
* misc/e-source-selector.c: make the source selector use a colock
block instead of setting the foreground to indicate the source
color.
svn path=/trunk/; revision=26313
Diffstat (limited to 'widgets/misc')
-rw-r--r-- | widgets/misc/e-source-selector.c | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/widgets/misc/e-source-selector.c b/widgets/misc/e-source-selector.c index f26ce4030b..8983af5585 100644 --- a/widgets/misc/e-source-selector.c +++ b/widgets/misc/e-source-selector.c @@ -378,28 +378,55 @@ text_cell_data_func (GtkTreeViewColumn *column, ESource *source; guint32 color; gboolean has_color; - + g_assert (E_IS_SOURCE (data)); source = E_SOURCE (data); - + g_object_set (renderer, "text", e_source_peek_name (source), "weight", PANGO_WEIGHT_NORMAL, + "foreground_set", FALSE, NULL); + } - has_color = e_source_get_color (source, &color); - if (!has_color) { - g_object_set (renderer, - "foreground_set", FALSE, - NULL); - } else { - char *color_string = g_strdup_printf ("#%06x", color); - g_object_set (renderer, - "foreground_set", TRUE, - "foreground", color_string, - NULL); - g_free (color_string); + g_object_unref (data); +} + +static void +pixbuf_cell_data_func (GtkTreeViewColumn *column, + GtkCellRenderer *renderer, + GtkTreeModel *model, + GtkTreeIter *iter, + ESourceSelector *selector) +{ + void *data; + + gtk_tree_model_get (model, iter, 0, &data, -1); + + if (E_IS_SOURCE_GROUP (data)) { + g_object_set (renderer, + "pixbuf", NULL, + NULL); + } else { + ESource *source; + guint32 color; + gboolean has_color; + GdkPixbuf *pixbuf; + + g_assert (E_IS_SOURCE (data)); + source = E_SOURCE (data); + + if (e_source_get_color (source, &color)) { + pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 16, 16); + gdk_pixbuf_fill (pixbuf, color << 8); } + + g_object_set (renderer, + "pixbuf", pixbuf, + NULL); + + if (pixbuf) + g_object_unref (pixbuf); } g_object_unref (data); @@ -710,6 +737,9 @@ init (ESourceSelector *selector) column = gtk_tree_view_column_new (); gtk_tree_view_append_column (GTK_TREE_VIEW (selector), column); + cell_renderer = gtk_cell_renderer_pixbuf_new (); + gtk_tree_view_column_pack_start (column, cell_renderer, FALSE); + gtk_tree_view_column_set_cell_data_func (column, cell_renderer, (GtkTreeCellDataFunc) pixbuf_cell_data_func, selector, NULL); cell_renderer = gtk_cell_renderer_toggle_new (); gtk_tree_view_column_pack_start (column, cell_renderer, FALSE); gtk_tree_view_column_set_cell_data_func (column, cell_renderer, (GtkTreeCellDataFunc) toggle_cell_data_func, selector, NULL); |