aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-mailer-prefs.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/em-mailer-prefs.c')
-rw-r--r--mail/em-mailer-prefs.c732
1 files changed, 220 insertions, 512 deletions
diff --git a/mail/em-mailer-prefs.c b/mail/em-mailer-prefs.c
index 12b2996b70..fa450dc2ee 100644
--- a/mail/em-mailer-prefs.c
+++ b/mail/em-mailer-prefs.c
@@ -25,15 +25,15 @@
#endif
#include <string.h>
+#include <glib/gi18n-lib.h>
#include "em-mailer-prefs.h"
-#include "em-format.h"
+#include "em-format/em-format.h"
#include <camel/camel-iconv.h>
#include <gtkhtml/gtkhtml-properties.h>
#include <libxml/tree.h>
#include "misc/e-charset-picker.h"
-#include <bonobo/bonobo-generic-factory.h>
#include <glade/glade.h>
@@ -41,9 +41,10 @@
#include "libedataserverui/e-cell-renderer-color.h"
+#include "e-util/e-binding.h"
#include "e-util/e-util-private.h"
-#include "e-util/e-util-labels.h"
+#include "e-mail-label-manager.h"
#include "mail-config.h"
#include "em-junk-hook.h"
#include "em-config.h"
@@ -51,7 +52,7 @@
static void em_mailer_prefs_class_init (EMMailerPrefsClass *class);
static void em_mailer_prefs_init (EMMailerPrefs *dialog);
-static void em_mailer_prefs_dispose (GObject *obj);
+static void em_mailer_prefs_finalize (GObject *object);
static GtkVBoxClass *parent_class = NULL;
@@ -127,7 +128,7 @@ em_mailer_prefs_class_init (EMMailerPrefsClass *klass)
object_class = (GObjectClass *) klass;
parent_class = g_type_class_ref (gtk_vbox_get_type ());
- object_class->dispose = em_mailer_prefs_dispose;
+ object_class->finalize = em_mailer_prefs_finalize;
}
static void
@@ -137,15 +138,10 @@ em_mailer_prefs_init (EMMailerPrefs *preferences)
}
static void
-em_mailer_prefs_dispose (GObject *obj)
+em_mailer_prefs_finalize (GObject *obj)
{
EMMailerPrefs *prefs = (EMMailerPrefs *) obj;
- if (prefs->header_list_store) {
- g_object_unref (prefs->header_list_store);
- prefs->header_list_store = NULL;
- }
-
g_object_unref (prefs->gui);
if (prefs->labels_change_notify_id) {
@@ -154,157 +150,48 @@ em_mailer_prefs_dispose (GObject *obj)
prefs->labels_change_notify_id = 0;
}
- ((GObjectClass *)(parent_class))->dispose (obj);
+ ((GObjectClass *)(parent_class))->finalize (obj);
}
-
-static void
-color_button_set_color (GtkColorButton *color_button, const gchar *spec)
+static gboolean
+mark_seen_timeout_transform (const GValue *src_value,
+ GValue *dst_value,
+ gpointer user_data)
{
- GdkColor color;
+ gdouble v_double;
+
+ /* Shell Settings (gint) -> Spin Button (double) */
+ v_double = (gdouble) g_value_get_int (src_value);
+ g_value_set_double (dst_value, v_double / 1000.0);
- if (gdk_color_parse (spec, &color))
- gtk_color_button_set_color (color_button, &color);
+ return TRUE;
}
-static void
-citation_color_set (GtkColorButton *color_button, EMMailerPrefs *prefs)
+static gboolean
+mark_seen_timeout_reverse_transform (const GValue *src_value,
+ GValue *dst_value,
+ gpointer user_data)
{
- GdkColor color;
- gchar spec[16];
+ gdouble v_double;
- gtk_color_button_get_color (color_button, &color);
- g_snprintf (spec, sizeof (spec), "#%04x%04x%04x",
- color.red, color.green, color.blue);
+ /* Spin Button (double) -> Shell Settings (gint) */
+ v_double = g_value_get_double (src_value);
+ g_value_set_int (dst_value, v_double * 1000);
- gconf_client_set_string (prefs->gconf,
- "/apps/evolution/mail/display/citation_colour",
- spec, NULL);
+ return TRUE;
}
enum {
- LABEL_LIST_COLUMN_COLOR,
- LABEL_LIST_COLUMN_TAG,
- LABEL_LIST_COLUMN_NAME
-};
-
-enum {
JH_LIST_COLUMN_NAME,
JH_LIST_COLUMN_VALUE
};
-static void
-label_sensitive_buttons (EMMailerPrefs *prefs)
-{
- gboolean can_remove = FALSE, have_selected = FALSE, locked;
-
- g_return_if_fail (prefs);
-
- /* it's not sensitive if it's locked for updates */
- locked = !GTK_WIDGET_IS_SENSITIVE (prefs->label_tree);
-
- if (!locked) {
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (prefs->label_tree));
- if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
- gchar *tag = NULL;
-
- gtk_tree_model_get (model, &iter, LABEL_LIST_COLUMN_TAG, &tag, -1);
-
- can_remove = tag && !e_util_labels_is_system (tag);
- have_selected = TRUE;
-
- g_free (tag);
- }
- }
-
- gtk_widget_set_sensitive (prefs->label_remove, !locked && can_remove);
- gtk_widget_set_sensitive (prefs->label_edit, !locked && have_selected);
-}
-
-static void
-label_tree_cursor_changed (GtkWidget *widget, gpointer user_data)
-{
- label_sensitive_buttons (user_data);
-}
-
-static void
-label_tree_refill (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
-{
- EMMailerPrefs *prefs = (EMMailerPrefs *)user_data;
- GSList *labels, *l;
- GtkTreeSelection *selection;
- GtkListStore *store;
- GtkTreeModel *model;
- GtkTreeIter last_iter;
- gchar *last_path = NULL;
-
- g_return_if_fail (prefs != NULL);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (prefs->label_tree));
- if (gtk_tree_selection_get_selected (selection, &model, &last_iter))
- last_path = gtk_tree_model_get_string_from_iter (model, &last_iter);
-
- store = GTK_LIST_STORE (model);
- gtk_list_store_clear (store);
-
- /* cannot use mail-config cache here, because it's (or can be) updated later than this function call */
- labels = e_util_labels_parse (client);
-
- for (l = labels; l; l = l->next) {
- GdkColor color;
- GtkTreeIter iter;
- EUtilLabel *label = l->data;
-
- if (label->colour)
- gdk_color_parse (label->colour, &color);
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (
- store, &iter,
- LABEL_LIST_COLUMN_COLOR, label->colour ? &color : NULL,
- LABEL_LIST_COLUMN_NAME, label->name,
- LABEL_LIST_COLUMN_TAG, label->tag,
- -1);
- }
-
- if (last_path) {
- gint children;
-
- children = gtk_tree_model_iter_n_children (model, NULL);
- if (children > 0) {
- GtkTreePath *path;
-
- if (!gtk_tree_model_get_iter_from_string (model, &last_iter, last_path))
- gtk_tree_model_iter_nth_child (model, &last_iter, NULL, children - 1);
-
- path = gtk_tree_model_get_path (model, &last_iter);
- if (path) {
- GtkTreeViewColumn *focus_col = gtk_tree_view_get_column (GTK_TREE_VIEW (prefs->label_tree), LABEL_LIST_COLUMN_NAME);
-
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (prefs->label_tree), path, focus_col, FALSE);
- gtk_tree_view_row_activated (GTK_TREE_VIEW (prefs->label_tree), path, focus_col);
- gtk_tree_path_free (path);
- }
- }
-
- g_free (last_path);
- }
-
- label_sensitive_buttons (prefs);
- e_util_labels_free (labels);
-}
-
static void
jh_tree_refill (EMMailerPrefs *prefs)
{
- GtkListStore *store;
+ GtkListStore *store = prefs->junk_header_list_store;
GSList *l, *cjh = gconf_client_get_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL);
- store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (prefs->junk_header_tree)));
gtk_list_store_clear (store);
for (l = cjh; l; l = l->next) {
@@ -422,126 +309,28 @@ jh_remove_cb (GtkWidget *widget, gpointer user_data)
}
-static gboolean
-init_junk_tree (GtkTreeView *jh_tree, EMMailerPrefs *prefs)
+static GtkListStore *
+init_junk_tree (GtkWidget *label_tree, EMMailerPrefs *prefs)
{
GtkListStore *store;
GtkCellRenderer *renderer;
gint col;
- g_return_val_if_fail (jh_tree != NULL, FALSE);
- g_return_val_if_fail (prefs != NULL, FALSE);
+ g_return_val_if_fail (label_tree != NULL, NULL);
+ g_return_val_if_fail (prefs != NULL, NULL);
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
- gtk_tree_view_set_model (GTK_TREE_VIEW (jh_tree), GTK_TREE_MODEL (store));
- g_object_unref (store);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (label_tree), GTK_TREE_MODEL (store));
renderer = gtk_cell_renderer_text_new ();
- col = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (jh_tree), -1, _("Header"), renderer, "text", JH_LIST_COLUMN_NAME, NULL);
+ col = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (label_tree), -1, _("Header"), renderer, "text", JH_LIST_COLUMN_NAME, NULL);
g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL);
renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (jh_tree), -1, _("Contains Value"), renderer, "text", JH_LIST_COLUMN_VALUE, NULL);
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (label_tree), -1, _("Contains Value"), renderer, "text", JH_LIST_COLUMN_VALUE, NULL);
g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL);
- jh_tree_refill (prefs);
-
- return TRUE;
-}
-
-static gboolean
-init_label_tree (GtkWidget *label_tree, EMMailerPrefs *prefs, gboolean locked)
-{
- GtkListStore *store;
- GtkCellRenderer *renderer;
- gint col;
-
- g_return_val_if_fail (label_tree != NULL, FALSE);
- g_return_val_if_fail (prefs != NULL, FALSE);
-
- store = gtk_list_store_new (3, GDK_TYPE_COLOR, G_TYPE_STRING, G_TYPE_STRING);
- gtk_tree_view_set_model (GTK_TREE_VIEW (label_tree), GTK_TREE_MODEL (store));
- g_object_unref (store);
-
- renderer = e_cell_renderer_color_new ();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (label_tree), -1, _("Color"), renderer, "color", LABEL_LIST_COLUMN_COLOR, NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- col = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (label_tree), -1, _("Tag"), renderer, "text", LABEL_LIST_COLUMN_TAG, NULL);
- g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
- gtk_tree_view_column_set_visible (gtk_tree_view_get_column (GTK_TREE_VIEW (label_tree), col - 1), FALSE);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (label_tree), -1, _("Name"), renderer, "text", LABEL_LIST_COLUMN_NAME, NULL);
- g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
-
- if (!locked)
- g_signal_connect (label_tree, "cursor-changed", G_CALLBACK (label_tree_cursor_changed), prefs);
-
- label_tree_refill (NULL, 0, NULL, prefs);
-
- prefs->labels_change_notify_id = gconf_client_notify_add (prefs->gconf, E_UTIL_LABELS_GCONF_KEY, label_tree_refill, prefs, NULL, NULL);
-
- return TRUE;
-}
-
-static void
-label_add_cb (GtkWidget *widget, gpointer user_data)
-{
- gchar *tag;
-
- tag = e_util_labels_add_with_dlg (GTK_WINDOW (gtk_widget_get_toplevel (widget)), NULL);
-
- g_free (tag);
-}
-
-static void
-label_remove_cb (GtkWidget *widget, gpointer user_data)
-{
- EMMailerPrefs *prefs = user_data;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- g_return_if_fail (prefs != NULL);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (prefs->label_tree));
- if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
- gchar *tag = NULL;
-
- gtk_tree_model_get (model, &iter, LABEL_LIST_COLUMN_TAG, &tag, -1);
-
- if (tag && !e_util_labels_is_system (tag))
- e_util_labels_remove (tag);
-
- g_free (tag);
- }
-}
-
-static void
-label_edit_cb (GtkWidget *widget, gpointer user_data)
-{
- EMMailerPrefs *prefs = user_data;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- g_return_if_fail (prefs != NULL);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (prefs->label_tree));
- if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
- gchar *tag = NULL;
-
- gtk_tree_model_get (model, &iter, LABEL_LIST_COLUMN_TAG, &tag, -1);
-
- if (tag) {
- gchar *str = e_util_labels_add_with_dlg (GTK_WINDOW (gtk_widget_get_toplevel (widget)), tag);
-
- g_free (str);
- }
-
- g_free (tag);
- }
+ return store;
}
static void
@@ -726,80 +515,6 @@ emmp_header_entry_changed (GtkWidget *entry, gpointer user_data)
}
static void
-mark_seen_timeout_changed (GtkSpinButton *spin, EMMailerPrefs *prefs)
-{
- gint timeout;
-
- timeout = (gint) (gtk_spin_button_get_value (prefs->timeout) * 1000.0);
- gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/display/mark_seen_timeout", timeout, NULL);
-}
-
-static void
-address_compress_count_changed (GtkSpinButton *spin, EMMailerPrefs *prefs)
-{
- gint count;
-
- count = (gint) gtk_spin_button_get_value (prefs->address_count);
-
- gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/display/address_count", count, NULL);
-}
-
-static void
-mlimit_count_changed (GtkSpinButton *spin, EMMailerPrefs *prefs)
-{
- gint count;
-
- count = (gint) gtk_spin_button_get_value (prefs->mlimit_count);
-
- gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/display/message_text_part_limit", count, NULL);
-}
-
-static void
-spin_button_init (EMMailerPrefs *prefs, GtkSpinButton *spin, const gchar *key, gfloat div, GCallback value_changed)
-{
- GError *err = NULL;
- double min, max;
- gchar *mkey, *p;
- gint val;
-
- gtk_spin_button_get_range (spin, &min, &max);
-
- mkey = g_alloca (strlen (key) + 5);
- p = g_stpcpy (mkey, key);
- *p++ = '_';
-
- /* see if the admin locked down the min value */
- strcpy (p, "min");
- val = gconf_client_get_int (prefs->gconf, mkey, &err);
- if (err == NULL)
- g_clear_error (&err);
- else
- min = (1.0 * val) / div;
-
- /* see if the admin locked down the max value */
- strcpy (p, "max");
- val = gconf_client_get_int (prefs->gconf, mkey, &err);
- if (err == NULL)
- g_clear_error (&err);
- else
- max = (1.0 * val) / div;
-
- gtk_spin_button_set_range (spin, min, max);
-
- /* get the value */
- val = gconf_client_get_int (prefs->gconf, key, NULL);
- gtk_spin_button_set_value (spin, (1.0 * val) / div);
-
- if (value_changed) {
- g_object_set_data ((GObject *) spin, "key", (gpointer) key);
- g_signal_connect (spin, "value-changed", value_changed, prefs);
- }
-
- if (!gconf_client_key_is_writable (prefs->gconf, key, NULL))
- gtk_widget_set_sensitive ((GtkWidget *) spin, FALSE);
-}
-
-static void
toggle_button_toggled (GtkToggleButton *toggle, EMMailerPrefs *prefs)
{
const gchar *key;
@@ -809,16 +524,6 @@ toggle_button_toggled (GtkToggleButton *toggle, EMMailerPrefs *prefs)
}
static void
-photo_toggle_changed (GtkToggleButton *toggle, EMMailerPrefs *prefs)
-{
- toggle_button_toggled (toggle, prefs);
- if (gtk_toggle_button_get_active (toggle))
- gtk_widget_set_sensitive ((GtkWidget *) prefs->photo_local, TRUE);
- else
- gtk_widget_set_sensitive ((GtkWidget *) prefs->photo_local, FALSE);
-}
-
-static void
junk_book_lookup_button_toggled (GtkToggleButton *toggle, EMMailerPrefs *prefs)
{
toggle_button_toggled (toggle, prefs);
@@ -843,30 +548,6 @@ custom_junk_button_toggled (GtkToggleButton *toggle, EMMailerPrefs *prefs)
}
static void
-custom_font_changed (GtkToggleButton *toggle, EMMailerPrefs *prefs)
-{
- gboolean use_custom;
-
- use_custom = !gtk_toggle_button_get_active (toggle);
-
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->font_fixed), use_custom);
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->font_variable), use_custom);
-
- gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/display/fonts/use_custom", use_custom, NULL);
-}
-
-static void
-font_changed (GtkFontButton *font_button, EMMailerPrefs *prefs)
-{
- const gchar *key;
- const gchar *font_name;
-
- key = g_object_get_data (G_OBJECT (font_button), "key");
- font_name = gtk_font_button_get_font_name (font_button);
- gconf_client_set_string (prefs->gconf, key, font_name, NULL);
-}
-
-static void
toggle_button_init (EMMailerPrefs *prefs, GtkToggleButton *toggle, gint not, const gchar *key, GCallback toggled)
{
gboolean bool;
@@ -921,74 +602,78 @@ charset_menu_init (EMMailerPrefs *prefs)
}
static void
-trash_days_changed (GtkComboBox *combobox, EMMailerPrefs *prefs)
+trash_days_activate (GtkWidget *item, EMMailerPrefs *prefs)
{
- gint idx;
-
- idx = gtk_combo_box_get_active (combobox);
- g_return_if_fail (idx >= 0 && idx < G_N_ELEMENTS (empty_trash_frequency));
+ gint days;
- gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/trash/empty_on_exit_days", empty_trash_frequency [idx].days, NULL);
+ days = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "days"));
+ gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/trash/empty_on_exit_days", days, NULL);
}
static void
emmp_empty_trash_init (EMMailerPrefs *prefs)
{
gint locked, days, hist = 0, i;
-
- toggle_button_init (prefs, prefs->empty_trash, FALSE,
- "/apps/evolution/mail/trash/empty_on_exit",
- G_CALLBACK (toggle_button_toggled));
+ GtkWidget *menu, *item;
days = gconf_client_get_int(prefs->gconf, "/apps/evolution/mail/trash/empty_on_exit_days", NULL);
-
- gtk_list_store_clear (GTK_LIST_STORE (gtk_combo_box_get_model (prefs->empty_trash_days)));
+ menu = gtk_menu_new();
for (i = 0; i < G_N_ELEMENTS (empty_trash_frequency); i++) {
if (days >= empty_trash_frequency[i].days)
hist = i;
- gtk_combo_box_append_text (prefs->empty_trash_days, _(empty_trash_frequency[i].label));
+ item = gtk_menu_item_new_with_label (_(empty_trash_frequency[i].label));
+ g_object_set_data ((GObject *) item, "days", GINT_TO_POINTER (empty_trash_frequency[i].days));
+ g_signal_connect (item, "activate", G_CALLBACK (trash_days_activate), prefs);
+
+ gtk_widget_show (item);
+ gtk_menu_shell_append((GtkMenuShell *)menu, item);
}
- g_signal_connect (prefs->empty_trash_days, "changed", G_CALLBACK (trash_days_changed), prefs);
- gtk_combo_box_set_active (prefs->empty_trash_days, hist);
+ gtk_widget_show(menu);
+ gtk_option_menu_set_menu((GtkOptionMenu *)prefs->empty_trash_days, menu);
+ gtk_option_menu_set_history((GtkOptionMenu *)prefs->empty_trash_days, hist);
locked = !gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/trash/empty_on_exit_days", NULL);
gtk_widget_set_sensitive ((GtkWidget *) prefs->empty_trash_days, !locked);
}
static void
-junk_days_changed (GtkComboBox *combobox, EMMailerPrefs *prefs)
+junk_days_activate (GtkWidget *item, EMMailerPrefs *prefs)
{
- gint idx;
-
- idx = gtk_combo_box_get_active (combobox);
- g_return_if_fail (idx >= 0 && idx < G_N_ELEMENTS (empty_trash_frequency));
+ gint days;
- gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/junk/empty_on_exit_days", empty_trash_frequency[idx].days, NULL);
+ days = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "days"));
+ gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/junk/empty_on_exit_days", days, NULL);
}
static void
emmp_empty_junk_init (EMMailerPrefs *prefs)
{
gint locked, days, hist = 0, i;
+ GtkWidget *menu, *item;
toggle_button_init (prefs, prefs->empty_junk, FALSE,
"/apps/evolution/mail/junk/empty_on_exit",
G_CALLBACK (toggle_button_toggled));
days = gconf_client_get_int(prefs->gconf, "/apps/evolution/mail/junk/empty_on_exit_days", NULL);
-
- gtk_list_store_clear (GTK_LIST_STORE (gtk_combo_box_get_model (prefs->empty_junk_days)));
+ menu = gtk_menu_new();
for (i = 0; i < G_N_ELEMENTS (empty_trash_frequency); i++) {
if (days >= empty_trash_frequency[i].days)
hist = i;
- gtk_combo_box_append_text (prefs->empty_junk_days, _(empty_trash_frequency[i].label));
+ item = gtk_menu_item_new_with_label (_(empty_trash_frequency[i].label));
+ g_object_set_data ((GObject *) item, "days", GINT_TO_POINTER (empty_trash_frequency[i].days));
+ g_signal_connect (item, "activate", G_CALLBACK (junk_days_activate), prefs);
+
+ gtk_widget_show (item);
+ gtk_menu_shell_append((GtkMenuShell *)menu, item);
}
- g_signal_connect (prefs->empty_junk_days, "changed", G_CALLBACK (junk_days_changed), prefs);
- gtk_combo_box_set_active (prefs->empty_junk_days, hist);
+ gtk_widget_show(menu);
+ gtk_option_menu_set_menu((GtkOptionMenu *)prefs->empty_junk_days, menu);
+ gtk_option_menu_set_history((GtkOptionMenu *)prefs->empty_junk_days, hist);
locked = !gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/junk/empty_on_exit_days", NULL);
gtk_widget_set_sensitive ((GtkWidget *) prefs->empty_junk_days, !locked);
@@ -1011,7 +696,7 @@ http_images_changed (GtkWidget *widget, EMMailerPrefs *prefs)
static GtkWidget *
-emmp_widget_glade(EConfig *ec, EConfigItem *item, struct _GtkWidget *parent, struct _GtkWidget *old, gpointer data)
+emmp_widget_glade(EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget *old, gpointer data)
{
EMMailerPrefs *prefs = data;
@@ -1148,15 +833,18 @@ create_combo_text_widget (void) {
}
static void
-em_mailer_prefs_construct (EMMailerPrefs *prefs)
+em_mailer_prefs_construct (EMMailerPrefs *prefs,
+ EShell *shell)
{
GSList *header_config_list, *header_add_list, *p;
+ EShellSettings *shell_settings;
GHashTable *default_header_hash;
GtkWidget *toplevel;
+ GtkWidget *container;
+ GtkWidget *widget;
GtkTreeSelection *selection;
GtkCellRenderer *renderer;
GtkTreeIter iter;
- gchar *font, *buf;
GladeXML *gui;
gboolean locked;
gint val, i;
@@ -1165,6 +853,8 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
GSList *l;
gchar *gladefile;
+ shell_settings = e_shell_get_shell_settings (shell);
+
gladefile = g_build_filename (EVOLUTION_GLADEDIR,
"mail-config.glade",
NULL);
@@ -1190,96 +880,119 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
/* General tab */
/* Message Display */
- prefs->timeout_toggle = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkMarkTimeout"));
- toggle_button_init (prefs, prefs->timeout_toggle, FALSE,
- "/apps/evolution/mail/display/mark_seen",
- G_CALLBACK (toggle_button_toggled));
-
- prefs->timeout = GTK_SPIN_BUTTON (glade_xml_get_widget (gui, "spinMarkTimeout"));
- spin_button_init (prefs, prefs->timeout,
- "/apps/evolution/mail/display/mark_seen_timeout",
- 1000.0, G_CALLBACK (mark_seen_timeout_changed));
-
- prefs->mlimit_toggle = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "mlimit_checkbutton"));
- toggle_button_init (prefs, prefs->mlimit_toggle, FALSE,
- "/apps/evolution/mail/display/force_message_limit",
- G_CALLBACK (toggle_button_toggled));
-
- prefs->magic_spacebar = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "magic_spacebar_checkbox"));
- toggle_button_init (prefs, prefs->magic_spacebar, FALSE,
- "/apps/evolution/mail/display/magic_spacebar",
- G_CALLBACK (toggle_button_toggled));
-
- prefs->mlimit_count = GTK_SPIN_BUTTON (glade_xml_get_widget (gui, "mlimit_spin"));
- spin_button_init (prefs, prefs->mlimit_count,
- "/apps/evolution/mail/display/message_text_part_limit",
- 1, G_CALLBACK (mlimit_count_changed));
-
- prefs->address_toggle = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "address_checkbox"));
- toggle_button_init (prefs, prefs->address_toggle, FALSE,
- "/apps/evolution/mail/display/address_compress",
- G_CALLBACK (toggle_button_toggled));
-
- prefs->address_count = GTK_SPIN_BUTTON (glade_xml_get_widget (gui, "address_spin"));
- spin_button_init (prefs, prefs->address_count,
- "/apps/evolution/mail/display/address_count",
- 1, G_CALLBACK (address_compress_count_changed));
+ widget = glade_xml_get_widget (gui, "chkMarkTimeout");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-mark-seen",
+ G_OBJECT (widget), "active");
+
+ /* The "mark seen" timeout requires special transform functions
+ * because we display the timeout value to the user in seconds
+ * but store the settings value in milliseconds. */
+ widget = glade_xml_get_widget (gui, "spinMarkTimeout");
+ prefs->timeout = GTK_SPIN_BUTTON (widget);
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-mark-seen",
+ G_OBJECT (widget), "sensitive");
+ e_mutual_binding_new_full (
+ G_OBJECT (shell_settings), "mail-mark-seen-timeout",
+ G_OBJECT (widget), "value",
+ mark_seen_timeout_transform,
+ mark_seen_timeout_reverse_transform,
+ NULL, NULL);
+
+ widget = glade_xml_get_widget (gui, "mlimit_checkbutton");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-force-message-limit",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "mlimit_spin");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-force-message-limit",
+ G_OBJECT (widget), "sensitive");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-message-text-part-limit",
+ G_OBJECT (widget), "value");
+
+ widget = glade_xml_get_widget (gui, "address_checkbox");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-address-compress",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "address_spin");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-address-compress",
+ G_OBJECT (widget), "sensitive");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-address-count",
+ G_OBJECT (widget), "value");
+
+ widget = glade_xml_get_widget (gui, "magic_spacebar_checkbox");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-magic-spacebar",
+ G_OBJECT (widget), "active");
prefs->charset = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuCharset"));
charset_menu_init (prefs);
- prefs->citation_highlight = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkHighlightCitations"));
- toggle_button_init (prefs, prefs->citation_highlight, FALSE,
- "/apps/evolution/mail/display/mark_citations",
- G_CALLBACK (toggle_button_toggled));
-
- prefs->citation_color = GTK_COLOR_BUTTON (glade_xml_get_widget (gui, "colorButtonHighlightCitations"));
- buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/display/citation_colour", NULL);
- color_button_set_color (prefs->citation_color, buf ? buf : "#737373");
- g_signal_connect (prefs->citation_color, "color-set", G_CALLBACK (citation_color_set), prefs);
- if (!gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/display/citation_colour", NULL))
- gtk_widget_set_sensitive ((GtkWidget *) prefs->citation_color, FALSE);
- g_free (buf);
-
- prefs->enable_search_folders = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkEnableSearchFolders"));
- toggle_button_init (prefs, prefs->enable_search_folders, FALSE,
- "/apps/evolution/mail/display/enable_vfolders",
- G_CALLBACK (toggle_button_toggled));
+ widget = glade_xml_get_widget (gui, "chkHighlightCitations");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-mark-citations",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "colorButtonHighlightCitations");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-mark-citations",
+ G_OBJECT (widget), "sensitive");
+ e_mutual_binding_new_full (
+ G_OBJECT (shell_settings), "mail-citation-color",
+ G_OBJECT (widget), "color",
+ e_binding_transform_string_to_color,
+ e_binding_transform_color_to_string,
+ NULL, NULL);
+
+ widget = glade_xml_get_widget (gui, "chkEnableSearchFolders");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-enable-search-folders",
+ G_OBJECT (widget), "active");
/* Deleting Mail */
- prefs->empty_trash = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkEmptyTrashOnExit"));
- prefs->empty_trash_days = GTK_COMBO_BOX (glade_xml_get_widget (gui, "comboboxEmptyTrashDays"));
+ widget = glade_xml_get_widget (gui, "chkEmptyTrashOnExit");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-empty-trash-on-exit",
+ G_OBJECT (widget), "active");
+
+ prefs->empty_trash_days = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuEmptyTrashDays"));
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-empty-trash-on-exit",
+ G_OBJECT (prefs->empty_trash_days), "sensitive");
emmp_empty_trash_init (prefs);
- prefs->confirm_expunge = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkConfirmExpunge"));
- toggle_button_init (prefs, prefs->confirm_expunge, FALSE,
- "/apps/evolution/mail/prompts/expunge",
- G_CALLBACK (toggle_button_toggled));
-
- /* Mail Fonts */
- font = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/display/fonts/monospace", NULL);
- prefs->font_fixed = GTK_FONT_BUTTON (glade_xml_get_widget (gui, "FontFixed"));
- gtk_font_button_set_font_name (prefs->font_fixed, font);
- g_free (font);
- g_object_set_data ((GObject *) prefs->font_fixed, "key", (gpointer) "/apps/evolution/mail/display/fonts/monospace");
- g_signal_connect (prefs->font_fixed, "font-set", G_CALLBACK (font_changed), prefs);
- if (!gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/display/fonts/monospace", NULL))
- gtk_widget_set_sensitive ((GtkWidget *) prefs->font_fixed, FALSE);
-
- font = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/display/fonts/variable", NULL);
- prefs->font_variable = GTK_FONT_BUTTON (glade_xml_get_widget (gui, "FontVariable"));
- gtk_font_button_set_font_name (prefs->font_variable, font);
- g_free (font);
- g_object_set_data ((GObject *) prefs->font_variable, "key", (gpointer) "/apps/evolution/mail/display/fonts/variable");
- g_signal_connect (prefs->font_variable, "font-set", G_CALLBACK (font_changed), prefs);
- if (!gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/display/fonts/variable", NULL))
- gtk_widget_set_sensitive ((GtkWidget *) prefs->font_variable, FALSE);
-
- prefs->font_share = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radFontUseSame"));
- toggle_button_init (prefs, prefs->font_share, TRUE,
- "/apps/evolution/mail/display/fonts/use_custom",
- G_CALLBACK (custom_font_changed));
- custom_font_changed (prefs->font_share, prefs);
+ widget = glade_xml_get_widget (gui, "chkConfirmExpunge");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-confirm-expunge",
+ G_OBJECT (widget), "active");
+
+ /* Mail Fonts */
+ widget = glade_xml_get_widget (gui, "radFontUseSame");
+ e_mutual_binding_new_with_negation (
+ G_OBJECT (shell_settings), "mail-use-custom-fonts",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "FontFixed");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-font-monospace",
+ G_OBJECT (widget), "font-name");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-use-custom-fonts",
+ G_OBJECT (widget), "sensitive");
+
+ widget = glade_xml_get_widget (gui, "FontVariable");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-font-variable",
+ G_OBJECT (widget), "font-name");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-use-custom-fonts",
+ G_OBJECT (widget), "sensitive");
/* HTML Mail tab */
@@ -1306,49 +1019,40 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
g_signal_connect (prefs->images_sometimes, "toggled", G_CALLBACK (http_images_changed), prefs);
g_signal_connect (prefs->images_always, "toggled", G_CALLBACK (http_images_changed), prefs);
- prefs->show_animated = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkShowAnimatedImages"));
- toggle_button_init (prefs, prefs->show_animated, FALSE,
- "/apps/evolution/mail/display/animate_images",
- G_CALLBACK (toggle_button_toggled));
+ widget = glade_xml_get_widget (gui, "chkShowAnimatedImages");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-show-animated-images",
+ G_OBJECT (widget), "active");
- prefs->prompt_unwanted_html = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkPromptWantHTML"));
- toggle_button_init (prefs, prefs->prompt_unwanted_html, FALSE,
- "/apps/evolution/mail/prompts/unwanted_html",
- G_CALLBACK (toggle_button_toggled));
-
- /* Labels... */
- locked = !gconf_client_key_is_writable (prefs->gconf, E_UTIL_LABELS_GCONF_KEY, NULL);
- prefs->label_add = glade_xml_get_widget (gui, "labelAdd");
- prefs->label_edit = glade_xml_get_widget (gui, "labelEdit");
- prefs->label_remove = glade_xml_get_widget (gui, "labelRemove");
- prefs->label_tree = glade_xml_get_widget (gui, "labelTree");
+ widget = glade_xml_get_widget (gui, "chkPromptWantHTML");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-confirm-unwanted-html",
+ G_OBJECT (widget), "active");
- gtk_widget_set_sensitive (prefs->label_add, !locked);
- gtk_widget_set_sensitive (prefs->label_remove, !locked);
- gtk_widget_set_sensitive (prefs->label_edit, !locked);
- gtk_widget_set_sensitive (prefs->label_tree, !locked);
+ container = glade_xml_get_widget (gui, "labels-alignment");
+ widget = e_mail_label_manager_new ();
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ gtk_widget_show (widget);
- init_label_tree (prefs->label_tree, prefs, locked);
-
- if (!locked) {
- g_signal_connect (G_OBJECT (prefs->label_add), "clicked", G_CALLBACK (label_add_cb), prefs);
- g_signal_connect (G_OBJECT (prefs->label_remove), "clicked", G_CALLBACK (label_remove_cb), prefs);
- g_signal_connect (G_OBJECT (prefs->label_edit), "clicked", G_CALLBACK (label_edit_cb), prefs);
- }
+ e_binding_new (
+ G_OBJECT (shell_settings), "mail-label-list-store",
+ G_OBJECT (widget), "list-store");
/* headers */
locked = !gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/display/headers", NULL);
- prefs->photo_show= GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "photo_show"));
- toggle_button_init (prefs, prefs->photo_show, FALSE,
- "/apps/evolution/mail/display/sender_photo",
- G_CALLBACK (photo_toggle_changed));
- prefs->photo_local = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "photo_local"));
- toggle_button_init (prefs, prefs->photo_local, FALSE,
- "/apps/evolution/mail/display/photo_local",
- G_CALLBACK (toggle_button_toggled));
- if (!gtk_toggle_button_get_active (prefs->photo_show))
- gtk_widget_set_sensitive ((GtkWidget *) prefs->photo_local, FALSE);
+ widget = glade_xml_get_widget (gui, "photo_show");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-show-sender-photo",
+ G_OBJECT (widget), "active");
+
+ widget = glade_xml_get_widget (gui, "photo_local");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-show-sender-photo",
+ G_OBJECT (widget), "sensitive");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-only-local-photos",
+ G_OBJECT (widget), "active");
/* always de-sensitised until the user types something in the entry */
prefs->add_header = GTK_BUTTON (glade_xml_get_widget (gui, "cmdHeadersAdd"));
@@ -1455,13 +1159,13 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
g_slist_free (header_add_list);
/* Junk prefs */
- prefs->check_incoming = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkCheckIncomingMail"));
- toggle_button_init (prefs, prefs->check_incoming, FALSE,
- "/apps/evolution/mail/junk/check_incoming",
- G_CALLBACK (toggle_button_toggled));
+ widget = glade_xml_get_widget (gui, "chkCheckIncomingMail");
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-check-for-junk",
+ G_OBJECT (widget), "active");
prefs->empty_junk = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "junk_empty_check"));
- prefs->empty_junk_days = GTK_COMBO_BOX (glade_xml_get_widget (gui, "junk_empty_combobox"));
+ prefs->empty_junk_days = GTK_OPTION_MENU (glade_xml_get_widget (gui, "junk_empty_combo"));
emmp_empty_junk_init (prefs);
prefs->default_junk_plugin = GTK_COMBO_BOX (glade_xml_get_widget (gui, "default_junk_plugin"));
@@ -1485,7 +1189,7 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
junk_book_lookup_button_toggled (prefs->junk_book_lookup, prefs);
- init_junk_tree ((GtkTreeView *)prefs->junk_header_tree, prefs);
+ prefs->junk_header_list_store = init_junk_tree ((GtkWidget *)prefs->junk_header_tree, prefs);
toggle_button_init (prefs, prefs->junk_header_check, FALSE,
"/apps/evolution/mail/junk/check_custom_header",
G_CALLBACK (custom_junk_button_toggled));
@@ -1503,14 +1207,18 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
}
GtkWidget *
-em_mailer_prefs_new (void)
+em_mailer_prefs_new (EShell *shell)
{
EMMailerPrefs *new;
- new = (EMMailerPrefs *) g_object_new (em_mailer_prefs_get_type (), NULL);
- em_mailer_prefs_construct (new);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
+ new = g_object_new (EM_TYPE_MAILER_PREFS, NULL);
+
+ /* FIXME Kill this function. */
+ em_mailer_prefs_construct (new, shell);
- return (GtkWidget *) new;
+ return GTK_WIDGET (new);
}