diff --git a/Makefile.in b/Makefile.in index 8be7481..90db632 100644 --- a/Makefile.in +++ b/Makefile.in @@ -39,6 +39,7 @@ SOURCES= \ $(wildcard src/terminal/drawing/*.c) \ $(wildcard src/terminal/font/*.c) \ $(wildcard src/terminal/keyboard/*.c) \ + $(wildcard src/terminal/actions/*.c) \ $(wildcard src/filetransfer/*.c) \ $(wildcard src/selection/*.c) \ $(wildcard src/selection/@OSNAME@/*.c) \ diff --git a/src/include/v3270/actions.h b/src/include/v3270/actions.h index e7bbf12..5405c60 100644 --- a/src/include/v3270/actions.h +++ b/src/include/v3270/actions.h @@ -37,7 +37,30 @@ typedef struct _V3270Accelerator V3270Accelerator; + typedef enum _v3270_action_flag + { + V3270_ACTION_FLAG_DEFAULT = 0x00000000, + V3270_ACTION_FLAG_CUT = 0x10000000, + } V3270_ACTION_FLAGS; + typedef struct _v3270_action + { + LIB3270_PROPERTY_HEAD + + V3270_ACTION_FLAGS flags; ///< @brief (The flags for activation. + + guint key; + GdkModifierType mods; + + int (*activate)(GtkWidget *widget, const struct _v3270_action *action); + + } V3270_ACTION; + + + /// + /// @brief Get internal V3270 action table. + /// + LIB3270_EXPORT const V3270_ACTION * v3270_get_actions(); // // Actions diff --git a/src/terminal/actions/clipboard.c b/src/terminal/actions/clipboard.c new file mode 100644 index 0000000..20a0d6d --- /dev/null +++ b/src/terminal/actions/clipboard.c @@ -0,0 +1,74 @@ +/* + * "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 + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + + int fire_copy_accelerator(GtkWidget *widget, const V3270_ACTION * action) { + + debug("%s",__FUNCTION__); + + v3270_clipboard_set( + widget, + (action->flags & 0x0F), + (action->flags & V3270_ACTION_FLAG_CUT) != 0 + ); + + return EINVAL; + } + + int fire_paste_accelerator(GtkWidget *widget, const V3270_ACTION * action) { + + + switch((int) action->flags) + { + case 0: // Default paste. + v3270_clipboard_get_from_url(widget,NULL); + break; + + case 1: // Text paste. + v3270_clipboard_get_from_url(widget,"text://"); + break; + + case 2: // File paste. + v3270_clipboard_get_from_url(widget,"file://"); + break; + + default: + g_warning("Unexpected paste flags %u",(unsigned int) action->flags); + } + + return 0; + } + + diff --git a/src/terminal/actions/private.h b/src/terminal/actions/private.h new file mode 100644 index 0000000..c1ee62e --- /dev/null +++ b/src/terminal/actions/private.h @@ -0,0 +1,39 @@ +/* + * "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 - 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 + + G_GNUC_INTERNAL int fire_copy_accelerator(GtkWidget *widget, const struct _v3270_action * action); + G_GNUC_INTERNAL int fire_paste_accelerator(GtkWidget *widget, const struct _v3270_action * action); + G_GNUC_INTERNAL int fire_zoom_action(GtkWidget *widget, const struct _v3270_action * action); + G_GNUC_INTERNAL int fire_keypad_action(GtkWidget *widget, const struct _v3270_action * action); + diff --git a/src/terminal/actions/table.c b/src/terminal/actions/table.c new file mode 100644 index 0000000..5a127fa --- /dev/null +++ b/src/terminal/actions/table.c @@ -0,0 +1,169 @@ +/* + * "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 + #include + + #ifndef GDK_NUMLOCK_MASK + #define GDK_NUMLOCK_MASK GDK_MOD2_MASK + #endif + + #ifndef GDK_ALT_MASK + #define GDK_ALT_MASK GDK_MOD1_MASK + #endif + +/*--[ Globals ]--------------------------------------------------------------------------------------*/ + + static const V3270_ACTION actions[] = + { + { + .name = "keypad-add", + .key = GDK_KP_Add, + .mods = GDK_NUMLOCK_MASK, + .activate = fire_keypad_action + }, + { + .name = "keypad-subtract", + .key = GDK_KP_Subtract, + .mods = GDK_NUMLOCK_MASK, + .activate = fire_keypad_action + }, + + // Standard Clipboard actions + { + .flags = 0, + .name = "copy", + .key = 'c', + .mods = GDK_CONTROL_MASK, + .activate = fire_copy_accelerator + }, + + { + .flags = V3270_COPY_APPEND, + .name = "copy-append", + .key = 'c', + .mods = GDK_ALT_MASK, + .activate = fire_copy_accelerator + }, + + { + .flags = V3270_COPY_TEXT, + .name = "copy-text", + .key = 'c', + .mods = GDK_SHIFT_MASK|GDK_CONTROL_MASK, + .activate = fire_copy_accelerator + }, + + { + .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_DEFAULT, + .name = "cut", + .key = 'x', + .mods = GDK_CONTROL_MASK, + .activate = fire_copy_accelerator + }, + + { + .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_APPEND, + .name = "cut-append", + .key = 'x', + .mods = GDK_ALT_MASK, + .activate = fire_copy_accelerator + }, + + { + .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_TEXT, + .name = "cut-text", + .key = 'x', + .mods = GDK_SHIFT_MASK|GDK_CONTROL_MASK, + .activate = fire_copy_accelerator + }, + + { + .flags = 0, + .name = "paste", + .key = 'v', + .mods = GDK_CONTROL_MASK, + .activate = fire_paste_accelerator + }, + + { + .flags = 1, + .name = "paste-text", + .key = 'v', + .mods = GDK_SHIFT_MASK|GDK_CONTROL_MASK, + .activate = fire_paste_accelerator + }, + + { + .flags = 2, + .name = "paste-file", + .key = 'v', + .mods = GDK_ALT_MASK, + .activate = fire_paste_accelerator + }, + + { + .flags = 0, + .name = "zoom-in", + .key = GDK_KP_Add, + .mods = GDK_CONTROL_MASK, + .activate = fire_zoom_action + }, + + { + .flags = 1, + .name = "zoom-out", + .key = GDK_KP_Subtract, + .mods = GDK_CONTROL_MASK, + .activate = fire_zoom_action + }, + + { + .flags = 2, + .name = "zoom-fit-best", + .key = '0', + .mods = GDK_CONTROL_MASK, + .activate = fire_zoom_action + }, + + { + .name = NULL + } + }; + + LIB3270_EXPORT const V3270_ACTION * v3270_get_actions() + { + return actions; + } + + diff --git a/src/terminal/actions/zoom.c b/src/terminal/actions/zoom.c new file mode 100644 index 0000000..fa578f4 --- /dev/null +++ b/src/terminal/actions/zoom.c @@ -0,0 +1,62 @@ +/* + * "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 + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + + int fire_zoom_action(GtkWidget *widget, const V3270_ACTION * action) { + + debug("%s",__FUNCTION__); + + switch(action->flags) + { + case 0: // Zoom in + v3270_zoom_in(widget); + break; + + case 1: // Zoom out + v3270_zoom_out(widget); + break; + + case 2: // Zoom fit best + v3270_zoom_best(widget); + break; + + default: + g_warning("Unexpected zoom flags %u",(unsigned int) action->flags); + } + + return 0; + } + + diff --git a/src/terminal/keyboard/accelerator.c b/src/terminal/keyboard/accelerator.c index 00c28c6..4dd496a 100644 --- a/src/terminal/keyboard/accelerator.c +++ b/src/terminal/keyboard/accelerator.c @@ -32,6 +32,7 @@ #include #include #include + #include /*--[ Implement ]------------------------------------------------------------------------------------*/ @@ -98,8 +99,11 @@ case V3270_ACCELERATOR_TYPE_LIB3270_ACTION: return gettext(((LIB3270_ACTION *) accel->arg)->summary); - // case V3270_ACCELERATOR_TYPE_INTERNAL: - // case V3270_ACCELERATOR_TYPE_GTK_ACTION: + case V3270_ACCELERATOR_TYPE_INTERNAL: + return ((V3270_ACTION *) accel->arg)->summary; + + case V3270_ACCELERATOR_TYPE_LIB3270_TOGGLE: + return ((LIB3270_TOGGLE *) accel->arg)->summary; } @@ -117,7 +121,7 @@ return ((LIB3270_TOGGLE *) accel->arg)->name; case V3270_ACCELERATOR_TYPE_INTERNAL: - return ((struct InternalAction *) accel->arg)->name; + return ((V3270_ACTION *) accel->arg)->name; case V3270_ACCELERATOR_TYPE_CUSTOM: return ((V3270CustomAccelerator *) accel)->name; diff --git a/src/terminal/keyboard/clipboard.c b/src/terminal/keyboard/clipboard.c deleted file mode 100644 index b9b2362..0000000 --- a/src/terminal/keyboard/clipboard.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * "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 - -/*--[ Implement ]------------------------------------------------------------------------------------*/ - - int fire_copy_accelerator(GtkWidget *widget, const struct InternalAction * action) { - - debug("%s",__FUNCTION__); - - v3270_clipboard_set( - widget, - (action->operation & 0x0F), - (action->operation & ACCEL_OPERATION_CUT) != 0 - ); - - return EINVAL; - } - - int fire_paste_accelerator(GtkWidget *widget, const struct InternalAction * action) { - - - switch(action->operation) - { - case 0: // Default paste. - v3270_clipboard_get_from_url(widget,NULL); - break; - - case 1: // Text paste. - v3270_clipboard_get_from_url(widget,"text://"); - break; - - case 2: // File paste. - v3270_clipboard_get_from_url(widget,"file://"); - break; - - default: - g_warning("Unexpected paste operation %u",(unsigned int) action->operation); - } - - return 0; - } - - diff --git a/src/terminal/keyboard/init.c b/src/terminal/keyboard/init.c index af4b75d..0ce16b7 100644 --- a/src/terminal/keyboard/init.c +++ b/src/terminal/keyboard/init.c @@ -44,109 +44,6 @@ #define GDK_ALT_MASK GDK_MOD1_MASK #endif -/*--[ Globals ]--------------------------------------------------------------------------------------*/ - - static int fire_keypad_action(GtkWidget *widget, const struct InternalAction * action); - static int fire_zoom_action(GtkWidget *widget, const struct InternalAction * action); - - static const struct InternalAction InternalActions[] = - { - { - .name = "keypad-add", - .key = GDK_KP_Add, - .mods = GDK_NUMLOCK_MASK, - .activate = G_CALLBACK(fire_keypad_action) - }, - { - .name = "keypad-subtract", - .key = GDK_KP_Subtract, - .mods = GDK_NUMLOCK_MASK, - .activate = G_CALLBACK(fire_keypad_action) - }, - - // Standard Clipboard actions - { - .operation = V3270_COPY_DEFAULT, - .name = "copy", - .key = 'c', - .mods = GDK_CONTROL_MASK, - .activate = G_CALLBACK(fire_copy_accelerator) - }, - - { - .operation = V3270_COPY_APPEND, - .name = "copy-append", - .key = 'c', - .mods = GDK_ALT_MASK, - .activate = G_CALLBACK(fire_copy_accelerator) - }, - - { - .operation = V3270_COPY_TEXT, - .name = "copy-text", - .key = 'c', - .mods = GDK_SHIFT_MASK|GDK_CONTROL_MASK, - .activate = G_CALLBACK(fire_copy_accelerator) - }, - - { - .operation = ACCEL_OPERATION_CUT|V3270_COPY_DEFAULT, - .name = "cut", - .key = 'x', - .mods = GDK_CONTROL_MASK, - .activate = G_CALLBACK(fire_copy_accelerator) - }, - - { - .operation = ACCEL_OPERATION_CUT|V3270_COPY_APPEND, - .name = "cut-append", - .key = 'x', - .mods = GDK_ALT_MASK, - .activate = G_CALLBACK(fire_copy_accelerator) - }, - - { - .operation = ACCEL_OPERATION_CUT|V3270_COPY_TEXT, - .name = "cut-text", - .key = 'x', - .mods = GDK_SHIFT_MASK|GDK_CONTROL_MASK, - .activate = G_CALLBACK(fire_copy_accelerator) - }, - - { - .operation = ACCEL_OPERATION_DEFAULT, - .name = "paste", - .key = 'v', - .mods = GDK_CONTROL_MASK, - .activate = G_CALLBACK(fire_paste_accelerator) - }, - - { - .operation = 0, - .name = "zoom-in", - .key = GDK_KP_Add, - .mods = GDK_CONTROL_MASK, - .activate = G_CALLBACK(fire_zoom_action) - }, - - { - .operation = 1, - .name = "zoom-out", - .key = GDK_KP_Subtract, - .mods = GDK_CONTROL_MASK, - .activate = G_CALLBACK(fire_zoom_action) - }, - - { - .operation = 2, - .name = "zoom-fit-best", - .key = '0', - .mods = GDK_CONTROL_MASK, - .activate = G_CALLBACK(fire_zoom_action) - }, - - }; - /*--[ Implement ]------------------------------------------------------------------------------------*/ static int fire_lib3270_action(GtkWidget *widget, const LIB3270_ACTION * action) @@ -171,7 +68,7 @@ return lib3270_toggle(v3270_get_session(widget),action->id); } - static int fire_keypad_action(GtkWidget *widget, const struct InternalAction * action) + int fire_keypad_action(GtkWidget *widget, const struct _v3270_action * action) { int rc = 0; debug("%s",__FUNCTION__); @@ -192,12 +89,6 @@ } - static int fire_zoom_action(GtkWidget *widget, const struct InternalAction * action) - { - debug("%s",__FUNCTION__); - return 0; - } - void v3270_init_accelerators(v3270 *widget) { size_t ix; @@ -267,15 +158,17 @@ { size_t ix; - for(ix = 0 ; ix < G_N_ELEMENTS(InternalActions); ix++) + const V3270_ACTION * actions = v3270_get_actions(); + + for(ix = 0 ; actions[ix].name; ix++) { V3270Accelerator * accelerator = g_new0(V3270Accelerator,1); 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; + accelerator->arg = (gconstpointer) &actions[ix]; + accelerator->activate = G_CALLBACK(actions[ix].activate); + accelerator->key = actions[ix].key; + accelerator->mods = actions[ix].mods; widget->accelerators = g_slist_prepend(widget->accelerators,accelerator); diff --git a/src/terminal/keyboard/private.h b/src/terminal/keyboard/private.h index 21d2aec..979c6bf 100644 --- a/src/terminal/keyboard/private.h +++ b/src/terminal/keyboard/private.h @@ -32,25 +32,6 @@ #include #include - enum - { - ACCEL_OPERATION_DEFAULT = 0x00000000, - ACCEL_OPERATION_CUT = 0x10000000, - }; + G_GNUC_INTERNAL void v3270_accelerator_map_sort(v3270 *widget); - #define ACCEL_OPERATION_MASK (ACCEL_OPERATION_CUT|ACCEL_OPERATION_APPEND) - - struct InternalAction - { - unsigned int operation; - const gchar * name; - guint key; - GdkModifierType mods; - GCallback activate; - }; - - G_GNUC_INTERNAL void v3270_accelerator_map_sort(v3270 *widget); - - G_GNUC_INTERNAL int fire_copy_accelerator(GtkWidget *widget, const struct InternalAction * action); - G_GNUC_INTERNAL int fire_paste_accelerator(GtkWidget *widget, const struct InternalAction * action); diff --git a/v3270.cbp b/v3270.cbp index 3387c03..9d15871 100644 --- a/v3270.cbp +++ b/v3270.cbp @@ -222,6 +222,10 @@ + + + @@ -281,6 +285,9 @@ + + -- libgit2 0.21.2