[nautilus] Search filter popover on [Ctrl]+[F]
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] Search filter popover on [Ctrl]+[F]
- Date: Fri, 18 May 2018 14:55:06 +0000 (UTC)
commit 543f5ae369213f90238466e6366a0d2e09260e05
Author: andrei-stratila <stratila andrei1 gmail com>
Date: Sat May 12 13:30:35 2018 +0300
Search filter popover on [Ctrl]+[F]
Currently using the [Ctrl]+[F] keyboard shortcut toggles the search bar
visibility.
Using the [Ctrl]+[F] keyboard shortcut shows the search filter popover
(and gives it keyboard focus).
To add this a new action "search-visible-popover" is added which in addition
to the "search-visible" action adds the feature to focus and show the search
dropdown menu.
https://gitlab.gnome.org/GNOME/nautilus/issues/333
src/nautilus-query-editor.c | 12 ++++++++++++
src/nautilus-query-editor.h | 3 +++
src/nautilus-window-slot.c | 32 +++++++++++++++++++++++++++++---
3 files changed, 44 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 7e594b90f..619553d5f 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -601,6 +601,18 @@ entry_tag_clicked (NautilusQueryEditor *editor)
TRUE);
}
+void
+nautilus_query_editor_show_popover (NautilusQueryEditor *editor)
+{
+ NautilusQueryEditorPrivate *priv;
+
+ priv = nautilus_query_editor_get_instance_private (editor);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->dropdown_button),
+ TRUE);
+ gtk_widget_grab_focus (GTK_WIDGET (priv->popover));
+}
+
static void
entry_tag_close_button_clicked (NautilusQueryEditor *editor,
GdTaggedEntryTag *tag)
diff --git a/src/nautilus-query-editor.h b/src/nautilus-query-editor.h
index 0a13ad857..5844d06e8 100644
--- a/src/nautilus-query-editor.h
+++ b/src/nautilus-query-editor.h
@@ -86,3 +86,6 @@ void nautilus_query_editor_set_text (NautilusQueryEditor *editor,
gboolean
nautilus_query_editor_handle_event (NautilusQueryEditor *self,
GdkEvent *event);
+
+void
+nautilus_query_editor_show_popover (NautilusQueryEditor *editor);
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 57504bd94..6cbc0cf11 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -875,13 +875,17 @@ nautilus_window_slot_constructed (GObject *object)
static void
action_search_visible (GSimpleAction *action,
GVariant *state,
- gpointer user_data)
+ gpointer user_data,
+ gboolean show_popover)
{
NautilusWindowSlot *self;
GVariant *current_state;
+ NautilusWindowSlotPrivate *priv;
self = NAUTILUS_WINDOW_SLOT (user_data);
+ priv = nautilus_window_slot_get_instance_private (self);
current_state = g_action_get_state (G_ACTION (action));
+
if (g_variant_get_boolean (current_state) != g_variant_get_boolean (state))
{
g_simple_action_set_state (action, state);
@@ -890,6 +894,10 @@ action_search_visible (GSimpleAction *action,
{
show_query_editor (self);
nautilus_window_slot_set_searching (self, TRUE);
+ if(show_popover == TRUE)
+ {
+ nautilus_query_editor_show_popover (priv->query_editor);
+ }
}
else
{
@@ -901,6 +909,23 @@ action_search_visible (GSimpleAction *action,
g_variant_unref (current_state);
}
+static void
+search_visible_with_popover (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data)
+{
+ action_search_visible (action, state, user_data, TRUE);
+}
+
+static void
+search_visible_without_popover (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data)
+{
+ action_search_visible (action, state, user_data, FALSE);
+}
+
+
static void
change_files_view_mode (NautilusWindowSlot *self,
guint view_id)
@@ -971,7 +996,8 @@ const GActionEntry slot_entries[] =
/* 4 is NAUTILUS_VIEW_INVALID_ID */
{ "files-view-mode", NULL, "u", "uint32 4", action_files_view_mode },
{ "files-view-mode-toggle", action_files_view_mode_toggle },
- { "search-visible", NULL, NULL, "false", action_search_visible },
+ { "search-visible", NULL, NULL, "false", search_visible_without_popover },
+ { "search-visible-popover", NULL, NULL, "false", search_visible_with_popover },
};
static void
@@ -1018,7 +1044,7 @@ nautilus_window_slot_init (NautilusWindowSlot *self)
G_ACTION_GROUP (priv->slot_action_group));
nautilus_application_set_accelerator (app, "slot.files-view-mode(uint32 1)", "<control>1");
nautilus_application_set_accelerator (app, "slot.files-view-mode(uint32 0)", "<control>2");
- nautilus_application_set_accelerator (app, "slot.search-visible", "<control>f");
+ nautilus_application_set_accelerator (app, "slot.search-visible-popover", "<control>f");
priv->view_mode_before_search = NAUTILUS_VIEW_INVALID_ID;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]