diff options
-rw-r--r-- | src/nautilus-no-search-results.ui | 55 | ||||
-rw-r--r-- | src/nautilus-window-slot.c | 59 | ||||
-rw-r--r-- | src/nautilus.gresource.xml | 1 |
3 files changed, 113 insertions, 2 deletions
diff --git a/src/nautilus-no-search-results.ui b/src/nautilus-no-search-results.ui new file mode 100644 index 000000000..4811ed437 --- /dev/null +++ b/src/nautilus-no-search-results.ui @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <object class="GtkGrid" id="no_search_results"> + <property name="visible">False</property> + <property name="row_spacing">12</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="halign">center</property> + <property name="valign">center</property> + <style> + <class name="dim-label"/> + </style> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="icon-name">edit-find-symbolic</property> + <property name="pixel-size">72</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="label" translatable="yes">No Results Found</property> + <attributes> + <attribute name="weight" value="bold"/> + <attribute name="scale" value="1.44"/> + </attributes> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="label" translatable="yes">Try a different search</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + </object> +</interface> diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index 4590006d2..9a905a3f7 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -68,6 +68,9 @@ struct NautilusWindowSlotDetails { GtkWidget *floating_bar; GtkWidget *view_overlay; + /* no search results widget */ + GtkWidget *no_search_results_widget; + /* slot contains * 1) an vbox containing extra_location_widgets * 2) the view @@ -192,6 +195,23 @@ nautilus_window_slot_sync_view_mode (NautilusWindowSlot *slot) } static void +nautilus_window_slot_on_done_loading (NautilusDirectory *directory, + NautilusWindowSlot *slot) +{ + GList *files; + + files = nautilus_directory_get_file_list (directory); + + if (g_list_length (files) != 0) { + gtk_widget_hide (slot->details->no_search_results_widget); + } else { + gtk_widget_show (slot->details->no_search_results_widget); + } + + nautilus_file_list_unref (files); +} + +static void sync_search_directory (NautilusWindowSlot *slot) { NautilusDirectory *directory; @@ -566,6 +586,7 @@ static void nautilus_window_slot_constructed (GObject *object) { NautilusWindowSlot *slot = NAUTILUS_WINDOW_SLOT (object); + GtkBuilder *builder; GtkWidget *extras_vbox; G_OBJECT_CLASS (nautilus_window_slot_parent_class)->constructed (object); @@ -593,6 +614,12 @@ nautilus_window_slot_constructed (GObject *object) gtk_box_pack_start (GTK_BOX (slot), slot->details->view_overlay, TRUE, TRUE, 0); gtk_widget_show (slot->details->view_overlay); + builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-no-search-results.ui"); + slot->details->no_search_results_widget = GTK_WIDGET (gtk_builder_get_object (builder, "no_search_results")); + gtk_overlay_add_overlay (GTK_OVERLAY (slot->details->view_overlay), + slot->details->no_search_results_widget); + g_object_unref (builder); + slot->details->floating_bar = nautilus_floating_bar_new (NULL, NULL, FALSE); gtk_widget_set_halign (slot->details->floating_bar, GTK_ALIGN_END); gtk_widget_set_valign (slot->details->floating_bar, GTK_ALIGN_END); @@ -860,6 +887,7 @@ begin_location_change (NautilusWindowSlot *slot, NautilusWindowGoToCallback callback, gpointer user_data) { + NautilusDirectory *previous_directory; NautilusDirectory *directory; NautilusFile *file; gboolean force_reload; @@ -875,6 +903,25 @@ begin_location_change (NautilusWindowSlot *slot, nautilus_profile_start (NULL); + previous_directory = nautilus_directory_get (previous_location); + directory = nautilus_directory_get (location); + + /* Disconnect search signals from the old directory if it was a search directory */ + if (NAUTILUS_IS_SEARCH_DIRECTORY (previous_directory)) { + gtk_widget_hide (slot->details->no_search_results_widget); + g_signal_handlers_disconnect_by_func (previous_directory, + G_CALLBACK (nautilus_window_slot_on_done_loading), + slot); + } + nautilus_directory_unref (previous_directory); + + /* Connect to the done loading signal if it is a search directory to update + * the no results widget */ + if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) { + g_signal_connect_object (directory, "done-loading", + G_CALLBACK (nautilus_window_slot_on_done_loading), slot, 0); + } + /* If there is no new selection and the new location is * a (grand)parent of the old location then we automatically * select the folder the previous location was in */ @@ -916,8 +963,6 @@ begin_location_change (NautilusWindowSlot *slot, slot->details->open_callback = callback; slot->details->open_callback_user_data = user_data; - directory = nautilus_directory_get (location); - /* The code to force a reload is here because if we do it * after determining an initial view (in the components), then * we end up fetching things twice. @@ -1766,6 +1811,7 @@ nautilus_window_slot_force_reload (NautilusWindowSlot *slot) g_assert (NAUTILUS_IS_WINDOW_SLOT (slot)); + gtk_widget_hide (slot->details->no_search_results_widget); location = nautilus_window_slot_get_location (slot); if (location == NULL) { return; @@ -2424,6 +2470,7 @@ static void nautilus_window_slot_dispose (GObject *object) { NautilusWindowSlot *slot; + NautilusDirectory *directory; GtkWidget *widget; slot = NAUTILUS_WINDOW_SLOT (object); @@ -2466,6 +2513,14 @@ nautilus_window_slot_dispose (GObject *object) /* TODO? why do we ref here, instead of unreffing? * It was already here before the slot migration, though */ g_object_ref (slot->details->location); + + directory = nautilus_directory_get (slot->details->location); + if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) { + g_signal_handlers_disconnect_by_func (directory, + G_CALLBACK (nautilus_window_slot_on_done_loading), + slot); + } + g_object_unref (directory); } if (slot->details->view_mode_before_search) { diff --git a/src/nautilus.gresource.xml b/src/nautilus.gresource.xml index bc3e8e44b..3a13de042 100644 --- a/src/nautilus.gresource.xml +++ b/src/nautilus.gresource.xml @@ -12,6 +12,7 @@ <file>nautilus-progress-info-widget.xml</file> <file>nautilus-move-to-trash-shortcut-changed.ui</file> <file>nautilus-window.ui</file> + <file>nautilus-no-search-results.ui</file> <file alias="icons/thumbnail_frame.png">../icons/thumbnail_frame.png</file> <file alias="icons/filmholes.png">../icons/filmholes.png</file> <file alias="icons/knob.png">../icons/knob.png</file> |