Commit e0247aab6186c5f94da8aa4b89c0efe3862e3b26
1 parent
eb4db366
Exists in
master
and in
1 other branch
Adding smart copy options.
Showing
7 changed files
with
85 additions
and
40 deletions
Show diff stats
locale/pt_BR.po
| ... | ... | @@ -5,8 +5,8 @@ msgid "" |
| 5 | 5 | msgstr "" |
| 6 | 6 | "Project-Id-Version: pw3270 5.0\n" |
| 7 | 7 | "Report-Msgid-Bugs-To: \n" |
| 8 | -"POT-Creation-Date: 2020-01-27 11:29-0300\n" | |
| 9 | -"PO-Revision-Date: 2020-01-27 11:31-0300\n" | |
| 8 | +"POT-Creation-Date: 2020-01-28 08:48-0300\n" | |
| 9 | +"PO-Revision-Date: 2020-01-28 10:09-0300\n" | |
| 10 | 10 | "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n" |
| 11 | 11 | "Language-Team: Português <>\n" |
| 12 | 12 | "Language: pt_BR\n" |
| ... | ... | @@ -257,7 +257,7 @@ msgstr "Clique para carregar arquivo" |
| 257 | 257 | msgid "Click to save file" |
| 258 | 258 | msgstr "Clique para salvar arquivo" |
| 259 | 259 | |
| 260 | -#: src/dialogs/settings/clipboard.c:385 | |
| 260 | +#: src/dialogs/settings/clipboard.c:409 | |
| 261 | 261 | msgid "Clipboard" |
| 262 | 262 | msgstr "Área de transferência" |
| 263 | 263 | |
| ... | ... | @@ -265,7 +265,7 @@ msgstr "Área de transferência" |
| 265 | 265 | msgid "Clipboard name" |
| 266 | 266 | msgstr "Nome da área de transferência" |
| 267 | 267 | |
| 268 | -#: src/dialogs/settings/clipboard.c:384 | |
| 268 | +#: src/dialogs/settings/clipboard.c:408 | |
| 269 | 269 | msgid "Clipboard properties" |
| 270 | 270 | msgstr "Configuração da área de transferência" |
| 271 | 271 | |
| ... | ... | @@ -317,7 +317,7 @@ msgstr "Copiar como texto puro" |
| 317 | 317 | msgid "Copy as table" |
| 318 | 318 | msgstr "Copiar como tabela" |
| 319 | 319 | |
| 320 | -#: src/dialogs/settings/clipboard.c:217 | |
| 320 | +#: src/dialogs/settings/clipboard.c:239 | |
| 321 | 321 | msgid "Copy options" |
| 322 | 322 | msgstr "Opções da cópia" |
| 323 | 323 | |
| ... | ... | @@ -523,7 +523,7 @@ msgstr "Cinza" |
| 523 | 523 | msgid "Green" |
| 524 | 524 | msgstr "Verde" |
| 525 | 525 | |
| 526 | -#: src/dialogs/settings/clipboard.c:219 | |
| 526 | +#: src/dialogs/settings/clipboard.c:241 | |
| 527 | 527 | msgid "HTML options" |
| 528 | 528 | msgstr "Opções HTML" |
| 529 | 529 | |
| ... | ... | @@ -689,11 +689,11 @@ msgstr "Nenhuma transferência" |
| 689 | 689 | msgid "No transfer in progress" |
| 690 | 690 | msgstr "Nenhuma transferência em andamento" |
| 691 | 691 | |
| 692 | -#: src/dialogs/settings/clipboard.c:282 | |
| 692 | +#: src/dialogs/settings/clipboard.c:306 | |
| 693 | 693 | msgid "None (Don't export color)" |
| 694 | 694 | msgstr "Nenhum (Não exporta cores)" |
| 695 | 695 | |
| 696 | -#: src/dialogs/settings/clipboard.c:402 | |
| 696 | +#: src/dialogs/settings/clipboard.c:426 | |
| 697 | 697 | msgid "None (Don't export font name)" |
| 698 | 698 | msgstr "Nenhuma (Não exporta fontes)" |
| 699 | 699 | |
| ... | ... | @@ -801,7 +801,7 @@ msgstr "Colar de um arquivo" |
| 801 | 801 | msgid "Paste from text file" |
| 802 | 802 | msgstr "Colar de um arquivo texto" |
| 803 | 803 | |
| 804 | -#: src/dialogs/settings/clipboard.c:218 | |
| 804 | +#: src/dialogs/settings/clipboard.c:240 | |
| 805 | 805 | msgid "Paste options" |
| 806 | 806 | msgstr "Opções para colar" |
| 807 | 807 | |
| ... | ... | @@ -825,7 +825,7 @@ msgstr "Rosa" |
| 825 | 825 | msgid "Plain text" |
| 826 | 826 | msgstr "Texto puro" |
| 827 | 827 | |
| 828 | -#: src/dialogs/settings/clipboard.c:350 | |
| 828 | +#: src/dialogs/settings/clipboard.c:374 | |
| 829 | 829 | msgid "Plain text only" |
| 830 | 830 | msgstr "Apenas texto puro" |
| 831 | 831 | |
| ... | ... | @@ -982,7 +982,7 @@ msgstr "" |
| 982 | 982 | "SPACE can be specified in units of TRACKS, CYLINDERS, or AVBLOCK, and only " |
| 983 | 983 | "one option can be used." |
| 984 | 984 | |
| 985 | -#: src/dialogs/settings/clipboard.c:283 src/dialogs/settings/clipboard.c:403 | |
| 985 | +#: src/dialogs/settings/clipboard.c:307 src/dialogs/settings/clipboard.c:427 | |
| 986 | 986 | msgid "Same of the screen" |
| 987 | 987 | msgstr "Igual ao terminal" |
| 988 | 988 | |
| ... | ... | @@ -1056,7 +1056,7 @@ msgstr "Guarda fila de transferência num arquivo XML externo" |
| 1056 | 1056 | msgid "Save transfer queue to file" |
| 1057 | 1057 | msgstr "Salvar fila de transferências para arquivo" |
| 1058 | 1058 | |
| 1059 | -#: src/dialogs/settings/clipboard.c:351 | |
| 1059 | +#: src/dialogs/settings/clipboard.c:375 | |
| 1060 | 1060 | msgid "Screen with terminal attributes" |
| 1061 | 1061 | msgstr "Completa incluindo atributos do terminal" |
| 1062 | 1062 | |
| ... | ... | @@ -1156,6 +1156,10 @@ msgstr "Skip" |
| 1156 | 1156 | msgid "Skip this transfer, keep the file on queue." |
| 1157 | 1157 | msgstr "Skip this transfer, keep the file on queue." |
| 1158 | 1158 | |
| 1159 | +#: src/dialogs/settings/clipboard.c:163 | |
| 1160 | +msgid "Smart copy" | |
| 1161 | +msgstr "Cópia inteligente" | |
| 1162 | + | |
| 1159 | 1163 | #: src/filetransfer/v3270ft.c:341 src/filetransfer/settings.c:544 |
| 1160 | 1164 | msgid "Space allocation units" |
| 1161 | 1165 | msgstr "Unidades de alocação de espaço" |
| ... | ... | @@ -1515,6 +1519,15 @@ msgstr "" |
| 1515 | 1519 | "Quando ativo pesquisa a área de transferência por uma tela similar, se " |
| 1516 | 1520 | "encontrar coloca os campos desprotegidos e restaura a posição do cursor" |
| 1517 | 1521 | |
| 1522 | +#: src/dialogs/settings/clipboard.c:164 | |
| 1523 | +msgid "" | |
| 1524 | +"When set the first copy operation after the selection will set the clipboard " | |
| 1525 | +"contents and the next ones will append" | |
| 1526 | +msgstr "" | |
| 1527 | +"Quando selecionado a primeira operação de cópia após a seleção definirá o " | |
| 1528 | +"conteúdo da área de transferência enquanto as operações subsequentes " | |
| 1529 | +"acrescentaram conteúdo" | |
| 1530 | + | |
| 1518 | 1531 | #: src/dialogs/settings/clipboard.c:144 |
| 1519 | 1532 | msgid "" |
| 1520 | 1533 | "When set the terminal spaces are exported as non-breaking spaces to prevent " | ... | ... |
src/dialogs/settings/clipboard.c
| ... | ... | @@ -157,8 +157,17 @@ |
| 157 | 157 | .width = 1, |
| 158 | 158 | .height = 1, |
| 159 | 159 | .grid = PASTE_SETTINGS |
| 160 | - } | |
| 160 | + }, | |
| 161 | 161 | |
| 162 | + { | |
| 163 | + .label = N_("Smart copy"), | |
| 164 | + .tooltip = N_("When set the first copy operation after the selection will set the clipboard contents and the next ones will append"), | |
| 165 | + .left = 1, | |
| 166 | + .top = 3, | |
| 167 | + .width = 1, | |
| 168 | + .height = 1, | |
| 169 | + .grid = COPY_SETTINGS | |
| 170 | + } | |
| 162 | 171 | }; |
| 163 | 172 | |
| 164 | 173 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
| ... | ... | @@ -206,6 +215,19 @@ static void copy_format_changed(GtkComboBox *widget, GtkWidget *grid) { |
| 206 | 215 | |
| 207 | 216 | } |
| 208 | 217 | |
| 218 | +static void keep_selected_toggled(GtkToggleButton *togglebutton, V3270ClipboardSettings *settings) { | |
| 219 | + | |
| 220 | + debug("%s",__FUNCTION__); | |
| 221 | + | |
| 222 | + if(!gtk_toggle_button_get_active(togglebutton)) { | |
| 223 | + gtk_toggle_button_set_active(settings->input.checkboxes[2],FALSE); | |
| 224 | + gtk_widget_set_sensitive(GTK_WIDGET(settings->input.checkboxes[2]),FALSE); | |
| 225 | + } else { | |
| 226 | + gtk_widget_set_sensitive(GTK_WIDGET(settings->input.checkboxes[2]),TRUE); | |
| 227 | + } | |
| 228 | + | |
| 229 | +} | |
| 230 | + | |
| 209 | 231 | static void V3270ClipboardSettings_init(V3270ClipboardSettings *widget) { |
| 210 | 232 | |
| 211 | 233 | size_t ix; |
| ... | ... | @@ -263,6 +285,8 @@ static void V3270ClipboardSettings_init(V3270ClipboardSettings *widget) { |
| 263 | 285 | } |
| 264 | 286 | |
| 265 | 287 | v3270_settings_create_toggle_buttons(toggles, G_N_ELEMENTS(toggles), grids, widget->input.toggles); |
| 288 | + g_signal_connect(G_OBJECT(widget->input.toggles[1]),"toggled",G_CALLBACK(keep_selected_toggled),widget); | |
| 289 | + | |
| 266 | 290 | v3270_settings_create_combos(combos, G_N_ELEMENTS(combos), grids, widget->input.combos); |
| 267 | 291 | v3270_settings_create_checkboxes(checkboxes, G_N_ELEMENTS(checkboxes), grids, widget->input.checkboxes); |
| 268 | 292 | |
| ... | ... | @@ -447,6 +471,7 @@ static void load(GtkWidget *w, GtkWidget *t) { |
| 447 | 471 | |
| 448 | 472 | gtk_toggle_button_set_active(widget->input.checkboxes[0],(terminal->selection.options & V3270_SELECTION_NON_BREAKABLE_SPACE) != 0); |
| 449 | 473 | gtk_toggle_button_set_active(widget->input.checkboxes[1],(terminal->selection.options & V3270_SELECTION_SCREEN_PASTE) != 0); |
| 474 | + gtk_toggle_button_set_active(widget->input.checkboxes[2],(terminal->selection.options & V3270_SELECTION_SMART_COPY) != 0); | |
| 450 | 475 | |
| 451 | 476 | // |
| 452 | 477 | // Set font combo-box |
| ... | ... | @@ -520,12 +545,18 @@ static void apply(GtkWidget *w, GtkWidget *t) { |
| 520 | 545 | terminal->selection.options &= ~V3270_SELECTION_NON_BREAKABLE_SPACE; |
| 521 | 546 | } |
| 522 | 547 | |
| 523 | - if(gtk_toggle_button_get_active(widget->input.checkboxes[0])) { | |
| 548 | + if(gtk_toggle_button_get_active(widget->input.checkboxes[1])) { | |
| 524 | 549 | terminal->selection.options |= V3270_SELECTION_SCREEN_PASTE; |
| 525 | 550 | } else { |
| 526 | 551 | terminal->selection.options &= ~V3270_SELECTION_SCREEN_PASTE; |
| 527 | 552 | } |
| 528 | 553 | |
| 554 | + if(gtk_toggle_button_get_active(widget->input.checkboxes[2])) { | |
| 555 | + terminal->selection.options |= V3270_SELECTION_SMART_COPY; | |
| 556 | + } else { | |
| 557 | + terminal->selection.options &= ~V3270_SELECTION_SMART_COPY; | |
| 558 | + } | |
| 559 | + | |
| 529 | 560 | // Get font settings |
| 530 | 561 | switch(get_active_id(widget,0)) { |
| 531 | 562 | case '0': | ... | ... |
src/include/terminal.h
| ... | ... | @@ -120,12 +120,13 @@ G_BEGIN_DECLS |
| 120 | 120 | |
| 121 | 121 | typedef enum _V3270SelectionOption { |
| 122 | 122 | |
| 123 | - V3270_SELECTION_PLAIN_TEXT = 0x0000, ///< @brief Uses only plain text. | |
| 124 | - V3270_SELECTION_FONT_FAMILY = 0x0001, ///< @brief Inform font-family. | |
| 125 | - V3270_SELECTION_COLORS = 0x0002, ///< @brief Inform terminal colors. | |
| 126 | - V3270_SELECTION_NON_BREAKABLE_SPACE = 0x0004, ///< @brief Use non breakable spaces. | |
| 127 | - V3270_SELECTION_DIALOG_STATE = 0x0010, ///< @brief Used for settings dialog. | |
| 128 | - V3270_SELECTION_SCREEN_PASTE = 0x0020, ///< @brief Enable screen paste. | |
| 123 | + V3270_SELECTION_PLAIN_TEXT = 0x00, ///< @brief Uses only plain text. | |
| 124 | + V3270_SELECTION_FONT_FAMILY = 0x01, ///< @brief Inform font-family. | |
| 125 | + V3270_SELECTION_COLORS = 0x02, ///< @brief Inform terminal colors. | |
| 126 | + V3270_SELECTION_NON_BREAKABLE_SPACE = 0x04, ///< @brief Use non breakable spaces. | |
| 127 | + V3270_SELECTION_SCREEN_PASTE = 0x08, ///< @brief Enable screen paste. | |
| 128 | + V3270_SELECTION_SMART_COPY = 0x10, ///< @brief Enable copy/append based on current selection state. | |
| 129 | + V3270_SELECTION_DIALOG_STATE = 0x20, ///< @brief Used for settings dialog. | |
| 129 | 130 | |
| 130 | 131 | } V3270SelectionOption; |
| 131 | 132 | |
| ... | ... | @@ -155,6 +156,7 @@ G_BEGIN_DECLS |
| 155 | 156 | int scaled_fonts : 1; /// @brief Use scaled fonts |
| 156 | 157 | int drawing : 1; /// @brief Draw widget? |
| 157 | 158 | int freeze : 1; /// @brief Truee when the "save settings" signal is disabled. |
| 159 | + int append : 1; /// @brief Next smart-copy operation will be append. | |
| 158 | 160 | |
| 159 | 161 | /// @brief Action properties. |
| 160 | 162 | GtkResponseType responses[V3270_TOGGLEABLE_DIALOG_CUSTOM]; | ... | ... |
src/include/v3270/selection.h
| ... | ... | @@ -39,11 +39,11 @@ |
| 39 | 39 | typedef enum _v3270_copy_mode |
| 40 | 40 | { |
| 41 | 41 | |
| 42 | - V3270_COPY_DEFAULT, ///< @brief Detect format based on lib3270's smart past toggle. | |
| 43 | 42 | V3270_COPY_FORMATTED, ///< @brief Copy formatted data; keep attributes. |
| 44 | 43 | V3270_COPY_TEXT, ///< @brief Single text format, ignore attributes. |
| 45 | 44 | V3270_COPY_TABLE, ///< @brief Copy as table. |
| 46 | - V3270_COPY_APPEND ///< @brief Append to current contents keeping the stored format. | |
| 45 | + V3270_COPY_APPEND, ///< @brief Append to current contents keeping the stored format. | |
| 46 | + V3270_COPY_SMART ///< @brief use append/default based on current copy state. | |
| 47 | 47 | |
| 48 | 48 | } V3270_COPY_MODE; |
| 49 | 49 | ... | ... |
src/selection/copy.c
| ... | ... | @@ -30,34 +30,32 @@ |
| 30 | 30 | #include <clipboard.h> |
| 31 | 31 | #include <lib3270/selection.h> |
| 32 | 32 | |
| 33 | - static void do_copy(v3270 *terminal, gboolean cut) | |
| 34 | - { | |
| 33 | + static void do_copy(v3270 *terminal, gboolean cut) { | |
| 34 | + | |
| 35 | 35 | lib3270_selection * selection = lib3270_selection_new(terminal->host,cut,0); |
| 36 | 36 | |
| 37 | - if(selection) | |
| 38 | - { | |
| 37 | + if(selection) { | |
| 39 | 38 | terminal->selection.blocks = g_list_append(terminal->selection.blocks,selection); |
| 39 | + terminal->append = ((terminal->selection.options & V3270_SELECTION_SMART_COPY) != 0) ? 1 : 0 ; // Define next smart option. | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - LIB3270_EXPORT void v3270_clipboard_set(GtkWidget *widget, V3270_COPY_MODE mode, gboolean cut) | |
| 45 | - { | |
| 44 | + LIB3270_EXPORT void v3270_clipboard_set(GtkWidget *widget, V3270_COPY_MODE mode, gboolean cut) { | |
| 45 | + | |
| 46 | 46 | g_return_if_fail(GTK_IS_V3270(widget)); |
| 47 | 47 | |
| 48 | 48 | v3270 * terminal = GTK_V3270(widget); |
| 49 | 49 | |
| 50 | + if(mode == V3270_COPY_SMART) { | |
| 51 | + mode = (terminal->append ? V3270_COPY_APPEND : V3270_COPY_FORMATTED); | |
| 52 | + } | |
| 53 | + | |
| 50 | 54 | if(mode != V3270_COPY_APPEND) { |
| 51 | 55 | |
| 52 | 56 | // It's not append, clear current contents ... |
| 53 | 57 | v3270_clear_selection(terminal); |
| 54 | 58 | |
| 55 | - // ... and set the new mode. | |
| 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); | |
| 58 | - mode = V3270_COPY_FORMATTED; | |
| 59 | - } | |
| 60 | - | |
| 61 | 59 | terminal->selection.format = mode; |
| 62 | 60 | |
| 63 | 61 | } |
| ... | ... | @@ -67,13 +65,11 @@ |
| 67 | 65 | v3270_update_system_clipboard(widget); |
| 68 | 66 | } |
| 69 | 67 | |
| 70 | - LIB3270_EXPORT void v3270_copy_selection(GtkWidget *widget, V3270_COPY_MODE format, gboolean cut) | |
| 71 | - { | |
| 68 | + LIB3270_EXPORT void v3270_copy_selection(GtkWidget *widget, V3270_COPY_MODE format, gboolean cut) { | |
| 72 | 69 | v3270_clipboard_set(widget,format,cut); |
| 73 | 70 | } |
| 74 | 71 | |
| 75 | - LIB3270_EXPORT void v3270_append_selection(GtkWidget *widget, gboolean cut) | |
| 76 | - { | |
| 72 | + LIB3270_EXPORT void v3270_append_selection(GtkWidget *widget, gboolean cut) { | |
| 77 | 73 | v3270_clipboard_set(widget,V3270_COPY_APPEND,cut); |
| 78 | 74 | } |
| 79 | 75 | ... | ... |
src/selection/selection.c
| ... | ... | @@ -109,6 +109,7 @@ LIB3270_EXPORT void v3270_unselect(GtkWidget *widget) |
| 109 | 109 | { |
| 110 | 110 | v3270_disable_updates(widget); |
| 111 | 111 | lib3270_unselect(v3270_get_session(widget)); |
| 112 | + GTK_V3270(widget)->append = 0; // Reset smart-copy. | |
| 112 | 113 | v3270_enable_updates(widget); |
| 113 | 114 | } |
| 114 | 115 | |
| ... | ... | @@ -122,6 +123,7 @@ LIB3270_EXPORT void v3270_select_region(GtkWidget *widget, gint start, gint end |
| 122 | 123 | { |
| 123 | 124 | g_return_if_fail(GTK_IS_V3270(widget)); |
| 124 | 125 | lib3270_select_region(GTK_V3270(widget)->host,start,end); |
| 126 | + GTK_V3270(widget)->append = 0; // Reset smart-copy. | |
| 125 | 127 | } |
| 126 | 128 | |
| 127 | 129 | LIB3270_EXPORT void v3270_select_all(GtkWidget *widget) |
| ... | ... | @@ -130,6 +132,7 @@ LIB3270_EXPORT void v3270_select_all(GtkWidget *widget) |
| 130 | 132 | v3270_disable_updates(widget); |
| 131 | 133 | lib3270_select_all(v3270_get_session(widget)); |
| 132 | 134 | v3270_enable_updates(widget); |
| 135 | + GTK_V3270(widget)->append = 0; // Reset smart-copy. | |
| 133 | 136 | } |
| 134 | 137 | |
| 135 | 138 | void v3270_selection_set_font_family(GtkWidget *widget, const gchar *name) { | ... | ... |
src/terminal/actions/table.c
| ... | ... | @@ -63,7 +63,7 @@ |
| 63 | 63 | |
| 64 | 64 | // Standard Clipboard actions |
| 65 | 65 | { |
| 66 | - .flags = 0, | |
| 66 | + .flags = V3270_COPY_SMART, | |
| 67 | 67 | .name = "copy", |
| 68 | 68 | .group = LIB3270_ACTION_GROUP_SELECTION, |
| 69 | 69 | .icon = "edit-copy", |
| ... | ... | @@ -112,7 +112,7 @@ |
| 112 | 112 | }, |
| 113 | 113 | |
| 114 | 114 | { |
| 115 | - .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_DEFAULT, | |
| 115 | + .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_SMART, | |
| 116 | 116 | .group = LIB3270_ACTION_GROUP_SELECTION, |
| 117 | 117 | .name = "cut", |
| 118 | 118 | .icon = "edit-cut", | ... | ... |