diff options
author | Dave Camp <dave@ximian.com> | 2002-07-11 06:31:04 +0000 |
---|---|---|
committer | Dave Camp <campd@src.gnome.org> | 2002-07-11 06:31:04 +0000 |
commit | 0d249582449c9c06c9808fd886b0a6b57c37a06c (patch) | |
tree | c91be32dbfb113eed217e6f5508c0e552d3d28b1 /components/history/nautilus-history-view.c | |
parent | b78fb7c01b5de87ce66dbda2e41a1e9d111ec529 (diff) | |
download | nautilus-0d249582449c9c06c9808fd886b0a6b57c37a06c.tar.gz |
Don't block the selection_changed signal. (row_activated_callback): Moved
2002-07-11 Dave Camp <dave@ximian.com>
* components/history/nautilus-history-view.c: (update_history):
Don't block the selection_changed signal.
(row_activated_callback): Moved here from
selection_changed_callback.
(update_click_policy), (click_policy_changed_callback): New
functions.
(nautilus_history_view_instance_init): Connect to row_activated,
set up a preferences callback for the click policy, and call
update_click_policy().
(nautilus_history_view_finalize): Remove the preferences callback.
Diffstat (limited to 'components/history/nautilus-history-view.c')
-rw-r--r-- | components/history/nautilus-history-view.c | 74 |
1 files changed, 52 insertions, 22 deletions
diff --git a/components/history/nautilus-history-view.c b/components/history/nautilus-history-view.c index 1d974aeba..a103f083b 100644 --- a/components/history/nautilus-history-view.c +++ b/components/history/nautilus-history-view.c @@ -29,6 +29,8 @@ #include <bonobo/bonobo-ui-util.h> #include <eel/eel-debug.h> +#include <eel/eel-gtk-extensions.h> +#include <eel/eel-preferences.h> #include <gtk/gtkcellrendererpixbuf.h> #include <gtk/gtkcellrenderertext.h> #include <gtk/gtkliststore.h> @@ -37,6 +39,8 @@ #include <gtk/gtkscrolledwindow.h> #include <libgnome/gnome-macros.h> #include <libnautilus-private/nautilus-bookmark.h> +#include <libnautilus-private/nautilus-global-preferences.h> + #include "nautilus-history-view.h" #define FACTORY_IID "OAFIID:Nautilus_History_View_Factory" @@ -123,11 +127,9 @@ update_history (NautilusHistoryView *view, selection = GTK_TREE_SELECTION (gtk_tree_view_get_selection (view->tree_view)); - g_signal_handler_block (selection, view->selection_changed_id); if (gtk_tree_model_get_iter_root (GTK_TREE_MODEL (store), &iter)) { gtk_tree_selection_select_iter (selection, &iter); } - g_signal_handler_unblock (selection, view->selection_changed_id); view->stop_updating_history = NULL; } @@ -143,34 +145,53 @@ history_changed_callback (NautilusHistoryView *view, } static void -on_selection_changed (GtkTreeSelection *selection, - gpointer user_data) +row_activated_callback (GtkTreeView *tree_view, + GtkTreePath *path, + GtkTreeViewColumn *column, + gpointer user_data) { NautilusHistoryView *view; - GtkTreeIter iter; - NautilusBookmark *bookmark; - char *uri; - - g_return_if_fail (user_data != NULL); - g_return_if_fail (NAUTILUS_IS_HISTORY_VIEW (user_data)); - + GtkTreeModel *model; + GtkTreeIter iter; + NautilusBookmark *bookmark; + char *uri; + view = NAUTILUS_HISTORY_VIEW (user_data); - - /* If this function returns FALSE, we don't have any rows selected */ - if (! gtk_tree_selection_get_selected (selection, NULL, &iter)) { + model = gtk_tree_view_get_model (tree_view); + + if (!gtk_tree_model_get_iter (model, &iter, path)) { return; } - - gtk_tree_model_get (GTK_TREE_MODEL (gtk_tree_view_get_model (view->tree_view)), &iter, - HISTORY_VIEW_COLUMN_BOOKMARK, &bookmark, - -1); + + gtk_tree_model_get + (model, &iter, HISTORY_VIEW_COLUMN_BOOKMARK, &bookmark, -1); /* Navigate to the clicked location. */ uri = nautilus_bookmark_get_uri (NAUTILUS_BOOKMARK (bookmark)); nautilus_view_open_location_in_this_window (NAUTILUS_VIEW (view), uri); - g_free (uri); + g_free (uri); +} +static void +update_click_policy (NautilusHistoryView *view) +{ + int policy; + + policy = eel_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY); + + eel_gtk_tree_view_set_activate_on_single_click + (view->tree_view, policy == NAUTILUS_CLICK_POLICY_SINGLE); +} + +static void +click_policy_changed_callback (gpointer user_data) +{ + NautilusHistoryView *view; + + view = NAUTILUS_HISTORY_VIEW (user_data); + + update_click_policy (view); } static void @@ -228,13 +249,18 @@ nautilus_history_view_instance_init (NautilusHistoryView *view) selection = gtk_tree_view_get_selection (tree_view); gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - view->selection_changed_id = g_signal_connect_object - (selection, "changed", - G_CALLBACK (on_selection_changed), view, 0); + + g_signal_connect_object + (tree_view, "row_activated", + G_CALLBACK (row_activated_callback), view, 0); g_signal_connect_object (view, "history_changed", G_CALLBACK (history_changed_callback), view, 0); + eel_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY, + click_policy_changed_callback, + view); + update_click_policy (view); } static void @@ -244,6 +270,10 @@ nautilus_history_view_finalize (GObject *object) view = NAUTILUS_HISTORY_VIEW (object); + eel_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY, + click_policy_changed_callback, + view); + if (view->stop_updating_history != NULL) { *view->stop_updating_history = TRUE; } |