aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--composer/e-composer-actions.c17
-rw-r--r--composer/e-msg-composer.c30
-rw-r--r--composer/e-msg-composer.h2
-rw-r--r--configure.in2
-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
8 files changed, 233 insertions, 142 deletions
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c
index ecf9f179f6..71065d6996 100644
--- a/composer/e-composer-actions.c
+++ b/composer/e-composer-actions.c
@@ -22,7 +22,6 @@
#include <fcntl.h>
#include <e-util/e-error.h>
#include <mail/em-event.h>
-#include <mail/em-format-html-print.h>
#include <mail/em-composer-utils.h>
#include "misc/e-charset-picker.h"
@@ -184,15 +183,9 @@ action_print_cb (GtkAction *action,
EMsgComposer *composer)
{
GtkPrintOperationAction print_action;
- CamelMimeMessage *message;
- EMFormatHTMLPrint *efhp;
print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
- message = e_msg_composer_get_message (composer, 1);
-
- efhp = em_format_html_print_new (NULL, print_action);
- em_format_html_print_raw_message (efhp, message);
- g_object_unref (efhp);
+ e_msg_composer_print (composer, print_action);
}
static void
@@ -200,15 +193,9 @@ action_print_preview_cb (GtkAction *action,
EMsgComposer *composer)
{
GtkPrintOperationAction print_action;
- CamelMimeMessage *message;
- EMFormatHTMLPrint *efhp;
print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW;
- message = e_msg_composer_get_message_print (composer, 1);
-
- efhp = em_format_html_print_new (NULL, print_action);
- em_format_html_print_raw_message (efhp, message);
- g_object_unref (efhp);
+ e_msg_composer_print (composer, print_action);
}
static void
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index dee28d0691..8eb72649ac 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -132,6 +132,7 @@ typedef enum {
enum {
SEND,
SAVE_DRAFT,
+ PRINT,
LAST_SIGNAL
};
@@ -2695,7 +2696,7 @@ msg_composer_class_init (EMsgComposerClass *class)
signals[SEND] = g_signal_new (
"send",
- E_TYPE_MSG_COMPOSER,
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
@@ -2703,11 +2704,20 @@ msg_composer_class_init (EMsgComposerClass *class)
signals[SAVE_DRAFT] = g_signal_new (
"save-draft",
- E_TYPE_MSG_COMPOSER,
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ signals[PRINT] = g_signal_new (
+ "print",
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__ENUM,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_PRINT_OPERATION_ACTION);
}
static void
@@ -3785,6 +3795,22 @@ e_msg_composer_save_draft (EMsgComposer *composer)
e_composer_autosave_set_saved (composer, FALSE);
}
+/**
+ * e_msg_composer_print:
+ * @composer: an #EMsgComposer
+ * @action: the print action to start
+ *
+ * Print the message in @composer.
+ **/
+void
+e_msg_composer_print (EMsgComposer *composer,
+ GtkPrintOperationAction action)
+{
+ g_return_if_fail (E_IS_MSG_COMPOSER (composer));
+
+ g_signal_emit (composer, signals[PRINT], 0, action);
+}
+
static GList *
add_recipients (GList *list, const gchar *recips)
{
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index c37845b5ca..5252f691e4 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -83,6 +83,8 @@ CamelSession * e_msg_composer_get_session (EMsgComposer *composer);
void e_msg_composer_send (EMsgComposer *composer);
void e_msg_composer_save_draft (EMsgComposer *composer);
+void e_msg_composer_print (EMsgComposer *composer,
+ GtkPrintOperationAction action);
void e_msg_composer_set_alternative (EMsgComposer *composer,
gboolean alt);
diff --git a/configure.in b/configure.in
index 5a6b372ec2..8018da60f8 100644
--- a/configure.in
+++ b/configure.in
@@ -1630,7 +1630,7 @@ fi
dnl --- evolution-test flags
-EVO_SET_COMPILE_FLAGS(EVOLUTION_TEST, gtk+-2.0 libxml-2.0)
+EVO_SET_COMPILE_FLAGS(EVOLUTION_TEST, gtk+-2.0 libxml-2.0 unique-1.0)
AC_SUBST(EVOLUTION_TEST_CFLAGS)
AC_SUBST(EVOLUTION_TEST_LIBS)
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);