diff --git a/pw3270.cbp b/pw3270.cbp
index e74484d..5a3d824 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -81,10 +81,7 @@
-
-
-
-
+
diff --git a/src/include/pw3270/actions.h b/src/include/pw3270/actions.h
index fd0eb03..8fa7595 100644
--- a/src/include/pw3270/actions.h
+++ b/src/include/pw3270/actions.h
@@ -44,6 +44,7 @@
G_BEGIN_DECLS
+ /*
//
// Abstract action
//
@@ -126,7 +127,9 @@
/// @brief Get lib3270 session handle.
H3270 * pw3270_action_get_session(GAction *action);
+ */
+ /*
//
// "Simple" action
//
@@ -176,6 +179,7 @@
/// @brief Update simple action from LIB3270's property description.
void pw3270_simple_action_set_lib3270_property(pw3270SimpleAction *action, const LIB3270_PROPERTY * property);
+ */
//
// Action view
diff --git a/src/objects/actions/abstract.c b/src/objects/actions/abstract.c
index 5851dbe..8ad9eae 100644
--- a/src/objects/actions/abstract.c
+++ b/src/objects/actions/abstract.c
@@ -30,6 +30,8 @@
#include "private.h"
#include
+ /*
+
static void pw3270_action_iface_init(GActionInterface *iface);
static void pw3270Action_class_init(pw3270ActionClass *klass);
static void pw3270Action_init(pw3270Action *action);
@@ -68,17 +70,6 @@
PROP_TOOLTIP
};
- /*
- enum {
- SIGNAL_CHANGE_STATE,
- NR_SIGNALS
- };
-
- static guint action_signals[NR_SIGNALS];
-
- */
-
-
G_DEFINE_TYPE_WITH_CODE(pw3270Action, pw3270Action, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(G_TYPE_ACTION, pw3270_action_iface_init))
void pw3270_action_iface_init(GActionInterface *iface) {
@@ -188,19 +179,6 @@
g_object_class_install_property (object_class, PROP_STATE, klass->properties.state);
- /*
- // Install signals
- action_signals[SIGNAL_CHANGE_STATE] =
- g_signal_new(
- I_("change_state"),
- G_TYPE_ACTION,
- G_SIGNAL_RUN_LAST | G_SIGNAL_MUST_COLLECT,
- 0, NULL, NULL,
- NULL,
- G_TYPE_NONE, 1,
- G_TYPE_VARIANT
- );
- */
}
void pw3270Action_init(pw3270Action *action) {
@@ -580,3 +558,4 @@
return pixbuf;
}
+*/
diff --git a/src/objects/actions/simple.c b/src/objects/actions/simple.c
index d86fa31..05af5a4 100644
--- a/src/objects/actions/simple.c
+++ b/src/objects/actions/simple.c
@@ -35,6 +35,7 @@
#include "private.h"
#include
+ /*
static void pw3270SimpleAction_class_init(pw3270SimpleActionClass *klass);
static void pw3270SimpleAction_init(pw3270SimpleAction *action);
static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to);
@@ -175,4 +176,4 @@
pw3270_action_notify_enabled(object);
}
-
+ */
diff --git a/src/objects/actions/tools.c b/src/objects/actions/tools.c
new file mode 100644
index 0000000..26af660
--- /dev/null
+++ b/src/objects/actions/tools.c
@@ -0,0 +1,118 @@
+/*
+ * "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 "private.h"
+ #include
+
+ gchar * g_action_get_text(GAction *action, const gchar * property_name) {
+ gchar *rc = NULL;
+
+ GValue value = G_VALUE_INIT;
+ g_value_init(&value, G_TYPE_STRING);
+ g_object_get_property(G_OBJECT(action),property_name,&value);
+
+ const gchar * text = g_value_get_string(&value);
+ if(text)
+ rc = g_strdup(text);
+
+ g_value_unset(&value);
+
+ return rc;
+
+ }
+
+ gchar * g_action_get_tooltip(GAction *action) {
+ return g_action_get_text(action, "tooltip");
+ }
+
+ gchar * g_action_get_label(GAction *action) {
+ return g_action_get_text(action, "label");
+ }
+
+ gchar * g_action_get_icon_name(GAction *action) {
+ return g_action_get_text(action, "icon-name");
+ }
+
+ static GdkPixbuf * pixbuf_from_icon_name(GValue *value, gint width, gint G_GNUC_UNUSED(height), GtkIconLookupFlags flags) {
+
+ const gchar * icon_name = g_value_get_string(value);
+
+ if(!icon_name)
+ return NULL;
+
+ return gtk_icon_theme_load_icon(
+ gtk_icon_theme_get_default(),
+ icon_name,
+ width,
+ flags, // GTK_ICON_LOOKUP_GENERIC_FALLBACK,
+ NULL
+ );
+
+ }
+
+ GdkPixbuf * g_action_get_pixbuf(GAction *action, GtkIconSize icon_size, GtkIconLookupFlags flags) {
+
+ struct Properties {
+ const gchar * name;
+ GType value_type;
+ GdkPixbuf * (*translate)(GValue *value, gint width, gint height, GtkIconLookupFlags flags);
+ } properties[] = {
+ {
+ .name = "icon-name",
+ .value_type = G_TYPE_STRING,
+ .translate = pixbuf_from_icon_name
+ }
+ };
+
+ size_t ix;
+ GdkPixbuf * pixbuf = NULL;
+ gint width, height;
+
+ gtk_icon_size_lookup(icon_size,&width,&height);
+
+ for(ix = 0; ix < G_N_ELEMENTS(properties) && !pixbuf; ix++) {
+
+ GParamSpec *spec = g_object_class_find_property(G_OBJECT_GET_CLASS(action),properties[ix].name);
+ if(spec && spec->value_type == properties[ix].value_type && (spec->flags & G_PARAM_READABLE) != 0) {
+
+ GValue value = G_VALUE_INIT;
+ g_value_init(&value, properties[ix].value_type);
+
+ g_object_get_property(G_OBJECT(action),properties[ix].name,&value);
+
+ pixbuf = properties[ix].translate(&value,width,height,flags);
+
+ g_value_unset(&value);
+
+ }
+
+ }
+
+ return pixbuf;
+ }
diff --git a/src/objects/window/actions/connect.c b/src/objects/window/actions/connect.c
index 3588b8a..eb50dc9 100644
--- a/src/objects/window/actions/connect.c
+++ b/src/objects/window/actions/connect.c
@@ -34,6 +34,7 @@
#include
#include
+ #include
#include "../private.h"
static void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) {
@@ -43,12 +44,20 @@
}
- GAction * pw3270_action_connect_new(void) {
+ GAction * pw3270_action_connect_new(void) {
- pw3270SimpleAction * action = pw3270_simple_action_new_from_lib3270(lib3270_action_get_by_name("reconnect"),"connect");
+ V3270SimpleAction *action = v3270_simple_action_new();
+
+ const LIB3270_PROPERTY * property = (const LIB3270_PROPERTY *) lib3270_action_get_by_name("reconnect");
+ if(property) {
+ action->icon_name = property->icon;
+ action->group.id = property->group;
+ }
+
+ action->name = "connect";
action->parent.activate = activate;
action->label = _("Connect");
- action->tooltip = N_("Connect to host");
+ action->tooltip = _("Connect to host");
return G_ACTION(action);
diff --git a/src/objects/window/window.c b/src/objects/window/window.c
index a2139e1..6843b25 100644
--- a/src/objects/window/window.c
+++ b/src/objects/window/window.c
@@ -522,14 +522,8 @@
GAction * action = g_action_map_lookup_action(G_ACTION_MAP(window), actions[ix]);
- if(action) {
-
- if(V3270_IS_ACTION(action)) {
- v3270_action_set_terminal_widget(action,terminal);
- } else if(PW3270_IS_ACTION(action)) {
- pw3270_action_set_terminal_widget(action,terminal);
- }
-
+ if(action && V3270_IS_ACTION(action)) {
+ v3270_action_set_terminal_widget(action,terminal);
}
}
--
libgit2 0.21.2