diff --git a/src/swfmoz_dialog.c b/src/swfmoz_dialog.c index c05c952..6422b62 100644 --- a/src/swfmoz_dialog.c +++ b/src/swfmoz_dialog.c @@ -162,12 +162,37 @@ 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_currently_selected, + gpointer data) +{ + GtkTreeIter iter; + GtkClipboard *primary; + + 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_currently_selected) { + primary = gtk_widget_get_clipboard (GTK_WIDGET (data), GDK_SELECTION_PRIMARY); + gtk_clipboard_set_text (primary, 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); @@ -175,7 +200,7 @@ swfmoz_dialog_get_media_page (SwfmozDialog *dialog) dialog->media = widget = gtk_tree_view_new_with_model (dialog->player->loaders); renderer = gtk_cell_renderer_text_new (); - g_object_set (renderer, "width-chars", 25, "editable", TRUE, + g_object_set (renderer, "width-chars", 25, "ellipsize", PANGO_ELLIPSIZE_START, "ellipsize-set", TRUE, NULL); column = gtk_tree_view_column_new_with_attributes ("URL", renderer, "text", SWFMOZ_LOADER_COLUMN_URL, NULL); @@ -198,8 +223,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);