summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@redhat.com>2018-07-13 19:17:18 +0200
committerCarlos Soriano <csoriano1618@gmail.com>2018-07-14 08:06:31 +0000
commit4a88f39d09df5be59e3fa25e78df5263c1905a41 (patch)
tree9146fb4c35278ba20852bf117af672d14eb01489
parent2f2647010f503c3e37db68719de9ab1980359d98 (diff)
downloadnautilus-4a88f39d09df5be59e3fa25e78df5263c1905a41.tar.gz
general: Provide search information on the view itself
With the new search bar design, the search information displayed under they query editor was not working properly. Instead, the new design says that the information should be displayed in the view itself, as a top banner. This work implements the new design and fixes several issues of sizing due to the wrong position of the search information label. Closes https://gitlab.gnome.org/GNOME/nautilus/issues/403
-rw-r--r--src/nautilus-file-utilities.c26
-rw-r--r--src/nautilus-file-utilities.h2
-rw-r--r--src/nautilus-query-editor.c76
-rw-r--r--src/nautilus-window-slot.c86
-rw-r--r--src/resources/css/Adwaita.css6
5 files changed, 129 insertions, 67 deletions
diff --git a/src/nautilus-file-utilities.c b/src/nautilus-file-utilities.c
index d898806bc..03c06b73d 100644
--- a/src/nautilus-file-utilities.c
+++ b/src/nautilus-file-utilities.c
@@ -1391,3 +1391,29 @@ nautilus_uri_to_native_uri (const gchar *uri)
return NULL;
}
+
+gboolean
+location_settings_search_is_recursive (GFile *location)
+{
+ NautilusFile *file;
+ gboolean recursive;
+
+ g_return_val_if_fail (location != NULL, TRUE);
+
+ file = nautilus_file_get (location);
+
+ if (nautilus_file_is_remote (file))
+ {
+ recursive = g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_ALWAYS;
+ }
+ else
+ {
+ recursive = g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY ||
+ g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_ALWAYS;
+ }
+
+ nautilus_file_unref (file);
+
+ return recursive;
+}
+
diff --git a/src/nautilus-file-utilities.h b/src/nautilus-file-utilities.h
index 680b857aa..e02f2b0c6 100644
--- a/src/nautilus-file-utilities.h
+++ b/src/nautilus-file-utilities.h
@@ -121,3 +121,5 @@ gboolean nautilus_file_can_rename_files (GList *files);
GList * nautilus_file_list_from_uri_list (GList *uris);
gchar * nautilus_uri_to_native_uri (const gchar *uri);
+
+gboolean location_settings_search_is_recursive (GFile *location);
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 5e05d3335..3a56ceea0 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -43,7 +43,6 @@ struct _NautilusQueryEditor
GtkWidget *entry;
GtkWidget *popover;
- GtkWidget *label;
GtkWidget *dropdown_button;
GdTaggedEntryTag *mime_types_tag;
@@ -82,75 +81,25 @@ static void nautilus_query_editor_changed (NautilusQueryEditor *editor);
G_DEFINE_TYPE (NautilusQueryEditor, nautilus_query_editor, GTK_TYPE_BOX);
-static gboolean
-settings_search_is_recursive (NautilusQueryEditor *editor)
-{
- NautilusFile *file;
- gboolean recursive;
-
- if (editor->location == NULL)
- {
- return TRUE;
- }
-
- file = nautilus_file_get (editor->location);
-
- if (nautilus_file_is_remote (file))
- {
- recursive = g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_ALWAYS;
- }
- else
- {
- recursive = g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY ||
- g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_ALWAYS;
- }
-
- nautilus_file_unref (file);
-
- return recursive;
-}
-
static void
-update_information_label (NautilusQueryEditor *editor)
+update_fts_sensitivity (NautilusQueryEditor *editor)
{
gboolean fts_sensitive = TRUE;
if (editor->location)
{
g_autoptr (NautilusFile) file = NULL;
- gchar *label;
g_autofree gchar *uri = NULL;
file = nautilus_file_get (editor->location);
- label = NULL;
uri = g_file_get_uri (editor->location);
- if (nautilus_file_is_other_locations (file))
- {
- label = _("Searching locations only");
- fts_sensitive = FALSE;
- }
- else if (g_str_has_prefix (uri, "network://"))
- {
- label = _("Searching network locations only");
- fts_sensitive = FALSE;
- }
- else if (nautilus_file_is_remote (file) &&
- !settings_search_is_recursive (editor))
- {
- label = _("Remote location — only searching the current folder");
- fts_sensitive = FALSE;
- }
- else if (!settings_search_is_recursive (editor))
- {
- label = _("Only searching the current folder");
- }
-
+ fts_sensitive = !nautilus_file_is_other_locations (file) &&
+ !g_str_has_prefix (uri, "network://") &&
+ !(nautilus_file_is_remote (file) &&
+ !location_settings_search_is_recursive (editor->location));
nautilus_search_popover_set_fts_sensitive (NAUTILUS_SEARCH_POPOVER (editor->popover),
fts_sensitive);
-
- gtk_widget_set_visible (editor->label, label != NULL);
- gtk_label_set_label (GTK_LABEL (editor->label), label);
}
}
@@ -166,14 +115,14 @@ recursive_search_preferences_changed (GSettings *settings,
return;
}
- recursive = settings_search_is_recursive (editor);
+ recursive = location_settings_search_is_recursive (editor->location);
if (recursive != nautilus_query_get_recursive (editor->query))
{
nautilus_query_set_recursive (editor->query, recursive);
nautilus_query_editor_changed (editor);
}
- update_information_label (editor);
+ update_fts_sensitivity (editor);
}
@@ -380,7 +329,7 @@ create_query (NautilusQueryEditor *editor)
nautilus_query_set_search_content (query, fts_enabled);
- recursive = settings_search_is_recursive (editor);
+ recursive = location_settings_search_is_recursive (editor->location);
nautilus_query_set_text (query, gtk_entry_get_text (GTK_ENTRY (editor->entry)));
nautilus_query_set_location (query, editor->location);
@@ -621,13 +570,6 @@ setup_widgets (NautilusQueryEditor *editor)
G_CALLBACK (entry_tag_close_button_clicked),
editor);
- /* additional information label */
- editor->label = gtk_label_new (NULL);
- gtk_widget_set_no_show_all (editor->label, TRUE);
- gtk_style_context_add_class (gtk_widget_get_style_context (editor->label), "dim-label");
-
- gtk_container_add (GTK_CONTAINER (vbox), editor->label);
-
/* setup the search popover */
editor->popover = nautilus_search_popover_new ();
@@ -735,7 +677,7 @@ nautilus_query_editor_set_location (NautilusQueryEditor *editor,
}
nautilus_query_set_location (editor->query, editor->location);
- update_information_label (editor);
+ update_fts_sensitivity (editor);
if (should_notify)
{
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index e01c6ae1f..b583de81f 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -100,6 +100,9 @@ typedef struct
gulong qe_cancel_id;
gulong qe_activated_id;
+ GtkLabel *search_info_label;
+ GtkRevealer *search_info_label_revealer;
+
/* Load state */
GCancellable *find_mount_cancellable;
/* It could be either the view is loading the files or the search didn't
@@ -155,6 +158,7 @@ static void nautilus_window_slot_set_location (NautilusWindowSlot *self,
static void trash_state_changed_cb (NautilusTrashMonitor *monitor,
gboolean is_empty,
gpointer user_data);
+static void update_search_information (NautilusWindowSlot *self);
void
nautilus_window_slot_restore_from_data (NautilusWindowSlot *self,
@@ -873,6 +877,20 @@ nautilus_window_slot_constructed (GObject *object)
g_object_ref_sink (priv->query_editor);
gtk_widget_show (GTK_WIDGET (priv->query_editor));
+ priv->search_info_label = GTK_LABEL (gtk_label_new (NULL));
+ priv->search_info_label_revealer = GTK_REVEALER (gtk_revealer_new ());
+
+ gtk_container_add (GTK_CONTAINER (priv->search_info_label_revealer),
+ GTK_WIDGET (priv->search_info_label));
+ gtk_container_add (GTK_CONTAINER (self),
+ GTK_WIDGET (priv->search_info_label_revealer));
+
+ gtk_widget_show (GTK_WIDGET (priv->search_info_label));
+ gtk_widget_show (GTK_WIDGET (priv->search_info_label_revealer));
+
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (priv->search_info_label));
+ gtk_style_context_add_class (style_context, "search-information");
+
g_object_bind_property (self, "location",
priv->query_editor, "location",
G_BINDING_DEFAULT);
@@ -912,6 +930,8 @@ action_search_visible (GSimpleAction *action,
hide_query_editor (self);
nautilus_window_slot_set_searching (self, FALSE);
}
+
+ update_search_information (self);
}
g_variant_unref (current_state);
@@ -1009,6 +1029,67 @@ const GActionEntry slot_entries[] =
};
static void
+update_search_information (NautilusWindowSlot *self)
+{
+ NautilusWindowSlotPrivate *priv;
+
+ priv = nautilus_window_slot_get_instance_private (self);
+
+ if (!nautilus_window_slot_get_searching (self))
+ {
+ gtk_revealer_set_reveal_child (priv->search_info_label_revealer, FALSE);
+
+ return;
+ }
+
+ if (priv->location)
+ {
+ g_autoptr (NautilusFile) file = NULL;
+ gchar *label;
+ g_autofree gchar *uri = NULL;
+
+ file = nautilus_file_get (priv->location);
+ label = NULL;
+ uri = g_file_get_uri (priv->location);
+
+ if (nautilus_file_is_other_locations (file))
+ {
+ label = _("Searching locations only");
+ }
+ else if (g_str_has_prefix (uri, "network://"))
+ {
+ label = _("Searching network locations only");
+ }
+ else if (nautilus_file_is_remote (file) &&
+ !location_settings_search_is_recursive (priv->location))
+ {
+ label = _("Remote location — only searching the current folder");
+ }
+ else if (!location_settings_search_is_recursive (priv->location))
+ {
+ label = _("Only searching the current folder");
+ }
+
+ gtk_label_set_label (priv->search_info_label, label);
+ gtk_revealer_set_reveal_child (priv->search_info_label_revealer,
+ label != NULL);
+ }
+
+}
+
+static void
+recursive_search_preferences_changed (GSettings *settings,
+ gchar *key,
+ gpointer callback_data)
+{
+ NautilusWindowSlot *self;
+
+ self = callback_data;
+
+ update_search_information (self);
+}
+
+static void
use_experimental_views_changed_callback (GSettings *settings,
gchar *key,
gpointer callback_data)
@@ -1042,6 +1123,11 @@ nautilus_window_slot_init (NautilusWindowSlot *self)
"changed::" NAUTILUS_PREFERENCES_USE_EXPERIMENTAL_VIEWS,
G_CALLBACK (use_experimental_views_changed_callback), self, 0);
+ g_signal_connect_object (nautilus_preferences,
+ "changed::recursive-search",
+ G_CALLBACK (recursive_search_preferences_changed),
+ self, 0);
+
priv->slot_action_group = G_ACTION_GROUP (g_simple_action_group_new ());
g_action_map_add_action_entries (G_ACTION_MAP (priv->slot_action_group),
slot_entries,
diff --git a/src/resources/css/Adwaita.css b/src/resources/css/Adwaita.css
index c58c64108..913d64903 100644
--- a/src/resources/css/Adwaita.css
+++ b/src/resources/css/Adwaita.css
@@ -188,6 +188,12 @@ entry.search > * {
border-bottom: 1px solid @theme_bg_color;
}
+.search-information {
+ background-color: @theme_selected_bg_color;
+ color:white;
+ padding:2px;
+}
+
/* Hide superfluous treeview drop target indication */
.nautilus-list-view .view.dnd {
border-style: none;