1 /*
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
10 * for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public License
13 * along with this program; if not, see <http://www.gnu.org/licenses/>.
14 *
15 *
16 * Authors:
17 * Not Zed <notzed@lostzed.mmc.com.au>
18 * Jeffrey Stedfast <fejj@ximian.com>
19 *
20 *
21 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
22 *
23 */
24
25 #include "evolution-config.h"
26
27 #include <gtk/gtk.h>
28 #include <glib/gi18n.h>
29
30 #include "e-util/e-util.h"
31 #include "e-util/e-util-private.h"
32
33 #include "em-vfolder-editor.h"
34 #include "em-vfolder-editor-rule.h"
35
G_DEFINE_TYPE(EMVFolderEditor,em_vfolder_editor,E_TYPE_RULE_EDITOR)36 G_DEFINE_TYPE (
37 EMVFolderEditor,
38 em_vfolder_editor,
39 E_TYPE_RULE_EDITOR)
40
41 static EFilterRule *
42 vfolder_editor_create_rule (ERuleEditor *rule_editor)
43 {
44 EMVFolderEditorContext *context;
45 EMailSession *session;
46 EFilterRule *rule;
47 EFilterPart *part;
48
49 context = EM_VFOLDER_EDITOR_CONTEXT (rule_editor->context);
50 session = em_vfolder_editor_context_get_session (context);
51
52 /* create a rule with 1 part in it */
53 rule = em_vfolder_editor_rule_new (session);
54 part = e_rule_context_next_part (rule_editor->context, NULL);
55 e_filter_rule_add_part (rule, e_filter_part_clone (part));
56
57 return rule;
58 }
59
60 static void
em_vfolder_editor_class_init(EMVFolderEditorClass * class)61 em_vfolder_editor_class_init (EMVFolderEditorClass *class)
62 {
63 ERuleEditorClass *rule_editor_class;
64
65 rule_editor_class = E_RULE_EDITOR_CLASS (class);
66 rule_editor_class->create_rule = vfolder_editor_create_rule;
67 }
68
69 static void
em_vfolder_editor_init(EMVFolderEditor * vfolder_editor)70 em_vfolder_editor_init (EMVFolderEditor *vfolder_editor)
71 {
72 gtk_window_set_default_size (GTK_WINDOW (vfolder_editor), 400, 650);
73
74 e_restore_window (
75 GTK_WINDOW (vfolder_editor),
76 "/org/gnome/evolution/mail/vfolder-window/",
77 E_RESTORE_WINDOW_SIZE);
78 }
79
80 /**
81 * em_vfolder_editor_new:
82 *
83 * Create a new EMVFolderEditor object.
84 *
85 * Returns: a new #EMVFolderEditor
86 **/
87 GtkWidget *
em_vfolder_editor_new(EMVFolderContext * context)88 em_vfolder_editor_new (EMVFolderContext *context)
89 {
90 EMVFolderEditor *editor;
91 GtkBuilder *builder;
92
93 g_return_val_if_fail (EM_IS_VFOLDER_CONTEXT (context), NULL);
94
95 editor = g_object_new (EM_TYPE_VFOLDER_EDITOR, NULL);
96
97 builder = gtk_builder_new ();
98 e_load_ui_builder_definition (builder, "filter.ui");
99
100 e_rule_editor_construct (
101 E_RULE_EDITOR (editor), E_RULE_CONTEXT (context),
102 builder, "incoming", _("Search _Folders"));
103 gtk_widget_hide (e_builder_get_widget (builder, "label17"));
104 gtk_widget_hide (e_builder_get_widget (builder, "filter_source_combobox"));
105 g_object_unref (builder);
106
107 return GTK_WIDGET (editor);
108 }
109