aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/groupwise-features/mail-send-options.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-10-14 00:50:20 +0800
committerMilan Crha <mcrha@redhat.com>2009-10-14 00:50:20 +0800
commit51f9daed7077c6b7f616c92ee86459a02f63bc16 (patch)
treefc90f9fc414920475768bec8ed2b973a8456a0bf /plugins/groupwise-features/mail-send-options.c
parent2efaad9c77b988b9d64256ff65976b2b5fe255cb (diff)
downloadgsoc2013-evolution-51f9daed7077c6b7f616c92ee86459a02f63bc16.tar.gz
gsoc2013-evolution-51f9daed7077c6b7f616c92ee86459a02f63bc16.tar.zst
gsoc2013-evolution-51f9daed7077c6b7f616c92ee86459a02f63bc16.zip
Bug #597123 - Composer's Send Options doesn't work
Diffstat (limited to 'plugins/groupwise-features/mail-send-options.c')
-rw-r--r--plugins/groupwise-features/mail-send-options.c92
1 files changed, 71 insertions, 21 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