X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-view.c;h=bc3cb980daf295efb03aad5d20d5f0fb6b504b65;hb=refs%2Ftags%2FEVINCE_2_23_5;hp=f984396c861ea96a6f64d9c197dc14820dc07d0b;hpb=b8aebf2e1ba5b4f9ff1e1256b28acb3e23947c51;p=evince.git diff --git a/shell/ev-view.c b/shell/ev-view.c index f984396c..bc3cb980 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -320,6 +320,7 @@ static void compute_selections (EvView GdkPoint *start, GdkPoint *stop); static void clear_selection (EvView *view); +static void clear_link_selected (EvView *view); static void selection_free (EvViewSelection *selection); static char* get_selected_text (EvView *ev_view); static void ev_view_primary_get_cb (GtkClipboard *clipboard, @@ -3178,6 +3179,7 @@ ev_view_button_release_event (GtkWidget *widget, } if (view->selection_info.selections) { + clear_link_selected (view); ev_view_update_primary_selection (view); if (view->selection_info.in_drag) { @@ -3438,6 +3440,8 @@ ev_view_key_press_event (GtkWidget *widget, switch (event->keyval) { case GDK_b: case GDK_B: + case GDK_period: + case GDK_KP_Decimal: view->presentation_state = (view->presentation_state == EV_PRESENTATION_BLACK) ? EV_PRESENTATION_NORMAL : EV_PRESENTATION_BLACK; @@ -3823,6 +3827,7 @@ ev_view_finalize (GObject *object) g_free (view->find_status); clear_selection (view); + clear_link_selected (view); if (view->image_dnd_info.image) g_object_unref (view->image_dnd_info.image); @@ -5746,19 +5751,27 @@ get_selected_text (EvView *view) return normalized_text; } +static void +ev_view_clipboard_copy (EvView *view, + const gchar *text) +{ + GtkClipboard *clipboard; + + clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view), + GDK_SELECTION_CLIPBOARD); + gtk_clipboard_set_text (clipboard, text, -1); +} + void ev_view_copy (EvView *ev_view) { - GtkClipboard *clipboard; char *text; if (!EV_IS_SELECTION (ev_view->document)) return; text = get_selected_text (ev_view); - clipboard = gtk_widget_get_clipboard (GTK_WIDGET (ev_view), - GDK_SELECTION_CLIPBOARD); - gtk_clipboard_set_text (clipboard, text, -1); + ev_view_clipboard_copy (ev_view, text); g_free (text); } @@ -5769,15 +5782,20 @@ ev_view_primary_get_cb (GtkClipboard *clipboard, gpointer data) { EvView *ev_view = EV_VIEW (data); - char *text; - if (!EV_IS_SELECTION (ev_view->document)) - return; - - text = get_selected_text (ev_view); - if (text) { - gtk_selection_data_set_text (selection_data, text, -1); - g_free (text); + if (ev_view->link_selected) { + gtk_selection_data_set_text (selection_data, + ev_link_action_get_uri (ev_view->link_selected), + -1); + } else if (EV_IS_SELECTION (ev_view->document) && + ev_view->selection_info.selections) { + gchar *text; + + text = get_selected_text (ev_view); + if (text) { + gtk_selection_data_set_text (selection_data, text, -1); + g_free (text); + } } } @@ -5788,6 +5806,7 @@ ev_view_primary_clear_cb (GtkClipboard *clipboard, EvView *view = EV_VIEW (data); clear_selection (view); + clear_link_selected (view); } static void @@ -5798,7 +5817,7 @@ ev_view_update_primary_selection (EvView *ev_view) clipboard = gtk_widget_get_clipboard (GTK_WIDGET (ev_view), GDK_SELECTION_PRIMARY); - if (ev_view->selection_info.selections) { + if (ev_view->selection_info.selections || ev_view->link_selected) { if (!gtk_clipboard_set_with_owner (clipboard, clipboard_targets, G_N_ELEMENTS (clipboard_targets), @@ -5812,6 +5831,27 @@ ev_view_update_primary_selection (EvView *ev_view) } } +static void +clear_link_selected (EvView *view) +{ + if (view->link_selected) { + g_object_unref (view->link_selected); + view->link_selected = NULL; + } +} + +void +ev_view_copy_link_address (EvView *view, + EvLinkAction *action) +{ + clear_link_selected (view); + + ev_view_clipboard_copy (view, ev_link_action_get_uri (action)); + + view->link_selected = g_object_ref (action); + ev_view_update_primary_selection (view); +} + /*** Cursor operations ***/ static GdkCursor *