diff --git a/src/include/internals.h b/src/include/internals.h index dc8bbd7..5e92019 100644 --- a/src/include/internals.h +++ b/src/include/internals.h @@ -144,6 +144,22 @@ /*--[ Internal Widgets & Tools ]---------------------------------------------------------------------*/ + enum + { + V3270_ACCELERATOR_TYPE_INTERNAL, ///< @brief Accelerator is internal. + V3270_ACCELERATOR_TYPE_LIB3270_ACTION, ///< @brief Accelerator is a lib3270 action. + V3270_ACCELERATOR_TYPE_GTK_ACTION, ///< @brief Accelerator is a GTK Action (Deprececated). + }; + + struct _V3270Accelerator + { + unsigned short type; + guint key; + GdkModifierType mods; + gconstpointer arg; + GCallback activate; + }; + typedef enum v3270_toggleable_dialog { V3270_TOGGLEABLE_DIALOG_PASTE_FAILED, diff --git a/src/include/terminal.h b/src/include/terminal.h index 001781a..e21ff4f 100644 --- a/src/include/terminal.h +++ b/src/include/terminal.h @@ -220,6 +220,9 @@ G_BEGIN_DECLS // Keyboard accelerators. GSList * accelerators; ///< @brief Keyboard accelerators. + // Scroll actions. + GtkAction * scroll[4]; ///< @brief Scroll actions. + }; G_GNUC_INTERNAL void v3270_activate(GtkWidget *widget); diff --git a/src/include/v3270/actions.h b/src/include/v3270/actions.h index 8aa349b..56bf3bd 100644 --- a/src/include/v3270/actions.h +++ b/src/include/v3270/actions.h @@ -41,6 +41,9 @@ LIB3270_EXPORT void v3270_tab(GtkWidget *widget); LIB3270_EXPORT void v3270_backtab(GtkWidget *widget); + /// @brief Reset accelerator map to defaults. + LIB3270_EXPORT void v3270_accelerator_map_reset(GtkWidget *widget); + LIB3270_EXPORT void v3270_accelerator_activate(V3270Accelerator * accell, GtkWidget *terminal); LIB3270_EXPORT gboolean v3270_accelerator_compare(const V3270Accelerator * accell, const guint keyval, const GdkModifierType mods); diff --git a/src/terminal/keyboard/accelerator.c b/src/terminal/keyboard/accelerator.c new file mode 100644 index 0000000..4011214 --- /dev/null +++ b/src/terminal/keyboard/accelerator.c @@ -0,0 +1,80 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como properties.c e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + #include "private.h" + #include + #include + #include + #include + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + + static gint compare_func(const V3270Accelerator *a, const V3270Accelerator *b) + { + if(a->activate != b->activate) + return a->activate - b->activate; + return a->arg - b->arg; + } + + void v3270_accelerator_map_reset(GtkWidget *widget) + { + v3270 * terminal = GTK_V3270(widget); + + if(terminal) + { + if(terminal->accelerators) + { + g_slist_free_full(terminal->accelerators,g_free); + terminal->accelerators = NULL; + } + v3270_init_accelerators(terminal); + } + + } + + void v3270_accelerator_map_sort(v3270 *widget) + { + widget->accelerators = g_slist_sort(widget->accelerators, (GCompareFunc) compare_func); + } + + gboolean v3270_accelerator_compare(const V3270Accelerator * accell, const guint keyval, const GdkModifierType mods) + { + return accell->key == keyval && accell->mods == mods; + } + + void v3270_accelerator_activate(V3270Accelerator * accell, GtkWidget *terminal) + { + int rc = ((int (*)(GtkWidget *, const void *)) accell->activate)(terminal,accell->arg); + + if(rc) + gdk_display_beep(gdk_display_get_default()); + + } + + diff --git a/src/terminal/keyboard/init.c b/src/terminal/keyboard/init.c index 101a891..5b76e70 100644 --- a/src/terminal/keyboard/init.c +++ b/src/terminal/keyboard/init.c @@ -32,6 +32,19 @@ #include #include #include + #include + + #ifndef GDK_NUMLOCK_MASK + #define GDK_NUMLOCK_MASK GDK_MOD2_MASK + #endif + +/*--[ Globals ]--------------------------------------------------------------------------------------*/ + +/* + static const struct InternalAction InternalActions[] = + { + }; +*/ /*--[ Implement ]------------------------------------------------------------------------------------*/ @@ -56,54 +69,66 @@ size_t ix; // Create accelerators for lib3270 actions. - const LIB3270_ACTION * actions = lib3270_get_actions(); - - for(ix = 0; actions[ix].name; ix++) { - if(actions[ix].keys) + const LIB3270_ACTION * actions = lib3270_get_actions(); + + for(ix = 0; actions[ix].name; ix++) { - size_t key; + if(actions[ix].keys) + { + size_t key; - gchar ** keys = g_strsplit(actions[ix].keys,",",-1); + gchar ** keys = g_strsplit(actions[ix].keys,",",-1); - for(key = 0; keys[key]; key++) - { + for(key = 0; keys[key]; key++) + { - V3270Accelerator * accelerator = g_new0(V3270Accelerator,1); + V3270Accelerator * accelerator = g_new0(V3270Accelerator,1); - accelerator->type = ACCELERATOR_TYPE_LIB3270_ACTION; - accelerator->arg = (gconstpointer) &actions[ix]; - accelerator->activate = G_CALLBACK(fire_lib3270_action); + accelerator->type = V3270_ACCELERATOR_TYPE_LIB3270_ACTION; + accelerator->arg = (gconstpointer) &actions[ix]; + accelerator->activate = G_CALLBACK(fire_lib3270_action); - debug("%s=%s",actions[ix].name,keys[key]); + debug("%s=%s",actions[ix].name,keys[key]); - gtk_accelerator_parse(keys[key],&accelerator->key,&accelerator->mods); + gtk_accelerator_parse(keys[key],&accelerator->key,&accelerator->mods); - widget->accelerators = g_slist_prepend(widget->accelerators,accelerator); + widget->accelerators = g_slist_prepend(widget->accelerators,accelerator); - } + } + + g_strfreev(keys); - g_strfreev(keys); + } } } + /* + // Create accelerators for internal actions. + { + size_t ix; - } + for(ix = 0 ; ix < G_N_ELEMENTS(InternalActions); ix++) + { + V3270Accelerator * accelerator = g_new0(V3270Accelerator,1); - gboolean v3270_accelerator_compare(const V3270Accelerator * accell, const guint keyval, const GdkModifierType mods) - { - return accell->key == keyval && accell->mods == mods; - } + accelerator->type = V3270_ACCELERATOR_TYPE_INTERNAL; + accelerator->arg = (gconstpointer) &InternalActions[ix]; + accelerator->activate = InternalActions[ix].activate; + accelerator->key = InternalActions[ix].key; + accelerator->mods = InternalActions[ix].mods; - void v3270_accelerator_activate(V3270Accelerator * accell, GtkWidget *terminal) - { - int rc = ((int (*)(GtkWidget *, const void *)) accell->activate)(terminal,accell->arg); + widget->accelerators = g_slist_prepend(widget->accelerators,accelerator); - if(rc) - gdk_display_beep(gdk_display_get_default()); + } + } + */ + + v3270_accelerator_map_sort(widget); } + diff --git a/src/terminal/keyboard/private.h b/src/terminal/keyboard/private.h index bcfe51b..7e9e581 100644 --- a/src/terminal/keyboard/private.h +++ b/src/terminal/keyboard/private.h @@ -30,17 +30,14 @@ #include #include #include + #include - enum + struct InternalAction { - ACCELERATOR_TYPE_LIB3270_ACTION, ///< @brief Accelerator is a lib3270 action - }; - - struct _V3270Accelerator - { - unsigned short type; guint key; GdkModifierType mods; - gconstpointer arg; GCallback activate; }; + + G_GNUC_INTERNAL void v3270_accelerator_map_sort(v3270 *widget); + diff --git a/src/terminal/mouse.c b/src/terminal/mouse.c index 5330a9c..0693393 100644 --- a/src/terminal/mouse.c +++ b/src/terminal/mouse.c @@ -42,7 +42,7 @@ /*--[ Globals ]--------------------------------------------------------------------------------------*/ - static GtkAction *action_scroll[] = { NULL, NULL, NULL, NULL }; +// static GtkAction *action_scroll[] = { NULL, NULL, NULL, NULL }; /*--[ Implement ]------------------------------------------------------------------------------------*/ @@ -314,28 +314,3 @@ gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event) return FALSE; } -LIB3270_EXPORT void v3270_set_scroll_action(GtkWidget *widget, GdkScrollDirection direction, GtkAction *action) -{ - g_return_if_fail(GTK_IS_V3270(widget)); - action_scroll[((int) direction) & 0x03] = action; -} - -gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event) -{ - H3270 * hSession = v3270_get_session(widget); - - lib3270_trace_event(hSession,"scroll event direction=%d",(int) event->direction); - - if(lib3270_get_program_message(hSession) != LIB3270_MESSAGE_NONE || event->direction < 0 || event->direction > G_N_ELEMENTS(action_scroll)) - { - lib3270_trace_event(hSession," dropped (not available)\n"); - return FALSE; - } - - lib3270_trace_event(hSession,"\n"); - - if(action_scroll[event->direction]) - gtk_action_activate(action_scroll[event->direction]); - - return TRUE; - } diff --git a/src/terminal/scroll.c b/src/terminal/scroll.c new file mode 100644 index 0000000..eb591de --- /dev/null +++ b/src/terminal/scroll.c @@ -0,0 +1,68 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como mouse.c e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + #include + #include + #include + #include + #include + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + +LIB3270_EXPORT void v3270_set_scroll_action(GtkWidget *widget, GdkScrollDirection direction, GtkAction *action) +{ + g_return_if_fail(GTK_IS_V3270(widget)); + GTK_V3270(widget)->scroll[((int) direction) & 0x03] = action; +} + +gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event) +{ + v3270 * terminal = GTK_V3270(widget); + + lib3270_trace_event(terminal->host,"scroll event direction=%d",(int) event->direction); + + if(lib3270_get_program_message(terminal->host) != LIB3270_MESSAGE_NONE || event->direction < 0 || event->direction > G_N_ELEMENTS(terminal->scroll)) + { + lib3270_trace_event(terminal->host," dropped (not available)\n"); + return FALSE; + } + + lib3270_trace_event(terminal->host,"\n"); + + debug("%d %p", (int) event->direction, terminal->scroll[event->direction]); + + if(terminal->scroll[event->direction]) + { + debug("%d %s", (int) event->direction, gtk_action_get_name(terminal->scroll[event->direction])); + gtk_action_activate(terminal->scroll[event->direction]); + return TRUE; + } + + return FALSE; + } diff --git a/v3270.cbp b/v3270.cbp index a41801e..30822fc 100644 --- a/v3270.cbp +++ b/v3270.cbp @@ -268,6 +268,9 @@ + + @@ -292,6 +295,9 @@ + + -- libgit2 0.21.2