[nautilus/wip/csoriano/destktop-split2: 30/54] window: allow to create custom slots in subclasses
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/csoriano/destktop-split2: 30/54] window: allow to create custom slots in subclasses
- Date: Wed, 30 Mar 2016 14:05:19 +0000 (UTC)
commit 713d32b204a537f21c75e85162071cc7cb2bd7d9
Author: Carlos Soriano <csoriano gnome org>
Date: Tue Mar 22 11:30:36 2016 +0100
window: allow to create custom slots in subclasses
We are not able to create subclasses of window slots, like the one
we will need for desktop.
So create a vfunc to handle that, and expose the common code in a public
function so subclasses can use it.
src/nautilus-window.c | 28 ++++++++++++++++++++--------
src/nautilus-window.h | 8 ++++++++
2 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 69823b6..e28cc05 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -525,14 +525,25 @@ disconnect_slot (NautilusWindow *window,
}
static NautilusWindowSlot *
-nautilus_window_create_slot (NautilusWindow *window,
- NautilusWindowOpenFlags flags)
+nautilus_window_create_slot (NautilusWindow *window)
{
- NautilusWindowSlot *slot;
+ return NAUTILUS_WINDOW_CLASS (G_OBJECT_GET_CLASS(window))->create_slot (window);
+}
+
+static NautilusWindowSlot *
+real_create_slot (NautilusWindow *window)
+{
+ return nautilus_window_slot_new (window);
+}
+void
+nautilus_window_initialize_slot (NautilusWindow *window,
+ NautilusWindowSlot *slot,
+ NautilusWindowOpenFlags flags)
+{
g_assert (NAUTILUS_IS_WINDOW (window));
+ g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));
- slot = nautilus_window_slot_new (window);
connect_slot (window, slot);
g_signal_handlers_block_by_func (window->priv->notebook,
@@ -550,8 +561,6 @@ nautilus_window_create_slot (NautilusWindow *window,
window->priv->slots = g_list_append (window->priv->slots, slot);
g_signal_emit (window, signals[SLOT_ADDED], 0, slot);
-
- return slot;
}
void
@@ -574,7 +583,8 @@ nautilus_window_open_location_full (NautilusWindow *window,
if (new_tab_at_end)
flags |= NAUTILUS_WINDOW_OPEN_SLOT_APPEND;
- target_slot = nautilus_window_create_slot (window, flags);
+ target_slot = nautilus_window_create_slot (window);
+ nautilus_window_initialize_slot (window, target_slot, flags);
}
if (target_slot == NULL) {
@@ -2130,7 +2140,8 @@ nautilus_window_constructed (GObject *self)
* some actions trigger UI widgets to show/hide. */
nautilus_window_initialize_actions (window);
- slot = nautilus_window_create_slot (window, 0);
+ slot = nautilus_window_create_slot (window);
+ nautilus_window_initialize_slot (window, slot, 0);
nautilus_window_set_active_slot (window, slot);
window->priv->bookmarks_id =
@@ -2579,6 +2590,7 @@ nautilus_window_class_init (NautilusWindowClass *class)
wclass->grab_focus = nautilus_window_grab_focus;
class->close = real_window_close;
+ class->create_slot = real_create_slot;
gtk_widget_class_set_template_from_resource (wclass,
"/org/gnome/nautilus/ui/nautilus-window.ui");
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 12b755c..9610a3d 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -87,6 +87,10 @@ struct NautilusWindowClass {
void (* sync_title) (NautilusWindow *window,
NautilusWindowSlot *slot);
void (* close) (NautilusWindow *window);
+ /* Use this in case your window has a special slot. Also is expected that
+ * the slot is initialized with nautilus_window_initialize_slot.
+ */
+ NautilusWindowSlot * (* create_slot) (NautilusWindow *window);
};
typedef struct _NautilusWindowPrivate NautilusWindowPrivate;
@@ -150,4 +154,8 @@ void nautilus_window_end_dnd (NautilusWindow *window,
void nautilus_window_search (NautilusWindow *window,
const gchar *text);
+
+void nautilus_window_initialize_slot (NautilusWindow *window,
+ NautilusWindowSlot *slot,
+ NautilusWindowOpenFlags flags);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]