[nautilus] bookmarks: cleanup NautilusWindow bookmark code
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] bookmarks: cleanup NautilusWindow bookmark code
- Date: Mon, 16 Jul 2012 05:58:45 +0000 (UTC)
commit e6291e85e6c959a0d84f948470700021e40bada3
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Jul 16 01:53:38 2012 -0400
bookmarks: cleanup NautilusWindow bookmark code
- move NautilusBookmarkList ownership to NautilusApplication, and avoid
making it a separate singleton
- move NautilusBookmarksWindow ownership to NautilusApplication as well,
since it's global and not per-window
- remove nautilus-window-bookmarks.[ch], since at this point, it only
contains dead or unused code
src/Makefile.am | 2 -
src/nautilus-application.c | 34 +++++++++-
src/nautilus-application.h | 6 ++
src/nautilus-bookmark-list.c | 23 ------
src/nautilus-places-sidebar.c | 4 +-
src/nautilus-window-bookmarks.c | 147 ---------------------------------------
src/nautilus-window-bookmarks.h | 36 ----------
src/nautilus-window-menus.c | 18 ++++-
src/nautilus-window-private.h | 4 -
src/nautilus-window.c | 4 -
10 files changed, 56 insertions(+), 222 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 7226dff..f7a0120 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -154,8 +154,6 @@ nautilus_SOURCES = \
nautilus-view-dnd.h \
nautilus-view-factory.c \
nautilus-view-factory.h \
- nautilus-window-bookmarks.c \
- nautilus-window-bookmarks.h \
nautilus-window-manage-views.c \
nautilus-window-manage-views.h \
nautilus-window-menus.c \
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 2d13d4b..69a77cf 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -34,6 +34,7 @@
#include "nautilus-empty-view.h"
#endif /* ENABLE_EMPTY_VIEW */
+#include "nautilus-bookmarks-window.h"
#include "nautilus-connect-server-dialog.h"
#include "nautilus-desktop-icon-view.h"
#include "nautilus-desktop-window.h"
@@ -46,7 +47,6 @@
#include "nautilus-progress-ui-handler.h"
#include "nautilus-self-check-functions.h"
#include "nautilus-window.h"
-#include "nautilus-window-bookmarks.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-window-private.h"
#include "nautilus-window-slot.h"
@@ -110,8 +110,37 @@ struct _NautilusApplicationPriv {
gchar *geometry;
NotifyNotification *unmount_notify;
+
+ GtkWidget *bookmarks_window;
+ NautilusBookmarkList *bookmark_list;
};
+NautilusBookmarkList *
+nautilus_application_get_bookmarks (NautilusApplication *application)
+{
+ return application->priv->bookmark_list;
+}
+
+void
+nautilus_application_edit_bookmarks (NautilusApplication *application,
+ NautilusWindow *window)
+{
+ 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)));
+ gtk_window_present (bookmarks_window);
+}
void
nautilus_application_notify_unmount_done (NautilusApplication *application,
@@ -921,6 +950,7 @@ nautilus_application_finalize (GObject *object)
g_clear_object (&application->priv->volume_monitor);
g_clear_object (&application->priv->progress_handler);
+ g_clear_object (&application->priv->bookmark_list);
g_free (application->priv->geometry);
@@ -1354,6 +1384,8 @@ nautilus_application_startup (GApplication *app)
g_signal_connect_object (self->priv->volume_monitor, "mount_added",
G_CALLBACK (mount_added_callback), self, 0);
+ self->priv->bookmark_list = nautilus_bookmark_list_new ();
+
/* Check the user's ~/.nautilus directories and post warnings
* if there are problems.
*/
diff --git a/src/nautilus-application.h b/src/nautilus-application.h
index 48a1c94..6dfb0eb 100644
--- a/src/nautilus-application.h
+++ b/src/nautilus-application.h
@@ -28,6 +28,7 @@
#include <gio/gio.h>
#include <gtk/gtk.h>
+#include "nautilus-bookmark-list.h"
#include "nautilus-window.h"
#define NAUTILUS_DESKTOP_ICON_VIEW_IID "OAFIID:Nautilus_File_Manager_Desktop_Icon_View"
@@ -77,4 +78,9 @@ void nautilus_application_notify_unmount_show (NautilusApplication *application,
void nautilus_application_notify_unmount_done (NautilusApplication *application,
const gchar *message);
+NautilusBookmarkList *
+ nautilus_application_get_bookmarks (NautilusApplication *application);
+void nautilus_application_edit_bookmarks (NautilusApplication *application,
+ NautilusWindow *window);
+
#endif /* __NAUTILUS_APPLICATION_H__ */
diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c
index 07e5a0c..6f2971a 100644
--- a/src/nautilus-bookmark-list.c
+++ b/src/nautilus-bookmark-list.c
@@ -45,7 +45,6 @@ enum {
};
static guint signals[LAST_SIGNAL];
-static NautilusBookmarkList *singleton = NULL;
/* forward declarations */
@@ -172,34 +171,12 @@ do_finalize (GObject *object)
G_OBJECT_CLASS (nautilus_bookmark_list_parent_class)->finalize (object);
}
-static GObject *
-do_constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- GObject *retval;
-
- if (singleton != NULL) {
- return g_object_ref (singleton);
- }
-
- retval = G_OBJECT_CLASS (nautilus_bookmark_list_parent_class)->constructor
- (type, n_construct_params, construct_params);
-
- singleton = NAUTILUS_BOOKMARK_LIST (retval);
- g_object_add_weak_pointer (retval, (gpointer) &singleton);
-
- return retval;
-}
-
-
static void
nautilus_bookmark_list_class_init (NautilusBookmarkListClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = do_finalize;
- object_class->constructor = do_constructor;
signals[CHANGED] =
g_signal_new ("changed",
diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c
index d8cc816..d0c1e9d 100644
--- a/src/nautilus-places-sidebar.c
+++ b/src/nautilus-places-sidebar.c
@@ -3333,7 +3333,6 @@ nautilus_places_sidebar_dispose (GObject *object)
}
g_clear_object (&sidebar->store);
- g_clear_object (&sidebar->bookmarks);
if (sidebar->go_to_after_mount_slot) {
g_object_remove_weak_pointer (G_OBJECT (sidebar->go_to_after_mount_slot),
@@ -3393,12 +3392,13 @@ nautilus_places_sidebar_set_parent_window (NautilusPlacesSidebar *sidebar,
NautilusWindow *window)
{
NautilusWindowSlot *slot;
+ NautilusApplication *app = NAUTILUS_APPLICATION (g_application_get_default ());
sidebar->window = window;
slot = nautilus_window_get_active_slot (window);
- sidebar->bookmarks = nautilus_bookmark_list_new ();
+ sidebar->bookmarks = nautilus_application_get_bookmarks (app);
sidebar->uri = nautilus_window_slot_get_current_uri (slot);
sidebar->bookmarks_changed_id =
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index b178ebf..34ac23f 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -36,7 +36,6 @@
#include "nautilus-navigation-action.h"
#include "nautilus-notebook.h"
#include "nautilus-window-manage-views.h"
-#include "nautilus-window-bookmarks.h"
#include "nautilus-window-private.h"
#include "nautilus-desktop-window.h"
#include <gtk/gtk.h>
@@ -320,14 +319,27 @@ static void
action_add_bookmark_callback (GtkAction *action,
gpointer user_data)
{
- nautilus_window_add_bookmark_for_current_location (NAUTILUS_WINDOW (user_data));
+ NautilusWindow *window = user_data;
+ NautilusApplication *app = NAUTILUS_APPLICATION (g_application_get_default ());
+ NautilusBookmark *bookmark;
+ NautilusWindowSlot *slot;
+ NautilusBookmarkList *list;
+
+ slot = nautilus_window_get_active_slot (window);
+ bookmark = slot->current_location_bookmark;
+ list = nautilus_application_get_bookmarks (app);
+
+ if (!nautilus_bookmark_list_contains (list, bookmark)) {
+ nautilus_bookmark_list_append (list, bookmark);
+ }
}
static void
action_edit_bookmarks_callback (GtkAction *action,
gpointer user_data)
{
- nautilus_window_edit_bookmarks (NAUTILUS_WINDOW (user_data));
+ NautilusApplication *app = NAUTILUS_APPLICATION (g_application_get_default ());
+ nautilus_application_edit_bookmarks (app, NAUTILUS_WINDOW (user_data));
}
static void
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index 4ebec16..ef444a1 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -45,10 +45,6 @@ struct NautilusWindowDetails
guint extensions_menu_merge_id;
GtkActionGroup *extensions_menu_action_group;
- GtkActionGroup *bookmarks_action_group;
- guint bookmarks_merge_id;
- NautilusBookmarkList *bookmark_list;
-
NautilusWindowShowHiddenFilesMode show_hidden_files_mode;
/* View As menu */
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index f346294..d896dde 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -41,7 +41,6 @@
#include "nautilus-toolbar.h"
#include "nautilus-view-factory.h"
#include "nautilus-window-manage-views.h"
-#include "nautilus-window-bookmarks.h"
#include "nautilus-window-slot.h"
#include <eel/eel-debug.h>
@@ -1115,8 +1114,6 @@ nautilus_window_constructed (GObject *self)
gtk_widget_show (window->details->main_view);
window->details->notebook = create_notebook (window);
-
- nautilus_window_initialize_bookmarks_menu (window);
nautilus_window_set_initial_window_geometry (window);
slot = nautilus_window_open_slot (window, 0);
@@ -1218,7 +1215,6 @@ nautilus_window_finalize (GObject *object)
nautilus_window_finalize_menus (window);
g_clear_object (&window->details->nav_state);
- g_clear_object (&window->details->bookmark_list);
g_clear_object (&window->details->ui_manager);
free_stored_viewers (window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]