Commit e99275ec2a6e021d5312fd89752e1e53a759695d
1 parent
df342db0
Exists in
master
and in
1 other branch
Refactoring v3270 action engine to make it more standard.
Showing
8 changed files
with
19 additions
and
31 deletions
Show diff stats
src/include/v3270/actions.h
| @@ -52,7 +52,7 @@ | @@ -52,7 +52,7 @@ | ||
| 52 | guint key; | 52 | guint key; |
| 53 | GdkModifierType mods; | 53 | GdkModifierType mods; |
| 54 | 54 | ||
| 55 | - int (*activate)(GtkWidget *widget, const struct _v3270_action *action); | 55 | + int (*activate)(const struct _v3270_action *action, GtkWidget *widget); |
| 56 | 56 | ||
| 57 | } V3270_ACTION; | 57 | } V3270_ACTION; |
| 58 | 58 |
src/terminal/actions/clipboard.c
| @@ -34,7 +34,7 @@ | @@ -34,7 +34,7 @@ | ||
| 34 | 34 | ||
| 35 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 35 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 36 | 36 | ||
| 37 | - int fire_copy_accelerator(GtkWidget *widget, const V3270_ACTION * action) { | 37 | + int fire_copy_accelerator(const V3270_ACTION * action, GtkWidget *widget) { |
| 38 | 38 | ||
| 39 | debug("%s",__FUNCTION__); | 39 | debug("%s",__FUNCTION__); |
| 40 | 40 | ||
| @@ -47,7 +47,7 @@ | @@ -47,7 +47,7 @@ | ||
| 47 | return EINVAL; | 47 | return EINVAL; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | - int fire_paste_accelerator(GtkWidget *widget, const V3270_ACTION * action) { | 50 | + int fire_paste_accelerator(const V3270_ACTION * action, GtkWidget *widget) { |
| 51 | 51 | ||
| 52 | 52 | ||
| 53 | switch((int) action->flags) | 53 | switch((int) action->flags) |
src/terminal/actions/private.h
| @@ -32,8 +32,8 @@ | @@ -32,8 +32,8 @@ | ||
| 32 | #include <v3270/actions.h> | 32 | #include <v3270/actions.h> |
| 33 | #include <internals.h> | 33 | #include <internals.h> |
| 34 | 34 | ||
| 35 | - G_GNUC_INTERNAL int fire_copy_accelerator(GtkWidget *widget, const struct _v3270_action * action); | ||
| 36 | - G_GNUC_INTERNAL int fire_paste_accelerator(GtkWidget *widget, const struct _v3270_action * action); | ||
| 37 | - G_GNUC_INTERNAL int fire_zoom_action(GtkWidget *widget, const struct _v3270_action * action); | ||
| 38 | - G_GNUC_INTERNAL int fire_keypad_action(GtkWidget *widget, const struct _v3270_action * action); | 35 | + G_GNUC_INTERNAL int fire_copy_accelerator(const V3270_ACTION *action, GtkWidget *widget); |
| 36 | + G_GNUC_INTERNAL int fire_paste_accelerator(const V3270_ACTION *action, GtkWidget *widget); | ||
| 37 | + G_GNUC_INTERNAL int fire_zoom_action(const V3270_ACTION *action, GtkWidget *widget); | ||
| 38 | + G_GNUC_INTERNAL int fire_keypad_action(const V3270_ACTION *action, GtkWidget *widget); | ||
| 39 | 39 |
src/terminal/actions/zoom.c
| @@ -34,11 +34,11 @@ | @@ -34,11 +34,11 @@ | ||
| 34 | 34 | ||
| 35 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 35 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 36 | 36 | ||
| 37 | - int fire_zoom_action(GtkWidget *widget, const V3270_ACTION * action) { | 37 | + int fire_zoom_action(const V3270_ACTION *action, GtkWidget *widget) { |
| 38 | 38 | ||
| 39 | debug("%s",__FUNCTION__); | 39 | debug("%s",__FUNCTION__); |
| 40 | 40 | ||
| 41 | - switch(action->flags) | 41 | + switch( ((int) action->flags) ) |
| 42 | { | 42 | { |
| 43 | case 0: // Zoom in | 43 | case 0: // Zoom in |
| 44 | v3270_zoom_in(widget); | 44 | v3270_zoom_in(widget); |
src/terminal/keyboard/accelerator.c
| @@ -71,7 +71,7 @@ | @@ -71,7 +71,7 @@ | ||
| 71 | 71 | ||
| 72 | void v3270_accelerator_activate(const V3270Accelerator * acel, GtkWidget *terminal) | 72 | void v3270_accelerator_activate(const V3270Accelerator * acel, GtkWidget *terminal) |
| 73 | { | 73 | { |
| 74 | - int rc = ((int (*)(GtkWidget *, const void *)) acel->activate)(terminal,acel->arg); | 74 | + int rc = ((int (*)(gconstpointer, GtkWidget *)) acel->activate)(acel->arg,terminal); |
| 75 | 75 | ||
| 76 | if(rc) | 76 | if(rc) |
| 77 | gdk_display_beep(gdk_display_get_default()); | 77 | gdk_display_beep(gdk_display_get_default()); |
src/terminal/keyboard/init.c
| @@ -46,7 +46,7 @@ | @@ -46,7 +46,7 @@ | ||
| 46 | 46 | ||
| 47 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 47 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 48 | 48 | ||
| 49 | - static int fire_lib3270_action(GtkWidget *widget, const LIB3270_ACTION * action) | 49 | + static int fire_lib3270_action(const LIB3270_ACTION * action, GtkWidget *widget) |
| 50 | { | 50 | { |
| 51 | int rc = EPERM; | 51 | int rc = EPERM; |
| 52 | 52 | ||
| @@ -62,13 +62,13 @@ | @@ -62,13 +62,13 @@ | ||
| 62 | 62 | ||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | - static int fire_lib3270_toggle(GtkWidget *widget, const LIB3270_TOGGLE * action) | 65 | + static int fire_lib3270_toggle(const LIB3270_TOGGLE * action, GtkWidget *widget) |
| 66 | { | 66 | { |
| 67 | debug("%s(%s)",__FUNCTION__,action->name); | 67 | debug("%s(%s)",__FUNCTION__,action->name); |
| 68 | return lib3270_toggle(v3270_get_session(widget),action->id); | 68 | return lib3270_toggle(v3270_get_session(widget),action->id); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | - int fire_keypad_action(GtkWidget *widget, const struct _v3270_action * action) | 71 | + int fire_keypad_action(const struct _v3270_action * action, GtkWidget *widget) |
| 72 | { | 72 | { |
| 73 | int rc = 0; | 73 | int rc = 0; |
| 74 | debug("%s",__FUNCTION__); | 74 | debug("%s",__FUNCTION__); |
src/testprogram/testprogram.c
| @@ -120,14 +120,6 @@ | @@ -120,14 +120,6 @@ | ||
| 120 | 120 | ||
| 121 | #endif // _WIN32 | 121 | #endif // _WIN32 |
| 122 | 122 | ||
| 123 | - static void accel_copy(GtkWidget *widget, GtkWidget *window) { | ||
| 124 | - debug("%s",__FUNCTION__); | ||
| 125 | - } | ||
| 126 | - | ||
| 127 | - static void accel_paste(GtkWidget *widget, GtkWidget *window) { | ||
| 128 | - debug("%s",__FUNCTION__); | ||
| 129 | - } | ||
| 130 | - | ||
| 131 | static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | 123 | static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { |
| 132 | 124 | ||
| 133 | GtkWidget * window = gtk_application_window_new(app); | 125 | GtkWidget * window = gtk_application_window_new(app); |
| @@ -173,10 +165,6 @@ | @@ -173,10 +165,6 @@ | ||
| 173 | 165 | ||
| 174 | } | 166 | } |
| 175 | 167 | ||
| 176 | - // Set accelerators | ||
| 177 | - // v3270_accelerator_map_add_entry(terminal, "copy", 'c', GDK_CONTROL_MASK, G_CALLBACK(accel_copy), window); | ||
| 178 | - // v3270_accelerator_map_add_entry(terminal, "paste", 'v', GDK_CONTROL_MASK, G_CALLBACK(accel_paste), window); | ||
| 179 | - | ||
| 180 | // Create trace window | 168 | // Create trace window |
| 181 | v3270_set_trace(terminal,TRUE); | 169 | v3270_set_trace(terminal,TRUE); |
| 182 | 170 |
v3270.cbp
| @@ -222,10 +222,16 @@ | @@ -222,10 +222,16 @@ | ||
| 222 | <Unit filename="src/terminal/actions.c"> | 222 | <Unit filename="src/terminal/actions.c"> |
| 223 | <Option compilerVar="CC" /> | 223 | <Option compilerVar="CC" /> |
| 224 | </Unit> | 224 | </Unit> |
| 225 | + <Unit filename="src/terminal/actions/clipboard.c"> | ||
| 226 | + <Option compilerVar="CC" /> | ||
| 227 | + </Unit> | ||
| 225 | <Unit filename="src/terminal/actions/private.h" /> | 228 | <Unit filename="src/terminal/actions/private.h" /> |
| 226 | <Unit filename="src/terminal/actions/table.c"> | 229 | <Unit filename="src/terminal/actions/table.c"> |
| 227 | <Option compilerVar="CC" /> | 230 | <Option compilerVar="CC" /> |
| 228 | </Unit> | 231 | </Unit> |
| 232 | + <Unit filename="src/terminal/actions/zoom.c"> | ||
| 233 | + <Option compilerVar="CC" /> | ||
| 234 | + </Unit> | ||
| 229 | <Unit filename="src/terminal/blink.c"> | 235 | <Unit filename="src/terminal/blink.c"> |
| 230 | <Option compilerVar="CC" /> | 236 | <Option compilerVar="CC" /> |
| 231 | </Unit> | 237 | </Unit> |
| @@ -275,9 +281,6 @@ | @@ -275,9 +281,6 @@ | ||
| 275 | <Unit filename="src/terminal/keyboard/accelerator.c"> | 281 | <Unit filename="src/terminal/keyboard/accelerator.c"> |
| 276 | <Option compilerVar="CC" /> | 282 | <Option compilerVar="CC" /> |
| 277 | </Unit> | 283 | </Unit> |
| 278 | - <Unit filename="src/terminal/keyboard/clipboard.c"> | ||
| 279 | - <Option compilerVar="CC" /> | ||
| 280 | - </Unit> | ||
| 281 | <Unit filename="src/terminal/keyboard/init.c"> | 284 | <Unit filename="src/terminal/keyboard/init.c"> |
| 282 | <Option compilerVar="CC" /> | 285 | <Option compilerVar="CC" /> |
| 283 | </Unit> | 286 | </Unit> |
| @@ -285,9 +288,6 @@ | @@ -285,9 +288,6 @@ | ||
| 285 | <Option compilerVar="CC" /> | 288 | <Option compilerVar="CC" /> |
| 286 | </Unit> | 289 | </Unit> |
| 287 | <Unit filename="src/terminal/keyboard/private.h" /> | 290 | <Unit filename="src/terminal/keyboard/private.h" /> |
| 288 | - <Unit filename="src/terminal/keyboard/zoom.c"> | ||
| 289 | - <Option compilerVar="CC" /> | ||
| 290 | - </Unit> | ||
| 291 | <Unit filename="src/terminal/keyfile.c"> | 291 | <Unit filename="src/terminal/keyfile.c"> |
| 292 | <Option compilerVar="CC" /> | 292 | <Option compilerVar="CC" /> |
| 293 | </Unit> | 293 | </Unit> |