evolution-3.6.4/mail/em-vfolder-editor.c

No issues found

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