diff --git a/src/actions/abstract.c b/src/actions/abstract.c
index 8c61ef0..bf116c3 100644
--- a/src/actions/abstract.c
+++ b/src/actions/abstract.c
@@ -80,6 +80,11 @@
iface->activate = pw3270_action_activate;
}
+ static const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*action))
+ {
+ return NULL;
+ }
+
void pw3270Action_class_init(pw3270ActionClass *klass) {
GObjectClass *object_class = G_OBJECT_CLASS(klass);
@@ -87,6 +92,7 @@
klass->change_widget = change_widget;
klass->get_enabled = get_enabled;
klass->activate = activate;
+ klass->get_parameter_type = get_parameter_type;
object_class->finalize = finalize;
object_class->set_property = pw3270_action_set_property;
@@ -286,8 +292,7 @@
}
const GVariantType * pw3270_action_get_parameter_type(GAction *action) {
-// debug("%s",__FUNCTION__);
- return NULL;
+ return PW3270_ACTION_GET_CLASS(action)->get_parameter_type(action);
}
const GVariantType * pw3270_action_get_state_type(GAction *object) {
diff --git a/src/actions/actions.cbp b/src/actions/actions.cbp
index eaf60e5..11d05ce 100644
--- a/src/actions/actions.cbp
+++ b/src/actions/actions.cbp
@@ -46,6 +46,12 @@
+
+
+
+
+
+
diff --git a/src/actions/lib3270/pakey.c b/src/actions/lib3270/pakey.c
new file mode 100644
index 0000000..7d0fd4b
--- /dev/null
+++ b/src/actions/lib3270/pakey.c
@@ -0,0 +1,139 @@
+/*
+ * "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 PAs.
+ *
+ */
+
+ #include "../private.h"
+ #include
+
+ #define PW3270_TYPE_PAKEY_ACTION (Lib3270PaAction_get_type())
+ #define PW3270_LIB3270_PAKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_PAKEY_ACTION, Lib3270PaAction))
+ #define PW3270_IS_LIB3270_PAKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_PAKEY_ACTION))
+
+ typedef struct _Lib3270PaActionClass {
+ pw3270ActionClass parent_class;
+
+ } Lib3270PaActionClass;
+
+ typedef struct _Lib3270PaAction {
+ pw3270Action parent;
+
+ } Lib3270PaAction;
+
+ static void Lib3270PaAction_class_init(Lib3270PaActionClass *klass);
+ static void Lib3270PaAction_init(Lib3270PaAction *action);
+ static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to);
+
+ G_DEFINE_TYPE(Lib3270PaAction, Lib3270PaAction, PW3270_TYPE_PAKEY_ACTION);
+
+ static gboolean get_enabled(GAction *action, GtkWidget *terminal) {
+
+ if(terminal)
+ return lib3270_is_connected(v3270_get_session(terminal)) > 0 ? TRUE: FALSE;
+
+ return FALSE;
+
+ }
+
+ static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) {
+
+ if(action && terminal && parameter) {
+
+ H3270 * hSession = v3270_get_session(terminal);
+
+ if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT32)) {
+
+ lib3270_pakey(hSession,(int) g_variant_get_int32(parameter));
+
+ } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT32)) {
+
+ lib3270_pakey(hSession,(int) g_variant_get_uint32(parameter));
+
+ } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT16)) {
+
+ lib3270_pakey(hSession,(int) g_variant_get_int16(parameter));
+
+ } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT16)) {
+
+ lib3270_pakey(hSession,(int) g_variant_get_uint16(parameter));
+
+ }
+
+ }
+
+ }
+
+ static const GVariantType * get_parameter_type(GAction *action)
+ {
+ return G_VARIANT_TYPE_UINT16;
+ }
+
+ void Lib3270PaAction_class_init(Lib3270PaActionClass *klass) {
+
+ pw3270ActionClass * action = PW3270_ACTION_CLASS(klass);
+
+ action->activate = activate;
+ action->get_enabled = get_enabled;
+ action->change_widget = change_widget;
+ action->get_parameter_type = get_parameter_type;
+
+ }
+
+ void Lib3270PaAction_init(Lib3270PaAction *action) {
+ }
+
+ GAction * pw3270_action_new_pakey(void) {
+
+ Lib3270PaAction * action = (Lib3270PaAction *) g_object_new(PW3270_TYPE_PAKEY_ACTION, NULL);
+
+ // Setup the default name.
+ pw3270Action * abstract = PW3270_ACTION(action);
+
+ if(abstract->name)
+ g_free(abstract->name);
+
+ abstract->name = g_strdup("win.pakey");
+
+ return G_ACTION(action);
+ }
+
+ void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) {
+
+ PW3270_ACTION_CLASS(Lib3270PaAction_parent_class)->change_widget(object,from,to);
+
+ // Does the "enabled" state has changed? If yes notify customers.
+ gboolean enabled = get_enabled(object,to);
+ if(get_enabled(object,from) != enabled)
+ pw3270_action_set_enabled(object,enabled);
+
+ }
+
diff --git a/src/actions/lib3270/pfkey.c b/src/actions/lib3270/pfkey.c
new file mode 100644
index 0000000..8e55bb4
--- /dev/null
+++ b/src/actions/lib3270/pfkey.c
@@ -0,0 +1,139 @@
+/*
+ * "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 PFs.
+ *
+ */
+
+ #include "../private.h"
+ #include
+
+ #define PW3270_TYPE_PFKEY_ACTION (Lib3270PfAction_get_type())
+ #define PW3270_LIB3270_PFKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_PFKEY_ACTION, Lib3270PfAction))
+ #define PW3270_IS_LIB3270_PFKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_PFKEY_ACTION))
+
+ typedef struct _Lib3270PfActionClass {
+ pw3270ActionClass parent_class;
+
+ } Lib3270PfActionClass;
+
+ typedef struct _Lib3270PfAction {
+ pw3270Action parent;
+
+ } Lib3270PfAction;
+
+ static void Lib3270PfAction_class_init(Lib3270PfActionClass *klass);
+ static void Lib3270PfAction_init(Lib3270PfAction *action);
+ static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to);
+
+ G_DEFINE_TYPE(Lib3270PfAction, Lib3270PfAction, PW3270_TYPE_PFKEY_ACTION);
+
+ static gboolean get_enabled(GAction *action, GtkWidget *terminal) {
+
+ if(terminal)
+ return lib3270_is_connected(v3270_get_session(terminal)) > 0 ? TRUE: FALSE;
+
+ return FALSE;
+
+ }
+
+ static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) {
+
+ if(action && terminal && parameter) {
+
+ H3270 * hSession = v3270_get_session(terminal);
+
+ if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT32)) {
+
+ lib3270_pfkey(hSession,(int) g_variant_get_int32(parameter));
+
+ } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT32)) {
+
+ lib3270_pfkey(hSession,(int) g_variant_get_uint32(parameter));
+
+ } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT16)) {
+
+ lib3270_pfkey(hSession,(int) g_variant_get_int16(parameter));
+
+ } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT16)) {
+
+ lib3270_pfkey(hSession,(int) g_variant_get_uint16(parameter));
+
+ }
+
+ }
+
+ }
+
+ static const GVariantType * get_parameter_type(GAction *action)
+ {
+ return G_VARIANT_TYPE_UINT16;
+ }
+
+ void Lib3270PfAction_class_init(Lib3270PfActionClass *klass) {
+
+ pw3270ActionClass * action = PW3270_ACTION_CLASS(klass);
+
+ action->activate = activate;
+ action->get_enabled = get_enabled;
+ action->change_widget = change_widget;
+ action->get_parameter_type = get_parameter_type;
+
+ }
+
+ void Lib3270PfAction_init(Lib3270PfAction *action) {
+ }
+
+ GAction * pw3270_action_new_pfkey(void) {
+
+ Lib3270PfAction * action = (Lib3270PfAction *) g_object_new(PW3270_TYPE_PFKEY_ACTION, NULL);
+
+ // Setup the default name.
+ pw3270Action * abstract = PW3270_ACTION(action);
+
+ if(abstract->name)
+ g_free(abstract->name);
+
+ abstract->name = g_strdup("win.pfkey");
+
+ return G_ACTION(action);
+ }
+
+ void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) {
+
+ PW3270_ACTION_CLASS(Lib3270PfAction_parent_class)->change_widget(object,from,to);
+
+ // Does the "enabled" state has changed? If yes notify customers.
+ gboolean enabled = get_enabled(object,to);
+ if(get_enabled(object,from) != enabled)
+ pw3270_action_set_enabled(object,enabled);
+
+ }
+
diff --git a/src/actions/private.h b/src/actions/private.h
index 3c3e582..c49e3a8 100644
--- a/src/actions/private.h
+++ b/src/actions/private.h
@@ -72,11 +72,14 @@
void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to);
gboolean (*get_enabled)(GAction *action, GtkWidget *terminal);
void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal);
+ const GVariantType * (*get_parameter_type)(GAction *action);
};
G_GNUC_INTERNAL GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition);
G_GNUC_INTERNAL GAction * pw3270_toggle_action_new_from_lib3270(const LIB3270_TOGGLE * definition);
+ G_GNUC_INTERNAL GAction * pw3270_action_new_pfkey(void);
+ G_GNUC_INTERNAL GAction * pw3270_action_new_pakey(void);
G_GNUC_INTERNAL void pw3270_action_change_state_boolean(GAction *action, gboolean state);
G_GNUC_INTERNAL void pw3270_action_set_enabled(GAction *action, gboolean state);
diff --git a/src/actions/window.c b/src/actions/window.c
index 703e57c..fd011c6 100644
--- a/src/actions/window.c
+++ b/src/actions/window.c
@@ -84,5 +84,8 @@
}
+ g_action_map_add_action(map,pw3270_action_new_pfkey());
+ g_action_map_add_action(map,pw3270_action_new_pakey());
+
debug("%s ends",__FUNCTION__);
}
--
libgit2 0.21.2