aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-02-01 02:02:22 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-02-01 02:02:22 +0800
commitcd5ff486fb02451645f8b4b39608edca2da5e4a2 (patch)
tree5aff2bff0e48bc3333ff1fc3fdb619c4c34fdbd2 /mail
parent70fce0bbb0712dc70a15c481c0b65d68a98a4ff7 (diff)
downloadgsoc2013-evolution-cd5ff486fb02451645f8b4b39608edca2da5e4a2.tar.gz
gsoc2013-evolution-cd5ff486fb02451645f8b4b39608edca2da5e4a2.tar.zst
gsoc2013-evolution-cd5ff486fb02451645f8b4b39608edca2da5e4a2.zip
Let the mailer handle composer printing.
Start roughing in the mailer search bar. svn path=/branches/kill-bonobo/; revision=37199
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-shell-view-actions.c46
-rw-r--r--mail/e-mail-shell-view-private.c253
-rw-r--r--mail/e-mail-shell-view-private.h6
-rw-r--r--mail/em-composer-utils.c19
4 files changed, 200 insertions, 124 deletions
diff --git a/mail/e-mail-shell-view-actions.c b/mail/e-mail-shell-view-actions.c
index 3c3cae101c..a4c2dfab1c 100644
--- a/mail/e-mail-shell-view-actions.c
+++ b/mail/e-mail-shell-view-actions.c
@@ -522,6 +522,14 @@ action_mail_view_cb (GtkRadioAction *action,
mail_shell_content, vertical_view);
}
+static void
+action_search_filter_cb (GtkRadioAction *action,
+ GtkRadioAction *current,
+ EMailShellView *mail_shell_view)
+{
+ e_mail_shell_view_execute_search (mail_shell_view);
+}
+
static GtkActionEntry mail_entries[] = {
{ "mail-account-disable",
@@ -1078,3 +1086,41 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
dst_object = G_OBJECT (ACTION (MAIL_THREADS_EXPAND_ALL));
e_binding_new (src_object, "active", dst_object, "sensitive");
}
+
+void
+e_mail_shell_view_update_search_filter (EMailShellView *mail_shell_view)
+{
+ EShellContent *shell_content;
+ EShellWindow *shell_window;
+ EShellView *shell_view;
+ GtkActionGroup *action_group;
+ GtkRadioAction *radio_action;
+ GList *list, *iter;
+ GSList *group;
+
+ shell_view = E_SHELL_VIEW (mail_shell_view);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ action_group = ACTION_GROUP (MAIL_FILTER);
+ e_action_group_remove_all_actions (action_group);
+
+ /* Add the standard filter actions. */
+ gtk_action_group_add_radio_actions (
+ action_group, mail_filter_entries,
+ G_N_ELEMENTS (mail_filter_entries),
+ MAIL_FILTER_ALL_MESSAGES,
+ G_CALLBACK (action_search_filter_cb),
+ mail_shell_view);
+
+ /* Retrieve the radio group from an action we just added. */
+ list = gtk_action_group_list_actions (action_group);
+ radio_action = GTK_RADIO_ACTION (list->data);
+ group = gtk_radio_action_get_group (radio_action);
+ g_list_free (list);
+
+ /* FIXME Build the label actions. */
+
+ /* User any action in the group; doesn't matter which. */
+ e_shell_content_set_filter_action (shell_content, radio_action);
+}
diff --git a/mail/e-mail-shell-view-private.c b/mail/e-mail-shell-view-private.c
index b9fe7ab4fd..4ad0d68e59 100644
--- a/mail/e-mail-shell-view-private.c
+++ b/mail/e-mail-shell-view-private.c
@@ -209,6 +209,7 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
mail_shell_view);
e_mail_shell_view_actions_init (mail_shell_view);
+ e_mail_shell_view_update_search_filter (mail_shell_view);
e_mail_reader_init (reader);
/* Restore the previously selected folder. */
@@ -245,6 +246,135 @@ e_mail_shell_view_private_finalize (EMailShellView *mail_shell_view)
}
void
+e_mail_shell_view_execute_search (EMailShellView *mail_shell_view)
+{
+ /* FIXME */
+}
+
+/* Helper for e_mail_shell_view_create_filter_from_selected() */
+static void
+mail_shell_view_create_filter_cb (CamelFolder *folder,
+ const gchar *uid,
+ CamelMimeMessage *message,
+ gpointer user_data)
+{
+ struct {
+ const gchar *source;
+ gint type;
+ } *filter_data = user_data;
+
+ if (message != NULL)
+ filter_gui_add_from_message (
+ message, filter_data->source, filter_data->type);
+
+ g_free (filter_data);
+}
+
+void
+e_mail_shell_view_create_filter_from_selected (EMailShellView *mail_shell_view,
+ gint filter_type)
+{
+ EMailReader *reader;
+ MessageList *message_list;
+ CamelFolder *folder;
+ const gchar *filter_source;
+ const gchar *folder_uri;
+ GPtrArray *uids;
+
+ struct {
+ const gchar *source;
+ gint type;
+ } *filter_data;
+
+ g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view));
+
+ reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
+ message_list = e_mail_reader_get_message_list (reader);
+ folder_uri = message_list->folder_uri;
+ folder = message_list->folder;
+
+ if (em_utils_folder_is_sent (folder, folder_uri))
+ filter_source = FILTER_SOURCE_OUTGOING;
+ else if (em_utils_folder_is_outbox (folder, folder_uri))
+ filter_source = FILTER_SOURCE_OUTGOING;
+ else
+ filter_source = FILTER_SOURCE_INCOMING;
+
+ uids = message_list_get_selected (message_list);
+
+ if (uids->len == 1) {
+ filter_data = g_malloc (sizeof (*filter_data));
+ filter_data->source = filter_source;
+ filter_data->type = filter_type;
+
+ mail_get_message (
+ folder, uids->pdata[0],
+ mail_shell_view_create_filter_cb,
+ filter_data, mail_msg_unordered_push);
+ }
+
+ em_utils_uids_free (uids);
+}
+
+/* Helper for e_mail_shell_view_create_vfolder_from_selected() */
+static void
+mail_shell_view_create_vfolder_cb (CamelFolder *folder,
+ const gchar *uid,
+ CamelMimeMessage *message,
+ gpointer user_data)
+{
+ struct {
+ gchar *uri;
+ gint type;
+ } *vfolder_data = user_data;
+
+ if (message != NULL)
+ vfolder_gui_add_from_message (
+ message, vfolder_data->type, vfolder_data->uri);
+
+ g_free (vfolder_data->uri);
+ g_free (vfolder_data);
+}
+
+void
+e_mail_shell_view_create_vfolder_from_selected (EMailShellView *mail_shell_view,
+ gint vfolder_type)
+{
+ EMailReader *reader;
+ MessageList *message_list;
+ CamelFolder *folder;
+ const gchar *folder_uri;
+ GPtrArray *uids;
+
+ struct {
+ gchar *uri;
+ gint type;
+ } *vfolder_data;
+
+ g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view));
+
+ reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
+ message_list = e_mail_reader_get_message_list (reader);
+ folder_uri = message_list->folder_uri;
+ folder = message_list->folder;
+
+ uids = message_list_get_selected (message_list);
+
+ if (uids->len == 1) {
+ vfolder_data = g_malloc (sizeof (*vfolder_data));
+ vfolder_data->uri = g_strdup (folder_uri);
+ vfolder_data->type = vfolder_type;
+
+ mail_get_message (
+ folder, uids->pdata[0],
+ mail_shell_view_create_vfolder_cb,
+ vfolder_data, mail_msg_unordered_push);
+ }
+
+ em_utils_uids_free (uids);
+}
+
+void
e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
{
EShellSidebar *shell_sidebar;
@@ -395,126 +525,3 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
camel_object_free (folder, CAMEL_FOLDER_NAME, folder_name);
g_string_free (buffer, TRUE);
}
-
-/* Helper for e_mail_shell_view_create_filter_from_selected() */
-static void
-mail_shell_view_create_filter_cb (CamelFolder *folder,
- const gchar *uid,
- CamelMimeMessage *message,
- gpointer user_data)
-{
- struct {
- const gchar *source;
- gint type;
- } *filter_data = user_data;
-
- if (message != NULL)
- filter_gui_add_from_message (
- message, filter_data->source, filter_data->type);
-
- g_free (filter_data);
-}
-
-void
-e_mail_shell_view_create_filter_from_selected (EMailShellView *mail_shell_view,
- gint filter_type)
-{
- EMailReader *reader;
- MessageList *message_list;
- CamelFolder *folder;
- const gchar *filter_source;
- const gchar *folder_uri;
- GPtrArray *uids;
-
- struct {
- const gchar *source;
- gint type;
- } *filter_data;
-
- g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view));
-
- reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
- message_list = e_mail_reader_get_message_list (reader);
- folder_uri = message_list->folder_uri;
- folder = message_list->folder;
-
- if (em_utils_folder_is_sent (folder, folder_uri))
- filter_source = FILTER_SOURCE_OUTGOING;
- else if (em_utils_folder_is_outbox (folder, folder_uri))
- filter_source = FILTER_SOURCE_OUTGOING;
- else
- filter_source = FILTER_SOURCE_INCOMING;
-
- uids = message_list_get_selected (message_list);
-
- if (uids->len == 1) {
- filter_data = g_malloc (sizeof (*filter_data));
- filter_data->source = filter_source;
- filter_data->type = filter_type;
-
- mail_get_message (
- folder, uids->pdata[0],
- mail_shell_view_create_filter_cb,
- filter_data, mail_msg_unordered_push);
- }
-
- em_utils_uids_free (uids);
-}
-
-/* Helper for e_mail_shell_view_create_vfolder_from_selected() */
-static void
-mail_shell_view_create_vfolder_cb (CamelFolder *folder,
- const gchar *uid,
- CamelMimeMessage *message,
- gpointer user_data)
-{
- struct {
- gchar *uri;
- gint type;
- } *vfolder_data = user_data;
-
- if (message != NULL)
- vfolder_gui_add_from_message (
- message, vfolder_data->type, vfolder_data->uri);
-
- g_free (vfolder_data->uri);
- g_free (vfolder_data);
-}
-
-void
-e_mail_shell_view_create_vfolder_from_selected (EMailShellView *mail_shell_view,
- gint vfolder_type)
-{
- EMailReader *reader;
- MessageList *message_list;
- CamelFolder *folder;
- const gchar *folder_uri;
- GPtrArray *uids;
-
- struct {
- gchar *uri;
- gint type;
- } *vfolder_data;
-
- g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view));
-
- reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
- message_list = e_mail_reader_get_message_list (reader);
- folder_uri = message_list->folder_uri;
- folder = message_list->folder;
-
- uids = message_list_get_selected (message_list);
-
- if (uids->len == 1) {
- vfolder_data = g_malloc (sizeof (*vfolder_data));
- vfolder_data->uri = g_strdup (folder_uri);
- vfolder_data->type = vfolder_type;
-
- mail_get_message (
- folder, uids->pdata[0],
- mail_shell_view_create_vfolder_cb,
- vfolder_data, mail_msg_unordered_push);
- }
-
- em_utils_uids_free (uids);
-}
diff --git a/mail/e-mail-shell-view-private.h b/mail/e-mail-shell-view-private.h
index 87c300213b..20094ed379 100644
--- a/mail/e-mail-shell-view-private.h
+++ b/mail/e-mail-shell-view-private.h
@@ -137,7 +137,7 @@ void e_mail_shell_view_private_finalize
void e_mail_shell_view_actions_init
(EMailShellView *mail_shell_view);
-void e_mail_shell_view_update_sidebar
+void e_mail_shell_view_execute_search
(EMailShellView *mail_shell_view);
void e_mail_shell_view_create_filter_from_selected
(EMailShellView *mail_shell_view,
@@ -145,6 +145,10 @@ void e_mail_shell_view_create_filter_from_selected
void e_mail_shell_view_create_vfolder_from_selected
(EMailShellView *mail_shell_view,
gint vfolder_type);
+void e_mail_shell_view_update_sidebar
+ (EMailShellView *mail_shell_view);
+void e_mail_shell_view_update_search_filter
+ (EMailShellView *mail_shell_view);
G_END_DECLS
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 205a894d37..065cd325df 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -46,6 +46,7 @@
#include "composer/e-msg-composer.h"
#include "composer/e-composer-autosave.h"
#include "em-format-html.h"
+#include "em-format-html-print.h"
#include "em-format-quote.h"
#include "em-event.h"
@@ -642,6 +643,20 @@ em_utils_composer_save_draft_cb (EMsgComposer *composer)
camel_object_unref (msg);
}
+static void
+em_utils_composer_print_cb (EMsgComposer *composer,
+ GtkPrintOperationAction action)
+{
+ CamelMimeMessage *message;
+ EMFormatHTMLPrint *efhp;
+
+ message = e_msg_composer_get_message_print (composer, 1);
+
+ efhp = em_format_html_print_new (NULL, action);
+ em_format_html_print_raw_message (efhp, message);
+ g_object_unref (efhp);
+}
+
/* Composing messages... */
static EMsgComposer *
@@ -2542,6 +2557,10 @@ em_configure_new_composer (EMsgComposer *composer)
composer, "save-draft",
G_CALLBACK (em_utils_composer_save_draft_cb), NULL);
+ g_signal_connect (
+ composer, "print",
+ G_CALLBACK (em_utils_composer_print_cb), NULL);
+
/* Supply the composer with a folder tree model. */
table = e_msg_composer_get_header_table (composer);
model = e_mail_shell_module_get_folder_tree_model (mail_shell_module);