diff options
author | Peter Williams <peterw@src.gnome.org> | 2000-08-11 01:30:50 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2000-08-11 01:30:50 +0800 |
commit | 8cb514d6dd9497893a35a089d07a132d51263ee7 (patch) | |
tree | 9f4e5d1f929da7e0be900919753d419fe4c9c61a /mail/mail-view.c | |
parent | bcbb63c59f80eb4e684036c5ef58ab141fb01b03 (diff) | |
download | gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.gz gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.bz2 gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.lz gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.xz gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.zst gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.zip |
Merge with camel-async.
svn path=/trunk/; revision=4687
Diffstat (limited to 'mail/mail-view.c')
-rw-r--r-- | mail/mail-view.c | 144 |
1 files changed, 123 insertions, 21 deletions
diff --git a/mail/mail-view.c b/mail/mail-view.c index a98cc4d5ca..6c336a47f8 100644 --- a/mail/mail-view.c +++ b/mail/mail-view.c @@ -20,17 +20,111 @@ * */ -#include <mail.h> -#include <camel.h> +#include <config.h> +#include "mail.h" +#include "mail-ops.h" +#include "camel/camel.h" + +typedef struct mail_view_data_s { + CamelFolder *source; + gchar *uid; + CamelMimeMessage *msg; + MailDisplay *md; +} mail_view_data; + +static void +mail_view_data_free (gpointer mvd) +{ + mail_view_data *data = (mail_view_data *) mvd; + + if (data->uid) + g_free (data->uid); + if (data->msg) + camel_object_unref (CAMEL_OBJECT (data->msg)); + if (data->source) + camel_object_unref (CAMEL_OBJECT (data->source)); + + g_free (data); +} + +static mail_view_data * +mail_view_data_new (CamelFolder *source, const gchar *uid, CamelMimeMessage *msg) +{ + mail_view_data *data; + + data = g_new (mail_view_data, 1); + data->source = source; + camel_object_ref (CAMEL_OBJECT (data->source)); + data->msg = msg; + camel_object_ref (CAMEL_OBJECT (data->msg)); + data->uid = g_strdup (uid); + + return data; +} static void on_close (GtkWidget *menuitem, gpointer user_data) { - GtkWidget *view; - - view = gtk_widget_get_toplevel (menuitem); - - gtk_widget_destroy (view); + GtkWidget *view_window; + + view_window = gtk_object_get_data (GTK_OBJECT (menuitem), "view-window"); + g_return_if_fail (view_window); + gtk_widget_destroy (GTK_WIDGET (view_window)); +} + +static void +view_reply_to_sender (GtkWidget *widget, gpointer user_data) +{ + mail_view_data *data = (mail_view_data *) user_data; + + mail_reply (data->source, data->msg, data->uid, FALSE); +} + +static void +view_reply_to_all (GtkWidget *widget, gpointer user_data) +{ + mail_view_data *data = (mail_view_data *) user_data; + + mail_reply (data->source, data->msg, data->uid, TRUE); +} + +static void +view_forward_msg (GtkWidget *widget, gpointer user_data) +{ + mail_view_data *data = (mail_view_data *) user_data; + + GPtrArray *uids; + EMsgComposer *composer; + + uids = g_ptr_array_new(); + g_ptr_array_add (uids, g_strdup (data->uid)); + + composer = E_MSG_COMPOSER (e_msg_composer_new ()); + gtk_signal_connect (GTK_OBJECT (composer), "send", + GTK_SIGNAL_FUNC (composer_send_cb), NULL); + + mail_do_forward_message (data->msg, data->source, uids, composer); +} + +static void +view_print_msg (GtkWidget *widget, gpointer user_data) +{ + mail_view_data *data = (mail_view_data *) user_data; + + mail_print_msg (data->md); +} + +static void +view_delete_msg (GtkWidget *button, gpointer user_data) +{ + mail_view_data *data = (mail_view_data *) user_data; + + GPtrArray *uids; + + uids = g_ptr_array_new(); + g_ptr_array_add (uids, g_strdup (data->uid)); + mail_do_flag_messages (data->source, uids, TRUE, + CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_DELETED); } static GnomeUIInfo mail_view_toolbar [] = { @@ -39,18 +133,18 @@ static GnomeUIInfo mail_view_toolbar [] = { save_msg, GNOME_STOCK_PIXMAP_SAVE),*/ GNOMEUIINFO_ITEM_STOCK (N_("Reply"), N_("Reply to the sender of this message"), - reply_to_sender, GNOME_STOCK_PIXMAP_MAIL_RPL), + view_reply_to_sender, GNOME_STOCK_PIXMAP_MAIL_RPL), GNOMEUIINFO_ITEM_STOCK (N_("Reply to All"), N_("Reply to all recipients of this message"), - reply_to_all, GNOME_STOCK_PIXMAP_MAIL_RPL), + view_reply_to_all, GNOME_STOCK_PIXMAP_MAIL_RPL), - GNOMEUIINFO_ITEM_STOCK (N_("Forward"), N_("Forward this message"), forward_msg, GNOME_STOCK_PIXMAP_MAIL_FWD), + GNOMEUIINFO_ITEM_STOCK (N_("Forward"), N_("Forward this message"), view_forward_msg, GNOME_STOCK_PIXMAP_MAIL_FWD), GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_STOCK (N_("Print"), N_("Print the selected message"), print_msg, GNOME_STOCK_PIXMAP_PRINT), + GNOMEUIINFO_ITEM_STOCK (N_("Print"), N_("Print the selected message"), view_print_msg, GNOME_STOCK_PIXMAP_PRINT), - GNOMEUIINFO_ITEM_STOCK (N_("Delete"), N_("Delete this message"), delete_msg, GNOME_STOCK_PIXMAP_TRASH), + GNOMEUIINFO_ITEM_STOCK (N_("Delete"), N_("Delete this message"), view_delete_msg, GNOME_STOCK_PIXMAP_TRASH), /*GNOMEUIINFO_SEPARATOR,*/ @@ -82,16 +176,17 @@ static GnomeUIInfo mail_view_menubar[] = }; GtkWidget * -mail_view_create (FolderBrowser *folder_browser) +mail_view_create (CamelFolder *source, const char *uid, CamelMimeMessage *msg) { - CamelMimeMessage *msg; GtkWidget *window; GtkWidget *toolbar; GtkWidget *mail_display; - char *subject; GnomeDockItemBehavior behavior; + char *subject; + mail_view_data *data; + + data = mail_view_data_new (source, uid, msg); - msg = folder_browser->mail_display->current_message; subject = (char *) camel_mime_message_get_subject (msg); if (!subject) subject = ""; @@ -102,26 +197,30 @@ mail_view_create (FolderBrowser *folder_browser) gnome_app_fill_toolbar_with_data (GTK_TOOLBAR (toolbar), mail_view_toolbar, - NULL, folder_browser); + NULL, data); behavior = GNOME_DOCK_ITEM_BEH_NORMAL; if (!gnome_preferences_get_toolbar_detachable ()) behavior |= GNOME_DOCK_ITEM_BEH_LOCKED; - gnome_app_add_toolbar (GNOME_APP (window), + gnome_app_add_toolbar (GNOME_APP (window), GTK_TOOLBAR (toolbar), GNOME_APP_TOOLBAR_NAME, behavior, GNOME_DOCK_TOP, 1, 0, 0); gnome_app_create_menus (GNOME_APP (window), mail_view_menubar); - + + gtk_object_set_data_full (GTK_OBJECT (window), "mvd", data, + mail_view_data_free); + gtk_widget_ref (mail_view_menubar[0].widget); gtk_object_set_data_full (GTK_OBJECT (window), "file", mail_view_menubar[0].widget, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_ref (file_menu[0].widget); + gtk_object_set_data (GTK_OBJECT (file_menu[0].widget), "view-window", window); gtk_object_set_data_full (GTK_OBJECT (window), "close", file_menu[0].widget, (GtkDestroyNotify) gtk_widget_unref); @@ -131,11 +230,14 @@ mail_view_create (FolderBrowser *folder_browser) mail_view_menubar[1].widget, (GtkDestroyNotify) gtk_widget_unref); - mail_display = mail_display_new (folder_browser); + mail_display = mail_display_new (); mail_display_set_message (MAIL_DISPLAY (mail_display), CAMEL_MEDIUM (msg)); gtk_widget_set_usize (mail_display, 600, 600); - + data->md = MAIL_DISPLAY (mail_display); gnome_app_set_contents (GNOME_APP (window), mail_display); return window; } + + + |