summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-03-22 13:38:54 +0100
committerCarlos Soriano <csoriano@gnome.org>2016-04-05 15:13:50 +0200
commit8440f1adde3bbd4d26dbec4c8526d7faf4592906 (patch)
tree4e91b67ad2136eef04c336cf1a6937caf262bd7e
parent2865830da3d2340bd19a9fc4dfd7d8e74da9e45e (diff)
downloadnautilus-8440f1adde3bbd4d26dbec4c8526d7faf4592906.tar.gz
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.
-rw-r--r--src/nautilus-window-slot.c18
-rw-r--r--src/nautilus-window-slot.h7
2 files changed, 17 insertions, 8 deletions
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index ea09cc517..e6b6efc2d 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -145,10 +145,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;
@@ -160,13 +167,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 */
@@ -2437,6 +2438,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 49b9749a8..9345f8741 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -48,6 +48,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);