From 20612e428d968635600c32f3701a556947746661 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Fri, 26 Jun 2020 07:37:58 -0300 Subject: [PATCH] Allowing image formats on clipboard. --- src/dialogs/settings/clipboard.c | 18 ++++++++++++++++++ src/include/clipboard.h | 3 ++- src/include/terminal.h | 1 + src/selection/linux/copy.c | 19 +++++++++++++++++++ v3270.cbp | 2 -- 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/dialogs/settings/clipboard.c b/src/dialogs/settings/clipboard.c index 208b820..297046f 100644 --- a/src/dialogs/settings/clipboard.c +++ b/src/dialogs/settings/clipboard.c @@ -163,11 +163,22 @@ .label = N_("Smart copy"), .tooltip = N_("When set the first copy operation after the selection will set the clipboard contents and the next ones will append"), .left = 1, + .top = 4, + .width = 1, + .height = 1, + .grid = COPY_SETTINGS + }, + + { + .label = N_("Image copy"), + .tooltip = N_("When set allow image formats on clipboard"), + .left = 1, .top = 3, .width = 1, .height = 1, .grid = COPY_SETTINGS } + }; /*--[ Globals ]--------------------------------------------------------------------------------------*/ @@ -472,6 +483,7 @@ static void load(GtkWidget *w, GtkWidget *t) { gtk_toggle_button_set_active(widget->input.checkboxes[0],(terminal->selection.options & V3270_SELECTION_NON_BREAKABLE_SPACE) != 0); gtk_toggle_button_set_active(widget->input.checkboxes[1],(terminal->selection.options & V3270_SELECTION_SCREEN_PASTE) != 0); gtk_toggle_button_set_active(widget->input.checkboxes[2],(terminal->selection.options & V3270_SELECTION_SMART_COPY) != 0); + gtk_toggle_button_set_active(widget->input.checkboxes[3],(terminal->selection.options & V3270_SELECTION_PIXBUFF) != 0); // // Set font combo-box @@ -559,6 +571,12 @@ static void apply(GtkWidget *w, GtkWidget *t) { terminal->selection.options &= ~V3270_SELECTION_SMART_COPY; } + if(gtk_toggle_button_get_active(widget->input.checkboxes[3])) { + terminal->selection.options |= V3270_SELECTION_PIXBUFF; + } else { + terminal->selection.options &= ~V3270_SELECTION_PIXBUFF; + } + // Get font settings switch(get_active_id(widget,0)) { case '0': diff --git a/src/include/clipboard.h b/src/include/clipboard.h index e742e29..863fe7d 100644 --- a/src/include/clipboard.h +++ b/src/include/clipboard.h @@ -45,7 +45,8 @@ CLIPBOARD_TYPE_TEXT, CLIPBOARD_TYPE_CSV, CLIPBOARD_TYPE_HTML, - CLIPBOARD_TYPE_V3270_FORMATTED + CLIPBOARD_TYPE_V3270_FORMATTED, + CLIPBOARD_TYPE_PIXBUFF }; /// @brief Column from selection. diff --git a/src/include/terminal.h b/src/include/terminal.h index 1d10745..f89f3f9 100644 --- a/src/include/terminal.h +++ b/src/include/terminal.h @@ -127,6 +127,7 @@ G_BEGIN_DECLS V3270_SELECTION_SCREEN_PASTE = 0x08, ///< @brief Enable screen paste. V3270_SELECTION_SMART_COPY = 0x10, ///< @brief Enable copy/append based on current selection state. V3270_SELECTION_DIALOG_STATE = 0x20, ///< @brief Used for settings dialog. + V3270_SELECTION_PIXBUFF = 0x40, ///< @brief Allow pixbuf formats. } V3270SelectionOption; diff --git a/src/selection/linux/copy.c b/src/selection/linux/copy.c index 72e3c8f..752a01e 100644 --- a/src/selection/linux/copy.c +++ b/src/selection/linux/copy.c @@ -104,6 +104,20 @@ static void clipboard_get(G_GNUC_UNUSED GtkClipboard *clipboard, GtkSelectionDa } break; + case CLIPBOARD_TYPE_PIXBUFF: + { + GdkPixbuf * pixbuff = v3270_get_selection_as_pixbuf(terminal, terminal->selection.blocks, FALSE); + + debug("%s: pixbuff=%p (blocks=%p)",__FUNCTION__,pixbuff,terminal->selection.blocks); + + if(pixbuff) + { + gtk_selection_data_set_pixbuf(selection,pixbuff); + g_object_unref(pixbuff); + } + } + break; + default: g_warning("Unexpected clipboard type %d\n",target); } @@ -143,6 +157,11 @@ void v3270_update_system_clipboard(GtkWidget *widget) } + if(terminal->selection.options & V3270_SELECTION_PIXBUFF) + { + gtk_target_list_add_image_targets(list,CLIPBOARD_TYPE_PIXBUFF,TRUE); + } + int n_targets; GtkTargetEntry * targets = gtk_target_table_new_from_list(list, &n_targets); diff --git a/v3270.cbp b/v3270.cbp index 74b5af2..44bb931 100644 --- a/v3270.cbp +++ b/v3270.cbp @@ -6,7 +6,6 @@