From e0247aab6186c5f94da8aa4b89c0efe3862e3b26 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Tue, 28 Jan 2020 10:09:50 -0300 Subject: [PATCH] Adding smart copy options. --- locale/pt_BR.po | 37 +++++++++++++++++++++++++------------ src/dialogs/settings/clipboard.c | 35 +++++++++++++++++++++++++++++++++-- src/include/terminal.h | 14 ++++++++------ src/include/v3270/selection.h | 4 ++-- src/selection/copy.c | 28 ++++++++++++---------------- src/selection/selection.c | 3 +++ src/terminal/actions/table.c | 4 ++-- 7 files changed, 85 insertions(+), 40 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index bd3be77..7978a57 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -5,8 +5,8 @@ msgid "" msgstr "" "Project-Id-Version: pw3270 5.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-27 11:29-0300\n" -"PO-Revision-Date: 2020-01-27 11:31-0300\n" +"POT-Creation-Date: 2020-01-28 08:48-0300\n" +"PO-Revision-Date: 2020-01-28 10:09-0300\n" "Last-Translator: Perry Werneck \n" "Language-Team: Português <>\n" "Language: pt_BR\n" @@ -257,7 +257,7 @@ msgstr "Clique para carregar arquivo" msgid "Click to save file" msgstr "Clique para salvar arquivo" -#: src/dialogs/settings/clipboard.c:385 +#: src/dialogs/settings/clipboard.c:409 msgid "Clipboard" msgstr "Área de transferência" @@ -265,7 +265,7 @@ msgstr "Área de transferência" msgid "Clipboard name" msgstr "Nome da área de transferência" -#: src/dialogs/settings/clipboard.c:384 +#: src/dialogs/settings/clipboard.c:408 msgid "Clipboard properties" msgstr "Configuração da área de transferência" @@ -317,7 +317,7 @@ msgstr "Copiar como texto puro" msgid "Copy as table" msgstr "Copiar como tabela" -#: src/dialogs/settings/clipboard.c:217 +#: src/dialogs/settings/clipboard.c:239 msgid "Copy options" msgstr "Opções da cópia" @@ -523,7 +523,7 @@ msgstr "Cinza" msgid "Green" msgstr "Verde" -#: src/dialogs/settings/clipboard.c:219 +#: src/dialogs/settings/clipboard.c:241 msgid "HTML options" msgstr "Opções HTML" @@ -689,11 +689,11 @@ msgstr "Nenhuma transferência" msgid "No transfer in progress" msgstr "Nenhuma transferência em andamento" -#: src/dialogs/settings/clipboard.c:282 +#: src/dialogs/settings/clipboard.c:306 msgid "None (Don't export color)" msgstr "Nenhum (Não exporta cores)" -#: src/dialogs/settings/clipboard.c:402 +#: src/dialogs/settings/clipboard.c:426 msgid "None (Don't export font name)" msgstr "Nenhuma (Não exporta fontes)" @@ -801,7 +801,7 @@ msgstr "Colar de um arquivo" msgid "Paste from text file" msgstr "Colar de um arquivo texto" -#: src/dialogs/settings/clipboard.c:218 +#: src/dialogs/settings/clipboard.c:240 msgid "Paste options" msgstr "Opções para colar" @@ -825,7 +825,7 @@ msgstr "Rosa" msgid "Plain text" msgstr "Texto puro" -#: src/dialogs/settings/clipboard.c:350 +#: src/dialogs/settings/clipboard.c:374 msgid "Plain text only" msgstr "Apenas texto puro" @@ -982,7 +982,7 @@ msgstr "" "SPACE can be specified in units of TRACKS, CYLINDERS, or AVBLOCK, and only " "one option can be used." -#: src/dialogs/settings/clipboard.c:283 src/dialogs/settings/clipboard.c:403 +#: src/dialogs/settings/clipboard.c:307 src/dialogs/settings/clipboard.c:427 msgid "Same of the screen" msgstr "Igual ao terminal" @@ -1056,7 +1056,7 @@ msgstr "Guarda fila de transferência num arquivo XML externo" msgid "Save transfer queue to file" msgstr "Salvar fila de transferências para arquivo" -#: src/dialogs/settings/clipboard.c:351 +#: src/dialogs/settings/clipboard.c:375 msgid "Screen with terminal attributes" msgstr "Completa incluindo atributos do terminal" @@ -1156,6 +1156,10 @@ msgstr "Skip" msgid "Skip this transfer, keep the file on queue." msgstr "Skip this transfer, keep the file on queue." +#: src/dialogs/settings/clipboard.c:163 +msgid "Smart copy" +msgstr "Cópia inteligente" + #: src/filetransfer/v3270ft.c:341 src/filetransfer/settings.c:544 msgid "Space allocation units" msgstr "Unidades de alocação de espaço" @@ -1515,6 +1519,15 @@ msgstr "" "Quando ativo pesquisa a área de transferência por uma tela similar, se " "encontrar coloca os campos desprotegidos e restaura a posição do cursor" +#: src/dialogs/settings/clipboard.c:164 +msgid "" +"When set the first copy operation after the selection will set the clipboard " +"contents and the next ones will append" +msgstr "" +"Quando selecionado a primeira operação de cópia após a seleção definirá o " +"conteúdo da área de transferência enquanto as operações subsequentes " +"acrescentaram conteúdo" + #: src/dialogs/settings/clipboard.c:144 msgid "" "When set the terminal spaces are exported as non-breaking spaces to prevent " diff --git a/src/dialogs/settings/clipboard.c b/src/dialogs/settings/clipboard.c index 3c90068..d49bc1d 100644 --- a/src/dialogs/settings/clipboard.c +++ b/src/dialogs/settings/clipboard.c @@ -157,8 +157,17 @@ .width = 1, .height = 1, .grid = PASTE_SETTINGS - } + }, + { + .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 = 3, + .width = 1, + .height = 1, + .grid = COPY_SETTINGS + } }; /*--[ Globals ]--------------------------------------------------------------------------------------*/ @@ -206,6 +215,19 @@ static void copy_format_changed(GtkComboBox *widget, GtkWidget *grid) { } +static void keep_selected_toggled(GtkToggleButton *togglebutton, V3270ClipboardSettings *settings) { + + debug("%s",__FUNCTION__); + + if(!gtk_toggle_button_get_active(togglebutton)) { + gtk_toggle_button_set_active(settings->input.checkboxes[2],FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(settings->input.checkboxes[2]),FALSE); + } else { + gtk_widget_set_sensitive(GTK_WIDGET(settings->input.checkboxes[2]),TRUE); + } + +} + static void V3270ClipboardSettings_init(V3270ClipboardSettings *widget) { size_t ix; @@ -263,6 +285,8 @@ static void V3270ClipboardSettings_init(V3270ClipboardSettings *widget) { } v3270_settings_create_toggle_buttons(toggles, G_N_ELEMENTS(toggles), grids, widget->input.toggles); + g_signal_connect(G_OBJECT(widget->input.toggles[1]),"toggled",G_CALLBACK(keep_selected_toggled),widget); + v3270_settings_create_combos(combos, G_N_ELEMENTS(combos), grids, widget->input.combos); v3270_settings_create_checkboxes(checkboxes, G_N_ELEMENTS(checkboxes), grids, widget->input.checkboxes); @@ -447,6 +471,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); // // Set font combo-box @@ -520,12 +545,18 @@ static void apply(GtkWidget *w, GtkWidget *t) { terminal->selection.options &= ~V3270_SELECTION_NON_BREAKABLE_SPACE; } - if(gtk_toggle_button_get_active(widget->input.checkboxes[0])) { + if(gtk_toggle_button_get_active(widget->input.checkboxes[1])) { terminal->selection.options |= V3270_SELECTION_SCREEN_PASTE; } else { terminal->selection.options &= ~V3270_SELECTION_SCREEN_PASTE; } + if(gtk_toggle_button_get_active(widget->input.checkboxes[2])) { + terminal->selection.options |= V3270_SELECTION_SMART_COPY; + } else { + terminal->selection.options &= ~V3270_SELECTION_SMART_COPY; + } + // Get font settings switch(get_active_id(widget,0)) { case '0': diff --git a/src/include/terminal.h b/src/include/terminal.h index 4a4cacf..43ab891 100644 --- a/src/include/terminal.h +++ b/src/include/terminal.h @@ -120,12 +120,13 @@ G_BEGIN_DECLS typedef enum _V3270SelectionOption { - V3270_SELECTION_PLAIN_TEXT = 0x0000, ///< @brief Uses only plain text. - V3270_SELECTION_FONT_FAMILY = 0x0001, ///< @brief Inform font-family. - V3270_SELECTION_COLORS = 0x0002, ///< @brief Inform terminal colors. - V3270_SELECTION_NON_BREAKABLE_SPACE = 0x0004, ///< @brief Use non breakable spaces. - V3270_SELECTION_DIALOG_STATE = 0x0010, ///< @brief Used for settings dialog. - V3270_SELECTION_SCREEN_PASTE = 0x0020, ///< @brief Enable screen paste. + V3270_SELECTION_PLAIN_TEXT = 0x00, ///< @brief Uses only plain text. + V3270_SELECTION_FONT_FAMILY = 0x01, ///< @brief Inform font-family. + V3270_SELECTION_COLORS = 0x02, ///< @brief Inform terminal colors. + V3270_SELECTION_NON_BREAKABLE_SPACE = 0x04, ///< @brief Use non breakable spaces. + 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. } V3270SelectionOption; @@ -155,6 +156,7 @@ G_BEGIN_DECLS int scaled_fonts : 1; /// @brief Use scaled fonts int drawing : 1; /// @brief Draw widget? int freeze : 1; /// @brief Truee when the "save settings" signal is disabled. + int append : 1; /// @brief Next smart-copy operation will be append. /// @brief Action properties. GtkResponseType responses[V3270_TOGGLEABLE_DIALOG_CUSTOM]; diff --git a/src/include/v3270/selection.h b/src/include/v3270/selection.h index a650bf3..2d44af8 100644 --- a/src/include/v3270/selection.h +++ b/src/include/v3270/selection.h @@ -39,11 +39,11 @@ typedef enum _v3270_copy_mode { - V3270_COPY_DEFAULT, ///< @brief Detect format based on lib3270's smart past toggle. V3270_COPY_FORMATTED, ///< @brief Copy formatted data; keep attributes. V3270_COPY_TEXT, ///< @brief Single text format, ignore attributes. V3270_COPY_TABLE, ///< @brief Copy as table. - V3270_COPY_APPEND ///< @brief Append to current contents keeping the stored format. + V3270_COPY_APPEND, ///< @brief Append to current contents keeping the stored format. + V3270_COPY_SMART ///< @brief use append/default based on current copy state. } V3270_COPY_MODE; diff --git a/src/selection/copy.c b/src/selection/copy.c index 25f783f..b668e35 100644 --- a/src/selection/copy.c +++ b/src/selection/copy.c @@ -30,34 +30,32 @@ #include #include - static void do_copy(v3270 *terminal, gboolean cut) - { + static void do_copy(v3270 *terminal, gboolean cut) { + lib3270_selection * selection = lib3270_selection_new(terminal->host,cut,0); - if(selection) - { + if(selection) { terminal->selection.blocks = g_list_append(terminal->selection.blocks,selection); + terminal->append = ((terminal->selection.options & V3270_SELECTION_SMART_COPY) != 0) ? 1 : 0 ; // Define next smart option. } } - LIB3270_EXPORT void v3270_clipboard_set(GtkWidget *widget, V3270_COPY_MODE mode, gboolean cut) - { + LIB3270_EXPORT void v3270_clipboard_set(GtkWidget *widget, V3270_COPY_MODE mode, gboolean cut) { + g_return_if_fail(GTK_IS_V3270(widget)); v3270 * terminal = GTK_V3270(widget); + if(mode == V3270_COPY_SMART) { + mode = (terminal->append ? V3270_COPY_APPEND : V3270_COPY_FORMATTED); + } + if(mode != V3270_COPY_APPEND) { // It's not append, clear current contents ... v3270_clear_selection(terminal); - // ... and set the new mode. - if(mode == V3270_COPY_DEFAULT) { -// mode = (lib3270_get_toggle(v3270_get_session(widget),LIB3270_TOGGLE_SMART_PASTE) ? V3270_COPY_FORMATTED : V3270_COPY_TEXT); - mode = V3270_COPY_FORMATTED; - } - terminal->selection.format = mode; } @@ -67,13 +65,11 @@ v3270_update_system_clipboard(widget); } - LIB3270_EXPORT void v3270_copy_selection(GtkWidget *widget, V3270_COPY_MODE format, gboolean cut) - { + LIB3270_EXPORT void v3270_copy_selection(GtkWidget *widget, V3270_COPY_MODE format, gboolean cut) { v3270_clipboard_set(widget,format,cut); } - LIB3270_EXPORT void v3270_append_selection(GtkWidget *widget, gboolean cut) - { + LIB3270_EXPORT void v3270_append_selection(GtkWidget *widget, gboolean cut) { v3270_clipboard_set(widget,V3270_COPY_APPEND,cut); } diff --git a/src/selection/selection.c b/src/selection/selection.c index d02ce36..ec542a2 100644 --- a/src/selection/selection.c +++ b/src/selection/selection.c @@ -109,6 +109,7 @@ LIB3270_EXPORT void v3270_unselect(GtkWidget *widget) { v3270_disable_updates(widget); lib3270_unselect(v3270_get_session(widget)); + GTK_V3270(widget)->append = 0; // Reset smart-copy. v3270_enable_updates(widget); } @@ -122,6 +123,7 @@ LIB3270_EXPORT void v3270_select_region(GtkWidget *widget, gint start, gint end { g_return_if_fail(GTK_IS_V3270(widget)); lib3270_select_region(GTK_V3270(widget)->host,start,end); + GTK_V3270(widget)->append = 0; // Reset smart-copy. } LIB3270_EXPORT void v3270_select_all(GtkWidget *widget) @@ -130,6 +132,7 @@ LIB3270_EXPORT void v3270_select_all(GtkWidget *widget) v3270_disable_updates(widget); lib3270_select_all(v3270_get_session(widget)); v3270_enable_updates(widget); + GTK_V3270(widget)->append = 0; // Reset smart-copy. } void v3270_selection_set_font_family(GtkWidget *widget, const gchar *name) { diff --git a/src/terminal/actions/table.c b/src/terminal/actions/table.c index 3f36ad4..d93aed2 100644 --- a/src/terminal/actions/table.c +++ b/src/terminal/actions/table.c @@ -63,7 +63,7 @@ // Standard Clipboard actions { - .flags = 0, + .flags = V3270_COPY_SMART, .name = "copy", .group = LIB3270_ACTION_GROUP_SELECTION, .icon = "edit-copy", @@ -112,7 +112,7 @@ }, { - .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_DEFAULT, + .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_SMART, .group = LIB3270_ACTION_GROUP_SELECTION, .name = "cut", .icon = "edit-cut", -- libgit2 0.21.2