summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-07-23 21:11:43 +0200
committerCarlos Soriano <csoriano@gnome.org>2015-07-23 21:11:43 +0200
commit69b5caad316bd39d4f13010e1dcfe7296f69ff68 (patch)
tree0de9ae8c0dcce648c41a209c1e43f081564cbc91
parentce5e60422191aea2263b293887ac000276c51071 (diff)
downloadnautilus-69b5caad316bd39d4f13010e1dcfe7296f69ff68.tar.gz
window-slot: show a "Folder is Empty" feedback
When the folder the user opens is empty we were providing no feedback, which cause confusion. Show an icon with a label for that case, similar to the feedback we provide when no search results are available.
-rw-r--r--src/nautilus-folder-is-empty.ui42
-rw-r--r--src/nautilus-window-slot.c25
-rw-r--r--src/nautilus.gresource.xml1
3 files changed, 68 insertions, 0 deletions
diff --git a/src/nautilus-folder-is-empty.ui b/src/nautilus-folder-is-empty.ui
new file mode 100644
index 000000000..be16c5765
--- /dev/null
+++ b/src/nautilus-folder-is-empty.ui
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkGrid" id="folder_is_empty">
+ <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">folder-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">Folder is Empty</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>
+ </object>
+</interface>
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 7292d9ef0..d0781e947 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -125,6 +125,9 @@ struct NautilusWindowSlotDetails {
NautilusWindowGoToCallback open_callback;
gpointer open_callback_user_data;
gchar *view_mode_before_search;
+
+ /*Folder is empty */
+ GtkWidget *folder_is_empty_widget;
};
static guint signals[LAST_SIGNAL] = { 0 };
@@ -652,6 +655,10 @@ nautilus_window_slot_constructed (GObject *object)
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);
+ builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-folder-is-empty.ui");
+ slot->details->folder_is_empty_widget = GTK_WIDGET (gtk_builder_get_object (builder, "folder_is_empty"));
+ gtk_overlay_add_overlay (GTK_OVERLAY (slot->details->view_overlay),
+ slot->details->folder_is_empty_widget);
g_object_unref (builder);
slot->details->floating_bar = nautilus_floating_bar_new (NULL, NULL, FALSE);
@@ -2242,6 +2249,10 @@ view_end_loading_cb (NautilusView *view,
gboolean all_files_seen,
NautilusWindowSlot *slot)
{
+ NautilusDirectory *directory;
+ GList *files;
+ gboolean show_folder_is_empty;
+
/* Only handle this if we're expecting it.
* Don't handle it if its from an old view we've switched from */
if (view == slot->details->content_view && all_files_seen) {
@@ -2257,10 +2268,23 @@ view_end_loading_cb (NautilusView *view,
slot->details->needs_reload = FALSE;
}
+ directory = nautilus_view_get_model (slot->details->content_view);
+ /* If there is no directory associated, we are probably in the middle
+ * of some change, so better to not show anything so it doesn't flash */
+ if (directory != NULL) {
+ files = nautilus_directory_get_file_list (directory);
+ show_folder_is_empty = g_list_length (files) == 0;
+ nautilus_file_list_free (files);
+ } else {
+ show_folder_is_empty = FALSE;
+ }
/* If it is a search directory, it will hide the toolbar when the search engine
* finishes, not every time the view end loading the new files */
if (!NAUTILUS_IS_SEARCH_DIRECTORY (nautilus_view_get_model (slot->details->content_view))) {
slot->details->busy = FALSE;
+ if (show_folder_is_empty) {
+ gtk_widget_show (slot->details->folder_is_empty_widget);
+ }
remove_loading_floating_bar (slot);
}
}
@@ -2330,6 +2354,7 @@ view_begin_loading_cb (NautilusView *view,
nautilus_profile_start (NULL);
slot->details->busy = TRUE;
+ gtk_widget_hide (slot->details->folder_is_empty_widget);
if (view == slot->details->new_content_view) {
location_has_really_changed (slot);
} else {
diff --git a/src/nautilus.gresource.xml b/src/nautilus.gresource.xml
index 3a13de042..0eb49cb4b 100644
--- a/src/nautilus.gresource.xml
+++ b/src/nautilus.gresource.xml
@@ -13,6 +13,7 @@
<file>nautilus-move-to-trash-shortcut-changed.ui</file>
<file>nautilus-window.ui</file>
<file>nautilus-no-search-results.ui</file>
+ <file>nautilus-folder-is-empty.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>