aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/groupwise-features/mail-send-options.c92
-rw-r--r--plugins/groupwise-features/org-gnome-groupwise-features.eplug.xml15
2 files changed, 85 insertions, 22 deletions
diff --git a/plugins/groupwise-features/mail-send-options.c b/plugins/groupwise-features/mail-send-options.c
index 3b3e8eb8a7..1db2209f4b 100644
--- a/plugins/groupwise-features/mail-send-options.c
+++ b/plugins/groupwise-features/mail-send-options.c
@@ -36,13 +36,14 @@
#include "mail/em-event.h"
#include "composer/e-msg-composer.h"
+#include "composer/e-composer-from-header.h"
#include "libedataserver/e-account.h"
#include "misc/e-send-options.h"
static ESendOptionsDialog * dialog = NULL;
-void org_gnome_composer_send_options (EPlugin *ep, EMEventTargetComposer *t);
+gboolean gw_ui_composer_actions (GtkUIManager *manager, EMsgComposer *composer);
void org_gnome_composer_message_reply (EPlugin *ep, EMEventTargetMessage *t);
static time_t
@@ -138,37 +139,86 @@ send_options_commit (EMsgComposer *comp, gpointer user_data)
}
}
-void
-org_gnome_composer_send_options (EPlugin *ep, EMEventTargetComposer *t)
+static gboolean
+account_is_groupwise (EAccount *account)
{
+ const gchar *url;
- EMsgComposer *comp = (struct _EMsgComposer *)t->composer;
- EComposerHeaderTable *table;
- EAccount *account = NULL;
- gchar *temp = NULL;
-
- table = e_msg_composer_get_header_table (comp);
- account = e_composer_header_table_get_account (table);
if (!account)
- return;
+ return FALSE;
+
+ url = e_account_get_string (account, E_ACCOUNT_TRANSPORT_URL);
+ return url && g_str_has_prefix (url, "groupwise://");
+}
+
+static void
+from_changed_cb (EComposerFromHeader *header, EMsgComposer *composer)
+{
+ GtkActionGroup *group;
+ GtkAction *action;
+
+ g_return_if_fail (header != NULL);
+ g_return_if_fail (composer != NULL);
+
+ group = gtkhtml_editor_get_action_group (GTKHTML_EDITOR (composer), "composer");
+ g_return_if_fail (group != NULL);
+
+ action = gtk_action_group_get_action (group, "gw-send-options");
+ g_return_if_fail (action != NULL);
+
+ gtk_action_set_visible (action, account_is_groupwise (e_composer_from_header_get_active (header)));
+}
+
+static void
+action_send_options_cb (GtkAction *action, EMsgComposer *composer)
+{
+ g_return_if_fail (action != NULL);
+ g_return_if_fail (composer != NULL);
- temp = strstr (account->transport->url, "groupwise");
- if (!temp) {
- return;
- }
- e_msg_composer_set_send_options (comp, TRUE);
/* display the send options dialog */
if (!dialog) {
- g_print ("New dialog\n\n");
dialog = e_sendoptions_dialog_new ();
}
- e_sendoptions_dialog_run (dialog, GTK_WIDGET (comp), E_ITEM_MAIL);
+
+ e_sendoptions_dialog_run (dialog, GTK_WIDGET (composer), E_ITEM_MAIL);
g_signal_connect (dialog, "sod_response",
- G_CALLBACK (feed_input_data), comp);
+ G_CALLBACK (feed_input_data), composer);
+
+ g_signal_connect (GTK_WIDGET (composer), "destroy",
+ G_CALLBACK (send_options_commit), dialog);
+}
+
+gboolean
+gw_ui_composer_actions (GtkUIManager *manager, EMsgComposer *composer)
+{
+ static GtkActionEntry entries[] = {
+ { "gw-send-options",
+ NULL,
+ N_("_Send Options"),
+ NULL,
+ N_("Insert Send options"),
+ G_CALLBACK (action_send_options_cb) }
+ };
+
+ GtkhtmlEditor *editor;
+ EComposerHeaderTable *headers;
+ EComposerHeader *header;
+
+ editor = GTKHTML_EDITOR (composer);
+
+ /* 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);
+
+ headers = e_msg_composer_get_header_table (composer);
+ header = e_composer_header_table_get_header (headers, E_COMPOSER_HEADER_FROM);
+
+ from_changed_cb (E_COMPOSER_FROM_HEADER (header), composer);
+ g_signal_connect (G_OBJECT (header), "changed", G_CALLBACK (from_changed_cb), composer);
- g_signal_connect (GTK_WIDGET (comp), "destroy",
- G_CALLBACK (send_options_commit), dialog);
+ return TRUE;
}
void
diff --git a/plugins/groupwise-features/org-gnome-groupwise-features.eplug.xml b/plugins/groupwise-features/org-gnome-groupwise-features.eplug.xml
index 7e7c3efdf7..e4e8a9a54f 100644
--- a/plugins/groupwise-features/org-gnome-groupwise-features.eplug.xml
+++ b/plugins/groupwise-features/org-gnome-groupwise-features.eplug.xml
@@ -72,9 +72,22 @@
</ui-manager>
</hook>
+ <hook class="org.gnome.evolution.ui:1.0">
+ <ui-manager id="org.gnome.evolution.composer" callback="gw_ui_composer_actions">
+ <menubar name="main-menu">
+ <menu action="insert-menu">
+ <placeholder name="insert-menu-top">
+ <placeholder name="send-options">
+ <menuitem action="gw-send-options"/>
+ </placeholder>
+ </placeholder>
+ </menu>
+ </menubar>
+ </ui-manager>
+ </hook>
+
<hook class="org.gnome.evolution.mail.events:1.0">
<event target="message" id="message.reading" type="pass" handle="org_gnome_popup_wizard"/>
- <event id="composer.selectsendoption" handle="org_gnome_composer_send_options" target="composer" enable="sendoption"/>
<event id="message.replying" handle="org_gnome_composer_message_reply" target="message" enable="reply"/>
</hook>