From 319796e75c796b419f60e6f0a3101ed330c79399 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Thu, 26 Dec 2019 15:07:38 -0300 Subject: [PATCH] Moving lib3270 action to the v3270 library. --- pw3270.cbp | 1 - src/include/pw3270/actions.h | 4 ++-- src/objects/actions/connect.c | 4 ++++ src/objects/actions/lib3270/action.c | 159 --------------------------------------------------------------------------------------------------------------------------------------------------------------- src/objects/actions/private.h | 2 +- src/objects/actions/window.c | 4 +++- src/objects/window/window.c | 1 + 7 files changed, 11 insertions(+), 164 deletions(-) delete mode 100644 src/objects/actions/lib3270/action.c diff --git a/pw3270.cbp b/pw3270.cbp index 5526df6..bc4f4cb 100644 --- a/pw3270.cbp +++ b/pw3270.cbp @@ -49,7 +49,6 @@ - diff --git a/src/include/pw3270/actions.h b/src/include/pw3270/actions.h index 7dc42a1..0ed2556 100644 --- a/src/include/pw3270/actions.h +++ b/src/include/pw3270/actions.h @@ -97,11 +97,11 @@ GType pw3270Action_get_type(void) G_GNUC_CONST; - /// @brief New generica acion. + /// @brief New generic action. GAction * pw3270_action_new(); /// @brief New action from LIB3270's control data. - GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition); + GAction * g_action_new_from_lib3270(const LIB3270_ACTION * definition); /// @brief Get action name. const gchar * pw3270_action_get_name(GAction *action); diff --git a/src/objects/actions/connect.c b/src/objects/actions/connect.c index b83b484..e8f6170 100644 --- a/src/objects/actions/connect.c +++ b/src/objects/actions/connect.c @@ -34,13 +34,16 @@ #include "private.h" + /* static void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { debug("%s",__FUNCTION__); gtk_widget_activate(terminal); } + */ + /* GAction * pw3270_action_connect_new(void) { pw3270Action * action = PW3270_ACTION(pw3270_action_new_from_lib3270(lib3270_action_get_by_name("reconnect"))); @@ -51,3 +54,4 @@ return G_ACTION(action); } + */ diff --git a/src/objects/actions/lib3270/action.c b/src/objects/actions/lib3270/action.c deleted file mode 100644 index 2046a9e..0000000 --- a/src/objects/actions/lib3270/action.c +++ /dev/null @@ -1,159 +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 - e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - */ - - /** - * @brief Implement GAction "wrapper" for lib3270's actions. - * - */ - - #include "../private.h" - #include - - #define PW3270_TYPE_LIB3270_ACTION (Lib3270Action_get_type()) - #define PW3270_LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_LIB3270_ACTION, Lib3270Action)) - #define PW3270_IS_LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_LIB3270_ACTION)) - - typedef struct _Lib3270ActionClass { - pw3270ActionClass parent_class; - - } Lib3270ActionClass; - - typedef struct _Lib3270Action { - pw3270Action parent; - - const LIB3270_ACTION * definition; - const void * listener; - - } Lib3270Action; - - static void Lib3270Action_class_init(Lib3270ActionClass *klass); - static void Lib3270Action_init(Lib3270Action *action); - static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to); - - G_DEFINE_TYPE(Lib3270Action, Lib3270Action, PW3270_TYPE_ACTION); - - static gboolean get_enabled(GAction *action, GtkWidget *terminal) { - - if(terminal) { - - H3270 * hSession = v3270_get_session(terminal); - if(hSession) - return PW3270_LIB3270_ACTION(action)->definition->activatable(hSession) > 0 ? TRUE : FALSE; - - } - - return FALSE; - - } - - static void activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { - PW3270_LIB3270_ACTION(action)->definition->activate(v3270_get_session(terminal)); - } - - static const gchar * get_icon_name(GAction *action) { - debug("%s(%s)=\"%s\"",__FUNCTION__,g_action_get_name(action),PW3270_LIB3270_ACTION(action)->definition->icon); - return PW3270_LIB3270_ACTION(action)->definition->icon; - } - - static const gchar * get_label(GAction *action) { - return PW3270_LIB3270_ACTION(action)->definition->label; - } - - static const gchar * get_tooltip(GAction *action) { - return PW3270_LIB3270_ACTION(action)->definition->summary; - } - - static void dispose(GObject *object) { - - Lib3270Action *action = PW3270_LIB3270_ACTION(object); - - if(action->listener) { - lib3270_unregister_action_group_listener(pw3270_action_get_session(G_ACTION(object)),action->definition->group,action->listener); - action->listener = NULL; - } - - G_OBJECT_CLASS(Lib3270Action_parent_class)->dispose(object); - } - - void Lib3270Action_class_init(Lib3270ActionClass *klass) { - - pw3270ActionClass * action = PW3270_ACTION_CLASS(klass); - - action->get_enabled = get_enabled; - action->change_widget = change_widget; - action->get_icon_name = get_icon_name; - action->get_label = get_label; - action->get_tooltip = get_tooltip; - - G_OBJECT_CLASS(klass)->dispose = dispose; - - } - - void Lib3270Action_init(Lib3270Action *action) { - - action->parent.activate = activate; - action->parent.name = "tn3270"; - - } - - GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition) { - - Lib3270Action * action = (Lib3270Action *) g_object_new(PW3270_TYPE_LIB3270_ACTION, NULL); - - // Setup hooks. - action->definition = definition; - action->listener = NULL; - action->parent.name = definition->name; - - return G_ACTION(action); - } - - static void event_listener(H3270 G_GNUC_UNUSED(*hSession), void *object) { - pw3270_action_notify_enabled(G_ACTION(object)); - } - - void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { - - // Remove old listener - Lib3270Action * action = PW3270_LIB3270_ACTION(object); - if(action->listener) { - lib3270_unregister_action_group_listener(pw3270_action_get_session(object),action->definition->group,action->listener); - action->listener = NULL; - } - - // Change widget - PW3270_ACTION_CLASS(Lib3270Action_parent_class)->change_widget(object,from,to); - - // Setup new listener - if(action->definition->group && to) { - action->listener = lib3270_register_action_group_listener(pw3270_action_get_session(object),action->definition->group,event_listener,object); - } - - } - diff --git a/src/objects/actions/private.h b/src/objects/actions/private.h index bd76f67..55703de 100644 --- a/src/objects/actions/private.h +++ b/src/objects/actions/private.h @@ -61,7 +61,7 @@ G_GNUC_INTERNAL void pw3270_action_notify_state(GAction *object); // Internal actions - G_GNUC_INTERNAL GAction * pw3270_action_connect_new(void); +// G_GNUC_INTERNAL GAction * pw3270_action_connect_new(void); G_GNUC_INTERNAL GAction * pw3270_action_copy_new(void); G_GNUC_INTERNAL GAction * pw3270_action_cut_new(void); G_GNUC_INTERNAL GAction * pw3270_action_paste_new(void); diff --git a/src/objects/actions/window.c b/src/objects/actions/window.c index 140c95c..d827e06 100644 --- a/src/objects/actions/window.c +++ b/src/objects/actions/window.c @@ -42,16 +42,18 @@ GActionMap * map = G_ACTION_MAP(appwindow); size_t ix; + /* // Map lib3270 actions { const LIB3270_ACTION * actions = lib3270_get_actions(); for(ix = 0; actions[ix].name; ix++) { - GAction *action = pw3270_action_new_from_lib3270(&actions[ix]); + GAction *action = g_action_new_from_lib3270(&actions[ix]); g_action_map_add_action(map,action); } } + */ // Map toggles { diff --git a/src/objects/window/window.c b/src/objects/window/window.c index 8f6c406..45d673c 100644 --- a/src/objects/window/window.c +++ b/src/objects/window/window.c @@ -143,6 +143,7 @@ pw3270_window_add_actions(GTK_WIDGET(widget)); g_action_map_add_v3270_actions(G_ACTION_MAP(widget)); + g_action_map_add_lib3270_actions(G_ACTION_MAP(widget)); // Map special actions { -- libgit2 0.21.2