aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-01-08 02:23:46 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-01-08 02:23:46 +0800
commit8d8e4ac1c23905892a42b779188c852fdead7f5f (patch)
tree01609ceef7151d75f81fdc8762ac6c25215e8a51
parent13a0edc3d27cce65a0f720e98516f7ab902ad0fc (diff)
downloadgsoc2013-evolution-8d8e4ac1c23905892a42b779188c852fdead7f5f.tar.gz
gsoc2013-evolution-8d8e4ac1c23905892a42b779188c852fdead7f5f.tar.zst
gsoc2013-evolution-8d8e4ac1c23905892a42b779188c852fdead7f5f.zip
Tweak the EShell API.
Disable File -> Close Window when there's only one window. Replace EMMessageBrowser with EMailBrowser. svn path=/branches/kill-bonobo/; revision=37009
-rw-r--r--composer/e-msg-composer.c4
-rw-r--r--doc/reference/shell/eshell-sections.txt8
-rw-r--r--doc/reference/shell/tmpl/e-shell.sgml21
-rw-r--r--doc/reference/shell/tmpl/eshell-unused.sgml54
-rw-r--r--mail/Makefile.am4
-rw-r--r--mail/e-mail-browser.c100
-rw-r--r--mail/e-mail-browser.h1
-rw-r--r--mail/e-mail-reader.c193
-rw-r--r--mail/e-mail-reader.h8
-rw-r--r--mail/e-mail-shell-module-settings.c2
-rw-r--r--mail/e-mail-shell-module.c9
-rw-r--r--mail/em-account-editor.c2
-rw-r--r--mail/em-composer-prefs.c2
-rw-r--r--mail/em-folder-view.c5
-rw-r--r--mail/em-format-html.c1
-rw-r--r--mail/em-mailer-prefs.c2
-rw-r--r--mail/em-message-browser.c397
-rw-r--r--mail/em-message-browser.h74
-rw-r--r--shell/e-shell-content.c46
-rw-r--r--shell/e-shell-migrate.c2
-rw-r--r--shell/e-shell-window-actions.c4
-rw-r--r--shell/e-shell-window-private.c19
-rw-r--r--shell/e-shell-window-private.h3
-rw-r--r--shell/e-shell-window.c42
-rw-r--r--shell/e-shell.c80
-rw-r--r--shell/e-shell.h8
-rw-r--r--shell/main.c7
-rw-r--r--shell/test/e-test-shell-module.c5
28 files changed, 518 insertions, 585 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 88ac673454..48b006bb67 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -1361,7 +1361,7 @@ set_editor_text (EMsgComposer *composer,
g_return_if_fail (text != NULL);
shell = e_shell_get_default ();
- shell_settings = e_shell_get_settings (shell);
+ shell_settings = e_shell_get_shell_settings (shell);
/*
@@ -2061,7 +2061,7 @@ msg_composer_constructor (GType type,
array = composer->priv->gconf_bridge_binding_ids;
shell = e_shell_get_default ();
- shell_settings = e_shell_get_settings (shell);
+ shell_settings = e_shell_get_shell_settings (shell);
/* Restore Persistent State */
diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt
index 908777cf4b..8e0d7723f9 100644
--- a/doc/reference/shell/eshell-sections.txt
+++ b/doc/reference/shell/eshell-sections.txt
@@ -3,13 +3,13 @@
<TITLE>EShell</TITLE>
EShell
e_shell_get_default
-e_shell_list_modules
+e_shell_get_shell_modules
+e_shell_get_shell_windows
e_shell_get_canonical_name
e_shell_get_module_by_name
e_shell_get_module_by_scheme
-e_shell_get_settings
-e_shell_create_window
-e_shell_get_focused_window
+e_shell_get_shell_settings
+e_shell_create_shell_window
e_shell_handle_uri
e_shell_send_receive
e_shell_get_network_available
diff --git a/doc/reference/shell/tmpl/e-shell.sgml b/doc/reference/shell/tmpl/e-shell.sgml
index 350141a0e5..1b96f4a40d 100644
--- a/doc/reference/shell/tmpl/e-shell.sgml
+++ b/doc/reference/shell/tmpl/e-shell.sgml
@@ -78,7 +78,6 @@ EShell
</para>
@eshell: the object which received the signal.
-@arg1:
<!-- ##### ARG EShell:network-available ##### -->
<para>
@@ -90,7 +89,7 @@ EShell
</para>
-<!-- ##### ARG EShell:settings ##### -->
+<!-- ##### ARG EShell:shell-settings ##### -->
<para>
</para>
@@ -103,7 +102,7 @@ EShell
@Returns:
-<!-- ##### FUNCTION e_shell_list_modules ##### -->
+<!-- ##### FUNCTION e_shell_get_shell_modules ##### -->
<para>
</para>
@@ -112,17 +111,16 @@ EShell
@Returns:
-<!-- ##### FUNCTION e_shell_get_canonical_name ##### -->
+<!-- ##### FUNCTION e_shell_get_shell_windows ##### -->
<para>
</para>
@shell:
-@name:
@Returns:
-<!-- ##### FUNCTION e_shell_get_module_by_name ##### -->
+<!-- ##### FUNCTION e_shell_get_canonical_name ##### -->
<para>
</para>
@@ -132,26 +130,27 @@ EShell
@Returns:
-<!-- ##### FUNCTION e_shell_get_module_by_scheme ##### -->
+<!-- ##### FUNCTION e_shell_get_module_by_name ##### -->
<para>
</para>
@shell:
-@scheme:
+@name:
@Returns:
-<!-- ##### FUNCTION e_shell_get_settings ##### -->
+<!-- ##### FUNCTION e_shell_get_module_by_scheme ##### -->
<para>
</para>
@shell:
+@scheme:
@Returns:
-<!-- ##### FUNCTION e_shell_create_window ##### -->
+<!-- ##### FUNCTION e_shell_get_shell_settings ##### -->
<para>
</para>
@@ -160,7 +159,7 @@ EShell
@Returns:
-<!-- ##### FUNCTION e_shell_get_focused_window ##### -->
+<!-- ##### FUNCTION e_shell_create_shell_window ##### -->
<para>
</para>
diff --git a/doc/reference/shell/tmpl/eshell-unused.sgml b/doc/reference/shell/tmpl/eshell-unused.sgml
index cee15019d4..d8c74f0d7b 100644
--- a/doc/reference/shell/tmpl/eshell-unused.sgml
+++ b/doc/reference/shell/tmpl/eshell-unused.sgml
@@ -433,6 +433,12 @@ intelligent
@minor:
@revision:
+<!-- ##### ARG EShell:settings ##### -->
+<para>
+
+</para>
+
+
<!-- ##### ENUM EShellLineStatus ##### -->
<para>
@@ -1731,6 +1737,22 @@ intelligent
@revision:
@Returns:
+<!-- ##### FUNCTION e_shell_create_window ##### -->
+<para>
+
+</para>
+
+@shell:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_get_focused_window ##### -->
+<para>
+
+</para>
+
+@shell:
+@Returns:
+
<!-- ##### FUNCTION e_shell_get_line_status ##### -->
<para>
@@ -1739,6 +1761,38 @@ intelligent
@shell:
@Returns:
+<!-- ##### FUNCTION e_shell_get_settings ##### -->
+<para>
+
+</para>
+
+@shell:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_list_modules ##### -->
+<para>
+
+</para>
+
+@shell:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_list_shell_modules ##### -->
+<para>
+
+</para>
+
+@shell:
+@Returns:
+
+<!-- ##### FUNCTION e_shell_list_shell_windows ##### -->
+<para>
+
+</para>
+
+@shell:
+@Returns:
+
<!-- ##### FUNCTION e_shell_marshal_BOOLEAN__STRING ##### -->
<para>
diff --git a/mail/Makefile.am b/mail/Makefile.am
index e0e1e5982e..1ce0ae79ad 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -121,8 +121,6 @@ libevolution_module_mail_la_SOURCES = \
em-mailer-prefs.h \
em-menu.c \
em-menu.h \
- em-message-browser.c \
- em-message-browser.h \
em-network-prefs.c \
em-network-prefs.h \
em-popup.c \
@@ -205,7 +203,6 @@ libevolution_module_mail_la_LIBADD = \
# em-inline-filter.h \
# em-junk-hook.h \
# em-menu.h \
-# em-message-browser.h \
# em-popup.h \
# em-stripsig-filter.h \
# em-sync-stream.h \
@@ -269,7 +266,6 @@ libevolution_module_mail_la_LIBADD = \
# em-inline-filter.c \
# em-junk-hook.c \
# em-menu.c \
-# em-message-browser.c \
# em-migrate.c \
# em-migrate.h \
# em-popup.c \
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index 13647c1f62..e6c1072304 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -29,6 +29,7 @@
#include "e-util/gconf-bridge.h"
#include "mail/e-mail-reader.h"
+#include "mail/e-mail-reader-utils.h"
#include "mail/e-mail-shell-module.h"
#include "mail/em-folder-tree-model.h"
#include "mail/em-format-html-display.h"
@@ -78,7 +79,7 @@ static void
action_close_cb (GtkAction *action,
EMailBrowser *browser)
{
- gtk_widget_destroy (GTK_WIDGET (browser));
+ e_mail_browser_close (browser);
}
static GtkActionEntry mail_browser_entries[] = {
@@ -187,6 +188,35 @@ mail_browser_connect_proxy_cb (EMailBrowser *browser,
}
static void
+mail_browser_message_selected_cb (EMailBrowser *browser,
+ const gchar *uid)
+{
+ EMFormatHTMLDisplay *html_display;
+ MessageList *message_list;
+ CamelMessageInfo *info;
+ EMailReader *reader;
+
+ if (uid == NULL)
+ return;
+
+ reader = E_MAIL_READER (browser);
+ html_display = e_mail_reader_get_html_display (reader);
+ message_list = e_mail_reader_get_message_list (reader);
+ info = camel_folder_get_message_info (message_list->folder, uid);
+
+ if (info == NULL)
+ return;
+
+ gtk_window_set_title (
+ GTK_WINDOW (browser),
+ camel_message_info_subject (info));
+ gtk_widget_grab_focus (
+ GTK_WIDGET (((EMFormatHTML *) html_display)->html));
+
+ camel_folder_free_message_info (message_list->folder, info);
+}
+
+static void
mail_browser_set_shell_module (EMailBrowser *browser,
EShellModule *shell_module)
{
@@ -367,6 +397,20 @@ mail_browser_constructed (GObject *object)
gtk_widget_show (widget);
}
+static gboolean
+mail_browser_key_press_event (GtkWidget *widget,
+ GdkEventKey *event)
+{
+ if (event->keyval == GDK_Escape) {
+ e_mail_browser_close (E_MAIL_BROWSER (widget));
+ return TRUE;
+ }
+
+ /* Chain up to parent's key_press_event() method. */
+ return GTK_WIDGET_CLASS (parent_class)->
+ key_press_event (widget, event);
+}
+
static GtkActionGroup *
mail_browser_get_action_group (EMailReader *reader)
{
@@ -419,9 +463,45 @@ mail_browser_get_window (EMailReader *reader)
}
static void
+mail_browser_set_message (EMailReader *reader,
+ const gchar *uid,
+ gboolean mark_read)
+{
+ EMailReaderIface *iface;
+ MessageList *message_list;
+ CamelMessageInfo *info;
+ CamelFolder *folder;
+
+ /* Chain up to parent's set_message() method. */
+ iface = g_type_default_interface_peek (E_TYPE_MAIL_READER);
+ iface->set_message (reader, uid, mark_read);
+
+ if (uid == NULL) {
+ e_mail_browser_close (E_MAIL_BROWSER (reader));
+ return;
+ }
+
+ message_list = e_mail_reader_get_message_list (reader);
+
+ folder = message_list->folder;
+ info = camel_folder_get_message_info (folder, uid);
+
+ if (info != NULL) {
+ gtk_window_set_title (
+ GTK_WINDOW (reader),
+ camel_message_info_subject (info));
+ camel_folder_free_message_info (folder, info);
+ }
+
+ if (mark_read)
+ e_mail_reader_mark_as_read (reader, uid);
+}
+
+static void
mail_browser_class_init (EMailBrowserClass *class)
{
GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (EMailBrowserPrivate));
@@ -432,6 +512,9 @@ mail_browser_class_init (EMailBrowserClass *class)
object_class->dispose = mail_browser_dispose;
object_class->constructed = mail_browser_constructed;
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->key_press_event = mail_browser_key_press_event;
+
g_object_class_install_property (
object_class,
PROP_SHELL_MODULE,
@@ -453,6 +536,7 @@ mail_browser_iface_init (EMailReaderIface *iface)
iface->get_message_list = mail_browser_get_message_list;
iface->get_shell_module = mail_browser_get_shell_module;
iface->get_window = mail_browser_get_window;
+ iface->set_message = mail_browser_set_message;
}
static void
@@ -473,9 +557,15 @@ mail_browser_init (EMailBrowser *browser)
browser->priv->message_list = message_list_new ();
g_object_ref_sink (browser->priv->message_list);
+ g_signal_connect_swapped (
+ browser->priv->message_list, "message-selected",
+ G_CALLBACK (mail_browser_message_selected_cb), browser);
+
bridge = gconf_bridge_get ();
prefix = "/apps/evolution/mail/mail_browser";
gconf_bridge_bind_window_size (bridge, prefix, GTK_WINDOW (browser));
+
+ gtk_window_set_title (GTK_WINDOW (browser), _("Evolution"));
}
GType
@@ -523,6 +613,14 @@ e_mail_browser_new (EShellModule *shell_module)
"shell-module", shell_module, NULL);
}
+void
+e_mail_browser_close (EMailBrowser *browser)
+{
+ g_return_if_fail (E_IS_MAIL_BROWSER (browser));
+
+ gtk_widget_destroy (GTK_WIDGET (browser));
+}
+
GtkUIManager *
e_mail_browser_get_ui_manager (EMailBrowser *browser)
{
diff --git a/mail/e-mail-browser.h b/mail/e-mail-browser.h
index 5bac3896a8..35040f0ab0 100644
--- a/mail/e-mail-browser.h
+++ b/mail/e-mail-browser.h
@@ -61,6 +61,7 @@ struct _EMailBrowserClass {
GType e_mail_browser_get_type (void);
GtkWidget * e_mail_browser_new (EShellModule *shell_module);
+void e_mail_browser_close (EMailBrowser *browser);
GtkUIManager * e_mail_browser_get_ui_manager (EMailBrowser *browser);
G_END_DECLS
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 4c09f96c55..93279c2bfe 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -24,6 +24,7 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include <gtkhtml/gtkhtml.h>
+#include <gtkhtml/gtkhtml-stream.h>
#ifdef HAVE_XFREE
#include <X11/XF86keysym.h>
@@ -31,11 +32,13 @@
#include "e-util/e-util.h"
#include "e-util/gconf-bridge.h"
+#include "shell/e-shell.h"
#include "widgets/misc/e-charset-picker.h"
#include "mail/e-mail-reader-utils.h"
#include "mail/e-mail-shell-module.h"
#include "mail/em-composer-utils.h"
+#include "mail/em-event.h"
#include "mail/em-folder-selector.h"
#include "mail/em-folder-tree.h"
#include "mail/em-utils.h"
@@ -1485,6 +1488,164 @@ mail_reader_key_press_cb (EMailReader *reader,
return TRUE;
}
+static gboolean
+mail_reader_message_read_cb (EMailReader *reader)
+{
+ MessageList *message_list;
+ const gchar *uid;
+
+ message_list = e_mail_reader_get_message_list (reader);
+
+ uid = g_object_get_data (G_OBJECT (reader), "mark-read-uid");
+ g_return_if_fail (uid != NULL);
+
+ if (g_strcmp0 (message_list->cursor_uid, uid) == 0)
+ e_mail_reader_mark_as_read (reader, uid);
+}
+
+static void
+mail_reader_message_loaded_cb (CamelFolder *folder,
+ const gchar *message_uid,
+ CamelMimeMessage *message,
+ gpointer user_data,
+ CamelException *ex)
+{
+ EMailReader *reader = user_data;
+ EMFormatHTMLDisplay *html_display;
+ MessageList *message_list;
+ EShellModule *shell_module;
+ EShellSettings *shell_settings;
+ EShell *shell;
+ EMEvent *event;
+ EMEventTargetMessage *target;
+ gboolean mark_read;
+ gint timeout_interval;
+ gpointer data;
+
+ html_display = e_mail_reader_get_html_display (reader);
+ message_list = e_mail_reader_get_message_list (reader);
+
+ shell_module = e_mail_reader_get_shell_module (reader);
+ shell = e_shell_module_get_shell (shell_module);
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ /* If the user picked a different message in the time it took
+ * to fetch this message, then don't bother rendering it. */
+ if (g_strcmp0 (message_list->cursor_uid, message_uid) != 0)
+ return;
+
+ /** @Event: message.reading
+ * @Title: Viewing a message
+ * @Target: EMEventTargetMessage
+ *
+ * message.reading is emitted whenever a user views a message.
+ */
+ event = em_event_peek ();
+ target = em_event_target_new_message (
+ event, folder, message, message_uid, 0);
+ e_event_emit (
+ (EEvent *) event, "message.reading",
+ (EEventTarget *) target);
+
+ em_format_format (
+ (EMFormat *) html_display, folder, message_uid, message);
+
+ /* Reset the shell view icon. */
+ e_shell_event (shell, "mail-icon", "evolution-mail");
+
+ /* Determine whether to mark the message as read. */
+ g_object_get (
+ shell_settings,
+ "mail-mark-seen", &mark_read,
+ "mail-mark-seen-timeout", &timeout_interval, NULL);
+
+ g_object_set_data_full (
+ G_OBJECT (reader), "mark-read-uid",
+ g_strdup (message_uid), (GDestroyNotify) g_free);
+
+ if (message_list->seen_id > 0)
+ g_source_remove (message_list->seen_id);
+
+ if (mark_read) {
+ message_list->seen_id = g_timeout_add (
+ timeout_interval, (GSourceFunc)
+ mail_reader_message_read_cb, reader);
+
+ } else if (camel_exception_is_set (ex)) {
+ GtkHTMLStream *stream;
+
+ /* Display the error inline and clear the exception. */
+ stream = gtk_html_begin (
+ ((EMFormatHTML *) html_display)->html);
+ gtk_html_stream_printf (
+ stream, "<h2>%s</h2><p>%s</p>",
+ _("Unable to retrieve message"),
+ ex->desc);
+ gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
+ camel_exception_clear (ex);
+ }
+
+ /* We referenced this in the call to mail_get_messagex(). */
+ g_object_unref (reader);
+}
+
+static gboolean
+mail_reader_message_selected_timeout_cb (EMailReader *reader)
+{
+ EMFormatHTMLDisplay *html_display;
+ MessageList *message_list;
+ const gchar *cursor_uid;
+ const gchar *format_uid;
+ const gchar *key;
+
+ html_display = e_mail_reader_get_html_display (reader);
+ message_list = e_mail_reader_get_message_list (reader);
+
+ cursor_uid = message_list->cursor_uid;
+ format_uid = ((EMFormat *) html_display)->uid;
+
+ if (cursor_uid != NULL) {
+ if (g_strcmp0 (cursor_uid, format_uid) != 0)
+ mail_get_messagex (
+ message_list->folder, cursor_uid,
+ mail_reader_message_loaded_cb,
+ g_object_ref (reader),
+ mail_msg_fast_ordered_push);
+ } else
+ em_format_format ((EMFormat *) html_display, NULL, NULL, NULL);
+
+ key = "message-selected-timeout";
+ g_object_set_data (G_OBJECT (reader), key, NULL);
+
+ return FALSE;
+}
+
+static void
+mail_reader_message_selected_cb (EMailReader *reader,
+ const gchar *uid)
+{
+ const gchar *key;
+ guint source_id;
+ gpointer data;
+
+ /* XXX This is kludgy, but we have no other place to store
+ * timeout state information. */
+
+ key = "message-selected-timeout";
+ data = g_object_get_data (G_OBJECT (reader), key);
+ source_id = GPOINTER_TO_UINT (data);
+
+ if (source_id > 0)
+ g_source_remove (source_id);
+
+ source_id = g_timeout_add (
+ 100, (GSourceFunc)
+ mail_reader_message_selected_timeout_cb, reader);
+
+ data = GUINT_TO_POINTER (source_id);
+ g_object_set_data (G_OBJECT (reader), key, data);
+}
+
static void
mail_reader_set_folder (EMailReader *reader,
CamelFolder *folder,
@@ -1509,6 +1670,18 @@ mail_reader_set_folder (EMailReader *reader,
}
static void
+mail_reader_set_message (EMailReader *reader,
+ const gchar *uid,
+ gboolean mark_read)
+{
+ MessageList *message_list;
+ gpointer data;
+
+ message_list = e_mail_reader_get_message_list (reader);
+ message_list_select_uid (message_list, uid);
+}
+
+static void
mail_reader_init_charset_actions (EMailReader *reader)
{
GtkActionGroup *action_group;
@@ -1541,6 +1714,7 @@ static void
mail_reader_class_init (EMailReaderIface *iface)
{
iface->set_folder = mail_reader_set_folder;
+ iface->set_message = mail_reader_set_message;
}
GType
@@ -1626,6 +1800,10 @@ e_mail_reader_init (EMailReader *reader)
/* Connect signals. */
g_signal_connect_swapped (
+ message_list, "message-selected",
+ G_CALLBACK (mail_reader_message_selected_cb), reader);
+
+ g_signal_connect_swapped (
message_list->tree, "double-click",
G_CALLBACK (mail_reader_double_click_cb), reader);
@@ -1730,6 +1908,21 @@ e_mail_reader_set_folder (EMailReader *reader,
}
void
+e_mail_reader_set_message (EMailReader *reader,
+ const gchar *uid,
+ gboolean mark_read)
+{
+ EMailReaderIface *iface;
+
+ g_return_if_fail (E_IS_MAIL_READER (reader));
+
+ iface = E_MAIL_READER_GET_IFACE (reader);
+ g_return_if_fail (iface->set_message != NULL);
+
+ iface->set_message (reader, uid, mark_read);
+}
+
+void
e_mail_reader_create_charset_menu (EMailReader *reader,
GtkUIManager *ui_manager,
guint merge_id)
diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h
index 5dcf8d0266..4fba37056f 100644
--- a/mail/e-mail-reader.h
+++ b/mail/e-mail-reader.h
@@ -64,14 +64,15 @@ struct _EMailReaderIface {
void (*set_folder) (EMailReader *reader,
CamelFolder *folder,
const gchar *folder_uri);
+ void (*set_message) (EMailReader *reader,
+ const gchar *uid,
+ gboolean mark_read);
};
GType e_mail_reader_get_type (void);
void e_mail_reader_init (EMailReader *reader);
GtkActionGroup *
e_mail_reader_get_action_group (EMailReader *reader);
-CamelFolder * e_mail_reader_get_folder (EMailReader *reader);
-const gchar * e_mail_reader_get_folder_uri (EMailReader *reader);
gboolean e_mail_reader_get_hide_deleted (EMailReader *reader);
EMFormatHTMLDisplay *
e_mail_reader_get_html_display (EMailReader *reader);
@@ -81,6 +82,9 @@ GtkWindow * e_mail_reader_get_window (EMailReader *reader);
void e_mail_reader_set_folder (EMailReader *reader,
CamelFolder *folder,
const gchar *folder_uri);
+void e_mail_reader_set_message (EMailReader *reader,
+ const gchar *uid,
+ gboolean mark_read);
void e_mail_reader_create_charset_menu
(EMailReader *reader,
GtkUIManager *ui_manager,
diff --git a/mail/e-mail-shell-module-settings.c b/mail/e-mail-shell-module-settings.c
index 04388a92f5..0bd72c27bc 100644
--- a/mail/e-mail-shell-module-settings.c
+++ b/mail/e-mail-shell-module-settings.c
@@ -26,7 +26,7 @@ e_mail_shell_module_init_settings (EShell *shell)
{
EShellSettings *shell_settings;
- shell_settings = e_shell_get_settings (shell);
+ shell_settings = e_shell_get_shell_settings (shell);
/* XXX Default values should match the GConf schema.
* Yes it's redundant, but we're stuck with GConf. */
diff --git a/mail/e-mail-shell-module.c b/mail/e-mail-shell-module.c
index aef48d2636..1185e13575 100644
--- a/mail/e-mail-shell-module.c
+++ b/mail/e-mail-shell-module.c
@@ -687,10 +687,13 @@ mail_shell_module_prepare_for_offline_cb (EShell *shell,
EActivity *activity,
EShellModule *shell_module)
{
- GtkWidget *parent;
+ GList *shell_windows;
+ GtkWidget *parent = NULL;
gboolean synchronize = FALSE;
- parent = e_shell_get_focused_window (shell);
+ shell_windows = e_shell_get_shell_windows (shell);
+ if (shell_windows != NULL)
+ parent = GTK_WIDGET (shell_windows->data);
if (e_shell_get_network_available (shell))
synchronize = em_utils_prompt_user (
@@ -871,7 +874,7 @@ e_shell_module_init (GTypeModule *type_module)
mail_shell_module_init_preferences (shell);
g_object_get (
- e_shell_get_settings (shell),
+ e_shell_get_shell_settings (shell),
"mail-enable-search-folders",
&enable_search_folders, NULL);
if (enable_search_folders)
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index 866d503292..a29f408231 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -667,7 +667,7 @@ emae_signature_new(GtkWidget *w, EMAccountEditor *emae)
gboolean html_mode;
shell = e_shell_get_default ();
- shell_settings = e_shell_get_settings (shell);
+ shell_settings = e_shell_get_shell_settings (shell);
parent = gtk_widget_get_toplevel (w);
g_object_get (
diff --git a/mail/em-composer-prefs.c b/mail/em-composer-prefs.c
index dfc50edf0e..52bbd98479 100644
--- a/mail/em-composer-prefs.c
+++ b/mail/em-composer-prefs.c
@@ -857,7 +857,7 @@ em_composer_prefs_construct (EMComposerPrefs *prefs,
bridge = gconf_bridge_get ();
client = mail_config_get_gconf_client ();
- shell_settings = e_shell_get_settings (shell);
+ shell_settings = e_shell_get_shell_settings (shell);
gladefile = g_build_filename (EVOLUTION_GLADEDIR,
"mail-config.glade",
diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c
index 3433453889..e940b841a4 100644
--- a/mail/em-folder-view.c
+++ b/mail/em-folder-view.c
@@ -90,7 +90,6 @@
#include "em-folder-browser.h"
#include "em-mailer-prefs.h"
#include "em-folder-browser.h"
-#include "em-message-browser.h"
#include "message-list.h"
#include "em-utils.h"
#include "em-composer-utils.h"
@@ -528,6 +527,7 @@ em_folder_view_open_selected(EMFolderView *emfv)
}
}
+#if 0 /* KILL-BONOBO */
/* TODO: have an em_utils_open_messages call? */
for (i=0; i<views->len; i++) {
EMMessageBrowser *emmb;
@@ -547,6 +547,7 @@ em_folder_view_open_selected(EMFolderView *emfv)
em_utils_handle_receipt (emfv->folder, uids->pdata[i], NULL);
g_free(views->pdata[i]);
}
+#endif
g_ptr_array_free(views, TRUE);
message_list_free_uids(emfv->list, uids);
@@ -664,6 +665,7 @@ emfv_popup_open(EPopup *ep, EPopupItem *pitem, void *data)
static void
emfv_popup_source(EPopup *ep, EPopupItem *pitem, void *data)
{
+#if 0 /* KILL-BONOBO */
EMFolderView *emfv = data;
EMMessageBrowser *emmb;
GPtrArray *uids;
@@ -678,6 +680,7 @@ emfv_popup_source(EPopup *ep, EPopupItem *pitem, void *data)
gtk_widget_show(emmb->window);
message_list_free_uids(emfv->list, uids);
+#endif
}
//#define DelInVFolderCheckName "DelInVFolderCheck"
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 8aed5e814c..99377cce74 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -159,7 +159,6 @@ efh_init(GObject *o)
gtk_html_set_default_content_type(efh->html, "text/html; charset=utf-8");
gtk_html_set_editable(efh->html, FALSE);
- g_signal_connect(efh->html, "destroy", G_CALLBACK(efh_gtkhtml_destroy), efh);
g_signal_connect(efh->html, "url_requested", G_CALLBACK(efh_url_requested), efh);
g_signal_connect(efh->html, "object_requested", G_CALLBACK(efh_object_requested), efh);
diff --git a/mail/em-mailer-prefs.c b/mail/em-mailer-prefs.c
index e1f512ee57..e0044ed082 100644
--- a/mail/em-mailer-prefs.c
+++ b/mail/em-mailer-prefs.c
@@ -1108,7 +1108,7 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs,
char *gladefile;
prefs->shell = g_object_ref (shell);
- shell_settings = e_shell_get_settings (shell);
+ shell_settings = e_shell_get_shell_settings (shell);
gladefile = g_build_filename (EVOLUTION_GLADEDIR,
"mail-config.glade",
diff --git a/mail/em-message-browser.c b/mail/em-message-browser.c
deleted file mode 100644
index 8b3ff99152..0000000000
--- a/mail/em-message-browser.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Michael Zucchi <notzed@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#ifdef G_OS_WIN32
-/* Work around 'DATADIR' and 'interface' lossage in <windows.h> */
-#define DATADIR crap_DATADIR
-#include <windows.h>
-#undef DATADIR
-#undef interface
-#endif
-
-#include <gdk/gdkkeysyms.h>
-
-#include <gconf/gconf-client.h>
-
-#include <camel/camel-folder.h>
-
-#include <bonobo/bonobo-main.h>
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-window.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <bonobo/bonobo-ui-component.h>
-#include <bonobo/bonobo-ui-util.h>
-
-#include "e-util/e-util-private.h"
-
-#include "em-format-html-display.h"
-#include "em-message-browser.h"
-#include "em-menu.h"
-
-#define EM_MESSAGE_BROWSER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), EM_TYPE_MESSAGE_BROWSER, EMMessageBrowserPrivate))
-
-#define DEFAULT_WIDTH 600
-#define DEFAULT_HEIGHT 400
-
-struct _EMMessageBrowserPrivate {
- GtkWidget *preview; /* container for message display */
-};
-
-static gpointer parent_class;
-static GtkAllocation window_size = { 0, 0, 0, 0 };
-
-static void
-emmb_close (BonoboUIComponent *uid,
- gpointer data,
- const gchar *path)
-{
- EMMessageBrowser *emmb = data;
- GtkWidget *toplevel;
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (emmb));
- gtk_widget_destroy (toplevel);
-}
-
-static BonoboUIVerb emmb_verbs[] = {
- BONOBO_UI_UNSAFE_VERB ("MessageBrowserClose", emmb_close),
- BONOBO_UI_VERB_END
-};
-
-static void
-emmb_set_message (EMFolderView *emfv,
- const gchar *uid,
- gint nomarkseen)
-{
- EMMessageBrowser *emmb = EM_MESSAGE_BROWSER (emfv);
- EMFolderViewClass *folder_view_class;
- CamelMessageInfo *info;
-
- /* Chain up to parent's set_message() method. */
- folder_view_class = EM_FOLDER_VIEW_CLASS (parent_class);
- folder_view_class->set_message (emfv, uid, nomarkseen);
-
- if (uid == NULL) {
- gtk_widget_destroy (GTK_WIDGET (emfv));
- return;
- }
-
- info = camel_folder_get_message_info (emfv->folder, uid);
-
- if (info != NULL) {
- gtk_window_set_title (
- GTK_WINDOW (emmb->window),
- camel_message_info_subject (info));
- camel_folder_free_message_info (emfv->folder, info);
- }
-
- /* Well we don't know if it got displayed (yet) ... but whatever ... */
- if (!nomarkseen)
- camel_folder_set_message_flags (
- emfv->folder, uid,
- CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
-}
-
-static void
-emmb_activate (EMFolderView *emfv,
- BonoboUIComponent *uic,
- gint state)
-{
- EMFolderViewClass *folder_view_class;
-
- folder_view_class = EM_FOLDER_VIEW_CLASS (parent_class);
-
- if (state) {
- /* Chain up to parent's activate() method. */
- folder_view_class->activate (emfv, uic, state);
-
- bonobo_ui_component_add_verb_list_with_data (
- uic, emmb_verbs, emfv);
- bonobo_ui_component_set_prop(
- uic, "/commands/EditPaste", "sensitive", "0", NULL);
- } else {
- const BonoboUIVerb *verb;
-
- for (verb = &emmb_verbs[0]; verb->cname; verb++)
- bonobo_ui_component_remove_verb (uic, verb->cname);
-
- /* Chain up to parent's activate() method. */
- folder_view_class->activate (emfv, uic, state);
- }
-}
-
-static void
-emmb_list_message_selected_cb (struct _MessageList *ml,
- const gchar *uid,
- EMMessageBrowser *emmb)
-{
- EMFolderView *emfv = EM_FOLDER_VIEW (emmb);
- CamelMessageInfo *info;
-
- if (uid == NULL)
- return;
-
- info = camel_folder_get_message_info (emfv->folder, uid);
- if (info == NULL)
- return;
-
- gtk_window_set_title (
- GTK_WINDOW (emmb->window),
- camel_message_info_subject (info));
- gtk_widget_grab_focus (
- GTK_WIDGET (emfv->preview->formathtml.html));
-
- camel_folder_free_message_info (emfv->folder, info);
-}
-
-static void
-emmb_window_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GConfClient *client;
-
- /* FIXME Have GConfBridge handle this. */
-
- /* save to in-memory variable for current session access */
- window_size = *allocation;
-
- /* save the setting across sessions */
- client = gconf_client_get_default ();
- gconf_client_set_int (
- client, "/apps/evolution/mail/message_window/width",
- window_size.width, NULL);
- gconf_client_set_int (
- client, "/apps/evolution/mail/message_window/height",
- window_size.height, NULL);
- g_object_unref (client);
-}
-
-static int
-emmb_key_press_event_cb (EMMessageBrowser *emmb,
- GdkEventKey *event)
-{
- if (event->keyval == GDK_Escape) {
- GtkWidget *toplevel;
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (emmb));
- gtk_widget_destroy (toplevel);
- g_signal_stop_emission_by_name (emmb, "key-press-event");
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-emmb_destroy (GtkObject *gtk_object)
-{
- EMFolderView *emfv = EM_FOLDER_VIEW (gtk_object);
-
- if (emfv->list) {
- gtk_widget_destroy (GTK_WIDGET (emfv->list));
- emfv->list = NULL;
- }
-
- /* Chain up to parent's destroy() method. */
- GTK_OBJECT_CLASS (parent_class)->destroy (gtk_object);
-}
-
-static void
-emmb_class_init (EMMessageBrowserClass *class)
-{
- GtkObjectClass *gtk_object_class;
- EMFolderViewClass *folder_view_class;
-
- parent_class = g_type_class_peek_parent (class);
- g_type_class_add_private (class, sizeof (EMMessageBrowserPrivate));
-
- gtk_object_class = GTK_OBJECT_CLASS (class);
- gtk_object_class->destroy = emmb_destroy;
-
- folder_view_class = EM_FOLDER_VIEW_CLASS (class);
- folder_view_class->update_message_style = FALSE;
- folder_view_class->set_message = emmb_set_message;
- folder_view_class->activate = emmb_activate;
-}
-
-static void
-emmb_init (EMMessageBrowser *emmb)
-{
- EMFolderView *emfv = EM_FOLDER_VIEW (emmb);
- GtkWidget *widget;
- gchar *filename;
-
- emmb->priv = EM_MESSAGE_BROWSER_GET_PRIVATE (emmb);
-
- emfv->preview_active = TRUE;
-
- g_slist_foreach (emfv->ui_files, (GFunc) g_free, NULL);
- g_slist_free (emfv->ui_files);
- emfv->ui_files = NULL;
-
- filename = g_build_filename (
- EVOLUTION_UIDIR, "evolution-mail-messagedisplay.xml", NULL);
- emfv->ui_files = g_slist_append (emfv->ui_files, filename);
-
- filename = g_build_filename (
- EVOLUTION_UIDIR, "evolution-mail-message.xml", NULL);
- emfv->ui_files = g_slist_append (emfv->ui_files, filename);
-
- widget = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (
- GTK_SCROLLED_WINDOW (widget),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (
- GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
- gtk_widget_show (widget);
- emmb->priv->preview = widget;
-
- widget = GTK_WIDGET (emfv->preview->formathtml.html);
- gtk_container_add (GTK_CONTAINER (emmb->priv->preview), widget);
- gtk_widget_show (widget);
-
- gtk_box_pack_start (
- GTK_BOX (emmb), emmb->priv->preview, TRUE, TRUE, 0);
- gtk_box_pack_start(
- GTK_BOX (emmb), em_format_html_get_search_dialog (
- emfv->preview), FALSE, FALSE, 0);
-
- /** @HookPoint-EMMenu: Standalone Message View Menu
- * @Id: org.gnome.evolution.mail.messagebrowser
- * @Class: org.gnome.evolution.mail.bonobomenu:1.0
- * @Target: EMMenuTargetSelect
- *
- * The main menu of standalone message viewer.
- */
- EM_FOLDER_VIEW (emmb)->menu =
- em_menu_new ("org.gnome.evolution.mail.messagebrowser");
-}
-
-GType
-em_message_browser_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo type_info = {
- sizeof (EMMessageBrowserClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) emmb_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (EMMessageBrowser),
- 0, /* n_preallocs */
- (GInstanceInitFunc) emmb_init,
- NULL /* value_table */
- };
-
- type = g_type_register_static (
- EM_TYPE_FOLDER_VIEW, "EMMessageBrowser",
- &type_info, 0);
- }
-
- return type;
-}
-
-GtkWidget *
-em_message_browser_new (void)
-{
- return g_object_new (EM_TYPE_MESSAGE_BROWSER, NULL);
-}
-
-GtkWidget *
-em_message_browser_window_new (void)
-{
- EMMessageBrowser *emmb;
- BonoboUIContainer *uicont;
- BonoboUIComponent *uic;
-
- emmb = (EMMessageBrowser *) em_message_browser_new ();
- gtk_widget_show (GTK_WIDGET (emmb));
-
- /* FIXME: title set elsewhere? */
- emmb->window = g_object_new (
- BONOBO_TYPE_WINDOW, "title", "Evolution", NULL);
- bonobo_window_set_contents (
- BONOBO_WINDOW (emmb->window), GTK_WIDGET (emmb));
-
- uic = bonobo_ui_component_new_default ();
- uicont = bonobo_window_get_ui_container (BONOBO_WINDOW (emmb->window));
- bonobo_ui_component_set_container (uic, BONOBO_OBJREF (uicont), NULL);
-
- em_folder_view_activate (EM_FOLDER_VIEW (emmb), uic, TRUE);
-
- if (window_size.width == 0) {
- /* initialize @window_size with the previous session's size */
-
- /* FIXME Have GConfBridge handle this. */
-
- GConfClient *client;
- GError *error = NULL;
-
- client = gconf_client_get_default ();
-
- window_size.width = gconf_client_get_int (
- client, "/apps/evolution/mail/message_window/width",
- &error);
- if (error != NULL) {
- window_size.width = DEFAULT_WIDTH;
- g_clear_error (&error);
- }
-
- window_size.height = gconf_client_get_int (
- client, "/apps/evolution/mail/message_window/height",
- &error);
- if (error != NULL) {
- window_size.height = DEFAULT_HEIGHT;
- g_clear_error (&error);
- }
-
- g_object_unref (client);
- }
-
- gtk_window_set_default_size (
- GTK_WINDOW (emmb->window),
- window_size.width, window_size.height);
-
- g_signal_connect (
- emmb->window, "size-allocate",
- G_CALLBACK (emmb_window_size_allocate), NULL);
- g_signal_connect (
- EM_FOLDER_VIEW (emmb)->list, "message_selected",
- G_CALLBACK (emmb_list_message_selected_cb), emmb);
- g_signal_connect (
- emmb, "key-press-event",
- G_CALLBACK (emmb_key_press_event_cb), NULL);
-
- /* cleanup? */
-
- return GTK_WIDGET (emmb);
-}
diff --git a/mail/em-message-browser.h b/mail/em-message-browser.h
deleted file mode 100644
index cf00a74a75..0000000000
--- a/mail/em-message-browser.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef EM_MESSAGE_BROWSER_H
-#define EM_MESSAGE_BROWSER_H
-
-#include <gtk/gtk.h>
-#include "em-folder-view.h"
-
-/* Standard GObject macros */
-#define EM_TYPE_MESSAGE_BROWSER \
- (em_message_browser_get_type ())
-#define EM_MESSAGE_BROWSER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), EM_TYPE_MESSAGE_BROWSER, EMMessageBrowser))
-#define EM_MESSAGE_BROWSER_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), EM_TYPE_MESSAGE_BROWSER, EMMessageBrowserClass))
-#define EM_IS_MESSAGE_BROWSER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), EM_TYPE_MESSAGE_BROWSER))
-#define EM_IS_MESSAGE_BROWSER_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), EM_TYPE_MESSAGE_BROWSER))
-#define EM_MESSAGE_BROWSER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), EM_TYPE_MESSAGE_BROWSER, EMMessageBrowserClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EMMessageBrowser EMMessageBrowser;
-typedef struct _EMMessageBrowserClass EMMessageBrowserClass;
-typedef struct _EMMessageBrowserPrivate EMMessageBrowserPrivate;
-
-struct _EMMessageBrowser {
- EMFolderView parent;
-
- /* container, if setup */
- GtkWidget *window;
-
- EMMessageBrowserPrivate *priv;
-};
-
-struct _EMMessageBrowserClass {
- EMFolderViewClass parent_class;
-};
-
-GType em_message_browser_get_type (void);
-
-GtkWidget * em_message_browser_new (void);
-
-/* Also sets up a bonobo container window w/ docks and so on. */
-GtkWidget * em_message_browser_window_new (void);
-
-G_END_DECLS
-
-#endif /* EM_MESSAGE_BROWSER_H */
diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c
index bde5a84084..4c02ba3709 100644
--- a/shell/e-shell-content.c
+++ b/shell/e-shell-content.c
@@ -459,35 +459,35 @@ shell_content_dispose (GObject *object)
priv->filter_label = NULL;
}
- if (priv->filter_combo_box != NULL) {
- g_object_unref (priv->filter_combo_box);
- priv->filter_combo_box = NULL;
- }
+ if (priv->filter_combo_box != NULL) {
+ g_object_unref (priv->filter_combo_box);
+ priv->filter_combo_box = NULL;
+ }
if (priv->search_context != NULL) {
g_object_unref (priv->search_context);
priv->search_context = NULL;
}
- if (priv->search_label != NULL) {
- g_object_unref (priv->search_label);
- priv->search_label = NULL;
- }
-
- if (priv->search_entry != NULL) {
- g_object_unref (priv->search_entry);
- priv->search_entry = NULL;
- }
-
- if (priv->scope_label != NULL) {
- g_object_unref (priv->scope_label);
- priv->scope_label = NULL;
- }
-
- if (priv->scope_combo_box != NULL) {
- g_object_unref (priv->scope_combo_box);
- priv->scope_combo_box = NULL;
- }
+ if (priv->search_label != NULL) {
+ g_object_unref (priv->search_label);
+ priv->search_label = NULL;
+ }
+
+ if (priv->search_entry != NULL) {
+ g_object_unref (priv->search_entry);
+ priv->search_entry = NULL;
+ }
+
+ if (priv->scope_label != NULL) {
+ g_object_unref (priv->scope_label);
+ priv->scope_label = NULL;
+ }
+
+ if (priv->scope_combo_box != NULL) {
+ g_object_unref (priv->scope_combo_box);
+ priv->scope_combo_box = NULL;
+ }
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (parent_class)->dispose (object);
diff --git a/shell/e-shell-migrate.c b/shell/e-shell-migrate.c
index 9979899563..b4467028f4 100644
--- a/shell/e-shell-migrate.c
+++ b/shell/e-shell-migrate.c
@@ -56,7 +56,7 @@ shell_migrate_attempt (EShell *shell,
GList *modules;
gboolean success = TRUE;
- modules = e_shell_list_modules (shell);
+ modules = e_shell_get_shell_modules (shell);
while (success && modules != NULL) {
EShellModule *shell_module = modules->data;
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index dc4307fe5c..cf513669c8 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -863,7 +863,7 @@ action_new_window_cb (GtkAction *action,
EShell *shell;
shell = e_shell_window_get_shell (shell_window);
- e_shell_create_window (shell);
+ e_shell_create_shell_window (shell);
}
/**
@@ -1970,7 +1970,7 @@ e_shell_window_create_switcher_actions (EShellWindow *shell_window)
ui_manager = e_shell_window_get_ui_manager (shell_window);
merge_id = gtk_ui_manager_new_merge_id (ui_manager);
shell = e_shell_window_get_shell (shell_window);
- list = e_shell_list_modules (shell);
+ list = e_shell_get_shell_modules (shell);
/* Construct a group of radio actions from the various EShellView
* subclasses and register them with the EShellSwitcher. These
diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c
index a1027e437c..6fcdc2b6fc 100644
--- a/shell/e-shell-window-private.c
+++ b/shell/e-shell-window-private.c
@@ -173,6 +173,7 @@ e_shell_window_private_init (EShellWindow *shell_window)
{
EShellWindowPrivate *priv = shell_window->priv;
GHashTable *loaded_views;
+ GArray *signal_handler_ids;
GtkAccelGroup *accel_group;
GtkToolItem *item;
GtkWidget *container;
@@ -185,6 +186,8 @@ e_shell_window_private_init (EShellWindow *shell_window)
(GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
+ signal_handler_ids = g_array_new (FALSE, FALSE, sizeof (gulong));
+
priv->ui_manager = gtk_ui_manager_new ();
priv->shell_actions = gtk_action_group_new ("shell");
priv->gal_view_actions = gtk_action_group_new ("gal-view");
@@ -194,6 +197,7 @@ e_shell_window_private_init (EShellWindow *shell_window)
priv->switcher_actions = gtk_action_group_new ("switcher");
priv->loaded_views = loaded_views;
priv->active_view = "unknown";
+ priv->signal_handler_ids = signal_handler_ids;
merge_id = gtk_ui_manager_new_merge_id (priv->ui_manager);
priv->custom_rule_merge_id = merge_id;
@@ -369,6 +373,21 @@ e_shell_window_private_dispose (EShellWindow *shell_window)
{
EShellWindowPrivate *priv = shell_window->priv;
+ /* Need to disconnect handlers before we unref the shell. */
+ if (priv->signal_handler_ids != NULL) {
+ GArray *array = priv->signal_handler_ids;
+ gulong handler_id;
+ guint ii;
+
+ for (ii = 0; ii < array->len; ii++) {
+ handler_id = g_array_index (array, gulong, ii);
+ g_signal_handler_disconnect (priv->shell, handler_id);
+ }
+
+ g_array_free (array, TRUE);
+ priv->signal_handler_ids = NULL;
+ }
+
DISPOSE (priv->shell);
DISPOSE (priv->ui_manager);
diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h
index a31640d347..ea69968344 100644
--- a/shell/e-shell-window-private.h
+++ b/shell/e-shell-window-private.h
@@ -99,6 +99,9 @@ struct _EShellWindowPrivate {
/* Miscellaneous */
+ /* Shell signal handlers. */
+ GArray *signal_handler_ids;
+
guint destroyed : 1; /* XXX Do we still need this? */
guint safe_mode : 1;
};
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index a110bad82f..ef36b0e9c9 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -129,17 +129,57 @@ shell_window_online_mode_notify_cb (EShell *shell,
}
static void
+shell_window_update_close_action_cb (EShellWindow *shell_window)
+{
+ EShell *shell;
+ GList *shell_windows;
+ gboolean sensitive;
+
+ shell = e_shell_window_get_shell (shell_window);
+ shell_windows = e_shell_get_shell_windows (shell);
+ g_return_if_fail (shell_windows != NULL);
+
+ /* Disable Close Window if there's only one window.
+ * Helps prevent users from accidentally quitting. */
+ sensitive = (g_list_length (shell_windows) > 1);
+ gtk_action_set_sensitive (ACTION (CLOSE), sensitive);
+}
+
+static void
shell_window_set_shell (EShellWindow *shell_window,
EShell *shell)
{
+ GArray *array;
+ gulong handler_id;
+
g_return_if_fail (shell_window->priv->shell == NULL);
shell_window->priv->shell = g_object_ref (shell);
- g_signal_connect (
+ /* Need to disconnect these when the window is closing. */
+
+ array = shell_window->priv->signal_handler_ids;
+
+ handler_id = g_signal_connect (
shell, "notify::online-mode",
G_CALLBACK (shell_window_online_mode_notify_cb),
shell_window);
+ g_array_append_val (array, handler_id);
+
+ handler_id = g_signal_connect_swapped (
+ shell, "window-created",
+ G_CALLBACK (shell_window_update_close_action_cb),
+ shell_window);
+
+ g_array_append_val (array, handler_id);
+
+ handler_id = g_signal_connect_swapped (
+ shell, "window-destroyed",
+ G_CALLBACK (shell_window_update_close_action_cb),
+ shell_window);
+
+ g_array_append_val (array, handler_id);
+
g_object_notify (G_OBJECT (shell), "online-mode");
}
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 38cc875a17..09726d612d 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -58,7 +58,7 @@ enum {
PROP_0,
PROP_NETWORK_AVAILABLE,
PROP_ONLINE_MODE,
- PROP_SETTINGS
+ PROP_SHELL_SETTINGS
};
enum {
@@ -131,14 +131,12 @@ shell_window_weak_notify_cb (EShell *shell,
GObject *where_the_object_was)
{
GList *active_windows;
- gboolean last_window;
active_windows = shell->priv->active_windows;
active_windows = g_list_remove (active_windows, where_the_object_was);
shell->priv->active_windows = active_windows;
- last_window = (shell->priv->active_windows == NULL);
- g_signal_emit (shell, signals[WINDOW_DESTROYED], 0, last_window);
+ g_signal_emit (shell, signals[WINDOW_DESTROYED], 0);
}
static void
@@ -306,7 +304,7 @@ shell_shutdown_timeout (EShell *shell)
static guint message_timer = 1;
/* Module list is read-only; do not free. */
- list = e_shell_list_modules (shell);
+ list = e_shell_get_shell_modules (shell);
/* Any module can defer shutdown if it's still busy. */
for (iter = list; proceed && iter != NULL; iter = iter->next) {
@@ -387,9 +385,9 @@ shell_get_property (GObject *object,
E_SHELL (object)));
return;
- case PROP_SETTINGS:
+ case PROP_SHELL_SETTINGS:
g_value_set_object (
- value, e_shell_get_settings (
+ value, e_shell_get_shell_settings (
E_SHELL (object)));
return;
}
@@ -522,11 +520,11 @@ shell_class_init (EShellClass *class)
**/
g_object_class_install_property (
object_class,
- PROP_SETTINGS,
+ PROP_SHELL_SETTINGS,
g_param_spec_object (
- "settings",
- _("Settings"),
- _("Application settings"),
+ "shell-settings",
+ _("Shell Settings"),
+ _("Application-wide settings"),
E_TYPE_SHELL_SETTINGS,
G_PARAM_READABLE));
@@ -655,7 +653,6 @@ shell_class_init (EShellClass *class)
/**
* EShell::window-destroyed
* @shell: the #EShell which emitted the signal
- * @last_window: whether that was the last #EShellWindow
*
* Emitted when an #EShellWindow is destroyed.
**/
@@ -664,9 +661,8 @@ shell_class_init (EShellClass *class)
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
@@ -739,7 +735,7 @@ e_shell_get_default (void)
}
/**
- * e_shell_list_modules:
+ * e_shell_get_shell_modules:
* @shell: an #EShell
*
* Returns a list of loaded #EShellModule instances. The list is
@@ -748,7 +744,7 @@ e_shell_get_default (void)
* Returns: a list of loaded #EShellModule instances
**/
GList *
-e_shell_list_modules (EShell *shell)
+e_shell_get_shell_modules (EShell *shell)
{
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
@@ -756,6 +752,26 @@ e_shell_list_modules (EShell *shell)
}
/**
+ * e_shell_get_shell_windows:
+ * @shell: an #EShell
+ *
+ * Returns a list of active #EShellWindow instances that were created by
+ * e_shell_create_shell_window(). The list is sorted by the most recently
+ * focused window, such that the first instance is the currently focused
+ * window. (Useful for choosing a parent for a transient window.) The
+ * list is owned by @shell and should not be modified or freed.
+ *
+ * Returns: a list of active #EShellWindow instances
+ **/
+GList *
+e_shell_get_shell_windows (EShell *shell)
+{
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
+ return shell->priv->active_windows;
+}
+
+/**
* e_shell_get_canonical_name:
* @shell: an #EShell
* @name: the name or alias of an #EShellModule
@@ -834,9 +850,8 @@ e_shell_get_module_by_scheme (EShell *shell,
return g_hash_table_lookup (hash_table, scheme);
}
-
/**
- * e_shell_get_settings:
+ * e_shell_get_shell_settings:
* @shell: an #EShell
*
* Returns the #EShellSettings instance for @shell.
@@ -844,7 +859,7 @@ e_shell_get_module_by_scheme (EShell *shell,
* Returns: the #EShellSettings instance for @shell
**/
EShellSettings *
-e_shell_get_settings (EShell *shell)
+e_shell_get_shell_settings (EShell *shell)
{
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
@@ -852,7 +867,7 @@ e_shell_get_settings (EShell *shell)
}
/**
- * e_shell_create_window:
+ * e_shell_create_shell_window:
* @shell: an #EShell
*
* Creates a new #EShellWindow and emits the #EShell::window-created
@@ -862,7 +877,7 @@ e_shell_get_settings (EShell *shell)
* Returns: a new #EShellWindow
**/
GtkWidget *
-e_shell_create_window (EShell *shell)
+e_shell_create_shell_window (EShell *shell)
{
GList *active_windows;
GtkWidget *shell_window;
@@ -895,27 +910,6 @@ e_shell_create_window (EShell *shell)
}
/**
- * e_shell_get_focused_window:
- * @shell: an #EShell
- *
- * Returns the most recently focused #EShellWindow. Useful for choosing
- * a parent for a transient window. This only works for windows created
- * with e_shell_create_window().
- *
- * Returns: the most recently focused #EShellWindow
- **/
-GtkWidget *
-e_shell_get_focused_window (EShell *shell)
-{
- g_return_val_if_fail (E_IS_SHELL (shell), NULL);
-
- if (shell->priv->active_windows == NULL)
- return NULL;
-
- return GTK_WIDGET (shell->priv->active_windows->data);
-}
-
-/**
* e_shell_handle_uri:
* @shell: an #EShell
* @uri: the URI to be handled
diff --git a/shell/e-shell.h b/shell/e-shell.h
index e482f93960..1503ca776b 100644
--- a/shell/e-shell.h
+++ b/shell/e-shell.h
@@ -76,16 +76,16 @@ struct _EShellClass {
GType e_shell_get_type (void);
EShell * e_shell_get_default (void);
-GList * e_shell_list_modules (EShell *shell);
+GList * e_shell_get_shell_modules (EShell *shell);
+GList * e_shell_get_shell_windows (EShell *shell);
const gchar * e_shell_get_canonical_name (EShell *shell,
const gchar *name);
EShellModule * e_shell_get_module_by_name (EShell *shell,
const gchar *name);
EShellModule * e_shell_get_module_by_scheme (EShell *shell,
const gchar *scheme);
-EShellSettings *e_shell_get_settings (EShell *shell);
-GtkWidget * e_shell_create_window (EShell *shell);
-GtkWidget * e_shell_get_focused_window (EShell *shell);
+EShellSettings *e_shell_get_shell_settings (EShell *shell);
+GtkWidget * e_shell_create_shell_window (EShell *shell);
gboolean e_shell_handle_uri (EShell *shell,
const gchar *uri);
void e_shell_send_receive (EShell *shell,
diff --git a/shell/main.c b/shell/main.c
index b078320c32..3c51bc1c46 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -317,7 +317,7 @@ idle_cb (gchar **uris)
g_object_unref (client);
}
- shell_window = e_shell_create_window (shell);
+ shell_window = e_shell_create_shell_window (shell);
#if 0 /* MBARNES */
if (shell == NULL) {
@@ -462,10 +462,9 @@ set_paths (void)
#endif
static void
-shell_window_destroyed_cb (EShell *shell,
- gboolean last_window)
+shell_window_destroyed_cb (EShell *shell)
{
- if (last_window)
+ if (e_shell_get_shell_windows (shell) == NULL)
gtk_main_quit ();
}
diff --git a/shell/test/e-test-shell-module.c b/shell/test/e-test-shell-module.c
index 6b2c5c4179..fc489fa3b0 100644
--- a/shell/test/e-test-shell-module.c
+++ b/shell/test/e-test-shell-module.c
@@ -133,10 +133,9 @@ test_module_window_created_cb (EShellModule *shell_module,
}
static void
-test_module_window_destroyed_cb (EShellModule *shell_module,
- gboolean last_window)
+test_module_window_destroyed_cb (EShellModule *shell_module)
{
- g_debug ("%s (last=%d)", G_STRFUNC, last_window);
+ g_debug ("%s", G_STRFUNC);
}
static EShellModuleInfo module_info = {