[nautilus/wip/csoriano/destktop-split2: 26/33] files-view: use inheritance for empty states



commit e714d289042fd29f82559423da099faeace4a844
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.

 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 2526dd9..3d7e115 100644
--- a/src/nautilus-desktop-canvas-view.c
+++ b/src/nautilus-desktop-canvas-view.c
@@ -68,6 +68,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);
 
@@ -293,6 +294,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));
 }
@@ -559,6 +561,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 874537f..feab55e 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);
 
@@ -3099,12 +3099,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);
@@ -3180,7 +3185,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);
 }
@@ -3548,7 +3553,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);
 }
@@ -7125,7 +7130,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
@@ -7987,6 +7992,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 d4181e5..2881b31 100644
--- a/src/nautilus-files-view.h
+++ b/src/nautilus-files-view.h
@@ -259,6 +259,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]