Commit d4f9d28b34c20afd44f91bd14c964ffa9d00813a

Authored by Perry Werneck
1 parent 5e08cc14

Implementing clipboard actions.

pw3270.cbp
... ... @@ -57,6 +57,9 @@
57 57 <Unit filename="src/objects/actions/abstract.c">
58 58 <Option compilerVar="CC" />
59 59 </Unit>
  60 + <Unit filename="src/objects/actions/clipboard.c">
  61 + <Option compilerVar="CC" />
  62 + </Unit>
60 63 <Unit filename="src/objects/actions/connect.c">
61 64 <Option compilerVar="CC" />
62 65 </Unit>
... ...
src/objects/actions/clipboard.c 0 → 100644
... ... @@ -0,0 +1,132 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como - e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + /**
  31 + * @brief Implement PW3270 clipboard actions.
  32 + *
  33 + */
  34 +
  35 + #include "private.h"
  36 + #include <v3270.h>
  37 +
  38 + static void activate_copy(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) {
  39 +
  40 + debug("%s",__FUNCTION__);
  41 + v3270_copy_selection(terminal,V3270_SELECT_TEXT,FALSE);
  42 +
  43 + }
  44 +
  45 + static void activate_cut(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) {
  46 +
  47 + debug("%s",__FUNCTION__);
  48 + v3270_copy_selection(terminal,V3270_SELECT_TEXT,TRUE);
  49 +
  50 + }
  51 +
  52 + static void activate_paste(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) {
  53 +
  54 + debug("%s",__FUNCTION__);
  55 + v3270_paste(terminal);
  56 +
  57 + }
  58 +
  59 + GAction * pw3270_copy_action_new(void) {
  60 +
  61 + static const LIB3270_ACTION action_descriptor = {
  62 + .name = "copy",
  63 + .type = LIB3270_ACTION_TYPE_SELECTION,
  64 +
  65 + .key = "<ctrl>c",
  66 + .icon = "edit-copy",
  67 + .label = N_( "_Copy" ),
  68 + .summary = N_( "Copy selected area to clipboard." ),
  69 + .activate = NULL,
  70 +
  71 + .group = LIB3270_ACTION_GROUP_SELECTED,
  72 + .activatable = lib3270_has_selection
  73 +
  74 + };
  75 +
  76 + GAction * action = pw3270_action_new_from_lib3270(&action_descriptor);
  77 +
  78 + PW3270_ACTION(action)->activate = activate_copy;
  79 +
  80 + return action;
  81 +
  82 + }
  83 +
  84 + GAction * pw3270_cut_action_new(void) {
  85 +
  86 + static const LIB3270_ACTION action_descriptor = {
  87 + .name = "cut",
  88 + .type = LIB3270_ACTION_TYPE_SELECTION,
  89 +
  90 + .key = "<ctrl>x",
  91 + .icon = "edit-cut",
  92 + .label = N_( "_Cut" ),
  93 + .summary = N_( "Cut selected area." ),
  94 + .activate = NULL,
  95 +
  96 + .group = LIB3270_ACTION_GROUP_SELECTED,
  97 + .activatable = lib3270_has_selection
  98 +
  99 + };
  100 +
  101 + GAction * action = pw3270_action_new_from_lib3270(&action_descriptor);
  102 +
  103 + PW3270_ACTION(action)->activate = activate_cut;
  104 +
  105 + return action;
  106 +
  107 + }
  108 +
  109 + GAction * pw3270_paste_action_new(void) {
  110 +
  111 + static const LIB3270_ACTION action_descriptor = {
  112 + .name = "paste",
  113 + .type = LIB3270_ACTION_TYPE_SELECTION,
  114 +
  115 + .key = "<ctrl>v",
  116 + .icon = "edit-paste",
  117 + .label = N_( "_Paste" ),
  118 + .summary = N_( "Paste data from clipboard." ),
  119 + .activate = NULL,
  120 +
  121 + .group = LIB3270_ACTION_GROUP_ONLINE,
  122 + .activatable = lib3270_is_connected
  123 +
  124 + };
  125 +
  126 + GAction * action = pw3270_action_new_from_lib3270(&action_descriptor);
  127 +
  128 + PW3270_ACTION(action)->activate = activate_paste;
  129 +
  130 + return action;
  131 +
  132 + }
... ...
src/objects/actions/private.h
... ... @@ -90,5 +90,7 @@
90 90  
91 91 // Internal actions
92 92 G_GNUC_INTERNAL GAction * pw3270_connect_action_new(void);
  93 + G_GNUC_INTERNAL GAction * pw3270_copy_action_new(void);
  94 + G_GNUC_INTERNAL GAction * pw3270_paste_action_new(void);
93 95  
94 96 #endif // PRIVATE_H_INCLUDED
... ...
src/objects/actions/window.c
... ... @@ -68,7 +68,10 @@
68 68 GAction * actions[] = {
69 69 pw3270_action_new_pfkey(),
70 70 pw3270_action_new_pakey(),
71   - pw3270_connect_action_new()
  71 + pw3270_connect_action_new(),
  72 + pw3270_copy_action_new(),
  73 + pw3270_cut_action_new(),
  74 + pw3270_paste_action_new()
72 75 };
73 76  
74 77 for(ix = 0; ix < G_N_ELEMENTS(actions); ix++) {
... ...
src/objects/window/tools.c
... ... @@ -28,6 +28,7 @@
28 28 */
29 29  
30 30 #include "private.h"
  31 + #include <pw3270/application.h>
31 32  
32 33 GtkWidget * pw3270_setup_image_button(GtkWidget *button, const gchar *image_name) {
33 34  
... ...
src/objects/window/window.c
... ... @@ -102,15 +102,14 @@
102 102 //
103 103 {
104 104 static const gchar *actions[] = {
105   - "win.select_all",
106 105 "win.copy",
107 106 "win.paste",
  107 + "win.select_all",
108 108 "separator",
109 109 "win.connect",
110 110 "win.disconnect",
111 111 "separator",
112   - "win.print",
113   - "win.close"
  112 + "win.print"
114 113 };
115 114  
116 115 size_t ix;
... ...