[nautilus/wip/csoriano/destktop-split2: 24/47] window-slot: allow overriding the creation of views



commit 5b205a3d8d888b4da57a6e5d6a9db76200039138
Author: Carlos Soriano <csoriano gnome org>
Date:   Tue Mar 22 13:38:54 2016 +0100

    window-slot: allow overriding the creation of views
    
    We would want in subclasses of nautilus window slot to have a way to
    create custom views, like for instance, the desktop.
    
    To allow it, make a vfunc for the creation of views that subclasses can
    override.

 src/nautilus-window-slot.c |   18 ++++++++++--------
 src/nautilus-window-slot.h |    7 +++++++
 2 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index aa54701..6baaf13 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -146,10 +146,17 @@ static gboolean nautilus_window_slot_get_search_visible (NautilusWindowSlot *sel
 static void nautilus_window_slot_set_location (NautilusWindowSlot *self,
                                                GFile              *location);
 
-static NautilusView*
+static NautilusView *
 nautilus_window_slot_get_view_for_location (NautilusWindowSlot *self,
                                             GFile              *location)
 {
+        return NAUTILUS_WINDOW_SLOT_CLASS (G_OBJECT_GET_CLASS (self))->get_view_for_location (self, 
location);
+}
+
+static NautilusView*
+real_get_view_for_location (NautilusWindowSlot *self,
+                            GFile              *location)
+{
         NautilusWindowSlotPrivate *priv;
 
         NautilusWindow *window;
@@ -161,13 +168,7 @@ nautilus_window_slot_get_view_for_location (NautilusWindowSlot *self,
         file = nautilus_file_get (location);
         view = NULL;
 
-        /* FIXME bugzilla.gnome.org 41243:
-        * We should use inheritance instead of these special cases
-        * for the desktop window.
-        */
-        if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
-                view = NAUTILUS_VIEW (nautilus_files_view_new (NAUTILUS_VIEW_DESKTOP_ID, self));
-        } else if (nautilus_file_is_other_locations (file)) {
+        if (nautilus_file_is_other_locations (file)) {
                 view = NAUTILUS_VIEW (nautilus_places_view_new ());
 
                 /* Save the current view, so we can go back after places view */
@@ -2438,6 +2439,7 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
 
        klass->active = real_active;
        klass->inactive = real_inactive;
+        klass->get_view_for_location = real_get_view_for_location;
 
        oclass->dispose = nautilus_window_slot_dispose;
        oclass->constructed = nautilus_window_slot_constructed;
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index 09fafbf..f9492ac 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -49,6 +49,13 @@ struct _NautilusWindowSlotClass {
        /* wrapped NautilusWindowInfo signals, for overloading */
        void (* active)   (NautilusWindowSlot *slot);
        void (* inactive) (NautilusWindowSlot *slot);
+
+        /* Use this in case the subclassed slot has some special views differents
+         * that the ones supported here. You can return your nautilus view
+         * subclass in this function.
+         */
+        NautilusView*  (* get_view_for_location) (NautilusWindowSlot *slot,
+                                                  GFile              *location);
 };
 
 NautilusWindowSlot * nautilus_window_slot_new              (NautilusWindow     *window);


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