diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c index c557465f..1660cebf 100644 --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -300,6 +300,7 @@ static void thunar_standard_view_scrolled (Gtk ThunarStandardView *standard_view); static void thunar_standard_view_size_allocate (ThunarStandardView *standard_view, GtkAllocation *allocation); +static gboolean thunar_standard_view_disable_actions (ThunarStandardView *standard_view); @@ -834,6 +835,9 @@ thunar_standard_view_constructor (GType type, g_signal_connect (adjustment, "value-changed", G_CALLBACK (thunar_standard_view_scrolled), object); + /* use focus-out-event signal to disable cut/copy/paste accelerators. workaround for bug #13680. */ + g_signal_connect_swapped (G_OBJECT (view), "focus-out-event", G_CALLBACK (thunar_standard_view_disable_actions), standard_view); + /* done, we have a working object */ return object; } @@ -4362,10 +4366,17 @@ void thunar_standard_view_context_menu (ThunarStandardView *standard_view) { GtkWidget *menu; + GtkWidget *view; GList *selected_items; _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view)); + /* figure out the real view */ + view = gtk_bin_get_child (GTK_BIN (standard_view)); + + /* disconnect the focus-out-event signal handler */ + g_signal_handlers_disconnect_by_func (view, thunar_standard_view_disable_actions, standard_view); + /* merge the custom menu actions for the selected items */ selected_items = (*THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->get_selected_items) (standard_view); thunar_standard_view_merge_custom_actions (standard_view, selected_items); @@ -4387,6 +4398,11 @@ G_GNUC_END_IGNORE_DEPRECATIONS else thunar_gtk_menu_run (GTK_MENU (menu)); + /* reconnect the focus-out-event signal handler */ + g_signal_connect_swapped (G_OBJECT (view), "focus-out-event", + G_CALLBACK (thunar_standard_view_disable_actions), + standard_view); + g_list_free_full (selected_items, (GDestroyNotify) gtk_tree_path_free); /* release the additional reference on the view */ @@ -4656,3 +4672,19 @@ thunar_standard_view_copy_history (ThunarStandardView *standard_view) return thunar_history_copy (standard_view->priv->history, NULL); } + + + +static gboolean +thunar_standard_view_disable_actions (ThunarStandardView *standard_view) +{ + _thunar_return_val_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view), FALSE); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + gtk_action_set_sensitive (standard_view->priv->action_cut, FALSE); + gtk_action_set_sensitive (standard_view->priv->action_copy, FALSE); + gtk_action_set_sensitive (standard_view->priv->action_paste, FALSE); +G_GNUC_END_IGNORE_DEPRECATIONS + + return FALSE; +}