[nautilus] bookmarks-window: make this a real GtkWindow subclass



commit c3c9fa607b84097ab9b196cf63883deb3ae542fc
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Aug 29 11:57:56 2012 -0400

    bookmarks-window: make this a real GtkWindow subclass
    
    This was long overdue, and in addition to making the whole code a
    little cleaner, it also allows us to disconnect signals from objects
    that outlive the window in dispose() (such as NautilusBookmarkList).
    
    This also fixes the crasher reported in
    https://bugzilla.gnome.org/show_bug.cgi?id=682916

 src/nautilus-application.c       |   14 +-
 src/nautilus-bookmarks-window.c  |  743 +++++++++++++++++++++-----------------
 src/nautilus-bookmarks-window.h  |   29 ++-
 src/nautilus-bookmarks-window.ui |  373 ++++++++++----------
 4 files changed, 617 insertions(+), 542 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 494325e..d03acc2 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -112,7 +112,6 @@ struct _NautilusApplicationPriv {
 
 	NotifyNotification *unmount_notify;
 
-	GtkWidget *bookmarks_window;
 	NautilusBookmarkList *bookmark_list;
 };
 
@@ -128,18 +127,7 @@ nautilus_application_edit_bookmarks (NautilusApplication *application,
 {
 	GtkWindow *bookmarks_window;
 
-	bookmarks_window = GTK_WINDOW (application->priv->bookmarks_window);
-
-	if (bookmarks_window == NULL) {
-		bookmarks_window = nautilus_bookmarks_window_new (window, application->priv->bookmark_list);
-		application->priv->bookmarks_window = GTK_WIDGET (bookmarks_window);
-
-		g_object_add_weak_pointer (G_OBJECT (bookmarks_window),
-					   (gpointer *) &application->priv->bookmarks_window);
-	}
-
-	gtk_window_set_transient_for (bookmarks_window, GTK_WINDOW (window));
-	gtk_window_set_screen (bookmarks_window, gtk_window_get_screen (GTK_WINDOW (window)));
+	bookmarks_window = nautilus_bookmarks_window_new (window);
 	gtk_window_present (bookmarks_window);
 }
 
diff --git a/src/nautilus-bookmarks-window.c b/src/nautilus-bookmarks-window.c
index 37be459..7d47cbf 100644
--- a/src/nautilus-bookmarks-window.c
+++ b/src/nautilus-bookmarks-window.c
@@ -26,80 +26,91 @@
  */
 
 #include <config.h>
+
+#include "nautilus-application.h"
 #include "nautilus-bookmarks-window.h"
 #include "nautilus-window.h"
 
 #include <libnautilus-private/nautilus-entry.h>
 #include <libnautilus-private/nautilus-global-preferences.h>
 
-#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-gnome-extensions.h>
-
 #include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
 #include <glib/gi18n.h>
-
-/* Static variables to keep track of window state. If there were
- * more than one bookmark-editing window, these would be struct or
- * class fields. 
- */
-static int		     bookmark_list_changed_signal_id;
-static NautilusBookmarkList *bookmarks = NULL;
-static GtkTreeView	    *bookmark_list_widget = NULL; /* awkward name to distinguish from NautilusBookmarkList */
-static GtkListStore	    *bookmark_list_store = NULL;
-static GtkListStore	    *bookmark_empty_list_store = NULL;
-static GtkTreeSelection     *bookmark_selection = NULL;
-static int                   selection_changed_id = 0;
-static GtkWidget	    *name_field = NULL;
-static int		     name_field_changed_signal_id;
-static GtkWidget	    *remove_button = NULL;
-static GtkWidget	    *up_button = NULL;
-static GtkWidget	    *down_button = NULL;
-static gboolean		     text_changed = FALSE;
-static gboolean		     name_text_changed = FALSE;
-static GtkWidget	    *uri_field = NULL;
-static int		     uri_field_changed_signal_id;
-static int		     row_changed_signal_id;
-static int		     row_deleted_signal_id;
-static int                   row_activated_signal_id;
-static int                   button_pressed_signal_id;
-static int                   key_pressed_signal_id;
+#include <gdk/gdkkeysyms.h>
 
 /* We store a pointer to the bookmark in a column so when an item is moved
    with DnD we know which item it is. However we have to be careful to keep
    this in sync with the actual bookmark. Note that
    nautilus_bookmark_list_insert_item() makes a copy of the bookmark, so we
    have to fetch the new copy and update our pointer. */
-#define BOOKMARK_LIST_COLUMN_ICON		0
-#define BOOKMARK_LIST_COLUMN_NAME		1
-#define BOOKMARK_LIST_COLUMN_BOOKMARK		2
-#define BOOKMARK_LIST_COLUMN_STYLE		3
-#define BOOKMARK_LIST_COLUMN_COUNT		4
+
+enum {
+	BOOKMARK_LIST_COLUMN_ICON,
+	BOOKMARK_LIST_COLUMN_NAME,
+	BOOKMARK_LIST_COLUMN_BOOKMARK,
+	BOOKMARK_LIST_COLUMN_STYLE,
+	BOOKMARK_LIST_NUM_COLUMNS
+};
 
 /* Larger size initially; user can stretch or shrink (but not shrink below min) */
 #define BOOKMARKS_WINDOW_INITIAL_WIDTH	500
 #define BOOKMARKS_WINDOW_INITIAL_HEIGHT	400
 
+G_DEFINE_TYPE (NautilusBookmarksWindow, nautilus_bookmarks_window, GTK_TYPE_WINDOW)
+
+enum {
+	PROP_PARENT_WINDOW = 1,
+	NUM_PROPERTIES
+};
+
+static GParamSpec* properties[NUM_PROPERTIES] = { NULL, };
+
+struct NautilusBookmarksWindowPrivate {
+	NautilusWindow *parent_window;
+
+	NautilusBookmarkList *bookmarks;
+	gulong bookmarks_changed_id;
+
+	GtkTreeView *tree_view;
+	GtkTreeSelection *selection;
+	gulong row_activated_id;
+	gulong button_press_id;
+	gulong key_press_id;
+	gulong selection_changed_id;
+
+	GtkListStore *model;
+	gulong row_changed_id;
+	gulong row_deleted_id;
+
+	GtkWidget *name_field;
+	GtkWidget *uri_field;
+	gulong name_changed_id;
+	gulong uri_changed_id;
+	gboolean text_changed;
+	gboolean name_text_changed;
+
+	GtkWidget *remove_button;
+	GtkWidget *up_button;
+	GtkWidget *down_button;
+};
+
 static gboolean
-get_selection_exists (void)
+get_selection_exists (NautilusBookmarksWindow *self)
 {
-	return gtk_tree_selection_get_selected (bookmark_selection, NULL, NULL);
+	return gtk_tree_selection_get_selected (self->priv->selection, NULL, NULL);
 }
 
 static guint
-get_selected_row (void)
+get_selected_row (NautilusBookmarksWindow *self)
 {
 	GtkTreeIter       iter;
 	GtkTreePath      *path;
 	GtkTreeModel     *model;
 	gint		 *indices, row;
 	
-	g_assert (get_selection_exists());
-	
-	model = GTK_TREE_MODEL (bookmark_list_store);
-	gtk_tree_selection_get_selected (bookmark_selection,
-					 &model,
-					 &iter);
+	if (!gtk_tree_selection_get_selected (self->priv->selection, &model, &iter)) {
+		g_assert_not_reached ();
+	}
 	
 	path = gtk_tree_model_get_path (model, &iter);
 	indices = gtk_tree_path_get_indices (path);
@@ -109,17 +120,18 @@ get_selected_row (void)
 }
 
 static NautilusBookmark *
-get_selected_bookmark (void)
+get_selected_bookmark (NautilusBookmarksWindow *self)
 {
-	g_return_val_if_fail(NAUTILUS_IS_BOOKMARK_LIST(bookmarks), NULL);
-
-	if (!get_selection_exists())
+	if (!get_selection_exists (self)) {
 		return NULL;
+	}
 
-	if (nautilus_bookmark_list_length (bookmarks) < 1)
+	if (nautilus_bookmark_list_length (self->priv->bookmarks) < 1) {
 		return NULL;
+	}
 
-	return nautilus_bookmark_list_item_at(bookmarks, get_selected_row ());
+	return nautilus_bookmark_list_item_at (self->priv->bookmarks,
+					       get_selected_row (self));
 }
 
 static int
@@ -138,7 +150,7 @@ nautilus_bookmarks_window_key_press_event_cb (GtkWindow *window,
 static GtkListStore *
 create_bookmark_store (void)
 {
-	return gtk_list_store_new (BOOKMARK_LIST_COLUMN_COUNT,
+	return gtk_list_store_new (BOOKMARK_LIST_NUM_COLUMNS,
 				   G_TYPE_ICON,
 				   G_TYPE_STRING,
 				   G_TYPE_OBJECT,
@@ -146,53 +158,56 @@ create_bookmark_store (void)
 }
 
 static void
-setup_empty_list (void)
+setup_empty_list (NautilusBookmarksWindow *self)
 {
+	GtkListStore *empty_model;
 	GtkTreeIter iter;
 
-	bookmark_empty_list_store = create_bookmark_store ();
-	gtk_list_store_append (bookmark_empty_list_store, &iter);
+	empty_model = create_bookmark_store ();
+	gtk_list_store_append (empty_model, &iter);
 
-	gtk_list_store_set (bookmark_empty_list_store, &iter,
+	gtk_list_store_set (empty_model, &iter,
 			    BOOKMARK_LIST_COLUMN_NAME, _("No bookmarks defined"),
 			    BOOKMARK_LIST_COLUMN_STYLE, PANGO_STYLE_ITALIC,
 			    -1);
+	gtk_tree_view_set_model (self->priv->tree_view,
+				 GTK_TREE_MODEL (empty_model));
+
+	g_object_unref (empty_model);
 }
 
 static void
-update_button_sensitivity (void)
+update_widgets_sensitivity (NautilusBookmarksWindow *self)
 {
 	NautilusBookmark *selected;
 	int n_active;
 	int index = -1;
 
-	selected = get_selected_bookmark ();
-	n_active = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (bookmark_list_store), NULL);
+	selected = get_selected_bookmark (self);
+	n_active = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (self->priv->model), NULL);
 	if (selected != NULL) {
-		index = get_selected_row ();
+		index = get_selected_row (self);
 	}
 
 	/* Set the sensitivity of widgets that require a selection */
-	gtk_widget_set_sensitive (remove_button, index >= 0 && n_active > 1);
-	gtk_widget_set_sensitive (up_button, index > 0);
-	gtk_widget_set_sensitive (down_button, index >= 0 && index < n_active - 1);
-	gtk_widget_set_sensitive (name_field, selected != NULL);
-	gtk_widget_set_sensitive (uri_field, selected != NULL);
+	gtk_widget_set_sensitive (self->priv->remove_button, index >= 0 && n_active > 1);
+	gtk_widget_set_sensitive (self->priv->up_button, index > 0);
+	gtk_widget_set_sensitive (self->priv->down_button, index >= 0 && index < n_active - 1);
+	gtk_widget_set_sensitive (self->priv->name_field, selected != NULL);
+	gtk_widget_set_sensitive (self->priv->uri_field, selected != NULL);
 }
 
 static void
 on_selection_changed (GtkTreeSelection *treeselection,
 		      gpointer user_data)
 {
+	NautilusBookmarksWindow *self = user_data;
 	NautilusBookmark *selected;
 	const char *name = NULL;
 	char *entry_text = NULL;
 	GFile *location;
 
-	g_assert (GTK_IS_ENTRY (name_field));
-	g_assert (GTK_IS_ENTRY (uri_field));
-
-	selected = get_selected_bookmark ();
+	selected = get_selected_bookmark (self);
 
 	if (selected) {
 		name = nautilus_bookmark_get_name (selected);
@@ -202,51 +217,50 @@ on_selection_changed (GtkTreeSelection *treeselection,
 		g_object_unref (location);
 	}
 
-	update_button_sensitivity ();
+	update_widgets_sensitivity (self);
 
-	g_signal_handler_block (name_field, name_field_changed_signal_id);
-	nautilus_entry_set_text (NAUTILUS_ENTRY (name_field),
+	g_signal_handler_block (self->priv->name_field, self->priv->name_changed_id);
+	nautilus_entry_set_text (NAUTILUS_ENTRY (self->priv->name_field),
 				 name ? name : "");
-	g_signal_handler_unblock (name_field, name_field_changed_signal_id);
+	g_signal_handler_unblock (self->priv->name_field, self->priv->name_changed_id);
 
-	g_signal_handler_block (uri_field, uri_field_changed_signal_id);
-	nautilus_entry_set_text (NAUTILUS_ENTRY (uri_field),
+	g_signal_handler_block (self->priv->uri_field, self->priv->uri_changed_id);
+	nautilus_entry_set_text (NAUTILUS_ENTRY (self->priv->uri_field),
 				 entry_text ? entry_text : "");
-	g_signal_handler_unblock (uri_field, uri_field_changed_signal_id);
+	g_signal_handler_unblock (self->priv->uri_field, self->priv->uri_changed_id);
 
-	text_changed = FALSE;
-	name_text_changed = FALSE;
+	self->priv->text_changed = FALSE;
+	self->priv->name_text_changed = FALSE;
 
 	g_free (entry_text);
 }
 
 static void
-bookmarks_set_empty (gboolean empty)
+bookmarks_set_empty (NautilusBookmarksWindow *self,
+		     gboolean empty)
 {
 	GtkTreeIter iter;
 
 	if (empty) {
-		gtk_tree_view_set_model (bookmark_list_widget,
-					 GTK_TREE_MODEL (bookmark_empty_list_store));
-		gtk_widget_set_sensitive (GTK_WIDGET (bookmark_list_widget), FALSE);
+		setup_empty_list (self);
+		gtk_widget_set_sensitive (GTK_WIDGET (self->priv->tree_view), FALSE);
 	} else {
-		gtk_tree_view_set_model (bookmark_list_widget,
-					 GTK_TREE_MODEL (bookmark_list_store));
-		gtk_widget_set_sensitive (GTK_WIDGET (bookmark_list_widget), TRUE);
+		gtk_tree_view_set_model (self->priv->tree_view, GTK_TREE_MODEL (self->priv->model));
+		gtk_widget_set_sensitive (GTK_WIDGET (self->priv->tree_view), TRUE);
 
-		if (nautilus_bookmark_list_length (bookmarks) > 0 &&
-		    !get_selection_exists ()) {
-			gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (bookmark_list_store),
+		if (nautilus_bookmark_list_length (self->priv->bookmarks) > 0 &&
+		    !get_selection_exists (self)) {
+			gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (self->priv->model),
 						       &iter, NULL, 0);
-			gtk_tree_selection_select_iter (bookmark_selection, &iter);
+			gtk_tree_selection_select_iter (self->priv->selection, &iter);
 		}
 	}
 
-	on_selection_changed (bookmark_selection, NULL);
+	on_selection_changed (self->priv->selection, self);
 }
 
 static void
-repopulate (void)
+repopulate (NautilusBookmarksWindow *self)
 {
 	NautilusBookmark *selected;
 	GtkListStore *store;
@@ -254,49 +268,35 @@ repopulate (void)
 	GtkTreeRowReference *reference;
 	guint index;
 
-	g_assert (GTK_IS_TREE_VIEW (bookmark_list_widget));
-	g_assert (NAUTILUS_IS_BOOKMARK_LIST (bookmarks));
-	
-	store = GTK_LIST_STORE (bookmark_list_store);
-
-	selected = get_selected_bookmark ();
-
-	g_signal_handler_block (bookmark_selection,
-				selection_changed_id);
-	g_signal_handler_block (bookmark_list_store,
-				row_deleted_signal_id);
-        g_signal_handler_block (bookmark_list_widget,
-                                row_activated_signal_id);
-        g_signal_handler_block (bookmark_list_widget,
-                                key_pressed_signal_id);
-        g_signal_handler_block (bookmark_list_widget,
-                                button_pressed_signal_id);
-
-	gtk_list_store_clear (store);
-	
-	g_signal_handler_unblock (bookmark_list_widget,
-				  row_activated_signal_id);
-        g_signal_handler_unblock (bookmark_list_widget,
-                                  key_pressed_signal_id);
-        g_signal_handler_unblock (bookmark_list_widget,
-                                  button_pressed_signal_id);
-	g_signal_handler_unblock (bookmark_list_store,
-				  row_deleted_signal_id);
-	g_signal_handler_unblock (bookmark_selection,
-				  selection_changed_id);
-	
+	selected = get_selected_bookmark (self);
+
+	g_signal_handler_block (self->priv->selection, self->priv->selection_changed_id);
+	g_signal_handler_block (self->priv->model, self->priv->row_deleted_id);
+        g_signal_handler_block (self->priv->tree_view, self->priv->row_activated_id);
+        g_signal_handler_block (self->priv->tree_view, self->priv->key_press_id);
+        g_signal_handler_block (self->priv->tree_view, self->priv->button_press_id);
+
+	gtk_list_store_clear (self->priv->model);
+
+	g_signal_handler_unblock (self->priv->selection, self->priv->selection_changed_id);
+	g_signal_handler_unblock (self->priv->model, self->priv->row_deleted_id);
+        g_signal_handler_unblock (self->priv->tree_view, self->priv->row_activated_id);
+        g_signal_handler_unblock (self->priv->tree_view, self->priv->key_press_id);
+        g_signal_handler_unblock (self->priv->tree_view, self->priv->button_press_id);
+
 	/* Fill the list in with the bookmark names. */
-	g_signal_handler_block (store, row_changed_signal_id);
+	g_signal_handler_block (self->priv->model, self->priv->row_changed_id);
 
 	reference = NULL;
+	store = self->priv->model;
 
-	for (index = 0; index < nautilus_bookmark_list_length (bookmarks); ++index) {
+	for (index = 0; index < nautilus_bookmark_list_length (self->priv->bookmarks); ++index) {
 		NautilusBookmark *bookmark;
 		const char       *bookmark_name;
 		GIcon            *bookmark_icon;
 		GtkTreeIter       iter;
 
-		bookmark = nautilus_bookmark_list_item_at (bookmarks, index);
+		bookmark = nautilus_bookmark_list_item_at (self->priv->bookmarks, index);
 		bookmark_name = nautilus_bookmark_get_name (bookmark);
 		bookmark_icon = nautilus_bookmark_get_icon (bookmark);
 
@@ -320,7 +320,7 @@ repopulate (void)
 		g_object_unref (bookmark_icon);
 	}
 
-	g_signal_handler_unblock (store, row_changed_signal_id);
+	g_signal_handler_unblock (self->priv->model, self->priv->row_changed_id);
 
 	if (reference != NULL) {
 		/* restore old selection */
@@ -328,112 +328,88 @@ repopulate (void)
 		/* bookmarks_set_empty() will call the selection change handler,
  		 * so we block it here in case of selection change.
  		 */
-		g_signal_handler_block (bookmark_selection, selection_changed_id);
+		g_signal_handler_block (self->priv->selection, self->priv->selection_changed_id);
 
 		g_assert (index != 0);
 		g_assert (gtk_tree_row_reference_valid (reference));
 
 		path = gtk_tree_row_reference_get_path (reference);
-		gtk_tree_selection_select_path (bookmark_selection, path);
+		gtk_tree_selection_select_path (self->priv->selection, path);
 		gtk_tree_row_reference_free (reference);
 		gtk_tree_path_free (path);
 
-		g_signal_handler_unblock (bookmark_selection, selection_changed_id);
+		g_signal_handler_unblock (self->priv->selection, self->priv->selection_changed_id);
 	}
 
-	bookmarks_set_empty (index == 0);	  
+	bookmarks_set_empty (self, (index == 0));
 }
 
 static void
-on_bookmark_list_changed (NautilusBookmarkList *bookmarks, gpointer data)
+on_bookmark_list_changed (NautilusBookmarkList *bookmarks,
+			  gpointer user_data)
 {
-	g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks));
+	NautilusBookmarksWindow *self = user_data;
 
 	/* maybe add logic here or in repopulate to save/restore selection */
-	repopulate ();
+	repopulate (self);
 }
 
 static void
 on_name_field_changed (GtkEditable *editable,
 		       gpointer     user_data)
 {
+	NautilusBookmarksWindow *self = user_data;
 	GtkTreeIter   iter;
-	g_return_if_fail(GTK_IS_TREE_VIEW(bookmark_list_widget));
-	g_return_if_fail(GTK_IS_ENTRY(name_field));
 
-	if (!get_selection_exists())
+	if (!get_selection_exists(self)) {
 		return;
+	}
 
 	/* Update text displayed in list instantly. Also remember that 
 	 * user has changed text so we update real bookmark later. 
 	 */
-	gtk_tree_selection_get_selected (bookmark_selection,
-					 NULL,
-					 &iter);
-	
-	gtk_list_store_set (bookmark_list_store, 
+	gtk_tree_selection_get_selected (self->priv->selection, NULL, &iter);
+	gtk_list_store_set (self->priv->model,
 			    &iter, BOOKMARK_LIST_COLUMN_NAME, 
-			    gtk_entry_get_text (GTK_ENTRY (name_field)),
+			    gtk_entry_get_text (GTK_ENTRY (self->priv->name_field)),
 			    -1);
-	text_changed = TRUE;
-	name_text_changed = TRUE;
-}
 
-static void
-open_selected_bookmark (NautilusWindow *window)
-{
-	NautilusBookmark *selected;
-	GFile *location;
-	
-	selected = get_selected_bookmark ();
-
-	if (!selected) {
-		return;
-	}
-
-	location = nautilus_bookmark_get_location (selected);
-	if (location == NULL) { 
-		return;
-	}
-
-	nautilus_window_go_to (window, location);
-
-	g_object_unref (location);
+	self->priv->text_changed = TRUE;
+	self->priv->name_text_changed = TRUE;
 }
 
 static void
-bookmarks_delete_bookmark (void)
+bookmarks_delete_bookmark (NautilusBookmarksWindow *self)
 {
 	GtkTreeIter iter;
 	GtkTreePath *path;
 	gint *indices, row, rows;
-
-	g_assert (GTK_IS_TREE_VIEW (bookmark_list_widget));
 	
-	if (!gtk_tree_selection_get_selected (bookmark_selection, NULL, &iter))
+	if (!gtk_tree_selection_get_selected (self->priv->selection, NULL, &iter)) {
 		return;
+	}
 
 	/* Remove the selected item from the list store. on_row_deleted() will
 	   remove it from the bookmark list. */
-	path = gtk_tree_model_get_path (GTK_TREE_MODEL (bookmark_list_store),
-					&iter);
+	path = gtk_tree_model_get_path (GTK_TREE_MODEL (self->priv->model), &iter);
 	indices = gtk_tree_path_get_indices (path);
 	row = indices[0];
 	gtk_tree_path_free (path);
 
-	gtk_list_store_remove (bookmark_list_store, &iter);
+	gtk_list_store_remove (self->priv->model, &iter);
 
 	/* Try to select the same row, or the last one in the list. */
-	rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (bookmark_list_store), NULL);
-	if (row >= rows)
+	rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (self->priv->model), NULL);
+	if (row >= rows) {
 		row = rows - 1;
+	}
 
 	if (row < 0) {
-		bookmarks_set_empty (TRUE);
+		bookmarks_set_empty (self, TRUE);
 	} else {
-		gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (bookmark_list_store),
+		gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (self->priv->model),
 					       &iter, NULL, row);
-		gtk_tree_selection_select_iter (bookmark_selection, &iter);
+		gtk_tree_selection_select_iter (self->priv->selection, &iter);
 	}
 }
 
@@ -441,35 +417,38 @@ static void
 on_remove_button_clicked (GtkButton *button,
                           gpointer   user_data)
 {
-        bookmarks_delete_bookmark ();
+	NautilusBookmarksWindow *self = user_data;
+        bookmarks_delete_bookmark (self);
 }
 
 static void
 on_up_button_clicked (GtkButton *button,
 		      gpointer   user_data)
 {
+	NautilusBookmarksWindow *self = user_data;
 	guint row;
 	GtkTreeIter iter;
 
-	row = get_selected_row ();
-	nautilus_bookmark_list_move_item (bookmarks, row, row - 1);
-	gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (bookmark_list_store),
+	row = get_selected_row (self);
+	nautilus_bookmark_list_move_item (self->priv->bookmarks, row, row - 1);
+	gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (self->priv->model),
 				       &iter, NULL, row - 1);
-	gtk_tree_selection_select_iter (bookmark_selection, &iter);
+	gtk_tree_selection_select_iter (self->priv->selection, &iter);
 }
 
 static void
 on_down_button_clicked (GtkButton *button,
 			gpointer   user_data)
 {
+	NautilusBookmarksWindow *self = user_data;
 	guint row;
 	GtkTreeIter iter;
 
-	row = get_selected_row ();
-	nautilus_bookmark_list_move_item (bookmarks, row, row + 1);
-	gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (bookmark_list_store),
+	row = get_selected_row (self);
+	nautilus_bookmark_list_move_item (self->priv->bookmarks, row, row + 1);
+	gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (self->priv->model),
 				       &iter, NULL, row + 1);
-	gtk_tree_selection_select_iter (bookmark_selection, &iter);
+	gtk_tree_selection_select_iter (self->priv->selection, &iter);
 }
 
 /* This is a bit of a kludge to get DnD to work. We check if the row in the
@@ -482,12 +461,11 @@ on_row_changed (GtkListStore *store,
 		GtkTreeIter *iter,
 		gpointer user_data)
 {
+	NautilusBookmarksWindow *self = user_data;
 	NautilusBookmark *bookmark = NULL, *bookmark_in_list;
 	gint *indices, row;
 	gboolean insert_bookmark = TRUE;
 
-	store = bookmark_list_store;
-
 	indices = gtk_tree_path_get_indices (path);
 	row = indices[0];
 	gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
@@ -496,33 +474,33 @@ on_row_changed (GtkListStore *store,
 
 	/* If the bookmark in the list doesn't match the changed one, it must
 	   have been dragged here, so we insert it into the list. */
-	if (row < (gint) nautilus_bookmark_list_length (bookmarks)) {
-		bookmark_in_list = nautilus_bookmark_list_item_at (bookmarks,
-								   row);
+	if (row < (gint) nautilus_bookmark_list_length (self->priv->bookmarks)) {
+		bookmark_in_list = nautilus_bookmark_list_item_at (self->priv->bookmarks, row);
 		if (bookmark_in_list == bookmark)
 			insert_bookmark = FALSE;
 	}
 
 	if (insert_bookmark) {
-		g_signal_handler_block (bookmarks,
-					bookmark_list_changed_signal_id);
-		nautilus_bookmark_list_insert_item (bookmarks, bookmark, row);
-		g_signal_handler_unblock (bookmarks,
-					  bookmark_list_changed_signal_id);
+		g_signal_handler_block (self->priv->bookmarks,
+					self->priv->bookmarks_changed_id);
+		nautilus_bookmark_list_insert_item (self->priv->bookmarks,
+						    bookmark, row);
+		g_signal_handler_unblock (self->priv->bookmarks,
+					  self->priv->bookmarks_changed_id);
 
 		/* The bookmark will be copied when inserted into the list, so
 		   we have to update the pointer in the list store. */
-		bookmark = nautilus_bookmark_list_item_at (bookmarks, row);
-		g_signal_handler_block (store, row_changed_signal_id);
+		bookmark = nautilus_bookmark_list_item_at (self->priv->bookmarks, row);
+		g_signal_handler_block (store, self->priv->row_changed_id);
 		gtk_list_store_set (store, iter,
 				    BOOKMARK_LIST_COLUMN_BOOKMARK, bookmark,
 				    -1);
-		g_signal_handler_unblock (store, row_changed_signal_id);
+		g_signal_handler_unblock (store, self->priv->row_changed_id);
 	}
 }
 
 static void
-update_bookmark_from_text (void)
+update_bookmark_from_text (NautilusBookmarksWindow *self)
 {
 	NautilusBookmark *bookmark, *bookmark_in_list;
 	const char *name;
@@ -531,57 +509,47 @@ update_bookmark_from_text (void)
 	GtkTreeIter iter;
 	GFile *location;
 
-	g_assert (GTK_IS_ENTRY (name_field));
-	g_assert (GTK_IS_ENTRY (uri_field));
-
-	if (!text_changed ||
-	    gtk_entry_get_text_length (GTK_ENTRY (uri_field)) == 0) {
+	if (!self->priv->text_changed ||
+	    gtk_entry_get_text_length (GTK_ENTRY (self->priv->uri_field)) == 0) {
 		return;
 	}
 
 	location = g_file_parse_name 
-		(gtk_entry_get_text (GTK_ENTRY (uri_field)));
-		
+		(gtk_entry_get_text (GTK_ENTRY (self->priv->uri_field)));
+
 	bookmark = nautilus_bookmark_new (location,
-					  name_text_changed ? gtk_entry_get_text (GTK_ENTRY (name_field)) : NULL,
+					  self->priv->name_text_changed ?
+					  gtk_entry_get_text (GTK_ENTRY (self->priv->name_field)) : NULL,
 					  NULL);
-		
 	g_object_unref (location);
 
-	selected_row = get_selected_row ();
+	selected_row = get_selected_row (self);
 
 	/* turn off list updating 'cuz otherwise the list-reordering code runs
 	 * after repopulate(), thus reordering the correctly-ordered list.
 	 */
-	g_signal_handler_block (bookmarks, 
-				bookmark_list_changed_signal_id);
-	nautilus_bookmark_list_delete_item_at (bookmarks, selected_row);
-	nautilus_bookmark_list_insert_item (bookmarks, bookmark, selected_row);
-	g_signal_handler_unblock (bookmarks, 
-				  bookmark_list_changed_signal_id);
+	g_signal_handler_block (self->priv->bookmarks, self->priv->bookmarks_changed_id);
+	nautilus_bookmark_list_delete_item_at (self->priv->bookmarks, selected_row);
+	nautilus_bookmark_list_insert_item (self->priv->bookmarks, bookmark, selected_row);
+	g_signal_handler_unblock (self->priv->bookmarks, self->priv->bookmarks_changed_id);
 	g_object_unref (bookmark);
 
 	/* We also have to update the bookmark pointer in the list
 	   store. */
-	gtk_tree_selection_get_selected (bookmark_selection,
-					 NULL, &iter);
-	g_signal_handler_block (bookmark_list_store,
-				row_changed_signal_id);
-
-	bookmark_in_list = nautilus_bookmark_list_item_at (bookmarks,
-							   selected_row);
+	gtk_tree_selection_get_selected (self->priv->selection, NULL, &iter);
+	g_signal_handler_block (self->priv->model, self->priv->row_changed_id);
 
+	bookmark_in_list = nautilus_bookmark_list_item_at (self->priv->bookmarks, selected_row);
 	name = nautilus_bookmark_get_name (bookmark_in_list);
 	icon = nautilus_bookmark_get_icon (bookmark_in_list);
 
-	gtk_list_store_set (bookmark_list_store, &iter,
+	gtk_list_store_set (self->priv->model, &iter,
 			    BOOKMARK_LIST_COLUMN_BOOKMARK, bookmark_in_list,
 			    BOOKMARK_LIST_COLUMN_NAME, name,
 			    BOOKMARK_LIST_COLUMN_ICON, icon,
 			    -1);
-	g_signal_handler_unblock (bookmark_list_store,
-				  row_changed_signal_id);
 
+	g_signal_handler_unblock (self->priv->model, self->priv->row_changed_id);
 	g_object_unref (icon);
 }
 
@@ -602,7 +570,8 @@ on_button_pressed (GtkTreeView *view,
 		   GdkEventButton *event,
 		   gpointer user_data)
 {
-	update_bookmark_from_text ();
+	NautilusBookmarksWindow *self = user_data;
+	update_bookmark_from_text (self);
 
 	return FALSE;
 }
@@ -612,12 +581,14 @@ on_key_pressed (GtkTreeView *view,
                 GdkEventKey *event,
                 gpointer user_data)
 {
+	NautilusBookmarksWindow *self = user_data;
+
         if (event->keyval == GDK_KEY_Delete || event->keyval == GDK_KEY_KP_Delete) {
-                bookmarks_delete_bookmark ();
+                bookmarks_delete_bookmark (self);
                 return TRUE;
         }
 
-	update_bookmark_from_text ();
+	update_bookmark_from_text (self);
 
         return FALSE;
 }
@@ -628,7 +599,23 @@ on_row_activated (GtkTreeView       *view,
                   GtkTreeViewColumn *column,
                   gpointer           user_data)
 {
-	open_selected_bookmark (user_data);
+	NautilusBookmarksWindow *self = user_data;
+	NautilusBookmark *selected;
+	GFile *location;
+
+	selected = get_selected_bookmark (self);
+
+	if (!selected) {
+		return;
+	}
+
+	location = nautilus_bookmark_get_location (selected);
+	if (location == NULL) {
+		return;
+	}
+
+	nautilus_window_go_to (self->priv->parent_window, location);
+	g_object_unref (location);
 }
 
 static void
@@ -636,14 +623,15 @@ on_row_deleted (GtkListStore *store,
 		GtkTreePath *path,
 		gpointer user_data)
 {
+	NautilusBookmarksWindow *self = user_data;
 	gint *indices, row;
 
 	indices = gtk_tree_path_get_indices (path);
 	row = indices[0];
 
-	g_signal_handler_block (bookmarks, bookmark_list_changed_signal_id);
-	nautilus_bookmark_list_delete_item_at (bookmarks, row);
-	g_signal_handler_unblock (bookmarks, bookmark_list_changed_signal_id);
+	g_signal_handler_block (self->priv->bookmarks, self->priv->bookmarks_changed_id);
+	nautilus_bookmark_list_delete_item_at (self->priv->bookmarks, row);
+	g_signal_handler_unblock (self->priv->bookmarks, self->priv->bookmarks_changed_id);
 }
 
 static gboolean
@@ -651,18 +639,19 @@ on_text_field_focus_out_event (GtkWidget *widget,
 			       GdkEventFocus *event,
 			       gpointer user_data)
 {
-	g_assert (NAUTILUS_IS_ENTRY (widget));
+	NautilusBookmarksWindow *self = user_data;
+	update_bookmark_from_text (self);
 
-	update_bookmark_from_text ();
 	return FALSE;
 }
 
 static void
-name_or_uri_field_activate (NautilusEntry *entry)
+name_or_uri_field_activate (NautilusEntry *entry,
+			    gpointer user_data)
 {
-	g_assert (NAUTILUS_IS_ENTRY (entry));
+	NautilusBookmarksWindow *self = user_data;
 
-	update_bookmark_from_text ();
+	update_bookmark_from_text (self);
 	nautilus_entry_select_all_at_idle (entry);
 }
 
@@ -670,68 +659,86 @@ static void
 on_uri_field_changed (GtkEditable *editable,
 		      gpointer user_data)
 {
+	NautilusBookmarksWindow *self = user_data;
+
 	/* Remember that user has changed text so we 
 	 * update real bookmark later. 
 	 */
-	text_changed = TRUE;
+	self->priv->text_changed = TRUE;
 }
 
-/**
- * nautilus_bookmarks_window_new:
- * 
- * Create a new bookmark-editing window. 
- * @list: The NautilusBookmarkList that this window will edit.
- *
- * Return value: A pointer to the new window.
- **/
-GtkWindow *
-nautilus_bookmarks_window_new (NautilusWindow *parent_window,
-			       NautilusBookmarkList *list)
+static void
+nautilus_bookmarks_window_dispose (GObject *object)
 {
-	GtkWindow         *window;
+	NautilusBookmarksWindow *self = NAUTILUS_BOOKMARKS_WINDOW (object);
+
+	if (self->priv->bookmarks_changed_id != 0) {
+		g_signal_handler_disconnect (self->priv->bookmarks,
+					     self->priv->bookmarks_changed_id);
+		self->priv->bookmarks_changed_id = 0;
+	}
+
+	g_clear_object (&self->priv->model);
+
+	G_OBJECT_CLASS (nautilus_bookmarks_window_parent_class)->dispose (object);
+}
+
+static void
+nautilus_bookmarks_window_constructed (GObject *object)
+{
+	NautilusBookmarksWindow *self = NAUTILUS_BOOKMARKS_WINDOW (object);
+	GtkBuilder *builder;
+	GError *error = NULL;
+	GtkWindow *window;
+	GtkWidget *content;
 	GtkTreeViewColumn *col;
-	GtkCellRenderer   *rend;
-	GtkBuilder        *builder;
+	GtkCellRenderer *rend;
 
-	bookmarks = list;
+	G_OBJECT_CLASS (nautilus_bookmarks_window_parent_class)->constructed (object);
 
 	builder = gtk_builder_new ();
 	if (!gtk_builder_add_from_resource (builder,
 					    "/org/gnome/nautilus/nautilus-bookmarks-window.ui",
-					    NULL)) {
-		return NULL;
-	}
+					    &error)) {
+		g_object_unref (builder);
 
-	window = GTK_WINDOW (gtk_builder_get_object (builder, "bookmarks_dialog"));
+		g_critical ("Can't load UI description for the bookmarks editor: %s", error->message);
+		g_error_free (error);
+		return;
+	}
 
+	window = GTK_WINDOW (object);
+	gtk_window_set_title (window, _("Bookmarks"));
 	gtk_window_set_default_size (window, 
 				     BOOKMARKS_WINDOW_INITIAL_WIDTH, 
 				     BOOKMARKS_WINDOW_INITIAL_HEIGHT);
 	gtk_window_set_application (window,
-				    gtk_window_get_application (GTK_WINDOW (parent_window)));
+				    gtk_window_get_application (GTK_WINDOW (self->priv->parent_window)));
 
 	gtk_window_set_destroy_with_parent (window, TRUE);
-	gtk_window_set_transient_for (window, GTK_WINDOW (parent_window));
+	gtk_window_set_transient_for (window, GTK_WINDOW (self->priv->parent_window));
 	gtk_window_set_position (window, GTK_WIN_POS_CENTER_ON_PARENT);
+	gtk_container_set_border_width (GTK_CONTAINER (window), 6);
 
 	g_signal_connect (window, "key-press-event",
 			  G_CALLBACK (nautilus_bookmarks_window_key_press_event_cb), NULL);
 
-	bookmark_list_widget = GTK_TREE_VIEW (gtk_builder_get_object (builder, "bookmark_tree_view"));
-	remove_button = GTK_WIDGET (gtk_builder_get_object (builder, "bookmark_remove_button"));
-	up_button = GTK_WIDGET (gtk_builder_get_object (builder, "bookmark_up_button"));
-	down_button = GTK_WIDGET (gtk_builder_get_object (builder, "bookmark_down_button"));
+	content = GTK_WIDGET (gtk_builder_get_object (builder, "bookmarks_window_content"));
+	gtk_container_add (GTK_CONTAINER (window), content);
+
+	/* tree view */
+	self->priv->tree_view = GTK_TREE_VIEW (gtk_builder_get_object (builder, "bookmark_tree_view"));
+	self->priv->selection = gtk_tree_view_get_selection (self->priv->tree_view);
+	gtk_tree_selection_set_mode (self->priv->selection, GTK_SELECTION_BROWSE);
 
 	rend = gtk_cell_renderer_pixbuf_new ();
-	g_object_set (rend,
-		      "follow-state", TRUE,
-		      NULL);
+	g_object_set (rend, "follow-state", TRUE, NULL);
 	col = gtk_tree_view_column_new_with_attributes ("Icon", 
 							rend,
 							"gicon", 
 							BOOKMARK_LIST_COLUMN_ICON,
 							NULL);
-	gtk_tree_view_append_column (bookmark_list_widget,
+	gtk_tree_view_append_column (self->priv->tree_view,
 				     GTK_TREE_VIEW_COLUMN (col));
 	gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (col),
 					      NAUTILUS_ICON_SIZE_SMALLER);
@@ -749,88 +756,150 @@ nautilus_bookmarks_window_new (NautilusWindow *parent_window,
 							"style",
 							BOOKMARK_LIST_COLUMN_STYLE,
 							NULL);
-	gtk_tree_view_append_column (bookmark_list_widget,
+	gtk_tree_view_append_column (self->priv->tree_view,
 				     GTK_TREE_VIEW_COLUMN (col));
-	
-	bookmark_list_store = create_bookmark_store ();
-	setup_empty_list ();
-	gtk_tree_view_set_model (bookmark_list_widget,
-				 GTK_TREE_MODEL (bookmark_empty_list_store));
-	
-	bookmark_selection =
-		GTK_TREE_SELECTION (gtk_tree_view_get_selection (bookmark_list_widget));
 
-	name_field = nautilus_entry_new ();
-	
-	gtk_widget_show (name_field);
+	self->priv->model = create_bookmark_store ();
+	setup_empty_list (self);
+
+	/* name entry */
+	self->priv->name_field = nautilus_entry_new ();
+	gtk_widget_show (self->priv->name_field);
 	gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "bookmark_name_placeholder")),
-			    name_field, TRUE, TRUE, 0);
+			    self->priv->name_field, TRUE, TRUE, 0);
 	
 	gtk_label_set_mnemonic_widget (
 		GTK_LABEL (gtk_builder_get_object (builder, "bookmark_name_label")),
-		name_field);
+		self->priv->name_field);
 
-	uri_field = nautilus_entry_new ();
-	gtk_widget_show (uri_field);
+	/* URI entry */
+	self->priv->uri_field = nautilus_entry_new ();
+	gtk_widget_show (self->priv->uri_field);
 	gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "bookmark_location_placeholder")),
-			    uri_field, TRUE, TRUE, 0);
+			    self->priv->uri_field, TRUE, TRUE, 0);
 
 	gtk_label_set_mnemonic_widget (
 		GTK_LABEL (gtk_builder_get_object (builder, "bookmark_location_label")),
-		uri_field);
-
-	bookmark_list_changed_signal_id =
-		g_signal_connect (bookmarks, "changed",
-				  G_CALLBACK (on_bookmark_list_changed), NULL);
-	row_changed_signal_id =
-		g_signal_connect (bookmark_list_store, "row_changed",
-				  G_CALLBACK (on_row_changed), NULL);
-	row_deleted_signal_id =
-		g_signal_connect (bookmark_list_store, "row_deleted",
-				  G_CALLBACK (on_row_deleted), NULL);
-        row_activated_signal_id =
-                g_signal_connect (bookmark_list_widget, "row_activated",
-                                  G_CALLBACK (on_row_activated), parent_window);
-        button_pressed_signal_id =
-                g_signal_connect (bookmark_list_widget, "button_press_event",
-                                  G_CALLBACK (on_button_pressed), NULL);
-        key_pressed_signal_id =
-                g_signal_connect (bookmark_list_widget, "key_press_event",
-                                  G_CALLBACK (on_key_pressed), NULL);
-	selection_changed_id =
-		g_signal_connect (bookmark_selection, "changed",
-				  G_CALLBACK (on_selection_changed), NULL);	
-
-	name_field_changed_signal_id =
-		g_signal_connect (name_field, "changed",
-				  G_CALLBACK (on_name_field_changed), NULL);
-                      		    
-	g_signal_connect (name_field, "focus_out_event",
-			  G_CALLBACK (on_text_field_focus_out_event), NULL);                            
-	g_signal_connect (name_field, "activate",
-			  G_CALLBACK (name_or_uri_field_activate), NULL);
-
-	uri_field_changed_signal_id = 
-		g_signal_connect (uri_field, "changed",
-				  G_CALLBACK (on_uri_field_changed), NULL);
-                      		    
-	g_signal_connect (uri_field, "focus_out_event",
-			  G_CALLBACK (on_text_field_focus_out_event), NULL);
-	g_signal_connect (uri_field, "activate",
-			  G_CALLBACK (name_or_uri_field_activate), NULL);
-	g_signal_connect (remove_button, "clicked",
-			  G_CALLBACK (on_remove_button_clicked), NULL);
-	g_signal_connect (up_button, "clicked",
-			  G_CALLBACK (on_up_button_clicked), NULL);
-	g_signal_connect (down_button, "clicked",
-			  G_CALLBACK (on_down_button_clicked), NULL);
-
-	gtk_tree_selection_set_mode (bookmark_selection, GTK_SELECTION_BROWSE);
-	
-	/* Fill in list widget with bookmarks, must be after signals are wired up. */
-	repopulate();
+		self->priv->uri_field);
+
+	/* buttons */
+	self->priv->remove_button = GTK_WIDGET (gtk_builder_get_object (builder, "bookmark_remove_button"));
+	self->priv->up_button = GTK_WIDGET (gtk_builder_get_object (builder, "bookmark_up_button"));
+	self->priv->down_button = GTK_WIDGET (gtk_builder_get_object (builder, "bookmark_down_button"));
 
 	g_object_unref (builder);
+
+	/* setup bookmarks list and signals */
+	self->priv->bookmarks = nautilus_application_get_bookmarks
+		(NAUTILUS_APPLICATION (g_application_get_default ()));
+	self->priv->bookmarks_changed_id =
+		g_signal_connect (self->priv->bookmarks, "changed",
+				  G_CALLBACK (on_bookmark_list_changed), self);
+
+	self->priv->row_changed_id =
+		g_signal_connect (self->priv->model, "row-changed",
+				  G_CALLBACK (on_row_changed), self);
+	self->priv->row_deleted_id =
+		g_signal_connect (self->priv->model, "row-deleted",
+				  G_CALLBACK (on_row_deleted), self);
+
+        self->priv->row_activated_id =
+                g_signal_connect (self->priv->tree_view, "row-activated",
+                                  G_CALLBACK (on_row_activated), self);
+        self->priv->button_press_id =
+                g_signal_connect (self->priv->tree_view, "button-press-event",
+                                  G_CALLBACK (on_button_pressed), self);
+        self->priv->key_press_id =
+                g_signal_connect (self->priv->tree_view, "key-press-event",
+                                  G_CALLBACK (on_key_pressed), self);
+	self->priv->selection_changed_id =
+		g_signal_connect (self->priv->selection, "changed",
+				  G_CALLBACK (on_selection_changed), self);
+
+	self->priv->name_changed_id =
+		g_signal_connect (self->priv->name_field, "changed",
+				  G_CALLBACK (on_name_field_changed), self);
+	g_signal_connect (self->priv->name_field, "focus_out_event",
+			  G_CALLBACK (on_text_field_focus_out_event), self);
+	g_signal_connect (self->priv->name_field, "activate",
+			  G_CALLBACK (name_or_uri_field_activate), self);
+
+	self->priv->uri_changed_id =
+		g_signal_connect (self->priv->uri_field, "changed",
+				  G_CALLBACK (on_uri_field_changed), self);
+	g_signal_connect (self->priv->uri_field, "focus_out_event",
+			  G_CALLBACK (on_text_field_focus_out_event), self);
+	g_signal_connect (self->priv->uri_field, "activate",
+			  G_CALLBACK (name_or_uri_field_activate), self);
+
+	g_signal_connect (self->priv->remove_button, "clicked",
+			  G_CALLBACK (on_remove_button_clicked), self);
+	g_signal_connect (self->priv->up_button, "clicked",
+			  G_CALLBACK (on_up_button_clicked), self);
+	g_signal_connect (self->priv->down_button, "clicked",
+			  G_CALLBACK (on_down_button_clicked), self);
 	
-	return GTK_WINDOW (window);
+	/* Fill in list widget with bookmarks, must be after signals are wired up. */
+	repopulate (self);
+}
+
+static void
+nautilus_bookmarks_window_set_property (GObject *object,
+					guint arg_id,
+					const GValue *value,
+					GParamSpec *pspec)
+{
+	NautilusBookmarksWindow *self = NAUTILUS_BOOKMARKS_WINDOW (object);
+
+	switch (arg_id) {
+	case PROP_PARENT_WINDOW:
+		self->priv->parent_window = g_value_get_object (value);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, arg_id, pspec);
+		break;
+	}
+}
+
+static void
+nautilus_bookmarks_window_init (NautilusBookmarksWindow *self)
+{
+	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NAUTILUS_TYPE_BOOKMARKS_WINDOW,
+						  NautilusBookmarksWindowPrivate);
+}
+
+static void
+nautilus_bookmarks_window_class_init (NautilusBookmarksWindowClass *klass)
+{
+	GObjectClass *oclass = G_OBJECT_CLASS (klass);
+
+	oclass->set_property = nautilus_bookmarks_window_set_property;
+	oclass->dispose = nautilus_bookmarks_window_dispose;
+	oclass->constructed = nautilus_bookmarks_window_constructed;
+
+	properties[PROP_PARENT_WINDOW] =
+		g_param_spec_object ("parent-window",
+				     "The NautilusWindow",
+				     "The parent NautilusWindow",
+				     NAUTILUS_TYPE_WINDOW,
+				     G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
+
+	g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
+	g_type_class_add_private (klass, sizeof (NautilusBookmarksWindowPrivate));
+}
+
+/**
+ * nautilus_bookmarks_window_new:
+ * 
+ * Create a new bookmark-editing window. 
+ * @parent_window: The parent NautilusWindow.
+ *
+ * Return value: A pointer to the new window.
+ **/
+GtkWindow *
+nautilus_bookmarks_window_new (NautilusWindow *parent_window)
+{
+	return g_object_new (NAUTILUS_TYPE_BOOKMARKS_WINDOW,
+			     "parent-window", parent_window,
+			     NULL);
 }
diff --git a/src/nautilus-bookmarks-window.h b/src/nautilus-bookmarks-window.h
index 08ddd48..47142d9 100644
--- a/src/nautilus-bookmarks-window.h
+++ b/src/nautilus-bookmarks-window.h
@@ -33,7 +33,32 @@
 #include "nautilus-window.h"
 #include "nautilus-bookmark-list.h"
 
-GtkWindow *nautilus_bookmarks_window_new (NautilusWindow       *parent_window,
-					  NautilusBookmarkList *bookmarks);
+#define NAUTILUS_TYPE_BOOKMARKS_WINDOW nautilus_bookmarks_window_get_type()
+#define NAUTILUS_BOOKMARKS_WINDOW(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_BOOKMARKS_WINDOW, NautilusBookmarksWindow))
+#define NAUTILUS_BOOKMARKS_WINDOW_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_BOOKMARKS_WINDOW, NautilusBookmarksWindowClass))
+#define NAUTILUS_IS_BOOKMARKS_WINDOW(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_BOOKMARKS_WINDOW))
+#define NAUTILUS_IS_BOOKMARKS_WINDOW_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_BOOKMARKS_WINDOW))
+#define NAUTILUS_BOOKMARKS_WINDOW_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_BOOKMARKS_WINDOW, NautilusBookmarksWindowClass))
+
+typedef struct NautilusBookmarksWindowPrivate NautilusBookmarksWindowPrivate;
+
+typedef struct  {
+	GtkWindow parent;
+
+	NautilusBookmarksWindowPrivate *priv;
+} NautilusBookmarksWindow;
+
+typedef struct {
+	GtkWindowClass parent_class;
+} NautilusBookmarksWindowClass;
+
+GType nautilus_bookmarks_window_get_type (void);
+
+GtkWindow *nautilus_bookmarks_window_new (NautilusWindow       *parent_window);
 
 #endif /* NAUTILUS_BOOKMARKS_WINDOW_H */
diff --git a/src/nautilus-bookmarks-window.ui b/src/nautilus-bookmarks-window.ui
index 55b49c0..5f2fc62 100644
--- a/src/nautilus-bookmarks-window.ui
+++ b/src/nautilus-bookmarks-window.ui
@@ -1,197 +1,208 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkWindow" id="bookmarks_dialog">
+  <object class="GtkBox" id="bookmarks_window_content">
+    <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="border_width">6</property>
-    <property name="title" translatable="yes">Bookmarks</property>
+    <property name="border_width">5</property>
+    <property name="spacing">18</property>
     <child>
-      <object class="GtkBox" id="hbox1">
+      <object class="GtkBox" id="box1">
+        <property name="width_request">200</property>
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="border_width">5</property>
-        <property name="spacing">18</property>
+        <property name="orientation">vertical</property>
         <child>
-          <object class="GtkBox" id="box1">
-            <property name="width_request">200</property>
+          <object class="GtkScrolledWindow" id="bookmark_list_window">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="orientation">vertical</property>
+            <property name="can_focus">True</property>
+            <property name="hscrollbar_policy">never</property>
+            <property name="shadow_type">in</property>
             <child>
-              <object class="GtkScrolledWindow" id="bookmark_list_window">
+              <object class="GtkTreeView" id="bookmark_tree_view">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="hscrollbar_policy">never</property>
-                <property name="shadow_type">in</property>
-                <child>
-                  <object class="GtkTreeView" id="bookmark_tree_view">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="headers_visible">False</property>
-                    <property name="reorderable">True</property>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="treeview-selection"/>
-                    </child>
-                  </object>
+                <property name="headers_visible">False</property>
+                <property name="reorderable">True</property>
+                <child internal-child="selection">
+                  <object class="GtkTreeSelection" id="treeview-selection"/>
                 </child>
               </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkToolbar" id="bookmarks_toolbar">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="toolbar_style">icons</property>
+            <property name="icon_size">1</property>
+            <style>
+              <class name="inline-toolbar"/>
+            </style>
             <child>
-              <object class="GtkToolbar" id="bookmarks_toolbar">
+              <object class="GtkToolItem" id="remove_toolitem">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="toolbar_style">icons</property>
-                <property name="icon_size">1</property>
-                <style>
-                  <class name="inline-toolbar"/>
-                </style>
                 <child>
-                  <object class="GtkToolItem" id="remove_toolitem">
+                  <object class="GtkBox" id="box3">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <child>
-                      <object class="GtkBox" id="box3">
+                      <object class="GtkButton" id="bookmark_remove_button">
                         <property name="visible">True</property>
-                        <property name="can_focus">False</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="has_tooltip">True</property>
+                        <property name="tooltip_text" translatable="yes">Remove</property>
                         <child>
-                          <object class="GtkButton" id="bookmark_remove_button">
+                          <object class="GtkImage" id="image2">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="has_tooltip">True</property>
-                            <property name="tooltip_text" translatable="yes">Remove</property>
-                            <child>
-                              <object class="GtkImage" id="image2">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="icon_name">list-remove-symbolic</property>
-                                <property name="icon-size">1</property>
-                              </object>
-                            </child>
+                            <property name="can_focus">False</property>
+                            <property name="icon_name">list-remove-symbolic</property>
+                            <property name="icon-size">1</property>
                           </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
-                          </packing>
                         </child>
                       </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
                     </child>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkSeparatorToolItem" id="toolbutton1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="draw">False</property>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                  </packing>
                 </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparatorToolItem" id="toolbutton1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="draw">False</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolItem" id="up_down_toolitem">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <child>
-                  <object class="GtkToolItem" id="up_down_toolitem">
+                  <object class="GtkBox" id="box2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <child>
-                      <object class="GtkBox" id="box2">
+                      <object class="GtkButton" id="bookmark_up_button">
                         <property name="visible">True</property>
-                        <property name="can_focus">False</property>
+                        <property name="can_focus">True</property>
+                        <property name="has_tooltip">True</property>
+                        <property name="tooltip_text" translatable="yes">Move Up</property>
                         <child>
-                          <object class="GtkButton" id="bookmark_up_button">
+                          <object class="GtkImage" id="image3">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="has_tooltip">True</property>
-                            <property name="tooltip_text" translatable="yes">Move Up</property>
-                            <child>
-                              <object class="GtkImage" id="image3">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="icon_name">go-up-symbolic</property>
-                                <property name="icon-size">1</property>
-                              </object>
-                            </child>
+                            <property name="can_focus">False</property>
+                            <property name="icon_name">go-up-symbolic</property>
+                            <property name="icon-size">1</property>
                           </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
-                          </packing>
                         </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="bookmark_down_button">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="has_tooltip">True</property>
+                        <property name="tooltip_text" translatable="yes">Move Down</property>
                         <child>
-                          <object class="GtkButton" id="bookmark_down_button">
+                          <object class="GtkImage" id="image5">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="has_tooltip">True</property>
-                            <property name="tooltip_text" translatable="yes">Move Down</property>
-                            <child>
-                              <object class="GtkImage" id="image5">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="icon_name">go-down-symbolic</property>
-                                <property name="icon-size">1</property>
-                              </object>
-                            </child>
+                            <property name="can_focus">False</property>
+                            <property name="icon_name">go-down-symbolic</property>
+                            <property name="icon-size">1</property>
                           </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">1</property>
-                          </packing>
                         </child>
                       </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
                     </child>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                  </packing>
                 </child>
               </object>
               <packing>
                 <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
               </packing>
             </child>
           </object>
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">0</property>
+            <property name="position">1</property>
           </packing>
         </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkBox" id="vbox2">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="valign">start</property>
+        <property name="hexpand">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">18</property>
         <child>
-          <object class="GtkBox" id="vbox2">
+          <object class="GtkBox" id="vbox4">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="valign">start</property>
-            <property name="hexpand">True</property>
             <property name="orientation">vertical</property>
-            <property name="spacing">18</property>
+            <property name="spacing">6</property>
             <child>
-              <object class="GtkBox" id="vbox4">
+              <object class="GtkLabel" id="bookmark_name_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">_Name</property>
+                <property name="use_underline">True</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="hbox3">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="orientation">vertical</property>
-                <property name="spacing">6</property>
                 <child>
-                  <object class="GtkLabel" id="bookmark_name_label">
+                  <object class="GtkLabel" id="label3">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">_Name</property>
-                    <property name="use_underline">True</property>
-                    <attributes>
-                      <attribute name="weight" value="bold"/>
-                    </attributes>
+                    <property name="label">    </property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -200,34 +211,11 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkBox" id="hbox3">
+                  <object class="GtkBox" id="bookmark_name_placeholder">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <child>
-                      <object class="GtkLabel" id="label3">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label">    </property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkBox" id="bookmark_name_placeholder">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <child>
-                          <placeholder/>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
+                      <placeholder/>
                     </child>
                   </object>
                   <packing>
@@ -238,29 +226,52 @@
                 </child>
               </object>
               <packing>
-                <property name="expand">False</property>
+                <property name="expand">True</property>
                 <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="vbox3">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkLabel" id="bookmark_location_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="xpad">2</property>
+                <property name="ypad">2</property>
+                <property name="label" translatable="yes">_Location</property>
+                <property name="use_underline">True</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="vbox3">
+              <object class="GtkBox" id="hbox2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="orientation">vertical</property>
-                <property name="spacing">6</property>
                 <child>
-                  <object class="GtkLabel" id="bookmark_location_label">
+                  <object class="GtkLabel" id="label2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="xpad">2</property>
-                    <property name="ypad">2</property>
-                    <property name="label" translatable="yes">_Location</property>
-                    <property name="use_underline">True</property>
-                    <attributes>
-                      <attribute name="weight" value="bold"/>
-                    </attributes>
+                    <property name="label">    </property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -269,34 +280,11 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkBox" id="hbox2">
+                  <object class="GtkBox" id="bookmark_location_placeholder">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <child>
-                      <object class="GtkLabel" id="label2">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label">    </property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkBox" id="bookmark_location_placeholder">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <child>
-                          <placeholder/>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
+                      <placeholder/>
                     </child>
                   </object>
                   <packing>
@@ -307,19 +295,24 @@
                 </child>
               </object>
               <packing>
-                <property name="expand">False</property>
+                <property name="expand">True</property>
                 <property name="fill">True</property>
                 <property name="position">1</property>
               </packing>
             </child>
           </object>
           <packing>
-            <property name="expand">True</property>
+            <property name="expand">False</property>
             <property name="fill">True</property>
             <property name="position">1</property>
           </packing>
         </child>
       </object>
+      <packing>
+        <property name="expand">True</property>
+        <property name="fill">True</property>
+        <property name="position">1</property>
+      </packing>
     </child>
   </object>
 </interface>



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