diff --git a/src/swfmoz_dialog.c b/src/swfmoz_dialog.c index c05c952..2c62212 100644 --- a/src/swfmoz_dialog.c +++ b/src/swfmoz_dialog.c @@ -162,12 +162,40 @@ swfmoz_dialog_save_media (GtkButton *button, SwfmozDialog *dialog) gtk_window_present (GTK_WINDOW (chooser)); } +static gboolean +swfmoz_dialog_manage_selection (GtkTreeSelection *selection, + GtkTreeModel *model, + GtkTreePath *path, + gboolean path_selected, + gpointer data) +{ + GtkTreeIter iter; + GtkClipboard *primary, *clipboard; + + if (gtk_tree_model_get_iter (model, &iter, path)) { + gchar *name; + + gtk_tree_model_get (model, &iter, SWFMOZ_LOADER_COLUMN_URL, &name, -1); + if (gtk_widget_has_screen (GTK_WIDGET (data)) && !path_selected) { + primary = gtk_widget_get_clipboard (GTK_WIDGET (data), GDK_SELECTION_PRIMARY); + clipboard = gtk_widget_get_clipboard (GTK_WIDGET (data), GDK_SELECTION_CLIPBOARD); + gtk_clipboard_set_text (primary, name, -1); + gtk_clipboard_set_text (clipboard, name, -1); + } + + g_free (name); + } + + return TRUE; +} + static GtkWidget * swfmoz_dialog_get_media_page (SwfmozDialog *dialog) { GtkWidget *vbox, *align, *widget; GtkCellRenderer *renderer; GtkTreeViewColumn *column; + GtkTreeSelection *selection; GtkTreePath *path; vbox = gtk_vbox_new (FALSE, 3); @@ -198,8 +226,11 @@ swfmoz_dialog_get_media_page (SwfmozDialog *dialog) gtk_tree_view_column_set_sort_column_id (column, SWFMOZ_LOADER_COLUMN_STATUS); gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column); - gtk_tree_selection_set_mode (gtk_tree_view_get_selection - (GTK_TREE_VIEW (widget)), GTK_SELECTION_BROWSE); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); + gtk_tree_selection_set_select_function (selection, + swfmoz_dialog_manage_selection, + widget, NULL); path = gtk_tree_path_new_from_indices (0, -1); gtk_tree_view_set_cursor (GTK_TREE_VIEW (widget), path, NULL, FALSE); gtk_tree_path_free (path);