diff --git a/pw3270.cbp b/pw3270.cbp
index d311e6b..0399f45 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -50,6 +50,9 @@
+
+
+
diff --git a/src/include/pw3270.h b/src/include/pw3270.h
index 1a06849..3e4e37c 100644
--- a/src/include/pw3270.h
+++ b/src/include/pw3270.h
@@ -52,6 +52,9 @@
#define I_(string) g_intern_static_string (string)
+ void pw3270_load_placeholders(GtkBuilder * builder);
+
+
G_END_DECLS
#endif // PW3270_H_INCLUDED
diff --git a/src/include/pw3270/actions.h b/src/include/pw3270/actions.h
index 150f1d8..0f71357 100644
--- a/src/include/pw3270/actions.h
+++ b/src/include/pw3270/actions.h
@@ -169,6 +169,8 @@
/// @brief New simple action from LIB3270's action name.
pw3270SimpleAction * pw3270_simple_action_new_from_name(const gchar *source_name, const gchar *name);
+ /// @brief Update simple action from LIB3270's property description.
+ void pw3270_simple_action_set_lib3270_property(pw3270SimpleAction *action, const LIB3270_PROPERTY * property);
//
// Dialog action
@@ -197,7 +199,7 @@
typedef struct _v3270PropertyAction {
- pw3270Action parent;
+ pw3270SimpleAction parent;
GParamSpec *pspec;
@@ -205,7 +207,7 @@
typedef struct _v3270PropertyActionClass {
- pw3270ActionClass parent_class;
+ pw3270SimpleActionClass parent_class;
} v3270PropertyActionClass;
diff --git a/src/main/placeholders.c b/src/main/placeholders.c
new file mode 100644
index 0000000..d2822d2
--- /dev/null
+++ b/src/main/placeholders.c
@@ -0,0 +1,70 @@
+/*
+ * "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. 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 main.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)
+ *
+ */
+
+ /**
+ * @brief PW3270 Placeholders management.
+ *
+ */
+
+ #include "private.h"
+ #include
+ #include
+ #include
+
+/*---[ Implement ]----------------------------------------------------------------------------------*/
+
+ void pw3270_load_placeholders(GtkBuilder * builder) {
+
+ GObject * placeholder = gtk_builder_get_object(builder, "font-select-placeholder");
+
+ if(placeholder && G_IS_MENU(placeholder)) {
+
+ GMenu * font_menu = G_MENU(placeholder);
+
+ gint n_families;
+ PangoFontFamily **families;
+ pango_context_list_families(gdk_pango_context_get_for_screen(gdk_screen_get_default()),&families, &n_families);
+
+ size_t ix;
+ for(ix=0; ix < (size_t) n_families; ix++)
+ {
+ if(!pango_font_family_is_monospace(families[ix]))
+ continue;
+
+ const gchar * family = pango_font_family_get_name(families[ix]);
+ g_autofree gchar * detailed_action = g_strconcat("win.font-family::",family,NULL);
+ g_menu_append(font_menu,family,detailed_action);
+
+ }
+
+ }
+
+
+ }
diff --git a/src/objects/actions/simple.c b/src/objects/actions/simple.c
index 0cb6d30..e8df206 100644
--- a/src/objects/actions/simple.c
+++ b/src/objects/actions/simple.c
@@ -101,6 +101,16 @@
}
+ void pw3270_simple_action_set_lib3270_property(pw3270SimpleAction *action, const LIB3270_PROPERTY * property) {
+
+ if(property) {
+ action->parent.name = property->name;
+ action->tooltip = property->summary ? property->summary : property->description;
+ action->group.id = property->group;
+ }
+
+ }
+
pw3270SimpleAction * pw3270_simple_action_new_from_lib3270(const LIB3270_ACTION * definition, const gchar *name) {
if(!definition)
@@ -110,10 +120,11 @@
pw3270SimpleAction * action = (pw3270SimpleAction *) g_object_new(PW3270_TYPE_SIMPLE_ACTION, NULL);
+ pw3270_simple_action_set_lib3270_property(action, (const LIB3270_PROPERTY *) definition);
+
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;
diff --git a/src/objects/actions/v3270/property.c b/src/objects/actions/v3270/property.c
index 3674a6b..9f89ed6 100644
--- a/src/objects/actions/v3270/property.c
+++ b/src/objects/actions/v3270/property.c
@@ -40,21 +40,22 @@
#include
#include
#include
+ #include
static void v3270PropertyAction_class_init(v3270PropertyActionClass *klass);
static void v3270PropertyAction_init(v3270PropertyAction *action);
static GVariant * get_state(GAction *action, GtkWidget *terminal);
static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to);
- G_DEFINE_TYPE(v3270PropertyAction, v3270PropertyAction, PW3270_TYPE_ACTION);
+ G_DEFINE_TYPE(v3270PropertyAction, v3270PropertyAction, PW3270_TYPE_SIMPLE_ACTION);
void v3270PropertyAction_class_init(v3270PropertyActionClass *klass) {
- klass->parent_class.change_widget = change_widget;
+ klass->parent_class.parent_class.change_widget = change_widget;
}
static void v3270PropertyAction_init(v3270PropertyAction *action) {
- action->parent.get_state_property = get_state;
+ action->parent.parent.get_state_property = get_state;
}
@@ -76,10 +77,11 @@
case G_TYPE_STRING:
result = g_variant_new_string(g_value_get_string(&value));
break;
- /*
+
case G_TYPE_BOOLEAN:
result = g_variant_new_boolean(g_value_get_boolean(&value));
break;
+ /*
case G_TYPE_INT:
result = g_variant_new_int32(g_value_get_int(&value));
@@ -100,17 +102,6 @@
g_value_unset (&value);
-#ifdef DEBUG
- if(result)
- {
- debug("Action %s set to \"%s\"",g_action_get_name(object),g_variant_get_string(result,NULL));
- }
- else
- {
- debug("Action %s set to \"%s\"",g_action_get_name(object),"NULL");
- }
-#endif // DEBUG
-
return result;
}
@@ -128,12 +119,27 @@
{
case G_TYPE_UINT:
g_value_set_uint(&value,atoi(g_variant_get_string(parameter,NULL)));
+
break;
- /*
case G_TYPE_BOOLEAN:
+
+ if(parameter) {
+
+ if(g_variant_is_of_type(parameter,G_VARIANT_TYPE_BOOLEAN))
+ g_value_set_boolean(&value,g_variant_get_boolean(parameter));
+ else
+ g_value_set_boolean(&value,atoi(g_variant_get_string(parameter,NULL)) != 0);
+
+ } else {
+
+ debug("%s: TODO: Toggle property",__FUNCTION__);
+
+ }
+
break;
+ /*
case G_TYPE_INT:
break;
@@ -170,6 +176,20 @@
GParamSpec *pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(widget), property_name);
+ if(!pspec) {
+
+ g_warning(
+ "Can't find property '%s::%s'",
+ G_OBJECT_TYPE_NAME(G_OBJECT(widget)),
+ property_name
+ );
+
+ return NULL;
+
+ }
+
+ debug("%s: pspec(%s)=%p",__FUNCTION__,property_name,pspec);
+
if(~pspec->flags & G_PARAM_READABLE || ~pspec->flags & G_PARAM_WRITABLE || pspec->flags & G_PARAM_CONSTRUCT_ONLY) {
g_warning(
@@ -183,11 +203,20 @@
v3270PropertyAction * action = (v3270PropertyAction *) g_object_new(V3270_TYPE_PROPERTY_ACTION, NULL);
- action->parent.name = pspec->name;
- action->parent.types.state = G_VARIANT_TYPE_STRING;
- action->parent.types.parameter = G_VARIANT_TYPE_STRING;
- action->parent.activate = activate;
- action->pspec = pspec;
+ pw3270_simple_action_set_lib3270_property(PW3270_SIMPLE_ACTION(action), lib3270_property_get_by_name(pspec->name));
+
+ action->parent.parent.name = g_param_spec_get_name(pspec);
+ action->parent.tooltip = g_param_spec_get_blurb(pspec);
+
+ if(pspec->value_type == G_TYPE_BOOLEAN) {
+ action->parent.parent.types.state = G_VARIANT_TYPE_BOOLEAN;
+ } else {
+ action->parent.parent.types.state = G_VARIANT_TYPE_STRING;
+ action->parent.parent.types.parameter = G_VARIANT_TYPE_STRING;
+ }
+
+ action->parent.parent.activate = activate;
+ action->pspec = pspec;
pw3270_action_set_terminal_widget(G_ACTION(action), widget);
diff --git a/src/objects/application/application.c b/src/objects/application/application.c
index 6b5935e..47bf497 100644
--- a/src/objects/application/application.c
+++ b/src/objects/application/application.c
@@ -32,6 +32,7 @@
*/
#include "private.h"
+ #include
#include
#include
@@ -246,14 +247,6 @@
.activate = pw3270_application_generic_activated,
},
- /*
- {
- .name = "model-number",
- .activate = model_cb,
- .parameter_type = "s"
- }
- */
-
};
g_action_map_add_action_entries(
@@ -274,46 +267,36 @@
if(pw3270_application_get_ui_style(application) == PW3270_UI_STYLE_CLASSICAL)
gtk_application_set_menubar(GTK_APPLICATION (application), G_MENU_MODEL(gtk_builder_get_object (builder, "menubar")));
+ pw3270_load_placeholders(builder);
+
g_object_unref(builder);
}
void activate(GApplication *application) {
+ size_t ix;
+
GtkWidget * window = pw3270_application_window_new(GTK_APPLICATION(application));
// Create terminal widget & associated widget
GtkWidget * terminal = pw3270_terminal_new(window);
- /*
- GAction * action = G_ACTION(v3270_property_action_new(terminal,"model_number"));
- if(action) {
- debug("Adding window action \"%s\"",g_action_get_name(action));
- g_action_map_add_action(G_ACTION_MAP(window),action);
- }
- */
-
- // https://developer.gnome.org/gnome-devel-demos/stable/menubar.vala.html.en
-
- /*
- static const GActionEntry actions[] = {
-
- {
- .name = "model-number",
- .activate = model_cb,
- .parameter_type = "s",
- .state = "2"
- }
-
+ // Create property actions
+ static const gchar * properties[] = {
+ "model-number",
+ "font-family",
+ "dynamic-font-spacing"
};
- g_action_map_add_action_entries(G_ACTION_MAP(window),actions,G_N_ELEMENTS(actions),NULL);
- */
+ for(ix = 0; ix < G_N_ELEMENTS(properties); ix++) {
- g_action_map_add_action(
- G_ACTION_MAP(window),
- v3270_property_action_new(terminal,"model-number")
- );
+ g_action_map_add_action(
+ G_ACTION_MAP(window),
+ v3270_property_action_new(terminal,properties[ix])
+ );
+
+ }
// Present the new window
pw3270_window_set_current_page(window,0);
diff --git a/src/objects/window/window.c b/src/objects/window/window.c
index b7ea0e5..6532d70 100644
--- a/src/objects/window/window.c
+++ b/src/objects/window/window.c
@@ -170,6 +170,8 @@
GtkWidget * pw3270_application_window_new(GtkApplication * application) {
+ size_t ix;
+
const gchar * title = _( "IBM 3270 Terminal emulator" );
g_autoptr(GSettings) settings = pw3270_application_get_settings(G_APPLICATION(application));
@@ -226,7 +228,6 @@
g_warning("Unexpected UI");
}
-
g_object_unref(builder);
}
diff --git a/ui/application.xml b/ui/application.xml
index 5f042a9..e220acb 100644
--- a/ui/application.xml
+++ b/ui/application.xml
@@ -245,8 +245,6 @@
Screen size
-
-
-
Model 2 - 80x24
win.model-number
--
libgit2 0.21.2