aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mail-to-task
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/mail-to-task')
-rw-r--r--plugins/mail-to-task/Makefile.am6
-rw-r--r--plugins/mail-to-task/mail-to-task.c261
-rw-r--r--plugins/mail-to-task/org-gnome-mail-to-task.eplug.xml101
-rw-r--r--plugins/mail-to-task/org-gnome-mail-to-task.xml28
4 files changed, 203 insertions, 193 deletions
diff --git a/plugins/mail-to-task/Makefile.am b/plugins/mail-to-task/Makefile.am
index dc63da7a8c..0815e65dda 100644
--- a/plugins/mail-to-task/Makefile.am
+++ b/plugins/mail-to-task/Makefile.am
@@ -6,20 +6,20 @@ AM_CPPFLAGS = \
@EVO_PLUGIN_RULE@
-plugin_DATA = org-gnome-mail-to-task.eplug org-gnome-mail-to-task.xml
+plugin_DATA = org-gnome-mail-to-task.eplug
plugin_LTLIBRARIES = liborg-gnome-mail-to-task.la
liborg_gnome_mail_to_task_la_SOURCES = mail-to-task.c
liborg_gnome_mail_to_task_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
liborg_gnome_mail_to_task_la_LIBADD = \
$(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/calendar/gui/libevolution-calendar.la \
$(top_builddir)/calendar/common/libevolution-calendarprivate.la \
$(top_builddir)/mail/libevolution-mail.la \
$(EVOLUTION_CALENDAR_LIBS) \
$(EVOLUTION_MAIL_LIBS)
-EXTRA_DIST = org-gnome-mail-to-task.eplug.xml \
- org-gnome-mail-to-task.xml
+EXTRA_DIST = org-gnome-mail-to-task.eplug.xml
BUILT_SOURCES = org-gnome-mail-to-task.eplug
CLEANFILES = $(BUILT_SOURCES)
diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c
index 94b629eae2..1b8ad64768 100644
--- a/plugins/mail-to-task/mail-to-task.c
+++ b/plugins/mail-to-task/mail-to-task.c
@@ -32,10 +32,12 @@
#include <string.h>
#include <stdio.h>
+#include <gtkhtml/gtkhtml.h>
#include <gconf/gconf-client.h>
#include <libecal/e-cal.h>
#include <libedataserver/e-account.h>
#include <libedataserverui/e-source-selector-dialog.h>
+
#include <camel/camel-folder.h>
#include <camel/camel-medium.h>
#include <camel/camel-mime-message.h>
@@ -43,17 +45,30 @@
#include <camel/camel-stream.h>
#include <camel/camel-stream-mem.h>
#include <camel/camel-utf8.h>
-#include "mail/em-menu.h"
-#include "mail/em-popup.h"
-#include "mail/em-utils.h"
-#include "mail/em-folder-view.h"
-#include "mail/em-format-html.h"
-#include "mail/mail-config.h"
-#include "e-util/e-dialog-utils.h"
-#include <gtkhtml/gtkhtml.h>
+
+#include <mail/em-utils.h>
+#include <mail/em-format-html.h>
+#include <mail/mail-config.h>
+#include <e-util/e-account-utils.h>
+#include <e-util/e-dialog-utils.h>
#include <calendar/common/authentication.h>
+#include <misc/e-popup-action.h>
+#include <shell/e-shell-view.h>
+#include <shell/e-shell-window-actions.h>
#include <calendar/gui/cal-editor-utils.h>
+#define E_SHELL_WINDOW_ACTION_CONVERT_TO_EVENT(window) \
+ E_SHELL_WINDOW_ACTION ((window), "mail-convert-to-event")
+#define E_SHELL_WINDOW_ACTION_CONVERT_TO_MEETING(window) \
+ E_SHELL_WINDOW_ACTION ((window), "mail-convert-to-meeting")
+#define E_SHELL_WINDOW_ACTION_CONVERT_TO_MEMO(window) \
+ E_SHELL_WINDOW_ACTION ((window), "mail-convert-to-memo")
+#define E_SHELL_WINDOW_ACTION_CONVERT_TO_TASK(window) \
+ E_SHELL_WINDOW_ACTION ((window), "mail-convert-to-task")
+
+gboolean e_plugin_ui_init (GtkUIManager *ui_manager,
+ EShellView *shell_view);
+
static gchar *
clean_name(const guchar *s)
{
@@ -215,7 +230,7 @@ set_organizer (ECalComponent *comp)
ECalComponentOrganizer organizer = {NULL, NULL, NULL, NULL};
gchar *res;
- account = mail_config_get_default_account ();
+ account = e_get_default_account ();
if (!account)
return NULL;
@@ -522,7 +537,13 @@ do_manage_comp_idle (GSList *manage_comp_datas)
}
if (edit_comp) {
- open_component_editor (mc->client, edit_comp, edit_comp == mc->comp, &error);
+ EShell *shell;
+
+ /* FIXME Pass in the EShell instance. */
+ shell = e_shell_get_default ();
+ open_component_editor (
+ shell, mc->client, edit_comp,
+ edit_comp == mc->comp, &error);
if (edit_comp != mc->comp)
g_object_unref (edit_comp);
}
@@ -742,12 +763,6 @@ do_mail_to_event (AsyncData *data)
return TRUE;
}
-static void
-copy_uids (gchar *uid, GPtrArray *uid_array)
-{
- g_ptr_array_add (uid_array, g_strdup (uid));
-}
-
static gboolean
text_contains_nonwhitespace (const gchar *text, gint len)
{
@@ -775,47 +790,51 @@ text_contains_nonwhitespace (const gchar *text, gint len)
/* should be freed with g_free after done with it */
static gchar *
-get_selected_text (EMFolderView *emfv)
+get_selected_text (EMailReader *reader)
{
+ EMFormatHTMLDisplay *html_display;
+ GtkHTML *html;
gchar *text = NULL;
gint len;
- if (!emfv || !emfv->preview || !gtk_html_command (((EMFormatHTML *)emfv->preview)->html, "is-selection-active"))
+ html_display = e_mail_reader_get_html_display (reader);
+ html = EM_FORMAT_HTML (html_display)->html;
+
+ if (!gtk_html_command (html, "is-selection-active"))
return NULL;
- if (gtk_html_command (((EMFormatHTML *)emfv->preview)->html, "is-selection-active")
- && (text = gtk_html_get_selection_plain_text (((EMFormatHTML *)emfv->preview)->html, &len))
- && len && text && text[0] && text_contains_nonwhitespace (text, len)) {
- /* selection is ok, so use it as returned from gtkhtml widget */
- } else {
+ text = gtk_html_get_selection_plain_text (html, &len);
+
+ if (text == NULL || !text_contains_nonwhitespace (text, len)) {
g_free (text);
- text = NULL;
+ return NULL;
}
return text;
}
static void
-mail_to_event (ECalSourceType source_type, gboolean with_attendees, GPtrArray *uids, CamelFolder *folder, EMFolderView *emfv)
+mail_to_event (ECalSourceType source_type,
+ gboolean with_attendees,
+ EShellView *shell_view)
{
- GPtrArray *uid_array = NULL;
+ EShellContent *shell_content;
+ EMailReader *reader;
+ MessageList *message_list;
+ CamelFolder *folder;
+ GPtrArray *selected;
ESourceList *source_list = NULL;
gboolean done = FALSE;
GSList *groups, *p;
ESource *source = NULL;
GError *error = NULL;
- g_return_if_fail (uids != NULL);
- g_return_if_fail (folder != NULL);
- g_return_if_fail (emfv != NULL);
+ shell_content = e_shell_view_get_shell_content (shell_view);
- if (uids->len > 0) {
- uid_array = g_ptr_array_new ();
- g_ptr_array_foreach (uids, (GFunc)copy_uids, (gpointer) uid_array);
- } else {
- /* nothing selected */
- return;
- }
+ reader = E_MAIL_READER (shell_content);
+ message_list = e_mail_reader_get_message_list (reader);
+ selected = message_list_get_selected (message_list);
+ folder = message_list->folder;
if (!e_cal_get_sources (&source_list, source_type, &error)) {
e_notice (NULL, GTK_MESSAGE_ERROR, _("Cannot get source list. %s"), error ? error->message : _("Unknown error."));
@@ -883,11 +902,11 @@ mail_to_event (ECalSourceType source_type, gboolean with_attendees, GPtrArray *u
data = g_new0 (AsyncData, 1);
data->client = client;
data->folder = folder;
- data->uids = uid_array;
+ data->uids = selected;
data->with_attendees = with_attendees;
- if (uid_array->len == 1)
- data->selected_text = get_selected_text (emfv);
+ if (selected->len == 1)
+ data->selected_text = get_selected_text (reader);
else
data->selected_text = NULL;
@@ -901,72 +920,138 @@ mail_to_event (ECalSourceType source_type, gboolean with_attendees, GPtrArray *u
g_object_unref (source_list);
}
-/* ************************************************************************* */
-
-gint e_plugin_lib_enable (EPluginLib *ep, gint enable);
-void org_gnome_mail_to_event (gpointer ep, EMPopupTargetSelect *t);
-void org_gnome_mail_to_event_menu (EPlugin *ep, EMMenuTargetSelect *t);
-void org_gnome_mail_to_meeting (gpointer ep, EMPopupTargetSelect *t);
-void org_gnome_mail_to_meeting_menu (EPlugin *ep, EMMenuTargetSelect *t);
-void org_gnome_mail_to_task (gpointer ep, EMPopupTargetSelect *t);
-void org_gnome_mail_to_task_menu (EPlugin *ep, EMMenuTargetSelect *t);
-void org_gnome_mail_to_memo (gpointer ep, EMPopupTargetSelect *t);
-void org_gnome_mail_to_memo_menu (EPlugin *ep, EMMenuTargetSelect *t);
-
-gint
-e_plugin_lib_enable (EPluginLib *ep, gint enable)
+static void
+action_mail_convert_to_event_cb (GtkAction *action,
+ EShellView *shell_view)
{
- return 0;
+ mail_to_event (E_CAL_SOURCE_TYPE_EVENT, FALSE, shell_view);
}
-void
-org_gnome_mail_to_event (gpointer ep, EMPopupTargetSelect *t)
+static void
+action_mail_convert_to_meeting_cb (GtkAction *action,
+ EShellView *shell_view)
{
- mail_to_event (E_CAL_SOURCE_TYPE_EVENT, FALSE, t->uids, t->folder, (EMFolderView *) t->target.widget);
+ mail_to_event (E_CAL_SOURCE_TYPE_EVENT, TRUE, shell_view);
}
-void
-org_gnome_mail_to_event_menu (EPlugin *ep, EMMenuTargetSelect *t)
+static void
+action_mail_convert_to_memo_cb (GtkAction *action,
+ EShellView *shell_view)
{
- mail_to_event (E_CAL_SOURCE_TYPE_EVENT, FALSE, t->uids, t->folder, (EMFolderView *) t->target.widget);
+ mail_to_event (E_CAL_SOURCE_TYPE_JOURNAL, FALSE, shell_view);
}
-void
-org_gnome_mail_to_meeting (gpointer ep, EMPopupTargetSelect *t)
+static void
+action_mail_convert_to_task_cb (GtkAction *action,
+ EShellView *shell_view)
{
- mail_to_event (E_CAL_SOURCE_TYPE_EVENT, TRUE, t->uids, t->folder, (EMFolderView *) t->target.widget);
+ mail_to_event (E_CAL_SOURCE_TYPE_TODO, FALSE, shell_view);
}
-void
-org_gnome_mail_to_meeting_menu (EPlugin *ep, EMMenuTargetSelect *t)
-{
- mail_to_event (E_CAL_SOURCE_TYPE_EVENT, TRUE, t->uids, t->folder, (EMFolderView *) t->target.widget);
-}
+static GtkActionEntry entries[] = {
+
+ { "mail-convert-to-event",
+ "appointment-new",
+ N_("Create an _Event"),
+ NULL,
+ N_("Create a new event from the selected message"),
+ G_CALLBACK (action_mail_convert_to_event_cb) },
+
+ { "mail-convert-to-meeting",
+ "stock_new-meeting",
+ N_("Create a _Meeting"),
+ NULL,
+ N_("Create a new meeting from the selected message"),
+ G_CALLBACK (action_mail_convert_to_meeting_cb) },
+
+ { "mail-convert-to-memo",
+ "stock_insert-note",
+ N_("Create a Mem_o"),
+ NULL,
+ N_("Create a new memo from the selected message"),
+ G_CALLBACK (action_mail_convert_to_memo_cb) },
+
+ { "mail-convert-to-task",
+ "stock_todo",
+ N_("Create a _Task"),
+ NULL,
+ N_("Create a new task from the selected message"),
+ G_CALLBACK (action_mail_convert_to_task_cb) }
+};
-void
-org_gnome_mail_to_task (gpointer ep, EMPopupTargetSelect *t)
-{
- /* do not create assigned tasks */
- mail_to_event (E_CAL_SOURCE_TYPE_TODO, FALSE, t->uids, t->folder, (EMFolderView *) t->target.widget);
-}
+static EPopupActionEntry popup_entries[] = {
-void
-org_gnome_mail_to_task_menu (EPlugin *ep, EMMenuTargetSelect *t)
-{
- /* do not create assigned tasks */
- mail_to_event (E_CAL_SOURCE_TYPE_TODO, FALSE, t->uids, t->folder, (EMFolderView *) t->target.widget);
-}
+ { "mail-popup-convert-to-event",
+ NULL,
+ "mail-convert-to-event" },
+
+ { "mail-popup-convert-to-meeting",
+ NULL,
+ "mail-convert-to-meeting" },
-void
-org_gnome_mail_to_memo (gpointer ep, EMPopupTargetSelect *t)
+ { "mail-popup-convert-to-memo",
+ NULL,
+ "mail-convert-to-memo" },
+
+ { "mail-popup-convert-to-task",
+ NULL,
+ "mail-convert-to-task" }
+};
+
+static void
+update_actions_cb (EShellView *shell_view)
{
- /* do not set organizer and attendees for memos */
- mail_to_event (E_CAL_SOURCE_TYPE_JOURNAL, FALSE, t->uids, t->folder, (EMFolderView *) t->target.widget);
+ EShellContent *shell_content;
+ EShellWindow *shell_window;
+ GtkAction *action;
+ gboolean sensitive;
+ guint32 state;
+
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ state = e_mail_reader_check_state (E_MAIL_READER (shell_content));
+
+ sensitive =
+ (state & E_MAIL_READER_SELECTION_SINGLE) ||
+ (state & E_MAIL_READER_SELECTION_MULTIPLE);
+
+ action = E_SHELL_WINDOW_ACTION_CONVERT_TO_EVENT (shell_window);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = E_SHELL_WINDOW_ACTION_CONVERT_TO_MEMO (shell_window);
+ gtk_action_set_sensitive (action, sensitive);
+
+ action = E_SHELL_WINDOW_ACTION_CONVERT_TO_TASK (shell_window);
+ gtk_action_set_sensitive (action, sensitive);
+
+ sensitive = (state & E_MAIL_READER_SELECTION_SINGLE);
+
+ action = E_SHELL_WINDOW_ACTION_CONVERT_TO_MEETING (shell_window);
+ gtk_action_set_sensitive (action, sensitive);
+
}
-void
-org_gnome_mail_to_memo_menu (EPlugin *ep, EMMenuTargetSelect *t)
+gboolean
+e_plugin_ui_init (GtkUIManager *ui_manager,
+ EShellView *shell_view)
{
- /* do not set organizer and attendees for memos */
- mail_to_event (E_CAL_SOURCE_TYPE_JOURNAL, FALSE, t->uids, t->folder, (EMFolderView *) t->target.widget);
+ EShellWindow *shell_window;
+ GtkActionGroup *action_group;
+
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ action_group = e_shell_window_get_action_group (shell_window, "mail");
+
+ gtk_action_group_add_actions (
+ action_group, entries,
+ G_N_ELEMENTS (entries), shell_view);
+ e_action_group_add_popup_actions (
+ action_group, popup_entries,
+ G_N_ELEMENTS (popup_entries));
+
+ g_signal_connect (
+ shell_view, "update-actions",
+ G_CALLBACK (update_actions_cb), NULL);
+
+ return TRUE;
}
diff --git a/plugins/mail-to-task/org-gnome-mail-to-task.eplug.xml b/plugins/mail-to-task/org-gnome-mail-to-task.eplug.xml
index e8494fb2d7..614da8cf3b 100644
--- a/plugins/mail-to-task/org-gnome-mail-to-task.eplug.xml
+++ b/plugins/mail-to-task/org-gnome-mail-to-task.eplug.xml
@@ -1,80 +1,33 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<e-plugin-list>
- <e-plugin
- type="shlib"
- id="org.gnome.evolution.plugin.mailToTask"
- location="@PLUGINDIR@/liborg-gnome-mail-to-task@SOEXT@"
- _name="Mail-to-Task">
- <_description>Convert a mail message to a task.</_description>
+ <e-plugin type="shlib" location="/home/mbarnes/local/lib/evolution/2.28/plugins/liborg-gnome-mail-to-task.so" id="org.gnome.evolution.plugin.mailToTask" name="Mail-to-Task">
<author name="Rodrigo Moya" email="rodrigo@novell.com"/>
+ <_description>Convert a mail message to a task.</_description>
- <!-- hook into the uri popup menu -->
- <hook class="org.gnome.evolution.mail.popup:1.0">
- <menu id="org.gnome.evolution.mail.folderview.popup" target="select">
- <item
- type="item"
- path="70.mail_to_event1"
- icon="appointment-new"
- _label="Create an _Event"
- enable="many"
- visible="many"
- activate="org_gnome_mail_to_event"/>
- <item
- type="item"
- path="70.mail_to_event2"
- icon="stock_new-meeting"
- _label="Create a _Meeting"
- enable="one"
- visible="many"
- activate="org_gnome_mail_to_meeting"/>
- <item
- type="item"
- path="70.mail_to_event3"
- icon="stock_todo"
- _label="Create a _Task"
- enable="many"
- visible="many"
- activate="org_gnome_mail_to_task"/>
- <item
- type="item"
- path="70.mail_to_event4"
- icon="stock_insert-note"
- _label="Create a Mem_o"
- enable="many"
- visible="many"
- activate="org_gnome_mail_to_memo"/>
- </menu>
+ <hook class="org.gnome.evolution.ui:1.0">
+ <ui-manager id="org.gnome.evolution.mail">
+ <menubar name='main-menu'>
+ <placeholder name='custom-menus'>
+ <menu action="mail-message-menu">
+ <placeholder name="mail-message-actions">
+ <menuitem action="mail-convert-to-event"/>
+ <menuitem action="mail-convert-to-meeting"/>
+ <menuitem action="mail-convert-to-task"/>
+ <menuitem action="mail-convert-to-memo"/>
+ </placeholder>
+ </menu>
+ </placeholder>
+ </menubar>
+ <popup name="mail-message-popup">
+ <placeholder name="mail-message-popup-actions">
+ <menuitem action="mail-popup-convert-to-event"/>
+ <menuitem action="mail-popup-convert-to-meeting"/>
+ <menuitem action="mail-popup-convert-to-task"/>
+ <menuitem action="mail-popup-convert-to-memo"/>
+ </placeholder>
+ </popup>
+ </ui-manager>
</hook>
- <hook class="org.gnome.evolution.mail.bonobomenu:1.0">
- <menu id="org.gnome.evolution.mail.browser" target="select">
- <!-- the path to the bonobo menu description -->
- <ui file="@PLUGINDIR@/org-gnome-mail-to-task.xml"/>
- <item
- type="item"
- verb="ConvertEvent"
- path="/commands/ConvertEvent"
- enable="many"
- activate="org_gnome_mail_to_event_menu"/>
- <item
- type="item"
- verb="ConvertMeeting"
- path="/commands/ConvertMeeting"
- enable="one"
- activate="org_gnome_mail_to_meeting_menu"/>
- <item
- type="item"
- verb="ConvertTask"
- path="/commands/ConvertTask"
- enable="many"
- activate="org_gnome_mail_to_task_menu"/>
- <item
- type="item"
- verb="ConvertMemo"
- path="/commands/ConvertMemo"
- enable="many"
- activate="org_gnome_mail_to_memo_menu"/>
- </menu>
- </hook>
-
+
</e-plugin>
</e-plugin-list>
diff --git a/plugins/mail-to-task/org-gnome-mail-to-task.xml b/plugins/mail-to-task/org-gnome-mail-to-task.xml
deleted file mode 100644
index c3d72b6d09..0000000000
--- a/plugins/mail-to-task/org-gnome-mail-to-task.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<Root>
- <commands>
- <cmd name="ConvertEvent" _label="Create an _Event"
- _tip="Create a new event from the selected message"
- pixtype="stock" pixname="appointment-new"/>
- <cmd name="ConvertMeeting" _label="Create a _Meeting"
- _tip="Create a new meeting from the selected message"
- pixtype="stock" pixname="stock_new-meeting"/>
- <cmd name="ConvertTask" _label="Create a _Task"
- _tip="Create a new task from the selected message"
- pixtype="stock" pixname="stock_todo"/>
- <cmd name="ConvertMemo" _label="Create a Mem_o"
- _tip="Create a new memo from the selected message"
- pixtype="stock" pixname="stock_insert-note"/>
- </commands>
-
- <menu>
- <placeholder name="MessagePlaceholder">
- <submenu name="Message">
- <separator f="" name="emaillist5"/>
- <menuitem name="ConvertEvent" verb=""/>
- <menuitem name="ConvertMeeting" verb=""/>
- <menuitem name="ConvertTask" verb=""/>
- <menuitem name="ConvertMemo" verb=""/>
- </submenu>
- </placeholder>
- </menu>
-</Root>