Commit 56954fbde3f8aa1d42072b04b266285702e7ead8

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

Implementing configuration for the "paste screen" option.

src/dialogs/settings/clipboard.c
... ... @@ -146,7 +146,17 @@
146 146 .top = 2,
147 147 .width = 1,
148 148 .height = 1,
149   - .grid = 2
  149 + .grid = HTML_SETTINGS
  150 + },
  151 +
  152 + {
  153 + .label = N_("Paste formatted screen"),
  154 + .tooltip = N_("If enabled search clipboard for a similar screen, if found paste unprotected fields and restore cursor position"),
  155 + .left = 0,
  156 + .top = 2,
  157 + .width = 1,
  158 + .height = 1,
  159 + .grid = PASTE_SETTINGS
150 160 }
151 161  
152 162 };
... ... @@ -336,7 +346,7 @@ static void V3270ClipboardSettings_init(V3270ClipboardSettings *widget) {
336 346 // Copy format combo
337 347 static const gchar * copy_formats[] = {
338 348 N_("Plain text only"),
339   - N_("Complete with terminal attributes")
  349 + N_("Screen with terminal attributes")
340 350 };
341 351  
342 352 gtk_combo_box_set_id_column(widget->input.combos[0],1);
... ... @@ -434,6 +444,7 @@ static void load(GtkWidget *w, GtkWidget *t) {
434 444 gtk_combo_box_set_active_id(widget->input.combos[2],(terminal->selection.options & (V3270_SELECTION_ENABLE_HTML|V3270_SELECTION_DIALOG_STATE)) == 0 ? "0" : "1");
435 445  
436 446 gtk_toggle_button_set_active(widget->input.checkboxes[0],(terminal->selection.options & V3270_SELECTION_NON_BREAKABLE_SPACE) != 0);
  447 + gtk_toggle_button_set_active(widget->input.checkboxes[1],(terminal->selection.options & V3270_SELECTION_SCREEN_PASTE) != 0);
437 448  
438 449 //
439 450 // Set font combo-box
... ... @@ -507,6 +518,12 @@ static void apply(GtkWidget *w, GtkWidget *t) {
507 518 terminal->selection.options &= ~V3270_SELECTION_NON_BREAKABLE_SPACE;
508 519 }
509 520  
  521 + if(gtk_toggle_button_get_active(widget->input.checkboxes[0])) {
  522 + terminal->selection.options |= V3270_SELECTION_SCREEN_PASTE;
  523 + } else {
  524 + terminal->selection.options &= ~V3270_SELECTION_SCREEN_PASTE;
  525 + }
  526 +
510 527 // Get font settings
511 528 switch(get_active_id(widget,0)) {
512 529 case '0':
... ...
src/include/terminal.h
... ... @@ -125,6 +125,7 @@ G_BEGIN_DECLS
125 125 V3270_SELECTION_COLORS = 0x0002, ///< @brief Inform terminal colors.
126 126 V3270_SELECTION_NON_BREAKABLE_SPACE = 0x0004, ///< @brief Use non breakable spaces.
127 127 V3270_SELECTION_DIALOG_STATE = 0x0010, ///< @brief Used for settings dialog.
  128 + V3270_SELECTION_SCREEN_PASTE = 0x0020, ///< @brief Enable screen paste.
128 129  
129 130 } V3270SelectionOption;
130 131  
... ...
src/selection/copy.c
... ... @@ -54,7 +54,8 @@
54 54  
55 55 // ... and set the new mode.
56 56 if(mode == V3270_COPY_DEFAULT) {
57   - mode = (lib3270_get_toggle(v3270_get_session(widget),LIB3270_TOGGLE_SMART_PASTE) ? V3270_COPY_FORMATTED : V3270_COPY_TEXT);
  57 +// mode = (lib3270_get_toggle(v3270_get_session(widget),LIB3270_TOGGLE_SMART_PASTE) ? V3270_COPY_FORMATTED : V3270_COPY_TEXT);
  58 + mode = V3270_COPY_FORMATTED;
58 59 }
59 60  
60 61 terminal->selection.format = mode;
... ...
src/selection/linux/paste.c
... ... @@ -176,13 +176,15 @@ static void formatted_received(GtkClipboard *clipboard, GtkSelectionData *select
176 176  
177 177 }
178 178  
179   -static void targets_received(GtkClipboard *clipboard, GdkAtom *atoms, gint n_atoms, GtkWidget *widget)
180   -{
  179 +static void targets_received(GtkClipboard *clipboard, GdkAtom *atoms, gint n_atoms, GtkWidget *widget) {
181 180  
182 181 // If smart paste is enabled try to get formatted clipboard.
183   - debug("%s: Smart paste is %s", __FUNCTION__, (lib3270_get_toggle(GTK_V3270(widget)->host,LIB3270_TOGGLE_SMART_PASTE) ? "enabled" : "disabled"));
184   - if(lib3270_get_toggle(GTK_V3270(widget)->host,LIB3270_TOGGLE_SMART_PASTE) && has_target(GTK_V3270_GET_CLASS(widget)->clipboard_formatted,atoms,n_atoms))
185   - {
  182 + gboolean screen_paste = ((GTK_V3270(widget)->selection.options & V3270_SELECTION_SCREEN_PASTE) != 0);
  183 +
  184 + debug("%s: Screen paste is %s", __FUNCTION__, screen_paste ? "enabled" : "disabled");
  185 +
  186 + if(screen_paste && has_target(GTK_V3270_GET_CLASS(widget)->clipboard_formatted,atoms,n_atoms)) {
  187 +
186 188 debug("Clipboard as TN3270 \"%s\" data",gdk_atom_name(GTK_V3270_GET_CLASS(widget)->clipboard_formatted));
187 189  
188 190 gtk_clipboard_request_contents(
... ... @@ -225,7 +227,6 @@ LIB3270_EXPORT void v3270_clipboard_get_from_url(GtkWidget *widget, const gchar
225 227 (GtkClipboardTextReceivedFunc) text_received,
226 228 (gpointer) widget
227 229 );
228   -
229 230 }
230 231 else if(g_str_has_prefix(url,"file://"))
231 232 {
... ... @@ -234,6 +235,15 @@ LIB3270_EXPORT void v3270_clipboard_get_from_url(GtkWidget *widget, const gchar
234 235 v3270_load_dialog_run(dialog);
235 236 gtk_widget_destroy(dialog);
236 237 }
  238 + else if(g_str_has_prefix(url,"screen://"))
  239 + {
  240 + gtk_clipboard_request_contents(
  241 + clipboard,
  242 + GTK_V3270_GET_CLASS(widget)->clipboard_formatted,
  243 + (GtkClipboardReceivedFunc) formatted_received,
  244 + (gpointer) widget
  245 + );
  246 + }
237 247  
238 248 }
239 249  
... ...
src/terminal/actions/action.c
... ... @@ -248,7 +248,7 @@
248 248  
249 249 }
250 250  
251   - void set_property(GObject G_GNUC_UNUSED(*object), guint G_GNUC_UNUSED(prop_id), const GValue G_GNUC_UNUSED(*value), GParamSpec *pspec) {
  251 + void set_property(GObject G_GNUC_UNUSED(*object), guint G_GNUC_UNUSED(prop_id), const GValue G_GNUC_UNUSED(*value), GParamSpec G_GNUC_UNUSED(*pspec)) {
252 252 // g_message("Action %s property %s is read-only",g_action_get_name(G_ACTION(object)),pspec->name);
253 253 }
254 254  
... ...
src/terminal/actions/clipboard.c
... ... @@ -50,7 +50,6 @@
50 50  
51 51 int fire_paste_accelerator(GtkWidget *widget, const V3270_ACTION * action) {
52 52  
53   -
54 53 switch((int) action->flags)
55 54 {
56 55 case 0: // Default paste.
... ... @@ -65,6 +64,10 @@
65 64 v3270_clipboard_get_from_url(widget,"file://");
66 65 break;
67 66  
  67 + case 3: // screen paste.
  68 + v3270_clipboard_get_from_url(widget,"screen://");
  69 + break;
  70 +
68 71 default:
69 72 g_warning("Unexpected paste flags %u",(unsigned int) action->flags);
70 73 }
... ...
src/terminal/actions/table.c
... ... @@ -193,6 +193,17 @@
193 193 .activate = fire_paste_accelerator
194 194 },
195 195  
  196 + {
  197 + .flags = 3,
  198 + .group = LIB3270_ACTION_GROUP_ONLINE,
  199 + .name = "paste-screen",
  200 + .label = N_("Paste formatted screen"),
  201 + .summary = N_("Search clipboard for a similar screen, if found paste unprotected fields and restore cursor position"),
  202 + .key = 'v',
  203 + .mods = GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_ALT_MASK,
  204 + .activate = fire_paste_accelerator
  205 + },
  206 +
196 207 {
197 208 .flags = 0,
198 209 .group = LIB3270_ACTION_GROUP_ONLINE,
... ...