[nautilus] window: make Bookmark this Location insensitive when it's bookmarked
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] window: make Bookmark this Location insensitive when it's bookmarked
- Date: Mon, 22 Oct 2012 17:35:32 +0000 (UTC)
commit 8e6f68afb117f13c4ba3528aa03e9fab14a1e1e9
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Oct 22 13:07:28 2012 -0400
window: make Bookmark this Location insensitive when it's bookmarked
If the directory is in the bookmark list already (or if it's the home
directory), don't offer to bookmark it again.
https://bugzilla.gnome.org/show_bug.cgi?id=327707
src/nautilus-window-private.h | 1 +
src/nautilus-window.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index 382a160..25a629e 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -78,6 +78,7 @@ struct NautilusWindowDetails
guint sidebar_width_handler_id;
guint app_menu_visibility_id;
+ guint bookmarks_id;
};
/* window geometry */
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index d7a31c7..c73a529 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -669,6 +669,27 @@ nautilus_window_slot_close (NautilusWindow *window,
}
static void
+nautilus_window_sync_bookmarks (NautilusWindow *window)
+{
+ gboolean can_bookmark = FALSE;
+ NautilusWindowSlot *slot;
+ NautilusBookmarkList *bookmarks;
+ GtkAction *action;
+
+ slot = window->details->active_slot;
+
+ if (slot->location != NULL) {
+ bookmarks = nautilus_application_get_bookmarks
+ (NAUTILUS_APPLICATION (gtk_window_get_application (GTK_WINDOW (window))));
+ can_bookmark = nautilus_bookmark_list_can_bookmark_location (bookmarks, slot->location);
+ }
+
+ action = gtk_action_group_get_action (nautilus_window_get_main_action_group (window),
+ NAUTILUS_ACTION_ADD_BOOKMARK);
+ gtk_action_set_sensitive (action, can_bookmark);
+}
+
+static void
toggle_toolbar_search_button (NautilusWindow *window,
gboolean active)
{
@@ -737,6 +758,8 @@ nautilus_window_sync_location_widgets (NautilusWindow *window)
action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_FORWARD);
gtk_action_set_sensitive (action, active_slot->forward_list != NULL);
+
+ nautilus_window_sync_bookmarks (window);
}
GtkWidget *
@@ -1163,6 +1186,7 @@ nautilus_window_constructed (GObject *self)
NautilusWindow *window;
GtkWidget *grid;
NautilusWindowSlot *slot;
+ NautilusApplication *application;
window = NAUTILUS_WINDOW (self);
@@ -1210,6 +1234,11 @@ nautilus_window_constructed (GObject *self)
slot = nautilus_window_open_slot (window, 0);
nautilus_window_set_active_slot (window, slot);
+ application = NAUTILUS_APPLICATION (g_application_get_default ());
+ window->details->bookmarks_id =
+ g_signal_connect_swapped (nautilus_application_get_bookmarks (application), "changed",
+ G_CALLBACK (nautilus_window_sync_bookmarks), window);
+
nautilus_profile_end (NULL);
}
@@ -1264,6 +1293,7 @@ static void
nautilus_window_destroy (GtkWidget *object)
{
NautilusWindow *window;
+ NautilusApplication *application;
GList *slots_copy;
window = NAUTILUS_WINDOW (object);
@@ -1283,6 +1313,13 @@ nautilus_window_destroy (GtkWidget *object)
window->details->active_slot = NULL;
+ if (window->details->bookmarks_id != 0) {
+ application = NAUTILUS_APPLICATION (gtk_window_get_application (GTK_WINDOW (window)));
+ g_signal_handler_disconnect (nautilus_application_get_bookmarks (application),
+ window->details->bookmarks_id);
+ window->details->bookmarks_id = 0;
+ }
+
GTK_WIDGET_CLASS (nautilus_window_parent_class)->destroy (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]