[nautilus/gnome-3-6] places-sidebar: make sure to pre-select the active item on construction
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/gnome-3-6] places-sidebar: make sure to pre-select the active item on construction
- Date: Mon, 29 Oct 2012 12:02:01 +0000 (UTC)
commit 70e19941b3a747ab7caf79aec0d51a97d9bd7174
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Oct 29 07:50:37 2012 -0400
places-sidebar: make sure to pre-select the active item on construction
Ensure the current window URI gets selected in the sidebar also when
it's already set on the window at construction.
At the same time, move the sidebar construction from
nautilus_window_show() to nautilus_window_constructed().
https://bugzilla.gnome.org/show_bug.cgi?id=674052
src/nautilus-places-sidebar.c | 73 +++++++++++++++++++++++-----------------
src/nautilus-window-slot.c | 1 -
src/nautilus-window.c | 12 +++---
3 files changed, 48 insertions(+), 38 deletions(-)
---
diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c
index 9236dbd..b6fda4d 100644
--- a/src/nautilus-places-sidebar.c
+++ b/src/nautilus-places-sidebar.c
@@ -1025,41 +1025,52 @@ desktop_setting_changed_callback (gpointer user_data)
}
static void
-loading_uri_callback (NautilusWindow *window,
- char *location,
- NautilusPlacesSidebar *sidebar)
+update_current_uri (NautilusPlacesSidebar *sidebar)
{
GtkTreeSelection *selection;
GtkTreeIter iter;
gboolean valid;
char *uri;
- if (strcmp (sidebar->uri, location) != 0) {
- g_free (sidebar->uri);
- sidebar->uri = g_strdup (location);
-
- /* set selection if any place matches location */
- selection = gtk_tree_view_get_selection (sidebar->tree_view);
- gtk_tree_selection_unselect_all (selection);
- valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (sidebar->store),
- &iter);
+ if (sidebar->uri == NULL) {
+ return;
+ }
- while (valid) {
- gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
- PLACES_SIDEBAR_COLUMN_URI, &uri,
- -1);
- if (uri != NULL) {
- if (strcmp (uri, location) == 0) {
- g_free (uri);
- gtk_tree_selection_select_iter (selection, &iter);
- break;
- }
+ /* set selection if any place matches location */
+ selection = gtk_tree_view_get_selection (sidebar->tree_view);
+ gtk_tree_selection_unselect_all (selection);
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (sidebar->store),
+ &iter);
+
+ while (valid) {
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
+ PLACES_SIDEBAR_COLUMN_URI, &uri,
+ -1);
+
+ if (uri != NULL) {
+ if (strcmp (uri, sidebar->uri) == 0) {
g_free (uri);
+ gtk_tree_selection_select_iter (selection, &iter);
+ break;
}
- valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (sidebar->store),
- &iter);
+ g_free (uri);
}
- }
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (sidebar->store),
+ &iter);
+ }
+}
+
+static void
+loading_uri_callback (NautilusWindow *window,
+ char *location,
+ NautilusPlacesSidebar *sidebar)
+{
+ if (g_strcmp0 (sidebar->uri, location) != 0) {
+ g_free (sidebar->uri);
+ sidebar->uri = g_strdup (location);
+
+ update_current_uri (sidebar);
+ }
}
/* Computes the appropriate row and position for dropping */
@@ -3352,17 +3363,11 @@ nautilus_places_sidebar_set_parent_window (NautilusPlacesSidebar *sidebar,
slot = nautilus_window_get_active_slot (window);
sidebar->bookmarks = nautilus_application_get_bookmarks (app);
- sidebar->uri = nautilus_window_slot_get_current_uri (slot);
-
sidebar->bookmarks_changed_id =
g_signal_connect_swapped (sidebar->bookmarks, "changed",
G_CALLBACK (update_places),
sidebar);
- g_signal_connect_object (window, "loading_uri",
- G_CALLBACK (loading_uri_callback),
- sidebar, 0);
-
g_signal_connect_object (sidebar->volume_monitor, "volume_added",
G_CALLBACK (volume_added_callback), sidebar, 0);
g_signal_connect_object (sidebar->volume_monitor, "volume_removed",
@@ -3383,6 +3388,12 @@ nautilus_places_sidebar_set_parent_window (NautilusPlacesSidebar *sidebar,
G_CALLBACK (drive_changed_callback), sidebar, 0);
update_places (sidebar);
+
+ g_signal_connect_object (window, "loading-uri",
+ G_CALLBACK (loading_uri_callback),
+ sidebar, 0);
+ sidebar->uri = nautilus_window_slot_get_current_uri (slot);
+ update_current_uri (sidebar);
}
static void
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 43215d2..44c758d 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -878,7 +878,6 @@ nautilus_window_slot_get_current_uri (NautilusWindowSlot *slot)
return g_file_get_uri (slot->location);
}
- g_assert_not_reached ();
return NULL;
}
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 0adb78b..66145c6 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1230,6 +1230,12 @@ nautilus_window_constructed (GObject *self)
slot = nautilus_window_open_slot (window, 0);
nautilus_window_set_active_slot (window, slot);
+ if (g_settings_get_boolean (nautilus_window_state, NAUTILUS_WINDOW_STATE_START_WITH_SIDEBAR)) {
+ nautilus_window_show_sidebar (window);
+ } else {
+ nautilus_window_hide_sidebar (window);
+ }
+
nautilus_profile_end (NULL);
}
@@ -1793,12 +1799,6 @@ nautilus_window_show (GtkWidget *widget)
window = NAUTILUS_WINDOW (widget);
- if (g_settings_get_boolean (nautilus_window_state, NAUTILUS_WINDOW_STATE_START_WITH_SIDEBAR)) {
- nautilus_window_show_sidebar (window);
- } else {
- nautilus_window_hide_sidebar (window);
- }
-
GTK_WIDGET_CLASS (nautilus_window_parent_class)->show (widget);
gtk_ui_manager_ensure_update (window->details->ui_manager);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]