Commit 2b230fbbf3b970054dd9e8dafaf77770ce90cd14

Authored by Perry Werneck
1 parent a97cab2e
Exists in master and in 1 other branch develop

Enabling copy-as-image action.

src/include/v3270/selection.h
@@ -60,7 +60,7 @@ @@ -60,7 +60,7 @@
60 LIB3270_EXPORT void v3270_append_selection(GtkWidget *widget, gboolean cut) G_GNUC_DEPRECATED; 60 LIB3270_EXPORT void v3270_append_selection(GtkWidget *widget, gboolean cut) G_GNUC_DEPRECATED;
61 61
62 LIB3270_EXPORT void v3270_copy_as_html(GtkWidget *widget); 62 LIB3270_EXPORT void v3270_copy_as_html(GtkWidget *widget);
63 - LIB3270_EXPORT void v3270_copy_as_image(GtkWidget *widget); 63 + LIB3270_EXPORT void v3270_copy_as_pixbuff(GtkWidget *widget);
64 64
65 // Selections 65 // Selections
66 66
src/selection/copy.c
@@ -111,3 +111,43 @@ @@ -111,3 +111,43 @@
111 111
112 v3270_emit_copy_state(widget); 112 v3270_emit_copy_state(widget);
113 } 113 }
  114 +
  115 + LIB3270_EXPORT void v3270_copy_as_pixbuff(GtkWidget *widget) {
  116 +
  117 + g_return_if_fail(GTK_IS_V3270(widget));
  118 + v3270 * terminal = GTK_V3270(widget);
  119 +
  120 + debug("%s",__FUNCTION__);
  121 +
  122 + do_copy(terminal,V3270_COPY_FORMATTED,0);
  123 +
  124 + //
  125 + // Export only in HTML format
  126 + //
  127 + GtkClipboard * clipboard = gtk_widget_get_clipboard(widget,terminal->selection.target);
  128 +
  129 + GtkTargetList * list = gtk_target_list_new(NULL,0);
  130 +
  131 + gtk_target_list_add_image_targets(list,CLIPBOARD_TYPE_PIXBUFF,TRUE);
  132 +
  133 + int n_targets;
  134 + GtkTargetEntry * targets = gtk_target_table_new_from_list(list, &n_targets);
  135 +
  136 + if(gtk_clipboard_set_with_owner(
  137 + clipboard,
  138 + targets,
  139 + n_targets,
  140 + (GtkClipboardGetFunc) v3270_clipboard_get,
  141 + (GtkClipboardClearFunc) v3270_clipboard_clear,
  142 + G_OBJECT(widget)
  143 + ))
  144 + {
  145 + gtk_clipboard_set_can_store(clipboard,targets,1);
  146 + }
  147 +
  148 + gtk_target_table_free(targets, n_targets);
  149 + gtk_target_list_unref(list);
  150 +
  151 + v3270_emit_copy_state(widget);
  152 +
  153 + }
src/terminal/actions/table.c
@@ -37,6 +37,7 @@ @@ -37,6 +37,7 @@
37 // static int fire_kp_sub_action(GtkWidget *widget, const struct _v3270_action * action); 37 // static int fire_kp_sub_action(GtkWidget *widget, const struct _v3270_action * action);
38 38
39 static int fire_copy_as_html(GtkWidget *widget, const struct _v3270_action * action); 39 static int fire_copy_as_html(GtkWidget *widget, const struct _v3270_action * action);
  40 + static int fire_copy_as_pixbuff(GtkWidget *widget, const struct _v3270_action * action);
40 41
41 /*--[ Implement ]------------------------------------------------------------------------------------*/ 42 /*--[ Implement ]------------------------------------------------------------------------------------*/
42 43
@@ -82,6 +83,15 @@ @@ -82,6 +83,15 @@
82 }, 83 },
83 84
84 { 85 {
  86 + .name = "copy-pixbuff",
  87 + .group = LIB3270_ACTION_GROUP_SELECTION,
  88 + .label = N_( "Copy as image" ),
  89 + .summary = N_("Copy selection in image format"),
  90 + .description = N_("Replace current clipboard contents with the selected area in image format"),
  91 + .activate = fire_copy_as_pixbuff
  92 + },
  93 +
  94 + {
85 .name = "copy-append", 95 .name = "copy-append",
86 .keys = "<Alt>c", 96 .keys = "<Alt>c",
87 .flags = (V3270_ACTION_FLAGS) V3270_COPY_APPEND, 97 .flags = (V3270_ACTION_FLAGS) V3270_COPY_APPEND,
@@ -340,6 +350,11 @@ @@ -340,6 +350,11 @@
340 return 0; 350 return 0;
341 } 351 }
342 352
  353 + static int fire_copy_as_pixbuff(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) {
  354 + v3270_copy_as_pixbuff(widget);
  355 + return 0;
  356 + }
  357 +
343 /* 358 /*
344 int fire_kp_add_action(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) { 359 int fire_kp_add_action(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) {
345 360