aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-content.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-06-10 11:15:20 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-06-13 22:49:05 +0800
commitbe8ee5393471a83b24aed4de1669afd723cb3168 (patch)
treef8a8e50d3830ec32f83fd2fa7e8815ebfc8316dc /shell/e-shell-content.c
parented0cdbd79042a962ec229f739b4c3284b00a4dc0 (diff)
downloadgsoc2013-evolution-be8ee5393471a83b24aed4de1669afd723cb3168.tar
gsoc2013-evolution-be8ee5393471a83b24aed4de1669afd723cb3168.tar.gz
gsoc2013-evolution-be8ee5393471a83b24aed4de1669afd723cb3168.tar.bz2
gsoc2013-evolution-be8ee5393471a83b24aed4de1669afd723cb3168.tar.lz
gsoc2013-evolution-be8ee5393471a83b24aed4de1669afd723cb3168.tar.xz
gsoc2013-evolution-be8ee5393471a83b24aed4de1669afd723cb3168.tar.zst
gsoc2013-evolution-be8ee5393471a83b24aed4de1669afd723cb3168.zip
Use key files for tracking widget states.
Each EShellView now maintains a GKeyFile for recording disposable widget state such as tree view path expansion, scroll bar positions, combo box selections, etc. The EShellView records changes to the key file to ~/.evolution/<shell-backend>/config/state, and automatically restores the GKeyFile at startup. Currently only the mailer uses the key file, but it's intended to serve all shell views. It replaces the use of Camel "cmeta" files, as well as "et-expanded-*" and "folder-tree-expand-state.xml" files. Also, the mailer's folder tree model now includes a column for tracking which sidebar folders are expanded. Folder tree widgets appearing in dialog windows can copy the sidebar's expanded state using em_folder_tree_clone_expanded().
Diffstat (limited to 'shell/e-shell-content.c')
-rw-r--r--shell/e-shell-content.c79
1 files changed, 75 insertions, 4 deletions
diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c
index 216520fbb4..2fc9569bd2 100644
--- a/shell/e-shell-content.c
+++ b/shell/e-shell-content.c
@@ -24,6 +24,7 @@
#include <glib/gi18n.h>
#include "e-util/e-binding.h"
+#include "e-util/e-util.h"
#include "filter/rule-editor.h"
#include "widgets/misc/e-action-combo-box.h"
#include "widgets/misc/e-hinted-entry.h"
@@ -36,6 +37,10 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_SHELL_CONTENT, EShellContentPrivate))
+#define STATE_KEY_SEARCH_FILTER "SearchFilter"
+#define STATE_KEY_SEARCH_SCOPE "SearchScope"
+#define STATE_KEY_SEARCH_TEXT "SearchText"
+
struct _EShellContentPrivate {
gpointer shell_view; /* weak pointer */
@@ -55,8 +60,6 @@ struct _EShellContentPrivate {
GtkWidget *search_entry;
GtkWidget *scope_label;
GtkWidget *scope_combo_box;
-
- GtkStateType search_state;
};
enum {
@@ -138,7 +141,10 @@ action_search_execute_cb (GtkAction *action,
/* Direct the focus away from the search entry, so that a
* focus-in event is required before the text can be changed.
* This will reset the entry to the appropriate visual state. */
- gtk_widget_grab_focus (gtk_bin_get_child (GTK_BIN (shell_content)));
+ widget = gtk_bin_get_child (GTK_BIN (shell_content));
+ if (GTK_IS_PANED (widget))
+ widget = gtk_paned_get_child1 (GTK_PANED (widget));
+ gtk_widget_grab_focus (widget);
}
static void
@@ -897,7 +903,6 @@ shell_content_init (EShellContent *shell_content)
gtk_label_set_mnemonic_widget (label, widget);
gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
shell_content->priv->search_entry = g_object_ref (widget);
- shell_content->priv->search_state = GTK_STATE_NORMAL;
gtk_widget_show (widget);
g_signal_connect_swapped (
@@ -1486,3 +1491,69 @@ exit:
g_object_unref (rule);
gtk_widget_destroy (dialog);
}
+
+void
+e_shell_content_restore_state (EShellContent *shell_content,
+ const gchar *group_name)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GKeyFile *key_file;
+ GtkAction *action;
+ GtkWidget *widget;
+ const gchar *key;
+ gchar *string;
+
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+ g_return_if_fail (group_name != NULL);
+
+ shell_view = e_shell_content_get_shell_view (shell_content);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ key_file = e_shell_view_get_state_key_file (shell_view);
+
+ /* Changing the combo boxes triggers searches, so block
+ * the search action until the state is fully restored. */
+ action = e_shell_window_get_action (shell_window, "search-execute");
+ gtk_action_block_activate (action);
+
+ key = STATE_KEY_SEARCH_FILTER;
+ string = g_key_file_get_string (key_file, group_name, key, NULL);
+ if (string != NULL && *string != '\0')
+ action = e_shell_window_get_action (shell_window, string);
+ else
+ action = NULL;
+ if (action != NULL)
+ gtk_action_activate (action);
+ else {
+ /* Pick the first combo box item. */
+ widget = shell_content->priv->filter_combo_box;
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+ }
+ g_free (string);
+
+ key = STATE_KEY_SEARCH_SCOPE;
+ string = g_key_file_get_string (key_file, group_name, key, NULL);
+ if (string != NULL && *string != '\0')
+ action = e_shell_window_get_action (shell_window, string);
+ else
+ action = NULL;
+ if (action != NULL)
+ gtk_action_activate (action);
+ else {
+ /* Pick the first combo box item. */
+ widget = shell_content->priv->scope_combo_box;
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+ }
+ g_free (string);
+
+ key = STATE_KEY_SEARCH_TEXT;
+ string = g_key_file_get_string (key_file, group_name, key, NULL);
+ e_shell_content_set_search_text (shell_content, string);
+ g_free (string);
+
+ action = e_shell_window_get_action (shell_window, "search-execute");
+ gtk_action_unblock_activate (action);
+
+ /* Now execute the search. */
+ gtk_action_activate (action);
+}