Commit 73a17cbdbdd12295ea741ebbafcb547cc934a41b
1 parent
ae0903ea
Exists in
master
and in
5 other branches
Implementando popup menus, atualizando mecanismo de beep, ajustes diversos para a versao 5
Showing
19 changed files
with
114 additions
and
49 deletions
Show diff stats
src/gtk/common/config.c
... | ... | @@ -353,13 +353,13 @@ void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val) |
353 | 353 | |
354 | 354 | HKEY hKey; |
355 | 355 | DWORD disp; |
356 | - gchar * path = g_strdup_printf("%s\\%s",registry_path,group); | |
356 | + gchar * path = g_strdup_printf("%s\\%s\\%s",registry_path,group,key); | |
357 | 357 | |
358 | -// trace("Creating key %s",path); | |
358 | + trace("Creating key %s",path); | |
359 | 359 | if(RegCreateKeyEx(HKEY_CURRENT_USER,path,0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS) |
360 | 360 | { |
361 | 361 | DWORD value = val ? 1 : 0; |
362 | - LONG rc = RegSetValueEx(hKey, key, 0, REG_DWORD,(const BYTE *) &value,sizeof(value)); | |
362 | + LONG rc = RegSetValueEx(hKey, NULL, 0, REG_DWORD,(const BYTE *) &value,sizeof(value)); | |
363 | 363 | |
364 | 364 | SetLastError(rc); |
365 | 365 | ... | ... |
src/gtk/mainwindow.c
... | ... | @@ -119,7 +119,7 @@ |
119 | 119 | GtkWidget *menu = NULL; |
120 | 120 | |
121 | 121 | if(!online) |
122 | - menu = popup[POPUP_OFFLINE] ? popup[POPUP_OFFLINE] : popup[POPUP_DEFAULT]; | |
122 | + menu = popup[POPUP_OFFLINE]; | |
123 | 123 | else if(selected && popup[POPUP_SELECTION]) |
124 | 124 | menu = popup[POPUP_SELECTION]; |
125 | 125 | else if(popup[POPUP_ONLINE]) |
... | ... | @@ -203,7 +203,7 @@ |
203 | 203 | |
204 | 204 | GtkWidget * create_main_window(void) |
205 | 205 | { |
206 | - static const SETUP_ITEM widget_setup[] = | |
206 | + static const UI_WIDGET_SETUP widget_setup[] = | |
207 | 207 | { |
208 | 208 | { "inputmethod", setup_input_method }, |
209 | 209 | { "screensizes", setup_screen_sizes }, | ... | ... |
src/gtk/pw3270-GTK.cbp
... | ... | @@ -31,11 +31,11 @@ |
31 | 31 | </Build> |
32 | 32 | <Compiler> |
33 | 33 | <Add option="-Wall" /> |
34 | - <Add option="`pkg-config lib3270 gtk+-2.0 --cflags`" /> | |
34 | + <Add option="`pkg-config lib3270 gtk+-2.0 lib3270 --cflags`" /> | |
35 | 35 | <Add directory="..\include" /> |
36 | 36 | </Compiler> |
37 | 37 | <Linker> |
38 | - <Add option="`pkg-config lib3270 gtk+-2.0 --libs`" /> | |
38 | + <Add option="`pkg-config lib3270 gtk+-2.0 lib3270 --libs`" /> | |
39 | 39 | </Linker> |
40 | 40 | <Unit filename="Makefile.in" /> |
41 | 41 | <Unit filename="actions.c"> | ... | ... |
src/gtk/uiparser/accelerator.c
src/gtk/uiparser/menuitem.c
... | ... | @@ -89,6 +89,26 @@ |
89 | 89 | |
90 | 90 | gtk_menu_shell_append((GtkMenuShell *) menu, widget); |
91 | 91 | |
92 | + // Setup menuitem | |
93 | + if(info->setup) | |
94 | + { | |
95 | + const gchar *name = ui_get_attribute("name",names,values); | |
96 | + | |
97 | + if(name) | |
98 | + { | |
99 | + int f; | |
100 | + for(f=0;info->setup[f].name;f++) | |
101 | + { | |
102 | + if(!g_strcasecmp(name,info->setup[f].name)) | |
103 | + { | |
104 | + info->setup[f].setup(widget,info->center_widget); | |
105 | + break; | |
106 | + } | |
107 | + } | |
108 | + } | |
109 | + } | |
110 | + | |
111 | + | |
92 | 112 | return G_OBJECT(widget); |
93 | 113 | } |
94 | 114 | ... | ... |
src/gtk/uiparser/parser.c
... | ... | @@ -206,7 +206,7 @@ void parser_build(struct parser *p, GtkWidget *widget) |
206 | 206 | |
207 | 207 | } |
208 | 208 | |
209 | -GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, GtkWidget *widget, const SETUP_ITEM *setup) | |
209 | +GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, GtkWidget *widget, const UI_WIDGET_SETUP *setup) | |
210 | 210 | { |
211 | 211 | struct parser p; |
212 | 212 | GDir * dir; |
... | ... | @@ -258,6 +258,7 @@ GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, con |
258 | 258 | p.popupname = popupname; |
259 | 259 | p.strings = g_string_chunk_new(0); |
260 | 260 | p.popup = g_new0(GtkWidget *,(g_strv_length((gchar **) p.popupname)+1)); |
261 | + p.setup = setup; | |
261 | 262 | |
262 | 263 | g_object_set_data_full(G_OBJECT(p.toplevel),"popup_menus",(gpointer) p.popup, g_free); |
263 | 264 | ... | ... |
src/gtk/uiparser/parser.h
... | ... | @@ -29,14 +29,32 @@ |
29 | 29 | * |
30 | 30 | */ |
31 | 31 | |
32 | - typedef struct _setup_item | |
33 | - { | |
34 | - const gchar * name; | |
35 | - void (*setup)(GtkWidget *widget, GtkWidget *obj); | |
36 | - } SETUP_ITEM; | |
32 | +#ifndef UI_PARSER_H_INCLUDED | |
37 | 33 | |
38 | - GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, GtkWidget *widget, const SETUP_ITEM *itn); | |
39 | - void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | |
40 | - void ui_connect_toggle(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | |
41 | - void ui_connect_pfkey(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | |
42 | - void ui_connect_pakey(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | |
34 | + #define UI_PARSER_H_INCLUDED 1 | |
35 | + | |
36 | + /** | |
37 | + * Callback list for specil widget. | |
38 | + * | |
39 | + * Struct used to define a list of calls to setup some specialized widgets. | |
40 | + * | |
41 | + */ | |
42 | + typedef struct _ui_widget_setup | |
43 | + { | |
44 | + const gchar * name; /**< Widget name */ | |
45 | + /** | |
46 | + * Widget setup call. | |
47 | + * | |
48 | + * @param widget Widget to setup. | |
49 | + * @param obj UI´s center widget. | |
50 | + */ | |
51 | + void (*setup)(GtkWidget *widget, GtkWidget *obj); | |
52 | + } UI_WIDGET_SETUP; | |
53 | + | |
54 | + GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, GtkWidget *widget, const UI_WIDGET_SETUP *itn); | |
55 | + void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | |
56 | + void ui_connect_toggle(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | |
57 | + void ui_connect_pfkey(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | |
58 | + void ui_connect_pakey(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | |
59 | + | |
60 | +#endif // UI_PARSER_H_INCLUDED | ... | ... |
src/gtk/uiparser/private.h
... | ... | @@ -29,8 +29,10 @@ |
29 | 29 | * |
30 | 30 | */ |
31 | 31 | |
32 | + #include <gtk/gtk.h> | |
32 | 33 | #include <lib3270/config.h> |
33 | 34 | #include "../common/common.h" |
35 | + #include "parser.h" | |
34 | 36 | |
35 | 37 | #define ERROR_DOMAIN g_quark_from_static_string("uiparser") |
36 | 38 | |
... | ... | @@ -52,16 +54,17 @@ |
52 | 54 | |
53 | 55 | struct parser |
54 | 56 | { |
55 | - int disabled; | |
56 | - GtkWidget * toplevel; | |
57 | - GObject * element; | |
58 | - GtkWidget * center_widget; | |
59 | - GtkWidget ** popup; /**< Popup widgets */ | |
60 | - GStringChunk * strings; | |
61 | - const gchar ** group; /**< Action group list */ | |
62 | - const gchar ** popupname; /**< Popup names */ | |
63 | - GHashTable * actions; /**< List of actions */ | |
64 | - GHashTable * element_list[UI_ELEMENT_COUNT]; | |
57 | + int disabled; | |
58 | + GtkWidget * toplevel; | |
59 | + GObject * element; | |
60 | + GtkWidget * center_widget; | |
61 | + GtkWidget ** popup; /**< Popup widgets */ | |
62 | + GStringChunk * strings; | |
63 | + const gchar ** group; /**< Action group list */ | |
64 | + const gchar ** popupname; /**< Popup names */ | |
65 | + GHashTable * actions; /**< List of actions */ | |
66 | + GHashTable * element_list[UI_ELEMENT_COUNT]; | |
67 | + const UI_WIDGET_SETUP * setup; | |
65 | 68 | }; |
66 | 69 | |
67 | 70 | const gchar * ui_get_attribute(const gchar *key, const gchar **name, const gchar **value); | ... | ... |
src/gtk/v3270/genmarshal
src/gtk/v3270/iocallback.c
... | ... | @@ -312,6 +312,11 @@ static int static_RunPendingEvents(int wait) |
312 | 312 | return rc; |
313 | 313 | } |
314 | 314 | |
315 | +static void beep(H3270 *session) | |
316 | +{ | |
317 | + gdk_beep(); | |
318 | +} | |
319 | + | |
315 | 320 | void v3270_register_io_handlers(v3270Class *cls) |
316 | 321 | { |
317 | 322 | static const struct lib3270_callbacks hdl = |
... | ... | @@ -338,7 +343,7 @@ void v3270_register_io_handlers(v3270Class *cls) |
338 | 343 | |
339 | 344 | static_Sleep, |
340 | 345 | static_RunPendingEvents, |
341 | - gdk_beep | |
346 | + beep | |
342 | 347 | |
343 | 348 | }; |
344 | 349 | ... | ... |
src/gtk/v3270/widget.c
... | ... | @@ -31,6 +31,8 @@ |
31 | 31 | #include <pw3270.h> |
32 | 32 | #include <lib3270.h> |
33 | 33 | #include <lib3270/session.h> |
34 | + #include <lib3270/actions.h> | |
35 | + #include <lib3270/log.h> | |
34 | 36 | #include "v3270.h" |
35 | 37 | #include "private.h" |
36 | 38 | #include "marshal.h" |
... | ... | @@ -284,11 +286,11 @@ static void v3270_class_init(v3270Class *klass) |
284 | 286 | v3270_widget_signal[SIGNAL_POPUP] = |
285 | 287 | g_signal_new( "popup", |
286 | 288 | G_OBJECT_CLASS_TYPE (gobject_class), |
287 | - G_SIGNAL_RUN_FIRST, | |
289 | + G_SIGNAL_RUN_LAST, | |
288 | 290 | 0, |
289 | 291 | NULL, NULL, |
290 | - pw3270_VOID__VOID_BOOL_BOOL_POINTER, | |
291 | - G_TYPE_NONE, 3, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_POINTER); | |
292 | + pw3270_BOOL__VOID_BOOL_BOOL_POINTER, | |
293 | + G_TYPE_BOOLEAN, 3, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_POINTER); | |
292 | 294 | } |
293 | 295 | |
294 | 296 | void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int height) |
... | ... | @@ -852,7 +854,7 @@ int v3270_connect(GtkWidget *widget, const gchar *host) |
852 | 854 | |
853 | 855 | trace("%s widget=%p host=%p",__FUNCTION__,widget,host); |
854 | 856 | |
855 | - g_return_if_fail(GTK_IS_V3270(widget)); | |
857 | + g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL); | |
856 | 858 | |
857 | 859 | terminal = GTK_V3270(widget); |
858 | 860 | ... | ... |
src/include/lib3270.h
... | ... | @@ -495,7 +495,7 @@ |
495 | 495 | |
496 | 496 | int (*Wait)(int seconds); |
497 | 497 | int (*RunPendingEvents)(int wait); |
498 | - void (*ring_bell)(void); | |
498 | + void (*ring_bell)(H3270 *); | |
499 | 499 | |
500 | 500 | }; |
501 | 501 | |
... | ... | @@ -596,6 +596,16 @@ |
596 | 596 | */ |
597 | 597 | LIB3270_EXPORT void * lib3270_get_widget(H3270 *h); |
598 | 598 | |
599 | + /** | |
600 | + * "beep" to notify user. | |
601 | + * | |
602 | + * If available play a sound signal do alert user. | |
603 | + * | |
604 | + * @param h Session handle | |
605 | + * | |
606 | + */ | |
607 | + LIB3270_EXPORT void lib3270_ring_bell(H3270 *session); | |
608 | + | |
599 | 609 | LIB3270_EXPORT int lib3270_set_model(H3270 *session, int model); |
600 | 610 | LIB3270_EXPORT int lib3270_get_model(H3270 *session); |
601 | 611 | ... | ... |
src/lib3270/XtGlue.c
... | ... | @@ -94,7 +94,7 @@ static void DefaultRemoveInput(unsigned long id); |
94 | 94 | |
95 | 95 | static int DefaultProcessEvents(int block); |
96 | 96 | |
97 | -static void dunno(void) | |
97 | +static void dunno(H3270 *session) | |
98 | 98 | { |
99 | 99 | |
100 | 100 | } |
... | ... | @@ -999,9 +999,10 @@ LIB3270_EXPORT int lib3270_wait(seconds) |
999 | 999 | return 0; |
1000 | 1000 | } |
1001 | 1001 | |
1002 | -LIB3270_EXPORT void lib3270_ring_bell(void) | |
1002 | +LIB3270_EXPORT void lib3270_ring_bell(H3270 *session) | |
1003 | 1003 | { |
1004 | - callbacks->ring_bell(); | |
1004 | + CHECK_SESSION_HANDLE(session); | |
1005 | + callbacks->ring_bell(session); | |
1005 | 1006 | } |
1006 | 1007 | |
1007 | 1008 | ... | ... |
src/lib3270/ansi.c
src/lib3270/api.h
src/lib3270/ctlr.c
... | ... | @@ -1871,7 +1871,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) |
1871 | 1871 | status_syswait(); |
1872 | 1872 | } |
1873 | 1873 | if (wcc_sound_alarm) |
1874 | - lib3270_ring_bell(); | |
1874 | + lib3270_ring_bell(NULL); | |
1875 | 1875 | |
1876 | 1876 | /* Set up the DBCS state. */ |
1877 | 1877 | if (ctlr_dbcs_postprocess() < 0 && rv == PDS_OKAY_NO_OUTPUT) | ... | ... |
src/lib3270/kybd.c
... | ... | @@ -182,7 +182,7 @@ static int enq_chk(void) |
182 | 182 | /* If operator error, complain and drop it. */ |
183 | 183 | if (kybdlock & KL_OERR_MASK) |
184 | 184 | { |
185 | - lib3270_ring_bell(); | |
185 | + lib3270_ring_bell(NULL); | |
186 | 186 | trace_event(" dropped (operator error)\n"); |
187 | 187 | return -1; |
188 | 188 | } |
... | ... | @@ -190,7 +190,7 @@ static int enq_chk(void) |
190 | 190 | /* If scroll lock, complain and drop it. */ |
191 | 191 | if (kybdlock & KL_SCROLLED) |
192 | 192 | { |
193 | - lib3270_ring_bell(); | |
193 | + lib3270_ring_bell(NULL); | |
194 | 194 | trace_event(" dropped (scrolled)\n"); |
195 | 195 | return -1; |
196 | 196 | } |
... | ... | @@ -471,7 +471,7 @@ operator_error(int error_type) |
471 | 471 | kybdlock_set((unsigned int)error_type, "operator_error"); |
472 | 472 | (void) flush_ta(); |
473 | 473 | } else { |
474 | - lib3270_ring_bell(); | |
474 | + lib3270_ring_bell(NULL); | |
475 | 475 | } |
476 | 476 | } |
477 | 477 | ... | ... |
src/lib3270/lib3270.cbp
... | ... | @@ -57,8 +57,14 @@ |
57 | 57 | <Add directory="..\include\lib3270" /> |
58 | 58 | </Compiler> |
59 | 59 | <Unit filename="..\include\lib3270.h" /> |
60 | + <Unit filename="..\include\lib3270\action_table.h" /> | |
61 | + <Unit filename="..\include\lib3270\actions.h" /> | |
60 | 62 | <Unit filename="..\include\lib3270\config.h.in" /> |
63 | + <Unit filename="..\include\lib3270\log.h" /> | |
64 | + <Unit filename="..\include\lib3270\macros.h" /> | |
65 | + <Unit filename="..\include\lib3270\popup.h" /> | |
61 | 66 | <Unit filename="..\include\lib3270\selection.h" /> |
67 | + <Unit filename="..\include\lib3270\session.h" /> | |
62 | 68 | <Unit filename="3270ds.h" /> |
63 | 69 | <Unit filename="Makefile.in" /> |
64 | 70 | <Unit filename="X11keysym.h" /> | ... | ... |
src/lib3270/selection.c
... | ... | @@ -205,7 +205,7 @@ LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr) |
205 | 205 | |
206 | 206 | if(!lib3270_connected(session) || isspace(ea_buf[baddr].chr)) |
207 | 207 | { |
208 | - lib3270_ring_bell(); | |
208 | + lib3270_ring_bell(session); | |
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
... | ... | @@ -227,15 +227,15 @@ LIB3270_EXPORT int lib3270_select_field(H3270 *session, int baddr) |
227 | 227 | |
228 | 228 | if(!lib3270_connected(session)) |
229 | 229 | { |
230 | - lib3270_ring_bell(); | |
231 | - return; | |
230 | + lib3270_ring_bell(session); | |
231 | + return -1; | |
232 | 232 | } |
233 | 233 | |
234 | 234 | start = lib3270_field_addr(session,baddr); |
235 | 235 | |
236 | 236 | if(start < 0) |
237 | 237 | { |
238 | - lib3270_ring_bell(); | |
238 | + lib3270_ring_bell(session); | |
239 | 239 | return -1; |
240 | 240 | } |
241 | 241 | ... | ... |