[nautilus] files-view: use inheritance for empty states



commit d7131602074fa740ca8bd004e8a23c1430f12819
Author: Carlos Soriano <csoriano gnome org>
Date:   Fri Mar 18 15:22:47 2016 +0100

    files-view: use inheritance for empty states
    
    We don't want always empty states, for example, in the desktop.
    Use inheritance to allow children to do its own handling.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=712620

 src/nautilus-desktop-canvas-view.c |    8 ++++++++
 src/nautilus-files-view.c          |   18 ++++++++++++------
 src/nautilus-files-view.h          |    4 ++++
 3 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/src/nautilus-desktop-canvas-view.c b/src/nautilus-desktop-canvas-view.c
index 2d8e5a5..32bd0c4 100644
--- a/src/nautilus-desktop-canvas-view.c
+++ b/src/nautilus-desktop-canvas-view.c
@@ -67,6 +67,7 @@ struct NautilusDesktopCanvasViewDetails
 static void     default_zoom_level_changed                        (gpointer                user_data);
 static void     real_update_context_menus                         (NautilusFilesView           *view);
 static char*    real_get_backing_uri                              (NautilusFilesView           *view);
+static void     real_check_empty_states                           (NautilusFilesView           *view);
 static void     nautilus_desktop_canvas_view_update_canvas_container_fonts  (NautilusDesktopCanvasView      
*view);
 static void     font_changed_callback                             (gpointer                callback_data);
 
@@ -292,6 +293,7 @@ nautilus_desktop_canvas_view_class_init (NautilusDesktopCanvasViewClass *class)
        vclass->get_view_id = real_get_id;
        vclass->end_loading = nautilus_desktop_canvas_view_end_loading;
        vclass->get_backing_uri = real_get_backing_uri;
+       vclass->check_empty_states = real_check_empty_states;
 
        g_type_class_add_private (class, sizeof (NautilusDesktopCanvasViewDetails));
 }
@@ -558,6 +560,12 @@ const GActionEntry desktop_view_entries[] = {
        { "unstretch", action_unstretch },
 };
 
+/* Do nothing */
+static void
+real_check_empty_states (NautilusFilesView *view)
+{
+}
+
 static char*
 real_get_backing_uri (NautilusFilesView *view)
 {
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 5e2c626..ed9788a 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -316,7 +316,7 @@ static void     nautilus_files_view_select_file                      (NautilusFi
 
 static void     update_templates_directory                     (NautilusFilesView *view);
 
-static void     check_empty_states                             (NautilusFilesView *view);
+static void     nautilus_files_view_check_empty_states         (NautilusFilesView *view);
 
 static gboolean nautilus_files_view_is_searching               (NautilusView      *view);
 
@@ -3098,12 +3098,17 @@ reveal_selection_idle_callback (gpointer data)
 }
 
 static void
-check_empty_states (NautilusFilesView *view)
+nautilus_files_view_check_empty_states (NautilusFilesView *view)
+{
+        NAUTILUS_FILES_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->check_empty_states (view);
+}
+
+static void
+real_check_empty_states (NautilusFilesView *view)
 {
         gtk_widget_hide (view->details->no_search_results_widget);
         gtk_widget_hide (view->details->folder_is_empty_widget);
         if (!view->details->loading &&
-            !NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view) &&
             nautilus_files_view_is_empty (view)) {
                 if (nautilus_view_is_searching (NAUTILUS_VIEW (view))) {
                         gtk_widget_show (view->details->no_search_results_widget);
@@ -3179,7 +3184,7 @@ done_loading (NautilusFilesView *view,
         g_signal_emit (view, signals[END_LOADING], 0, all_files_seen);
         g_object_notify (G_OBJECT (view), "is-loading");
 
-        check_empty_states (view);
+        nautilus_files_view_check_empty_states (view);
 
         nautilus_profile_end (NULL);
 }
@@ -3547,7 +3552,7 @@ static void
 on_end_file_changes (NautilusFilesView *view)
 {
         /* Addition and removal of files modify the empty state */
-        check_empty_states (view);
+        nautilus_files_view_check_empty_states (view);
         /* If the view is empty, zoom slider and sort menu are insensitive */
         nautilus_files_view_update_toolbar_menus (view);
 }
@@ -7124,7 +7129,7 @@ finish_loading (NautilusFilesView *view)
         g_signal_emit (view, signals[BEGIN_LOADING], 0);
         nautilus_profile_end ("BEGIN_LOADING");
 
-        check_empty_states (view);
+        nautilus_files_view_check_empty_states (view);
 
         if (nautilus_directory_are_all_files_seen (view->details->model)) {
                 /* Unschedule a pending update and schedule a new one with the minimal
@@ -7986,6 +7991,7 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
         klass->get_window = nautilus_files_view_get_window;
         klass->update_context_menus = real_update_context_menus;
         klass->update_actions_state = real_update_actions_state;
+        klass->check_empty_states = real_check_empty_states;
 
         copied_files_atom = gdk_atom_intern ("x-special/gnome-copied-files", FALSE);
 
diff --git a/src/nautilus-files-view.h b/src/nautilus-files-view.h
index c8c70ac..efb4dea 100644
--- a/src/nautilus-files-view.h
+++ b/src/nautilus-files-view.h
@@ -258,6 +258,10 @@ struct NautilusFilesViewClass {
         GdkRectangle * (*compute_rename_popover_relative_to) (NautilusFilesView *view);
 
         GIcon *        (* get_icon)          (NautilusFilesView *view);
+
+        /* Use this to show an optional visual feedback when the directory is empty.
+         * By default it shows a widget overlay on top of the view */
+        void           (* check_empty_states)          (NautilusFilesView *view);
 };
 
 /* GObject support */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]