diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 11 | ||||
-rw-r--r-- | mail/Makefile.am | 2 | ||||
-rw-r--r-- | mail/folder-browser-window.c | 107 | ||||
-rw-r--r-- | mail/folder-browser-window.h | 64 | ||||
-rw-r--r-- | mail/folder-browser.c | 28 | ||||
-rw-r--r-- | mail/folder-browser.h | 2 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 60 | ||||
-rw-r--r-- | mail/mail-callbacks.h | 1 |
8 files changed, 270 insertions, 5 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 5caa25df2b..315d25ba04 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,14 @@ +2002-03-12 Jeffrey Stedfast <fejj@ximian.com> + + * folder-browser.c (folder_browser_set_folder): Set the folder on + a folder-browser object. + + * folder-browser-window.c (folder_browser_window_new): Simple + window to display a folder-browser. + + * mail-callbacks.c (view_digest): New callback to open a + folder-browser-window with a digest folder. + 2002-03-08 Radek Doulik <rodo@ximian.com> * mail-signature-editor.c (menu_file_save_cb): truncate stream diff --git a/mail/Makefile.am b/mail/Makefile.am index 2a2a784d07..465094792b 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -53,6 +53,8 @@ evolution_mail_SOURCES = \ folder-browser-factory.h \ folder-browser-ui.c \ folder-browser-ui.h \ + folder-browser-window.c \ + folder-browser-window.h \ folder-info.c \ mail-accounts.c \ mail-accounts.h \ diff --git a/mail/folder-browser-window.c b/mail/folder-browser-window.c new file mode 100644 index 0000000000..3de5e5a042 --- /dev/null +++ b/mail/folder-browser-window.c @@ -0,0 +1,107 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: Jeffrey Stedfast <fejj@ximian.com> + * + * Copyright 2002 Ximian, Inc. (www.ximian.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <bonobo/bonobo-exception.h> +#include <bonobo/bonobo-ui-component.h> +#include <bonobo/bonobo-ui-container.h> +#include <bonobo/bonobo-ui-util.h> + +#include <gal/util/e-util.h> + +#include "folder-browser-window.h" + +#include "folder-browser-ui.h" + +#define PARENT_TYPE (bonobo_window_get_type ()) + +static BonoboWindowClass *folder_browser_window_parent_class = NULL; + +static void +folder_browser_window_destroy (GtkObject *object) +{ + FolderBrowserWindow *folder_browser_window; + + folder_browser_window = FOLDER_BROWSER_WINDOW (object); + + if (folder_browser_window->folder_browser) { + gtk_widget_destroy (GTK_WIDGET (folder_browser_window->folder_browser)); + folder_browser_window->folder_browser = NULL; + } + + if (GTK_OBJECT_CLASS (folder_browser_window_parent_class)->destroy) + (GTK_OBJECT_CLASS (folder_browser_window_parent_class)->destroy) (object); +} + +static void +folder_browser_window_class_init (GtkObjectClass *object_class) +{ + object_class->destroy = folder_browser_window_destroy; + + folder_browser_window_parent_class = gtk_type_class (PARENT_TYPE); +} + +static void +folder_browser_window_init (GtkObject *object) +{ + ; +} + + +GtkWidget * +folder_browser_window_new (FolderBrowser *fb) +{ + FolderBrowserWindow *new; + BonoboUIContainer *uicont; + BonoboUIComponent *uic; + CORBA_Environment ev; + + g_return_val_if_fail (IS_FOLDER_BROWSER (fb), NULL); + + new = gtk_type_new (FOLDER_BROWSER_WINDOW_TYPE); + new = (FolderBrowserWindow *) bonobo_window_construct (BONOBO_WINDOW (new), "Ximian Evolution", ""); + if (!new) + return NULL; + + new->folder_browser = fb; + bonobo_window_set_contents (BONOBO_WINDOW (new), GTK_WIDGET (fb)); + + uicont = bonobo_ui_container_new (); + bonobo_ui_container_set_win (uicont, BONOBO_WINDOW (new)); + + uic = bonobo_ui_component_new_default (); + bonobo_ui_component_set_container (uic, BONOBO_OBJREF (uicont)); + + folder_browser_set_ui_component (FOLDER_BROWSER (fb), uic); + folder_browser_ui_add_global (fb); + folder_browser_ui_add_list (fb); + folder_browser_ui_add_message (fb); + /*folder_browser_set_shell_view (fb, fb_get_svi (control));*/ + + return GTK_WIDGET (new); +} + +E_MAKE_TYPE (folder_browser_window, "FolderBrowserWindow", FolderBrowserWindow, folder_browser_window_class_init, folder_browser_window_init, PARENT_TYPE); diff --git a/mail/folder-browser-window.h b/mail/folder-browser-window.h new file mode 100644 index 0000000000..fdd9b1315b --- /dev/null +++ b/mail/folder-browser-window.h @@ -0,0 +1,64 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: Jeffrey Stedfast <fejj@ximian.com> + * + * Copyright 2002 Ximian, Inc. (www.ximian.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + + +#ifndef __FOLDER_BROWSER_WINDOW_H__ +#define __FOLDER_BROWSER_WINDOW_H__ + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +#include <bonobo/bonobo-win.h> + +#include "folder-browser.h" + +#define FOLDER_BROWSER_WINDOW_TYPE (folder_browser_window_get_type ()) +#define FOLDER_BROWSER_WINDOW(o) (GTK_CHECK_CAST ((o), FOLDER_BROWSER_WINDOW_TYPE, FolderBrowserWindow)) +#define FOLDER_BROWSER_WINDOW_CLASS(k) (GTK_CHECK_CLASS_CAST((k), FOLDER_BROWSER_WINDOW_TYPE, FolderBrowserWindowClass)) +#define IS_FOLDER_BROWSER_WINDOW(o) (GTK_CHECK_TYPE ((o), FOLDER_BROWSER_WINDOW_TYPE)) +#define IS_FOLDER_BROWSER_WINDOW_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), FOLDER_BROWSER_WINDOW_TYPE)) + +typedef struct _FolderBrowserWindowClass FolderBrowserWindowClass; +typedef struct _FolderBrowserWindow FolderBrowserWindow; + +struct _FolderBrowserWindow { + BonoboWindow parent; + + FolderBrowser *folder_browser; +}; + +struct _FolderBrowserWindowClass { + BonoboWindowClass parent_class; + +}; + +GtkType folder_browser_window_get_type (void); + +GtkWidget *folder_browser_window_new (FolderBrowser *fb); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __FOLDER_BROWSER_WINDOW_H__ */ diff --git a/mail/folder-browser.c b/mail/folder-browser.c index 48b2f01297..eb7ea566dd 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -868,6 +868,23 @@ got_folder(char *uri, CamelFolder *folder, void *data) } void +folder_browser_set_folder (FolderBrowser *fb, CamelFolder *folder, const char *uri) +{ + g_return_if_fail (IS_FOLDER_BROWSER (fb)); + g_return_if_fail (CAMEL_IS_FOLDER (folder)); + + if (fb->get_id != -1) { + /* FIXME: cancel the get_folder request? */ + } + + g_free (fb->uri); + fb->uri = g_strdup (uri); + + gtk_object_ref (GTK_OBJECT (fb)); + got_folder (uri, folder, fb); +} + +void folder_browser_set_ui_component (FolderBrowser *fb, BonoboUIComponent *uicomp) { g_return_if_fail (IS_FOLDER_BROWSER (fb)); @@ -2176,10 +2193,13 @@ folder_browser_new (const GNOME_Evolution_Shell shell, const char *uri) } CORBA_exception_free (&ev); - - folder_browser->uri = g_strdup (uri); - gtk_object_ref (GTK_OBJECT (folder_browser)); - folder_browser->get_id = mail_get_folder (folder_browser->uri, 0, got_folder, folder_browser, mail_thread_new); + + if (uri) { + folder_browser->uri = g_strdup (uri); + gtk_object_ref (GTK_OBJECT (folder_browser)); + folder_browser->get_id = mail_get_folder (folder_browser->uri, 0, got_folder, + folder_browser, mail_thread_new); + } return GTK_WIDGET (folder_browser); } diff --git a/mail/folder-browser.h b/mail/folder-browser.h index fd399df930..5b21efc036 100644 --- a/mail/folder-browser.h +++ b/mail/folder-browser.h @@ -109,6 +109,8 @@ GtkType folder_browser_get_type (void); GtkWidget *folder_browser_new (const GNOME_Evolution_Shell shell, const char *uri); +void folder_browser_set_folder (FolderBrowser *fb, CamelFolder *folder, const char *uri); + void folder_browser_set_ui_component (FolderBrowser *fb, BonoboUIComponent *uicomp); void folder_browser_set_shell_view (FolderBrowser *fb, GNOME_Evolution_ShellView shell_view); diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index 5cec76bafb..37f4d352bc 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -43,6 +43,7 @@ #include <e-util/e-dialog-utils.h> #include <filter/filter-editor.h> #include "mail.h" +#include "folder-browser-window.h" #include "message-browser.h" #include "mail-callbacks.h" #include "mail-config.h" @@ -3031,6 +3032,63 @@ configure_folder (BonoboUIComponent *uih, void *user_data, const char *path) } static void +do_view_digest (CamelFolder *folder, char *uid, CamelMimeMessage *message, void *data) +{ + FolderBrowser *folder_browser = FOLDER_BROWSER (data); + + if (FOLDER_BROWSER_IS_DESTROYED (folder_browser)) + return; + + if (message) { + CamelFolder *digest; + CamelStore *store; + FolderBrowser *fb; + GtkWidget *window; + + store = camel_digest_store_new ("digest:/"); + + digest = camel_digest_folder_new (store, message); + camel_object_unref (CAMEL_OBJECT (store)); + if (!digest) + return; + + camel_folder_set_message_flags (folder, uid, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN); + + fb = (FolderBrowser *) folder_browser_new (folder_browser->shell, NULL); + folder_browser_set_message_preview (fb, TRUE); + folder_browser_set_folder (fb, digest, "digest:/"); + camel_object_unref (CAMEL_OBJECT (digest)); + gtk_widget_show (GTK_WIDGET (fb)); + + window = folder_browser_window_new (fb); + gtk_widget_show (window); + } +} + +void +view_digest (GtkWidget *widget, gpointer user_data) +{ + FolderBrowser *fb = FOLDER_BROWSER (user_data); + GPtrArray *uids; + int i; + + if (FOLDER_BROWSER_IS_DESTROYED (fb)) + return; + + uids = g_ptr_array_new (); + message_list_foreach (fb->message_list, enumerate_msg, uids); + + if (uids->len > 10 && !are_you_sure (_("Are you sure you want to open all %d messages in separate windows?"), uids, fb)) + return; + + for (i = 0; i < uids->len; i++) { + mail_get_message (fb->folder, uids->pdata [i], do_view_digest, fb, mail_thread_queued); + g_free (uids->pdata [i]); + } + g_ptr_array_free (uids, TRUE); +} + +static void do_view_message (CamelFolder *folder, char *uid, CamelMimeMessage *message, void *data) { FolderBrowser *fb = FOLDER_BROWSER (data); @@ -3062,7 +3120,7 @@ view_msg (GtkWidget *widget, gpointer user_data) if (uids->len > 10 && !are_you_sure (_("Are you sure you want to open all %d messages in separate windows?"), uids, fb)) return; - + for (i = 0; i < uids->len; i++) { mail_get_message (fb->folder, uids->pdata [i], do_view_message, fb, mail_thread_queued); g_free (uids->pdata [i]); diff --git a/mail/mail-callbacks.h b/mail/mail-callbacks.h index f50763b16d..16f0219b1e 100644 --- a/mail/mail-callbacks.h +++ b/mail/mail-callbacks.h @@ -73,6 +73,7 @@ void edit_msg (GtkWidget *widget, gpointer user_data); void open_msg (GtkWidget *widget, gpointer user_data); void save_msg (GtkWidget *widget, gpointer user_data); void view_msg (GtkWidget *widget, gpointer user_data); +void view_digest (GtkWidget *widget, gpointer user_data); void view_source (GtkWidget *widget, gpointer user_data); void next_msg (GtkWidget *widget, gpointer user_data); void next_unread_msg (GtkWidget *widget, gpointer user_data); |