aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/groupwise-features/junk-mail-settings.c
blob: b868e28c5a20e3ee8537afc81e43537a77cd40b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with the program; if not, see <http://www.gnu.org/licenses/>
 *
 *
 * Authors:
 *      Vivek Jain <jvivek@novell.com>
 *
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 *
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <glib/gi18n-lib.h>
#include <string.h>
#include <stdio.h>
#include <gtk/gtk.h>

#include <mail/e-mail-reader.h>
#include <mail/message-list.h>

#include <e-gw-connection.h>

#include "gw-ui.h"
#include "share-folder.h"
#include "junk-settings.h"

static void
abort_changes (JunkSettings *js)
{
    g_object_run_dispose ((GObject *)js);
}

static void
junk_dialog_response (GtkWidget *dialog, gint response, JunkSettings *js)
{
    if (response == GTK_RESPONSE_ACCEPT) {
        commit_changes(js);
        abort_changes (js);
    }
    else
        abort_changes (js);

    gtk_widget_destroy (dialog);

}

void
gw_junk_mail_settings_cb (GtkAction *action, EShellView *shell_view)
{
    GtkWidget *dialog ,*w, *notebook, *box;
    JunkSettings *junk_tab;
    gint page_count =0;
    EGwConnection *cnc;
    gchar *msg;
    EShellContent *shell_content;
    EMailReader *reader;
    CamelFolder *folder;

    shell_content = e_shell_view_get_shell_content (shell_view);

    reader = E_MAIL_READER (shell_content);
    folder = e_mail_reader_get_folder (reader);
    g_return_if_fail (folder != NULL);

    cnc = get_cnc (folder->parent_store);

    dialog =  gtk_dialog_new_with_buttons (_("Junk Settings"),
            NULL,
            GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
            GTK_STOCK_CANCEL,
            GTK_RESPONSE_REJECT,
            GTK_STOCK_OK,
            GTK_RESPONSE_ACCEPT,
            NULL);
    gtk_window_set_default_size ((GtkWindow *) dialog, 292, 260);
    gtk_widget_ensure_style (dialog);
    gtk_container_set_border_width ((GtkContainer *) ((GtkDialog *) dialog)->vbox, 12);
    box = gtk_vbox_new (FALSE, 6);
    w = gtk_label_new ("");
    msg = g_strdup_printf("<b>%s</b>", _("Junk Mail Settings"));
    gtk_label_set_markup (GTK_LABEL (w), msg);
    gtk_box_pack_start ((GtkBox *) box, w, FALSE, FALSE, 6);
    g_free(msg);

    junk_tab = junk_settings_new (cnc);
    w = (GtkWidget *)junk_tab->vbox;
    gtk_box_pack_start ((GtkBox *) box, w, FALSE, FALSE, 6);

    /* We might have to add more options for settings i.e. more pages */
    while (page_count > 0 ) {
        notebook = gtk_notebook_new ();
        gtk_notebook_append_page ((GtkNotebook *)notebook, box, NULL);
        gtk_box_pack_start (
            (GtkBox *) ((GtkDialog *) dialog)->vbox,
            notebook, TRUE, TRUE, 0);
    }

    if (page_count == 0)
        gtk_box_pack_start ((GtkBox *) ((GtkDialog *) dialog)->vbox, box, TRUE, TRUE, 0);

    g_signal_connect (dialog, "response", G_CALLBACK (junk_dialog_response), junk_tab);
    gtk_widget_show_all (dialog);
}