aboutsummaryrefslogtreecommitdiffstats
path: root/composer
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
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')
-rw-r--r--composer/ChangeLog15
-rw-r--r--composer/Makefile.am2
-rw-r--r--composer/e-msg-composer.c108
-rw-r--r--composer/e-msg-composer.h3
4 files changed, 92 insertions, 36 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index b9f8904f78..ec42f9287a 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,18 @@
+2002-05-16 Ettore Perazzoli <ettore@ximian.com>
+
+ * 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.
+
2002-05-15 Jeffrey Stedfast <fejj@ximian.com>
* e-msg-composer-attachment.c (e_msg_composer_attachment_new):
diff --git a/composer/Makefile.am b/composer/Makefile.am
index 505c0c130e..0b9f4a2f7b 100644
--- a/composer/Makefile.am
+++ b/composer/Makefile.am
@@ -22,7 +22,7 @@ $(IDL_GENERATED): $(IDLS) $(selectnamesdir)/Evolution-Addressbook-SelectNames.id
$(ORBIT_IDL) -I $(srcdir) -I $(datadir)/idl `$(GNOME_CONFIG) --cflags idl` \
-I $(selectnamesdir) $(srcdir)/Composer.idl
-Editor-commmon.c: $(GTKHTML_DATADIR)/Editor.idl
+Editor-commmon.c: $(GTKHTML_DATADIR)/Editor.idl
$(HTML_EDITOR_GENERATED): $(GTKHTML_DATADIR)/Editor.idl
$(ORBIT_IDL) -I $(srcdir) `$(GNOME_CONFIG) --cflags idl` -I $(GTKHTML_DATADIR)/gtkhtml $(GTKHTML_DATADIR)/Editor.idl
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;
+}
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 921dfc2ee1..b92713bb93 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -194,6 +194,9 @@ void e_msg_composer_add_message_attachments (EMsgCo
void e_msg_composer_ignore (EMsgComposer *composer,
const gchar *str);
void e_msg_composer_drop_editor_undo (EMsgComposer *composer);
+
+gboolean e_msg_composer_request_close_all (void);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */