diff --git a/ChangeLog b/ChangeLog index e377d770e32612a19c964c98eb88bc7eb4c30633..d8d153e650a57ad55121df1a8a6472de8f532e34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-09-23 Benedikt Meurer <benny@xfce.org> + + * thunar/thunar-details-view.c(thunar_details_view_button_press_event), + thunar/thunar-icon-view.c(thunar_icon_view_button_press_event): Open + folders in new windows on double middle-click events. + 2005-09-22 Benedikt Meurer <benny@xfce.org> * configure.in.in: Fix typo. diff --git a/thunar/thunar-details-view.c b/thunar/thunar-details-view.c index d13fd6b47699d13cfd5fec7b470d1ddf6fa92620..f279eb61465cec579ed66f1ae1389e2fceea58f9 100644 --- a/thunar/thunar-details-view.c +++ b/thunar/thunar-details-view.c @@ -368,6 +368,9 @@ thunar_details_view_button_press_event (GtkTreeView *tree_view, { GtkTreeSelection *selection; GtkTreePath *path; + GtkTreeIter iter; + ThunarFile *file; + GtkAction *action; /* we unselect all selected items if the user clicks on an empty * area of the treeview and no modifier key is active. @@ -406,6 +409,43 @@ thunar_details_view_button_press_event (GtkTreeView *tree_view, return TRUE; } + else if ((event->type == GDK_BUTTON_PRESS || event->type == GDK_2BUTTON_PRESS) && event->button == 2) + { + /* determine the path to the item that was middle-clicked */ + if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y, &path, NULL, NULL, NULL)) + { + /* select only the path to the item on which the user clicked */ + selection = gtk_tree_view_get_selection (tree_view); + gtk_tree_selection_unselect_all (selection); + gtk_tree_selection_select_path (selection, path); + + /* if the event was a double-click, then we'll open the file or folder (folder's are opened in new windows) */ + if (G_LIKELY (event->type == GDK_2BUTTON_PRESS)) + { + /* determine the file for the path */ + gtk_tree_model_get_iter (GTK_TREE_MODEL (THUNAR_STANDARD_VIEW (details_view)->model), &iter, path); + file = thunar_list_model_get_file (THUNAR_STANDARD_VIEW (details_view)->model, &iter); + if (G_LIKELY (file != NULL)) + { + /* determine the action to perform depending on the type of the file */ + action = gtk_action_group_get_action (THUNAR_STANDARD_VIEW (details_view)->action_group, + thunar_file_is_directory (file) ? "open-in-new-window" : "open"); + + /* emit the action */ + if (G_LIKELY (action != NULL)) + gtk_action_activate (action); + + /* release the file reference */ + g_object_unref (G_OBJECT (file)); + } + } + + /* cleanup */ + gtk_tree_path_free (path); + } + + return TRUE; + } return FALSE; } diff --git a/thunar/thunar-icon-view.c b/thunar/thunar-icon-view.c index dd9d09d97c42b58277681aaba3d6a8297ad1b2ca..b0dff3891a7bf83ac7732879d76cf1d5cbccff20 100644 --- a/thunar/thunar-icon-view.c +++ b/thunar/thunar-icon-view.c @@ -351,10 +351,13 @@ thunar_icon_view_button_press_event (ExoIconView *view, ThunarIconView *icon_view) { GtkTreePath *path; + GtkTreeIter iter; + ThunarFile *file; + GtkAction *action; - /* open the context menu on right clicks */ if (event->type == GDK_BUTTON_PRESS && event->button == 3) { + /* open the context menu on right clicks */ if (exo_icon_view_get_item_at_pos (view, event->x, event->y, &path, NULL)) { /* select the path on which the user clicked if not selected yet */ @@ -383,6 +386,44 @@ thunar_icon_view_button_press_event (ExoIconView *view, return TRUE; } + else if ((event->type == GDK_BUTTON_PRESS || event->type == GDK_2BUTTON_PRESS) && event->button == 2) + { + /* unselect all currently selected items */ + exo_icon_view_unselect_all (view); + + /* determine the path to the item that was middle-clicked */ + if (exo_icon_view_get_item_at_pos (view, event->x, event->y, &path, NULL)) + { + /* select only the path to the item on which the user clicked */ + exo_icon_view_select_path (view, path); + + /* if the event was a double-click, then we'll open the file or folder (folder's are opened in new windows) */ + if (G_LIKELY (event->type == GDK_2BUTTON_PRESS)) + { + /* determine the file for the path */ + gtk_tree_model_get_iter (GTK_TREE_MODEL (THUNAR_STANDARD_VIEW (icon_view)->model), &iter, path); + file = thunar_list_model_get_file (THUNAR_STANDARD_VIEW (icon_view)->model, &iter); + if (G_LIKELY (file != NULL)) + { + /* determine the action to perform depending on the type of the file */ + action = gtk_action_group_get_action (THUNAR_STANDARD_VIEW (icon_view)->action_group, + thunar_file_is_directory (file) ? "open-in-new-window" : "open"); + + /* emit the action */ + if (G_LIKELY (action != NULL)) + gtk_action_activate (action); + + /* release the file reference */ + g_object_unref (G_OBJECT (file)); + } + } + + /* cleanup */ + gtk_tree_path_free (path); + } + + return TRUE; + } return FALSE; }