diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-11-26 21:46:32 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-11-26 23:41:49 +0800 |
commit | 4899dc5ca6e6e0e7522e7afc672adebf96eb5b81 (patch) | |
tree | fd19800dd82b98cdfe93b77fdbaf6a3767a4bf19 /mail | |
parent | 3cd87037bc025819567e28b3da1013414a1b93d7 (diff) | |
download | gsoc2013-evolution-4899dc5ca6e6e0e7522e7afc672adebf96eb5b81.tar gsoc2013-evolution-4899dc5ca6e6e0e7522e7afc672adebf96eb5b81.tar.gz gsoc2013-evolution-4899dc5ca6e6e0e7522e7afc672adebf96eb5b81.tar.bz2 gsoc2013-evolution-4899dc5ca6e6e0e7522e7afc672adebf96eb5b81.tar.lz gsoc2013-evolution-4899dc5ca6e6e0e7522e7afc672adebf96eb5b81.tar.xz gsoc2013-evolution-4899dc5ca6e6e0e7522e7afc672adebf96eb5b81.tar.zst gsoc2013-evolution-4899dc5ca6e6e0e7522e7afc672adebf96eb5b81.zip |
EMailJunkOptions: Bind to "junk-filter" instead of "junk-filter-name".
Use transformation functions to convert between EMailJunkFilter and the
junk filter name.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-junk-options.c | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/mail/e-mail-junk-options.c b/mail/e-mail-junk-options.c index 7d93a86c5f..6977e2a8f3 100644 --- a/mail/e-mail-junk-options.c +++ b/mail/e-mail-junk-options.c @@ -51,6 +51,51 @@ enum { COLUMN_DISPLAY_NAME }; +static gboolean +mail_junk_options_junk_filter_to_name (GBinding *binding, + const GValue *source_value, + GValue *target_value, + gpointer user_data) +{ + CamelJunkFilter *junk_filter; + gboolean success = FALSE; + + junk_filter = g_value_get_object (source_value); + + if (E_IS_MAIL_JUNK_FILTER (junk_filter)) { + EMailJunkFilterClass *class; + + class = E_MAIL_JUNK_FILTER_GET_CLASS (junk_filter); + g_value_set_string (target_value, class->filter_name); + success = TRUE; + } + + return success; +} + +static gboolean +mail_junk_options_name_to_junk_filter (GBinding *binding, + const GValue *source_value, + GValue *target_value, + gpointer user_data) +{ + const gchar *filter_name; + gboolean success = FALSE; + + filter_name = g_value_get_string (source_value); + + if (filter_name != NULL) { + EMailJunkFilter *junk_filter; + + junk_filter = e_mail_session_get_junk_filter_by_name ( + E_MAIL_SESSION (user_data), filter_name); + g_value_set_object (target_value, junk_filter); + success = (junk_filter != NULL); + } + + return success; +} + static void mail_junk_options_combo_box_changed_cb (GtkComboBox *combo_box, EMailJunkOptions *options) @@ -137,11 +182,14 @@ mail_junk_options_rebuild (EMailJunkOptions *options) if (session != NULL) { GBinding *binding; - binding = g_object_bind_property ( - session, "junk-filter-name", + binding = g_object_bind_property_full ( + session, "junk-filter", combo_box, "active-id", G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_BINDING_SYNC_CREATE, + mail_junk_options_junk_filter_to_name, + mail_junk_options_name_to_junk_filter, + session, (GDestroyNotify) NULL); options->priv->active_id_binding = binding; } |