aboutsummaryrefslogtreecommitdiffstats
path: root/composer/e-msg-composer.c
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2002-05-16 22:42:37 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2002-05-16 22:42:37 +0800
commit9b864ecd40139b61c89c459e4feb093c5b49d14b (patch)
tree8de9ea52ac3d2a646bb6190655e1bcc615a6925c /composer/e-msg-composer.c
parent442cb01bee426d4a716485759ea093c773f5321a (diff)
downloadgsoc2013-evolution-9b864ecd40139b61c89c459e4feb093c5b49d14b.tar
gsoc2013-evolution-9b864ecd40139b61c89c459e4feb093c5b49d14b.tar.gz
gsoc2013-evolution-9b864ecd40139b61c89c459e4feb093c5b49d14b.tar.bz2
gsoc2013-evolution-9b864ecd40139b61c89c459e4feb093c5b49d14b.tar.lz
gsoc2013-evolution-9b864ecd40139b61c89c459e4feb093c5b49d14b.tar.xz
gsoc2013-evolution-9b864ecd40139b61c89c459e4feb093c5b49d14b.tar.zst
gsoc2013-evolution-9b864ecd40139b61c89c459e4feb093c5b49d14b.zip
New. (create_component): Pass it as the @request_quit_fn to
* component-factory.c (request_quit): New. (create_component): Pass it as the @request_quit_fn to evolution_shell_component_new(). * e-msg-composer.c: New local `all_composers'; keeps a list of all the composer windows created. Changed type of `parent_class' to BonoboWindowClass *. (do_exit): Cleaned up a bit. Raise the composer window before showing the message box dialog. (exit_dialog_cb): Removed. (e_msg_composer_request_close_all): New. (create_composer): Add the composer to the all_composers list and weakref it. (msg_composer_destroy_notify): GtkDestroyNotify function for the composer's weakref; remove the composer from the all_composers list. svn path=/trunk/; revision=16930
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r--composer/e-msg-composer.c108
1 files changed, 73 insertions, 35 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index bf93b80762..368797a2ad 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -50,8 +50,10 @@
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
+
#include <gal/unicode/gunicode.h>
#include <gal/util/e-unicode-i18n.h>
+
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-exec.h>
#include <libgnomeui/gnome-app.h>
@@ -60,23 +62,25 @@
#include <libgnomeui/gnome-dialog-util.h>
#include <libgnomeui/gnome-stock.h>
#include <libgnomeui/gnome-window-icon.h>
+
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-moniker-util.h>
#include <bonobo/bonobo-object-client.h>
#include <bonobo/bonobo-stream-memory.h>
#include <bonobo/bonobo-ui-util.h>
#include <bonobo/bonobo-widget.h>
+
#include <libgnomevfs/gnome-vfs.h>
#include <glade/glade.h>
+
#include <gal/widgets/e-gui-utils.h>
#include <gal/widgets/e-scroll-frame.h>
#include <gal/e-text/e-entry.h>
+
#include <gtkhtml/gtkhtml.h>
#include <gtkhtml/htmlselection.h>
-/*#include <addressbook/backend/ebook/e-card.h>*/
-
#include "widgets/misc/e-charset-picker.h"
#include "camel/camel.h"
@@ -133,8 +137,14 @@ static GtkTargetEntry drop_types[] = {
static int num_drop_types = sizeof (drop_types) / sizeof (drop_types[0]);
-static GnomeAppClass *parent_class = NULL;
+
+/* The parent class. */
+static BonoboWindowClass *parent_class = NULL;
+
+/* All the composer windows open, for bookkeeping purposes. */
+static GSList *all_composers = NULL;
+
/* local prototypes */
static GList *add_recipients (GList *list, const char *recips, gboolean decode);
@@ -1306,46 +1316,43 @@ menu_file_save_draft_cb (BonoboUIComponent *uic, void *data, const char *path)
/* Exit dialog. (Displays a "Save composition to 'Drafts' before exiting?" warning before actually exiting.) */
-enum { REPLY_YES = 0, REPLY_NO, REPLY_CANCEL };
-
-static void
-exit_dialog_cb (int reply, EMsgComposer *composer)
-{
- switch (reply) {
- case REPLY_YES:
- gtk_signal_emit (GTK_OBJECT (composer), signals[SAVE_DRAFT], TRUE);
- e_msg_composer_unset_changed (composer);
- break;
- case REPLY_NO:
- gtk_widget_destroy (GTK_WIDGET (composer));
- break;
- case REPLY_CANCEL:
- default:
- }
-}
-
static void
do_exit (EMsgComposer *composer)
{
GtkWidget *dialog;
gint button;
- if (e_msg_composer_is_dirty (composer)) {
- dialog = gnome_message_box_new (_("This message has not been sent.\n\nDo you wish to save your changes?"),
- GNOME_MESSAGE_BOX_QUESTION,
- GNOME_STOCK_BUTTON_YES, /* Save */
- GNOME_STOCK_BUTTON_NO, /* Don't save */
- GNOME_STOCK_BUTTON_CANCEL, /* Cancel */
- NULL);
-
- gtk_window_set_title (GTK_WINDOW (dialog), _("Warning: Modified Message"));
- gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (composer));
- gnome_dialog_set_default (GNOME_DIALOG (dialog), 0);
- button = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
+ if (! e_msg_composer_is_dirty (composer)) {
+ gtk_widget_destroy (GTK_WIDGET (composer));
+ return;
+ }
+
+ gdk_window_raise (GTK_WIDGET (composer)->window);
+
+ dialog = gnome_message_box_new (_("This message has not been sent.\n\nDo you wish to save your changes?"),
+ GNOME_MESSAGE_BOX_QUESTION,
+ GNOME_STOCK_BUTTON_YES, /* Save */
+ GNOME_STOCK_BUTTON_NO, /* Don't save */
+ GNOME_STOCK_BUTTON_CANCEL, /* Cancel */
+ NULL);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Warning: Modified Message"));
+ gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (composer));
+ gnome_dialog_set_default (GNOME_DIALOG (dialog), 0);
+ button = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
- exit_dialog_cb (button, composer);
- } else {
+ switch (button) {
+ case 0: /* Save */
+ gtk_signal_emit (GTK_OBJECT (composer), signals[SAVE_DRAFT], TRUE);
+ e_msg_composer_unset_changed (composer);
+ break;
+ case 1: /* Don't save */
gtk_widget_destroy (GTK_WIDGET (composer));
+ break;
+ case 2: /* Cancel */
+ break;
+ default:
+ g_assert_not_reached ();
}
}
@@ -2628,6 +2635,14 @@ map_default_cb (EMsgComposer *composer, gpointer user_data)
CORBA_exception_free (&ev);
}
+static void
+msg_composer_destroy_notify (void *data)
+{
+ EMsgComposer *composer = E_MSG_COMPOSER (data);
+
+ all_composers = g_slist_remove (all_composers, composer);
+}
+
static EMsgComposer *
create_composer (void)
{
@@ -2640,6 +2655,12 @@ create_composer (void)
composer = gtk_type_new (E_TYPE_MSG_COMPOSER);
+ all_composers = g_slist_prepend (all_composers, composer);
+
+ gtk_object_weakref (GTK_OBJECT (composer),
+ msg_composer_destroy_notify,
+ composer);
+
gtk_window_set_default_size (GTK_WINDOW (composer),
DEFAULT_WIDTH, DEFAULT_HEIGHT);
gnome_window_icon_set_from_file (GTK_WINDOW (composer), EVOLUTION_DATADIR
@@ -4321,3 +4342,20 @@ e_msg_composer_drop_editor_undo (EMsgComposer *composer)
GNOME_GtkHTML_Editor_Engine_dropUndo (composer->editor_engine, &ev);
CORBA_exception_free (&ev);
}
+
+
+gboolean
+e_msg_composer_request_close_all (void)
+{
+ GSList *p, *pnext;
+
+ for (p = all_composers; p != NULL; p = pnext) {
+ pnext = p->next;
+ do_exit (E_MSG_COMPOSER (p->data));
+ }
+
+ if (all_composers == NULL)
+ return TRUE;
+ else
+ return FALSE;
+}