[evolution/kill-bonobo] Get the "Hide Deleted Messages" option working.



commit 0b04c6cfd743afcf5a4e6a195a120776074cb2a7
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Apr 28 19:19:47 2009 -0400

    Get the "Hide Deleted Messages" option working.
---
 mail/e-mail-browser.c            |   61 ++++++++++++++++++++++++++++++++++++-
 mail/e-mail-browser.h            |    3 ++
 mail/e-mail-shell-content.c      |   56 +++++++++++++++++++++++++++++++++-
 mail/e-mail-shell-content.h      |    5 +++
 mail/e-mail-shell-view-actions.c |   17 +++++++++-
 mail/e-mail-shell-view-private.h |    2 +
 mail/e-mail-shell-view.h         |    5 +++
 7 files changed, 143 insertions(+), 6 deletions(-)

diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index 4088538..69ccc54 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -54,11 +54,14 @@ struct _EMailBrowserPrivate {
 	GtkWidget *message_list;
 	GtkWidget *search_bar;
 	GtkWidget *statusbar;
+
+	guint show_deleted : 1;
 };
 
 enum {
 	PROP_0,
 	PROP_SHELL_MODULE,
+	PROP_SHOW_DELETED,
 	PROP_UI_MANAGER
 };
 
@@ -257,6 +260,12 @@ mail_browser_set_property (GObject *object,
 				E_MAIL_BROWSER (object),
 				g_value_get_object (value));
 			return;
+
+		case PROP_SHOW_DELETED:
+			e_mail_browser_set_show_deleted (
+				E_MAIL_BROWSER (object),
+				g_value_get_boolean (value));
+			return;
 	}
 
 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -275,6 +284,12 @@ mail_browser_get_property (GObject *object,
 				E_MAIL_READER (object)));
 			return;
 
+		case PROP_SHOW_DELETED:
+			g_value_set_boolean (
+				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 (
@@ -349,6 +364,7 @@ mail_browser_constructed (GObject *object)
 	EMailReader *reader;
 	EShellModule *shell_module;
 	EShell *shell;
+	GConfBridge *bridge;
 	GtkAccelGroup *accel_group;
 	GtkActionGroup *action_group;
 	GtkUIManager *ui_manager;
@@ -356,6 +372,7 @@ mail_browser_constructed (GObject *object)
 	GtkWidget *widget;
 	GtkHTML *html;
 	const gchar *domain;
+	const gchar *key;
 	guint merge_id;
 
 	priv = E_MAIL_BROWSER_GET_PRIVATE (object);
@@ -455,6 +472,14 @@ mail_browser_constructed (GObject *object)
 	widget = GTK_WIDGET (EM_FORMAT_HTML (html_display)->html);
 	gtk_container_add (GTK_CONTAINER (container), widget);
 	gtk_widget_show (widget);
+
+	/* Bind GObject properties to GConf keys. */
+
+	bridge = gconf_bridge_get ();
+
+	object = G_OBJECT (reader);
+	key = "/apps/evolution/mail/display/show_deleted";
+	gconf_bridge_bind_property (bridge, key, object, "show-deleted");
 }
 
 static gboolean
@@ -484,8 +509,11 @@ mail_browser_get_action_group (EMailReader *reader)
 static gboolean
 mail_browser_get_hide_deleted (EMailReader *reader)
 {
-	/* FIXME */
-	return FALSE;
+	EMailBrowser *browser;
+
+	browser = E_MAIL_BROWSER (reader);
+
+	return !e_mail_browser_get_show_deleted (browser);
 }
 
 static EMFormatHTMLDisplay *
@@ -597,6 +625,16 @@ mail_browser_class_init (EMailBrowserClass *class)
 			E_TYPE_SHELL_MODULE,
 			G_PARAM_READWRITE |
 			G_PARAM_CONSTRUCT_ONLY));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SHOW_DELETED,
+		g_param_spec_boolean (
+			"show-deleted",
+			_("Show Deleted"),
+			_("Show deleted messages"),
+			FALSE,
+			G_PARAM_READWRITE));
 }
 
 static void
@@ -684,6 +722,25 @@ e_mail_browser_close (EMailBrowser *browser)
 	gtk_widget_destroy (GTK_WIDGET (browser));
 }
 
+gboolean
+e_mail_browser_get_show_deleted (EMailBrowser *browser)
+{
+	g_return_val_if_fail (E_IS_MAIL_BROWSER (browser), FALSE);
+
+	return browser->priv->show_deleted;
+}
+
+void
+e_mail_browser_set_show_deleted (EMailBrowser *browser,
+                                 gboolean show_deleted)
+{
+	g_return_if_fail (E_IS_MAIL_BROWSER (browser));
+
+	browser->priv->show_deleted = show_deleted;
+
+	g_object_notify (G_OBJECT (browser), "show-deleted");
+}
+
 GtkUIManager *
 e_mail_browser_get_ui_manager (EMailBrowser *browser)
 {
diff --git a/mail/e-mail-browser.h b/mail/e-mail-browser.h
index 35040f0..bcc8870 100644
--- a/mail/e-mail-browser.h
+++ b/mail/e-mail-browser.h
@@ -62,6 +62,9 @@ struct _EMailBrowserClass {
 GType		e_mail_browser_get_type		(void);
 GtkWidget *	e_mail_browser_new		(EShellModule *shell_module);
 void		e_mail_browser_close		(EMailBrowser *browser);
+gboolean	e_mail_browser_get_show_deleted	(EMailBrowser *browser);
+void		e_mail_browser_set_show_deleted (EMailBrowser *browser,
+						 gboolean show_deleted);
 GtkUIManager *	e_mail_browser_get_ui_manager	(EMailBrowser *browser);
 
 G_END_DECLS
diff --git a/mail/e-mail-shell-content.c b/mail/e-mail-shell-content.c
index 0f7e91f..9f6de12 100644
--- a/mail/e-mail-shell-content.c
+++ b/mail/e-mail-shell-content.c
@@ -67,11 +67,13 @@ struct _EMailShellContentPrivate {
 	guint preview_visible			: 1;
 	guint suppress_message_selection	: 1;
 	guint vertical_view			: 1;
+	guint show_deleted			: 1;
 };
 
 enum {
 	PROP_0,
 	PROP_PREVIEW_VISIBLE,
+	PROP_SHOW_DELETED,
 	PROP_VERTICAL_VIEW
 };
 
@@ -258,6 +260,12 @@ mail_shell_content_set_property (GObject *object,
 				g_value_get_boolean (value));
 			return;
 
+		case PROP_SHOW_DELETED:
+			e_mail_shell_content_set_show_deleted (
+				E_MAIL_SHELL_CONTENT (object),
+				g_value_get_boolean (value));
+			return;
+
 		case PROP_VERTICAL_VIEW:
 			e_mail_shell_content_set_vertical_view (
 				E_MAIL_SHELL_CONTENT (object),
@@ -282,6 +290,13 @@ mail_shell_content_get_property (GObject *object,
 				E_MAIL_SHELL_CONTENT (object)));
 			return;
 
+		case PROP_SHOW_DELETED:
+			g_value_set_boolean (
+				value,
+				e_mail_shell_content_get_show_deleted (
+				E_MAIL_SHELL_CONTENT (object)));
+			return;
+
 		case PROP_VERTICAL_VIEW:
 			g_value_set_boolean (
 				value,
@@ -427,6 +442,10 @@ mail_shell_content_constructed (GObject *object)
 	key = "/apps/evolution/mail/display/paned_size";
 	gconf_bridge_bind_property_delayed (bridge, key, object, "position");
 
+	object = G_OBJECT (shell_content);
+	key = "/apps/evolution/mail/display/show_deleted";
+	gconf_bridge_bind_property (bridge, key, object, "show-deleted");
+
 	/* Message list customizations. */
 
 	reader = E_MAIL_READER (shell_content);
@@ -461,8 +480,11 @@ mail_shell_content_get_action_group (EMailReader *reader)
 static gboolean
 mail_shell_content_get_hide_deleted (EMailReader *reader)
 {
-	/* FIXME */
-	return TRUE;
+	EMailShellContent *mail_shell_content;
+
+	mail_shell_content = E_MAIL_SHELL_CONTENT (reader);
+
+	return !e_mail_shell_content_get_show_deleted (mail_shell_content);
 }
 
 static EMFormatHTMLDisplay *
@@ -609,6 +631,16 @@ mail_shell_content_class_init (EMailShellContentClass *class)
 
 	g_object_class_install_property (
 		object_class,
+		PROP_SHOW_DELETED,
+		g_param_spec_boolean (
+			"show-deleted",
+			"Show Deleted",
+			NULL,
+			FALSE,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property (
+		object_class,
 		PROP_VERTICAL_VIEW,
 		g_param_spec_boolean (
 			"vertical-view",
@@ -723,6 +755,26 @@ e_mail_shell_content_set_preview_visible (EMailShellContent *mail_shell_content,
 }
 
 gboolean
+e_mail_shell_content_get_show_deleted (EMailShellContent *mail_shell_content)
+{
+	g_return_val_if_fail (
+		E_IS_MAIL_SHELL_CONTENT (mail_shell_content), FALSE);
+
+	return mail_shell_content->priv->show_deleted;
+}
+
+void
+e_mail_shell_content_set_show_deleted (EMailShellContent *mail_shell_content,
+                                       gboolean show_deleted)
+{
+	g_return_if_fail (E_IS_MAIL_SHELL_CONTENT (mail_shell_content));
+
+	mail_shell_content->priv->show_deleted = show_deleted;
+
+	g_object_notify (G_OBJECT (mail_shell_content), "show-deleted");
+}
+
+gboolean
 e_mail_shell_content_get_vertical_view (EMailShellContent *mail_shell_content)
 {
 	g_return_val_if_fail (
diff --git a/mail/e-mail-shell-content.h b/mail/e-mail-shell-content.h
index a27e1a6..485a9a8 100644
--- a/mail/e-mail-shell-content.h
+++ b/mail/e-mail-shell-content.h
@@ -68,6 +68,11 @@ gboolean	e_mail_shell_content_get_preview_visible
 void		e_mail_shell_content_set_preview_visible
 						(EMailShellContent *mail_shell_content,
 						 gboolean preview_visible);
+gboolean	e_mail_shell_content_get_show_deleted
+						(EMailShellContent *mail_shell_content);
+void		e_mail_shell_content_set_show_deleted
+						(EMailShellContent *mail_shell_content,
+						 gboolean show_deleted);
 gboolean	e_mail_shell_content_get_vertical_view
 						(EMailShellContent *mail_shell_content);
 void		e_mail_shell_content_set_vertical_view
diff --git a/mail/e-mail-shell-view-actions.c b/mail/e-mail-shell-view-actions.c
index 0355a96..600d8e8 100644
--- a/mail/e-mail-shell-view-actions.c
+++ b/mail/e-mail-shell-view-actions.c
@@ -396,8 +396,15 @@ static void
 action_mail_hide_deleted_cb (GtkToggleAction *action,
                              EMailShellView *mail_shell_view)
 {
-	/* FIXME */
-	g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+	MessageList *message_list;
+	EMailReader *reader;
+	gboolean active;
+
+	reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
+	message_list = e_mail_reader_get_message_list (reader);
+
+	active = gtk_toggle_action_get_active (action);
+	message_list_set_hidedeleted (message_list, active);
 }
 
 static void
@@ -1447,6 +1454,12 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
 	dst_object = G_OBJECT (ACTION (MAIL_THREADS_EXPAND_ALL));
 	e_binding_new (src_object, "active", dst_object, "sensitive");
 
+	/* XXX The boolean sense of the GConf key is the inverse of
+	 *     the menu item, so we have to maintain two properties. */
+	e_mutual_binding_new_with_negation (
+		G_OBJECT (shell_content), "show-deleted",
+		G_OBJECT (ACTION (MAIL_HIDE_DELETED)), "active");
+
 	g_signal_connect (
 		ACTION (GAL_SAVE_CUSTOM_VIEW), "activate",
 		G_CALLBACK (action_gal_save_custom_view_cb), mail_shell_view);
diff --git a/mail/e-mail-shell-view-private.h b/mail/e-mail-shell-view-private.h
index 8568438..97bb638 100644
--- a/mail/e-mail-shell-view-private.h
+++ b/mail/e-mail-shell-view-private.h
@@ -131,6 +131,8 @@ struct _EMailShellViewPrivate {
 
 	/* Filter rules correspond to the search entry menu. */
 	FilterRule *search_rules[MAIL_NUM_SEARCH_RULES];
+
+	guint show_deleted : 1;
 };
 
 void		e_mail_shell_view_private_init
diff --git a/mail/e-mail-shell-view.h b/mail/e-mail-shell-view.h
index 62f3f78..2c5a364 100644
--- a/mail/e-mail-shell-view.h
+++ b/mail/e-mail-shell-view.h
@@ -65,6 +65,11 @@ struct _EMailShellViewClass {
 
 GType		e_mail_shell_view_get_type
 					(GTypeModule *type_module);
+gboolean	e_mail_shell_view_get_show_deleted
+					(EMailShellView *mail_shell_view);
+void		e_mail_shell_view_set_show_deleted
+					(EMailShellView *mail_shell_view,
+					 gboolean show_deleted);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]