Index: thunar/thunar-shortcuts-view.c =================================================================== --- thunar/thunar-shortcuts-view.c (révision 19614) +++ thunar/thunar-shortcuts-view.c (copie de travail) @@ -24,6 +24,7 @@ #include #endif +#include #include #include #include @@ -296,6 +297,7 @@ GdkEventButton *event) { ThunarShortcutsView *view = THUNAR_SHORTCUTS_VIEW (widget); + ThunarApplication *application; GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; @@ -313,18 +315,14 @@ /* 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); - - /* check if we have a right-click event */ - if (G_LIKELY (event->button != 3)) + + /* check if we have a right-click or middle-click event */ + if (G_LIKELY (event->button != 3 && event->button != 2)) return result; /* resolve the path at the cursor position */ if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), event->x, event->y, &path, NULL, NULL, NULL)) { - /* allocate a new tooltips object */ - tooltips = gtk_tooltips_new (); - exo_gtk_object_ref_sink (GTK_OBJECT (tooltips)); - /* determine the iterator for the selected row */ model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); gtk_tree_model_get_iter (model, &iter, path); @@ -335,99 +333,118 @@ /* determine the file for the given path */ file = thunar_shortcuts_model_file_for_iter (THUNAR_SHORTCUTS_MODEL (model), &iter); - /* prepare the internal loop */ - loop = g_main_loop_new (NULL, FALSE); + if (event->type == GDK_2BUTTON_PRESS && event->button == 2) + { + /* get application */ + application = thunar_application_get(); + thunar_application_open_window(application, file, gtk_widget_get_screen(GTK_WIDGET(view))); - /* prepare the popup menu */ - menu = gtk_menu_new (); - gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget)); - g_signal_connect_swapped (G_OBJECT (menu), "deactivate", G_CALLBACK (g_main_loop_quit), loop); - exo_gtk_object_ref_sink (GTK_OBJECT (menu)); + /* clean up */ + g_object_unref(G_OBJECT(application)); - /* prepend the custom actions for the selected file (if any) */ - if (G_LIKELY (file != NULL)) + /* we effectively handled the event */ + return TRUE; + } + else if (event->type == GDK_BUTTON_PRESS && event->button == 3) { - /* determine the toplevel window */ - window = gtk_widget_get_toplevel (widget); + /* allocate a new tooltips object */ + tooltips = gtk_tooltips_new (); + exo_gtk_object_ref_sink (GTK_OBJECT (tooltips)); + + /* prepare the internal loop */ + loop = g_main_loop_new (NULL, FALSE); - /* determine the actions for the selected file */ - actions = thunar_file_get_actions (file, window); + /* prepare the popup menu */ + menu = gtk_menu_new (); + gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget)); + g_signal_connect_swapped (G_OBJECT (menu), "deactivate", G_CALLBACK (g_main_loop_quit), loop); + exo_gtk_object_ref_sink (GTK_OBJECT (menu)); - /* check if we have any actions */ - if (G_LIKELY (actions != NULL)) + /* prepend the custom actions for the selected file (if any) */ + if (G_LIKELY (file != NULL)) { - /* append the actions */ - for (lp = actions; lp != NULL; lp = lp->next) + /* determine the toplevel window */ + window = gtk_widget_get_toplevel (widget); + + /* determine the actions for the selected file */ + actions = thunar_file_get_actions (file, window); + + /* check if we have any actions */ + if (G_LIKELY (actions != NULL)) { - /* append the menu item */ - item = gtk_action_create_menu_item (GTK_ACTION (lp->data)); + /* append the actions */ + for (lp = actions; lp != NULL; lp = lp->next) + { + /* append the menu item */ + item = gtk_action_create_menu_item (GTK_ACTION (lp->data)); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + gtk_widget_show (item); + + /* release the reference on the action */ + g_object_unref (G_OBJECT (lp->data)); + } + g_list_free (actions); + + /* append a menu separator */ + item = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); - - /* release the reference on the action */ - g_object_unref (G_OBJECT (lp->data)); } - g_list_free (actions); - - /* append a menu separator */ - item = gtk_separator_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); } - } - /* append the remove menu item */ - item = gtk_image_menu_item_new_with_mnemonic (_("_Remove Shortcut")); - g_object_set_data_full (G_OBJECT (item), I_("thunar-shortcuts-row"), - gtk_tree_row_reference_new (model, path), - (GDestroyNotify) gtk_tree_row_reference_free); - g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_remove_activated), widget); - gtk_widget_set_sensitive (item, mutable); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); + /* append the remove menu item */ + item = gtk_image_menu_item_new_with_mnemonic (_("_Remove Shortcut")); + g_object_set_data_full (G_OBJECT (item), I_("thunar-shortcuts-row"), + gtk_tree_row_reference_new (model, path), + (GDestroyNotify) gtk_tree_row_reference_free); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_remove_activated), widget); + gtk_widget_set_sensitive (item, mutable); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + gtk_widget_show (item); - /* set the remove stock icon */ - image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - gtk_widget_show (image); + /* set the remove stock icon */ + image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); + gtk_widget_show (image); - /* append the rename menu item */ - item = gtk_image_menu_item_new_with_mnemonic (_("Re_name Shortcut")); - g_object_set_data_full (G_OBJECT (item), I_("thunar-shortcuts-row"), - gtk_tree_row_reference_new (model, path), - (GDestroyNotify) gtk_tree_row_reference_free); - g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_rename_activated), widget); - gtk_widget_set_sensitive (item, mutable); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); + /* append the rename menu item */ + item = gtk_image_menu_item_new_with_mnemonic (_("Re_name Shortcut")); + g_object_set_data_full (G_OBJECT (item), I_("thunar-shortcuts-row"), + gtk_tree_row_reference_new (model, path), + (GDestroyNotify) gtk_tree_row_reference_free); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_rename_activated), widget); + gtk_widget_set_sensitive (item, mutable); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + gtk_widget_show (item); - /* append a menu separator */ - item = gtk_separator_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); + /* append a menu separator */ + item = gtk_separator_menu_item_new (); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + gtk_widget_show (item); - /* append the "Display icon emblems" item */ - item = gtk_check_menu_item_new_with_mnemonic (_("Display _Emblem Icons")); - exo_mutual_binding_new (G_OBJECT (view->preferences), "shortcuts-icon-emblems", G_OBJECT (item), "active"); - gtk_tooltips_set_tip (tooltips, item, _("Display emblem icons in the shortcuts list for all files for which " - "emblems have been defined in the file properties dialog."), NULL); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); + /* append the "Display icon emblems" item */ + item = gtk_check_menu_item_new_with_mnemonic (_("Display _Emblem Icons")); + exo_mutual_binding_new (G_OBJECT (view->preferences), "shortcuts-icon-emblems", G_OBJECT (item), "active"); + gtk_tooltips_set_tip (tooltips, item, _("Display emblem icons in the shortcuts list for all files for which " + "emblems have been defined in the file properties dialog."), NULL); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + gtk_widget_show (item); - /* run the internal loop */ - gtk_grab_add (menu); - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 0, event->time); - g_main_loop_run (loop); - gtk_grab_remove (menu); + /* run the internal loop */ + gtk_grab_add (menu); + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 0, event->time); + g_main_loop_run (loop); + gtk_grab_remove (menu); - /* clean up */ - g_object_unref (G_OBJECT (tooltips)); - g_object_unref (G_OBJECT (menu)); - gtk_tree_path_free (path); - g_main_loop_unref (loop); + /* clean up */ + g_object_unref (G_OBJECT (tooltips)); + g_object_unref (G_OBJECT (menu)); + gtk_tree_path_free (path); + g_main_loop_unref (loop); - /* we effectively handled the event */ - return TRUE; + /* we effectively handled the event */ + return TRUE; + } } return result;