From cfd0320fa91512b908f2c6faa955059b51b92115 Mon Sep 17 00:00:00 2001 From: Benedikt Meurer <benny@xfce.org> Date: Sun, 26 Feb 2006 14:04:34 +0000 Subject: [PATCH] 2006-02-26 Benedikt Meurer <benny@xfce.org> * thunar/thunar-standard-view.c(thunar_standard_view_drag_begin): Release the drag path list, just in case drag_end() wasn't called before (Gtk+ is somewhat buggy here, but I wasn't able to locate the bug yet). * thunar/thunar-window.c(thunar_window_action_location_bar_changed): Add "reload" button to the toolbar. * thunar/thunar-shortcuts-view.c, thunar/thunar-details-view.c: Use ExoTreeView, which provides a tree view with single-click support. * thunar/thunar-standard-view.c, thunar/thunar-icon-view.c: The internal widgets now both provide the "single-click" property, so we can connect it in the ThunarStandardView constructor. (Old svn revision: 20085) --- ChangeLog | 14 ++++ thunar/thunar-details-view.c | 120 +-------------------------------- thunar/thunar-icon-view.c | 1 - thunar/thunar-shortcuts-view.c | 109 ++---------------------------- thunar/thunar-standard-view.c | 6 +- thunar/thunar-window.c | 5 ++ 6 files changed, 32 insertions(+), 223 deletions(-) diff --git a/ChangeLog b/ChangeLog index cdb7ad5dd..c11c3466c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2006-02-26 Benedikt Meurer <benny@xfce.org> + + * thunar/thunar-standard-view.c(thunar_standard_view_drag_begin): + Release the drag path list, just in case drag_end() wasn't called + before (Gtk+ is somewhat buggy here, but I wasn't able to locate + the bug yet). + * thunar/thunar-window.c(thunar_window_action_location_bar_changed): + Add "reload" button to the toolbar. + * thunar/thunar-shortcuts-view.c, thunar/thunar-details-view.c: Use + ExoTreeView, which provides a tree view with single-click support. + * thunar/thunar-standard-view.c, thunar/thunar-icon-view.c: The internal + widgets now both provide the "single-click" property, so we can + connect it in the ThunarStandardView constructor. + 2006-02-25 Benedikt Meurer <benny@xfce.org> * configure.in.in: Bump soname. diff --git a/thunar/thunar-details-view.c b/thunar/thunar-details-view.c index 20f430382..c27107836 100644 --- a/thunar/thunar-details-view.c +++ b/thunar/thunar-details-view.c @@ -52,18 +52,9 @@ static void thunar_details_view_notify_model (GtkTreeView static gboolean thunar_details_view_button_press_event (GtkTreeView *tree_view, GdkEventButton *event, ThunarDetailsView *details_view); -static gboolean thunar_details_view_button_release_event (GtkTreeView *tree_view, - GdkEventButton *event, - ThunarDetailsView *details_view); -static gboolean thunar_details_view_motion_notify_event (GtkTreeView *tree_view, - GdkEventMotion *event, - ThunarDetailsView *details_view); static gboolean thunar_details_view_key_press_event (GtkTreeView *tree_view, GdkEventKey *event, ThunarDetailsView *details_view); -static void thunar_details_view_drag_begin (GtkWidget *tree_view, - GdkDragContext *context, - ThunarDetailsView *details_view); static void thunar_details_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, @@ -80,11 +71,6 @@ struct _ThunarDetailsViewClass struct _ThunarDetailsView { ThunarStandardView __parent__; - - /* TRUE if the next button_release_event should activate - * the row below the pointer (for single click support). - */ - gboolean button_release_activates; }; @@ -162,19 +148,13 @@ thunar_details_view_init (ThunarDetailsView *details_view) g_signal_connect (G_OBJECT (details_view), "notify::zoom-level", G_CALLBACK (thunar_details_view_zoom_level_changed), NULL); /* create the tree view to embed */ - tree_view = gtk_tree_view_new (); + tree_view = exo_tree_view_new (); g_signal_connect (G_OBJECT (tree_view), "notify::model", G_CALLBACK (thunar_details_view_notify_model), details_view); g_signal_connect (G_OBJECT (tree_view), "button-press-event", G_CALLBACK (thunar_details_view_button_press_event), details_view); - g_signal_connect (G_OBJECT (tree_view), "button-release-event", - G_CALLBACK (thunar_details_view_button_release_event), details_view); - g_signal_connect (G_OBJECT (tree_view), "motion-notify-event", - G_CALLBACK (thunar_details_view_motion_notify_event), details_view); g_signal_connect (G_OBJECT (tree_view), "key-press-event", G_CALLBACK (thunar_details_view_key_press_event), details_view); - g_signal_connect (G_OBJECT (tree_view), "drag-begin", - G_CALLBACK (thunar_details_view_drag_begin), details_view); g_signal_connect (G_OBJECT (tree_view), "row-activated", G_CALLBACK (thunar_details_view_row_activated), details_view); gtk_container_add (GTK_CONTAINER (details_view), tree_view); @@ -432,14 +412,6 @@ thunar_details_view_button_press_event (GtkTreeView *tree_view, GtkTreeIter iter; ThunarFile *file; GtkAction *action; - gboolean single_click; - - /* check if we're in single click mode */ - g_object_get (G_OBJECT (THUNAR_STANDARD_VIEW (details_view)->preferences), "misc-single-click", &single_click, NULL); - - /* check if the next button-release-event should activate the selected row (single click support) */ - details_view->button_release_activates = (single_click && event->type == GDK_BUTTON_PRESS && event->button == 1 - && (event->state & gtk_accelerator_get_default_mod_mask ()) == 0); /* we unselect all selected items if the user clicks on an empty * area of the treeview and no modifier key is active. @@ -491,7 +463,7 @@ thunar_details_view_button_press_event (GtkTreeView *tree_view, /* if the event was a double-click or we are in single-click mode, then * we'll open the file or folder (folder's are opened in new windows) */ - if (G_LIKELY (event->type == GDK_2BUTTON_PRESS || single_click)) + if (G_LIKELY (event->type == GDK_2BUTTON_PRESS || exo_tree_view_get_single_click (EXO_TREE_VIEW (tree_view)))) { /* determine the file for the path */ gtk_tree_model_get_iter (GTK_TREE_MODEL (THUNAR_STANDARD_VIEW (details_view)->model), &iter, path); @@ -518,81 +490,6 @@ thunar_details_view_button_press_event (GtkTreeView *tree_view, return TRUE; } - /* ignore double click events in single-click mode */ - if (G_UNLIKELY (single_click && event->type == GDK_2BUTTON_PRESS)) - { - details_view->button_release_activates = FALSE; - return TRUE; - } - - return FALSE; -} - - - -static gboolean -thunar_details_view_button_release_event (GtkTreeView *tree_view, - GdkEventButton *event, - ThunarDetailsView *details_view) -{ - GtkTreeViewColumn *column; - GtkTreePath *path; - gboolean single_click; - - /* check if we're in single click mode */ - g_object_get (G_OBJECT (THUNAR_STANDARD_VIEW (details_view)->preferences), "misc-single-click", &single_click, NULL); - - /* check if this button release should generate a "row-activated" event (single click support) */ - if (G_UNLIKELY (single_click && details_view->button_release_activates)) - { - /* reset button_release_activates state */ - details_view->button_release_activates = FALSE; - - /* determine the path to the row that should be activated */ - if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y, &path, &column, NULL, NULL)) - { - /* emit row-activated for the determined row */ - gtk_tree_view_row_activated (tree_view, path, column); - - /* cleanup */ - gtk_tree_path_free (path); - } - } - - return FALSE; -} - - - -static gboolean -thunar_details_view_motion_notify_event (GtkTreeView *tree_view, - GdkEventMotion *event, - ThunarDetailsView *details_view) -{ - GdkCursor *cursor; - gboolean single_click; - - /* check if we're in single click mode */ - g_object_get (G_OBJECT (THUNAR_STANDARD_VIEW (details_view)->preferences), "misc-single-click", &single_click, NULL); - - /* check if the event occurred on the tree view internal window */ - if (event->window != gtk_tree_view_get_bin_window (tree_view)) - return FALSE; - - /* check if we are in single click mode and check if a row is located at the event coordinates */ - if (single_click && gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y, NULL, NULL, NULL, NULL)) - { - /* setup a hand cursor */ - cursor = gdk_cursor_new (GDK_HAND2); - gdk_window_set_cursor (GTK_WIDGET (tree_view)->window, cursor); - gdk_cursor_unref (cursor); - } - else - { - /* reset the cursor to its default */ - gdk_window_set_cursor (GTK_WIDGET (tree_view)->window, NULL); - } - return FALSE; } @@ -615,19 +512,6 @@ thunar_details_view_key_press_event (GtkTreeView *tree_view, -static void -thunar_details_view_drag_begin (GtkWidget *tree_view, - GdkDragContext *context, - ThunarDetailsView *details_view) -{ - /* Do not activate the selected row on the next button_release_event, - * as the user started a drag operation with the mouse instead. - */ - details_view->button_release_activates = FALSE; -} - - - static void thunar_details_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path, diff --git a/thunar/thunar-icon-view.c b/thunar/thunar-icon-view.c index 79b8d42b3..552471230 100644 --- a/thunar/thunar-icon-view.c +++ b/thunar/thunar-icon-view.c @@ -235,7 +235,6 @@ thunar_icon_view_init (ThunarIconView *icon_view) g_signal_connect (G_OBJECT (view), "key-press-event", G_CALLBACK (thunar_icon_view_key_press_event), icon_view); g_signal_connect (G_OBJECT (view), "item-activated", G_CALLBACK (thunar_icon_view_item_activated), icon_view); g_signal_connect_swapped (G_OBJECT (view), "selection-changed", G_CALLBACK (thunar_standard_view_selection_changed), icon_view); - exo_binding_new (G_OBJECT (THUNAR_STANDARD_VIEW (icon_view)->preferences), "misc-single-click", G_OBJECT (view), "single-click"); gtk_container_add (GTK_CONTAINER (icon_view), view); gtk_widget_show (view); diff --git a/thunar/thunar-shortcuts-view.c b/thunar/thunar-shortcuts-view.c index e8cc4e11f..5dffd0cd0 100644 --- a/thunar/thunar-shortcuts-view.c +++ b/thunar/thunar-shortcuts-view.c @@ -55,10 +55,6 @@ static void thunar_shortcuts_view_init (ThunarShortcut static void thunar_shortcuts_view_finalize (GObject *object); static gboolean thunar_shortcuts_view_button_press_event (GtkWidget *widget, GdkEventButton *event); -static gboolean thunar_shortcuts_view_button_release_event (GtkWidget *widget, - GdkEventButton *event); -static gboolean thunar_shortcuts_view_motion_notify_event (GtkWidget *widget, - GdkEventMotion *event); static void thunar_shortcuts_view_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, @@ -76,8 +72,6 @@ static gboolean thunar_shortcuts_view_drag_motion (GtkWidget gint x, gint y, guint time); -static void thunar_shortcuts_view_drag_begin (GtkWidget *widget, - GdkDragContext *context); static void thunar_shortcuts_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column); @@ -108,19 +102,14 @@ static gboolean thunar_shortcuts_view_separator_func (GtkTreeModel struct _ThunarShortcutsViewClass { - GtkTreeViewClass __parent__; + ExoTreeViewClass __parent__; }; struct _ThunarShortcutsView { - GtkTreeView __parent__; + ExoTreeView __parent__; ThunarPreferences *preferences; - /* TRUE if the next button_release_event should - * fire a "row-activated" (single click support). - */ - gboolean button_release_activates; - #if GTK_CHECK_VERSION(2,8,0) /* id of the signal used to queue a resize on the * column whenever the shortcuts icon size is changed. @@ -170,7 +159,7 @@ thunar_shortcuts_view_get_type (void) NULL, }; - type = g_type_register_static (GTK_TYPE_TREE_VIEW, I_("ThunarShortcutsView"), &info, 0); + type = g_type_register_static (EXO_TYPE_TREE_VIEW, I_("ThunarShortcutsView"), &info, 0); } return type; @@ -193,12 +182,9 @@ thunar_shortcuts_view_class_init (ThunarShortcutsViewClass *klass) gtkwidget_class = GTK_WIDGET_CLASS (klass); gtkwidget_class->button_press_event = thunar_shortcuts_view_button_press_event; - gtkwidget_class->button_release_event = thunar_shortcuts_view_button_release_event; - gtkwidget_class->motion_notify_event = thunar_shortcuts_view_motion_notify_event; gtkwidget_class->drag_data_received = thunar_shortcuts_view_drag_data_received; gtkwidget_class->drag_drop = thunar_shortcuts_view_drag_drop; gtkwidget_class->drag_motion = thunar_shortcuts_view_drag_motion; - gtkwidget_class->drag_begin = thunar_shortcuts_view_drag_begin; gtktree_view_class = GTK_TREE_VIEW_CLASS (klass); gtktree_view_class->row_activated = thunar_shortcuts_view_row_activated; @@ -235,6 +221,9 @@ thunar_shortcuts_view_init (ThunarShortcutsView *view) view->preferences = thunar_preferences_get (); g_signal_connect_swapped (G_OBJECT (view->preferences), "notify::shortcuts-icon-emblems", G_CALLBACK (gtk_widget_queue_draw), view); + /* apply the single-click mode setting */ + exo_binding_new (G_OBJECT (view->preferences), "misc-single-click", G_OBJECT (view), "single-click"); + /* allocate a single column for our renderers */ column = g_object_new (GTK_TYPE_TREE_VIEW_COLUMN, "reorderable", FALSE, @@ -334,14 +323,6 @@ thunar_shortcuts_view_button_press_event (GtkWidget *widget, /* check if we are in single-click mode */ g_object_get (G_OBJECT (view->preferences), "misc-single-click", &single_click, NULL); - /* check if the next button-release-event should activate the selected row (single click support) */ - view->button_release_activates = (single_click && event->type == GDK_BUTTON_PRESS && event->button == 1 - && (event->state & gtk_accelerator_get_default_mod_mask ()) == 0); - - /* ignore all kinds of double click events in single-click mode */ - if (G_UNLIKELY (single_click && event->type == GDK_2BUTTON_PRESS)) - return TRUE; - /* let the widget process the event first (handles focussing and scrolling) */ result = (*GTK_WIDGET_CLASS (thunar_shortcuts_view_parent_class)->button_press_event) (widget, event); @@ -538,68 +519,6 @@ thunar_shortcuts_view_button_press_event (GtkWidget *widget, -static gboolean -thunar_shortcuts_view_button_release_event (GtkWidget *widget, - GdkEventButton *event) -{ - ThunarShortcutsView *view = THUNAR_SHORTCUTS_VIEW (widget); - GtkTreeViewColumn *column; - GtkTreePath *path; - gboolean single_click; - - /* check if we're in single-click mode */ - g_object_get (G_OBJECT (view->preferences), "misc-single-click", &single_click, NULL); - if (G_UNLIKELY (single_click && view->button_release_activates)) - { - /* reset button_release_activates state */ - view->button_release_activates = FALSE; - - /* determine the path to the row that should be activated */ - if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (view), event->x, event->y, &path, &column, NULL, NULL)) - { - /* emit row-activated for the determined row */ - gtk_tree_view_row_activated (GTK_TREE_VIEW (view), path, column); - - /* cleanup */ - gtk_tree_path_free (path); - } - } - - return (*GTK_WIDGET_CLASS (thunar_shortcuts_view_parent_class)->button_release_event) (widget, event); -} - - - -static gboolean -thunar_shortcuts_view_motion_notify_event (GtkWidget *widget, - GdkEventMotion *event) -{ - ThunarShortcutsView *view = THUNAR_SHORTCUTS_VIEW (widget); - GdkCursor *cursor; - gboolean single_click; - - /* check if we're in single-click mode */ - g_object_get (G_OBJECT (view->preferences), "misc-single-click", &single_click, NULL); - - /* check if we are in single-click mode and have a path for the mouse pointer position */ - if (G_UNLIKELY (single_click && gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), event->x, event->y, NULL, NULL, NULL, NULL))) - { - /* setup hand cursor */ - cursor = gdk_cursor_new (GDK_HAND2); - gdk_window_set_cursor (widget->window, cursor); - gdk_cursor_unref (cursor); - } - else - { - /* reset the cursor to its default */ - gdk_window_set_cursor (widget->window, NULL); - } - - return (*GTK_WIDGET_CLASS (thunar_shortcuts_view_parent_class)->motion_notify_event) (widget, event); -} - - - static void thunar_shortcuts_view_drag_data_received (GtkWidget *widget, GdkDragContext *context, @@ -711,22 +630,6 @@ thunar_shortcuts_view_drag_motion (GtkWidget *widget, -static void -thunar_shortcuts_view_drag_begin (GtkWidget *widget, - GdkDragContext *context) -{ - ThunarShortcutsView *view = THUNAR_SHORTCUTS_VIEW (widget); - - /* Do not activate the selected row on the next button_release_event, - * as the user started a drag operation with the mouse instead. - */ - view->button_release_activates = FALSE; - - (*GTK_WIDGET_CLASS (thunar_shortcuts_view_parent_class)->drag_begin) (widget, context); -} - - - static void thunar_shortcuts_view_row_activated (GtkTreeView *tree_view, GtkTreePath *path, diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c index f94041d9a..73f92abbd 100644 --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -618,6 +618,9 @@ thunar_standard_view_constructor (GType type, */ g_object_set (G_OBJECT (view), "model", standard_view->model, NULL); + /* apply the single-click mode to the view */ + exo_binding_new (G_OBJECT (standard_view->preferences), "misc-single-click", G_OBJECT (view), "single-click"); + /* apply the default sort column and sort order */ g_object_get (G_OBJECT (standard_view->preferences), "last-sort-column", &sort_column, "last-sort-order", &sort_order, NULL); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (standard_view->model), sort_column, sort_order); @@ -2626,7 +2629,8 @@ thunar_standard_view_drag_begin (GtkWidget *view, GdkPixbuf *icon; gint size; - g_return_if_fail (standard_view->priv->drag_path_list == NULL); + /* release the drag path list (just in case the drag-end wasn't fired before) */ + thunar_vfs_path_list_free (standard_view->priv->drag_path_list); /* query the list of selected URIs */ standard_view->priv->drag_path_list = thunar_file_list_to_path_list (standard_view->selected_files); diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c index 49efebb2e..bb8a2401b 100644 --- a/thunar/thunar-window.c +++ b/thunar/thunar-window.c @@ -1107,6 +1107,11 @@ thunar_window_action_location_bar_changed (GtkRadioAction *action, gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1); gtk_widget_show (GTK_WIDGET (toolitem)); + /* add the "reload" action */ + toolitem = thunar_gtk_action_group_create_tool_item (window->action_group, "reload"); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1); + gtk_widget_show (GTK_WIDGET (toolitem)); + /* add a separator */ toolitem = gtk_separator_tool_item_new (); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1); -- GitLab