aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2011-04-29 15:21:58 +0800
committerMilan Crha <mcrha@redhat.com>2011-04-29 15:21:58 +0800
commitd21199c9199bceb3bba10ca41a0e4c7fa8b1ad36 (patch)
tree2609b8d0cb9dcece4670db2f6f84fe04c2684668
parent0ea909d4e23719823ae30f4d09d7cfc44e29b5ce (diff)
downloadgsoc2013-evolution-d21199c9199bceb3bba10ca41a0e4c7fa8b1ad36.tar
gsoc2013-evolution-d21199c9199bceb3bba10ca41a0e4c7fa8b1ad36.tar.gz
gsoc2013-evolution-d21199c9199bceb3bba10ca41a0e4c7fa8b1ad36.tar.bz2
gsoc2013-evolution-d21199c9199bceb3bba10ca41a0e4c7fa8b1ad36.tar.lz
gsoc2013-evolution-d21199c9199bceb3bba10ca41a0e4c7fa8b1ad36.tar.xz
gsoc2013-evolution-d21199c9199bceb3bba10ca41a0e4c7fa8b1ad36.tar.zst
gsoc2013-evolution-d21199c9199bceb3bba10ca41a0e4c7fa8b1ad36.zip
Bug #588891 - Spam settings dialog terribly un-higgy
-rw-r--r--mail/mail-config.ui120
-rw-r--r--modules/mail/em-mailer-prefs.c83
2 files changed, 164 insertions, 39 deletions
diff --git a/mail/mail-config.ui b/mail/mail-config.ui
index 5305593e8c..faabb282b3 100644
--- a/mail/mail-config.ui
+++ b/mail/mail-config.ui
@@ -5236,6 +5236,126 @@ for display purposes only. </property>
<property name="tab_fill">False</property>
</packing>
</child>
+ </object>
+ <object class="GtkDialog" id="add-custom-junk-header">
+ <property name="type_hint">dialog</property>
+ <property name="title" translatable="yes">Set custom junk header</property>
+ <property name="border-width">12</property>
+ <property name="width-request">400</property>
+ <property name="resizable">FALSE</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="inner-vbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="border-width">12</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="junk_header_info">
+ <property name="visible">True</property>
+ <property name="wrap">True</property>
+ <property name="label" translatable="yes">All new emails with header that matches given content will be automatically filtered as junk</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTable" id="junk_header_table">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">12</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="junk_header_label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Header name</property>
+ <property name="mnemonic_widget">junk-header-name</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_SHRINK</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="junk_header_label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Header content</property>
+ <property name="mnemonic_widget">junk-header-content</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_SHRINK</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="junk-header-name">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="junk-header-content">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2></property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="junk_header_hbutton_box">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="junk-header-cancel">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="use_stock">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="junk-header-ok">
+ <property name="label" translatable="yes">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="use_stock">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">junk-header-cancel</action-widget>
+ <action-widget response="-3">junk-header-ok</action-widget>
+ </action-widgets>
</object>
<object class="GtkSizeGroup" id="composer-label-size-group">
<widgets>
diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c
index 6147328aed..22feb95728 100644
--- a/modules/mail/em-mailer-prefs.c
+++ b/modules/mail/em-mailer-prefs.c
@@ -163,55 +163,60 @@ jh_tree_refill (EMMailerPrefs *prefs)
}
static void
+jh_dialog_entry_changed_cb (GtkEntry *entry, gpointer user_data)
+{
+ GtkBuilder *builder = GTK_BUILDER (user_data);
+ GtkWidget *ok_button, *entry1, *entry2;
+ const gchar *name, *value;
+
+ ok_button = e_builder_get_widget (builder, "junk-header-ok");
+ entry1 = e_builder_get_widget (builder, "junk-header-name");
+ entry2 = e_builder_get_widget (builder, "junk-header-content");
+
+ name = gtk_entry_get_text (GTK_ENTRY (entry1));
+ value = gtk_entry_get_text (GTK_ENTRY (entry2));
+
+ gtk_widget_set_sensitive (ok_button, name && *name && value && *value);
+}
+
+static void
jh_add_cb (GtkWidget *widget, gpointer user_data)
{
+ GtkWidget *dialog;
+ GtkWidget *entry;
EMMailerPrefs *prefs = (EMMailerPrefs *) user_data;
- GtkWidget *dialog, *l1, *l2, *entry1, *entry2, *vbox, *hbox;
- GtkWidget *content_area;
- gint response;
-
- dialog = gtk_dialog_new_with_buttons (
- _("Add Custom Junk Header"),
- (GtkWindow *) gtk_widget_get_toplevel (widget),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
-
- vbox = gtk_vbox_new (FALSE, 6);
- hbox = gtk_hbox_new (FALSE, 0);
- l1 = gtk_label_new_with_mnemonic (_("Header Name:"));
- l2 = gtk_label_new_with_mnemonic (_("Header Value Contains:"));
- entry1 = gtk_entry_new ();
- entry2 = gtk_entry_new ();
- gtk_box_pack_start ((GtkBox *) hbox, l1, FALSE, FALSE, 6);
- gtk_box_pack_start ((GtkBox *)hbox, entry1, FALSE, FALSE, 6);
- gtk_box_pack_start ((GtkBox *)vbox, hbox, FALSE, FALSE, 6);
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start ((GtkBox *)hbox, l2, FALSE, FALSE, 6);
- gtk_box_pack_start ((GtkBox *)hbox, entry2, FALSE, FALSE, 6);
- gtk_box_pack_start ((GtkBox *)vbox, hbox, FALSE, FALSE, 6);
-
- gtk_widget_show_all (vbox);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_container_add (GTK_CONTAINER (content_area), vbox);
- response = gtk_dialog_run ((GtkDialog *)dialog);
- if (response == GTK_RESPONSE_ACCEPT) {
- const gchar *name = gtk_entry_get_text ((GtkEntry *)entry1);
- const gchar *value = gtk_entry_get_text ((GtkEntry *)entry2);
- gchar *tok;
- GSList *list = gconf_client_get_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL);
-
- /* FIXME: Validate the values */
-
+ GtkBuilder *builder = gtk_builder_new();
+ gchar *tok;
+ const gchar *name, *value;
+ GSList *list;
+
+ e_load_ui_builder_definition (builder, "mail-config.ui");
+ dialog = e_builder_get_widget (builder, "add-custom-junk-header");
+ jh_dialog_entry_changed_cb (NULL, builder);
+
+ entry = e_builder_get_widget (builder, "junk-header-name");
+ g_signal_connect (entry, "changed",
+ G_CALLBACK (jh_dialog_entry_changed_cb), builder);
+ entry = e_builder_get_widget (builder, "junk-header-content");
+ g_signal_connect (entry, "changed",
+ G_CALLBACK (jh_dialog_entry_changed_cb), builder);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
+ name = gtk_entry_get_text (GTK_ENTRY (e_builder_get_widget (builder, "junk-header-name")));
+ value = gtk_entry_get_text (GTK_ENTRY (e_builder_get_widget (builder, "junk-header-content")));
+
+ list = gconf_client_get_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL);
tok = g_strdup_printf ("%s=%s", name, value);
list = g_slist_append (list, tok);
gconf_client_set_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, list, NULL);
- g_slist_foreach (list, (GFunc)g_free, NULL);
+ g_slist_foreach (list, (GFunc) g_free, NULL);
g_slist_free (list);
}
+
+ g_object_unref (builder);
gtk_widget_destroy (dialog);
+
jh_tree_refill (prefs);
}