diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-02-01 03:40:31 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-02-01 03:40:31 +0800 |
commit | d48d40c7cea47dc69e10988417e99c525b877a16 (patch) | |
tree | b415d40a5d10dbdbdfd7ae52c69a3da3b487ee58 /mail/mail-preferences.c | |
parent | 08fdb0bd4aeac43bc42438e9735e843c352b4e05 (diff) | |
download | gsoc2013-evolution-d48d40c7cea47dc69e10988417e99c525b877a16.tar.gz gsoc2013-evolution-d48d40c7cea47dc69e10988417e99c525b877a16.tar.zst gsoc2013-evolution-d48d40c7cea47dc69e10988417e99c525b877a16.zip |
New function to return a cached list of labels.
2003-01-31 Jeffrey Stedfast <fejj@ximian.com>
* mail-config.c (mail_config_get_labels): New function to return a
cached list of labels.
(mail_config_get_label_color_by_name): New convenience function to
search the cached labels.
(mail_config_get_label_color_by_index): Same.
(mail_config_init): Cache the labels and also listen for changes
to them in the gconf db.
(config_cache_labels): Internal function to cache the labels.
* folder-browser.c (on_right_click): Fixed the label colours in
the menu by using the cached linked list of labels.
* mail-preferences.c (colorpicker_set_color): Now takes a string
argument allowing us to get rid of converting a string into an rgb
guint32 all over the place when trying to set defaults, since we
now store colors in gconf as strings.
(mail_preferences_construct): Use the cached labels (they are
already parsed for us).
svn path=/trunk/; revision=19694
Diffstat (limited to 'mail/mail-preferences.c')
-rw-r--r-- | mail/mail-preferences.c | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/mail/mail-preferences.c b/mail/mail-preferences.c index 465f229ca0..60638fff93 100644 --- a/mail/mail-preferences.c +++ b/mail/mail-preferences.c @@ -100,8 +100,14 @@ mail_preferences_finalise (GObject *obj) static void -colorpicker_set_color (GnomeColorPicker *color, guint32 rgb) +colorpicker_set_color (GnomeColorPicker *color, const char *str) { + GdkColor colour; + guint32 rgb; + + gdk_color_parse (str, &colour); + rgb = ((colour.red & 0xff00) << 8) | (colour.green & 0xff00) | ((colour.blue & 0xff00) >> 8); + gnome_color_picker_set_i8 (color, (rgb & 0xff0000) >> 16, (rgb & 0xff00) >> 8, rgb & 0xff, 0xff); } @@ -148,7 +154,7 @@ restore_labels_clicked (GtkWidget *widget, gpointer user_data) for (i = 0; i < 5; i++) { gtk_entry_set_text (prefs->labels[i].name, _(label_defaults[i].name)); - colorpicker_set_color (prefs->labels[i].color, label_defaults[i].color); + colorpicker_set_color (prefs->labels[i].color, label_defaults[i].colour); } } @@ -183,10 +189,8 @@ mail_preferences_construct (MailPreferences *prefs) GtkWidget *widget, *toplevel, *menu; const char *text; GSList *list, *l; - GdkColor colour; GladeXML *gui; gboolean bool; - guint32 rgb; int i, val; char *buf; char *names[][2] = { @@ -234,9 +238,7 @@ mail_preferences_construct (MailPreferences *prefs) prefs->citation_color = GNOME_COLOR_PICKER (glade_xml_get_widget (gui, "colorpickerHighlightCitations")); buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/display/citation_colour", NULL); - gdk_color_parse (buf ? buf : "#737373", &colour); - rgb = ((colour.red & 0xff00) << 8) | (colour.green & 0xff00) | ((colour.blue & 0xff00) >> 8); - colorpicker_set_color (prefs->citation_color, rgb); + colorpicker_set_color (prefs->citation_color, buf ? buf : "#737373"); g_signal_connect (prefs->citation_color, "color-set", G_CALLBACK (color_set), prefs); g_free (buf); @@ -307,11 +309,13 @@ mail_preferences_construct (MailPreferences *prefs) gtk_toggle_button_set_active (prefs->prompt_unwanted_html, bool); g_signal_connect (prefs->prompt_unwanted_html, "toggled", G_CALLBACK (settings_changed), prefs); - l = list = gconf_client_get_list (prefs->gconf, "/apps/evolution/mail/labels", GCONF_VALUE_STRING, NULL); - - /* Labels and Colours tab */ - for (i = 0; i < 5; i++) { - char *widget_name, *label, *p; + i = 0; + list = mail_config_get_labels (); + while (list != NULL && i < 5) { + MailConfigLabel *label; + char *widget_name; + + label = list->data; widget_name = g_strdup_printf ("txtLabel%d", i); prefs->labels[i].name = GTK_ENTRY (glade_xml_get_widget (gui, widget_name)); @@ -321,35 +325,16 @@ mail_preferences_construct (MailPreferences *prefs) prefs->labels[i].color = GNOME_COLOR_PICKER (glade_xml_get_widget (gui, widget_name)); g_free (widget_name); - label = l ? (char *) l->data : g_strdup (_(label_defaults[i].name)); - if ((p = strrchr (label, ':'))) { - *p++ = '\0'; - gdk_color_parse (p, &colour); - rgb = ((colour.red & 0xff00) << 8) | (colour.green & 0xff00) | ((colour.blue & 0xff) >> 8); - } else { - rgb = label_defaults[i].color; - } - - gtk_entry_set_text (prefs->labels[i].name, label); - g_free (label); - + gtk_entry_set_text (prefs->labels[i].name, label->name); g_signal_connect (prefs->labels[i].name, "changed", G_CALLBACK (settings_changed), prefs); - colorpicker_set_color (prefs->labels[i].color, rgb); + colorpicker_set_color (prefs->labels[i].color, label->colour); g_signal_connect (prefs->labels[i].color, "color_set", G_CALLBACK (color_set), prefs); - if (l != NULL) - l = l->next; - } - - /* this is in case somehow the gconf list is longer than 5... */ - while (l != NULL) { - g_free (l->data); - l = l->next; + i++; + list = list->next; } - g_slist_free (list); - prefs->restore_labels = GTK_BUTTON (glade_xml_get_widget (gui, "cmdRestoreLabels")); g_signal_connect (prefs->restore_labels, "clicked", G_CALLBACK (restore_labels_clicked), prefs); } |