diff --git a/pw3270.cbp b/pw3270.cbp
index 957fc65..8933c51 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -76,6 +76,9 @@
+
+
+
diff --git a/src/include/pw3270/actions.h b/src/include/pw3270/actions.h
index 28ac983..6aac43e 100644
--- a/src/include/pw3270/actions.h
+++ b/src/include/pw3270/actions.h
@@ -42,6 +42,9 @@
G_BEGIN_DECLS
+ //
+ // Abstract action
+ //
#define PW3270_TYPE_ACTION (pw3270Action_get_type())
#define PW3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_ACTION, pw3270Action))
#define PW3270_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_ACTION, pw3270ActionClass))
@@ -110,6 +113,47 @@
/// @brief Add lib3270 actions to an application window.
void pw3270_window_add_actions(GtkWidget * appwindow);
+ //
+ // "Simple" action
+ //
+ #define PW3270_TYPE_SIMPLE_ACTION (pw3270SimpleAction_get_type())
+ #define PW3270_SIMPLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_SIMPLE_ACTION, pw3270SimpleAction))
+ #define PW3270_SIMPLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_SIMPLE_ACTION, pw3270SimpleActionClass))
+ #define PW3270_IS_SIMPLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_SIMPLE_ACTION))
+ #define PW3270_IS_SIMPLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_SIMPLE_ACTION))
+ #define PW3270_SIMPLE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_SIMPLE_ACTION, pw3270SimpleActionClass))
+
+ typedef struct _pw3270SimpleAction {
+
+ pw3270Action parent;
+
+ // Fixed data
+ const gchar * icon_name;
+ const gchar * label;
+ const gchar * tooltip;
+
+ /// @brief Activation method.
+ void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal);
+
+ } pw3270SimpleAction;
+
+ typedef struct _pw3270SimpleActionClass {
+
+ pw3270ActionClass parent_class;
+
+ } pw3270SimpleActionClass;
+
+ GType pw3270SimpleAction_get_type(void) G_GNUC_CONST;
+
+ /// @brief Create an empty simple action.
+ pw3270SimpleAction * pw3270_simple_action_new();
+
+ /// @brief New simple action from LIB3270's control data.
+ pw3270SimpleAction * pw3270_simple_action_new_from_lib3270(const LIB3270_ACTION * definition, const gchar *name);
+
+ /// @brief New simple action from LIB3270's action name.
+ pw3270SimpleAction * pw3270_simple_action_new_from_name(const gchar *source_name, const gchar *name);
+
G_END_DECLS
#endif // PW3270_ACTIONS_H_INCLUDED
diff --git a/src/objects/actions/abstract.c b/src/objects/actions/abstract.c
index 9818947..f6b92b2 100644
--- a/src/objects/actions/abstract.c
+++ b/src/objects/actions/abstract.c
@@ -354,8 +354,13 @@
}
- static void change_widget(GAction *action, GtkWidget G_GNUC_UNUSED(*from), GtkWidget *to) {
- PW3270_ACTION(action)->terminal = to;
+ static void change_widget(GAction *action, GtkWidget *from, GtkWidget *to) {
+
+ if(from != to) {
+ PW3270_ACTION(action)->terminal = to;
+ pw3270_action_notify_enabled(action);
+ }
+
}
void pw3270_action_set_terminal_widget(GAction *object, GtkWidget *widget) {
@@ -383,6 +388,7 @@
if(action && action->terminal) {
enabled = PW3270_ACTION_GET_CLASS(object)->get_enabled(object,action->terminal);
+ debug("Action %s is %s",g_action_get_name(object),enabled ? "enabled" : "disabled");
}
return enabled;
@@ -402,7 +408,6 @@
}
gboolean get_enabled(GAction G_GNUC_UNUSED(*object), GtkWidget *terminal) {
- debug("Action %s is %s",pw3270_action_get_name(object),terminal == NULL ? "disabled" : "enabled");
return terminal != NULL;
}
@@ -415,6 +420,8 @@
}
const gchar * pw3270_action_get_icon_name(GAction *action) {
+ debug("***********%s(%p)=%p",__FUNCTION__,action,PW3270_ACTION_GET_CLASS(action)->get_icon_name);
+ debug("*************** %s",g_action_get_name(action));
return PW3270_ACTION_GET_CLASS(action)->get_icon_name(action);
}
diff --git a/src/objects/actions/simple.c b/src/objects/actions/simple.c
new file mode 100644
index 0000000..e024de5
--- /dev/null
+++ b/src/objects/actions/simple.c
@@ -0,0 +1,109 @@
+/*
+ * "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 PW3270 Simple Action.
+ *
+ */
+
+ #include "private.h"
+
+ static void pw3270SimpleAction_class_init(pw3270SimpleActionClass *klass);
+ static void pw3270SimpleAction_init(pw3270SimpleAction *action);
+
+ G_DEFINE_TYPE(pw3270SimpleAction, pw3270SimpleAction, PW3270_TYPE_ACTION);
+
+ static void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) {
+
+ debug("%s",__FUNCTION__);
+
+ }
+
+ static gboolean get_enabled(GAction *action, GtkWidget *terminal) {
+ return TRUE;
+ }
+
+ static const gchar * get_icon_name(GAction *action) {
+ return PW3270_SIMPLE_ACTION(action)->icon_name;
+ }
+
+ static const gchar * get_label(GAction *action) {
+ return PW3270_SIMPLE_ACTION(action)->label;
+ }
+
+ static const gchar * get_tooltip(GAction *action) {
+ return PW3270_SIMPLE_ACTION(action)->tooltip;
+ }
+
+ static void pw3270SimpleAction_class_init(pw3270SimpleActionClass *klass) {
+
+ klass->parent_class.get_icon_name = get_icon_name;
+ klass->parent_class.get_label = get_label;
+ klass->parent_class.get_tooltip = get_tooltip;
+ klass->parent_class.get_enabled = get_enabled;
+
+ debug("%s:%p",__FUNCTION__,klass->parent_class.get_icon_name);
+
+ }
+
+ static void pw3270SimpleAction_init(pw3270SimpleAction *action) {
+
+ action->icon_name = NULL;
+ action->label = N_( "No label" );
+ action->tooltip = NULL;
+
+ }
+
+ pw3270SimpleAction * pw3270_simple_action_new_from_lib3270(const LIB3270_ACTION * definition, const gchar *name) {
+
+ if(!definition)
+ return NULL;
+
+ debug("%s(%s,%s)",__FUNCTION__,definition->name,name);
+
+ pw3270SimpleAction * action = (pw3270SimpleAction *) g_object_new(PW3270_TYPE_SIMPLE_ACTION, NULL);
+
+ action->parent.name = name ? name : definition->name;
+ action->icon_name = definition->icon;
+ action->label = definition->label;
+ action->tooltip = definition->summary;
+ action->activate = activate;
+
+ return action;
+
+ }
+
+ pw3270SimpleAction * pw3270_simple_action_new_from_name(const gchar *source_name, const gchar *name) {
+ return pw3270_simple_action_new_from_lib3270(lib3270_action_get_by_name(source_name),name);
+ }
+
+ pw3270SimpleAction * pw3270_simple_action_new() {
+ return (pw3270SimpleAction *) g_object_new(PW3270_TYPE_SIMPLE_ACTION, NULL);
+ }
+
diff --git a/src/objects/window/actions/preferences.c b/src/objects/window/actions/preferences.c
index d6f5ab5..a289f5a 100644
--- a/src/objects/window/actions/preferences.c
+++ b/src/objects/window/actions/preferences.c
@@ -41,6 +41,9 @@
action->activate = activate;
action->name = "preferences";
+ debug("action=%p",__FUNCTION__);
+ debug("\n\n%s\n\n",pw3270_action_get_icon_name(G_ACTION(action)));
+
return G_ACTION(action);
}
diff --git a/src/objects/window/actions/setcolors.c b/src/objects/window/actions/setcolors.c
index a7428cc..50c4a1f 100644
--- a/src/objects/window/actions/setcolors.c
+++ b/src/objects/window/actions/setcolors.c
@@ -38,10 +38,12 @@
GAction * pw3270_set_color_action_new(void) {
- pw3270Action * action = PW3270_ACTION(pw3270_action_new());
+ pw3270SimpleAction * action = pw3270_simple_action_new();
- action->activate = activate;
- action->name = "setcolors";
+ action->parent.activate = activate;
+ action->parent.name = "set.colors";
+ action->icon_name = "gtk-select-color";
+ action->label = N_("Colors");
return G_ACTION(action);
@@ -58,5 +60,7 @@
g_signal_connect(dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL);
g_signal_connect(dialog,"response",G_CALLBACK(gtk_widget_destroy),NULL);
+ gtk_widget_show_all(dialog);
+
}
diff --git a/src/objects/window/window.c b/src/objects/window/window.c
index 08dfe67..995e240 100644
--- a/src/objects/window/window.c
+++ b/src/objects/window/window.c
@@ -153,6 +153,7 @@
"win.connect",
"win.disconnect",
"separator",
+ "win.set.colors",
"win.preferences",
"win.print"
--
libgit2 0.21.2