aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-05-24 04:22:42 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-05-24 04:22:42 +0800
commit18b4f29daa6f95a318bd5f29aec15448fa2039f2 (patch)
treee57b65793d485ce4e22fab0f65123d1aba1f4b8c /mail
parent2aef04318ccca705321efd7340b0275a6537ac70 (diff)
downloadgsoc2013-evolution-18b4f29daa6f95a318bd5f29aec15448fa2039f2.tar
gsoc2013-evolution-18b4f29daa6f95a318bd5f29aec15448fa2039f2.tar.gz
gsoc2013-evolution-18b4f29daa6f95a318bd5f29aec15448fa2039f2.tar.bz2
gsoc2013-evolution-18b4f29daa6f95a318bd5f29aec15448fa2039f2.tar.lz
gsoc2013-evolution-18b4f29daa6f95a318bd5f29aec15448fa2039f2.tar.xz
gsoc2013-evolution-18b4f29daa6f95a318bd5f29aec15448fa2039f2.tar.zst
gsoc2013-evolution-18b4f29daa6f95a318bd5f29aec15448fa2039f2.zip
If the folder-browser has a parent, reparent it.
2002-05-23 Jeffrey Stedfast <fejj@ximian.com> * folder-browser-window.c (folder_browser_window_new): If the folder-browser has a parent, reparent it. * message-browser.[c,h]: Revert back to the old broken implementation since that's what users want. They're not happy unless it's broken. svn path=/trunk/; revision=16989
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog9
-rw-r--r--mail/folder-browser-window.c28
-rw-r--r--mail/folder-browser-window.h1
-rw-r--r--mail/mail-callbacks.c3
-rw-r--r--mail/message-browser.c294
-rw-r--r--mail/message-browser.h19
6 files changed, 316 insertions, 38 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index b50f207c4e..d32be58325 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,12 @@
+2002-05-23 Jeffrey Stedfast <fejj@ximian.com>
+
+ * folder-browser-window.c (folder_browser_window_new): If the
+ folder-browser has a parent, reparent it.
+
+ * message-browser.[c,h]: Revert back to the old broken
+ implementation since that's what users want. They're not happy
+ unless it's broken.
+
2002-05-23 Radek Doulik <rodo@ximian.com>
* mail-composer-prefs.c: be more careful about language_str{_orig}
diff --git a/mail/folder-browser-window.c b/mail/folder-browser-window.c
index e87a745811..0f8132454a 100644
--- a/mail/folder-browser-window.c
+++ b/mail/folder-browser-window.c
@@ -77,6 +77,23 @@ folder_browser_window_init (GtkObject *object)
}
+static gboolean
+destroy_cb (GtkWidget *widget)
+{
+ FolderBrowserWindow *fbw = (FolderBrowserWindow *) widget;
+ FolderBrowser *fb = fbw->folder_browser;
+
+ if (fbw->fb_parent) {
+ gtk_widget_ref (GTK_WIDGET (fb));
+ gtk_widget_unparent (GTK_WIDGET (fb));
+ gtk_container_add (GTK_CONTAINER (fbw->fb_parent), GTK_WIDGET (fb));
+ gtk_widget_unref (GTK_WIDGET (fb));
+ fbw->folder_browser = NULL;
+ }
+
+ return FALSE;
+}
+
static void
folder_browser_window_size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation)
{
@@ -111,7 +128,18 @@ folder_browser_window_new (FolderBrowser *fb)
set_default_size (GTK_WIDGET (new));
new->folder_browser = fb;
+ gtk_widget_ref (GTK_WIDGET (fb));
+ if (GTK_WIDGET (fb)->parent) {
+ new->fb_parent = GTK_WIDGET (fb)->parent;
+ gtk_widget_unparent (GTK_WIDGET (fb));
+
+ gtk_signal_connect (GTK_OBJECT (new), "delete_event",
+ destroy_cb, new);
+ }
+
+ new->folder_browser = fb;
bonobo_window_set_contents (BONOBO_WINDOW (new), GTK_WIDGET (fb));
+ gtk_widget_unref (GTK_WIDGET (fb));
uicont = bonobo_ui_container_new ();
bonobo_ui_container_set_win (uicont, BONOBO_WINDOW (new));
diff --git a/mail/folder-browser-window.h b/mail/folder-browser-window.h
index fdd9b1315b..ee00be2236 100644
--- a/mail/folder-browser-window.h
+++ b/mail/folder-browser-window.h
@@ -45,6 +45,7 @@ typedef struct _FolderBrowserWindow FolderBrowserWindow;
struct _FolderBrowserWindow {
BonoboWindow parent;
+ GtkWidget *fb_parent;
FolderBrowser *folder_browser;
};
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index ec84ceec06..21c6aea978 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -24,6 +24,7 @@
* USA
*/
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -3118,7 +3119,7 @@ do_view_message (CamelFolder *folder, char *uid, CamelMimeMessage *message, void
GtkWidget *mb;
camel_folder_set_message_flags (folder, uid, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
- mb = message_browser_new (message);
+ mb = folder_browser_window_new (fb);
gtk_widget_show (mb);
}
}
diff --git a/mail/message-browser.c b/mail/message-browser.c
index 4e42bdd35c..ae318f1869 100644
--- a/mail/message-browser.c
+++ b/mail/message-browser.c
@@ -27,30 +27,58 @@
#include <gal/util/e-util.h>
#include <gal/widgets/e-unicode.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-ui-component.h>
+#include <bonobo/bonobo-ui-container.h>
+#include <bonobo/bonobo-ui-util.h>
+
#include "message-browser.h"
-#include "mail-display.h"
+#include "mail.h"
+#include "mail-callbacks.h"
+#include "mail-tools.h"
+#include "message-list.h"
+#include "mail-ops.h"
+#include "mail-vfolder.h"
+#include "mail-autofilter.h"
+#include "mail-mt.h"
#include "mail-local.h"
#include "mail-config.h"
+#include "folder-browser-ui.h"
+
#define d(x)
#define MINIMUM_WIDTH 600
#define MINIMUM_HEIGHT 400
-#define PARENT_TYPE GTK_TYPE_WINDOW
+#define PARENT_TYPE BONOBO_TYPE_WINDOW
/* Size of the window last time it was changed. */
static GtkAllocation last_allocation = { 0, 0 };
-static GtkWindowClass *parent_class = NULL;
+static BonoboWindowClass *message_browser_parent_class;
+static void
+message_browser_destroy (GtkObject *object)
+{
+ MessageBrowser *message_browser;
+
+ message_browser = MESSAGE_BROWSER (object);
+
+ gtk_object_unref (GTK_OBJECT (message_browser->fb));
+
+ if (GTK_OBJECT_CLASS (message_browser_parent_class)->destroy)
+ (GTK_OBJECT_CLASS (message_browser_parent_class)->destroy) (object);
+}
static void
message_browser_class_init (GtkObjectClass *object_class)
{
- parent_class = gtk_type_class (PARENT_TYPE);
+ object_class->destroy = message_browser_destroy;
+
+ message_browser_parent_class = gtk_type_class (PARENT_TYPE);
}
static void
@@ -59,35 +87,161 @@ message_browser_init (GtkObject *object)
}
-GtkType
-message_browser_get_type (void)
+static void
+transfer_msg_done (gboolean ok, void *data)
{
- static GtkType type = 0;
-
- if (!type) {
- GtkTypeInfo type_info = {
- "MessageBrowser",
- sizeof (MessageBrowser),
- sizeof (MessageBrowserClass),
- (GtkClassInitFunc) message_browser_class_init,
- (GtkObjectInitFunc) message_browser_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
+ MessageBrowser *mb = data;
+ int row;
+
+ if (ok && !GTK_OBJECT_DESTROYED (mb)) {
+ row = e_tree_row_of_node (mb->fb->message_list->tree,
+ e_tree_get_cursor (mb->fb->message_list->tree));
- type = gtk_type_unique (gtk_window_get_type (), &type_info);
+ /* If this is the last message and deleted messages
+ are hidden, select the previous */
+ if ((row + 1 == e_tree_row_count (mb->fb->message_list->tree))
+ && mail_config_get_hide_deleted ())
+ message_list_select (mb->fb->message_list, MESSAGE_LIST_SELECT_PREVIOUS,
+ 0, CAMEL_MESSAGE_DELETED, FALSE);
+ else
+ message_list_select (mb->fb->message_list, MESSAGE_LIST_SELECT_NEXT,
+ 0, 0, FALSE);
+ }
+
+ gtk_object_unref (GTK_OBJECT (mb));
+}
+
+static void
+transfer_msg (MessageBrowser *mb, int del)
+{
+ const char *allowed_types[] = { "mail", "vtrash", NULL };
+ extern EvolutionShellClient *global_shell_client;
+ GNOME_Evolution_Folder *folder;
+ static char *last_uri = NULL;
+ GPtrArray *uids;
+ char *desc;
+
+ if (GTK_OBJECT_DESTROYED(mb))
+ return;
+
+ if (last_uri == NULL)
+ last_uri = g_strdup ("");
+
+ if (del)
+ desc = _("Move message(s) to");
+ else
+ desc = _("Copy message(s) to");
+
+ evolution_shell_client_user_select_folder (global_shell_client,
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (mb))),
+ desc, last_uri, allowed_types, &folder);
+ if (!folder)
+ return;
+
+ if (strcmp (last_uri, folder->evolutionUri) != 0) {
+ g_free (last_uri);
+ last_uri = g_strdup (folder->evolutionUri);
}
- return type;
+ uids = g_ptr_array_new ();
+ message_list_foreach (mb->fb->message_list, enumerate_msg, uids);
+
+ if (del) {
+ gtk_object_ref (GTK_OBJECT (mb));
+ mail_transfer_messages (mb->fb->folder, uids, del,
+ folder->physicalUri, 0, transfer_msg_done, mb);
+ } else {
+ mail_transfer_messages (mb->fb->folder, uids, del,
+ folder->physicalUri, 0, NULL, NULL);
+ }
+
+ CORBA_free (folder);
+}
+
+
+/* UI callbacks */
+
+static void
+message_browser_close (BonoboUIComponent *uih, void *user_data, const char *path)
+{
+ gtk_widget_destroy (GTK_WIDGET (user_data));
+}
+
+static void
+message_browser_move (BonoboUIComponent *uih, void *user_data, const char *path)
+{
+ transfer_msg(user_data, TRUE);
+}
+
+static void
+message_browser_copy (BonoboUIComponent *uih, void *user_data, const char *path)
+{
+ transfer_msg(user_data, FALSE);
}
+static BonoboUIVerb
+browser_verbs [] = {
+ BONOBO_UI_UNSAFE_VERB ("MessageBrowserClose", message_browser_close),
+ BONOBO_UI_UNSAFE_VERB ("MessageMove", message_browser_move),
+ BONOBO_UI_UNSAFE_VERB ("MessageCopy", message_browser_copy),
+ BONOBO_UI_VERB_END
+};
+
+/* FB message loading hookups */
static void
-message_browser_size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation)
+message_browser_message_loaded (FolderBrowser *fb, const char *uid, MessageBrowser *mb)
+{
+ CamelMimeMessage *message;
+ char *subject = NULL;
+ char *title;
+
+ folder_browser_ui_message_loaded(fb);
+
+ message = fb->mail_display->current_message;
+
+ if (message)
+ subject = (char *) camel_mime_message_get_subject (message);
+
+ if (subject != NULL)
+ subject = e_utf8_to_gtk_string (GTK_WIDGET (mb), subject);
+ else
+ subject = g_strdup (_("(No subject)"));
+
+ title = g_strdup_printf (_("%s - Message"), subject);
+ g_free (subject);
+
+ gtk_window_set_title (GTK_WINDOW (mb), title);
+
+ g_free (title);
+}
+
+static void
+message_browser_message_list_built (MessageList *ml, MessageBrowser *mb)
+{
+ const char *uid = gtk_object_get_data (GTK_OBJECT (mb), "uid");
+
+ gtk_signal_disconnect_by_func (GTK_OBJECT (ml), message_browser_message_list_built, mb);
+
+ message_list_select_uid (ml, uid);
+}
+
+static void
+message_browser_folder_loaded (FolderBrowser *fb, const char *uri, MessageBrowser *mb)
+{
+ gtk_signal_connect (GTK_OBJECT (fb->message_list), "message_list_built",
+ message_browser_message_list_built, mb);
+}
+
+static void
+message_browser_size_allocate_cb (GtkWidget *widget,
+ GtkAllocation *allocation)
{
last_allocation = *allocation;
}
+/* Construction */
+
static void
set_default_size (GtkWidget *widget)
{
@@ -99,22 +253,102 @@ set_default_size (GtkWidget *widget)
gtk_window_set_default_size (GTK_WINDOW (widget), width, height);
}
+static void
+set_bonobo_ui (GtkWidget *widget, FolderBrowser *fb)
+{
+ BonoboUIContainer *uicont;
+ BonoboUIComponent *uic;
+ CORBA_Environment ev;
+
+ uicont = bonobo_ui_container_new ();
+ bonobo_ui_container_set_win (uicont, BONOBO_WINDOW (widget));
+
+ uic = bonobo_ui_component_new_default ();
+ bonobo_ui_component_set_container (uic, BONOBO_OBJREF (uicont));
+ folder_browser_set_ui_component (fb, uic);
+
+ /* Load our UI */
+
+ /*bonobo_ui_component_freeze (uic, NULL);*/
+ bonobo_ui_util_set_ui (uic, EVOLUTION_DATADIR, "evolution-mail-messagedisplay.xml", "evolution-mail");
+
+ /* Load the appropriate UI stuff from the folder browser */
+
+ folder_browser_ui_add_message (fb);
+
+ /* We just opened the message! We don't need to open it again. */
+
+ CORBA_exception_init (&ev);
+ bonobo_ui_component_rm (uic, "/menu/File/FileOps/MessageOpen", &ev);
+ if (BONOBO_EX (&ev))
+ g_warning ("Couldn't remove message open item. Weird. Error: %s",
+ bonobo_exception_get_text (&ev));
+ CORBA_exception_free (&ev);
+
+ /* Hack around the move/copy commands api's */
+ bonobo_ui_component_remove_listener (uic, "MessageCopy");
+ bonobo_ui_component_remove_listener (uic, "MessageMove");
+
+ /* Add the Close & Move/Copy items */
+
+ bonobo_ui_component_add_verb_list_with_data (uic, browser_verbs, widget);
+
+ /* Done */
+
+ /*bonobo_ui_component_thaw (uic, NULL);*/
+}
+
GtkWidget *
-message_browser_new (CamelMimeMessage *message)
+message_browser_new (const GNOME_Evolution_Shell shell, const char *uri, const char *uid)
{
- GtkWidget *new, *mail_display;
+ GtkWidget *vbox;
+ MessageBrowser *new;
+ FolderBrowser *fb;
+
+ new = gtk_type_new (MESSAGE_BROWSER_TYPE);
+ new = (MessageBrowser *) bonobo_window_construct (BONOBO_WINDOW (new), "Ximian Evolution", "");
+ if (!new) {
+ g_warning ("Failed to construct Bonobo window!");
+ return NULL;
+ }
+
+ gtk_object_set_data_full (GTK_OBJECT (new), "uid", g_strdup (uid), g_free);
+
+ fb = FOLDER_BROWSER (folder_browser_new (shell, uri));
+ new->fb = fb;
+
+ set_bonobo_ui (GTK_WIDGET (new), fb);
+
+ /* some evil hackery action... */
+ vbox = gtk_vbox_new (TRUE, 0);
+ gtk_widget_ref (GTK_WIDGET (fb->mail_display));
+ gtk_widget_reparent (GTK_WIDGET (fb->mail_display), vbox);
+ /* Note: normally we'd unref the fb->mail_display now, except
+ that if we do then our refcounts will not be in
+ harmony... both the fb *and* the message-browser need to
+ own a ref on the mail_display. */
+ gtk_widget_show (GTK_WIDGET (fb->mail_display));
+ gtk_widget_show (vbox);
- new = gtk_widget_new (message_browser_get_type (), NULL);
gtk_signal_connect (GTK_OBJECT (new), "size_allocate",
GTK_SIGNAL_FUNC (message_browser_size_allocate_cb), NULL);
- mail_display = mail_display_new ();
- gtk_container_add (GTK_CONTAINER (new), mail_display);
- gtk_widget_show (mail_display);
+ bonobo_window_set_contents (BONOBO_WINDOW (new), vbox);
+ gtk_widget_grab_focus (GTK_WIDGET (MAIL_DISPLAY (fb->mail_display)->html));
+
+ set_default_size (GTK_WIDGET (new));
- mail_display_set_message (MAIL_DISPLAY (mail_display), CAMEL_MEDIUM (message), NULL);
+ /* more evil hackery... */
+ gtk_signal_connect (GTK_OBJECT (fb), "folder_loaded",
+ message_browser_folder_loaded, new);
- set_default_size (new);
+ gtk_signal_connect (GTK_OBJECT (fb), "message_loaded",
+ message_browser_message_loaded, new);
- return new;
+ return GTK_WIDGET (new);
}
+
+/* Fin */
+
+E_MAKE_TYPE (message_browser, "MessageBrowser", MessageBrowser, message_browser_class_init,
+ message_browser_init, PARENT_TYPE);
diff --git a/mail/message-browser.h b/mail/message-browser.h
index ddc9f55292..d9a54b0900 100644
--- a/mail/message-browser.h
+++ b/mail/message-browser.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef __MESSAGE_BROWSER_H__
-#define __MESSAGE_BROWSER_H__
+#ifndef _MESSAGE_BROWSER_H_
+#define _MESSAGE_BROWSER_H_
#include <gnome.h>
#include <bonobo/bonobo-win.h>
@@ -38,19 +38,24 @@
#define IS_MESSAGE_BROWSER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), MESSAGE_BROWSER_TYPE))
struct _MessageBrowser {
- GtkWindow parent;
+ BonoboWindow parent;
+ /*
+ * The current URI being displayed by the MessageBrowser
+ */
+ FolderBrowser *fb;
};
typedef struct {
- GtkWindowClass parent_class;
+ BonoboWindowClass parent_class;
} MessageBrowserClass;
-GtkType message_browser_get_type (void);
+GtkType message_browser_get_type (void);
-GtkWidget *message_browser_new (CamelMimeMessage *message);
+GtkWidget *message_browser_new (const GNOME_Evolution_Shell shell,
+ const char *uri, const char *uid);
-#endif /* __MESSAGE_BROWSER_H__ */
+#endif /* _MESSAGE_BROWSER_H_ */