From 45d475c31b2dbda8033021984ba9a429b9eddf51 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 9 Aug 2009 20:03:24 -0400 Subject: Kill EMMenu and EMPopup. Also finish adapting Templates plugin to EPluginUI. It was still leaning pretty hard on EMPopup. --- mail/Makefile.am | 4 - mail/em-folder-tree.c | 5 +- mail/em-folder-utils.c | 1 - mail/em-format-html-display.c | 15 +- mail/em-menu.c | 354 ---------------- mail/em-menu.h | 121 ------ mail/em-popup.c | 472 ---------------------- mail/em-popup.h | 261 ------------ mail/message-list.c | 5 +- plugins/email-custom-header/email-custom-header.c | 1 - plugins/external-editor/external-editor.c | 1 - plugins/face/face.c | 1 - plugins/mail-to-task/mail-to-task.c | 2 - plugins/templates/org-gnome-templates.eplug.xml | 36 +- plugins/templates/templates.c | 387 +++++++++++------- shell/e-shell-window-private.c | 11 +- shell/e-shell-window.c | 11 - ui/Makefile.am | 10 +- ui/evolution-mail-global.xml | 149 ------- ui/evolution-mail-list.xml | 154 ------- ui/evolution-mail-message.xml | 426 ------------------- ui/evolution-mail-messagedisplay.xml | 74 ---- ui/evolution-mail.ui | 2 + ui/evolution.xml | 199 --------- 24 files changed, 283 insertions(+), 2419 deletions(-) delete mode 100644 mail/em-menu.c delete mode 100644 mail/em-menu.h delete mode 100644 mail/em-popup.c delete mode 100644 mail/em-popup.h delete mode 100644 ui/evolution-mail-global.xml delete mode 100644 ui/evolution-mail-list.xml delete mode 100644 ui/evolution-mail-message.xml delete mode 100644 ui/evolution-mail-messagedisplay.xml delete mode 100644 ui/evolution.xml diff --git a/mail/Makefile.am b/mail/Makefile.am index 5f8372f691..53b5bca508 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -71,8 +71,6 @@ mailinclude_HEADERS = \ em-icon-stream.h \ em-inline-filter.h \ em-junk-hook.h \ - em-menu.h \ - em-popup.h \ em-search-context.h \ em-subscribe-editor.h \ em-sync-stream.h \ @@ -131,8 +129,6 @@ libevolution_mail_la_SOURCES = \ em-icon-stream.c \ em-inline-filter.c \ em-junk-hook.c \ - em-menu.c \ - em-popup.c \ em-search-context.c \ em-subscribe-editor.c \ em-sync-stream.c \ diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index cadb8fee65..a3813ca69d 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -65,7 +65,6 @@ #include "mail-vfolder.h" #include "em-utils.h" -#include "em-popup.h" #include "em-folder-tree.h" #include "em-folder-utils.h" #include "em-folder-selector.h" @@ -1384,6 +1383,7 @@ tree_drag_data_action(struct _DragDataReceivedAsync *m) mail_msg_unordered_push (m); } +#if 0 /* KILL-BONOBO */ static void emft_drop_popup_copy(EPopup *ep, EPopupItem *item, gpointer data) { @@ -1509,6 +1509,7 @@ tree_drag_data_received(GtkWidget *widget, GdkDragContext *context, gint x, gint tree_drag_data_action(m); } } +#endif static gboolean is_special_local_folder (const gchar *name) @@ -1952,7 +1953,9 @@ em_folder_tree_enable_drag_and_drop (EMFolderTree *emft) g_signal_connect (tree_view, "drag-begin", G_CALLBACK (tree_drag_begin), emft); g_signal_connect (tree_view, "drag-data-delete", G_CALLBACK (tree_drag_data_delete), emft); g_signal_connect (tree_view, "drag-data-get", G_CALLBACK (tree_drag_data_get), emft); +#if 0 /* KILL-BONOBO */ g_signal_connect (tree_view, "drag-data-received", G_CALLBACK (tree_drag_data_received), emft); +#endif g_signal_connect (tree_view, "drag-drop", G_CALLBACK (tree_drag_drop), emft); g_signal_connect (tree_view, "drag-end", G_CALLBACK (tree_drag_end), emft); g_signal_connect (tree_view, "drag-leave", G_CALLBACK (tree_drag_leave), emft); diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index e483942885..700e445beb 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -61,7 +61,6 @@ #include "mail-folder-cache.h" #include "em-utils.h" -#include "em-popup.h" #include "em-folder-tree.h" #include "em-folder-tree-model.h" #include "em-folder-utils.h" diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 270db0e698..a15b0d671f 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -78,7 +78,6 @@ #include "em-format-html-display.h" #include "em-icon-stream.h" #include "em-utils.h" -#include "em-popup.h" #include "widgets/misc/e-attachment-button.h" #include "widgets/misc/e-attachment-view.h" @@ -841,6 +840,7 @@ efhd_can_process_attachment (GtkWidget *button) return efh && efh->state != EM_FORMAT_HTML_STATE_RENDERING; } +#if 0 /* KILL-BONOBO */ /* if it hasn't been processed yet, format the attachment */ static void efhd_attachment_show(EPopup *ep, EPopupItem *item, gpointer data) @@ -975,6 +975,7 @@ efhd_attachment_popup_menu(GtkWidget *w, struct _attach_puri *info) { return efhd_attachment_popup(w, NULL, info); } +#endif /* ********************************************************************** */ @@ -1132,9 +1133,13 @@ efhd_image_unallocate (struct _EMFormatPURI * puri) struct _attach_puri *info = (struct _attach_puri *) puri; g_signal_handlers_disconnect_by_func(info->html, efhd_image_resized, info); +#if 0 /* KILL-BONOBO */ g_signal_handlers_disconnect_by_func(info->event_box, efhd_image_popup, info); +#endif g_signal_handlers_disconnect_by_func(info->event_box, efhd_change_cursor, info); +#if 0 /* KILL-BONOBO */ g_signal_handlers_disconnect_by_func(info->event_box, efhd_attachment_popup_menu, info); +#endif g_signal_handlers_disconnect_by_func(info->event_box, efhd_image_fit_width, info); } @@ -1185,9 +1190,13 @@ efhd_attachment_image(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObjec g_signal_connect(box, "drag-data-get", G_CALLBACK(efhd_drag_data_get), pobject); g_signal_connect (box, "drag-data-delete", G_CALLBACK(efhd_drag_data_delete), pobject); +#if 0 /* KILL-BONOBO */ g_signal_connect(box, "button_press_event", G_CALLBACK(efhd_image_popup), info); +#endif g_signal_connect(box, "enter-notify-event", G_CALLBACK(efhd_change_cursor), info); +#if 0 /* KILL-BONOBO */ g_signal_connect(box, "popup_menu", G_CALLBACK(efhd_attachment_popup_menu), info); +#endif g_signal_connect(box, "button-press-event", G_CALLBACK(efhd_image_fit_width), info); g_object_set_data (G_OBJECT (box), "efh", efh); @@ -1244,9 +1253,11 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje g_object_set_data (G_OBJECT (widget), "efh", efh); +#if 0 /* KILL-BONOBO */ g_signal_connect ( widget, "notify::expanded", G_CALLBACK (efhd_attachment_button_expanded), info); +#endif return TRUE; } @@ -1407,9 +1418,11 @@ efhd_attachment_optional(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPOb a11y = gtk_widget_get_accessible (button); atk_object_set_name (a11y, _("Attachment")); +#if 0 /* KILL-BONOBO */ g_signal_connect(button, "button_press_event", G_CALLBACK(efhd_attachment_popup), info); g_signal_connect(button, "popup_menu", G_CALLBACK(efhd_attachment_popup_menu), info); g_signal_connect(button, "clicked", G_CALLBACK(efhd_attachment_popup_menu), info); +#endif gtk_box_pack_start(GTK_BOX (mainbox), button, FALSE, FALSE, 6); gtk_widget_show_all(mainbox); diff --git a/mail/em-menu.c b/mail/em-menu.c deleted file mode 100644 index bb8063e7dc..0000000000 --- a/mail/em-menu.c +++ /dev/null @@ -1,354 +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: - * Michael Zucchi - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include - -#include "em-menu.h" -#include "libedataserver/e-msgport.h" -#include "em-utils.h" -#include "em-composer-utils.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -static void emp_standard_menu_factory(EMenu *emp, gpointer data); - -static GObjectClass *emp_parent; - -static void -emp_init(GObject *o) -{ - /*EMMenu *emp = (EMMenu *)o; */ -} - -static void -emp_finalise(GObject *o) -{ - ((GObjectClass *)emp_parent)->finalize(o); -} - -static void -emp_target_free(EMenu *ep, EMenuTarget *t) -{ - switch (t->type) { - case EM_MENU_TARGET_SELECT: { - EMMenuTargetSelect *s = (EMMenuTargetSelect *)t; - - if (s->folder) - camel_object_unref(s->folder); - g_free(s->uri); - if (s->uids) - em_utils_uids_free(s->uids); - break; } - } - - ((EMenuClass *)emp_parent)->target_free(ep, t); -} - -static void -emp_class_init(GObjectClass *klass) -{ - klass->finalize = emp_finalise; - ((EMenuClass *)klass)->target_free = emp_target_free; - - e_menu_class_add_factory((EMenuClass *)klass, NULL, (EMenuFactoryFunc)emp_standard_menu_factory, NULL); -} - -GType -em_menu_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof(EMMenuClass), - NULL, NULL, - (GClassInitFunc)emp_class_init, - NULL, NULL, - sizeof(EMMenu), 0, - (GInstanceInitFunc)emp_init - }; - emp_parent = g_type_class_ref(e_menu_get_type()); - type = g_type_register_static(e_menu_get_type(), "EMMenu", &info, 0); - } - - return type; -} - -EMMenu *em_menu_new(const gchar *menuid) -{ - EMMenu *emp = g_object_new(em_menu_get_type(), NULL); - - e_menu_construct(&emp->popup, menuid); - - return emp; -} - -/** - * em_menu_target_new_select: - * @folder: The selection will ref this for the life of it. - * @folder_uri: - * @uids: The selection will free this when done with it. - * - * Create a new selection popup target. - * - * Return value: - **/ -EMMenuTargetSelect * -em_menu_target_new_select(EMMenu *emp, CamelFolder *folder, const gchar *folder_uri, GPtrArray *uids) -{ - EMMenuTargetSelect *t = e_menu_target_new(&emp->popup, EM_MENU_TARGET_SELECT, sizeof(*t)); - guint32 mask = ~0; - gint i; - const gchar *tmp; - - /* NB: This is identical to em-popup-target-new-select function */ - - t->uids = uids; - t->folder = folder; - t->uri = g_strdup(folder_uri); - - if (folder == NULL) { - t->target.mask = mask; - - return t; - } - - camel_object_ref(folder); - mask &= ~EM_MENU_SELECT_FOLDER; - - if (em_utils_folder_is_sent(folder, folder_uri)) - mask &= ~EM_MENU_SELECT_EDIT; - - if (!(em_utils_folder_is_drafts(folder, folder_uri) - || em_utils_folder_is_outbox(folder, folder_uri)) - && uids->len == 1) - mask &= ~EM_MENU_SELECT_ADD_SENDER; - - if (uids->len == 1) - mask &= ~EM_MENU_SELECT_ONE; - - if (uids->len >= 1) - mask &= ~EM_MENU_SELECT_MANY; - - for (i = 0; i < uids->len; i++) { - CamelMessageInfo *info = camel_folder_get_message_info(folder, uids->pdata[i]); - guint32 flags; - - if (info == NULL) - continue; - - flags = camel_message_info_flags(info); - - if (flags & CAMEL_MESSAGE_SEEN) - mask &= ~EM_MENU_SELECT_MARK_UNREAD; - else - mask &= ~EM_MENU_SELECT_MARK_READ; - - if (flags & CAMEL_MESSAGE_DELETED) - mask &= ~EM_MENU_SELECT_UNDELETE; - else - mask &= ~EM_MENU_SELECT_DELETE; - - if (flags & CAMEL_MESSAGE_FLAGGED) - mask &= ~EM_MENU_SELECT_MARK_UNIMPORTANT; - else - mask &= ~EM_MENU_SELECT_MARK_IMPORTANT; - - if (flags & CAMEL_MESSAGE_JUNK) - mask &= ~EM_MENU_SELECT_MARK_NOJUNK; - else - mask &= ~EM_MENU_SELECT_MARK_JUNK; - - tmp = camel_message_info_user_tag(info, "follow-up"); - if (tmp && *tmp) { - mask &= ~EM_MENU_SELECT_FLAG_CLEAR; - tmp = camel_message_info_user_tag(info, "completed-on"); - if (tmp == NULL || *tmp == 0) - mask &= ~EM_MENU_SELECT_FLAG_COMPLETED; - } else - mask &= ~EM_MENU_SELECT_FLAG_FOLLOWUP; - - if (i == 0 && uids->len == 1 - && (tmp = camel_message_info_mlist(info)) - && tmp[0] != 0) - mask &= ~EM_MENU_SELECT_MAILING_LIST; - - camel_folder_free_message_info(folder, info); - } - - t->target.mask = mask; - - return t; -} - -/** - * em_menu_target_new_window: - * @emp: - * @window: - * - * create a dummy target which references some sort of widget. - * - * Return value: - **/ -EMMenuTargetWidget * -em_menu_target_new_widget(EMMenu *emp, GtkWidget *w) -{ - EMMenuTargetWidget *t = e_menu_target_new(&emp->popup, EM_MENU_TARGET_WIDGET, sizeof(*t)); - guint32 mask = ~0; - - t->target.mask = mask; - t->target.widget = w; - - return t; -} - -static void -emp_standard_menu_factory(EMenu *emp, gpointer data) -{ - /* noop */ -} - -/* ********************************************************************** */ - -/* menu plugin handler */ - -/* - - - - - - - -*/ - -static gpointer emph_parent_class; -#define emph ((EMMenuHook *)eph) - -static const EMenuHookTargetMask emph_select_masks[] = { - { "one", EM_MENU_SELECT_ONE }, - { "many", EM_MENU_SELECT_MANY }, - { "mark_read", EM_MENU_SELECT_MARK_READ }, - { "mark_unread", EM_MENU_SELECT_MARK_UNREAD }, - { "delete", EM_MENU_SELECT_DELETE }, - { "undelete", EM_MENU_SELECT_UNDELETE }, - { "mailing_list", EM_MENU_SELECT_MAILING_LIST }, - { "resend", EM_MENU_SELECT_EDIT }, - { "mark_important", EM_MENU_SELECT_MARK_IMPORTANT }, - { "mark_unimportant", EM_MENU_SELECT_MARK_UNIMPORTANT }, - { "flag_followup", EM_MENU_SELECT_FLAG_FOLLOWUP }, - { "flag_completed", EM_MENU_SELECT_FLAG_COMPLETED }, - { "flag_clear", EM_MENU_SELECT_FLAG_CLEAR }, - { "add_sender", EM_MENU_SELECT_ADD_SENDER }, - { "mark_junk", EM_MENU_SELECT_MARK_JUNK }, - { "mark_nojunk", EM_MENU_SELECT_MARK_NOJUNK }, - { "folder", EM_MENU_SELECT_FOLDER }, - { NULL } -}; - -/* dummy widget target, probably wont have any useful masks. - this should probably be a more specific target type */ -static const EMenuHookTargetMask emph_widget_masks[] = { - { NULL } -}; - -static const EMenuHookTargetMap emph_targets[] = { - { "select", EM_MENU_TARGET_SELECT, emph_select_masks }, - { "widget", EM_MENU_TARGET_WIDGET, emph_widget_masks }, - { NULL } -}; - -static void -emph_finalise(GObject *o) -{ - /*EPluginHook *eph = (EPluginHook *)o;*/ - - ((GObjectClass *)emph_parent_class)->finalize(o); -} - -static void -emph_class_init(EPluginHookClass *klass) -{ - gint i; - - ((GObjectClass *)klass)->finalize = emph_finalise; - ((EPluginHookClass *)klass)->id = "org.gnome.evolution.mail.bonobomenu:1.0"; - - for (i=0;emph_targets[i].type;i++) - e_menu_hook_class_add_target_map((EMenuHookClass *)klass, &emph_targets[i]); - - /* FIXME: leaks parent set class? */ - ((EMenuHookClass *)klass)->menu_class = g_type_class_ref(em_menu_get_type()); -} - -GType -em_menu_hook_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EMMenuHookClass), NULL, NULL, (GClassInitFunc) emph_class_init, NULL, NULL, - sizeof(EMMenuHook), 0, (GInstanceInitFunc) NULL, - }; - - emph_parent_class = g_type_class_ref(e_menu_hook_get_type()); - type = g_type_register_static(e_menu_hook_get_type(), "EMMenuHook", &info, 0); - } - - return type; -} diff --git a/mail/em-menu.h b/mail/em-menu.h deleted file mode 100644 index b2e66916e3..0000000000 --- a/mail/em-menu.h +++ /dev/null @@ -1,121 +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: - * Michel Zucchi - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EM_MENU_H__ -#define __EM_MENU_H__ - -#include -#include - -#include "e-util/e-menu.h" - -G_BEGIN_DECLS - -typedef struct _EMMenu EMMenu; -typedef struct _EMMenuClass EMMenuClass; - -/* Current target description */ -/* Types of popup tagets */ -enum _em_menu_target_t { - EM_MENU_TARGET_SELECT, - EM_MENU_TARGET_WIDGET -}; - -/* Flags that describe a TARGET_SELECT */ -enum { - EM_MENU_SELECT_ONE = 1<<1, - EM_MENU_SELECT_MANY = 1<<2, - EM_MENU_SELECT_MARK_READ = 1<<3, - EM_MENU_SELECT_MARK_UNREAD = 1<<4, - EM_MENU_SELECT_DELETE = 1<<5, - EM_MENU_SELECT_UNDELETE = 1<<6, - EM_MENU_SELECT_MAILING_LIST = 1<<7, - EM_MENU_SELECT_EDIT = 1<<8, - EM_MENU_SELECT_MARK_IMPORTANT = 1<<9, - EM_MENU_SELECT_MARK_UNIMPORTANT = 1<<10, - EM_MENU_SELECT_FLAG_FOLLOWUP = 1<<11, - EM_MENU_SELECT_FLAG_COMPLETED = 1<<12, - EM_MENU_SELECT_FLAG_CLEAR = 1<<13, - EM_MENU_SELECT_ADD_SENDER = 1<<14, - EM_MENU_SELECT_MARK_JUNK = 1<<15, - EM_MENU_SELECT_MARK_NOJUNK = 1<<16, - EM_MENU_SELECT_FOLDER = 1<<17, /* do we have any folder at all? */ - EM_MENU_SELECT_LAST = 1<<18 /* reserve 2 slots */ -}; - -/* Flags that describe a TARGET_WIDGET (none) - this should probably be a more specific target type */ - -typedef struct _EMMenuTargetSelect EMMenuTargetSelect; - -struct _EMMenuTargetSelect { - EMenuTarget target; - CamelFolder *folder; - gchar *uri; - GPtrArray *uids; -}; - -typedef struct _EMMenuTargetWidget EMMenuTargetWidget; - -struct _EMMenuTargetWidget { - EMenuTarget target; -}; - -typedef struct _EMenuItem EMMenuItem; - -/* The object */ -struct _EMMenu { - EMenu popup; - - struct _EMMenuPrivate *priv; -}; - -struct _EMMenuClass { - EMenuClass popup_class; -}; - -GType em_menu_get_type(void); - -EMMenu *em_menu_new(const gchar *menuid); - -EMMenuTargetSelect *em_menu_target_new_select(EMMenu *emp, CamelFolder *folder, const gchar *folder_uri, GPtrArray *uids); -EMMenuTargetWidget *em_menu_target_new_widget(EMMenu *emp, GtkWidget *w); - -/* ********************************************************************** */ - -typedef struct _EMMenuHook EMMenuHook; -typedef struct _EMMenuHookClass EMMenuHookClass; - -struct _EMMenuHook { - EMenuHook hook; -}; - -struct _EMMenuHookClass { - EMenuHookClass hook_class; -}; - -GType em_menu_hook_get_type(void); - -G_END_DECLS - -#endif /* __EM_MENU_H__ */ diff --git a/mail/em-popup.c b/mail/em-popup.c deleted file mode 100644 index f9caf9de0c..0000000000 --- a/mail/em-popup.c +++ /dev/null @@ -1,472 +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: - * Michael Zucchi - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include -#include - -#include "em-popup.h" -#include "libedataserver/e-msgport.h" -#include "em-utils.h" -#include "em-composer-utils.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include "e-attachment.h" - -static GObjectClass *emp_parent; - -static void -emp_init(GObject *o) -{ - /*EMPopup *emp = (EMPopup *)o; */ -} - -static void -emp_finalise(GObject *o) -{ - ((GObjectClass *)emp_parent)->finalize(o); -} - -static void -emp_target_free(EPopup *ep, EPopupTarget *t) -{ - switch (t->type) { - case EM_POPUP_TARGET_SELECT: { - EMPopupTargetSelect *s = (EMPopupTargetSelect *)t; - - if (s->folder) - camel_object_unref(s->folder); - g_free(s->uri); - if (s->uids) - em_utils_uids_free(s->uids); - break; } - case EM_POPUP_TARGET_URI: { - EMPopupTargetURI *s = (EMPopupTargetURI *)t; - - g_free(s->uri); - break; } - case EM_POPUP_TARGET_PART: { - EMPopupTargetPart *s = (EMPopupTargetPart *)t; - - camel_object_unref(s->part); - g_free(s->mime_type); - break; } - case EM_POPUP_TARGET_FOLDER: { - EMPopupTargetFolder *s = (EMPopupTargetFolder *)t; - - g_free(s->uri); - break; } - } - - ((EPopupClass *)emp_parent)->target_free(ep, t); -} - -static void -emp_class_init(GObjectClass *klass) -{ - klass->finalize = emp_finalise; - ((EPopupClass *)klass)->target_free = emp_target_free; -} - -GType -em_popup_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof(EMPopupClass), - NULL, NULL, - (GClassInitFunc)emp_class_init, - NULL, NULL, - sizeof(EMPopup), 0, - (GInstanceInitFunc)emp_init - }; - emp_parent = g_type_class_ref(e_popup_get_type()); - type = g_type_register_static(e_popup_get_type(), "EMPopup", &info, 0); - } - - return type; -} - -EMPopup *em_popup_new(const gchar *menuid) -{ - EMPopup *emp = g_object_new(em_popup_get_type(), NULL); - - e_popup_construct(&emp->popup, menuid); - - return emp; -} - -/** - * em_popup_target_new_select: - * @folder: The selection will ref this for the life of it. - * @folder_uri: - * @uids: The selection will free this when done with it. - * - * Create a new selection popup target. - * - * Return value: - **/ -EMPopupTargetSelect * -em_popup_target_new_select(EMPopup *emp, CamelFolder *folder, const gchar *folder_uri, GPtrArray *uids) -{ - EMPopupTargetSelect *t = e_popup_target_new(&emp->popup, EM_POPUP_TARGET_SELECT, sizeof(*t)); - CamelStore *store = CAMEL_STORE (folder->parent_store); - guint32 mask = ~0; - gboolean draft_or_outbox; - gint i; - const gchar *tmp; - - t->uids = uids; - t->folder = folder; - t->uri = g_strdup(folder_uri); - - if (folder == NULL) { - t->target.mask = mask; - - return t; - } - - camel_object_ref(folder); - mask &= ~EM_POPUP_SELECT_FOLDER; - - if (em_utils_folder_is_sent(folder, folder_uri)) - mask &= ~EM_POPUP_SELECT_EDIT; - - draft_or_outbox = em_utils_folder_is_drafts(folder, folder_uri) || em_utils_folder_is_outbox(folder, folder_uri); - if (!draft_or_outbox && uids->len == 1) - mask &= ~EM_POPUP_SELECT_ADD_SENDER; - - if (uids->len == 1) - mask &= ~EM_POPUP_SELECT_ONE; - - if (uids->len >= 1) - mask &= ~EM_POPUP_SELECT_MANY; - - for (i = 0; i < uids->len; i++) { - CamelMessageInfo *info = camel_folder_get_message_info(folder, uids->pdata[i]); - guint32 flags; - - if (info == NULL) - continue; - - flags = camel_message_info_flags(info); - if (flags & CAMEL_MESSAGE_SEEN) - mask &= ~EM_POPUP_SELECT_MARK_UNREAD; - else - mask &= ~EM_POPUP_SELECT_MARK_READ; - - if ((store->flags & CAMEL_STORE_VJUNK) && !draft_or_outbox) { - if ((flags & CAMEL_MESSAGE_JUNK)) - mask &= ~EM_POPUP_SELECT_NOT_JUNK; - else - mask &= ~EM_POPUP_SELECT_JUNK; - } else if (draft_or_outbox) { - /* Show none option */ - mask |= EM_POPUP_SELECT_NOT_JUNK; - mask |= EM_POPUP_SELECT_JUNK; - } else { - /* Show both options */ - mask &= ~EM_POPUP_SELECT_NOT_JUNK; - mask &= ~EM_POPUP_SELECT_JUNK; - } - - if (flags & CAMEL_MESSAGE_DELETED) - mask &= ~EM_POPUP_SELECT_UNDELETE; - else - mask &= ~EM_POPUP_SELECT_DELETE; - - if (flags & CAMEL_MESSAGE_FLAGGED) - mask &= ~EM_POPUP_SELECT_MARK_UNIMPORTANT; - else - mask &= ~EM_POPUP_SELECT_MARK_IMPORTANT; - - tmp = camel_message_info_user_tag(info, "follow-up"); - if (tmp && *tmp) { - mask &= ~EM_POPUP_SELECT_FLAG_CLEAR; - tmp = camel_message_info_user_tag(info, "completed-on"); - if (tmp == NULL || *tmp == 0) - mask &= ~EM_POPUP_SELECT_FLAG_COMPLETED; - } else - mask &= ~EM_POPUP_SELECT_FLAG_FOLLOWUP; - - if (i == 0 && uids->len == 1 - && (tmp = camel_message_info_mlist(info)) - && tmp[0] != 0) - mask &= ~EM_POPUP_SELECT_MAILING_LIST; - - camel_folder_free_message_info(folder, info); - } - - t->target.mask = mask; - - return t; -} - -EMPopupTargetURI * -em_popup_target_new_uri(EMPopup *emp, const gchar *uri) -{ - EMPopupTargetURI *t = e_popup_target_new(&emp->popup, EM_POPUP_TARGET_URI, sizeof(*t)); - guint32 mask = ~0; - - t->uri = g_strdup(uri); - - if (g_ascii_strncasecmp(uri, "http:", 5) == 0 - || g_ascii_strncasecmp(uri, "https:", 6) == 0) - mask &= ~EM_POPUP_URI_HTTP; - - if (g_ascii_strncasecmp(uri, "mailto:", 7) == 0) - mask &= ~EM_POPUP_URI_MAILTO; - else - mask &= ~(EM_POPUP_URI_NOT_MAILTO|~mask); - - t->target.mask = mask; - - return t; -} - -EMPopupTargetPart * -em_popup_target_new_part(EMPopup *emp, CamelMimePart *part, const gchar *mime_type) -{ - EMPopupTargetPart *t = e_popup_target_new(&emp->popup, EM_POPUP_TARGET_PART, sizeof(*t)); - guint32 mask = ~0; - - t->part = part; - camel_object_ref(part); - if (mime_type) - t->mime_type = g_strdup(mime_type); - else - t->mime_type = camel_data_wrapper_get_mime_type((CamelDataWrapper *)part); - - camel_strdown(t->mime_type); - - if (CAMEL_IS_MIME_MESSAGE(camel_medium_get_content_object((CamelMedium *)part))) - mask &= ~EM_POPUP_PART_MESSAGE; - - if (strncmp(t->mime_type, "image/", 6) == 0) - mask &= ~EM_POPUP_PART_IMAGE; - - t->target.mask = mask; - - return t; -} - -/* TODO: This should be based on the CamelFolderInfo, but ... em-folder-tree doesn't keep it? */ -EMPopupTargetFolder * -em_popup_target_new_folder (EMPopup *emp, const gchar *uri, guint32 info_flags, guint32 popup_flags) -{ - EMPopupTargetFolder *t = e_popup_target_new(&emp->popup, EM_POPUP_TARGET_FOLDER, sizeof(*t)); - guint32 mask = ~0; - CamelURL *url; - - t->uri = g_strdup(uri); - - if (popup_flags & EM_POPUP_FOLDER_STORE) - mask &= ~(EM_POPUP_FOLDER_STORE|EM_POPUP_FOLDER_INFERIORS); - else - mask &= ~EM_POPUP_FOLDER_FOLDER; - - url = camel_url_new(uri, NULL); - if (url == NULL) - goto done; - - if (!(popup_flags & EM_POPUP_FOLDER_STORE)) { - const gchar *path; - - if (popup_flags & EM_POPUP_FOLDER_DELETE) - mask &= ~EM_POPUP_FOLDER_DELETE; - - if (!(info_flags & CAMEL_FOLDER_NOINFERIORS)) - mask &= ~EM_POPUP_FOLDER_INFERIORS; - - if (info_flags & CAMEL_FOLDER_TYPE_OUTBOX) - mask &= ~EM_POPUP_FOLDER_OUTBOX; - else - mask &= ~EM_POPUP_FOLDER_NONSTATIC; - - if (!(info_flags & CAMEL_FOLDER_NOSELECT)) - mask &= ~EM_POPUP_FOLDER_SELECT; - - if (info_flags & CAMEL_FOLDER_VIRTUAL) - mask |= EM_POPUP_FOLDER_DELETE|EM_POPUP_FOLDER_INFERIORS; - - if ((path = url->fragment ? url->fragment : url->path)) { - if ((!strcmp (url->protocol, "vfolder") && !strcmp (path, CAMEL_UNMATCHED_NAME)) - || (!strcmp (url->protocol, "maildir") && !strcmp (path, "."))) /* hack for maildir toplevel folder */ - mask |= EM_POPUP_FOLDER_DELETE|EM_POPUP_FOLDER_INFERIORS; - } - } - - camel_url_free(url); -done: - t->target.mask = mask; - - return t; -} - -/* ********************************************************************** */ - -/* Popup menu plugin handler */ - -/* - - - - - - - -*/ - -static gpointer emph_parent_class; -#define emph ((EMPopupHook *)eph) - -static const EPopupHookTargetMask emph_select_masks[] = { - { "one", EM_POPUP_SELECT_ONE }, - { "many", EM_POPUP_SELECT_MANY }, - { "mark_read", EM_POPUP_SELECT_MARK_READ }, - { "mark_unread", EM_POPUP_SELECT_MARK_UNREAD }, - { "delete", EM_POPUP_SELECT_DELETE }, - { "undelete", EM_POPUP_SELECT_UNDELETE }, - { "mailing_list", EM_POPUP_SELECT_MAILING_LIST }, - { "resend", EM_POPUP_SELECT_EDIT }, - { "mark_important", EM_POPUP_SELECT_MARK_IMPORTANT }, - { "mark_unimportant", EM_POPUP_SELECT_MARK_UNIMPORTANT }, - { "flag_followup", EM_POPUP_SELECT_FLAG_FOLLOWUP }, - { "flag_completed", EM_POPUP_SELECT_FLAG_COMPLETED }, - { "flag_clear", EM_POPUP_SELECT_FLAG_CLEAR }, - { "add_sender", EM_POPUP_SELECT_ADD_SENDER }, - { "folder", EM_POPUP_SELECT_FOLDER }, - { "junk", EM_POPUP_SELECT_JUNK }, - { "not_junk", EM_POPUP_SELECT_NOT_JUNK }, - { NULL } -}; - -static const EPopupHookTargetMask emph_uri_masks[] = { - { "http", EM_POPUP_URI_HTTP }, - { "mailto", EM_POPUP_URI_MAILTO }, - { "notmailto", EM_POPUP_URI_NOT_MAILTO }, - { NULL } -}; - -static const EPopupHookTargetMask emph_part_masks[] = { - { "message", EM_POPUP_PART_MESSAGE }, - { "image", EM_POPUP_PART_IMAGE }, - { NULL } -}; - -static const EPopupHookTargetMask emph_folder_masks[] = { - { "folder", EM_POPUP_FOLDER_FOLDER }, - { "store", EM_POPUP_FOLDER_STORE }, - { "inferiors", EM_POPUP_FOLDER_INFERIORS }, - { "delete", EM_POPUP_FOLDER_DELETE }, - { "select", EM_POPUP_FOLDER_SELECT }, - { "outbox", EM_POPUP_FOLDER_OUTBOX }, - { "nonstatic", EM_POPUP_FOLDER_NONSTATIC }, - { NULL } -}; - -static const EPopupHookTargetMap emph_targets[] = { - { "select", EM_POPUP_TARGET_SELECT, emph_select_masks }, - { "uri", EM_POPUP_TARGET_URI, emph_uri_masks }, - { "part", EM_POPUP_TARGET_PART, emph_part_masks }, - { "folder", EM_POPUP_TARGET_FOLDER, emph_folder_masks }, - { NULL } -}; - -static void -emph_finalise(GObject *o) -{ - /*EPluginHook *eph = (EPluginHook *)o;*/ - - ((GObjectClass *)emph_parent_class)->finalize(o); -} - -static void -emph_class_init(EPluginHookClass *klass) -{ - gint i; - - ((GObjectClass *)klass)->finalize = emph_finalise; - ((EPluginHookClass *)klass)->id = "org.gnome.evolution.mail.popup:1.0"; - - for (i=0;emph_targets[i].type;i++) - e_popup_hook_class_add_target_map((EPopupHookClass *)klass, &emph_targets[i]); - - ((EPopupHookClass *)klass)->popup_class = g_type_class_ref(em_popup_get_type()); -} - -GType -em_popup_hook_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EMPopupHookClass), NULL, NULL, (GClassInitFunc) emph_class_init, NULL, NULL, - sizeof(EMPopupHook), 0, (GInstanceInitFunc) NULL, - }; - - emph_parent_class = g_type_class_ref(e_popup_hook_get_type()); - type = g_type_register_static(e_popup_hook_get_type(), "EMPopupHook", &info, 0); - } - - return type; -} diff --git a/mail/em-popup.h b/mail/em-popup.h deleted file mode 100644 index f7182e9358..0000000000 --- a/mail/em-popup.h +++ /dev/null @@ -1,261 +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: - * Michel Zucchi - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EM_POPUP_H__ -#define __EM_POPUP_H__ - -#include -#include - -#include "e-util/e-popup.h" - -G_BEGIN_DECLS - -typedef struct _EMPopup EMPopup; -typedef struct _EMPopupClass EMPopupClass; - -/** - * enum _em_popup_target_t - A list of mail popup target types. - * - * @EM_POPUP_TARGET_SELECT: A selection of messages. - * @EM_POPUP_TARGET_URI: A URI. - * @EM_POPUP_TARGET_PART: A CamelMimePart message part. - * @EM_POPUP_TARGET_FOLDER: A folder URI. - * - * Defines the value of the targetid for all EMPopup target types. - **/ -enum _em_popup_target_t { - EM_POPUP_TARGET_SELECT, - EM_POPUP_TARGET_URI, - EM_POPUP_TARGET_PART, - EM_POPUP_TARGET_FOLDER -}; - -/** - * enum _em_popup_target_select_t - EMPopupTargetSelect qualifiers. - * - * @EM_POPUP_SELECT_ONE: Only one item is selected. - * @EM_POPUP_SELECT_MANY: One ore more items are selected. - * @EM_POPUP_SELECT_MARK_READ: Message(s) are unseen and can be - * marked seen. - * @EM_POPUP_SELECT_MARK_UNREAD: Message(s) are seen and can be - * marked unseen. - * @EM_POPUP_SELECT_DELETE: Message(s) are undeleted and can - * be marked deleted. - * @EM_POPUP_SELECT_UNDELETE: Message(s) are deleted and can be - * undeleted. - * @EM_POPUP_SELECT_MAILING_LIST: If one message is selected, and it - * contains a message list tag. - * @EM_POPUP_SELECT_EDIT: The message can be opened for editing (the - * folder is a sent folder). - * @EM_POPUP_SELECT_MARK_IMPORTANT: Message(s) are not marked - * important. - * @EM_POPUP_SELECT_MARK_UNIMPORTANT: Message(s) are marked - * important. - * @EM_POPUP_SELECT_FLAG_FOLLOWUP: Message(s) are not flagged for - * followup. - * @EM_POPUP_SELECT_FLAG_COMPLETED: Message(s) are not flagged completed. - * @EM_POPUP_SELECT_FLAG_CLEAR: Message(s) are flagged for followup. - * @EM_POPUP_SELECT_ADD_SENDER: The message contains sender addresses - * which might be added to the addressbook. i.e. it isn't a message in - * the Sent or Drafts folders. - * @EM_POPUP_SELECT_FOLDER: A folder is set on the selection. - * @EM_POPUP_SELECT_LAST: The last bit used, can be used to add - * additional types from derived application code. - * - **/ -enum _em_popup_target_select_t { - EM_POPUP_SELECT_ONE = 1<<1, - EM_POPUP_SELECT_MANY = 1<<2, - EM_POPUP_SELECT_MARK_READ = 1<<3, - EM_POPUP_SELECT_MARK_UNREAD = 1<<4, - EM_POPUP_SELECT_DELETE = 1<<5, - EM_POPUP_SELECT_UNDELETE = 1<<6, - EM_POPUP_SELECT_MAILING_LIST = 1<<7, - EM_POPUP_SELECT_EDIT = 1<<8, - EM_POPUP_SELECT_MARK_IMPORTANT = 1<<9, - EM_POPUP_SELECT_MARK_UNIMPORTANT = 1<<10, - EM_POPUP_SELECT_FLAG_FOLLOWUP = 1<<11, - EM_POPUP_SELECT_FLAG_COMPLETED = 1<<12, - EM_POPUP_SELECT_FLAG_CLEAR = 1<<13, - EM_POPUP_SELECT_ADD_SENDER = 1<<14, - EM_POPUP_SELECT_FOLDER = 1<<15, /* do we have any folder at all? */ - EM_POPUP_SELECT_JUNK = 1<<16, - EM_POPUP_SELECT_NOT_JUNK = 1<<17, - EM_POPUP_SELECT_LAST = 1<<18 -}; - -/** - * enum _em_popup_target_uri_t - EMPopupTargetURI qualifiers. - * - * @EM_POPUP_URI_HTTP: This is a HTTP or HTTPS url. - * @EM_POPUP_URI_MAILTO: This is a MAILTO url. - * @EM_POPUP_URI_NOT_MAILTO: This is not a MAILTO url. - * - **/ -enum _em_popup_target_uri_t { - EM_POPUP_URI_HTTP = 1<<0, - EM_POPUP_URI_MAILTO = 1<<1, - EM_POPUP_URI_NOT_MAILTO = 1<<2 -}; - -/** - * enum _em_popup_target_part_t - EMPopupTargetPart qualifiers. - * - * @EM_POPUP_PART_MESSAGE: This is a message type. - * @EM_POPUP_PART_IMAGE: This is an image type. - * - **/ -enum _em_popup_target_part_t { - EM_POPUP_PART_MESSAGE = 1<<0, - EM_POPUP_PART_IMAGE = 1<<1 -}; - -/** - * enum _em_popup_target_folder_t - EMPopupTargetFolder qualifiers. - * - * @EM_POPUP_FOLDER_FOLDER: This is a normal folder. - * @EM_POPUP_FOLDER_STORE: This is a store. - * @EM_POPUP_FOLDER_INFERIORS: This folder may have child folders. - * @EM_POPUP_FOLDER_DELETE: This folder can be deleted or renamed. - * @EM_POPUP_FOLDER_SELECT: This folder exists and can be selected or - * opened. - * - **/ -enum _em_popup_target_folder_t { - EM_POPUP_FOLDER_FOLDER = 1<<0, /* normal folder */ - EM_POPUP_FOLDER_STORE = 1<<1, /* root/nonselectable folder, i.e. store */ - EM_POPUP_FOLDER_INFERIORS = 1<<2, /* folder can have children */ - EM_POPUP_FOLDER_DELETE = 1<<3, /* folder can be deleted/renamed */ - EM_POPUP_FOLDER_SELECT = 1<<4, /* folder can be selected/opened */ - EM_POPUP_FOLDER_OUTBOX = 1<<5, /* Outbox folder */ - EM_POPUP_FOLDER_NONSTATIC = 1<<6 /* Except static folders like Outbox.*/ -}; - -typedef struct _EMPopupTargetSelect EMPopupTargetSelect; -typedef struct _EMPopupTargetURI EMPopupTargetURI; -typedef struct _EMPopupTargetPart EMPopupTargetPart; -typedef struct _EMPopupTargetFolder EMPopupTargetFolder; - -/** - * struct _EMPopupTargetURI - An inline URI. - * - * @target: Superclass. - * @uri: The encoded URI to which this target applies. - * - * Used to represent popup-menu context on any URI object. - **/ -struct _EMPopupTargetURI { - EPopupTarget target; - gchar *uri; -}; - -/** - * struct _EMPopupTargetSelect - A list of messages. - * - * @target: Superclass. - * @folder: The CamelFolder of the selected messages. - * @uri: The encoded URI represending this folder. - * @uids: An array of UID strings of messages within @folder. - * - * Used to represent a selection of messages as context for a popup - * menu. All items may be NULL if the current view has no active - * folder selected. - **/ -struct _EMPopupTargetSelect { - EPopupTarget target; - CamelFolder *folder; - gchar *uri; - GPtrArray *uids; -}; - -/** - * struct _EMPopupTargetPart - A Camel object. - * - * @target: Superclass. - * @mime_type: MIME type of the part. This may be a calculated type - * not matching the @part's MIME type. - * @part: A CamelMimePart representing a message or attachment. - * - * Used to represent a message part as context for a popup menu. This - * is used for both attachments and inline-images. - **/ -struct _EMPopupTargetPart { - EPopupTarget target; - gchar *mime_type; - CamelMimePart *part; -}; - -/** - * struct _EMPopupTargetFolder - A folder uri. - * - * @target: Superclass. - * @uri: A folder URI. - * - * This target is used to represent folder context. - **/ -struct _EMPopupTargetFolder { - EPopupTarget target; - gchar *uri; -}; - -typedef struct _EPopupItem EMPopupItem; - -/* The object */ -struct _EMPopup { - EPopup popup; - - struct _EMPopupPrivate *priv; -}; - -struct _EMPopupClass { - EPopupClass popup_class; -}; - -GType em_popup_get_type(void); - -EMPopup *em_popup_new(const gchar *menuid); - -EMPopupTargetURI *em_popup_target_new_uri(EMPopup *emp, const gchar *uri); -EMPopupTargetSelect *em_popup_target_new_select(EMPopup *emp, CamelFolder *folder, const gchar *folder_uri, GPtrArray *uids); -EMPopupTargetPart *em_popup_target_new_part(EMPopup *emp, CamelMimePart *part, const gchar *mime_type); -EMPopupTargetFolder *em_popup_target_new_folder(EMPopup *emp, const gchar *uri, guint32 info_flags, guint32 popup_flags); - -/* ********************************************************************** */ - -typedef struct _EMPopupHook EMPopupHook; -typedef struct _EMPopupHookClass EMPopupHookClass; - -struct _EMPopupHook { - EPopupHook hook; -}; - -struct _EMPopupHookClass { - EPopupHookClass hook_class; -}; - -GType em_popup_hook_get_type(void); - -G_END_DECLS - -#endif /* __EM_POPUP_H__ */ diff --git a/mail/message-list.c b/mail/message-list.c index ce1b20123e..b80431d5ff 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -70,7 +70,6 @@ #include "table/e-cell-hbox.h" #include "e-mail-label-list-store.h" -#include "em-popup.h" #include "em-utils.h" #include "mail-config.h" #include "mail-mt.h" @@ -2156,6 +2155,7 @@ ml_drop_action(struct _drop_msg *m) mail_msg_unordered_push (m); } +#if 0 /* KILL-BONOBO */ static void ml_drop_popup_copy(EPopup *ep, EPopupItem *item, gpointer data) { @@ -2241,6 +2241,7 @@ ml_tree_drag_data_received (ETree *tree, gint row, ETreePath path, gint col, ml_drop_action(m); } } +#endif struct search_child_struct { gboolean found; @@ -2709,8 +2710,10 @@ message_list_construct (MessageList *message_list) ml_drop_types, sizeof(ml_drop_types)/sizeof(ml_drop_types[0]), GDK_ACTION_MOVE|GDK_ACTION_COPY|GDK_ACTION_ASK); +#if 0 /* KILL-BONOBO */ g_signal_connect(message_list->tree, "tree_drag_data_received", G_CALLBACK(ml_tree_drag_data_received), message_list); +#endif g_signal_connect(message_list->tree, "drag-motion", G_CALLBACK(ml_tree_drag_motion), message_list); } diff --git a/plugins/email-custom-header/email-custom-header.c b/plugins/email-custom-header/email-custom-header.c index 81dd24d396..4e76f971c8 100644 --- a/plugins/email-custom-header/email-custom-header.c +++ b/plugins/email-custom-header/email-custom-header.c @@ -29,7 +29,6 @@ #include #include #include -#include "mail/em-menu.h" #include "mail/em-utils.h" #include "mail/em-event.h" #include "composer/e-msg-composer.h" diff --git a/plugins/external-editor/external-editor.c b/plugins/external-editor/external-editor.c index dcd81650f5..2342651fa3 100644 --- a/plugins/external-editor/external-editor.c +++ b/plugins/external-editor/external-editor.c @@ -26,7 +26,6 @@ #include #endif -#include #include #include #include diff --git a/plugins/face/face.c b/plugins/face/face.c index 6bbc7bbf1a..1bb56c2bff 100644 --- a/plugins/face/face.c +++ b/plugins/face/face.c @@ -28,7 +28,6 @@ #include "composer/e-msg-composer.h" #include #include -#include #include #include diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 3613694985..16c1ab5f35 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -46,8 +46,6 @@ #include #include -#include -#include #include #include #include diff --git a/plugins/templates/org-gnome-templates.eplug.xml b/plugins/templates/org-gnome-templates.eplug.xml index 02b14148ad..b4b8a81039 100644 --- a/plugins/templates/org-gnome-templates.eplug.xml +++ b/plugins/templates/org-gnome-templates.eplug.xml @@ -7,30 +7,22 @@ _name="Templates"> <_description>Drafts based template plugin - + - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - diff --git a/plugins/templates/templates.c b/plugins/templates/templates.c index 78a0cf40a1..89496b57eb 100644 --- a/plugins/templates/templates.c +++ b/plugins/templates/templates.c @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -35,13 +36,15 @@ #include #include +#include #include -#include #include #include +#include #include #include -#include +#include +#include #include @@ -63,32 +66,10 @@ enum { CLUE_N_COLUMNS }; -typedef struct { - CamelMimeMessage *msg; - EMPopupTargetSelect *t; -} UserData; - -static gchar * get_content (CamelMimeMessage *message); - -static void reply_with_template (EPopup *ep, EPopupItem *item, gpointer data); - -static void popup_free (EPopup *ep, GSList *l, gpointer data); - -static GSList *fill_submenu (CamelStore *store, - CamelFolderInfo *info, - GSList *list, - EMPopupTargetSelect *t); - -static GSList *append_to_menu (CamelFolder *folder, - GPtrArray *uids, - GSList *list, - EMPopupTargetSelect *t); - -void org_gnome_templates_popup (EPlugin *ep, EMPopupTargetSelect *t); - GtkWidget *e_plugin_lib_get_configure_widget (EPlugin *epl); -gboolean e_plugin_ui_init (GtkUIManager *ui_manager, EMsgComposer *composer); +gboolean e_plugin_ui_init (GtkUIManager *ui_manager, GObject *object); +gint e_plugin_lib_enable (EPlugin *plugin, gboolean enabled); /* Thanks to attachment reminder plugin for this*/ static void commit_changes (UIData *ui); @@ -102,6 +83,8 @@ static void value_cell_edited_callback (GtkCellRendererText *cell, gchar *path_ static gboolean clue_foreach_check_isempty (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, UIData *ui); +static gboolean plugin_enabled; + static void selection_changed (GtkTreeSelection *selection, UIData *ui) { @@ -496,32 +479,23 @@ get_content (CamelMimeMessage *message) } static void -reply_with_template (EPopup *ep, EPopupItem *item, gpointer data) +action_reply_with_template_cb (GtkAction *action, + CamelMimeMessage *message) { - CamelMimeMessage *new, *template, *reply_to; - CamelFolder *templates_folder; + CamelMimeMessage *new, *template; + CamelFolder *folder; struct _camel_header_raw *header; - UserData *userdata = item->user_data; gchar *cont; - /* We get the templates folder and all the uids of the messages in there */ - templates_folder = e_mail_local_get_folder (E_MAIL_FOLDER_TEMPLATES); - - /* Get from the currently selected folder, the currently selected message */ - reply_to = camel_folder_get_message (userdata->t->folder, - g_ptr_array_index (userdata->t->uids, 0), - NULL); - - /* The message we'll be using has been stored when building the menu */ - template = userdata->msg; + folder = e_mail_local_get_folder (E_MAIL_FOLDER_TEMPLATES); + template = g_object_get_data (G_OBJECT (action), "template"); /* The new message we are creating */ new = camel_mime_message_new(); /* Add the headers from the message we are replying to, so CC and that - * stuff is preserved. - */ - header = ((CamelMimePart *)reply_to)->headers; + * stuff is preserved. */ + header = ((CamelMimePart *)message)->headers; while (header) { if (g_ascii_strncasecmp (header->name, "content-", 8) != 0) { camel_medium_add_header((CamelMedium *) new, @@ -538,7 +512,7 @@ reply_with_template (EPopup *ep, EPopupItem *item, gpointer data) /* Set the To: field to the same To: field of the message we are replying to. */ camel_mime_message_set_recipients (new, CAMEL_RECIPIENT_TYPE_TO, - camel_mime_message_get_from (reply_to)); + camel_mime_message_get_from (message)); /* Copy the CC and BCC from the template.*/ camel_mime_message_set_recipients (new, CAMEL_RECIPIENT_TYPE_CC, @@ -551,160 +525,148 @@ reply_with_template (EPopup *ep, EPopupItem *item, gpointer data) cont, (gint) g_utf8_strlen(cont, -1), "text"); /* Create the composer */ - em_utils_edit_message (new, templates_folder); + em_utils_edit_message (new, folder); camel_object_unref(new); } static void -popup_free (EPopup *ep, GSList *l, gpointer data) +build_template_menus_recurse (GtkUIManager *ui_manager, + GtkActionGroup *action_group, + const gchar *menu_path, + guint *action_count, + guint merge_id, + CamelFolderInfo *folder_info, + CamelMimeMessage *message) { - g_slist_free (l); -} + CamelStore *store; -static GSList -*append_to_menu (CamelFolder *folder, GPtrArray *uids, GSList *list, EMPopupTargetSelect *t) -{ - gint i; + store = e_mail_local_get_store (); - for (i = 0; i < uids->len; i++) { - const gchar *subject; + while (folder_info != NULL) { + CamelFolder *folder; + GPtrArray *uids; + GtkAction *action; + const gchar *action_label; + gchar *action_name; gchar *path; - EPopupItem *item; - CamelMimeMessage *message; - UserData *user_data; - const gchar *uid; - - uid = g_strdup (g_ptr_array_index (uids, i)); - - /* Same as in fill_submenu */ - if (!g_str_has_suffix (folder->name, "Templates")) - path = g_strdup_printf ("80.%s", folder->full_name); - else - path = g_strdup ("80.Templates"); - - /* If this uid is trashed, ignore it */ - if (camel_folder_get_message_flags (folder, uid) & CAMEL_MESSAGE_DELETED) - continue; + guint ii; - /* Get the message for this uid */ - message = camel_folder_get_message (folder, - uid, - NULL); + folder = camel_store_get_folder ( + store, folder_info->full_name, 0, NULL); - subject = camel_mime_message_get_subject (message); + action_name = g_strdup_printf ( + "templates-menu-%d", *action_count); + *action_count = *action_count + 1; - /* Create the menu item for it */ - item = g_slice_alloc0(sizeof(*item)); - item->type = E_POPUP_ITEM; - item->path = g_strdup_printf ("%s/%02d", path, i); - item->label = g_strdup ((strlen(subject) > 0) ? subject : _("No title")); - item->visible = EM_POPUP_SELECT_MANY | EM_POPUP_SELECT_ONE; + /* To avoid having a Templates dir, we ignore the top level */ + if (g_str_has_suffix (folder->name, "Templates")) + action_label = _("Templates"); + else + action_label = folder->name; - /* Make some info available to the callback */ - user_data = g_slice_new(UserData); - user_data->msg = message; - user_data->t = t; + action = gtk_action_new ( + action_name, action_label, NULL, NULL); - item->user_data = user_data; - item->activate = reply_with_template; + gtk_action_group_add_action (action_group, action); - list = g_slist_prepend (list, item); - } + g_debug ("Adding %s/%s", menu_path, action_name); - return list; -} + gtk_ui_manager_add_ui ( + ui_manager, merge_id, menu_path, action_name, + action_name, GTK_UI_MANAGER_MENU, FALSE); -static GSList -*fill_submenu (CamelStore *store, CamelFolderInfo *info, GSList *list, EMPopupTargetSelect *t) -{ - while (info) { - CamelFolder *folder; - GPtrArray *uids; - EPopupItem *item; + path = g_strdup_printf ("%s/%s", menu_path, action_name); - folder = camel_store_get_folder (store, info->full_name, 0, NULL); + g_object_unref (action); + g_free (action_name); - item = g_slice_alloc0(sizeof(*item)); - item->type = E_POPUP_SUBMENU; - item->label = folder->name; - item->visible = EM_POPUP_SELECT_MANY | EM_POPUP_SELECT_ONE; + /* Add submenus, if any. */ + if (folder_info->child != NULL) + build_template_menus_recurse ( + ui_manager, action_group, + path, action_count, merge_id, + folder_info->child, message); - /* To avoid having a Templates dir, we ignore the top level */ - if (!g_str_has_suffix (folder->name, "Templates")) - item->path = g_strdup_printf ("80.%s", folder->full_name); - else - item->path = g_strdup ("80.Templates"); + /* Get the UIDs for this folder and add them to the menu. */ + uids = camel_folder_get_uids (folder); + for (ii = 0; ii < uids->len; ii++) { + CamelMimeMessage *template; + const gchar *uid = uids->pdata[ii]; + guint32 flags; - list = g_slist_prepend (list, item); + /* If the UIDs is marked for deletion, skip it. */ + flags = camel_folder_get_message_flags (folder, uid); + if (flags & CAMEL_MESSAGE_DELETED) + continue; - /* Get the uids for this folder and fill them in the menu */ - uids = camel_folder_get_uids (folder); - list = append_to_menu (folder, uids, list, t); - camel_folder_free_uids (folder, uids); + template = camel_folder_get_message (folder, uid, NULL); + camel_object_ref (template); - /* If the folder has a child, call this function again */ - if (info->child) { - list = fill_submenu (store, info->child, list, t); - } + action_label = + camel_mime_message_get_subject (template); + if (action_label == NULL || *action_label == '\0') + action_label = _("No Title"); - info = info->next; - } + action_name = g_strdup_printf ( + "templates-item-%d", *action_count); + *action_count = *action_count + 1; - return list; -} + action = gtk_action_new ( + action_name, action_label, NULL, NULL); -void -org_gnome_templates_popup (EPlugin *ep, EMPopupTargetSelect *t) -{ - CamelFolder *templates_folder; - CamelFolderInfo *templates_info; - CamelStore *store; + g_object_set_data_full ( + G_OBJECT (action), "template", template, + (GDestroyNotify) camel_object_unref); - GSList *list = NULL; + g_signal_connect ( + action, "activate", + G_CALLBACK (action_reply_with_template_cb), + message); - /* We get the templates folder and all the uids of the messages in there */ - store = e_mail_local_get_store (); + gtk_action_group_add_action (action_group, action); - templates_folder = e_mail_local_get_folder (E_MAIL_FOLDER_TEMPLATES); + g_debug ("Adding %s/%s", path, action_name); - templates_info = camel_store_get_folder_info ( - store, templates_folder->full_name, - CAMEL_STORE_FOLDER_INFO_RECURSIVE | - CAMEL_STORE_FOLDER_INFO_FAST, NULL); + gtk_ui_manager_add_ui ( + ui_manager, merge_id, path, action_name, + action_name, GTK_UI_MANAGER_MENUITEM, FALSE); - /* Get subfolders and fill it */ - list = fill_submenu (store, templates_info, list, t); + g_object_unref (action); + g_free (action_name); + } + camel_folder_free_uids (folder, uids); - e_popup_add_items (t->target.popup, list, NULL, popup_free, NULL); + g_free (path); - return; + folder_info = folder_info->next; + } } static void action_template_cb (GtkAction *action, - EMsgComposer *composer) + EMsgComposer *composer) { CamelMessageInfo *info; CamelMimeMessage *msg; - CamelFolder *templates_folder; + CamelFolder *folder; + + /* Get the templates folder and all UIDs of the messages there. */ + folder = e_mail_local_get_folder (E_MAIL_FOLDER_TEMPLATES); - /* We get the templates folder and all the uids of the messages in there */ - templates_folder = e_mail_local_get_folder (E_MAIL_FOLDER_TEMPLATES); msg = e_msg_composer_get_message_draft (composer); info = camel_message_info_new (NULL); /* FIXME: what's the ~0 for? :) */ - camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DRAFT, ~0); + camel_message_info_set_flags ( + info, CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DRAFT, ~0); - mail_append_mail (templates_folder, msg, info, NULL, composer); - - return; + mail_append_mail (folder, msg, info, NULL, composer); } -static GtkActionEntry entries[] = { +static GtkActionEntry composer_entries[] = { - { "Template", + { "template", GTK_STOCK_SAVE, N_("Save as _Template"), "t", @@ -712,9 +674,73 @@ static GtkActionEntry entries[] = { G_CALLBACK (action_template_cb) } }; -gboolean -e_plugin_ui_init (GtkUIManager *ui_manager, - EMsgComposer *composer) +static void +update_actions_cb (EShellView *shell_view) +{ + EShellContent *shell_content; + EShellWindow *shell_window; + GtkActionGroup *action_group; + GtkUIManager *ui_manager; + MessageList *message_list; + CamelMimeMessage *message; + CamelFolderInfo *folder_info; + CamelFolder *folder; + CamelStore *store; + EMailReader *reader; + GPtrArray *uids; + guint action_count = 0; + guint merge_id; + gpointer data; + + shell_content = e_shell_view_get_shell_content (shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + ui_manager = e_shell_window_get_ui_manager (shell_window); + action_group = e_lookup_action_group (ui_manager, "templates"); + data = g_object_get_data (G_OBJECT (action_group), "merge-id"); + merge_id = GPOINTER_TO_UINT (data); + g_return_if_fail (merge_id > 0); + + gtk_ui_manager_remove_ui (ui_manager, merge_id); + e_action_group_remove_all_actions (action_group); + + if (!plugin_enabled) + return; + + reader = E_MAIL_READER (shell_content); + message_list = e_mail_reader_get_message_list (reader); + + folder = message_list->folder; + uids = message_list_get_selected (message_list); + + if (uids->len != 1) + goto exit; + + /* This is the source message to use in replying with a template. */ + message = camel_folder_get_message (folder, uids->pdata[0], NULL); + + /* Now recursively build template submenus in the pop-up menu. */ + + store = e_mail_local_get_store (); + folder = e_mail_local_get_folder (E_MAIL_FOLDER_TEMPLATES); + + folder_info = camel_store_get_folder_info ( + store, folder->full_name, + CAMEL_STORE_FOLDER_INFO_RECURSIVE | + CAMEL_STORE_FOLDER_INFO_FAST, NULL); + + build_template_menus_recurse ( + ui_manager, action_group, + "/mail-message-popup/mail-message-templates", + &action_count, merge_id, folder_info, message); + +exit: + em_utils_uids_free (uids); +} + +static gboolean +init_composer_actions (GtkUIManager *ui_manager, + EMsgComposer *composer) { GtkhtmlEditor *editor; @@ -723,7 +749,62 @@ e_plugin_ui_init (GtkUIManager *ui_manager, /* Add actions to the "composer" action group. */ gtk_action_group_add_actions ( gtkhtml_editor_get_action_group (editor, "composer"), - entries, G_N_ELEMENTS (entries), composer); + composer_entries, G_N_ELEMENTS (composer_entries), composer); return TRUE; } + +static gboolean +init_shell_actions (GtkUIManager *ui_manager, + EShellWindow *shell_window) +{ + EShellView *shell_view; + GtkActionGroup *action_group; + guint merge_id; + + shell_view = e_shell_window_get_shell_view (shell_window, "mail"); + + /* This is where we keep dynamically-built menu items. */ + e_shell_window_add_action_group (shell_window, "templates"); + action_group = e_lookup_action_group (ui_manager, "templates"); + + merge_id = gtk_ui_manager_new_merge_id (ui_manager); + + g_object_set_data ( + G_OBJECT (action_group), "merge-id", + GUINT_TO_POINTER (merge_id)); + + g_signal_connect ( + shell_view, "update-actions", + G_CALLBACK (update_actions_cb), NULL); +} + +gboolean +e_plugin_ui_init (GtkUIManager *ui_manager, + GObject *object) +{ + /* XXX This is a scenario I hadn't considered when designing + * EPluginUI: two different UI manager IDs with different + * closures sharing the same plugin entry point. We know + * the closures are both GObjects so we query the type. + * Awkward, but it should work for now. */ + + if (E_IS_MSG_COMPOSER (object)) + return init_composer_actions ( + ui_manager, E_MSG_COMPOSER (object)); + + if (E_IS_SHELL_WINDOW (object)) + return init_shell_actions ( + ui_manager, E_SHELL_WINDOW (object)); + + return FALSE; +} + +gint +e_plugin_lib_enable (EPlugin *plugin, + gboolean enabled) +{ + plugin_enabled = enabled; + + return 0; +} diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c index 71617433d1..1eb5eed460 100644 --- a/shell/e-shell-window-private.c +++ b/shell/e-shell-window-private.c @@ -212,6 +212,8 @@ e_shell_window_private_init (EShellWindow *shell_window) merge_id = gtk_ui_manager_new_merge_id (priv->ui_manager); priv->gal_view_merge_id = merge_id; + gtk_window_set_title (GTK_WINDOW (shell_window), _("Evolution")); + e_shell_window_actions_init (shell_window); accel_group = gtk_ui_manager_get_accel_group (priv->ui_manager); @@ -335,10 +337,12 @@ e_shell_window_private_constructed (EShellWindow *shell_window) EShellSettings *shell_settings; EShell *shell; GConfBridge *bridge; - GtkActionGroup *action_group; GtkAction *action; + GtkActionGroup *action_group; + GtkUIManager *ui_manager; GObject *object; const gchar *key; + const gchar *id; shell = e_shell_window_get_shell (shell_window); shell_settings = e_shell_get_shell_settings (shell); @@ -427,6 +431,11 @@ e_shell_window_private_constructed (EShellWindow *shell_window) gconf_bridge_bind_property (bridge, key, object, "active"); shell_window_init_switcher_style (shell_window); + + id = "org.gnome.evolution.shell"; + ui_manager = e_shell_window_get_ui_manager (shell_window); + e_plugin_ui_register_manager (ui_manager, id, shell_window); + e_plugin_ui_enable_manager (ui_manager, id); } void diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index c838235616..19392094ee 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -335,20 +335,9 @@ shell_window_class_init (EShellWindowClass *class) static void shell_window_init (EShellWindow *shell_window) { - GtkUIManager *ui_manager; - const gchar *id; - shell_window->priv = E_SHELL_WINDOW_GET_PRIVATE (shell_window); - gtk_window_set_title (GTK_WINDOW (shell_window), _("Evolution")); - e_shell_window_private_init (shell_window); - - ui_manager = e_shell_window_get_ui_manager (shell_window); - - id = "org.gnome.evolution.shell"; - e_plugin_ui_register_manager (ui_manager, id, shell_window); - e_plugin_ui_enable_manager (ui_manager, id); } GType diff --git a/ui/Makefile.am b/ui/Makefile.am index ebae928dee..a57b470dca 100644 --- a/ui/Makefile.am +++ b/ui/Makefile.am @@ -1,10 +1,3 @@ -XML_FILES = \ - evolution.xml \ - evolution-mail-message.xml \ - evolution-mail-list.xml \ - evolution-mail-global.xml \ - evolution-mail-messagedisplay.xml - UI_FILES = \ evolution-calendars.ui \ evolution-contacts.ui \ @@ -14,11 +7,10 @@ UI_FILES = \ evolution-shell.ui \ evolution-tasks.ui -evolutionui_DATA = $(UI_FILES) $(XML_FILES) +evolutionui_DATA = $(UI_FILES) EXTRA_DIST = \ $(UI_FILES) \ - $(XML_FILES) \ ChangeLog.pre-1-4 -include $(top_srcdir)/git.mk diff --git a/ui/evolution-mail-global.xml b/ui/evolution-mail-global.xml deleted file mode 100644 index c582cd6b62..0000000000 --- a/ui/evolution-mail-global.xml +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ui/evolution-mail-list.xml b/ui/evolution-mail-list.xml deleted file mode 100644 index 95b62eb996..0000000000 --- a/ui/evolution-mail-list.xml +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ui/evolution-mail-message.xml b/ui/evolution-mail-message.xml deleted file mode 100644 index f90e737c24..0000000000 --- a/ui/evolution-mail-message.xml +++ /dev/null @@ -1,426 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ui/evolution-mail-messagedisplay.xml b/ui/evolution-mail-messagedisplay.xml deleted file mode 100644 index 7e4fcf30a9..0000000000 --- a/ui/evolution-mail-messagedisplay.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ui/evolution-mail.ui b/ui/evolution-mail.ui index c676cf524e..4c607c9fa5 100644 --- a/ui/evolution-mail.ui +++ b/ui/evolution-mail.ui @@ -109,6 +109,8 @@ + + diff --git a/ui/evolution.xml b/ui/evolution.xml deleted file mode 100644 index 2b4ee71d3b..0000000000 --- a/ui/evolution.xml +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3