table.c
12.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
* Copyright (C) 2008 Banco do Brasil S.A.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "private.h"
#include <lib3270/actions.h>
#include <v3270/actions.h>
#include <v3270/selection.h>
#include <v3270/settings.h>
#include <terminal.h>
static int fire_copy_as_html(GtkWidget *widget, const struct _v3270_action * action);
static int fire_copy_as_pixbuff(GtkWidget *widget, const struct _v3270_action * action);
// Dialogs
static int fire_accelerators_dialog(GtkWidget *widget, const struct _v3270_action * action);
static int fire_host_dialog(GtkWidget *widget, const struct _v3270_action * action);
static int fire_color_dialog(GtkWidget *widget, const struct _v3270_action * action);
static int fire_clipboard_dialog(GtkWidget *widget, const struct _v3270_action * action);
static int fire_font_dialog(GtkWidget *widget, const struct _v3270_action * action);
/*--[ Implement ]------------------------------------------------------------------------------------*/
LIB3270_EXPORT const V3270_ACTION * v3270_get_actions() {
static const V3270_ACTION actions[] = {
//
// Standard Clipboard actions
//
{
.flags = (V3270_ACTION_FLAGS) V3270_COPY_SMART,
.name = "copy",
.keys = "<Primary>c",
.group = LIB3270_ACTION_GROUP_SELECTION,
.icon = "edit-copy",
.label = N_( "Copy" ),
.summary = N_("Copy selection to clipboard"),
.description = N_("Replace current clipboard contents with the selected area"),
.activate = fire_copy_accelerator
},
{
.name = "copy-append",
.keys = "<Primary><Shift>c",
.flags = (V3270_ACTION_FLAGS) V3270_COPY_APPEND,
.group = LIB3270_ACTION_GROUP_SELECTION,
.label = N_( "Add to copy" ),
.summary = N_("Append selection to clipboard"),
.description = N_("Append selected area to current clipboard contents"),
.activate = fire_copy_accelerator
},
{
.name = "copy-html",
.group = LIB3270_ACTION_GROUP_SELECTION,
.label = N_( "Copy as HTML" ),
.summary = N_("Copy selection in HTML format"),
.description = N_("Replace current clipboard contents with the selected area in HTML format"),
.activate = fire_copy_as_html
},
{
.name = "copy-pixbuff",
.group = LIB3270_ACTION_GROUP_SELECTION,
.label = N_( "Copy as image" ),
.summary = N_("Copy selection in image format"),
.description = N_("Replace current clipboard contents with the selected area in image format"),
.activate = fire_copy_as_pixbuff
},
{
.name = "copy-text",
.flags = (V3270_ACTION_FLAGS) V3270_COPY_TEXT,
.group = LIB3270_ACTION_GROUP_SELECTION,
.icon = "edit-copy",
.label = N_( "Copy" ),
.summary = N_( "Copy as plain text" ),
.activate = fire_copy_accelerator
},
{
.name = "copy-table",
.keys = "<Shift><Alt>c",
.flags = (V3270_ACTION_FLAGS) V3270_COPY_TABLE,
.group = LIB3270_ACTION_GROUP_SELECTION,
.icon = "edit-copy",
.label = N_( "Copy as table" ),
.summary = N_( "Copy as table" ),
.activate = fire_copy_accelerator
},
{
.name = "cut",
.keys = "<Primary>x",
.flags = V3270_ACTION_FLAG_CUT|V3270_COPY_SMART,
.group = LIB3270_ACTION_GROUP_SELECTION,
.icon = "edit-cut",
.label = N_( "Cut" ),
.activate = fire_copy_accelerator
},
{
.name = "cut-append",
.keys = "<Alt>x",
.flags = V3270_ACTION_FLAG_CUT|V3270_COPY_APPEND,
.group = LIB3270_ACTION_GROUP_SELECTION,
.label = N_( "Cut" ),
.summary = N_( "Cut and append to copy" ),
.activate = fire_copy_accelerator
},
{
.name = "cut-text",
.keys = "<Primary><Shift>x",
.flags = V3270_ACTION_FLAG_CUT|V3270_COPY_TEXT,
.group = LIB3270_ACTION_GROUP_SELECTION,
.icon = "edit-cut",
.label = N_( "Cut" ),
.summary = N_( "Cut as plain text" ),
.activate = fire_copy_accelerator
},
{
.name = "cut-table",
.keys = "<Shift><Alt>x",
.flags = V3270_ACTION_FLAG_CUT|V3270_COPY_TABLE,
.group = LIB3270_ACTION_GROUP_SELECTION,
.icon = "edit-cut",
.label = N_( "Cut as table" ),
.summary = N_( "Cut as table" ),
.activate = fire_copy_accelerator
},
{
.name = "paste",
.keys = "<Primary>v",
.flags = 0,
.group = LIB3270_ACTION_GROUP_ONLINE,
.icon = "edit-paste",
.label = N_("Paste"),
.summary = N_("Paste clipboard contents"),
.description = N_("Input current clipboard contents to screen"),
.activate = fire_paste_accelerator
},
{
.name = "paste-text",
.keys = "<Primary><Shift>v",
.flags = 1,
.group = LIB3270_ACTION_GROUP_ONLINE,
.icon = "edit-paste",
.label = N_("Paste"),
.summary = N_("Paste as plain text"),
.activate = fire_paste_accelerator
},
{
.name = "paste-file",
.keys = "<Alt>v",
.flags = 2,
.group = LIB3270_ACTION_GROUP_ONLINE,
.label = N_("Paste file"),
.summary = N_("Paste from text file"),
.activate = fire_paste_accelerator
},
{
.name = "paste-screen",
.keys = "<Primary><Shift><Alt>v",
.flags = 3,
.group = LIB3270_ACTION_GROUP_ONLINE,
.label = N_("Paste formatted screen"),
.summary = N_("Paste similar screen from clipboard"),
.description = N_("Search clipboard for a similar screen, if found paste unprotected fields and restore cursor position"),
.activate = fire_paste_accelerator
},
{
.name = "zoom-in",
.keys = "<Primary>KP_Add",
.flags = 0,
.group = LIB3270_ACTION_GROUP_ONLINE,
.icon = "zoom-in",
.label = N_("Zoom in"),
.summary = N_("Increase the font size"),
.activate = fire_zoom_action
},
{
.name = "zoom-out",
.keys = "<Primary>KP_Subtract",
.flags = 1,
.group = LIB3270_ACTION_GROUP_ONLINE,
.label = N_("Zoom out"),
.summary = N_("decrease the font size"),
.icon = "zoom-out",
.activate = fire_zoom_action
},
{
.name = "zoom-fit-best",
.keys = "<Primary>0",
.flags = 2,
.group = LIB3270_ACTION_GROUP_ONLINE,
.label = N_("Fit best"),
.summary = N_("Set the font to the best size for window"),
.icon = "zoom-fit-best",
.activate = fire_zoom_action
},
//
// Save actions
//
{
.flags = -1,
.group = LIB3270_ACTION_GROUP_ONLINE,
.name = "save",
.icon = "document-save-as",
.label = N_("Save"),
.summary = N_("Save screen or selection"),
.activate = fire_save_action
},
{
.flags = (V3270_ACTION_FLAGS) LIB3270_CONTENT_ALL,
.group = LIB3270_ACTION_GROUP_ONLINE,
.name = "save-all",
.label = N_("Save all"),
.icon = "document-save-as",
.summary = N_("Save screen"),
.activate = fire_save_action
},
{
.flags = (V3270_ACTION_FLAGS) LIB3270_CONTENT_SELECTED,
.group = LIB3270_ACTION_GROUP_SELECTION,
.name = "save-selected",
.label = N_("Save selected"),
.icon = "document-save-as",
.summary = N_("Save selected area"),
.activate = fire_save_action
},
{
.flags = (V3270_ACTION_FLAGS) LIB3270_CONTENT_COPY,
.group = LIB3270_ACTION_GROUP_COPY,
.name = "save-copy",
.label = N_("Save copy"),
.icon = "document-save-as",
.summary = N_("Save Copy"),
.activate = fire_save_action
},
//
// Print actions
//
{
.flags = -1,
.group = LIB3270_ACTION_GROUP_ONLINE,
.name = "print",
.icon = "document-print",
.label = N_("Print"),
.summary = N_("Print screen or selection"),
.activate = fire_print_action
},
{
.flags = (V3270_ACTION_FLAGS) LIB3270_CONTENT_ALL,
.group = LIB3270_ACTION_GROUP_ONLINE,
.name = "print-all",
.icon = "document-print",
.label = N_("Print screen"),
.summary = N_("Print the entire screen"),
.activate = fire_print_action
},
{
.flags = (V3270_ACTION_FLAGS) LIB3270_CONTENT_SELECTED,
.group = LIB3270_ACTION_GROUP_SELECTION,
.name = "print-selected",
.icon = "document-print",
.label = N_("Print selected"),
.summary = N_("Print selected area"),
.activate = fire_print_action
},
{
.flags = (V3270_ACTION_FLAGS) LIB3270_CONTENT_COPY,
.group = LIB3270_ACTION_GROUP_COPY,
.name = "print-copy",
.icon = "document-print",
.label = N_("Print Copy"),
.activate = fire_print_action
},
//
// Dialog actions
//
{
.group = LIB3270_ACTION_GROUP_NONE,
.name = "dialog-keyboard",
.icon = "preferences-desktop-keyboard-shortcuts",
.label = N_("Keyboard accelerators"),
.summary = N_("Edit keyboard accelerators"),
.activate = fire_accelerators_dialog
},
{
.group = LIB3270_ACTION_GROUP_OFFLINE,
.name = "dialog-host",
.icon = "network-server",
.label = N_("Host settings"),
.summary = N_("Edit host settings"),
.activate = fire_host_dialog
},
{
.group = LIB3270_ACTION_GROUP_NONE,
.name = "dialog-colors",
.icon = "gtk-select-color",
.label = N_("Terminal colors"),
.summary = N_("Edit terminal colors"),
.activate = fire_color_dialog
},
{
.group = LIB3270_ACTION_GROUP_NONE,
.name = "dialog-clipboard",
.label = N_("Selection settings"),
.summary = N_("Edit clipboard settings"),
.activate = fire_clipboard_dialog
},
{
.group = LIB3270_ACTION_GROUP_NONE,
.icon = "preferences-desktop-font",
.name = "dialog-font",
.label = N_("Font settings"),
.summary = N_("Select terminal font"),
.activate = fire_font_dialog
},
//
// Terminator
//
{
.name = NULL
}
};
return actions;
}
static int fire_copy_as_html(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) {
v3270_copy_as_html(widget);
return 0;
}
static int fire_copy_as_pixbuff(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) {
v3270_copy_as_pixbuff(widget);
return 0;
}
static int fire_accelerators_dialog(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) {
GtkWidget * dialog =
v3270_settings_popup_dialog(
v3270_accelerator_settings_new(),
widget,
TRUE
);
gtk_window_set_default_size(GTK_WINDOW(dialog),950,400);
gtk_widget_show_all(dialog);
return 0;
}
static int fire_host_dialog(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) {
gtk_widget_show_all(
v3270_settings_popup_dialog(
v3270_host_settings_new(),
widget,
TRUE
)
);
return 0;
/*
GtkWidget * dialog = v3270_settings_dialog_new();
GtkWidget * settings = v3270_host_settings_new();
v3270_settings_dialog_set_has_subtitle(dialog,FALSE);
gtk_window_set_title(GTK_WINDOW(dialog), v3270_settings_get_title(settings));
gtk_container_add(GTK_CONTAINER(dialog), settings);
gtk_dialog_set_toplevel(dialog,widget);
gtk_window_set_modal(GTK_WINDOW(dialog),TRUE);
v3270_settings_dialog_set_terminal_widget(dialog, widget);
gtk_window_set_default_size(GTK_WINDOW(dialog), 700, 150);
gtk_widget_show_all(dialog);
gboolean again = TRUE;
while(again)
{
gtk_widget_set_sensitive(dialog,TRUE);
gtk_widget_set_visible(dialog,TRUE);
switch(gtk_dialog_run(GTK_DIALOG(dialog)))
{
case GTK_RESPONSE_APPLY:
debug("V3270HostSelectWidget::%s=%s",__FUNCTION__,"GTK_RESPONSE_APPLY");
v3270_settings_dialog_apply(dialog);
again = lib3270_reconnect(v3270_get_session(widget),0);
break;
case GTK_RESPONSE_CANCEL:
again = FALSE;
debug("V3270HostSelectWidget::%s=%s",__FUNCTION__,"GTK_RESPONSE_CANCEL");
v3270_settings_dialog_revert(dialog);
break;
}
}
gtk_widget_destroy(dialog);
*/
}
static int fire_color_dialog(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) {
gtk_widget_show_all(
v3270_settings_popup_dialog(
v3270_color_settings_new(),
widget,
FALSE
)
);
return 0;
}
static int fire_clipboard_dialog(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) {
gtk_widget_show_all(
v3270_settings_popup_dialog(
v3270_clipboard_settings_new(),
widget,
FALSE
)
);
return 0;
}
static int fire_font_dialog(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) {
GtkWidget * dialog =
v3270_settings_popup_dialog(
v3270_font_settings_new(),
widget,
TRUE
);
gtk_window_set_default_size(GTK_WINDOW(dialog),950,400);
gtk_widget_show_all(dialog);
return 0;
}