aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-09-03 03:21:35 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-09-03 03:26:49 +0800
commit53268d5516083c47607dbd3acbbd6bafd6d15747 (patch)
treec2a35758d36f00a2ce51633674c811eb1c5070ba /shell
parent5cbcdddfe769c0df81122b8d4944507f4739a618 (diff)
downloadgsoc2013-evolution-53268d5516083c47607dbd3acbbd6bafd6d15747.tar.gz
gsoc2013-evolution-53268d5516083c47607dbd3acbbd6bafd6d15747.tar.zst
gsoc2013-evolution-53268d5516083c47607dbd3acbbd6bafd6d15747.zip
Introduce an EShellView::execute-search signal.
This addresses bug #593896 but is also a cleaner design than before. It introduces an EShellView::execute-search signal and renames the "search-execute" action to "search-quick" to clarify that it's only meant for the "quick" search bar in the main window. Shell view subclasses should implement the execute_search() method to actually execute a search. e_shell_view_execute_search() emits the new signal.
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell-content.c72
-rw-r--r--shell/e-shell-view.c36
-rw-r--r--shell/e-shell-view.h7
-rw-r--r--shell/e-shell-window-actions.c51
-rw-r--r--shell/e-shell-window-actions.h4
-rw-r--r--shell/e-shell-window.c3
6 files changed, 124 insertions, 49 deletions
diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c
index 15c1a93fa9..fe4ea24e72 100644
--- a/shell/e-shell-content.c
+++ b/shell/e-shell-content.c
@@ -95,26 +95,23 @@ shell_content_dialog_rule_changed (GtkWidget *dialog,
}
static void
-action_search_execute_cb (GtkAction *action,
- EShellContent *shell_content)
+shell_content_execute_search_cb (EShellView *shell_view,
+ EShellContent *shell_content)
{
- EShellView *shell_view;
EShellWindow *shell_window;
+ GtkAction *action;
GtkWidget *widget;
const gchar *search_text;
gboolean sensitive;
- /* EShellView subclasses are responsible for actually
- * executing the search. This is all cosmetic stuff. */
-
- shell_view = e_shell_content_get_shell_view (shell_content);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
if (!e_shell_view_is_active (shell_view))
return;
- widget = shell_content->priv->search_entry;
+ /* EShellView subclasses are responsible for actually
+ * executing the search. This is all cosmetic stuff. */
+ widget = shell_content->priv->search_entry;
+ shell_window = e_shell_view_get_shell_window (shell_view);
search_text = e_shell_content_get_search_text (shell_content);
if (search_text != NULL && *search_text != '\0') {
@@ -159,22 +156,38 @@ action_search_execute_cb (GtkAction *action,
}
static void
-shell_content_entry_activated_cb (EShellContent *shell_content,
- GtkWidget *entry)
+shell_content_entry_activate_cb (EShellContent *shell_content,
+ GtkEntry *entry)
{
+ EShellView *shell_view;
EShellWindow *shell_window;
+ GtkAction *action;
+
+ shell_view = e_shell_content_get_shell_view (shell_content);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_QUICK (shell_window);
+ gtk_action_activate (action);
+}
+
+static void
+shell_content_entry_changed_cb (EShellContent *shell_content,
+ GtkEntry *entry)
+{
EShellView *shell_view;
+ EShellWindow *shell_window;
GtkAction *action;
+ const gchar *text;
+ gboolean sensitive;
shell_view = e_shell_content_get_shell_view (shell_content);
shell_window = e_shell_view_get_shell_window (shell_view);
- /* Verify the shell view is active before proceeding. */
- if (!e_shell_view_is_active (shell_view))
- return;
+ text = gtk_entry_get_text (entry);
+ sensitive = (text != NULL && *text != '\0');
- action = E_SHELL_WINDOW_ACTION_SEARCH_EXECUTE (shell_window);
- gtk_action_activate (action);
+ action = E_SHELL_WINDOW_ACTION_SEARCH_QUICK (shell_window);
+ gtk_action_set_sensitive (action, sensitive);
}
static void
@@ -563,6 +576,11 @@ shell_content_constructed (GObject *object)
shell_window = e_shell_view_get_shell_window (shell_view);
size_group = e_shell_view_get_size_group (shell_view);
+ g_signal_connect_after (
+ shell_view, "execute-search",
+ G_CALLBACK (shell_content_execute_search_cb),
+ shell_content);
+
widget = shell_content->priv->search_entry;
action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
@@ -576,11 +594,6 @@ shell_content_constructed (GObject *object)
action, "tooltip",
widget, "secondary-icon-tooltip-text");
- action = E_SHELL_WINDOW_ACTION_SEARCH_EXECUTE (shell_window);
- g_signal_connect (
- action, "activate",
- G_CALLBACK (action_search_execute_cb), shell_content);
-
action = E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS (shell_window);
e_binding_new (
action, "sensitive",
@@ -918,7 +931,12 @@ shell_content_init (EShellContent *shell_content)
g_signal_connect_swapped (
widget, "activate",
- G_CALLBACK (shell_content_entry_activated_cb),
+ G_CALLBACK (shell_content_entry_activate_cb),
+ shell_content);
+
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (shell_content_entry_changed_cb),
shell_content);
g_signal_connect_swapped (
@@ -1338,7 +1356,6 @@ e_shell_content_run_advanced_search_dialog (EShellContent *shell_content)
{
EShellView *shell_view;
EShellWindow *shell_window;
- GtkAction *action;
GtkWidget *dialog;
GtkWidget *widget;
FilterRule *rule;
@@ -1394,8 +1411,7 @@ run:
e_shell_content_set_search_rule (shell_content, rule);
- action = E_SHELL_WINDOW_ACTION_SEARCH_EXECUTE (shell_window);
- gtk_action_activate (action);
+ e_shell_view_execute_search (shell_view);
if (response == GTK_RESPONSE_APPLY) {
if (!rule_context_find_rule (context, rule->name, rule->source))
@@ -1524,7 +1540,7 @@ e_shell_content_restore_state (EShellContent *shell_content,
/* 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");
+ action = E_SHELL_WINDOW_ACTION_SEARCH_QUICK (shell_window);
gtk_action_block_activate (action);
key = STATE_KEY_SEARCH_FILTER;
@@ -1562,7 +1578,7 @@ e_shell_content_restore_state (EShellContent *shell_content,
e_shell_content_set_search_text (shell_content, string);
g_free (string);
- action = e_shell_window_get_action (shell_window, "search-execute");
+ action = E_SHELL_WINDOW_ACTION_SEARCH_QUICK (shell_window);
gtk_action_unblock_activate (action);
/* Now execute the search. */
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 5808f9e027..9b740d49a1 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -69,6 +69,7 @@ enum {
enum {
TOGGLED,
+ EXECUTE_SEARCH,
UPDATE_ACTIONS,
LAST_SIGNAL
};
@@ -672,6 +673,23 @@ shell_view_class_init (EShellViewClass *class)
G_TYPE_NONE, 0);
/**
+ * EShellView::execute-search
+ * @shell_view: the #EShellView which emitted the signal
+ *
+ * #EShellView subclasses should override the
+ * <structfield>execute_search</structfield> method in
+ * #EShellViewClass to execute the current search conditions.
+ **/
+ signals[EXECUTE_SEARCH] = g_signal_new (
+ "execute-search",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EShellViewClass, execute_search),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
* EShellView::update-actions
* @shell_view: the #EShellView which emitted the signal
*
@@ -1097,6 +1115,24 @@ e_shell_view_set_state_dirty (EShellView *shell_view)
}
/**
+ * e_shell_view_execute_search:
+ * @shell_view: an #EShellView
+ *
+ * Emits the #EShellView:;execute-search signal.
+ *
+ * #EShellView subclasses should implement the
+ * <structfield>execute_search</structfield> method in #EShellViewClass
+ * to execute a search based on the current search conditions.
+ **/
+void
+e_shell_view_execute_search (EShellView *shell_view)
+{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+
+ g_signal_emit (shell_view, signals[EXECUTE_SEARCH], 0);
+}
+
+/**
* e_shell_view_update_actions:
* @shell_view: an #EShellView
*
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index 1e5e03f71b..1a8a9046fb 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -111,7 +111,10 @@ struct _EShellView {
* @toggled: Class method for the #EShellView::toggled signal.
* Subclasses should rarely need to override the
* default behavior.
- * @update_actions: Class method for the #EShellView::update_actions
+ * @execute_search: Class method for the #EShellView::execute-search
+ * signal. There is no default behavior; subclasses
+ * should override this.
+ * @update_actions: Class method for the #EShellView::update-actions
* signal. There is no default behavior; subclasses
* should override this.
*
@@ -150,6 +153,7 @@ struct _EShellViewClass {
/* Signals */
void (*toggled) (EShellView *shell_view);
+ void (*execute_search) (EShellView *shell_view);
void (*update_actions) (EShellView *shell_view);
};
@@ -174,6 +178,7 @@ EShellTaskbar * e_shell_view_get_shell_taskbar (EShellView *shell_view);
EShellWindow * e_shell_view_get_shell_window (EShellView *shell_view);
GKeyFile * e_shell_view_get_state_key_file (EShellView *shell_view);
void e_shell_view_set_state_dirty (EShellView *shell_view);
+void e_shell_view_execute_search (EShellView *shell_view);
void e_shell_view_update_actions (EShellView *shell_view);
void e_shell_view_show_popup_menu (EShellView *shell_view,
const gchar *widget_path,
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index 54cd47ffa2..2fe4a17e0a 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -719,7 +719,8 @@ action_custom_rule_cb (GtkAction *action,
g_return_if_fail (IS_FILTER_RULE (rule));
e_shell_content_set_search_rule (shell_content, rule);
- gtk_action_activate (ACTION (SEARCH_EXECUTE));
+
+ e_shell_view_execute_search (shell_view);
}
/**
@@ -1024,7 +1025,7 @@ action_search_clear_cb (GtkAction *action,
e_shell_content_set_search_rule (shell_content, NULL);
e_shell_content_set_search_text (shell_content, NULL);
- gtk_action_activate (ACTION (SEARCH_EXECUTE));
+ e_shell_view_execute_search (shell_view);
e_shell_window_update_search_menu (shell_window);
}
@@ -1054,15 +1055,6 @@ action_search_edit_cb (GtkAction *action,
}
/**
- * E_SHELL_WINDOW_ACTION_SEARCH_EXECUTE:
- * @window: an #EShellWindow
- *
- * Activation of this action executes the current search conditions.
- *
- * Main menu item: Search -> Find Now
- **/
-
-/**
* E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS:
* @window: an #EShellWindow
*
@@ -1087,6 +1079,27 @@ action_search_options_cb (GtkAction *action,
}
/**
+ * E_SHELL_WINDOW_ACTION_SEARCH_QUICK:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action executes the current search conditions.
+ *
+ * Main menu item: Search -> Find Now
+ **/
+static void
+action_search_quick_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ const gchar *view_name;
+
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+
+ e_shell_view_execute_search (shell_view);
+}
+
+/**
* E_SHELL_WINDOW_ACTION_SEARCH_SAVE:
* @window: an #EShellWindow
*
@@ -1523,13 +1536,6 @@ static GtkActionEntry shell_entries[] = {
N_("Manage your saved searches"),
G_CALLBACK (action_search_edit_cb) },
- { "search-execute",
- GTK_STOCK_FIND,
- N_("_Find Now"),
- "", /* Block the default Ctrl+F. */
- N_("Execute the current search parameters"),
- NULL }, /* Handled by EShellContent and subclasses. */
-
{ "search-options",
GTK_STOCK_FIND,
NULL,
@@ -1537,6 +1543,13 @@ static GtkActionEntry shell_entries[] = {
N_("Click here to change the search type"),
G_CALLBACK (action_search_options_cb) },
+ { "search-quick",
+ GTK_STOCK_FIND,
+ N_("_Find Now"),
+ "", /* Block the default Ctrl+F. */
+ N_("Execute the current search parameters"),
+ G_CALLBACK (action_search_quick_cb) },
+
{ "search-save",
NULL,
N_("_Save Search..."),
@@ -1872,6 +1885,8 @@ e_shell_window_actions_init (EShellWindow *shell_window)
/* Fine tuning. */
+ gtk_action_set_sensitive (ACTION (SEARCH_QUICK), FALSE);
+
g_object_set (ACTION (SEND_RECEIVE), "is-important", TRUE, NULL);
e_binding_new (
diff --git a/shell/e-shell-window-actions.h b/shell/e-shell-window-actions.h
index 757487b72f..dec9160868 100644
--- a/shell/e-shell-window-actions.h
+++ b/shell/e-shell-window-actions.h
@@ -63,10 +63,10 @@
E_SHELL_WINDOW_ACTION ((window), "search-clear")
#define E_SHELL_WINDOW_ACTION_SEARCH_EDIT(window) \
E_SHELL_WINDOW_ACTION ((window), "search-edit")
-#define E_SHELL_WINDOW_ACTION_SEARCH_EXECUTE(window) \
- E_SHELL_WINDOW_ACTION ((window), "search-execute")
#define E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS(window) \
E_SHELL_WINDOW_ACTION ((window), "search-options")
+#define E_SHELL_WINDOW_ACTION_SEARCH_QUICK(window) \
+ E_SHELL_WINDOW_ACTION ((window), "search-quick")
#define E_SHELL_WINDOW_ACTION_SEARCH_SAVE(window) \
E_SHELL_WINDOW_ACTION ((window), "search-save")
#define E_SHELL_WINDOW_ACTION_SEND_RECEIVE(window) \
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 19392094ee..6b43877aba 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -106,6 +106,9 @@ shell_window_new_view (EShellBackend *shell_backend,
shell_view, "notify::view-id",
G_CALLBACK (e_shell_window_update_view_menu), shell_window);
+ /* Execute an initial search. */
+ e_shell_view_execute_search (shell_view);
+
return shell_view;
}