[nautilus] window-pane: move code around
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] window-pane: move code around
- Date: Thu, 17 Feb 2011 16:31:59 +0000 (UTC)
commit 610b14e6c85d16d519a0c9665ada09b289d21de7
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Feb 16 09:51:47 2011 -0500
window-pane: move code around
Makes things more readable.
src/nautilus-window-pane.c | 207 +++++++++++++++++++++-----------------------
src/nautilus-window-pane.h | 1 -
2 files changed, 97 insertions(+), 111 deletions(-)
---
diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c
index e5e0d51..ab7d3cc 100644
--- a/src/nautilus-window-pane.c
+++ b/src/nautilus-window-pane.c
@@ -28,15 +28,24 @@
#include "nautilus-window-manage-views.h"
#include <eel/eel-gtk-macros.h>
-static void nautilus_window_pane_init (NautilusWindowPane *pane);
-static void nautilus_window_pane_class_init (NautilusWindowPaneClass *class);
-static void nautilus_window_pane_dispose (GObject *object);
-
-G_DEFINE_TYPE (NautilusWindowPane,
- nautilus_window_pane,
+G_DEFINE_TYPE (NautilusWindowPane, nautilus_window_pane,
G_TYPE_OBJECT)
#define parent_class nautilus_window_pane_parent_class
+static void
+real_sync_location_widgets (NautilusWindowPane *pane)
+{
+ NautilusWindowSlot *slot;
+
+ /* TODO: Would be nice with a real subclass for spatial panes */
+ g_assert (NAUTILUS_IS_SPATIAL_WINDOW (pane->window));
+
+ slot = pane->active_slot;
+
+ /* Change the location button to match the current location. */
+ nautilus_spatial_window_set_location_button (NAUTILUS_SPATIAL_WINDOW (pane->window),
+ slot->location);
+}
static inline NautilusWindowSlot *
get_first_inactive_slot (NautilusWindowPane *pane)
@@ -54,101 +63,59 @@ get_first_inactive_slot (NautilusWindowPane *pane)
return NULL;
}
-void
-nautilus_window_pane_show (NautilusWindowPane *pane)
-{
- pane->visible = TRUE;
- EEL_CALL_METHOD (NAUTILUS_WINDOW_PANE_CLASS, pane,
- show, (pane));
-}
-
-void
-nautilus_window_pane_slot_close (NautilusWindowPane *pane, NautilusWindowSlot *slot)
+static void
+nautilus_window_pane_dispose (GObject *object)
{
- NautilusWindowSlot *next_slot;
+ NautilusWindowPane *pane = NAUTILUS_WINDOW_PANE (object);
- if (pane->window) {
- NautilusWindow *window;
- window = pane->window;
- if (pane->active_slot == slot) {
- next_slot = get_first_inactive_slot (NAUTILUS_WINDOW_PANE (pane));
- nautilus_window_set_active_slot (window, next_slot);
- }
- nautilus_window_close_slot (slot);
+ g_assert (pane->slots == NULL);
- /* If that was the last slot in the active pane, close the pane or even the whole window. */
- if (window->details->active_pane->slots == NULL) {
- NautilusWindowPane *next_pane;
- next_pane = nautilus_window_get_next_pane (window);
-
- /* If next_pane is non-NULL, we have more than one pane available. In this
- * case, close the current pane and switch to the next one. If there is
- * no next pane, close the window. */
- if(next_pane) {
- nautilus_window_close_pane (pane);
- nautilus_window_pane_switch_to (next_pane);
- if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
- nautilus_navigation_window_update_show_hide_menu_items (NAUTILUS_NAVIGATION_WINDOW (window));
- }
- } else {
- nautilus_window_close (window);
- }
- }
- }
+ pane->window = NULL;
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-real_sync_location_widgets (NautilusWindowPane *pane)
+nautilus_window_pane_class_init (NautilusWindowPaneClass *klass)
{
- NautilusWindowSlot *slot;
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
- /* TODO: Would be nice with a real subclass for spatial panes */
- g_assert (NAUTILUS_IS_SPATIAL_WINDOW (pane->window));
-
- slot = pane->active_slot;
-
- /* Change the location button to match the current location. */
- nautilus_spatial_window_set_location_button (NAUTILUS_SPATIAL_WINDOW (pane->window),
- slot->location);
+ oclass->dispose = nautilus_window_pane_dispose;
+ klass->sync_location_widgets = real_sync_location_widgets;
}
-
-void
-nautilus_window_pane_sync_location_widgets (NautilusWindowPane *pane)
+static void
+nautilus_window_pane_init (NautilusWindowPane *pane)
{
- EEL_CALL_METHOD (NAUTILUS_WINDOW_PANE_CLASS, pane,
- sync_location_widgets, (pane));
+ pane->slots = NULL;
+ pane->active_slot = NULL;
+ pane->is_active = FALSE;
}
-void
-nautilus_window_pane_sync_search_widgets (NautilusWindowPane *pane)
+NautilusWindowPane *
+nautilus_window_pane_new (NautilusWindow *window)
{
- g_assert (NAUTILUS_IS_WINDOW_PANE (pane));
+ NautilusWindowPane *pane;
- EEL_CALL_METHOD (NAUTILUS_WINDOW_PANE_CLASS, pane,
- sync_search_widgets, (pane));
+ pane = g_object_new (NAUTILUS_TYPE_WINDOW_PANE, NULL);
+ pane->window = window;
+ return pane;
}
-void
-nautilus_window_pane_grab_focus (NautilusWindowPane *pane)
+NautilusWindowSlot *
+nautilus_window_pane_get_slot_for_content_box (NautilusWindowPane *pane,
+ GtkWidget *content_box)
{
- if (NAUTILUS_IS_WINDOW_PANE (pane) && pane->active_slot) {
- nautilus_view_grab_focus (pane->active_slot->content_view);
- }
-}
+ NautilusWindowSlot *slot;
+ GList *l;
-void
-nautilus_window_pane_switch_to (NautilusWindowPane *pane)
-{
- nautilus_window_pane_grab_focus (pane);
-}
+ for (l = pane->slots; l != NULL; l = l->next) {
+ slot = NAUTILUS_WINDOW_SLOT (l->data);
-static void
-nautilus_window_pane_init (NautilusWindowPane *pane)
-{
- pane->slots = NULL;
- pane->active_slot = NULL;
- pane->is_active = FALSE;
+ if (slot->content_box == content_box) {
+ return slot;
+ }
+ }
+ return NULL;
}
void
@@ -167,47 +134,67 @@ nautilus_window_pane_set_active (NautilusWindowPane *pane, gboolean is_active)
set_active, (pane, is_active));
}
-static void
-nautilus_window_pane_class_init (NautilusWindowPaneClass *class)
+void
+nautilus_window_pane_show (NautilusWindowPane *pane)
{
- G_OBJECT_CLASS (class)->dispose = nautilus_window_pane_dispose;
- NAUTILUS_WINDOW_PANE_CLASS (class)->sync_location_widgets = real_sync_location_widgets;
+ pane->visible = TRUE;
+ EEL_CALL_METHOD (NAUTILUS_WINDOW_PANE_CLASS, pane,
+ show, (pane));
}
-static void
-nautilus_window_pane_dispose (GObject *object)
-{
- NautilusWindowPane *pane = NAUTILUS_WINDOW_PANE (object);
-
- g_assert (pane->slots == NULL);
- pane->window = NULL;
- G_OBJECT_CLASS (parent_class)->dispose (object);
+void
+nautilus_window_pane_sync_location_widgets (NautilusWindowPane *pane)
+{
+ EEL_CALL_METHOD (NAUTILUS_WINDOW_PANE_CLASS, pane,
+ sync_location_widgets, (pane));
}
-NautilusWindowPane *
-nautilus_window_pane_new (NautilusWindow *window)
+void
+nautilus_window_pane_sync_search_widgets (NautilusWindowPane *pane)
{
- NautilusWindowPane *pane;
-
- pane = g_object_new (NAUTILUS_TYPE_WINDOW_PANE, NULL);
- pane->window = window;
- return pane;
+ EEL_CALL_METHOD (NAUTILUS_WINDOW_PANE_CLASS, pane,
+ sync_search_widgets, (pane));
}
-NautilusWindowSlot *
-nautilus_window_pane_get_slot_for_content_box (NautilusWindowPane *pane,
- GtkWidget *content_box)
+void
+nautilus_window_pane_slot_close (NautilusWindowPane *pane, NautilusWindowSlot *slot)
{
- NautilusWindowSlot *slot;
- GList *l;
+ NautilusWindowSlot *next_slot;
- for (l = pane->slots; l != NULL; l = l->next) {
- slot = NAUTILUS_WINDOW_SLOT (l->data);
+ if (pane->window) {
+ NautilusWindow *window;
+ window = pane->window;
+ if (pane->active_slot == slot) {
+ next_slot = get_first_inactive_slot (NAUTILUS_WINDOW_PANE (pane));
+ nautilus_window_set_active_slot (window, next_slot);
+ }
+ nautilus_window_close_slot (slot);
- if (slot->content_box == content_box) {
- return slot;
+ /* If that was the last slot in the active pane, close the pane or even the whole window. */
+ if (window->details->active_pane->slots == NULL) {
+ NautilusWindowPane *next_pane;
+ next_pane = nautilus_window_get_next_pane (window);
+
+ /* If next_pane is non-NULL, we have more than one pane available. In this
+ * case, close the current pane and switch to the next one. If there is
+ * no next pane, close the window. */
+ if(next_pane) {
+ nautilus_window_close_pane (pane);
+ if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
+ nautilus_navigation_window_update_show_hide_menu_items (NAUTILUS_NAVIGATION_WINDOW (window));
+ }
+ } else {
+ nautilus_window_close (window);
+ }
}
}
- return NULL;
+}
+
+void
+nautilus_window_pane_grab_focus (NautilusWindowPane *pane)
+{
+ if (NAUTILUS_IS_WINDOW_PANE (pane) && pane->active_slot) {
+ nautilus_view_grab_focus (pane->active_slot->content_view);
+ }
}
diff --git a/src/nautilus-window-pane.h b/src/nautilus-window-pane.h
index 538a9de..0772394 100644
--- a/src/nautilus-window-pane.h
+++ b/src/nautilus-window-pane.h
@@ -84,7 +84,6 @@ void nautilus_window_pane_set_active (NautilusWindowPane *pane, gboolean is_acti
void nautilus_window_pane_slot_close (NautilusWindowPane *pane, NautilusWindowSlot *slot);
NautilusWindowSlot* nautilus_window_pane_get_slot_for_content_box (NautilusWindowPane *pane, GtkWidget *content_box);
-void nautilus_window_pane_switch_to (NautilusWindowPane *pane);
void nautilus_window_pane_grab_focus (NautilusWindowPane *pane);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]