diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-06-04 20:36:21 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-06-05 01:38:46 +0800 |
commit | 2424fc184189430b8b33f2f876c0916f12808504 (patch) | |
tree | e943fcdda704d568e452470cf0f613b5b78a80e6 /mail | |
parent | 37f600d4bbd849e7f4bd617ad7378880cf47a0a6 (diff) | |
download | gsoc2013-evolution-2424fc184189430b8b33f2f876c0916f12808504.tar gsoc2013-evolution-2424fc184189430b8b33f2f876c0916f12808504.tar.gz gsoc2013-evolution-2424fc184189430b8b33f2f876c0916f12808504.tar.bz2 gsoc2013-evolution-2424fc184189430b8b33f2f876c0916f12808504.tar.lz gsoc2013-evolution-2424fc184189430b8b33f2f876c0916f12808504.tar.xz gsoc2013-evolution-2424fc184189430b8b33f2f876c0916f12808504.tar.zst gsoc2013-evolution-2424fc184189430b8b33f2f876c0916f12808504.zip |
EMailBrowser cleanups.
(cherry picked from commit f150d051191a2b7661e957b40246c0aff213e7b7)
Conflicts:
mail/e-mail-browser.c
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-browser.c | 215 | ||||
-rw-r--r-- | mail/e-mail-browser.h | 7 |
2 files changed, 119 insertions, 103 deletions
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c index 36aa126443..349790cc24 100644 --- a/mail/e-mail-browser.c +++ b/mail/e-mail-browser.c @@ -28,14 +28,16 @@ #include <string.h> #include <glib/gi18n.h> -#include "shell/e-shell.h" -#include "shell/e-shell-utils.h" -#include "shell/e-shell-settings.h" +#include <shell/e-shell.h> +#include <shell/e-shell-utils.h> +#include <shell/e-shell-settings.h> -#include "mail/e-mail-reader.h" -#include "mail/e-mail-reader-utils.h" -#include "mail/em-folder-tree-model.h" -#include "mail/message-list.h" +#include <em-format/e-mail-formatter-enumtypes.h> + +#include "e-mail-reader.h" +#include "e-mail-reader-utils.h" +#include "em-folder-tree-model.h" +#include "message-list.h" #define E_MAIL_BROWSER_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -49,7 +51,7 @@ struct _EMailBrowserPrivate { GtkUIManager *ui_manager; EFocusTracker *focus_tracker; - EMailFormatterMode mode; + EMailFormatterMode display_mode; GtkWidget *main_menu; GtkWidget *main_toolbar; @@ -63,13 +65,13 @@ struct _EMailBrowserPrivate { enum { PROP_0, PROP_BACKEND, + PROP_DISPLAY_MODE, PROP_FOCUS_TRACKER, PROP_FORWARD_STYLE, PROP_GROUP_BY_THREADS, - PROP_SHOW_DELETED, PROP_REPLY_STYLE, - PROP_UI_MANAGER, - PROP_DISPLAY_MODE, + PROP_SHOW_DELETED, + PROP_UI_MANAGER }; /* This is too trivial to put in a file. @@ -301,7 +303,7 @@ mail_browser_message_list_built_cb (EMailBrowser *browser, g_return_if_fail (E_IS_MAIL_BROWSER (browser)); g_return_if_fail (IS_MESSAGE_LIST (message_list)); - if (!message_list_count (message_list)) + if (message_list_count (message_list) == 0) /* Prioritize ahead of GTK+ redraws. */ g_idle_add_full ( G_PRIORITY_HIGH_IDLE, @@ -366,6 +368,13 @@ mail_browser_set_backend (EMailBrowser *browser, } static void +mail_browser_set_display_mode (EMailBrowser *browser, + EMailFormatterMode display_mode) +{ + browser->priv->display_mode = display_mode; +} + +static void mail_browser_set_property (GObject *object, guint property_id, const GValue *value, @@ -378,6 +387,12 @@ mail_browser_set_property (GObject *object, g_value_get_object (value)); return; + case PROP_DISPLAY_MODE: + mail_browser_set_display_mode ( + E_MAIL_BROWSER (object), + g_value_get_enum (value)); + return; + case PROP_FORWARD_STYLE: e_mail_reader_set_forward_style ( E_MAIL_READER (object), @@ -401,11 +416,6 @@ mail_browser_set_property (GObject *object, E_MAIL_BROWSER (object), g_value_get_boolean (value)); return; - - case PROP_DISPLAY_MODE: - E_MAIL_BROWSER (object)->priv->mode = - g_value_get_int (value); - return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -420,50 +430,59 @@ mail_browser_get_property (GObject *object, switch (property_id) { case PROP_BACKEND: g_value_set_object ( - value, e_mail_reader_get_backend ( + value, + e_mail_reader_get_backend ( E_MAIL_READER (object))); return; + case PROP_DISPLAY_MODE: + g_value_set_enum ( + value, + e_mail_browser_get_display_mode ( + E_MAIL_BROWSER (object))); + return; + case PROP_FOCUS_TRACKER: g_value_set_object ( - value, e_mail_browser_get_focus_tracker ( + value, + e_mail_browser_get_focus_tracker ( E_MAIL_BROWSER (object))); return; case PROP_FORWARD_STYLE: g_value_set_enum ( - value, e_mail_reader_get_forward_style ( + value, + e_mail_reader_get_forward_style ( E_MAIL_READER (object))); return; case PROP_GROUP_BY_THREADS: g_value_set_boolean ( - value, e_mail_reader_get_group_by_threads ( + value, + e_mail_reader_get_group_by_threads ( E_MAIL_READER (object))); return; case PROP_REPLY_STYLE: g_value_set_enum ( - value, e_mail_reader_get_reply_style ( + value, + e_mail_reader_get_reply_style ( E_MAIL_READER (object))); return; case PROP_SHOW_DELETED: g_value_set_boolean ( - value, e_mail_browser_get_show_deleted ( + value, + e_mail_browser_get_show_deleted ( E_MAIL_BROWSER (object))); return; case PROP_UI_MANAGER: g_value_set_object ( - value, e_mail_browser_get_ui_manager ( + value, + e_mail_browser_get_ui_manager ( E_MAIL_BROWSER (object))); return; - - case PROP_DISPLAY_MODE: - g_value_set_int ( - value, E_MAIL_BROWSER (object)->priv->mode); - return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -476,30 +495,13 @@ mail_browser_dispose (GObject *object) priv = E_MAIL_BROWSER_GET_PRIVATE (object); - if (priv->backend != NULL) { - g_object_unref (priv->backend); - priv->backend = NULL; - } - - if (priv->ui_manager != NULL) { - g_object_unref (priv->ui_manager); - priv->ui_manager = NULL; - } - - if (priv->focus_tracker != NULL) { - g_object_unref (priv->focus_tracker); - priv->focus_tracker = NULL; - } - - if (priv->main_menu != NULL) { - g_object_unref (priv->main_menu); - priv->main_menu = NULL; - } - - if (priv->main_toolbar != NULL) { - g_object_unref (priv->main_toolbar); - priv->main_toolbar = NULL; - } + g_clear_object (&priv->backend); + g_clear_object (&priv->ui_manager); + g_clear_object (&priv->focus_tracker); + g_clear_object (&priv->main_menu); + g_clear_object (&priv->main_toolbar); + g_clear_object (&priv->preview_pane); + g_clear_object (&priv->statusbar); if (priv->message_list != NULL) { /* This will cancel a regen operation. */ @@ -507,16 +509,6 @@ mail_browser_dispose (GObject *object) priv->message_list = NULL; } - if (priv->preview_pane != NULL) { - g_object_unref (priv->preview_pane); - priv->preview_pane = NULL; - } - - if (priv->statusbar != NULL) { - g_object_unref (priv->statusbar); - priv->statusbar = NULL; - } - /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_mail_browser_parent_class)->dispose (object); } @@ -579,7 +571,7 @@ mail_browser_constructed (GObject *object) display = g_object_new ( E_TYPE_MAIL_DISPLAY, - "mode", E_MAIL_BROWSER (object)->priv->mode, NULL); + "display-mode", browser->priv->display_mode, NULL); g_signal_connect_swapped ( display, "popup-event", @@ -604,7 +596,6 @@ mail_browser_constructed (GObject *object) gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); /* For easy access. Takes ownership of the reference. */ - g_object_set_data_full ( object, ACTION_GROUP_STANDARD, action_group, (GDestroyNotify) g_object_unref); @@ -755,22 +746,23 @@ mail_browser_get_hide_deleted (EMailReader *reader) static EMailDisplay * mail_browser_get_mail_display (EMailReader *reader) { - EMailBrowserPrivate *priv; + EPreviewPane *preview_pane; + EWebView *web_view; - priv = E_MAIL_BROWSER_GET_PRIVATE (E_MAIL_BROWSER (reader)); + preview_pane = e_mail_reader_get_preview_pane (reader); + web_view = e_preview_pane_get_web_view (preview_pane); - return E_MAIL_DISPLAY (e_preview_pane_get_web_view ( - E_PREVIEW_PANE (priv->preview_pane))); + return E_MAIL_DISPLAY (web_view); } static GtkWidget * mail_browser_get_message_list (EMailReader *reader) { - EMailBrowser *browser; + EMailBrowserPrivate *priv; - browser = E_MAIL_BROWSER (reader); + priv = E_MAIL_BROWSER_GET_PRIVATE (reader); - return browser->priv->message_list; + return priv->message_list; } static GtkMenu * @@ -790,11 +782,11 @@ mail_browser_get_popup_menu (EMailReader *reader) static EPreviewPane * mail_browser_get_preview_pane (EMailReader *reader) { - EMailBrowser *browser; + EMailBrowserPrivate *priv; - browser = E_MAIL_BROWSER (reader); + priv = E_MAIL_BROWSER_GET_PRIVATE (reader); - return E_PREVIEW_PANE (browser->priv->preview_pane); + return E_PREVIEW_PANE (priv->preview_pane); } static GtkWindow * @@ -921,7 +913,21 @@ e_mail_browser_class_init (EMailBrowserClass *class) "The mail backend", E_TYPE_MAIL_BACKEND, G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property ( + object_class, + PROP_DISPLAY_MODE, + g_param_spec_enum ( + "display-mode", + "Display Mode", + NULL, + E_TYPE_MAIL_FORMATTER_MODE, + E_MAIL_FORMATTER_MODE_NORMAL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property ( object_class, @@ -931,7 +937,8 @@ e_mail_browser_class_init (EMailBrowserClass *class) "Focus Tracker", NULL, E_TYPE_FOCUS_TRACKER, - G_PARAM_READABLE)); + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); /* Inherited from EMailReader */ g_object_class_override_property ( @@ -959,19 +966,19 @@ e_mail_browser_class_init (EMailBrowserClass *class) "Show Deleted", "Show deleted messages", FALSE, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property ( object_class, - PROP_DISPLAY_MODE, - g_param_spec_int ( - "display-mode", - "Display Mode", + PROP_UI_MANAGER, + g_param_spec_object ( + "ui-manager", + "UI Manager", NULL, - 0, - G_MAXINT, - E_MAIL_FORMATTER_MODE_NORMAL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + GTK_TYPE_UI_MANAGER, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); } static void @@ -1007,19 +1014,15 @@ GtkWidget * e_mail_browser_new (EMailBackend *backend, CamelFolder *folder, const gchar *msg_uid, - EMailFormatterMode mode) + EMailFormatterMode display_mode) { - GtkWidget *widget; - g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL); - widget= g_object_new ( + return g_object_new ( E_TYPE_MAIL_BROWSER, "backend", backend, - "display-mode", mode, + "display-mode", display_mode, NULL); - - return widget; } void @@ -1030,6 +1033,24 @@ e_mail_browser_close (EMailBrowser *browser) gtk_widget_destroy (GTK_WIDGET (browser)); } +EMailFormatterMode +e_mail_browser_get_display_mode (EMailBrowser *browser) +{ + g_return_val_if_fail ( + E_IS_MAIL_BROWSER (browser), + E_MAIL_FORMATTER_MODE_INVALID); + + return browser->priv->display_mode; +} + +EFocusTracker * +e_mail_browser_get_focus_tracker (EMailBrowser *browser) +{ + g_return_val_if_fail (E_IS_MAIL_BROWSER (browser), NULL); + + return browser->priv->focus_tracker; +} + gboolean e_mail_browser_get_show_deleted (EMailBrowser *browser) { @@ -1052,14 +1073,6 @@ e_mail_browser_set_show_deleted (EMailBrowser *browser, g_object_notify (G_OBJECT (browser), "show-deleted"); } -EFocusTracker * -e_mail_browser_get_focus_tracker (EMailBrowser *browser) -{ - g_return_val_if_fail (E_IS_MAIL_BROWSER (browser), NULL); - - return browser->priv->focus_tracker; -} - GtkUIManager * e_mail_browser_get_ui_manager (EMailBrowser *browser) { diff --git a/mail/e-mail-browser.h b/mail/e-mail-browser.h index bd636cdaf2..fe7c6bfafd 100644 --- a/mail/e-mail-browser.h +++ b/mail/e-mail-browser.h @@ -64,12 +64,15 @@ GType e_mail_browser_get_type (void); GtkWidget * e_mail_browser_new (EMailBackend *backend, CamelFolder *folder, const gchar *message_uid, - EMailFormatterMode mode); + EMailFormatterMode display_mode); void e_mail_browser_close (EMailBrowser *browser); +EMailFormatterMode + e_mail_browser_get_display_mode (EMailBrowser *browser); +EFocusTracker * e_mail_browser_get_focus_tracker + (EMailBrowser *browser); gboolean e_mail_browser_get_show_deleted (EMailBrowser *browser); void e_mail_browser_set_show_deleted (EMailBrowser *browser, gboolean show_deleted); -EFocusTracker * e_mail_browser_get_focus_tracker (EMailBrowser *browser); GtkUIManager * e_mail_browser_get_ui_manager (EMailBrowser *browser); G_END_DECLS |