diff --git a/pw3270.cbp b/pw3270.cbp
index 65c0c14..903da14 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -250,6 +250,9 @@
+
+
+
diff --git a/src/include/pw3270.h b/src/include/pw3270.h
index 1c35265..93d46c4 100644
--- a/src/include/pw3270.h
+++ b/src/include/pw3270.h
@@ -56,6 +56,7 @@
LIB3270_EXPORT gboolean pw3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix);
LIB3270_EXPORT H3270 * pw3270_get_session(GtkWidget *widget);
LIB3270_EXPORT GtkWidget * pw3270_get_terminal_widget(GtkWidget *widget);
+ LIB3270_EXPORT gchar * pw3270_build_filename(GtkWidget *widget, const gchar *first_element, ...);
G_END_DECLS
diff --git a/src/pw3270/Makefile.in b/src/pw3270/Makefile.in
index 3c660f5..26dd6ae 100644
--- a/src/pw3270/Makefile.in
+++ b/src/pw3270/Makefile.in
@@ -56,11 +56,12 @@ include uiparser/sources.mak
#---[ Targets ]----------------------------------------------------------------
-APP_SOURCES= main.c window.c actions.c fonts.c dialog.c print.c colors.c \
- filetransfer.c \
- $(foreach SRC, $(UI_PARSER_SRC), uiparser/$(SRC))
+APP_SOURCES= main.c
-LIB_SOURCES= $(foreach SRC, $(V3270_SRC), v3270/$(SRC)) \
+LIB_SOURCES= window.c actions.c fonts.c dialog.c print.c colors.c \
+ filetransfer.c tools.c \
+ $(foreach SRC, $(UI_PARSER_SRC), uiparser/$(SRC)) \
+ $(foreach SRC, $(V3270_SRC), v3270/$(SRC)) \
$(foreach SRC, $(COMMON_SRC), common/$(SRC))
DEPENDS=*.h common/*.h uiparser/*.h v3270/*.h $(GLOBAL_DEPS)
diff --git a/src/pw3270/common/common.h.in b/src/pw3270/common/common.h.in
index fd23d65..4da7532 100644
--- a/src/pw3270/common/common.h.in
+++ b/src/pw3270/common/common.h.in
@@ -54,22 +54,6 @@
#define PACKAGE_NAME "@PACKAGE_NAME@"
#endif
- #if defined(_WIN32)
-
- #include
- #define DLL_EXPORT __declspec (dllexport)
-
- #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
-
- #define DLL_EXPORT
-
- #else
-
- #define DLL_EXPORT __attribute__((visibility("default"))) extern
-
- #endif
-
-
#define ENABLE_NLS
#ifndef GETTEXT_PACKAGE
@@ -86,26 +70,27 @@
#endif
// Configuration
- DLL_EXPORT void configuration_init(void);
- DLL_EXPORT void configuration_deinit(void);
+ void configuration_init(void);
+ void configuration_deinit(void);
- DLL_EXPORT gchar * get_string_from_config(const gchar *group, const gchar *key, const gchar *def);
- DLL_EXPORT gboolean get_boolean_from_config(const gchar *group, const gchar *key, gboolean def);
- DLL_EXPORT gint get_integer_from_config(const gchar *group, const gchar *key, gint def);
+ gchar * get_string_from_config(const gchar *group, const gchar *key, const gchar *def);
+ gboolean get_boolean_from_config(const gchar *group, const gchar *key, gboolean def);
+ gint get_integer_from_config(const gchar *group, const gchar *key, gint def);
- DLL_EXPORT void set_string_to_config(const gchar *group, const gchar *key, const gchar *fmt, ...);
- DLL_EXPORT void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val);
- DLL_EXPORT void set_integer_to_config(const gchar *group, const gchar *key, gint val);
+ void set_string_to_config(const gchar *group, const gchar *key, const gchar *fmt, ...);
+ void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val);
+ void set_integer_to_config(const gchar *group, const gchar *key, gint val);
- DLL_EXPORT gchar * build_data_filename(const gchar *first_element, ...);
+ gchar * build_data_filename(const gchar *first_element, ...);
+ gchar * filename_from_va(const gchar *first_element, va_list args);
#ifdef WIN_REGISTRY_ENABLED
- DLL_EXPORT gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired);
- DLL_EXPORT void registry_foreach(HKEY parent, const gchar *name,void (*cbk)(const gchar *key, const gchar *val, gpointer *user_data), gpointer *user_data);
- DLL_EXPORT void registry_set_double(HKEY hKey, const gchar *key, gdouble value);
- DLL_EXPORT gboolean registry_get_double(HKEY hKey, const gchar *key, gdouble *value);
+ gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired);
+ void registry_foreach(HKEY parent, const gchar *name,void (*cbk)(const gchar *key, const gchar *val, gpointer *user_data), gpointer *user_data);
+ void registry_set_double(HKEY hKey, const gchar *key, gdouble value);
+ gboolean registry_get_double(HKEY hKey, const gchar *key, gdouble *value);
#else
- DLL_EXPORT GKeyFile * get_application_keyfile(void);
+ GKeyFile * get_application_keyfile(void);
#endif // WIN_REGISTRY_ENABLED
#endif
diff --git a/src/pw3270/common/config.c b/src/pw3270/common/config.c
index 1bfcac4..84f1ace 100644
--- a/src/pw3270/common/config.c
+++ b/src/pw3270/common/config.c
@@ -380,10 +380,7 @@ gchar * get_last_error_msg(void)
void configuration_init(void)
{
-#ifdef WIN_REGISTRY_ENABLED
-
-#else
-
+#ifndef WIN_REGISTRY_ENABLED
gchar *filename = search_for_ini();
if(program_config)
@@ -554,11 +551,21 @@ void configuration_deinit(void)
gchar * build_data_filename(const gchar *first_element, ...)
{
+ va_list args;
+ gchar *path;
+
+ va_start(args, first_element);
+ path = filename_from_va(first_element,args);
+ va_end(args);
+ return path;
+}
+
+gchar * filename_from_va(const gchar *first_element, va_list args)
+{
static const gchar * datadir = NULL;
const gchar * appname[] = { g_get_application_name(), PACKAGE_NAME };
GString * result = NULL;
const gchar * element;
- va_list args;
if(datadir)
result = g_string_new(datadir);
@@ -627,16 +634,12 @@ gchar * build_data_filename(const gchar *first_element, ...)
g_warning("Unable to find application datadir, using %s",result->str);
}
- va_start(args, first_element);
-
for(element = first_element;element;element = va_arg(args, gchar *))
{
g_string_append_c(result,G_DIR_SEPARATOR);
g_string_append(result,element);
}
- va_end(args);
-
return g_string_free(result, FALSE);
}
diff --git a/src/pw3270/main.c b/src/pw3270/main.c
index da942af..774f261 100644
--- a/src/pw3270/main.c
+++ b/src/pw3270/main.c
@@ -75,7 +75,7 @@ static int initialize(void)
static void toplevel_setup(GtkWindow *window)
{
gchar * name = g_strdup_printf("%s.png",g_get_application_name());
- gchar * filename = build_data_filename(name,NULL);
+ gchar * filename = pw3270_build_filename(GTK_WIDGET(window),name,NULL);
gtk_window_set_type_hint(window,GDK_WINDOW_TYPE_HINT_NORMAL);
gtk_window_set_position(window,GTK_WIN_POS_CENTER);
@@ -200,7 +200,6 @@ int main(int argc, char *argv[])
if(!rc)
{
GtkSettings *settings = gtk_settings_get_default();
- configuration_init();
if(settings)
{
@@ -218,7 +217,6 @@ int main(int argc, char *argv[])
gtk_main();
- configuration_deinit();
}
return rc;
diff --git a/src/pw3270/tools.c b/src/pw3270/tools.c
new file mode 100644
index 0000000..7cf1a71
--- /dev/null
+++ b/src/pw3270/tools.c
@@ -0,0 +1,90 @@
+/*
+ * "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 tools.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)
+ *
+ */
+
+ #include "globals.h"
+
+#if defined WIN32
+ BOOL WINAPI DllMain(HANDLE hinst, DWORD dwcallpurpose, LPVOID lpvResvd);
+
+ static int libpw3270_loaded(void);
+ static int libpw3270_unloaded(void);
+
+#else
+ int libpw3270_loaded(void) __attribute__((constructor));
+ int libpw3270_unloaded(void) __attribute__((destructor));
+#endif
+
+/*--[ Implement ]------------------------------------------------------------------------------------*/
+
+#if defined WIN32
+
+BOOL WINAPI DllMain(HANDLE hinst, DWORD dwcallpurpose, LPVOID lpvResvd)
+{
+// Trace("%s - Library %s",__FUNCTION__,(dwcallpurpose == DLL_PROCESS_ATTACH) ? "Loaded" : "Unloaded");
+
+ switch(dwcallpurpose)
+ {
+ case DLL_PROCESS_ATTACH:
+ libpw3270_loaded();
+ break;
+
+ case DLL_PROCESS_DETACH:
+ libpw3270_unloaded();
+ break;
+ }
+
+ return TRUE;
+}
+
+#endif // WIN32
+
+int libpw3270_loaded(void)
+{
+ trace("%s",__FUNCTION__);
+ return 0;
+}
+
+int libpw3270_unloaded(void)
+{
+ trace("%s",__FUNCTION__);
+ configuration_deinit();
+ return 0;
+}
+
+
+gchar * pw3270_build_filename(GtkWidget *widget, const gchar *first_element, ...)
+{
+ va_list args;
+ gchar *path;
+
+ va_start(args, first_element);
+ path = filename_from_va(first_element,args);
+ va_end(args);
+ return path;
+}
diff --git a/src/pw3270/window.c b/src/pw3270/window.c
index 87d243e..302180f 100644
--- a/src/pw3270/window.c
+++ b/src/pw3270/window.c
@@ -18,7 +18,7 @@
* 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 mainwindow.c e possui - linhas de código.
+ * Este programa está nomeado como window.c e possui - linhas de código.
*
* Contatos:
*
@@ -149,8 +149,6 @@
static void pw3270_class_init(pw3270Class *klass)
{
-// GObjectClass * gobject_class = G_OBJECT_CLASS(klass);
-
#if GTK_CHECK_VERSION(3,0,0)
GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass);
widget_class->destroy = pw3270_destroy;
@@ -161,6 +159,7 @@
}
#endif // GTK3
+ configuration_init();
lib3270_set_popup_handler(popup_handler);
}
@@ -426,7 +425,7 @@
// Load UI
{
- gchar *path = build_data_filename("ui",NULL);
+ gchar *path = pw3270_build_filename(GTK_WIDGET(widget),"ui",NULL);
if(ui_parse_xml_folder(GTK_WINDOW(widget),path,groupname,popupname,widget->terminal,widget_setup))
{
--
libgit2 0.21.2