diff --git a/.gitignore b/.gitignore
index da755d0..e3ef52f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,3 +55,5 @@ certs
src/include/lib3270
*.desktop
vgcore.*
+gschemas.compiled
+*.gschema.xml
diff --git a/pw3270.cbp b/pw3270.cbp
index daadc23..59a6274 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -51,6 +51,9 @@
+
+
+
diff --git a/schemas/application.gschema.xml.in b/schemas/application.gschema.xml.in
index bc2c53d..4aeb215 100644
--- a/schemas/application.gschema.xml.in
+++ b/schemas/application.gschema.xml.in
@@ -1,12 +1,36 @@
-
+
1
@@ -14,6 +38,12 @@
The ID of the current user interface style
+
+ true
+ Enable top window subtitle
+ If TRUE, reserve space for a subtitle, even if none is currently set.
+
+
diff --git a/src/include/pw3270.h b/src/include/pw3270.h
index b7ce97f..470bbb3 100644
--- a/src/include/pw3270.h
+++ b/src/include/pw3270.h
@@ -49,4 +49,6 @@
/* not really I18N-related, but also a string marker macro */
#define I_(string) g_intern_static_string (string)
+ G_GNUC_INTERNAL GSettings * pw3270_get_settings(void);
+
#endif // PW3270_H_INCLUDED
diff --git a/src/main/main.c b/src/main/main.c
index 1946c52..ab2b98b 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -45,39 +45,8 @@ int main (int argc, char **argv) {
GtkApplication *app;
int status;
-/*
-#ifdef DEBUG
- {
- GError * error = NULL;
- GSettingsSchemaSource * source =
- g_settings_schema_source_new_from_directory(
- ".",
- NULL,
- TRUE,
- &error
- );
-
- g_assert_no_error(error);
-
- GSettingsSchema * schema =
- g_settings_schema_source_lookup(
- source,
- "br.com.bb.pw3270",
- TRUE);
-
- g_settings_schema_source_unref(source);
-
- GSettings * settings = g_settings_new_full(schema, NULL, "/br/com/bb/pw3270/application/");
-
- debug("ui-style=%u",g_settings_get_uint(settings,"ui-style"));
-
- g_object_unref(settings);
- }
-#endif // DEBUG
-*/
-
-// app = pw3270_application_new("br.com.bb." G_STRINGIFY(PRODUCT_NAME),G_APPLICATION_HANDLES_OPEN);
- app = pw3270_application_new("br.com.bb.pw3270",G_APPLICATION_HANDLES_OPEN);
+ g_set_application_name(G_STRINGIFY(PRODUCT_NAME));
+ app = pw3270_application_new("br.com.bb." G_STRINGIFY(PRODUCT_NAME),G_APPLICATION_HANDLES_OPEN);
status = g_application_run(G_APPLICATION (app), argc, argv);
g_object_unref (app);
diff --git a/src/main/private.h b/src/main/private.h
index 6bce3ff..f0f0a0c 100644
--- a/src/main/private.h
+++ b/src/main/private.h
@@ -33,4 +33,8 @@
#include
+ #include
+ #include
+
+
#endif // PRIVATE_H_INCLUDED
diff --git a/src/main/tools.c b/src/main/tools.c
new file mode 100644
index 0000000..e9e799e
--- /dev/null
+++ b/src/main/tools.c
@@ -0,0 +1,73 @@
+/*
+ * "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 Misc tools for pw3270 application.
+ *
+ */
+
+ #include "private.h"
+
+/*---[ Implement ]----------------------------------------------------------------------------------*/
+
+ GSettings * pw3270_get_settings() {
+
+#ifdef DEBUG
+ GError * error = NULL;
+ GSettingsSchemaSource * source =
+ g_settings_schema_source_new_from_directory(
+ ".",
+ NULL,
+ TRUE,
+ &error
+ );
+
+ g_assert_no_error(error);
+
+ GSettingsSchema * schema =
+ g_settings_schema_source_lookup(
+ source,
+ "br.com.bb." PACKAGE_NAME,
+ TRUE);
+
+ g_settings_schema_source_unref(source);
+
+ g_autofree gchar * path = g_strconcat("/apps/" PACKAGE_NAME "/", g_get_application_name(),"/",NULL);
+
+ debug("path=%s",path);
+ return g_settings_new_full(schema, NULL, path);
+
+#else
+
+ #error TODO!
+
+#endif // DEBUG
+
+ }
diff --git a/src/objects/actions/abstract.c b/src/objects/actions/abstract.c
index 46144f0..f833f5d 100644
--- a/src/objects/actions/abstract.c
+++ b/src/objects/actions/abstract.c
@@ -89,6 +89,8 @@
GObjectClass *object_class = G_OBJECT_CLASS(klass);
+ debug("%s",__FUNCTION__);
+
klass->change_widget = change_widget;
klass->get_enabled = get_enabled;
klass->activate = activate;
@@ -154,8 +156,8 @@
// Install signals
action_signals[SIGNAL_CHANGE_STATE] =
g_signal_new(
- I_("change-state"),
- G_TYPE_SIMPLE_ACTION,
+ I_("change_state"),
+ G_TYPE_ACTION,
G_SIGNAL_RUN_LAST | G_SIGNAL_MUST_COLLECT,
0, NULL, NULL,
NULL,
@@ -202,8 +204,7 @@
}
-
- void pw3270_action_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) {
+ void pw3270_action_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec G_GNUC_UNUSED(*pspec)) {
GAction *action = G_ACTION(object);
@@ -236,7 +237,7 @@
}
- void pw3270_action_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) {
+ void pw3270_action_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec G_GNUC_UNUSED(*pspec)) {
// debug("%s(%d)",__FUNCTION__,prop_id);
@@ -306,8 +307,7 @@
}
- GVariant * pw3270_action_get_state_hint(GAction *action) {
- debug("%s",__FUNCTION__);
+ GVariant * pw3270_action_get_state_hint(GAction G_GNUC_UNUSED(*action)) {
return NULL;
}
@@ -351,7 +351,7 @@
}
- void pw3270_action_set_enabled(GAction *object, gboolean state) {
+ void pw3270_action_set_enabled(GAction *object, gboolean G_GNUC_UNUSED(state)) {
g_object_notify_by_pspec(G_OBJECT(object), PW3270_ACTION_GET_CLASS(object)->properties.enabled);
}
@@ -401,8 +401,8 @@
}
- gboolean get_enabled(GAction *object, GtkWidget *terminal) {
- debug("%s(%s)",__FUNCTION__,pw3270_action_get_name(object));
+ gboolean get_enabled(GAction G_GNUC_UNUSED(*object), GtkWidget G_GNUC_UNUSED(*terminal)) {
+// debug("%s(%s)",__FUNCTION__,pw3270_action_get_name(object));
return TRUE;
}
diff --git a/src/objects/actions/lib3270/pakey.c b/src/objects/actions/lib3270/pakey.c
index 2c63cd1..44b3eda 100644
--- a/src/objects/actions/lib3270/pakey.c
+++ b/src/objects/actions/lib3270/pakey.c
@@ -55,9 +55,9 @@
G_DEFINE_TYPE(Lib3270PaAction, Lib3270PaAction, PW3270_TYPE_ACTION);
- static gboolean get_enabled(GAction *action, GtkWidget *terminal) {
+ static gboolean get_enabled(GAction G_GNUC_UNUSED(*action), GtkWidget *terminal) {
- debug("%s(%s)",__FUNCTION__,pw3270_action_get_name(action));
+// debug("%s(%s)",__FUNCTION__,pw3270_action_get_name(action));
if(terminal)
return lib3270_is_connected(v3270_get_session(terminal)) > 0 ? TRUE: FALSE;
@@ -94,7 +94,7 @@
}
- static const GVariantType * get_parameter_type(GAction *action)
+ static const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*action))
{
return G_VARIANT_TYPE_UINT16;
}
@@ -110,7 +110,7 @@
}
- void Lib3270PaAction_init(Lib3270PaAction *action) {
+ void Lib3270PaAction_init(Lib3270PaAction G_GNUC_UNUSED(*action)) {
}
GAction * pw3270_action_new_pakey(void) {
diff --git a/src/objects/actions/lib3270/pfkey.c b/src/objects/actions/lib3270/pfkey.c
index f74cdfe..c5d7a25 100644
--- a/src/objects/actions/lib3270/pfkey.c
+++ b/src/objects/actions/lib3270/pfkey.c
@@ -55,9 +55,9 @@
G_DEFINE_TYPE(Lib3270PfAction, Lib3270PfAction, PW3270_TYPE_ACTION);
- static gboolean get_enabled(GAction *action, GtkWidget *terminal) {
+ static gboolean get_enabled(GAction G_GNUC_UNUSED(*action), GtkWidget *terminal) {
- debug("%s(%s)",__FUNCTION__,pw3270_action_get_name(action));
+// debug("%s(%s)",__FUNCTION__,pw3270_action_get_name(action));
if(terminal)
return lib3270_is_connected(v3270_get_session(terminal)) > 0 ? TRUE: FALSE;
@@ -94,8 +94,7 @@
}
- static const GVariantType * get_parameter_type(GAction *action)
- {
+ static const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*action)) {
return G_VARIANT_TYPE_UINT16;
}
@@ -110,7 +109,7 @@
}
- void Lib3270PfAction_init(Lib3270PfAction *action) {
+ void Lib3270PfAction_init(Lib3270PfAction G_GNUC_UNUSED(*action)) {
}
GAction * pw3270_action_new_pfkey(void) {
diff --git a/src/objects/actions/memcheck.sh b/src/objects/actions/memcheck.sh
new file mode 100755
index 0000000..ebf97bc
--- /dev/null
+++ b/src/objects/actions/memcheck.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+valgrind \
+ --leak-check=full \
+ --track-origins=yes \
+ --gen-suppressions=all \
+ --suppressions=valgrind.suppression \
+ .bin/Debug/PW3270\ Actions
+
diff --git a/src/objects/actions/valgrind.suppression b/src/objects/actions/valgrind.suppression
new file mode 100644
index 0000000..a1efd7a
--- /dev/null
+++ b/src/objects/actions/valgrind.suppression
@@ -0,0 +1,162 @@
+{
+ libcrypto_BIO_read
+ Memcheck:Cond
+ ...
+ fun:BIO_read
+}
+
+{
+ libcrypt_FIPS_selftest
+ Memcheck:Cond
+ ...
+ fun:FIPS_selftest
+}
+
+{
+ libcrypt_FIPS_mode_set
+ Memcheck:Cond
+ ...
+ fun:FIPS_mode_set
+}
+
+{
+ libcrypt_BIO_new_mem_buf
+ Memcheck:Cond
+ ...
+ fun:BIO_new_mem_buf
+}
+
+
+{
+ g_type_register_fundamental
+ Memcheck:Leak
+ ...
+ fun:g_type_register_fundamental
+}
+
+{
+ glib_dl_init
+ Memcheck:Leak
+ ...
+ fun:_dl_init
+}
+
+{
+ pango_itemize_with_base_dir
+ Memcheck:Leak
+ ...
+ fun:pango_itemize_with_base_dir
+}
+
+{
+ fontconfig_FcDefaultSubstitute
+ Memcheck:Leak
+ ...
+ fun:FcDefaultSubstitute
+}
+
+{
+ fontconfig_FcConfigParseAndLoad
+ Memcheck:Leak
+ ...
+ fun:FcConfigParseAndLoad
+}
+
+{
+ fontconfig_FcFontMatch
+ Memcheck:Leak
+ ...
+ fun:FcFontMatch
+}
+
+{
+ g_type_register_static
+ Memcheck:Leak
+ ...
+ fun:g_type_register_static
+}
+
+{
+ g_thread_pool_push
+ Memcheck:Leak
+ ...
+ fun:g_task_run_in_thread
+}
+
+{
+ g_bus_get_sync
+ Memcheck:Leak
+ ...
+ fun:g_bus_get_sync
+}
+
+{
+ g_type_add_interface_static
+ Memcheck:Leak
+ ...
+ fun:g_type_add_interface_static
+}
+
+{
+ g_type_create_instance
+ Memcheck:Leak
+ ...
+ fun:g_type_create_instance
+}
+
+{
+ fontconfig_FcPatternDuplicate
+ Memcheck:Leak
+ ...
+ fun:FcPatternDuplicate
+}
+
+{
+ gtk_style_context_set_state
+ Memcheck:Leak
+ ...
+ fun:gtk_style_context_set_state
+}
+
+{
+ g_param_spec_flags
+ Memcheck:Leak
+ ...
+ fun:g_param_spec_flags
+}
+
+{
+ gtk_style_new
+ Memcheck:Leak
+ ...
+ fun:gtk_style_new
+}
+
+{
+ libcrypto_BIO_read
+ Memcheck:Cond
+ fun:BIO_read
+}
+
+{
+ cairo_mask
+ Memcheck:Cond
+ ...
+ fun:cairo_mask
+}
+
+{
+ gtk_css_dimension_value_new
+ Memcheck:Leak
+ ...
+ fun:gtk_css_dimension_value_new
+}
+
+{
+ gtk_style_constructed
+ Memcheck:Leak
+ ...
+ fun:gtk_style_constructed
+}
+
+
diff --git a/src/objects/window/application.c b/src/objects/window/application.c
index 18a30c5..22819e7 100644
--- a/src/objects/window/application.c
+++ b/src/objects/window/application.c
@@ -127,45 +127,10 @@
#endif // _WIN32
// Bind properties
- GSettings * settings = NULL;
-
-#ifdef DEBUG
- {
- GError * error = NULL;
- GSettingsSchemaSource * source =
- g_settings_schema_source_new_from_directory(
- ".",
- NULL,
- TRUE,
- &error
- );
-
- g_assert_no_error(error);
-
- GSettingsSchema * schema =
- g_settings_schema_source_lookup(
- source,
- "br.com.bb." G_STRINGIFY(PRODUCT_NAME),
- TRUE);
-
- g_settings_schema_source_unref(source);
-
- settings = g_settings_new_full(schema, NULL, "/br/com/bb/" G_STRINGIFY(PRODUCT_NAME) "/application/");
-
- }
-#else
-
- #error TODO!
-
-#endif // DEBUG
+ g_autoptr(GSettings) settings = pw3270_get_settings();
if(settings) {
-
g_settings_bind(settings, "ui-style", app, "ui-style", G_SETTINGS_BIND_DEFAULT);
-
-
- g_object_unref(settings);
-
}
}
diff --git a/src/objects/window/terminal.c b/src/objects/window/terminal.c
index f4847f5..a658d37 100644
--- a/src/objects/window/terminal.c
+++ b/src/objects/window/terminal.c
@@ -50,7 +50,11 @@
}
- static gboolean on_terminal_focus(GtkWidget *terminal, GdkEvent *event, GtkWindow * window) {
+ static gboolean on_terminal_focus(GtkWidget *terminal, GdkEvent G_GNUC_UNUSED(*event), GtkWindow * window) {
+
+ if(gtk_window_get_default_widget(window) == terminal) {
+ return FALSE;
+ }
// Store the active terminal widget.
gtk_widget_grab_default(terminal);
@@ -62,6 +66,22 @@
pw3270_window_set_subtitle(GTK_WIDGET(window), v3270_is_connected(terminal) ? _("Connected to host") : _("Disconnected from host"));
+ // Update actions
+ size_t ix;
+ gchar ** actions = g_action_group_list_actions(G_ACTION_GROUP(window));
+
+ for(ix = 0; actions[ix]; ix++) {
+
+ GAction * action = g_action_map_lookup_action(G_ACTION_MAP(window), actions[ix]);
+
+ if(action && PW3270_IS_ACTION(action)) {
+ pw3270_action_set_terminal_widget(action,terminal);
+ }
+
+ }
+
+ g_strfreev(actions);
+
return FALSE;
}
@@ -92,7 +112,7 @@
}
- static void on_close_tab(GtkButton *button, GtkWidget *terminal) {
+ static void on_close_tab(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) {
GtkNotebook * notebook = GTK_NOTEBOOK(gtk_widget_get_parent(terminal));
gtk_notebook_remove_page(notebook,gtk_notebook_page_num(notebook, terminal));
diff --git a/src/objects/window/window.c b/src/objects/window/window.c
index 68ad0c8..07e0d3e 100644
--- a/src/objects/window/window.c
+++ b/src/objects/window/window.c
@@ -28,16 +28,18 @@
*/
#include "private.h"
+ #include
#include
#include
+ #include
G_DEFINE_TYPE(pw3270ApplicationWindow, pw3270ApplicationWindow, GTK_TYPE_APPLICATION_WINDOW);
- static void pw3270ApplicationWindow_class_init(pw3270ApplicationWindowClass *klass) {
+ static void pw3270ApplicationWindow_class_init(pw3270ApplicationWindowClass G_GNUC_UNUSED(*klass)) {
}
- void on_page_changed(GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer user_data) {
+ void on_page_changed(GtkNotebook *notebook, GtkWidget G_GNUC_UNUSED(*child), guint G_GNUC_UNUSED(page_num), gpointer G_GNUC_UNUSED(user_data)) {
gtk_notebook_set_show_tabs(notebook,gtk_notebook_get_n_pages(notebook) > 1);
}
@@ -63,6 +65,11 @@
gtk_container_add(GTK_CONTAINER(widget),GTK_WIDGET(vBox));
//
+ // Setup tn3270 actions.
+ //
+ pw3270_window_add_actions(GTK_WIDGET(widget));
+
+ //
// Setup Window actions.
//
static GActionEntry actions[] = {
@@ -97,6 +104,8 @@
const gchar * title = _( "IBM 3270 Terminal emulator" );
+ g_autoptr(GSettings) settings = pw3270_get_settings();
+
g_return_val_if_fail(GTK_IS_APPLICATION(application), NULL);
pw3270ApplicationWindow * window =
g_object_new(
@@ -124,8 +133,10 @@
gtk_header_bar_set_show_close_button(header,TRUE);
gtk_header_bar_set_title(header,title);
- // gtk_header_bar_set_subtitle(header,_("Disconnected from host"));
- gtk_header_bar_set_has_subtitle(header,TRUE);
+ if(settings)
+ g_settings_bind(settings, "has-subtitle", header, "has-subtitle", G_SETTINGS_BIND_DEFAULT);
+ else
+ gtk_header_bar_set_has_subtitle(header,TRUE);
// Create gear button
// https://wiki.gnome.org/Initiatives/GnomeGoals/GearIcons
diff --git a/ui/application.xml b/ui/application.xml
index d875c0f..ca9d9de 100644
--- a/ui/application.xml
+++ b/ui/application.xml
@@ -1,4 +1,32 @@
+