From e758de5b1d7f0e257ff034caa9d73db64607a800 Mon Sep 17 00:00:00 2001 From: Srinivasa Ragavan Date: Thu, 1 Mar 2012 22:34:32 +0530 Subject: Redo Filters/Search folder editors to use a shared non ui based library for making search folders running remotely. --- mail/Makefile.am | 12 +- mail/em-filter-context.c | 4 +- mail/em-filter-editor-folder-element.c | 230 ++++++++++ mail/em-filter-editor-folder-element.h | 73 ++++ mail/em-filter-folder-element.c | 362 ---------------- mail/em-filter-folder-element.h | 77 ---- mail/em-folder-tree.c | 2 +- mail/em-folder-utils.c | 4 +- mail/em-vfolder-context.c | 204 --------- mail/em-vfolder-context.h | 72 ---- mail/em-vfolder-editor-context.c | 216 ++++++++++ mail/em-vfolder-editor-context.h | 73 ++++ mail/em-vfolder-editor-rule.c | 505 ++++++++++++++++++++++ mail/em-vfolder-editor-rule.h | 81 ++++ mail/em-vfolder-editor.c | 10 +- mail/em-vfolder-editor.h | 2 +- mail/em-vfolder-rule.c | 767 --------------------------------- mail/em-vfolder-rule.h | 91 ---- mail/mail-autofilter.c | 12 +- mail/mail-autofilter.h | 2 +- mail/mail-vfolder.c | 14 +- mail/mail-vfolder.h | 2 +- 22 files changed, 1210 insertions(+), 1605 deletions(-) create mode 100644 mail/em-filter-editor-folder-element.c create mode 100644 mail/em-filter-editor-folder-element.h delete mode 100644 mail/em-filter-folder-element.c delete mode 100644 mail/em-filter-folder-element.h delete mode 100644 mail/em-vfolder-context.c delete mode 100644 mail/em-vfolder-context.h create mode 100644 mail/em-vfolder-editor-context.c create mode 100644 mail/em-vfolder-editor-context.h create mode 100644 mail/em-vfolder-editor-rule.c create mode 100644 mail/em-vfolder-editor-rule.h delete mode 100644 mail/em-vfolder-rule.c delete mode 100644 mail/em-vfolder-rule.h (limited to 'mail') diff --git a/mail/Makefile.am b/mail/Makefile.am index 0273c245f6..ebc3f6669f 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -68,7 +68,7 @@ mailinclude_HEADERS = \ em-event.h \ em-filter-context.h \ em-filter-editor.h \ - em-filter-folder-element.h \ + em-filter-editor-folder-element.h \ em-filter-rule.h \ em-filter-source-element.h \ em-folder-properties.h \ @@ -86,9 +86,9 @@ mailinclude_HEADERS = \ em-subscription-editor.h \ em-sync-stream.h \ em-utils.h \ - em-vfolder-context.h \ + em-vfolder-editor-context.h \ + em-vfolder-editor-rule.h \ em-vfolder-editor.h \ - em-vfolder-rule.h \ mail-autofilter.h \ mail-guess-servers.h \ mail-send-recv.h \ @@ -133,7 +133,7 @@ libevolution_mail_la_SOURCES = \ em-event.c \ em-filter-context.c \ em-filter-editor.c \ - em-filter-folder-element.c \ + em-filter-editor-folder-element.c \ em-filter-rule.c \ em-filter-source-element.c \ em-folder-properties.c \ @@ -151,9 +151,9 @@ libevolution_mail_la_SOURCES = \ em-subscription-editor.c \ em-sync-stream.c \ em-utils.c \ - em-vfolder-context.c \ + em-vfolder-editor-context.c \ + em-vfolder-editor-rule.c \ em-vfolder-editor.c \ - em-vfolder-rule.c \ mail-autofilter.c \ mail-guess-servers.c \ mail-send-recv.c \ diff --git a/mail/em-filter-context.c b/mail/em-filter-context.c index 6a5822c7a1..41c27ff375 100644 --- a/mail/em-filter-context.c +++ b/mail/em-filter-context.c @@ -34,7 +34,7 @@ #include "em-filter-source-element.h" /* For poking into filter-folder guts */ -#include "em-filter-folder-element.h" +#include "em-filter-editor-folder-element.h" #define EM_FILTER_CONTEXT_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -236,7 +236,7 @@ filter_context_new_element (ERuleContext *context, priv = EM_FILTER_CONTEXT_GET_PRIVATE (context); if (strcmp (type, "folder") == 0) - return em_filter_folder_element_new (priv->session); + return em_filter_editor_folder_element_new (priv->session); if (strcmp (type, "system-flag") == 0) return e_filter_option_new (); diff --git a/mail/em-filter-editor-folder-element.c b/mail/em-filter-editor-folder-element.c new file mode 100644 index 0000000000..5943ff18a9 --- /dev/null +++ b/mail/em-filter-editor-folder-element.c @@ -0,0 +1,230 @@ +/* + * + * 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 + * + * + * Authors: + * Not Zed + * Jeffrey Stedfast + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include +#include + +#include "em-filter-editor-folder-element.h" +#include "mail/em-folder-selection-button.h" +#include "mail/em-utils.h" +#include "shell/e-shell.h" +#include "filter/e-filter-part.h" +#include "libevolution-utils/e-alert.h" + +#define EM_FILTER_EDITOR_FOLDER_ELEMENT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT, EMFilterEditorFolderElementPrivate)) + +struct _EMFilterEditorFolderElementPrivate { + EMailSession *session; +}; + +enum { + PROP_0, + PROP_SESSION +}; + +G_DEFINE_TYPE ( + EMFilterEditorFolderElement, + em_filter_editor_folder_element, + EM_TYPE_FILTER_FOLDER_ELEMENT) + +static void +filter_editor_folder_element_set_session (EMFilterEditorFolderElement *element, + EMailSession *session) +{ + if (session == NULL) { + EShell *shell; + EShellBackend *shell_backend; + EMailBackend *backend; + + shell = e_shell_get_default (); + shell_backend = e_shell_get_backend_by_name (shell, "mail"); + + backend = E_MAIL_BACKEND (shell_backend); + session = e_mail_backend_get_session (backend); + } + + g_return_if_fail (E_IS_MAIL_SESSION (session)); + g_return_if_fail (element->priv->session == NULL); + + element->priv->session = g_object_ref (session); +} + +static void +filter_editor_folder_element_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SESSION: + filter_editor_folder_element_set_session ( + EM_FILTER_EDITOR_FOLDER_ELEMENT (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +filter_editor_folder_element_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SESSION: + g_value_set_object ( + value, + em_filter_editor_folder_element_get_session ( + EM_FILTER_EDITOR_FOLDER_ELEMENT (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +filter_editor_folder_element_selected_cb (EMFolderSelectionButton *button, + EMFilterEditorFolderElement *ff) +{ + GtkWidget *toplevel; + const gchar *uri; + + uri = em_folder_selection_button_get_folder_uri (button); + + em_filter_folder_element_set_uri ((EMFilterFolderElement *) ff, uri); + + toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button)); + gtk_window_present (GTK_WINDOW (toplevel)); +} + +static void +filter_editor_folder_element_dispose (GObject *object) +{ + EMFilterEditorFolderElementPrivate *priv; + + priv = EM_FILTER_EDITOR_FOLDER_ELEMENT_GET_PRIVATE (object); + if (priv->session != NULL) { + g_object_unref (priv->session); + priv->session = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (em_filter_editor_folder_element_parent_class)->dispose (object); +} + +static void +filter_editor_folder_element_finalize (GObject *object) +{ + EMFilterEditorFolderElementPrivate *priv; + + priv = EM_FILTER_EDITOR_FOLDER_ELEMENT_GET_PRIVATE (object); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (em_filter_editor_folder_element_parent_class)->finalize (object); +} + +static GtkWidget * +filter_editor_folder_element_get_widget (EFilterElement *fe) +{ + EMFilterEditorFolderElement *ff = (EMFilterEditorFolderElement *) fe; + EMailSession *session; + GtkWidget *button; + + session = em_filter_editor_folder_element_get_session (ff); + + button = em_folder_selection_button_new ( + session, _("Select Folder"), NULL); + em_folder_selection_button_set_folder_uri ( + EM_FOLDER_SELECTION_BUTTON (button), em_filter_folder_element_get_uri ((EMFilterFolderElement *) ff)); + gtk_widget_show (button); + + g_signal_connect ( + button, "selected", + G_CALLBACK (filter_editor_folder_element_selected_cb), ff); + + return button; +} + +static void +em_filter_editor_folder_element_class_init (EMFilterEditorFolderElementClass *class) +{ + GObjectClass *object_class; + EFilterElementClass *filter_element_class; + + g_type_class_add_private (class, sizeof (EMFilterEditorFolderElementPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = filter_editor_folder_element_set_property; + object_class->get_property = filter_editor_folder_element_get_property; + object_class->dispose = filter_editor_folder_element_dispose; + object_class->finalize = filter_editor_folder_element_finalize; + + filter_element_class = E_FILTER_ELEMENT_CLASS (class); + filter_element_class->get_widget = filter_editor_folder_element_get_widget; + + g_object_class_install_property ( + object_class, + PROP_SESSION, + g_param_spec_object ( + "session", + NULL, + NULL, + E_TYPE_MAIL_SESSION, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); +} + +static void +em_filter_editor_folder_element_init (EMFilterEditorFolderElement *element) +{ + element->priv = EM_FILTER_EDITOR_FOLDER_ELEMENT_GET_PRIVATE (element); +} + +EFilterElement * +em_filter_editor_folder_element_new (EMailSession *session) +{ + g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + + return g_object_new ( + EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT, + "session", session, NULL); +} + +EMailSession * +em_filter_editor_folder_element_get_session (EMFilterEditorFolderElement *element) +{ + g_return_val_if_fail (EM_IS_FILTER_EDITOR_FOLDER_ELEMENT (element), NULL); + + return element->priv->session; +} diff --git a/mail/em-filter-editor-folder-element.h b/mail/em-filter-editor-folder-element.h new file mode 100644 index 0000000000..acb84bb10e --- /dev/null +++ b/mail/em-filter-editor-folder-element.h @@ -0,0 +1,73 @@ +/* + * + * 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 + * + * + * Authors: + * Not Zed + * Jeelementrey Stedfast + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef EM_FILTER_EDITOR_FOLDER_ELEMENT_H +#define EM_FILTER_EDITOR_FOLDER_ELEMENT_H + +#include +#include +#include + +/* Standard GObject macros */ +#define EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT \ + (em_filter_editor_folder_element_get_type ()) +#define EM_FILTER_EDITOR_FOLDER_ELEMENT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT, EMFilterEditorFolderElement)) +#define EM_FILTER_EDITOR_FOLDER_ELEMENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT, EMFilterEditorFolderElementClass)) +#define EM_IS_FILTER_EDITOR_FOLDER_ELEMENT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT)) +#define EM_IS_FILTER_EDITOR_FOLDER_ELEMENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT)) +#define EM_FILTER_EDITOR_FOLDER_ELEMENT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT, EMFilterEditorFolderElementClass)) + +G_BEGIN_DECLS + +typedef struct _EMFilterEditorFolderElement EMFilterEditorFolderElement; +typedef struct _EMFilterEditorFolderElementClass EMFilterEditorFolderElementClass; +typedef struct _EMFilterEditorFolderElementPrivate EMFilterEditorFolderElementPrivate; + +struct _EMFilterEditorFolderElement { + EMFilterFolderElement parent; + EMFilterEditorFolderElementPrivate *priv; +}; + +struct _EMFilterEditorFolderElementClass { + EMFilterFolderElementClass parent_class; +}; + +GType em_filter_editor_folder_element_get_type (void); +EFilterElement *em_filter_editor_folder_element_new (EMailSession *session); +EMailSession * em_filter_editor_folder_element_get_session + (EMFilterEditorFolderElement *element); + +G_END_DECLS + +#endif /* EM_FILTER_EDITOR_FOLDER_ELEMENT_H */ diff --git a/mail/em-filter-folder-element.c b/mail/em-filter-folder-element.c deleted file mode 100644 index 7b88991d92..0000000000 --- a/mail/em-filter-folder-element.c +++ /dev/null @@ -1,362 +0,0 @@ -/* - * - * 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 - * - * - * Authors: - * Not Zed - * Jeffrey Stedfast - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include - -#include "em-filter-folder-element.h" -#include "mail/em-folder-selection-button.h" -#include "mail/em-utils.h" -#include "shell/e-shell.h" -#include "filter/e-filter-part.h" -#include "libevolution-utils/e-alert.h" - -#define EM_FILTER_FOLDER_ELEMENT_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), EM_TYPE_FILTER_FOLDER_ELEMENT, EMFilterFolderElementPrivate)) - -struct _EMFilterFolderElementPrivate { - EMailSession *session; - gchar *uri; -}; - -enum { - PROP_0, - PROP_SESSION -}; - -G_DEFINE_TYPE ( - EMFilterFolderElement, - em_filter_folder_element, - E_TYPE_FILTER_ELEMENT) - -static void -filter_folder_element_selected_cb (EMFolderSelectionButton *button, - EMFilterFolderElement *ff) -{ - GtkWidget *toplevel; - const gchar *uri; - - uri = em_folder_selection_button_get_folder_uri (button); - - g_free (ff->priv->uri); - ff->priv->uri = g_strdup (uri); - - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button)); - gtk_window_present (GTK_WINDOW (toplevel)); -} - -static void -filter_folder_element_set_session (EMFilterFolderElement *element, - EMailSession *session) -{ - /* FIXME Dirty hack. Session should be passed in always. */ - if (session == NULL) { - EShell *shell; - EShellBackend *shell_backend; - EMailBackend *backend; - - shell = e_shell_get_default (); - shell_backend = e_shell_get_backend_by_name (shell, "mail"); - - backend = E_MAIL_BACKEND (shell_backend); - session = e_mail_backend_get_session (backend); - } - - g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_return_if_fail (element->priv->session == NULL); - - element->priv->session = g_object_ref (session); -} - -static void -filter_folder_element_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SESSION: - filter_folder_element_set_session ( - EM_FILTER_FOLDER_ELEMENT (object), - g_value_get_object (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -filter_folder_element_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SESSION: - g_value_set_object ( - value, - em_filter_folder_element_get_session ( - EM_FILTER_FOLDER_ELEMENT (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -filter_folder_element_dispose (GObject *object) -{ - EMFilterFolderElementPrivate *priv; - - priv = EM_FILTER_FOLDER_ELEMENT_GET_PRIVATE (object); - - if (priv->session != NULL) { - g_object_unref (priv->session); - priv->session = NULL; - } - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (em_filter_folder_element_parent_class)->dispose (object); -} - -static void -filter_folder_element_finalize (GObject *object) -{ - EMFilterFolderElementPrivate *priv; - - priv = EM_FILTER_FOLDER_ELEMENT_GET_PRIVATE (object); - - g_free (priv->uri); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (em_filter_folder_element_parent_class)->finalize (object); -} - -static gboolean -filter_folder_element_validate (EFilterElement *fe, - EAlert **alert) -{ - EMFilterFolderElement *ff = (EMFilterFolderElement *) fe; - - g_warn_if_fail (alert == NULL || *alert == NULL); - - if (ff->priv->uri != NULL && *ff->priv->uri != '\0') - return TRUE; - - if (alert) - *alert = e_alert_new ("mail:no-folder", NULL); - - return FALSE; -} - -static gint -filter_folder_element_eq (EFilterElement *fe, - EFilterElement *cm) -{ - return E_FILTER_ELEMENT_CLASS ( - em_filter_folder_element_parent_class)->eq (fe, cm) && - strcmp (((EMFilterFolderElement *) fe)->priv->uri, - ((EMFilterFolderElement *) cm)->priv->uri)== 0; -} - -static xmlNodePtr -filter_folder_element_xml_encode (EFilterElement *fe) -{ - xmlNodePtr value, work; - EMFilterFolderElement *ff = (EMFilterFolderElement *) fe; - - value = xmlNewNode (NULL, (xmlChar *) "value"); - xmlSetProp (value, (xmlChar *) "name", (xmlChar *) fe->name); - xmlSetProp (value, (xmlChar *) "type", (xmlChar *) "folder"); - - work = xmlNewChild (value, NULL, (xmlChar *) "folder", NULL); - xmlSetProp (work, (xmlChar *) "uri", (xmlChar *) ff->priv->uri); - - return value; -} - -static gint -filter_folder_element_xml_decode (EFilterElement *fe, - xmlNodePtr node) -{ - EMFilterFolderElement *ff = (EMFilterFolderElement *) fe; - xmlNodePtr n; - - xmlFree (fe->name); - fe->name = (gchar *) xmlGetProp(node, (xmlChar *) "name"); - - n = node->children; - while (n) { - if (!strcmp((gchar *) n->name, "folder")) { - gchar *uri; - - uri = (gchar *) xmlGetProp(n, (xmlChar *) "uri"); - g_free (ff->priv->uri); - ff->priv->uri = g_strdup (uri); - xmlFree (uri); - break; - } - n = n->next; - } - - return 0; -} - -static GtkWidget * -filter_folder_element_get_widget (EFilterElement *fe) -{ - EMFilterFolderElement *ff = (EMFilterFolderElement *) fe; - EMailSession *session; - GtkWidget *button; - - session = em_filter_folder_element_get_session (ff); - - button = em_folder_selection_button_new ( - session, _("Select Folder"), NULL); - em_folder_selection_button_set_folder_uri ( - EM_FOLDER_SELECTION_BUTTON (button), ff->priv->uri); - gtk_widget_show (button); - - g_signal_connect ( - button, "selected", - G_CALLBACK (filter_folder_element_selected_cb), ff); - - return button; -} - -static void -filter_folder_element_build_code (EFilterElement *fe, - GString *out, - EFilterPart *ff) -{ - /* We are doing nothing on purpose. */ -} - -static void -filter_folder_element_format_sexp (EFilterElement *fe, - GString *out) -{ - EMFilterFolderElement *ff = (EMFilterFolderElement *) fe; - - camel_sexp_encode_string (out, ff->priv->uri); -} - -static void -filter_folder_element_copy_value (EFilterElement *de, - EFilterElement *se) -{ - if (EM_IS_FILTER_FOLDER_ELEMENT (se)) { - em_filter_folder_element_set_uri ( - EM_FILTER_FOLDER_ELEMENT (de), - EM_FILTER_FOLDER_ELEMENT (se)->priv->uri); - } else { - E_FILTER_ELEMENT_CLASS ( - em_filter_folder_element_parent_class)->copy_value (de, se); - } -} -static void -em_filter_folder_element_class_init (EMFilterFolderElementClass *class) -{ - GObjectClass *object_class; - EFilterElementClass *filter_element_class; - - g_type_class_add_private (class, sizeof (EMFilterFolderElementPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->set_property = filter_folder_element_set_property; - object_class->get_property = filter_folder_element_get_property; - object_class->dispose = filter_folder_element_dispose; - object_class->finalize = filter_folder_element_finalize; - - filter_element_class = E_FILTER_ELEMENT_CLASS (class); - filter_element_class->validate = filter_folder_element_validate; - filter_element_class->eq = filter_folder_element_eq; - filter_element_class->xml_encode = filter_folder_element_xml_encode; - filter_element_class->xml_decode = filter_folder_element_xml_decode; - filter_element_class->get_widget = filter_folder_element_get_widget; - filter_element_class->build_code = filter_folder_element_build_code; - filter_element_class->format_sexp = filter_folder_element_format_sexp; - filter_element_class->copy_value = filter_folder_element_copy_value; - - g_object_class_install_property ( - object_class, - PROP_SESSION, - g_param_spec_object ( - "session", - NULL, - NULL, - E_TYPE_MAIL_SESSION, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); -} - -static void -em_filter_folder_element_init (EMFilterFolderElement *element) -{ - element->priv = EM_FILTER_FOLDER_ELEMENT_GET_PRIVATE (element); -} - -EFilterElement * -em_filter_folder_element_new (EMailSession *session) -{ - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); - - return g_object_new ( - EM_TYPE_FILTER_FOLDER_ELEMENT, - "session", session, NULL); -} - -EMailSession * -em_filter_folder_element_get_session (EMFilterFolderElement *element) -{ - g_return_val_if_fail (EM_IS_FILTER_FOLDER_ELEMENT (element), NULL); - - return element->priv->session; -} - -const gchar * -em_filter_folder_element_get_uri (EMFilterFolderElement *element) -{ - g_return_val_if_fail (EM_IS_FILTER_FOLDER_ELEMENT (element), NULL); - - return element->priv->uri; -} - -void -em_filter_folder_element_set_uri (EMFilterFolderElement *element, - const gchar *uri) -{ - g_return_if_fail (EM_IS_FILTER_FOLDER_ELEMENT (element)); - - g_free (element->priv->uri); - element->priv->uri = g_strdup (uri); -} - diff --git a/mail/em-filter-folder-element.h b/mail/em-filter-folder-element.h deleted file mode 100644 index f5a1741795..0000000000 --- a/mail/em-filter-folder-element.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * 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 - * - * - * Authors: - * Not Zed - * Jeelementrey Stedfast - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef EM_FILTER_FOLDER_ELEMENT_H -#define EM_FILTER_FOLDER_ELEMENT_H - -#include -#include - -/* Standard GObject macros */ -#define EM_TYPE_FILTER_FOLDER_ELEMENT \ - (em_filter_folder_element_get_type ()) -#define EM_FILTER_FOLDER_ELEMENT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), EM_TYPE_FILTER_FOLDER_ELEMENT, EMFilterFolderElement)) -#define EM_FILTER_FOLDER_ELEMENT_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), EM_TYPE_FILTER_FOLDER_ELEMENT, EMFilterFolderElementClass)) -#define EM_IS_FILTER_FOLDER_ELEMENT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), EM_TYPE_FILTER_FOLDER_ELEMENT)) -#define EM_IS_FILTER_FOLDER_ELEMENT_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), EM_TYPE_FILTER_FOLDER_ELEMENT)) -#define EM_FILTER_FOLDER_ELEMENT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), EM_TYPE_FILTER_FOLDER_ELEMENT, EMFilterFolderElementClass)) - -G_BEGIN_DECLS - -typedef struct _EMFilterFolderElement EMFilterFolderElement; -typedef struct _EMFilterFolderElementClass EMFilterFolderElementClass; -typedef struct _EMFilterFolderElementPrivate EMFilterFolderElementPrivate; - -struct _EMFilterFolderElement { - EFilterElement parent; - EMFilterFolderElementPrivate *priv; -}; - -struct _EMFilterFolderElementClass { - EFilterElementClass parent_class; -}; - -GType em_filter_folder_element_get_type (void); -EFilterElement *em_filter_folder_element_new (EMailSession *session); -EMailSession * em_filter_folder_element_get_session - (EMFilterFolderElement *element); -const gchar * em_filter_folder_element_get_uri - (EMFilterFolderElement *element); -void em_filter_folder_element_set_uri - (EMFilterFolderElement *element, - const gchar *uri); - -G_END_DECLS - -#endif /* EM_FILTER_FOLDER_ELEMENT_H */ diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 2a6f0b5b25..d8234f9498 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -46,7 +46,7 @@ #include "misc/e-selectable.h" -#include "em-vfolder-rule.h" +#include "em-vfolder-editor-rule.h" #include "libemail-utils/mail-mt.h" #include "libemail-engine/e-mail-folder-utils.h" diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index 3ffdd6c859..cbf458a799 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -44,7 +44,7 @@ #include "libevolution-utils/e-alert-dialog.h" #include "e-util/e-dialog-utils.h" -#include "em-vfolder-rule.h" +#include "em-vfolder-editor-rule.h" #include "libemail-utils/mail-mt.h" #include "libemail-engine/e-mail-folder-utils.h" @@ -655,7 +655,7 @@ em_folder_utils_create_folder (GtkWindow *parent, else skip_slash = folder_name; - rule = em_vfolder_rule_new (session); + rule = em_vfolder_editor_rule_new (session); e_filter_rule_set_name (rule, skip_slash); vfolder_gui_add_rule (EM_VFOLDER_RULE (rule)); } else { diff --git a/mail/em-vfolder-context.c b/mail/em-vfolder-context.c deleted file mode 100644 index 665700e9f5..0000000000 --- a/mail/em-vfolder-context.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * - * 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 - * - * - * Authors: - * Not Zed - * Jeffrey Stedfast - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "em-vfolder-context.h" -#include "em-vfolder-rule.h" -#include "filter/e-filter-option.h" -#include "filter/e-filter-int.h" - -#include "em-filter-folder-element.h" - -#define EM_VFOLDER_CONTEXT_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), EM_TYPE_VFOLDER_CONTEXT, EMVFolderContextPrivate)) - -struct _EMVFolderContextPrivate { - EMailSession *session; -}; - -enum { - PROP_0, - PROP_SESSION -}; - -G_DEFINE_TYPE ( - EMVFolderContext, - em_vfolder_context, - E_TYPE_RULE_CONTEXT) - -static void -vfolder_context_set_session (EMVFolderContext *context, - EMailSession *session) -{ - g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_return_if_fail (context->priv->session == NULL); - - context->priv->session = g_object_ref (session); -} - -static void -vfolder_context_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SESSION: - vfolder_context_set_session ( - EM_VFOLDER_CONTEXT (object), - g_value_get_object (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -vfolder_context_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SESSION: - g_value_set_object ( - value, - em_vfolder_context_get_session ( - EM_VFOLDER_CONTEXT (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -vfolder_context_dispose (GObject *object) -{ - EMVFolderContextPrivate *priv; - - priv = EM_VFOLDER_CONTEXT_GET_PRIVATE (object); - - if (priv->session != NULL) { - g_object_unref (priv->session); - priv->session = NULL; - } - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (em_vfolder_context_parent_class)->dispose (object); -} - -static EFilterElement * -vfolder_context_new_element (ERuleContext *context, - const gchar *type) -{ - EMVFolderContextPrivate *priv; - - priv = EM_VFOLDER_CONTEXT_GET_PRIVATE (context); - - if (strcmp (type, "system-flag") == 0) - return e_filter_option_new (); - - if (strcmp (type, "score") == 0) - return e_filter_int_new_type("score", -3, 3); - - if (strcmp (type, "folder") == 0) - return em_filter_folder_element_new (priv->session); - - /* XXX Legacy type name. Same as "folder" now. */ - if (strcmp (type, "folder-curi") == 0) - return em_filter_folder_element_new (priv->session); - - return E_RULE_CONTEXT_CLASS (em_vfolder_context_parent_class)-> - new_element (context, type); -} - -static void -em_vfolder_context_class_init (EMVFolderContextClass *class) -{ - GObjectClass *object_class; - ERuleContextClass *rule_context_class; - - g_type_class_add_private (class, sizeof (EMVFolderContextPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->set_property = vfolder_context_set_property; - object_class->get_property = vfolder_context_get_property; - object_class->dispose = vfolder_context_dispose; - - rule_context_class = E_RULE_CONTEXT_CLASS (class); - rule_context_class->new_element = vfolder_context_new_element; - - g_object_class_install_property ( - object_class, - PROP_SESSION, - g_param_spec_object ( - "session", - NULL, - NULL, - E_TYPE_MAIL_SESSION, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); -} - -static void -em_vfolder_context_init (EMVFolderContext *context) -{ - context->priv = EM_VFOLDER_CONTEXT_GET_PRIVATE (context); - - e_rule_context_add_part_set ( - E_RULE_CONTEXT (context), "partset", E_TYPE_FILTER_PART, - (ERuleContextPartFunc) e_rule_context_add_part, - (ERuleContextNextPartFunc) e_rule_context_next_part); - - e_rule_context_add_rule_set ( - E_RULE_CONTEXT (context), "ruleset", EM_TYPE_VFOLDER_RULE, - (ERuleContextRuleFunc) e_rule_context_add_rule, - (ERuleContextNextRuleFunc) e_rule_context_next_rule); - - E_RULE_CONTEXT (context)->flags = - E_RULE_CONTEXT_THREADING | E_RULE_CONTEXT_GROUPING; -} - -EMVFolderContext * -em_vfolder_context_new (EMailSession *session) -{ - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); - - return g_object_new ( - EM_TYPE_VFOLDER_CONTEXT, "session", session, NULL); -} - -EMailSession * -em_vfolder_context_get_session (EMVFolderContext *context) -{ - g_return_val_if_fail (EM_IS_VFOLDER_CONTEXT (context), NULL); - - return context->priv->session; -} diff --git a/mail/em-vfolder-context.h b/mail/em-vfolder-context.h deleted file mode 100644 index 2d1c6ef0fc..0000000000 --- a/mail/em-vfolder-context.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * 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 - * - * - * Authors: - * Not Zed - * Jeffrey Stedfast - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef EM_VFOLDER_CONTEXT_H -#define EM_VFOLDER_CONTEXT_H - -#include -#include - -/* Standard GObject macros */ -#define EM_TYPE_VFOLDER_CONTEXT \ - (em_vfolder_context_get_type ()) -#define EM_VFOLDER_CONTEXT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), EM_TYPE_VFOLDER_CONTEXT, EMVFolderContext)) -#define EM_VFOLDER_CONTEXT_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), EM_TYPE_VFOLDER_CONTEXT, EMVFolderContextClass)) -#define EM_IS_VFOLDER_CONTEXT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), EM_TYPE_VFOLDER_CONTEXT)) -#define EM_IS_VFOLDER_CONTEXT_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), EM_TYPE_VFOLDER_CONTEXT)) -#define EM_VFOLDER_CONTEXT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), EM_TYPE_VFOLDER_CONTEXT, EMVFolderContextClass)) - -G_BEGIN_DECLS - -typedef struct _EMVFolderContext EMVFolderContext; -typedef struct _EMVFolderContextClass EMVFolderContextClass; -typedef struct _EMVFolderContextPrivate EMVFolderContextPrivate; - -struct _EMVFolderContext { - ERuleContext parent; - EMVFolderContextPrivate *priv; -}; - -struct _EMVFolderContextClass { - ERuleContextClass parent_class; -}; - -GType em_vfolder_context_get_type (void); -EMVFolderContext * - em_vfolder_context_new (EMailSession *session); -EMailSession * em_vfolder_context_get_session (EMVFolderContext *context); - -G_END_DECLS - -#endif /* EM_VFOLDER_CONTEXT_H */ diff --git a/mail/em-vfolder-editor-context.c b/mail/em-vfolder-editor-context.c new file mode 100644 index 0000000000..89e0048bba --- /dev/null +++ b/mail/em-vfolder-editor-context.c @@ -0,0 +1,216 @@ +/* + * + * 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 + * + * + * Authors: + * Not Zed + * Jeffrey Stedfast + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "mail/em-utils.h" +#include "em-vfolder-editor-context.h" +#include "em-vfolder-editor-rule.h" +#include "filter/e-filter-option.h" +#include "filter/e-filter-int.h" + +#include "em-filter-editor-folder-element.h" + +#define EM_VFOLDER_EDITOR_CONTEXT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), EM_TYPE_VFOLDER_EDITOR_CONTEXT, EMVFolderEditorContextPrivate)) + +struct _EMVFolderEditorContextPrivate { + EMailSession *session; +}; + +enum { + PROP_0, + PROP_SESSION +}; + +G_DEFINE_TYPE ( + EMVFolderEditorContext, + em_vfolder_editor_context, + EM_TYPE_VFOLDER_CONTEXT) + +static void +vfolder_editor_context_set_session (EMVFolderEditorContext *context, + EMailSession *session) +{ + if (session == NULL) { + EShell *shell; + EShellBackend *shell_backend; + EMailBackend *backend; + + shell = e_shell_get_default (); + shell_backend = e_shell_get_backend_by_name (shell, "mail"); + + backend = E_MAIL_BACKEND (shell_backend); + session = e_mail_backend_get_session (backend); + } + + g_return_if_fail (E_IS_MAIL_SESSION (session)); + g_return_if_fail (context->priv->session == NULL); + + context->priv->session = g_object_ref (session); +} + +static void +vfolder_editor_context_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SESSION: + vfolder_editor_context_set_session ( + EM_VFOLDER_EDITOR_CONTEXT (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +vfolder_editor_context_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SESSION: + g_value_set_object ( + value, + em_vfolder_editor_context_get_session ( + EM_VFOLDER_EDITOR_CONTEXT (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +vfolder_editor_context_dispose (GObject *object) +{ + EMVFolderEditorContextPrivate *priv; + + priv = EM_VFOLDER_EDITOR_CONTEXT_GET_PRIVATE (object); + if (priv->session != NULL) { + g_object_unref (priv->session); + priv->session = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (em_vfolder_editor_context_parent_class)->dispose (object); +} + +static EFilterElement * +vfolder_editor_context_new_element (ERuleContext *context, + const gchar *type) +{ + EMVFolderEditorContextPrivate *priv; + + priv = EM_VFOLDER_EDITOR_CONTEXT_GET_PRIVATE (context); + + if (strcmp (type, "system-flag") == 0) + return e_filter_option_new (); + + if (strcmp (type, "score") == 0) + return e_filter_int_new_type("score", -3, 3); + + if (strcmp (type, "folder") == 0) + return em_filter_editor_folder_element_new (priv->session); + + /* XXX Legacy type name. Same as "folder" now. */ + if (strcmp (type, "folder-curi") == 0) + return em_filter_editor_folder_element_new (priv->session); + + return E_RULE_CONTEXT_CLASS (em_vfolder_editor_context_parent_class)-> + new_element (context, type); +} + +static void +em_vfolder_editor_context_class_init (EMVFolderEditorContextClass *class) +{ + GObjectClass *object_class; + ERuleContextClass *rule_context_class; + + g_type_class_add_private (class, sizeof (EMVFolderEditorContextPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = vfolder_editor_context_set_property; + object_class->get_property = vfolder_editor_context_get_property; + object_class->dispose = vfolder_editor_context_dispose; + + rule_context_class = E_RULE_CONTEXT_CLASS (class); + rule_context_class->new_element = vfolder_editor_context_new_element; + + g_object_class_install_property ( + object_class, + PROP_SESSION, + g_param_spec_object ( + "session", + NULL, + NULL, + E_TYPE_MAIL_SESSION, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); +} + +static void +em_vfolder_editor_context_init (EMVFolderEditorContext *context) +{ + context->priv = EM_VFOLDER_EDITOR_CONTEXT_GET_PRIVATE (context); + + e_rule_context_add_part_set ( + E_RULE_CONTEXT (context), "partset", E_TYPE_FILTER_PART, + (ERuleContextPartFunc) e_rule_context_add_part, + (ERuleContextNextPartFunc) e_rule_context_next_part); + + e_rule_context_add_rule_set ( + E_RULE_CONTEXT (context), "ruleset", EM_TYPE_VFOLDER_EDITOR_RULE, + (ERuleContextRuleFunc) e_rule_context_add_rule, + (ERuleContextNextRuleFunc) e_rule_context_next_rule); + + E_RULE_CONTEXT (context)->flags = + E_RULE_CONTEXT_THREADING | E_RULE_CONTEXT_GROUPING; +} + +EMVFolderEditorContext * +em_vfolder_editor_context_new (EMailSession *session) +{ + g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + + return g_object_new ( + EM_TYPE_VFOLDER_EDITOR_CONTEXT, "session", session, NULL); +} + +EMailSession * +em_vfolder_editor_context_get_session (EMVFolderEditorContext *context) +{ + g_return_val_if_fail (EM_IS_VFOLDER_EDITOR_CONTEXT (context), NULL); + + return context->priv->session; +} diff --git a/mail/em-vfolder-editor-context.h b/mail/em-vfolder-editor-context.h new file mode 100644 index 0000000000..062d8bf08a --- /dev/null +++ b/mail/em-vfolder-editor-context.h @@ -0,0 +1,73 @@ +/* + * + * 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 + * + * + * Authors: + * Not Zed + * Jeffrey Stedfast + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef EM_VFOLDER_EDITOR_CONTEXT_H +#define EM_VFOLDER_EDITOR_CONTEXT_H + +#include +#include +#include + +/* Standard GObject macros */ +#define EM_TYPE_VFOLDER_EDITOR_CONTEXT \ + (em_vfolder_editor_context_get_type ()) +#define EM_VFOLDER_EDITOR_CONTEXT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), EM_TYPE_VFOLDER_EDITOR_CONTEXT, EMVFolderEditorContext)) +#define EM_VFOLDER_EDITOR_CONTEXT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), EM_TYPE_VFOLDER_EDITOR_CONTEXT, EMVFolderEditorContextClass)) +#define EM_IS_VFOLDER_EDITOR_CONTEXT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), EM_TYPE_VFOLDER_EDITOR_CONTEXT)) +#define EM_IS_VFOLDER_EDITOR_CONTEXT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), EM_TYPE_VFOLDER_EDITOR_CONTEXT)) +#define EM_VFOLDER_EDITOR_CONTEXT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), EM_TYPE_VFOLDER_EDITOR_CONTEXT, EMVFolderEditorContextClass)) + +G_BEGIN_DECLS + +typedef struct _EMVFolderEditorContext EMVFolderEditorContext; +typedef struct _EMVFolderEditorContextClass EMVFolderEditorContextClass; +typedef struct _EMVFolderEditorContextPrivate EMVFolderEditorContextPrivate; + +struct _EMVFolderEditorContext { + EMVFolderContext parent; + EMVFolderEditorContextPrivate *priv; +}; + +struct _EMVFolderEditorContextClass { + EMVFolderContextClass parent_class; +}; + +GType em_vfolder_editor_context_get_type (void); +EMVFolderEditorContext * + em_vfolder_editor_context_new (EMailSession *session); +EMailSession * em_vfolder_editor_context_get_session (EMVFolderEditorContext *context); + +G_END_DECLS + +#endif /* EM_VFOLDER_EDITOR_CONTEXT_H */ diff --git a/mail/em-vfolder-editor-rule.c b/mail/em-vfolder-editor-rule.c new file mode 100644 index 0000000000..377bf1e23e --- /dev/null +++ b/mail/em-vfolder-editor-rule.c @@ -0,0 +1,505 @@ +/* + * 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 + * + * + * Authors: + * Not Zed + * Jeffrey Stedfast + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include +#include + +#include + +#include +#include +#include + +#include + +#include "em-folder-selector.h" +#include "em-folder-tree.h" +#include "em-utils.h" +#include "em-vfolder-editor-context.h" +#include "em-vfolder-editor-rule.h" + +#define EM_VFOLDER_EDITOR_RULE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), EM_TYPE_VFOLDER_EDITOR_RULE, EMVFolderEditorRulePrivate)) + +#define EM_VFOLDER_EDITOR_RULE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), EM_TYPE_VFOLDER_EDITOR_RULE, EMVFolderEditorRulePrivate)) + +struct _EMVFolderEditorRulePrivate { + EMailSession *session; +}; + +enum { + PROP_0, + PROP_SESSION +}; + +static GtkWidget *get_widget (EFilterRule *fr, ERuleContext *f); + +G_DEFINE_TYPE ( + EMVFolderEditorRule, + em_vfolder_editor_rule, + EM_TYPE_VFOLDER_RULE) + +static void +vfolder_editor_rule_set_session (EMVFolderEditorRule *rule, + EMailSession *session) +{ + if (session == NULL) { + EShell *shell; + EShellBackend *shell_backend; + EMailBackend *backend; + + shell = e_shell_get_default (); + shell_backend = e_shell_get_backend_by_name (shell, "mail"); + + backend = E_MAIL_BACKEND (shell_backend); + session = e_mail_backend_get_session (backend); + } + + g_return_if_fail (E_IS_MAIL_SESSION (session)); + g_return_if_fail (rule->priv->session == NULL); + + rule->priv->session = g_object_ref (session); +} + +static void +vfolder_editor_rule_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SESSION: + vfolder_editor_rule_set_session ( + EM_VFOLDER_EDITOR_RULE (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +vfolder_editor_rule_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SESSION: + g_value_set_object ( + value, + em_vfolder_editor_rule_get_session ( + EM_VFOLDER_EDITOR_RULE (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +vfolder_editor_rule_dispose (GObject *object) +{ + EMVFolderEditorRulePrivate *priv; + + priv = EM_VFOLDER_EDITOR_RULE_GET_PRIVATE (object); + if (priv->session != NULL) { + g_object_unref (priv->session); + priv->session = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (em_vfolder_editor_rule_parent_class)->dispose (object); +} + +static void +vfolder_editor_rule_finalize (GObject *object) +{ + /* EMVFolderEditorRule *rule = EM_VFOLDER_EDITOR_RULE (object); */ + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (em_vfolder_editor_rule_parent_class)->finalize (object); +} + +static void +em_vfolder_editor_rule_class_init (EMVFolderEditorRuleClass *class) +{ + GObjectClass *object_class; + EFilterRuleClass *filter_rule_class; + + g_type_class_add_private (class, sizeof (EMVFolderEditorRulePrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = vfolder_editor_rule_set_property; + object_class->get_property = vfolder_editor_rule_get_property; + object_class->dispose = vfolder_editor_rule_dispose; + object_class->finalize = vfolder_editor_rule_finalize; + + filter_rule_class = E_FILTER_RULE_CLASS (class); + filter_rule_class->get_widget = get_widget; + + g_object_class_install_property ( + object_class, + PROP_SESSION, + g_param_spec_object ( + "session", + NULL, + NULL, + E_TYPE_MAIL_SESSION, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); +} + +static void +em_vfolder_editor_rule_init (EMVFolderEditorRule *rule) +{ + rule->priv = EM_VFOLDER_EDITOR_RULE_GET_PRIVATE (rule); +} + +EFilterRule * +em_vfolder_editor_rule_new (EMailSession *session) +{ + g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + + return g_object_new ( + EM_TYPE_VFOLDER_EDITOR_RULE, "session", session, NULL); +} + +EMailSession * +em_vfolder_editor_rule_get_session (EMVFolderEditorRule *rule) +{ + g_return_val_if_fail (EM_IS_VFOLDER_RULE (rule), NULL); + + return rule->priv->session; +} + +enum { + BUTTON_ADD, + BUTTON_REMOVE, + BUTTON_LAST +}; + +struct _source_data { + ERuleContext *rc; + EMVFolderRule *vr; + const gchar *current; + GtkListStore *model; + GtkTreeView *list; + GtkWidget *source_selector; + GtkButton *buttons[BUTTON_LAST]; +}; + +static void source_add (GtkWidget *widget, struct _source_data *data); +static void source_remove (GtkWidget *widget, struct _source_data *data); + +static struct { + const gchar *name; + GCallback func; +} edit_buttons[] = { + { "source_add", G_CALLBACK(source_add) }, + { "source_remove", G_CALLBACK(source_remove)}, +}; + +static void +set_sensitive (struct _source_data *data) +{ + gtk_widget_set_sensitive ( + GTK_WIDGET (data->buttons[BUTTON_ADD]), TRUE); + gtk_widget_set_sensitive ( + GTK_WIDGET (data->buttons[BUTTON_REMOVE]), + data->current != NULL); +} + +static void +select_source (GtkWidget *list, + struct _source_data *data) +{ + GtkTreeViewColumn *column; + GtkTreePath *path; + GtkTreeIter iter; + + gtk_tree_view_get_cursor (data->list, &path, &column); + gtk_tree_model_get_iter (GTK_TREE_MODEL (data->model), &iter, path); + gtk_tree_path_free (path); + + gtk_tree_model_get (GTK_TREE_MODEL (data->model), &iter, 0, &data->current, -1); + + set_sensitive (data); +} + +static void +select_source_with_changed (GtkWidget *widget, + struct _source_data *data) +{ + em_vfolder_rule_with_t with = 0; + GSList *group = NULL; + gint i = 0; + + if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) + return; + + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget)); + + for (i = 0; i< g_slist_length (group); i++) { + if (g_slist_nth_data (group, with = i) == widget) + break; + } + + if (with > EM_VFOLDER_RULE_WITH_LOCAL ) + with = 0; + + gtk_widget_set_sensitive (data->source_selector, !with ); + + data->vr->with = with; +} + +static void +vfr_folder_response (EMFolderSelector *selector, + gint button, + struct _source_data *data) +{ + EMFolderTreeModel *model; + EMailSession *session; + const gchar *uri; + + model = em_folder_selector_get_model (selector); + session = em_folder_tree_model_get_session (model); + + uri = em_folder_selector_get_selected_uri (selector); + + if (button == GTK_RESPONSE_OK && uri != NULL) { + GtkTreeSelection *selection; + GtkTreeIter iter; + gchar *markup; + + g_queue_push_tail (&data->vr->sources, g_strdup (uri)); + + markup = e_mail_folder_uri_to_markup ( + CAMEL_SESSION (session), uri, NULL); + + gtk_list_store_append (data->model, &iter); + gtk_list_store_set (data->model, &iter, 0, markup, 1, uri, -1); + selection = gtk_tree_view_get_selection (data->list); + gtk_tree_selection_select_iter (selection, &iter); + data->current = uri; + + g_free (markup); + + set_sensitive (data); + } + + gtk_widget_destroy (GTK_WIDGET (selector)); +} + +static void +source_add (GtkWidget *widget, + struct _source_data *data) +{ + EMFolderTree *folder_tree; + EMFolderTreeModel *model; + GtkWidget *dialog; + gpointer parent; + + parent = gtk_widget_get_toplevel (widget); + parent = gtk_widget_is_toplevel (parent) ? parent : NULL; + + model = em_folder_tree_model_get_default (); + + dialog = em_folder_selector_new ( + parent, model, + EM_FOLDER_SELECTOR_CAN_CREATE, + _("Add Folder"), NULL, _("_Add")); + + folder_tree = em_folder_selector_get_folder_tree ( + EM_FOLDER_SELECTOR (dialog)); + + em_folder_tree_set_excluded (folder_tree, EMFT_EXCLUDE_NOSELECT); + + g_signal_connect ( + dialog, "response", + G_CALLBACK (vfr_folder_response), data); + + gtk_widget_show (dialog); +} + +static void +source_remove (GtkWidget *widget, + struct _source_data *data) +{ + GtkTreeSelection *selection; + const gchar *source; + GtkTreePath *path; + GtkTreeIter iter; + gint index = 0; + gint n; + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->list)); + + source = NULL; + while ((source = em_vfolder_rule_next_source (data->vr, source))) { + path = gtk_tree_path_new (); + gtk_tree_path_append_index (path, index); + + if (gtk_tree_selection_path_is_selected (selection, path)) { + gtk_tree_model_get_iter ( + GTK_TREE_MODEL (data->model), &iter, path); + + em_vfolder_rule_remove_source (data->vr, source); + gtk_list_store_remove (data->model, &iter); + gtk_tree_path_free (path); + + /* now select the next rule */ + n = gtk_tree_model_iter_n_children ( + GTK_TREE_MODEL (data->model), NULL); + index = index >= n ? n - 1 : index; + + if (index >= 0) { + path = gtk_tree_path_new (); + gtk_tree_path_append_index (path, index); + gtk_tree_model_get_iter ( + GTK_TREE_MODEL (data->model), + &iter, path); + gtk_tree_path_free (path); + + gtk_tree_selection_select_iter ( + selection, &iter); + gtk_tree_model_get ( + GTK_TREE_MODEL (data->model), &iter, + 0, &data->current, -1); + } else { + data->current = NULL; + } + + break; + } + + index++; + gtk_tree_path_free (path); + } + + set_sensitive (data); +} + +static GtkWidget * +get_widget (EFilterRule *fr, + ERuleContext *rc) +{ + EMVFolderRule *vr =(EMVFolderRule *) fr; + EMailSession *session; + GtkWidget *widget, *frame; + struct _source_data *data; + GtkRadioButton *rb; + const gchar *source; + GtkTreeIter iter; + GtkBuilder *builder; + GObject *object; + gint i; + + widget = E_FILTER_RULE_CLASS (em_vfolder_editor_rule_parent_class)-> + get_widget (fr, rc); + + data = g_malloc0 (sizeof (*data)); + data->rc = rc; + data->vr = vr; + + builder = gtk_builder_new (); + e_load_ui_builder_definition (builder, "mail-dialogs.ui"); + + frame = e_builder_get_widget(builder, "vfolder_source_frame"); + + g_object_set_data_full((GObject *)frame, "data", data, g_free); + + for (i = 0; i < BUTTON_LAST; i++) { + data->buttons[i] =(GtkButton *) + e_builder_get_widget (builder, edit_buttons[i].name); + g_signal_connect ( + data->buttons[i], "clicked", + edit_buttons[i].func, data); + } + + object = gtk_builder_get_object (builder, "source_list"); + data->list = GTK_TREE_VIEW (object); + object = gtk_builder_get_object (builder, "source_model"); + data->model = GTK_LIST_STORE (object); + + session = em_vfolder_editor_context_get_session (EM_VFOLDER_EDITOR_CONTEXT (rc)); + + source = NULL; + while ((source = em_vfolder_rule_next_source (vr, source))) { + gchar *markup; + + markup = e_mail_folder_uri_to_markup ( + CAMEL_SESSION (session), source, NULL); + + gtk_list_store_append (data->model, &iter); + gtk_list_store_set (data->model, &iter, 0, markup, 1, source, -1); + g_free (markup); + } + + g_signal_connect ( + data->list, "cursor-changed", + G_CALLBACK (select_source), data); + + rb = (GtkRadioButton *)e_builder_get_widget (builder, "local_rb"); + g_signal_connect ( + rb, "toggled", + G_CALLBACK (select_source_with_changed), data); + + rb = (GtkRadioButton *)e_builder_get_widget (builder, "remote_rb"); + g_signal_connect ( + rb, "toggled", + G_CALLBACK (select_source_with_changed), data); + + rb = (GtkRadioButton *)e_builder_get_widget (builder, "local_and_remote_rb"); + g_signal_connect ( + rb, "toggled", + G_CALLBACK (select_source_with_changed), data); + + rb = (GtkRadioButton *) e_builder_get_widget (builder, "specific_rb"); + g_signal_connect ( + rb, "toggled", + G_CALLBACK (select_source_with_changed), data); + + data->source_selector = (GtkWidget *) + e_builder_get_widget (builder, "source_selector"); + + rb = g_slist_nth_data (gtk_radio_button_get_group (rb), vr->with); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb), TRUE); + g_signal_emit_by_name (rb, "toggled"); + + set_sensitive (data); + + gtk_box_pack_start (GTK_BOX (widget), frame, TRUE, TRUE, 3); + + g_object_unref (builder); + + return widget; +} diff --git a/mail/em-vfolder-editor-rule.h b/mail/em-vfolder-editor-rule.h new file mode 100644 index 0000000000..39ad09797d --- /dev/null +++ b/mail/em-vfolder-editor-rule.h @@ -0,0 +1,81 @@ +/* + * 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 + * + * + * Authors: + * NotZed + * Jeffrey Stedfast + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef EM_VFOLDER_EDITOR_RULE_H +#define EM_VFOLDER_EDITOR_RULE_H + +#include +#include +#include + +/* Standard GObject macros */ +#define EM_TYPE_VFOLDER_EDITOR_RULE \ + (em_vfolder_editor_rule_get_type ()) +#define EM_VFOLDER_EDITOR_RULE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), EM_TYPE_VFOLDER_EDITOR_RULE, EMVFolderEditorRule)) +#define EM_VFOLDER_EDITOR_RULE_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), EM_TYPE_VFOLDER_EDITOR_RULE, EMVFolderEditorRuleClass)) +#define EM_IS_VFOLDER_EDITOR_RULE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), EM_TYPE_VFOLDER_EDITOR_RULE)) +#define EM_IS_VFOLDER_EDITOR_RULE_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), EM_TYPE_VFOLDER_EDITOR_RULE)) +#define EM_VFOLDER_EDITOR_RULE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), EM_TYPE_VFOLDER_EDITOR_RULE, EMVFolderEditorRuleClass)) + +G_BEGIN_DECLS + +/* perhaps should be bits? */ +enum _em_vfolder_editor_rule_with_t { + EM_VFOLDER_EDITOR_RULE_WITH_SPECIFIC, + EM_VFOLDER_EDITOR_RULE_WITH_LOCAL_REMOTE_ACTIVE, + EM_VFOLDER_EDITOR_RULE_WITH_REMOTE_ACTIVE, + EM_VFOLDER_EDITOR_RULE_WITH_LOCAL +}; + +typedef struct _EMVFolderEditorRule EMVFolderEditorRule; +typedef struct _EMVFolderEditorRuleClass EMVFolderEditorRuleClass; +typedef struct _EMVFolderEditorRulePrivate EMVFolderEditorRulePrivate; + +typedef enum _em_vfolder_editor_rule_with_t em_vfolder_editor_rule_with_t; + +struct _EMVFolderEditorRule { + EMVFolderRule rule; + EMVFolderEditorRulePrivate *priv; +}; + +struct _EMVFolderEditorRuleClass { + EMVFolderRuleClass parent_class; +}; + +GType em_vfolder_editor_rule_get_type (void); +EFilterRule * em_vfolder_editor_rule_new (EMailSession *session); +EMailSession * em_vfolder_editor_rule_get_session (EMVFolderEditorRule *rule); + +G_END_DECLS + +#endif /* EM_VFOLDER_EDITOR_RULE_H */ diff --git a/mail/em-vfolder-editor.c b/mail/em-vfolder-editor.c index ef3e0fb3ca..48f1395430 100644 --- a/mail/em-vfolder-editor.c +++ b/mail/em-vfolder-editor.c @@ -34,7 +34,7 @@ #include "e-util/e-util-private.h" #include "em-vfolder-editor.h" -#include "em-vfolder-rule.h" +#include "em-vfolder-editor-rule.h" G_DEFINE_TYPE ( EMVFolderEditor, @@ -44,16 +44,16 @@ G_DEFINE_TYPE ( static EFilterRule * vfolder_editor_create_rule (ERuleEditor *rule_editor) { - EMVFolderContext *context; + EMVFolderEditorContext *context; EMailSession *session; EFilterRule *rule; EFilterPart *part; - context = EM_VFOLDER_CONTEXT (rule_editor->context); - session = em_vfolder_context_get_session (context); + context = EM_VFOLDER_EDITOR_CONTEXT (rule_editor->context); + session = em_vfolder_editor_context_get_session (context); /* create a rule with 1 part in it */ - rule = em_vfolder_rule_new (session); + rule = em_vfolder_editor_rule_new (session); part = e_rule_context_next_part (rule_editor->context, NULL); e_filter_rule_add_part (rule, e_filter_part_clone (part)); diff --git a/mail/em-vfolder-editor.h b/mail/em-vfolder-editor.h index 2548582ad7..311a63777f 100644 --- a/mail/em-vfolder-editor.h +++ b/mail/em-vfolder-editor.h @@ -25,7 +25,7 @@ #define EM_VFOLDER_EDITOR_H #include "filter/e-rule-editor.h" -#include "em-vfolder-context.h" +#include "em-vfolder-editor-context.h" /* Standard GObject macros */ #define EM_TYPE_VFOLDER_EDITOR \ diff --git a/mail/em-vfolder-rule.c b/mail/em-vfolder-rule.c deleted file mode 100644 index adea1b92f0..0000000000 --- a/mail/em-vfolder-rule.c +++ /dev/null @@ -1,767 +0,0 @@ -/* - * 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 - * - * - * Authors: - * Not Zed - * Jeffrey Stedfast - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include - -#include - -#include -#include -#include - -#include - -#include "em-folder-selector.h" -#include "em-folder-tree.h" -#include "em-utils.h" -#include "em-vfolder-context.h" -#include "em-vfolder-rule.h" - -#define EM_VFOLDER_RULE_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), EM_TYPE_VFOLDER_RULE, EMVFolderRulePrivate)) - -#define EM_VFOLDER_RULE_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), EM_TYPE_VFOLDER_RULE, EMVFolderRulePrivate)) - -struct _EMVFolderRulePrivate { - EMailSession *session; -}; - -enum { - PROP_0, - PROP_SESSION -}; - -static gint validate (EFilterRule *, EAlert **alert); -static gint vfolder_eq (EFilterRule *fr, EFilterRule *cm); -static xmlNodePtr xml_encode (EFilterRule *); -static gint xml_decode (EFilterRule *, xmlNodePtr, ERuleContext *f); -static void rule_copy (EFilterRule *dest, EFilterRule *src); -static GtkWidget *get_widget (EFilterRule *fr, ERuleContext *f); - -/* DO NOT internationalise these strings */ -static const gchar *with_names[] = { - "specific", - "local_remote_active", - "remote_active", - "local" -}; - -G_DEFINE_TYPE ( - EMVFolderRule, - em_vfolder_rule, - E_TYPE_FILTER_RULE) - -static void -vfolder_rule_set_session (EMVFolderRule *rule, - EMailSession *session) -{ - if (session == NULL) { - EShell *shell; - EShellBackend *shell_backend; - EMailBackend *backend; - - shell = e_shell_get_default (); - shell_backend = e_shell_get_backend_by_name (shell, "mail"); - - backend = E_MAIL_BACKEND (shell_backend); - session = e_mail_backend_get_session (backend); - } - - g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_return_if_fail (rule->priv->session == NULL); - - rule->priv->session = g_object_ref (session); -} - -static void -vfolder_rule_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SESSION: - vfolder_rule_set_session ( - EM_VFOLDER_RULE (object), - g_value_get_object (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -vfolder_rule_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SESSION: - g_value_set_object ( - value, - em_vfolder_rule_get_session ( - EM_VFOLDER_RULE (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -vfolder_rule_dispose (GObject *object) -{ - EMVFolderRulePrivate *priv; - - priv = EM_VFOLDER_RULE_GET_PRIVATE (object); - - if (priv->session != NULL) { - g_object_unref (priv->session); - priv->session = NULL; - } - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (em_vfolder_rule_parent_class)->dispose (object); -} - -static void -vfolder_rule_finalize (GObject *object) -{ - EMVFolderRule *rule = EM_VFOLDER_RULE (object); - gchar *uri; - - while ((uri = g_queue_pop_head (&rule->sources)) != NULL) - g_free (uri); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (em_vfolder_rule_parent_class)->finalize (object); -} - -static void -em_vfolder_rule_class_init (EMVFolderRuleClass *class) -{ - GObjectClass *object_class; - EFilterRuleClass *filter_rule_class; - - g_type_class_add_private (class, sizeof (EMVFolderRulePrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->set_property = vfolder_rule_set_property; - object_class->get_property = vfolder_rule_get_property; - object_class->dispose = vfolder_rule_dispose; - object_class->finalize = vfolder_rule_finalize; - - filter_rule_class = E_FILTER_RULE_CLASS (class); - filter_rule_class->validate = validate; - filter_rule_class->eq = vfolder_eq; - filter_rule_class->xml_encode = xml_encode; - filter_rule_class->xml_decode = xml_decode; - filter_rule_class->copy = rule_copy; - filter_rule_class->get_widget = get_widget; - - g_object_class_install_property ( - object_class, - PROP_SESSION, - g_param_spec_object ( - "session", - NULL, - NULL, - E_TYPE_MAIL_SESSION, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); -} - -static void -em_vfolder_rule_init (EMVFolderRule *rule) -{ - rule->priv = EM_VFOLDER_RULE_GET_PRIVATE (rule); - rule->with = EM_VFOLDER_RULE_WITH_SPECIFIC; - rule->rule.source = g_strdup ("incoming"); -} - -EFilterRule * -em_vfolder_rule_new (EMailSession *session) -{ - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); - - return g_object_new ( - EM_TYPE_VFOLDER_RULE, "session", session, NULL); -} - -EMailSession * -em_vfolder_rule_get_session (EMVFolderRule *rule) -{ - g_return_val_if_fail (EM_IS_VFOLDER_RULE (rule), NULL); - - return rule->priv->session; -} - -void -em_vfolder_rule_add_source (EMVFolderRule *rule, - const gchar *uri) -{ - g_return_if_fail (EM_IS_VFOLDER_RULE (rule)); - g_return_if_fail (uri); - - g_queue_push_tail (&rule->sources, g_strdup (uri)); - - e_filter_rule_emit_changed (E_FILTER_RULE (rule)); -} - -const gchar * -em_vfolder_rule_find_source (EMVFolderRule *rule, - const gchar *uri) -{ - GList *link; - - g_return_val_if_fail (EM_IS_VFOLDER_RULE (rule), NULL); - - /* only does a simple string or address comparison, should - * probably do a decoded url comparison */ - link = g_queue_find_custom ( - &rule->sources, uri, (GCompareFunc) strcmp); - - return (link != NULL) ? link->data : NULL; -} - -void -em_vfolder_rule_remove_source (EMVFolderRule *rule, - const gchar *uri) -{ - gchar *found; - - g_return_if_fail (EM_IS_VFOLDER_RULE (rule)); - - found =(gchar *) em_vfolder_rule_find_source (rule, uri); - if (found != NULL) { - g_queue_remove (&rule->sources, found); - g_free (found); - e_filter_rule_emit_changed (E_FILTER_RULE (rule)); - } -} - -const gchar * -em_vfolder_rule_next_source (EMVFolderRule *rule, - const gchar *last) -{ - GList *link; - - if (last == NULL) { - link = g_queue_peek_head_link (&rule->sources); - } else { - link = g_queue_find (&rule->sources, last); - if (link == NULL) - link = g_queue_peek_head_link (&rule->sources); - else - link = g_list_next (link); - } - - return (link != NULL) ? link->data : NULL; -} - -static gint -validate (EFilterRule *fr, - EAlert **alert) -{ - g_return_val_if_fail (fr != NULL, 0); - g_warn_if_fail (alert == NULL || *alert == NULL); - - if (!fr->name || !*fr->name) { - if (alert) - *alert = e_alert_new ("mail:no-name-vfolder", NULL); - return 0; - } - - /* We have to have at least one source set in the "specific" case. - * Do not translate this string! */ - if (((EMVFolderRule *) fr)->with == EM_VFOLDER_RULE_WITH_SPECIFIC && - g_queue_is_empty (&((EMVFolderRule *) fr)->sources)) { - if (alert) - *alert = e_alert_new ("mail:vfolder-no-source", NULL); - return 0; - } - - return E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->validate (fr, alert); -} - -static gint -queue_eq (GQueue *queue_a, - GQueue *queue_b) -{ - GList *link_a; - GList *link_b; - gint truth = TRUE; - - link_a = g_queue_peek_head_link (queue_a); - link_b = g_queue_peek_head_link (queue_b); - - while (truth && link_a != NULL && link_b != NULL) { - gchar *uri_a = link_a->data; - gchar *uri_b = link_b->data; - - truth = (strcmp (uri_a, uri_b)== 0); - - link_a = g_list_next (link_a); - link_b = g_list_next (link_b); - } - - return truth && link_a == NULL && link_b == NULL; -} - -static gint -vfolder_eq (EFilterRule *fr, - EFilterRule *cm) -{ - return E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->eq (fr, cm) - && queue_eq ( - &((EMVFolderRule *) fr)->sources, - &((EMVFolderRule *) cm)->sources); -} - -static xmlNodePtr -xml_encode (EFilterRule *fr) -{ - EMVFolderRule *vr =(EMVFolderRule *) fr; - xmlNodePtr node, set, work; - GList *head, *link; - - node = E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->xml_encode (fr); - g_return_val_if_fail (node != NULL, NULL); - g_return_val_if_fail (vr->with < G_N_ELEMENTS (with_names), NULL); - - set = xmlNewNode(NULL, (const guchar *)"sources"); - xmlAddChild (node, set); - xmlSetProp(set, (const guchar *)"with", (guchar *)with_names[vr->with]); - - head = g_queue_peek_head_link (&vr->sources); - for (link = head; link != NULL; link = g_list_next (link)) { - const gchar *uri = link->data; - - work = xmlNewNode (NULL, (const guchar *) "folder"); - xmlSetProp (work, (const guchar *) "uri", (guchar *) uri); - xmlAddChild (set, work); - } - - return node; -} - -static void -set_with (EMVFolderRule *vr, - const gchar *name) -{ - gint i; - - for (i = 0; i < G_N_ELEMENTS (with_names); i++) { - if (!strcmp (name, with_names[i])) { - vr->with = i; - return; - } - } - - vr->with = 0; -} - -static gint -xml_decode (EFilterRule *fr, - xmlNodePtr node, - ERuleContext *f) -{ - xmlNodePtr set, work; - gint result; - EMVFolderRule *vr =(EMVFolderRule *) fr; - gchar *tmp; - - result = E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)-> - xml_decode (fr, node, f); - if (result != 0) - return result; - - /* handle old format file, vfolder source is in filterrule */ - if (strcmp(fr->source, "incoming")!= 0) { - set_with (vr, fr->source); - g_free (fr->source); - fr->source = g_strdup("incoming"); - } - - set = node->children; - while (set) { - if (!strcmp((gchar *)set->name, "sources")) { - tmp = (gchar *)xmlGetProp(set, (const guchar *)"with"); - if (tmp) { - set_with (vr, tmp); - xmlFree (tmp); - } - work = set->children; - while (work) { - if (!strcmp((gchar *)work->name, "folder")) { - tmp = (gchar *)xmlGetProp(work, (const guchar *)"uri"); - if (tmp) { - g_queue_push_tail (&vr->sources, g_strdup (tmp)); - xmlFree (tmp); - } - } - work = work->next; - } - } - set = set->next; - } - return 0; -} - -static void -rule_copy (EFilterRule *dest, - EFilterRule *src) -{ - EMVFolderRule *vdest, *vsrc; - GList *head, *link; - gchar *uri; - - vdest =(EMVFolderRule *) dest; - vsrc =(EMVFolderRule *) src; - - while ((uri = g_queue_pop_head (&vdest->sources)) != NULL) - g_free (uri); - - head = g_queue_peek_head_link (&vsrc->sources); - for (link = head; link != NULL; link = g_list_next (link)) { - const gchar *uri = link->data; - g_queue_push_tail (&vdest->sources, g_strdup (uri)); - } - - vdest->with = vsrc->with; - - E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->copy (dest, src); -} - -enum { - BUTTON_ADD, - BUTTON_REMOVE, - BUTTON_LAST -}; - -struct _source_data { - ERuleContext *rc; - EMVFolderRule *vr; - const gchar *current; - GtkListStore *model; - GtkTreeView *list; - GtkWidget *source_selector; - GtkButton *buttons[BUTTON_LAST]; -}; - -static void source_add (GtkWidget *widget, struct _source_data *data); -static void source_remove (GtkWidget *widget, struct _source_data *data); - -static struct { - const gchar *name; - GCallback func; -} edit_buttons[] = { - { "source_add", G_CALLBACK(source_add) }, - { "source_remove", G_CALLBACK(source_remove)}, -}; - -static void -set_sensitive (struct _source_data *data) -{ - gtk_widget_set_sensitive ( - GTK_WIDGET (data->buttons[BUTTON_ADD]), TRUE); - gtk_widget_set_sensitive ( - GTK_WIDGET (data->buttons[BUTTON_REMOVE]), - data->current != NULL); -} - -static void -select_source (GtkWidget *list, - struct _source_data *data) -{ - GtkTreeViewColumn *column; - GtkTreePath *path; - GtkTreeIter iter; - - gtk_tree_view_get_cursor (data->list, &path, &column); - gtk_tree_model_get_iter (GTK_TREE_MODEL (data->model), &iter, path); - gtk_tree_path_free (path); - - gtk_tree_model_get (GTK_TREE_MODEL (data->model), &iter, 0, &data->current, -1); - - set_sensitive (data); -} - -static void -select_source_with_changed (GtkWidget *widget, - struct _source_data *data) -{ - em_vfolder_rule_with_t with = 0; - GSList *group = NULL; - gint i = 0; - - if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) - return; - - group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget)); - - for (i = 0; i< g_slist_length (group); i++) { - if (g_slist_nth_data (group, with = i) == widget) - break; - } - - if (with > EM_VFOLDER_RULE_WITH_LOCAL ) - with = 0; - - gtk_widget_set_sensitive (data->source_selector, !with ); - - data->vr->with = with; -} - -static void -vfr_folder_response (EMFolderSelector *selector, - gint button, - struct _source_data *data) -{ - EMFolderTreeModel *model; - EMailSession *session; - const gchar *uri; - - model = em_folder_selector_get_model (selector); - session = em_folder_tree_model_get_session (model); - - uri = em_folder_selector_get_selected_uri (selector); - - if (button == GTK_RESPONSE_OK && uri != NULL) { - GtkTreeSelection *selection; - GtkTreeIter iter; - gchar *markup; - - g_queue_push_tail (&data->vr->sources, g_strdup (uri)); - - markup = e_mail_folder_uri_to_markup ( - CAMEL_SESSION (session), uri, NULL); - - gtk_list_store_append (data->model, &iter); - gtk_list_store_set (data->model, &iter, 0, markup, 1, uri, -1); - selection = gtk_tree_view_get_selection (data->list); - gtk_tree_selection_select_iter (selection, &iter); - data->current = uri; - - g_free (markup); - - set_sensitive (data); - } - - gtk_widget_destroy (GTK_WIDGET (selector)); -} - -static void -source_add (GtkWidget *widget, - struct _source_data *data) -{ - EMFolderTree *folder_tree; - EMFolderTreeModel *model; - GtkWidget *dialog; - gpointer parent; - - parent = gtk_widget_get_toplevel (widget); - parent = gtk_widget_is_toplevel (parent) ? parent : NULL; - - model = em_folder_tree_model_get_default (); - - dialog = em_folder_selector_new ( - parent, model, - EM_FOLDER_SELECTOR_CAN_CREATE, - _("Add Folder"), NULL, _("_Add")); - - folder_tree = em_folder_selector_get_folder_tree ( - EM_FOLDER_SELECTOR (dialog)); - - em_folder_tree_set_excluded (folder_tree, EMFT_EXCLUDE_NOSELECT); - - g_signal_connect ( - dialog, "response", - G_CALLBACK (vfr_folder_response), data); - - gtk_widget_show (dialog); -} - -static void -source_remove (GtkWidget *widget, - struct _source_data *data) -{ - GtkTreeSelection *selection; - const gchar *source; - GtkTreePath *path; - GtkTreeIter iter; - gint index = 0; - gint n; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->list)); - - source = NULL; - while ((source = em_vfolder_rule_next_source (data->vr, source))) { - path = gtk_tree_path_new (); - gtk_tree_path_append_index (path, index); - - if (gtk_tree_selection_path_is_selected (selection, path)) { - gtk_tree_model_get_iter ( - GTK_TREE_MODEL (data->model), &iter, path); - - em_vfolder_rule_remove_source (data->vr, source); - gtk_list_store_remove (data->model, &iter); - gtk_tree_path_free (path); - - /* now select the next rule */ - n = gtk_tree_model_iter_n_children ( - GTK_TREE_MODEL (data->model), NULL); - index = index >= n ? n - 1 : index; - - if (index >= 0) { - path = gtk_tree_path_new (); - gtk_tree_path_append_index (path, index); - gtk_tree_model_get_iter ( - GTK_TREE_MODEL (data->model), - &iter, path); - gtk_tree_path_free (path); - - gtk_tree_selection_select_iter ( - selection, &iter); - gtk_tree_model_get ( - GTK_TREE_MODEL (data->model), &iter, - 0, &data->current, -1); - } else { - data->current = NULL; - } - - break; - } - - index++; - gtk_tree_path_free (path); - } - - set_sensitive (data); -} - -static GtkWidget * -get_widget (EFilterRule *fr, - ERuleContext *rc) -{ - EMVFolderRule *vr =(EMVFolderRule *) fr; - EMailSession *session; - GtkWidget *widget, *frame; - struct _source_data *data; - GtkRadioButton *rb; - const gchar *source; - GtkTreeIter iter; - GtkBuilder *builder; - GObject *object; - gint i; - - widget = E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)-> - get_widget (fr, rc); - - data = g_malloc0 (sizeof (*data)); - data->rc = rc; - data->vr = vr; - - builder = gtk_builder_new (); - e_load_ui_builder_definition (builder, "mail-dialogs.ui"); - - frame = e_builder_get_widget(builder, "vfolder_source_frame"); - - g_object_set_data_full((GObject *)frame, "data", data, g_free); - - for (i = 0; i < BUTTON_LAST; i++) { - data->buttons[i] =(GtkButton *) - e_builder_get_widget (builder, edit_buttons[i].name); - g_signal_connect ( - data->buttons[i], "clicked", - edit_buttons[i].func, data); - } - - object = gtk_builder_get_object (builder, "source_list"); - data->list = GTK_TREE_VIEW (object); - object = gtk_builder_get_object (builder, "source_model"); - data->model = GTK_LIST_STORE (object); - - session = em_vfolder_context_get_session (EM_VFOLDER_CONTEXT (rc)); - - source = NULL; - while ((source = em_vfolder_rule_next_source (vr, source))) { - gchar *markup; - - markup = e_mail_folder_uri_to_markup ( - CAMEL_SESSION (session), source, NULL); - - gtk_list_store_append (data->model, &iter); - gtk_list_store_set (data->model, &iter, 0, markup, 1, source, -1); - g_free (markup); - } - - g_signal_connect ( - data->list, "cursor-changed", - G_CALLBACK (select_source), data); - - rb = (GtkRadioButton *)e_builder_get_widget (builder, "local_rb"); - g_signal_connect ( - rb, "toggled", - G_CALLBACK (select_source_with_changed), data); - - rb = (GtkRadioButton *)e_builder_get_widget (builder, "remote_rb"); - g_signal_connect ( - rb, "toggled", - G_CALLBACK (select_source_with_changed), data); - - rb = (GtkRadioButton *)e_builder_get_widget (builder, "local_and_remote_rb"); - g_signal_connect ( - rb, "toggled", - G_CALLBACK (select_source_with_changed), data); - - rb = (GtkRadioButton *) e_builder_get_widget (builder, "specific_rb"); - g_signal_connect ( - rb, "toggled", - G_CALLBACK (select_source_with_changed), data); - - data->source_selector = (GtkWidget *) - e_builder_get_widget (builder, "source_selector"); - - rb = g_slist_nth_data (gtk_radio_button_get_group (rb), vr->with); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb), TRUE); - g_signal_emit_by_name (rb, "toggled"); - - set_sensitive (data); - - gtk_box_pack_start (GTK_BOX (widget), frame, TRUE, TRUE, 3); - - g_object_unref (builder); - - return widget; -} diff --git a/mail/em-vfolder-rule.h b/mail/em-vfolder-rule.h deleted file mode 100644 index 1b3a4432ca..0000000000 --- a/mail/em-vfolder-rule.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 - * - * - * Authors: - * NotZed - * Jeffrey Stedfast - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef EM_VFOLDER_RULE_H -#define EM_VFOLDER_RULE_H - -#include -#include - -/* Standard GObject macros */ -#define EM_TYPE_VFOLDER_RULE \ - (em_vfolder_rule_get_type ()) -#define EM_VFOLDER_RULE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), EM_TYPE_VFOLDER_RULE, EMVFolderRule)) -#define EM_VFOLDER_RULE_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), EM_TYPE_VFOLDER_RULE, EMVFolderRuleClass)) -#define EM_IS_VFOLDER_RULE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), EM_TYPE_VFOLDER_RULE)) -#define EM_IS_VFOLDER_RULE_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), EM_TYPE_VFOLDER_RULE)) -#define EM_VFOLDER_RULE_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), EM_TYPE_VFOLDER_RULE, EMVFolderRuleClass)) - -G_BEGIN_DECLS - -/* perhaps should be bits? */ -enum _em_vfolder_rule_with_t { - EM_VFOLDER_RULE_WITH_SPECIFIC, - EM_VFOLDER_RULE_WITH_LOCAL_REMOTE_ACTIVE, - EM_VFOLDER_RULE_WITH_REMOTE_ACTIVE, - EM_VFOLDER_RULE_WITH_LOCAL -}; - -typedef struct _EMVFolderRule EMVFolderRule; -typedef struct _EMVFolderRuleClass EMVFolderRuleClass; -typedef struct _EMVFolderRulePrivate EMVFolderRulePrivate; - -typedef enum _em_vfolder_rule_with_t em_vfolder_rule_with_t; - -struct _EMVFolderRule { - EFilterRule rule; - EMVFolderRulePrivate *priv; - - em_vfolder_rule_with_t with; - GQueue sources; /* uri's of the source folders */ -}; - -struct _EMVFolderRuleClass { - EFilterRuleClass parent_class; -}; - -GType em_vfolder_rule_get_type (void); -EFilterRule * em_vfolder_rule_new (EMailSession *session); -EMailSession * em_vfolder_rule_get_session (EMVFolderRule *rule); -void em_vfolder_rule_add_source (EMVFolderRule *rule, - const gchar *uri); -void em_vfolder_rule_remove_source (EMVFolderRule *rule, - const gchar *uri); -const gchar * em_vfolder_rule_find_source (EMVFolderRule *rule, - const gchar *uri); -const gchar * em_vfolder_rule_next_source (EMVFolderRule *rule, - const gchar *last); - -G_END_DECLS - -#endif /* EM_VFOLDER_RULE_H */ diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c index 597c87d9d3..4db48df056 100644 --- a/mail/mail-autofilter.c +++ b/mail/mail-autofilter.c @@ -38,8 +38,8 @@ #include "libevolution-utils/e-alert-dialog.h" #include "e-util/e-util-private.h" -#include "em-vfolder-context.h" -#include "em-vfolder-rule.h" +#include "em-vfolder-editor-context.h" +#include "em-vfolder-editor-rule.h" #include "em-vfolder-editor.h" #include "em-filter-context.h" @@ -317,9 +317,9 @@ em_vfolder_rule_from_message (EMVFolderContext *context, uri = e_mail_folder_uri_from_folder (folder); - session = em_vfolder_context_get_session (context); + session = em_vfolder_editor_context_get_session ((EMVFolderEditorContext *) context); - rule = em_vfolder_rule_new (session); + rule = em_vfolder_editor_rule_new (session); em_vfolder_rule_add_source (EM_VFOLDER_RULE (rule), uri); rule_from_message (rule, E_RULE_CONTEXT (context), msg, flags); @@ -344,9 +344,9 @@ em_vfolder_rule_from_address (EMVFolderContext *context, uri = e_mail_folder_uri_from_folder (folder); - session = em_vfolder_context_get_session (context); + session = em_vfolder_editor_context_get_session ((EMVFolderEditorContext *) context); - rule = em_vfolder_rule_new (session); + rule = em_vfolder_editor_rule_new (session); em_vfolder_rule_add_source (EM_VFOLDER_RULE (rule), uri); rule_from_address (rule, E_RULE_CONTEXT (context), addr, flags); diff --git a/mail/mail-autofilter.h b/mail/mail-autofilter.h index 34593b0f95..a9e4254f9b 100644 --- a/mail/mail-autofilter.h +++ b/mail/mail-autofilter.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include enum { diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index a9fd42e5db..1435c39ae5 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -42,9 +42,9 @@ #include "e-mail-backend.h" #include "em-folder-tree-model.h" #include "em-utils.h" -#include "em-vfolder-context.h" +#include "em-vfolder-editor-context.h" #include "em-vfolder-editor.h" -#include "em-vfolder-rule.h" +#include "em-vfolder-editor-rule.h" #include "mail-autofilter.h" #include "mail-vfolder.h" #include "e-mail-ui-session.h" @@ -713,7 +713,7 @@ rule_changed (EFilterRule *rule, const gchar *full_name; full_name = camel_folder_get_full_name (folder); - session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule)); + session = em_vfolder_editor_rule_get_session (EM_VFOLDER_EDITOR_RULE (rule)); service = camel_session_get_service ( CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID); @@ -815,7 +815,7 @@ context_rule_added (ERuleContext *ctx, d(printf("rule added: %s\n", rule->name)); - session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule)); + session = em_vfolder_editor_rule_get_session (EM_VFOLDER_EDITOR_RULE (rule)); service = camel_session_get_service ( CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID); @@ -848,7 +848,7 @@ context_rule_removed (ERuleContext *ctx, d(printf("rule removed; %s\n", rule->name)); - session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule)); + session = em_vfolder_editor_rule_get_session (EM_VFOLDER_EDITOR_RULE (rule)); service = camel_session_get_service ( CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID); @@ -1043,7 +1043,7 @@ vfolder_load_storage (EMailBackend *backend) /* load our rules */ user = g_build_filename (config_dir, "vfolders.xml", NULL); - context = em_vfolder_context_new (session); + context = (EMVFolderContext *) em_vfolder_editor_context_new (session); xmlfile = g_build_filename (EVOLUTION_PRIVDATADIR, "vfoldertypes.xml", NULL); if (e_rule_context_load ((ERuleContext *) context, @@ -1283,7 +1283,7 @@ vfolder_clone_rule (EMailSession *session, g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); - rule = em_vfolder_rule_new (session); + rule = em_vfolder_editor_rule_new (session); xml = e_filter_rule_xml_encode (in); e_filter_rule_xml_decode (rule, xml, (ERuleContext *) context); diff --git a/mail/mail-vfolder.h b/mail/mail-vfolder.h index efebc17762..fc03e881d9 100644 --- a/mail/mail-vfolder.h +++ b/mail/mail-vfolder.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include void vfolder_load_storage (EMailBackend *backend); -- cgit