Commit 0813b6340ba695aec25bcedcd863c4de2c6d38bf

Authored by perry.werneck@gmail.com
1 parent ce603b9a

Implementando "paste"

pw3270.cbp
... ... @@ -8,8 +8,8 @@
8 8 <Option compiler="gcc" />
9 9 <Build>
10 10 <Target title="Debug">
11   - <Option output=".bin/Debug/pw3270" prefix_auto="1" extension_auto="1" />
12   - <Option object_output=".obj/Debug/" />
  11 + <Option output=".bin\Debug\pw3270" prefix_auto="1" extension_auto="1" />
  12 + <Option object_output=".obj\Debug\" />
13 13 <Option type="0" />
14 14 <Option compiler="gcc" />
15 15 <Compiler>
... ... @@ -18,8 +18,8 @@
18 18 </Compiler>
19 19 </Target>
20 20 <Target title="Release">
21   - <Option output=".bin/Release/pw3270" prefix_auto="1" extension_auto="1" />
22   - <Option object_output=".obj/Release/" />
  21 + <Option output=".bin\Release\pw3270" prefix_auto="1" extension_auto="1" />
  22 + <Option object_output=".obj\Release\" />
23 23 <Option type="0" />
24 24 <Option compiler="gcc" />
25 25 <Compiler>
... ... @@ -33,7 +33,7 @@
33 33 <Compiler>
34 34 <Add option="-Wall" />
35 35 <Add option="`pkg-config gtk+-3.0 lib3270 --cflags`" />
36   - <Add directory="src/include" />
  36 + <Add directory="src\include" />
37 37 </Compiler>
38 38 <Linker>
39 39 <Add option="`pkg-config gtk+-3.0 lib3270 --libs`" />
... ... @@ -41,275 +41,284 @@
41 41 <Unit filename="Makefile.in" />
42 42 <Unit filename="configure.ac" />
43 43 <Unit filename="pw3270.spec.in" />
44   - <Unit filename="src/gtk/Makefile.in" />
45   - <Unit filename="src/gtk/actions.c">
  44 + <Unit filename="src\gtk\Makefile.in" />
  45 + <Unit filename="src\gtk\actions.c">
46 46 <Option compilerVar="CC" />
47 47 </Unit>
48   - <Unit filename="src/gtk/common/common.h" />
49   - <Unit filename="src/gtk/common/config.c">
  48 + <Unit filename="src\gtk\common\common.h" />
  49 + <Unit filename="src\gtk\common\config.c">
50 50 <Option compilerVar="CC" />
51 51 </Unit>
52   - <Unit filename="src/gtk/fonts.c">
  52 + <Unit filename="src\gtk\fonts.c">
53 53 <Option compilerVar="CC" />
54 54 </Unit>
55   - <Unit filename="src/gtk/globals.h" />
56   - <Unit filename="src/gtk/main.c">
  55 + <Unit filename="src\gtk\globals.h" />
  56 + <Unit filename="src\gtk\main.c">
57 57 <Option compilerVar="CC" />
58 58 </Unit>
59   - <Unit filename="src/gtk/mainwindow.c">
  59 + <Unit filename="src\gtk\mainwindow.c">
60 60 <Option compilerVar="CC" />
61 61 </Unit>
62   - <Unit filename="src/gtk/uiparser/Makefile.in" />
63   - <Unit filename="src/gtk/uiparser/accelerator.c">
  62 + <Unit filename="src\gtk\uiparser\Makefile.in" />
  63 + <Unit filename="src\gtk\uiparser\accelerator.c">
64 64 <Option compilerVar="CC" />
65 65 </Unit>
66   - <Unit filename="src/gtk/uiparser/action.c">
  66 + <Unit filename="src\gtk\uiparser\action.c">
67 67 <Option compilerVar="CC" />
68 68 </Unit>
69   - <Unit filename="src/gtk/uiparser/menu.c">
  69 + <Unit filename="src\gtk\uiparser\menu.c">
70 70 <Option compilerVar="CC" />
71 71 </Unit>
72   - <Unit filename="src/gtk/uiparser/menubar.c">
  72 + <Unit filename="src\gtk\uiparser\menubar.c">
73 73 <Option compilerVar="CC" />
74 74 </Unit>
75   - <Unit filename="src/gtk/uiparser/menuitem.c">
  75 + <Unit filename="src\gtk\uiparser\menuitem.c">
76 76 <Option compilerVar="CC" />
77 77 </Unit>
78   - <Unit filename="src/gtk/uiparser/parsefile.c">
  78 + <Unit filename="src\gtk\uiparser\parsefile.c">
79 79 <Option compilerVar="CC" />
80 80 </Unit>
81   - <Unit filename="src/gtk/uiparser/parser.c">
  81 + <Unit filename="src\gtk\uiparser\parser.c">
82 82 <Option compilerVar="CC" />
83 83 </Unit>
84   - <Unit filename="src/gtk/uiparser/parser.h" />
85   - <Unit filename="src/gtk/uiparser/popup.c">
  84 + <Unit filename="src\gtk\uiparser\parser.h" />
  85 + <Unit filename="src\gtk\uiparser\popup.c">
86 86 <Option compilerVar="CC" />
87 87 </Unit>
88   - <Unit filename="src/gtk/uiparser/private.h" />
89   - <Unit filename="src/gtk/uiparser/script.c">
  88 + <Unit filename="src\gtk\uiparser\private.h" />
  89 + <Unit filename="src\gtk\uiparser\script.c">
90 90 <Option compilerVar="CC" />
91 91 </Unit>
92   - <Unit filename="src/gtk/uiparser/separator.c">
  92 + <Unit filename="src\gtk\uiparser\separator.c">
93 93 <Option compilerVar="CC" />
94 94 </Unit>
95   - <Unit filename="src/gtk/uiparser/sources.mak" />
96   - <Unit filename="src/gtk/uiparser/toolbar.c">
  95 + <Unit filename="src\gtk\uiparser\sources.mak" />
  96 + <Unit filename="src\gtk\uiparser\toolbar.c">
97 97 <Option compilerVar="CC" />
98 98 </Unit>
99   - <Unit filename="src/gtk/uiparser/toolitem.c">
  99 + <Unit filename="src\gtk\uiparser\toolitem.c">
100 100 <Option compilerVar="CC" />
101 101 </Unit>
102   - <Unit filename="src/gtk/v3270/clipboard.c">
  102 + <Unit filename="src\gtk\v3270\clipboard.c">
103 103 <Option compilerVar="CC" />
104 104 </Unit>
105   - <Unit filename="src/gtk/v3270/draw.c">
  105 + <Unit filename="src\gtk\v3270\draw.c">
106 106 <Option compilerVar="CC" />
107 107 </Unit>
108   - <Unit filename="src/gtk/v3270/genmarshal" />
109   - <Unit filename="src/gtk/v3270/iocallback.c">
  108 + <Unit filename="src\gtk\v3270\genmarshal" />
  109 + <Unit filename="src\gtk\v3270\iocallback.c">
110 110 <Option compilerVar="CC" />
111 111 </Unit>
112   - <Unit filename="src/gtk/v3270/keyboard.c">
  112 + <Unit filename="src\gtk\v3270\keyboard.c">
113 113 <Option compilerVar="CC" />
114 114 </Unit>
115   - <Unit filename="src/gtk/v3270/mouse.c">
  115 + <Unit filename="src\gtk\v3270\mouse.c">
116 116 <Option compilerVar="CC" />
117 117 </Unit>
118   - <Unit filename="src/gtk/v3270/oia.c">
  118 + <Unit filename="src\gtk\v3270\oia.c">
119 119 <Option compilerVar="CC" />
120 120 </Unit>
121   - <Unit filename="src/gtk/v3270/private.h" />
122   - <Unit filename="src/gtk/v3270/sources.mak" />
123   - <Unit filename="src/gtk/v3270/v3270.h" />
124   - <Unit filename="src/gtk/v3270/widget.c">
  121 + <Unit filename="src\gtk\v3270\private.h" />
  122 + <Unit filename="src\gtk\v3270\sources.mak" />
  123 + <Unit filename="src\gtk\v3270\v3270.h" />
  124 + <Unit filename="src\gtk\v3270\widget.c">
125 125 <Option compilerVar="CC" />
126 126 </Unit>
127   - <Unit filename="src/include/lib3270.h" />
128   - <Unit filename="src/include/lib3270/action_table.h" />
129   - <Unit filename="src/include/lib3270/actions.h" />
130   - <Unit filename="src/include/lib3270/config.h.in" />
131   - <Unit filename="src/include/lib3270/log.h" />
132   - <Unit filename="src/include/lib3270/popup.h" />
133   - <Unit filename="src/include/lib3270/selection.h" />
134   - <Unit filename="src/include/lib3270/session.h" />
135   - <Unit filename="src/include/pw3270.h" />
136   - <Unit filename="src/include/rules.mak.in" />
137   - <Unit filename="src/lib3270/3270ds.h" />
138   - <Unit filename="src/lib3270/Makefile.in" />
139   - <Unit filename="src/lib3270/X11keysym.h" />
140   - <Unit filename="src/lib3270/XtGlue.c">
  127 + <Unit filename="src\include\lib3270.h" />
  128 + <Unit filename="src\include\lib3270\action_table.h" />
  129 + <Unit filename="src\include\lib3270\actions.h" />
  130 + <Unit filename="src\include\lib3270\config.h.in" />
  131 + <Unit filename="src\include\lib3270\log.h" />
  132 + <Unit filename="src\include\lib3270\popup.h" />
  133 + <Unit filename="src\include\lib3270\selection.h" />
  134 + <Unit filename="src\include\lib3270\session.h" />
  135 + <Unit filename="src\include\pw3270.h" />
  136 + <Unit filename="src\include\rules.mak.in" />
  137 + <Unit filename="src\lib3270\3270ds.h" />
  138 + <Unit filename="src\lib3270\Makefile.in" />
  139 + <Unit filename="src\lib3270\X11keysym.h" />
  140 + <Unit filename="src\lib3270\XtGlue.c">
141 141 <Option compilerVar="CC" />
142 142 </Unit>
143   - <Unit filename="src/lib3270/actions.c">
  143 + <Unit filename="src\lib3270\actions.c">
144 144 <Option compilerVar="CC" />
145 145 </Unit>
146   - <Unit filename="src/lib3270/actionsc.h" />
147   - <Unit filename="src/lib3270/ansi.c">
  146 + <Unit filename="src\lib3270\actionsc.h" />
  147 + <Unit filename="src\lib3270\ansi.c">
148 148 <Option compilerVar="CC" />
149 149 </Unit>
150   - <Unit filename="src/lib3270/ansic.h" />
151   - <Unit filename="src/lib3270/api.h" />
152   - <Unit filename="src/lib3270/apl.c">
  150 + <Unit filename="src\lib3270\ansic.h" />
  151 + <Unit filename="src\lib3270\api.h" />
  152 + <Unit filename="src\lib3270\apl.c">
153 153 <Option compilerVar="CC" />
154 154 </Unit>
155   - <Unit filename="src/lib3270/aplc.h" />
156   - <Unit filename="src/lib3270/appres.h" />
157   - <Unit filename="src/lib3270/arpa_telnet.h" />
158   - <Unit filename="src/lib3270/cg.h" />
159   - <Unit filename="src/lib3270/charset.c">
  155 + <Unit filename="src\lib3270\aplc.h" />
  156 + <Unit filename="src\lib3270\appres.h" />
  157 + <Unit filename="src\lib3270\arpa_telnet.h" />
  158 + <Unit filename="src\lib3270\cg.h" />
  159 + <Unit filename="src\lib3270\charset.c">
160 160 <Option compilerVar="CC" />
161 161 </Unit>
162   - <Unit filename="src/lib3270/charsetc.h" />
163   - <Unit filename="src/lib3270/childc.h" />
164   - <Unit filename="src/lib3270/ctlr.c">
  162 + <Unit filename="src\lib3270\charsetc.h" />
  163 + <Unit filename="src\lib3270\childc.h" />
  164 + <Unit filename="src\lib3270\ctlr.c">
165 165 <Option compilerVar="CC" />
166 166 </Unit>
167   - <Unit filename="src/lib3270/ctlr.h" />
168   - <Unit filename="src/lib3270/ctlrc.h" />
169   - <Unit filename="src/lib3270/dialogc.h" />
170   - <Unit filename="src/lib3270/fallbacks.c">
  167 + <Unit filename="src\lib3270\ctlr.h" />
  168 + <Unit filename="src\lib3270\ctlrc.h" />
  169 + <Unit filename="src\lib3270\dialogc.h" />
  170 + <Unit filename="src\lib3270\fallbacks.c">
171 171 <Option compilerVar="CC" />
172 172 </Unit>
173   - <Unit filename="src/lib3270/ft.c">
  173 + <Unit filename="src\lib3270\ft.c">
174 174 <Option compilerVar="CC" />
175 175 </Unit>
176   - <Unit filename="src/lib3270/ft_cut.c">
  176 + <Unit filename="src\lib3270\ft_cut.c">
177 177 <Option compilerVar="CC" />
178 178 </Unit>
179   - <Unit filename="src/lib3270/ft_cut_ds.h" />
180   - <Unit filename="src/lib3270/ft_cutc.h" />
181   - <Unit filename="src/lib3270/ft_dft.c">
  179 + <Unit filename="src\lib3270\ft_cut_ds.h" />
  180 + <Unit filename="src\lib3270\ft_cutc.h" />
  181 + <Unit filename="src\lib3270\ft_dft.c">
182 182 <Option compilerVar="CC" />
183 183 </Unit>
184   - <Unit filename="src/lib3270/ft_dft_ds.h" />
185   - <Unit filename="src/lib3270/ft_dftc.h" />
186   - <Unit filename="src/lib3270/ftc.h" />
187   - <Unit filename="src/lib3270/globals.h" />
188   - <Unit filename="src/lib3270/glue.c">
  184 + <Unit filename="src\lib3270\ft_dft_ds.h" />
  185 + <Unit filename="src\lib3270\ft_dftc.h" />
  186 + <Unit filename="src\lib3270\ftc.h" />
  187 + <Unit filename="src\lib3270\globals.h" />
  188 + <Unit filename="src\lib3270\glue.c">
189 189 <Option compilerVar="CC" />
190 190 </Unit>
191   - <Unit filename="src/lib3270/gluec.h" />
192   - <Unit filename="src/lib3270/host.c">
  191 + <Unit filename="src\lib3270\gluec.h" />
  192 + <Unit filename="src\lib3270\host.c">
193 193 <Option compilerVar="CC" />
194 194 </Unit>
195   - <Unit filename="src/lib3270/hostc.h" />
196   - <Unit filename="src/lib3270/icmdc.h" />
197   - <Unit filename="src/lib3270/keypadc.h" />
198   - <Unit filename="src/lib3270/kybd.c">
  195 + <Unit filename="src\lib3270\hostc.h" />
  196 + <Unit filename="src\lib3270\icmdc.h" />
  197 + <Unit filename="src\lib3270\keypadc.h" />
  198 + <Unit filename="src\lib3270\kybd.c">
199 199 <Option compilerVar="CC" />
200 200 </Unit>
201   - <Unit filename="src/lib3270/kybdc.h" />
202   - <Unit filename="src/lib3270/localdefs.h" />
203   - <Unit filename="src/lib3270/log.c">
  201 + <Unit filename="src\lib3270\kybdc.h" />
  202 + <Unit filename="src\lib3270\localdefs.h" />
  203 + <Unit filename="src\lib3270\log.c">
204 204 <Option compilerVar="CC" />
205 205 </Unit>
206   - <Unit filename="src/lib3270/macros.c">
  206 + <Unit filename="src\lib3270\macros.c">
207 207 <Option compilerVar="CC" />
208 208 </Unit>
209   - <Unit filename="src/lib3270/mkfb.c">
  209 + <Unit filename="src\lib3270\mkfb.c">
210 210 <Option compilerVar="CC" />
211 211 </Unit>
212   - <Unit filename="src/lib3270/objects.h" />
213   - <Unit filename="src/lib3270/paste.c">
  212 + <Unit filename="src\lib3270\objects.h" />
  213 + <Unit filename="src\lib3270\paste.c">
214 214 <Option compilerVar="CC" />
215 215 </Unit>
216   - <Unit filename="src/lib3270/popupsc.h" />
217   - <Unit filename="src/lib3270/print.c">
  216 + <Unit filename="src\lib3270\popupsc.h" />
  217 + <Unit filename="src\lib3270\print.c">
218 218 <Option compilerVar="CC" />
219 219 </Unit>
220   - <Unit filename="src/lib3270/printc.h" />
221   - <Unit filename="src/lib3270/printer.c">
  220 + <Unit filename="src\lib3270\printc.h" />
  221 + <Unit filename="src\lib3270\printer.c">
222 222 <Option compilerVar="CC" />
223 223 </Unit>
224   - <Unit filename="src/lib3270/printerc.h" />
225   - <Unit filename="src/lib3270/proxy.c">
  224 + <Unit filename="src\lib3270\printerc.h" />
  225 + <Unit filename="src\lib3270\proxy.c">
226 226 <Option compilerVar="CC" />
227 227 </Unit>
228   - <Unit filename="src/lib3270/proxyc.h" />
229   - <Unit filename="src/lib3270/resolver.c">
  228 + <Unit filename="src\lib3270\proxyc.h" />
  229 + <Unit filename="src\lib3270\resolver.c">
230 230 <Option compilerVar="CC" />
231 231 </Unit>
232   - <Unit filename="src/lib3270/resolverc.h" />
233   - <Unit filename="src/lib3270/resources.c">
  232 + <Unit filename="src\lib3270\resolverc.h" />
  233 + <Unit filename="src\lib3270\resources.c">
234 234 <Option compilerVar="CC" />
235 235 </Unit>
236   - <Unit filename="src/lib3270/resources.h" />
237   - <Unit filename="src/lib3270/rpq.c">
  236 + <Unit filename="src\lib3270\resources.h" />
  237 + <Unit filename="src\lib3270\rpq.c">
238 238 <Option compilerVar="CC" />
239 239 </Unit>
240   - <Unit filename="src/lib3270/savec.h" />
241   - <Unit filename="src/lib3270/screen.c">
  240 + <Unit filename="src\lib3270\savec.h" />
  241 + <Unit filename="src\lib3270\screen.c">
242 242 <Option compilerVar="CC" />
243 243 </Unit>
244   - <Unit filename="src/lib3270/screen.h" />
245   - <Unit filename="src/lib3270/screenc.h" />
246   - <Unit filename="src/lib3270/scrollc.h" />
247   - <Unit filename="src/lib3270/see.c">
  244 + <Unit filename="src\lib3270\screen.h" />
  245 + <Unit filename="src\lib3270\screenc.h" />
  246 + <Unit filename="src\lib3270\scrollc.h" />
  247 + <Unit filename="src\lib3270\see.c">
248 248 <Option compilerVar="CC" />
249 249 </Unit>
250   - <Unit filename="src/lib3270/seec.h" />
251   - <Unit filename="src/lib3270/selection.c">
  250 + <Unit filename="src\lib3270\seec.h" />
  251 + <Unit filename="src\lib3270\selection.c">
252 252 <Option compilerVar="CC" />
253 253 </Unit>
254   - <Unit filename="src/lib3270/sf.c">
  254 + <Unit filename="src\lib3270\sf.c">
255 255 <Option compilerVar="CC" />
256 256 </Unit>
257   - <Unit filename="src/lib3270/sfc.h" />
258   - <Unit filename="src/lib3270/shlobj_missing.h" />
259   - <Unit filename="src/lib3270/statusc.h" />
260   - <Unit filename="src/lib3270/tables.c">
  257 + <Unit filename="src\lib3270\sfc.h" />
  258 + <Unit filename="src\lib3270\shlobj_missing.h" />
  259 + <Unit filename="src\lib3270\statusc.h" />
  260 + <Unit filename="src\lib3270\tables.c">
261 261 <Option compilerVar="CC" />
262 262 </Unit>
263   - <Unit filename="src/lib3270/tablesc.h" />
264   - <Unit filename="src/lib3270/telnet.c">
  263 + <Unit filename="src\lib3270\tablesc.h" />
  264 + <Unit filename="src\lib3270\telnet.c">
265 265 <Option compilerVar="CC" />
266 266 </Unit>
267   - <Unit filename="src/lib3270/telnetc.h" />
268   - <Unit filename="src/lib3270/testprogram.c">
  267 + <Unit filename="src\lib3270\telnetc.h" />
  268 + <Unit filename="src\lib3270\testprogram.c">
269 269 <Option compilerVar="CC" />
270 270 </Unit>
271   - <Unit filename="src/lib3270/tn3270e.h" />
272   - <Unit filename="src/lib3270/toggle.h" />
273   - <Unit filename="src/lib3270/toggles.c">
  271 + <Unit filename="src\lib3270\tn3270e.h" />
  272 + <Unit filename="src\lib3270\toggle.h" />
  273 + <Unit filename="src\lib3270\toggles.c">
274 274 <Option compilerVar="CC" />
275 275 </Unit>
276   - <Unit filename="src/lib3270/togglesc.h" />
277   - <Unit filename="src/lib3270/trace_ds.c">
  276 + <Unit filename="src\lib3270\togglesc.h" />
  277 + <Unit filename="src\lib3270\trace_ds.c">
278 278 <Option compilerVar="CC" />
279 279 </Unit>
280   - <Unit filename="src/lib3270/trace_dsc.h" />
281   - <Unit filename="src/lib3270/utf8.c">
  280 + <Unit filename="src\lib3270\trace_dsc.h" />
  281 + <Unit filename="src\lib3270\utf8.c">
282 282 <Option compilerVar="CC" />
283 283 </Unit>
284   - <Unit filename="src/lib3270/utf8c.h" />
285   - <Unit filename="src/lib3270/util.c">
  284 + <Unit filename="src\lib3270\utf8c.h" />
  285 + <Unit filename="src\lib3270\util.c">
286 286 <Option compilerVar="CC" />
287 287 </Unit>
288   - <Unit filename="src/lib3270/utilc.h" />
289   - <Unit filename="src/lib3270/version.c">
  288 + <Unit filename="src\lib3270\utilc.h" />
  289 + <Unit filename="src\lib3270\version.c">
290 290 <Option compilerVar="CC" />
291 291 </Unit>
292   - <Unit filename="src/lib3270/w3misc.c">
  292 + <Unit filename="src\lib3270\w3misc.c">
293 293 <Option compilerVar="CC" />
294 294 </Unit>
295   - <Unit filename="src/lib3270/w3miscc.h" />
296   - <Unit filename="src/lib3270/widec.h" />
297   - <Unit filename="src/lib3270/winvers.c">
  295 + <Unit filename="src\lib3270\w3miscc.h" />
  296 + <Unit filename="src\lib3270\widec.h" />
  297 + <Unit filename="src\lib3270\winvers.c">
298 298 <Option compilerVar="CC" />
299 299 </Unit>
300   - <Unit filename="src/lib3270/winversc.h" />
301   - <Unit filename="src/lib3270/xio.c">
  300 + <Unit filename="src\lib3270\winversc.h" />
  301 + <Unit filename="src\lib3270\xio.c">
302 302 <Option compilerVar="CC" />
303 303 </Unit>
304   - <Unit filename="src/lib3270/xioc.h" />
305   - <Unit filename="src/lib3270/xl.h" />
306   - <Unit filename="ui/00default.xml" />
307   - <Unit filename="ui/99debug.xml" />
  304 + <Unit filename="src\lib3270\xioc.h" />
  305 + <Unit filename="src\lib3270\xl.h" />
  306 + <Unit filename="ui\00default.xml" />
  307 + <Unit filename="ui\99debug.xml" />
308 308 <Unit filename="valgrind.suppression" />
309 309 <Extensions>
310 310 <code_completion />
311 311 <debugger />
312 312 <envvars />
  313 + <DoxyBlocks>
  314 + <comment_style block="0" line="0" />
  315 + <doxyfile_project />
  316 + <doxyfile_build />
  317 + <doxyfile_warnings />
  318 + <doxyfile_output />
  319 + <doxyfile_dot />
  320 + <general />
  321 + </DoxyBlocks>
313 322 </Extensions>
314 323 </Project>
315 324 </CodeBlocks_project_file>
... ...
src/gtk/actions.c
... ... @@ -74,6 +74,11 @@ static void copy_action(GtkAction *action, GtkWidget *widget)
74 74 v3270_copy_clipboard(GTK_V3270(widget));
75 75 }
76 76  
  77 +static void paste_action(GtkAction *action, GtkWidget *widget)
  78 +{
  79 + trace("Action %s activated on widget %p",gtk_action_get_name(action),widget);
  80 + v3270_paste_clipboard(GTK_V3270(widget));
  81 +}
77 82  
78 83 void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id)
79 84 {
... ... @@ -110,6 +115,7 @@ void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name,
110 115 { "connect", connect_action },
111 116 { "copy", copy_action },
112 117 { "disconnect", disconnect_action },
  118 + { "paste", paste_action },
113 119 };
114 120  
115 121 int f;
... ...
src/gtk/mainwindow.c
... ... @@ -118,14 +118,31 @@
118 118  
119 119 static void disconnected(GtkWidget *widget, GtkActionGroup **group)
120 120 {
  121 + gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],FALSE);
121 122 gtk_action_group_set_sensitive(group[ACTION_GROUP_ONLINE],FALSE);
122 123 gtk_action_group_set_sensitive(group[ACTION_GROUP_OFFLINE],TRUE);
123 124 }
124 125  
  126 +#ifndef WIN32
  127 + static void clipboard_text_check(GtkClipboard *clipboard, const gchar *text, GtkActionGroup **group)
  128 + {
  129 + trace("%s called with text=%p",__FUNCTION__,text);
  130 + gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],text != NULL);
  131 + }
  132 +#endif
  133 +
125 134 static void connected(GtkWidget *widget, GtkActionGroup **group)
126 135 {
127 136 gtk_action_group_set_sensitive(group[ACTION_GROUP_ONLINE],TRUE);
128 137 gtk_action_group_set_sensitive(group[ACTION_GROUP_OFFLINE],FALSE);
  138 +
  139 +#ifdef WIN32
  140 + gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],TRUE);
  141 +#else
  142 + gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],FALSE);
  143 + gtk_clipboard_request_text(gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD),clipboard_text_check,(gpointer) group);
  144 +#endif
  145 +
129 146 }
130 147  
131 148 static void update_config(GtkWidget *widget, const gchar *name, const gchar *value)
... ...
src/gtk/v3270/clipboard.c
... ... @@ -109,3 +109,174 @@ void v3270_copy_clipboard(v3270 *widget)
109 109 }
110 110 }
111 111  
  112 +static void paste_text(GtkWidget *widget, const gchar *text, const gchar *encoding)
  113 +{
  114 + gchar *buffer = NULL;
  115 + gchar *ptr;
  116 + GError *error = NULL;
  117 + H3270 *session = v3270_get_session(widget);
  118 +
  119 + if(!text)
  120 + return;
  121 +
  122 + buffer = g_convert(text, -1, lib3270_get_charset(session), encoding, NULL, NULL, &error);
  123 +
  124 + if(!buffer)
  125 + {
  126 + /* Falhou ao converter - Reajusta e tenta de novo */
  127 + int f;
  128 +
  129 + static const struct _xlat
  130 + {
  131 + const gchar *from;
  132 + const gchar *to;
  133 + } xlat[] =
  134 + {
  135 + { "–", "-" },
  136 + { "→", "->" },
  137 + { "←", "<-" },
  138 + { "©", "(c)" },
  139 + { "↔", "<->" },
  140 + { "™", "(TM)" },
  141 + { "®", "(R)" },
  142 + { "“", "\"" },
  143 + { "”", "\"" },
  144 + { "…", "..." },
  145 + { "•", "*" },
  146 + { "․", "." },
  147 + { "·", "*" },
  148 +
  149 + };
  150 +
  151 + gchar *string = g_strdup(text);
  152 +
  153 + if(error)
  154 + {
  155 + g_error_free(error);
  156 + error = NULL;
  157 + }
  158 +
  159 + // FIXME (perry#1#): Is there any better way for a "sed" here?
  160 + for(f=0;f<G_N_ELEMENTS(xlat);f++)
  161 + {
  162 + gchar *ptr = g_strstr_len(string,-1,xlat[f].from);
  163 +
  164 + if(ptr)
  165 + {
  166 + gchar *old = string;
  167 + gchar **tmp = g_strsplit(old,xlat[f].from,-1);
  168 + string = g_strjoinv(xlat[f].to,tmp);
  169 + g_strfreev(tmp);
  170 + g_free(old);
  171 + }
  172 + }
  173 +
  174 + buffer = g_convert(string, -1, lib3270_get_charset(session), encoding, NULL, NULL, &error);
  175 +
  176 + if(!buffer)
  177 + {
  178 + gchar **ln = g_strsplit(string,"\n",-1);
  179 +
  180 + for(f=0;ln[f];f++)
  181 + {
  182 + gchar *str = g_convert(ln[f], -1, lib3270_get_charset(session), encoding, NULL, NULL, &error);
  183 +
  184 + if(error)
  185 + {
  186 + g_error_free(error);
  187 + error = 0;
  188 + }
  189 +
  190 + if(!str)
  191 + {
  192 + GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW( gtk_widget_get_toplevel(widget)),
  193 + GTK_DIALOG_DESTROY_WITH_PARENT,
  194 + GTK_MESSAGE_ERROR,
  195 + GTK_BUTTONS_OK,
  196 + _( "Can't convert line %d from %s to %s" ),f+1, encoding, lib3270_get_charset(session));
  197 +
  198 + gtk_window_set_title(GTK_WINDOW(dialog), _( "Charset error" ) );
  199 + if(error)
  200 + {
  201 + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s\n%s", error->message ? error->message : N_( "Unexpected error" ), ln[f]);
  202 + g_error_free(error);
  203 + error = 0;
  204 + }
  205 + else
  206 + {
  207 + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s", ln[f]);
  208 + }
  209 + gtk_dialog_run(GTK_DIALOG (dialog));
  210 + gtk_widget_destroy(dialog);
  211 + return;
  212 +
  213 + }
  214 + else
  215 + {
  216 + g_free(str);
  217 + }
  218 + }
  219 +
  220 + g_strfreev(ln);
  221 + g_free(string);
  222 + }
  223 +
  224 + g_free(string);
  225 +
  226 + if(error)
  227 + {
  228 + g_error_free(error);
  229 + error = 0;
  230 + }
  231 +
  232 +
  233 + if(!buffer)
  234 + {
  235 + GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW( gtk_widget_get_toplevel(widget)),
  236 + GTK_DIALOG_DESTROY_WITH_PARENT,
  237 + GTK_MESSAGE_ERROR,
  238 + GTK_BUTTONS_OK,
  239 + _( "Can't convert text from %s to %s" ), encoding, lib3270_get_charset(session));
  240 +
  241 + gtk_window_set_title(GTK_WINDOW(dialog), _( "Charset error" ) );
  242 + if(error)
  243 + {
  244 + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s", error->message ? error->message : N_( "Unexpected error" ));
  245 + g_error_free(error);
  246 + error = 0;
  247 + }
  248 + gtk_dialog_run(GTK_DIALOG (dialog));
  249 + gtk_widget_destroy(dialog);
  250 +
  251 + return;
  252 + }
  253 + }
  254 +
  255 + if(error)
  256 + g_error_free(error);
  257 +
  258 + /* Remove TABS */
  259 + for(ptr = buffer;*ptr;ptr++)
  260 + {
  261 + if(*ptr == '\t')
  262 + *ptr = ' ';
  263 + }
  264 +
  265 + trace("Received text:%p (%d bytes)",buffer,(int) strlen(buffer));
  266 +
  267 +// paste_string(buffer);
  268 +
  269 + g_free(buffer);
  270 +
  271 +}
  272 +
  273 +static void text_received(GtkClipboard *clipboard, const gchar *text, GtkWidget *widget)
  274 +{
  275 + paste_text(widget,text,"UTF-8");
  276 +}
  277 +
  278 +void v3270_paste_clipboard(v3270 *widget)
  279 +{
  280 + gtk_clipboard_request_text(gtk_widget_get_clipboard(GTK_WIDGET(widget),GDK_SELECTION_CLIPBOARD),(GtkClipboardTextReceivedFunc) text_received,(gpointer) widget);
  281 +}
  282 +
... ...
src/gtk/v3270/v3270.h
... ... @@ -200,7 +200,7 @@
200 200 int v3270_connect(GtkWidget *widget, const gchar *host);
201 201 void v3270_disconnect(GtkWidget *widget);
202 202  
203   -// Clipboard
  203 + // Clipboard
204 204 void v3270_copy_clipboard(v3270 *widget);
205 205 void v3270_paste_clipboard(v3270 *widget);
206 206  
... ...
src/include/lib3270.h
... ... @@ -227,7 +227,7 @@
227 227 #define LIB3270_EXPORT __attribute__((visibility("default"))) extern
228 228  
229 229 #else
230   -
  230 +
231 231 #error Unable to set visibility attribute
232 232  
233 233 #endif
... ... @@ -636,8 +636,8 @@
636 636 LIB3270_EXPORT char * lib3270_get_selected(H3270 *h);
637 637  
638 638  
639   - LIB3270_EXPORT int lib3270_set_model(H3270 *session, int model);
640   - LIB3270_EXPORT int lib3270_get_model(H3270 *session);
  639 + LIB3270_EXPORT int lib3270_set_model(H3270 *session, int model);
  640 + LIB3270_EXPORT int lib3270_get_model(H3270 *session);
641 641  
642 642 #ifdef __cplusplus
643 643 }
... ...
src/include/lib3270/popup.h
... ... @@ -44,6 +44,7 @@
44 44 } LIB3270_NOTIFY;
45 45  
46 46 LIB3270_EXPORT void lib3270_set_popup_handler(int (*popup_handler)(H3270 *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list));
  47 + LIB3270_EXPORT lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...);
47 48  
48 49 #endif // LIB3270_POPUP_INCLUDED
49 50  
... ...
src/lib3270/paste.c
... ... @@ -32,14 +32,17 @@
32 32  
33 33 #include "globals.h"
34 34  
35   -#if defined(X3270_DISPLAY) /*[*/
36   -#include <X11/Xatom.h>
  35 +/*
  36 +#if defined(X3270_DISPLAY)
  37 + #include <X11/Xatom.h>
37 38 #endif
  39 +*/
  40 +
38 41 #define XK_3270
39   -#if defined(X3270_APL) /*[*/
40   -#define XK_APL
41   -#endif /*]*/
42   -//#include <X11/keysym.h>
  42 +
  43 +#if defined(X3270_APL)
  44 + #define XK_APL
  45 +#endif
43 46  
44 47 #include <fcntl.h>
45 48 #include "3270ds.h"
... ... @@ -53,17 +56,18 @@
53 56 #include "ctlrc.h"
54 57 #include "ftc.h"
55 58 #include "hostc.h"
56   -// #include "idlec.h"
57   -// #include "keymapc.h"
58 59 #include "keypadc.h"
59 60 #include "kybdc.h"
60   -// #include "macrosc.h"
61 61 #include "popupsc.h"
62 62 #include "printc.h"
63 63 #include "screenc.h"
64   -// #if defined(X3270_DISPLAY) /*[*/
65   -// #include "selectc.h"
66   -// #endif /*]*/
  64 +
  65 +/*
  66 +#if defined(X3270_DISPLAY)
  67 + #include "selectc.h"
  68 +#endif
  69 +*/
  70 +
67 71 #include "statusc.h"
68 72 #include "tablesc.h"
69 73 #include "telnetc.h"
... ... @@ -76,6 +80,8 @@
76 80 #endif /*]*/
77 81 #include "api.h"
78 82  
  83 +#include <lib3270/popup.h>
  84 +
79 85 /*---[ Struct ]-------------------------------------------------------------------------------------------------*/
80 86  
81 87 typedef struct _paste_data
... ... @@ -157,6 +163,15 @@
157 163 return c;
158 164 }
159 165  
  166 +/**
  167 + * Set string at cursor position.
  168 + *
  169 + * @param h Session handle.
  170 + * @param str String to set
  171 + *
  172 + * @return Number of characters inserted; <0 in case of error.
  173 + *
  174 + */
160 175 LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str)
161 176 {
162 177 PASTE_DATA data;
... ... @@ -218,3 +233,62 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str)
218 233 screen_resume(h);
219 234 return data.qtd;
220 235 }
  236 +
  237 +LIB3270_EXPORT int lib3270_paste(H3270 *h, const char *str)
  238 +{
  239 + int sz;
  240 + CHECK_SESSION_HANDLE(h);
  241 +
  242 + if(!lib3270_connected(h))
  243 + {
  244 + lib3270_ring_bell(h);
  245 + return 0;
  246 + }
  247 +
  248 + if(h->paste_buffer)
  249 + {
  250 + free(h->paste_buffer);
  251 + h->paste_buffer = NULL;
  252 + }
  253 +
  254 + sz = lib3270_set_string(h,str);
  255 + if(sz < 0)
  256 + {
  257 + // Can´t paste
  258 + lib3270_popup_dialog(h,LIB3270_NOTIFY_WARNING,
  259 + _( "Action failed" ),
  260 + _( "Unable to paste text" ),
  261 + "%s", sz == -EINVAL ? _( "Keyboard is locked" ) : _( "Unexpected error" ) );
  262 + return 0;
  263 + }
  264 +
  265 + if(strlen(str) > sz)
  266 + {
  267 + h->paste_buffer = strdup(str+sz);
  268 + return 1;
  269 + }
  270 +
  271 + return 0;
  272 +}
  273 +
  274 +LIB3270_EXPORT int lib3270_pastenext(H3270 *h)
  275 +{
  276 + char * ptr;
  277 + int rc;
  278 +
  279 + CHECK_SESSION_HANDLE(h);
  280 +
  281 + if(!(lib3270_connected(h) && h->paste_buffer))
  282 + {
  283 + lib3270_ring_bell(h);
  284 + return 0;
  285 + }
  286 +
  287 + ptr = h->paste_buffer;
  288 + h->paste_buffer = NULL;
  289 +
  290 + rc = lib3270_paste(h,ptr);
  291 +
  292 + free(ptr);
  293 + return rc;
  294 +}
... ...
src/lib3270/screen.c
... ... @@ -787,3 +787,13 @@ LIB3270_EXPORT void lib3270_set_popup_handler(int (*handler)(H3270 *, LIB3270_NO
787 787 popup_handler = handler ? handler : logpopup;
788 788 }
789 789  
  790 +LIB3270_EXPORT lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...)
  791 +{
  792 + va_list args;
  793 +
  794 + CHECK_SESSION_HANDLE(session);
  795 +
  796 + va_start(args, fmt);
  797 + popup_handler(session,id,title ? title : _( "3270 Error" ), message,fmt,args);
  798 + va_end(args);
  799 +}
... ...
src/lib3270/selection.c
... ... @@ -345,29 +345,3 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession)
345 345 return realloc(ret,sz+1);
346 346 }
347 347  
348   -LIB3270_EXPORT int lib3270_paste(H3270 *h, const char *str)
349   -{
350   - CHECK_SESSION_HANDLE(h);
351   -
352   - if(!lib3270_connected(h))
353   - {
354   - lib3270_ring_bell(h);
355   - return 0;
356   - }
357   -
358   - return 0;
359   -}
360   -
361   -LIB3270_EXPORT int lib3270_pastenext(H3270 *h)
362   -{
363   - CHECK_SESSION_HANDLE(h);
364   -
365   - if(!(lib3270_connected(h) && h->paste_buffer))
366   - {
367   - lib3270_ring_bell(h);
368   - return 0;
369   - }
370   -
371   -
372   - return 0;
373   -}
... ...