[nautilus/wip/csoriano/destktop-split2: 18/33] files-view: use inheritance for get_backing_uri



commit 0e213ace514e5fb85a46162d09f38a4cca476b3a
Author: Carlos Soriano <csoriano gnome org>
Date:   Fri Mar 18 14:57:29 2016 +0100

    files-view: use inheritance for get_backing_uri
    
    So we remove another desktop special case

 src/nautilus-desktop-canvas-view.c |   33 +++++++++++++++++++++++++++++++++
 src/nautilus-files-view.c          |   17 +----------------
 2 files changed, 34 insertions(+), 16 deletions(-)
---
diff --git a/src/nautilus-desktop-canvas-view.c b/src/nautilus-desktop-canvas-view.c
index 559bf2a..2526dd9 100644
--- a/src/nautilus-desktop-canvas-view.c
+++ b/src/nautilus-desktop-canvas-view.c
@@ -40,6 +40,7 @@
 #include <gdk/gdkx.h>
 #include <glib/gi18n.h>
 #include <libnautilus-private/nautilus-desktop-icon-file.h>
+#include <libnautilus-private/nautilus-desktop-directory.h>
 #include <libnautilus-private/nautilus-directory-notify.h>
 #include <libnautilus-private/nautilus-file-changes-queue.h>
 #include <libnautilus-private/nautilus-file-operations.h>
@@ -66,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     nautilus_desktop_canvas_view_update_canvas_container_fonts  (NautilusDesktopCanvasView      
*view);
 static void     font_changed_callback                             (gpointer                callback_data);
 
@@ -290,6 +292,7 @@ nautilus_desktop_canvas_view_class_init (NautilusDesktopCanvasViewClass *class)
        vclass->update_context_menus = real_update_context_menus;
        vclass->get_view_id = real_get_id;
        vclass->end_loading = nautilus_desktop_canvas_view_end_loading;
+       vclass->get_backing_uri = real_get_backing_uri;
 
        g_type_class_add_private (class, sizeof (NautilusDesktopCanvasViewDetails));
 }
@@ -556,6 +559,36 @@ const GActionEntry desktop_view_entries[] = {
        { "unstretch", action_unstretch },
 };
 
+static char*
+real_get_backing_uri (NautilusFilesView *view)
+{
+        gchar *uri;
+        NautilusDirectory *directory;
+        NautilusDirectory *model;
+
+        g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), NULL);
+
+        model = nautilus_files_view_get_model (view);
+
+        if (model == NULL) {
+                return NULL;
+        }
+
+        directory = model;
+
+        if (NAUTILUS_IS_DESKTOP_DIRECTORY (directory)) {
+                directory = nautilus_desktop_directory_get_real_directory (NAUTILUS_DESKTOP_DIRECTORY 
(directory));
+        } else {
+                nautilus_directory_ref (directory);
+        }
+
+        uri = nautilus_directory_get_uri (directory);
+
+        nautilus_directory_unref (directory);
+
+        return uri;
+}
+
 static void
 real_update_context_menus (NautilusFilesView *view)
 {
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 0516196..874537f 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -526,28 +526,13 @@ set_floating_bar_status (NautilusFilesView *view,
 static char *
 real_get_backing_uri (NautilusFilesView *view)
 {
-        NautilusDirectory *directory;
-        char *uri;
-
         g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), NULL);
 
         if (view->details->model == NULL) {
                 return NULL;
         }
 
-        directory = view->details->model;
-
-        if (NAUTILUS_IS_DESKTOP_DIRECTORY (directory)) {
-                directory = nautilus_desktop_directory_get_real_directory (NAUTILUS_DESKTOP_DIRECTORY 
(directory));
-        } else {
-                nautilus_directory_ref (directory);
-        }
-
-        uri = nautilus_directory_get_uri (directory);
-
-        nautilus_directory_unref (directory);
-
-        return uri;
+        return nautilus_directory_get_uri (view->details->model);
 }
 
 /**


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