[nautilus] window-pane: turn into a GtkBox, simplify code
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] window-pane: turn into a GtkBox, simplify code
- Date: Thu, 29 Sep 2011 00:20:55 +0000 (UTC)
commit d49f23ae211cb24cc43efa68d46f7867dbe26364
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Sep 28 20:19:33 2011 -0400
window-pane: turn into a GtkBox, simplify code
src/nautilus-window-pane.c | 19 ++++++-------------
src/nautilus-window-pane.h | 9 ++-------
src/nautilus-window.c | 16 +++++++---------
3 files changed, 15 insertions(+), 29 deletions(-)
---
diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c
index e68d6d0..a58b556 100644
--- a/src/nautilus-window-pane.c
+++ b/src/nautilus-window-pane.c
@@ -41,7 +41,7 @@
#include <libnautilus-private/nautilus-entry.h>
G_DEFINE_TYPE (NautilusWindowPane, nautilus_window_pane,
- G_TYPE_OBJECT)
+ GTK_TYPE_BOX)
static gboolean
widget_is_in_temporary_bars (GtkWidget *widget,
@@ -657,7 +657,6 @@ nautilus_window_pane_setup (NautilusWindowPane *pane)
NautilusWindow *window;
GtkActionGroup *action_group;
- pane->widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
window = pane->window;
header_size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
@@ -670,7 +669,7 @@ nautilus_window_pane_setup (NautilusWindowPane *pane)
setup_search_action (pane);
- gtk_box_pack_start (GTK_BOX (pane->widget),
+ gtk_box_pack_start (GTK_BOX (pane),
pane->tool_bar,
FALSE, FALSE, 0);
@@ -716,7 +715,7 @@ nautilus_window_pane_setup (NautilusWindowPane *pane)
/* initialize the notebook */
pane->notebook = g_object_new (NAUTILUS_TYPE_NOTEBOOK, NULL);
- gtk_box_pack_start (GTK_BOX (pane->widget), pane->notebook,
+ gtk_box_pack_start (GTK_BOX (pane), pane->notebook,
TRUE, TRUE, 0);
g_signal_connect (pane->notebook,
"tab-close-request",
@@ -746,7 +745,7 @@ nautilus_window_pane_setup (NautilusWindowPane *pane)
* of the UI (like location bar and tabs) don't request more and
* thus affect the default position of the split view paned.
*/
- gtk_widget_set_size_request (pane->widget, 60, 60);
+ gtk_widget_set_size_request (GTK_WIDGET (pane), 60, 60);
/* we can unref the size group now */
g_object_unref (header_size_group);
@@ -760,7 +759,6 @@ nautilus_window_pane_dispose (GObject *object)
unset_focus_widget (pane);
pane->window = NULL;
- gtk_widget_destroy (pane->widget);
g_clear_object (&pane->action_group);
g_assert (pane->slots == NULL);
@@ -782,6 +780,8 @@ nautilus_window_pane_init (NautilusWindowPane *pane)
pane->slots = NULL;
pane->active_slot = NULL;
pane->is_active = FALSE;
+
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (pane), GTK_ORIENTATION_VERTICAL);
}
NautilusWindowPane *
@@ -836,13 +836,6 @@ nautilus_window_pane_set_active (NautilusWindowPane *pane,
}
void
-nautilus_window_pane_show (NautilusWindowPane *pane)
-{
- pane->visible = TRUE;
- gtk_widget_show (pane->widget);
-}
-
-void
nautilus_window_pane_sync_location_widgets (NautilusWindowPane *pane)
{
NautilusWindowSlot *slot, *active_slot;
diff --git a/src/nautilus-window-pane.h b/src/nautilus-window-pane.h
index bf14a40..2e48c4a 100644
--- a/src/nautilus-window-pane.h
+++ b/src/nautilus-window-pane.h
@@ -39,7 +39,7 @@
#define NAUTILUS_WINDOW_PANE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NAUTILUS_TYPE_WINDOW_PANE, NautilusWindowPaneClass))
struct _NautilusWindowPaneClass {
- GObjectClass parent_class;
+ GtkBoxClass parent_class;
};
/* A NautilusWindowPane is a layer between a slot and a window.
@@ -49,15 +49,13 @@ struct _NautilusWindowPaneClass {
* window can contain one or multiple panes. Likewise, the window has
* the notion of an "active pane".
*
- * A spatial window has only one pane, which contains a single slot.
* A navigation window may have one or more panes.
*/
struct _NautilusWindowPane {
- GObject parent;
+ GtkBox parent;
/* hosting window */
NautilusWindow *window;
- gboolean visible;
/* available slots, and active slot.
* Both of them may never be NULL. */
@@ -67,8 +65,6 @@ struct _NautilusWindowPane {
/* whether or not this pane is active */
gboolean is_active;
- GtkWidget *widget;
-
/* location bar */
GtkWidget *location_bar;
GtkWidget *path_bar;
@@ -90,7 +86,6 @@ GType nautilus_window_pane_get_type (void);
NautilusWindowPane *nautilus_window_pane_new (NautilusWindow *window);
-void nautilus_window_pane_show (NautilusWindowPane *pane);
void nautilus_window_pane_sync_location_widgets (NautilusWindowPane *pane);
void nautilus_window_pane_sync_search_widgets (NautilusWindowPane *pane);
void nautilus_window_pane_set_active (NautilusWindowPane *pane, gboolean is_active);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 82aad10..1d91bc1 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -632,8 +632,7 @@ nautilus_window_constructed (GObject *self)
pane = nautilus_window_pane_new (window);
window->details->panes = g_list_prepend (window->details->panes, pane);
- gtk_paned_pack1 (GTK_PANED (hpaned), pane->widget, TRUE, FALSE);
- gtk_widget_show (pane->widget);
+ gtk_paned_pack1 (GTK_PANED (hpaned), GTK_WIDGET (pane), TRUE, FALSE);
/* this has to be done after the location bar has been set up,
* but before menu stuff is being called */
@@ -792,10 +791,9 @@ nautilus_window_view_visible (NautilusWindow *window,
}
slot->visible = TRUE;
-
pane = slot->pane;
- if (pane->visible) {
+ if (gtk_widget_get_visible (GTK_WIDGET (pane))) {
return;
}
@@ -809,13 +807,13 @@ nautilus_window_view_visible (NautilusWindow *window,
}
/* None, this pane is visible */
- nautilus_window_pane_show (pane);
+ gtk_widget_show (GTK_WIDGET (pane));
/* Look for other non-visible panes */
for (walk = window->details->panes; walk; walk = walk->next) {
pane = walk->data;
- if (!pane->visible) {
+ if (!gtk_widget_get_visible (GTK_WIDGET (pane))) {
return;
}
}
@@ -904,7 +902,7 @@ nautilus_window_close_pane (NautilusWindowPane *pane)
window->details->panes = g_list_remove (window->details->panes, pane);
- g_object_unref (pane);
+ gtk_widget_destroy (GTK_WIDGET (pane));
}
void
@@ -1841,9 +1839,9 @@ create_extra_pane (NautilusWindow *window)
paned = GTK_PANED (window->details->split_view_hpane);
if (gtk_paned_get_child1 (paned) == NULL) {
- gtk_paned_pack1 (paned, pane->widget, TRUE, FALSE);
+ gtk_paned_pack1 (paned, GTK_WIDGET (pane), TRUE, FALSE);
} else {
- gtk_paned_pack2 (paned, pane->widget, TRUE, FALSE);
+ gtk_paned_pack2 (paned, GTK_WIDGET (pane), TRUE, FALSE);
}
/* slot */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]