From fc337b919db2a7ec7bd23bcbd6041b8452db0628 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Mon, 9 Sep 2019 14:34:51 -0300 Subject: [PATCH] Splitting properties get/set/init in separated sources. remap file is now a property. --- Makefile.in | 1 + src/include/config.h.in | 1 + src/include/terminal.h | 1 + src/include/v3270.h | 3 ++- src/terminal/charset.c | 347 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/terminal/properties.c | 485 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/terminal/properties/get.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/terminal/properties/init.c | 265 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/terminal/properties/methods.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/terminal/properties/private.h | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/terminal/properties/set.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/terminal/widget.c | 6 ++++++ src/trace/exec.c | 8 ++++++++ v3270.cbp | 12 +++++++++++- 14 files changed, 745 insertions(+), 761 deletions(-) delete mode 100644 src/terminal/properties.c create mode 100644 src/terminal/properties/get.c create mode 100644 src/terminal/properties/init.c create mode 100644 src/terminal/properties/methods.c create mode 100644 src/terminal/properties/private.h create mode 100644 src/terminal/properties/set.c diff --git a/Makefile.in b/Makefile.in index 56ee207..d917107 100644 --- a/Makefile.in +++ b/Makefile.in @@ -34,6 +34,7 @@ SOURCES= \ $(wildcard src/terminal/*.c) \ $(wildcard src/terminal/@OSNAME@/*.rc) \ $(wildcard src/terminal/@OSNAME@/*.c) \ + $(wildcard src/terminal/properties/*.c) \ $(wildcard src/filetransfer/*.c) \ $(wildcard src/selection/*.c) \ $(wildcard src/selection/@OSNAME@/*.c) \ diff --git a/src/include/config.h.in b/src/include/config.h.in index 856bad0..c9d1f3d 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -34,6 +34,7 @@ #undef PACKAGE_NAME #undef PACKAGE_VERSION #undef PACKAGE_RELEASE + #undef PRODUCT_NAME #undef HAVE_LIBM #undef HAVE_GNOME diff --git a/src/include/terminal.h b/src/include/terminal.h index d0f7fc2..08f96bf 100644 --- a/src/include/terminal.h +++ b/src/include/terminal.h @@ -164,6 +164,7 @@ G_BEGIN_DECLS // Session H3270 * host; /**< Related 3270 session */ gchar * session_name; /**< Session name (for window title) */ + gchar * remap_filename; /**< @brief XML file with remap table. */ // Auto disconnect struct diff --git a/src/include/v3270.h b/src/include/v3270.h index ef65a6a..67cf735 100644 --- a/src/include/v3270.h +++ b/src/include/v3270.h @@ -246,7 +246,8 @@ LIB3270_EXPORT void v3270_set_session_host_type(GtkWidget *widget, LIB3270_HOST_TYPE); - LIB3270_EXPORT void v3270_remap_from_xml(GtkWidget *widget, const gchar *path); + LIB3270_EXPORT void v3270_set_remap_filename(GtkWidget *widget, const gchar *path); + LIB3270_EXPORT const gchar * v3270_get_remap_filename(GtkWidget *widget); // Keyboard & Mouse special actions LIB3270_EXPORT void v3270_set_scroll_action(GtkWidget *widget, GdkScrollDirection direction, GtkAction *action); diff --git a/src/terminal/charset.c b/src/terminal/charset.c index 3aaa425..5b745a2 100644 --- a/src/terminal/charset.c +++ b/src/terminal/charset.c @@ -31,7 +31,6 @@ #include #include #include -// #include #include #define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME) @@ -69,258 +68,6 @@ return chr; } - /* - static unsigned short getChar(const gchar *id, GError **error) { - - static struct - { - const char * name; - unsigned short keysym; - } latin[] = - { - { "space", XK_space }, - { "exclam", XK_exclam }, - { "quotedbl", XK_quotedbl }, - { "numbersign", XK_numbersign }, - { "dollar", XK_dollar }, - { "percent", XK_percent }, - { "ampersand", XK_ampersand }, - { "apostrophe", XK_apostrophe }, - { "quoteright", XK_quoteright }, - { "parenleft", XK_parenleft }, - { "parenright", XK_parenright }, - { "asterisk", XK_asterisk }, - { "plus", XK_plus }, - { "comma", XK_comma }, - { "minus", XK_minus }, - { "period", XK_period }, - { "slash", XK_slash }, - { "0", XK_0 }, - { "1", XK_1 }, - { "2", XK_2 }, - { "3", XK_3 }, - { "4", XK_4 }, - { "5", XK_5 }, - { "6", XK_6 }, - { "7", XK_7 }, - { "8", XK_8 }, - { "9", XK_9 }, - { "colon", XK_colon }, - { "semicolon", XK_semicolon }, - { "less", XK_less }, - { "equal", XK_equal }, - { "greater", XK_greater }, - { "question", XK_question }, - { "at", XK_at }, - { "A", XK_A }, - { "B", XK_B }, - { "C", XK_C }, - { "D", XK_D }, - { "E", XK_E }, - { "F", XK_F }, - { "G", XK_G }, - { "H", XK_H }, - { "I", XK_I }, - { "J", XK_J }, - { "K", XK_K }, - { "L", XK_L }, - { "M", XK_M }, - { "N", XK_N }, - { "O", XK_O }, - { "P", XK_P }, - { "Q", XK_Q }, - { "R", XK_R }, - { "S", XK_S }, - { "T", XK_T }, - { "U", XK_U }, - { "V", XK_V }, - { "W", XK_W }, - { "X", XK_X }, - { "Y", XK_Y }, - { "Z", XK_Z }, - { "bracketleft", XK_bracketleft }, - { "backslash", XK_backslash }, - { "bracketright", XK_bracketright }, - { "asciicircum", XK_asciicircum }, - { "underscore", XK_underscore }, - { "grave", XK_grave }, - { "quoteleft", XK_quoteleft }, - { "a", XK_a }, - { "b", XK_b }, - { "c", XK_c }, - { "d", XK_d }, - { "e", XK_e }, - { "f", XK_f }, - { "g", XK_g }, - { "h", XK_h }, - { "i", XK_i }, - { "j", XK_j }, - { "k", XK_k }, - { "l", XK_l }, - { "m", XK_m }, - { "n", XK_n }, - { "o", XK_o }, - { "p", XK_p }, - { "q", XK_q }, - { "r", XK_r }, - { "s", XK_s }, - { "t", XK_t }, - { "u", XK_u }, - { "v", XK_v }, - { "w", XK_w }, - { "x", XK_x }, - { "y", XK_y }, - { "z", XK_z }, - { "braceleft", XK_braceleft }, - { "bar", XK_bar }, - { "braceright", XK_braceright }, - { "asciitilde", XK_asciitilde }, - { "nobreakspace", XK_nobreakspace }, - { "exclamdown", XK_exclamdown }, - { "cent", XK_cent }, - { "sterling", XK_sterling }, - { "currency", XK_currency }, - { "yen", XK_yen }, - { "brokenbar", XK_brokenbar }, - { "section", XK_section }, - { "diaeresis", XK_diaeresis }, - { "copyright", XK_copyright }, - { "ordfeminine", XK_ordfeminine }, - { "guillemotleft", XK_guillemotleft }, - { "notsign", XK_notsign }, - { "hyphen", XK_hyphen }, - { "registered", XK_registered }, - { "macron", XK_macron }, - { "degree", XK_degree }, - { "plusminus", XK_plusminus }, - { "twosuperior", XK_twosuperior }, - { "threesuperior", XK_threesuperior }, - { "acute", XK_acute }, - { "mu", XK_mu }, - { "paragraph", XK_paragraph }, - { "periodcentered", XK_periodcentered }, - { "cedilla", XK_cedilla }, - { "onesuperior", XK_onesuperior }, - { "masculine", XK_masculine }, - { "guillemotright", XK_guillemotright }, - { "onequarter", XK_onequarter }, - { "onehalf", XK_onehalf }, - { "threequarters", XK_threequarters }, - { "questiondown", XK_questiondown }, - { "Agrave", XK_Agrave }, - { "Aacute", XK_Aacute }, - { "Acircumflex", XK_Acircumflex }, - { "Atilde", XK_Atilde }, - { "Adiaeresis", XK_Adiaeresis }, - { "Aring", XK_Aring }, - { "AE", XK_AE }, - { "Ccedilla", XK_Ccedilla }, - { "Egrave", XK_Egrave }, - { "Eacute", XK_Eacute }, - { "Ecircumflex", XK_Ecircumflex }, - { "Ediaeresis", XK_Ediaeresis }, - { "Igrave", XK_Igrave }, - { "Iacute", XK_Iacute }, - { "Icircumflex", XK_Icircumflex }, - { "Idiaeresis", XK_Idiaeresis }, - { "ETH", XK_ETH }, - { "Eth", XK_Eth }, - { "Ntilde", XK_Ntilde }, - { "Ograve", XK_Ograve }, - { "Oacute", XK_Oacute }, - { "Ocircumflex", XK_Ocircumflex }, - { "Otilde", XK_Otilde }, - { "Odiaeresis", XK_Odiaeresis }, - { "multiply", XK_multiply }, - { "Ooblique", XK_Ooblique }, - { "Ugrave", XK_Ugrave }, - { "Uacute", XK_Uacute }, - { "Ucircumflex", XK_Ucircumflex }, - { "Udiaeresis", XK_Udiaeresis }, - { "Yacute", XK_Yacute }, - { "THORN", XK_THORN }, - { "Thorn", XK_Thorn }, - { "ssharp", XK_ssharp }, - { "agrave", XK_agrave }, - { "aacute", XK_aacute }, - { "acircumflex", XK_acircumflex }, - { "atilde", XK_atilde }, - { "adiaeresis", XK_adiaeresis }, - { "aring", XK_aring }, - { "ae", XK_ae }, - { "ccedilla", XK_ccedilla }, - { "egrave", XK_egrave }, - { "eacute", XK_eacute }, - { "ecircumflex", XK_ecircumflex }, - { "ediaeresis", XK_ediaeresis }, - { "igrave", XK_igrave }, - { "iacute", XK_iacute }, - { "icircumflex", XK_icircumflex }, - { "idiaeresis", XK_idiaeresis }, - { "eth", XK_eth }, - { "ntilde", XK_ntilde }, - { "ograve", XK_ograve }, - { "oacute", XK_oacute }, - { "ocircumflex", XK_ocircumflex }, - { "otilde", XK_otilde }, - { "odiaeresis", XK_odiaeresis }, - { "division", XK_division }, - { "oslash", XK_oslash }, - { "ugrave", XK_ugrave }, - { "uacute", XK_uacute }, - { "ucircumflex", XK_ucircumflex }, - { "udiaeresis", XK_udiaeresis }, - { "yacute", XK_yacute }, - { "thorn", XK_thorn }, - { "ydiaeresis", XK_ydiaeresis }, - - // The following are, umm, hacks to allow symbolic names for - // control codes. - #if !defined(_WIN32) - { "BackSpace", 0x08 }, - { "Tab", 0x09 }, - { "Linefeed", 0x0a }, - { "Return", 0x0d }, - { "Escape", 0x1b }, - { "Delete", 0x7f }, - #endif - }; - - size_t ix; - - if(*error) { - return 0; - } - - if(g_str_has_prefix(id,"0x")) { - - unsigned int rc = 0; - - if(sscanf(id + 2, "%x", &rc) != 1) - { - *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_( "Can't parse character value" )); - return 0; - } - - return (unsigned short) rc; - - } - - for(ix=0;ix < G_N_ELEMENTS(latin);ix++) { - if(!g_ascii_strcasecmp(id,latin[ix].name)) - return latin[ix].keysym; - } - - if(strlen(id) != 1) - { - *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_( "Invalid character value" )); - return 0; - } - - return (unsigned short) *id; - } - */ - static lib3270_remap_scope getRemapScope(const gchar *str, GError **error) { static const char *text[] = { "CS_ONLY","FT_ONLY", "BOTH" }; @@ -434,7 +181,37 @@ { } - LIB3270_EXPORT void v3270_remap_from_xml(GtkWidget *widget, const gchar *path) + static gchar * get_filename(const gchar *name) + { + size_t ix; + const gchar * const * system_data_dirs = g_get_system_data_dirs(); + +#ifdef _WIN32 + #error Implementar. +#endif // _WIN32 + + for(ix=0;system_data_dirs[ix];ix++) + { + gchar * filename = g_build_filename(system_data_dirs[ix],G_STRINGIFY(PRODUCT_NAME),"remap",name,NULL); + + debug("%s(%s)",__FUNCTION__,filename); + + if(g_file_test(filename,G_FILE_TEST_IS_REGULAR)) + return filename; + + g_free(filename); + } + + return g_build_filename("remap",name,NULL); + + } + + LIB3270_EXPORT const char * v3270_get_remap_filename(GtkWidget *widget) + { + return GTK_V3270(widget)->remap_filename; + } + + LIB3270_EXPORT void v3270_set_remap_filename(GtkWidget *widget, const gchar *path) { static const GMarkupParser parser = { @@ -454,12 +231,46 @@ }; GError * error = NULL; - gchar * text = NULL; + g_autofree gchar * text = NULL; + v3270 * terminal = GTK_V3270(widget); struct parse cfg; + debug("%s(%s)",__FUNCTION__,path); + + g_return_if_fail(GTK_IS_V3270(widget)); + + if(terminal->remap_filename) + { + g_free(terminal->remap_filename); + terminal->remap_filename = NULL; + } + + if(!(path && *path)) + { + lib3270_reset_charset(terminal->host,NULL,NULL,LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET); + return; + } + memset(&cfg,0,sizeof(cfg)); - if(g_file_get_contents(path,&text,NULL,&error)) + if(g_file_test(path,G_FILE_TEST_IS_REGULAR)) + { + terminal->remap_filename = g_strdup(path); + } + else if(g_str_has_suffix(path,".xml")) + { + terminal->remap_filename = get_filename(path); + } + else + { + g_autofree gchar *name = g_strconcat(path,".xml",NULL); + terminal->remap_filename = get_filename(name); + } + + debug("Loading \"%s\"",terminal->remap_filename); + g_file_get_contents(terminal->remap_filename,&text,NULL,&error); + + if(text && !error) { GMarkupParseContext * context = g_markup_parse_context_new(&parser,G_MARKUP_TREAT_CDATA_AS_TEXT|G_MARKUP_PREFIX_ERROR_POSITION,&cfg,NULL); @@ -470,42 +281,30 @@ debug("error=%p",error); + lib3270_reset_charset(terminal->host,NULL,NULL,LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET); + if(error) { - g_autofree gchar * name = g_path_get_basename(path); - v3270_popup_gerror( widget, error, _( "Remap Failed" ), - _( "Can't parse %s" ), name + _( "Can't parse %s" ), path ); g_error_free(error); } else { - H3270 * hSession = v3270_get_session(widget); + unsigned int i; - - if(hSession) + for(i=0;i < cfg.len; i++) { - unsigned int i; - - lib3270_reset_charset(hSession, cfg.host, cfg.display, cfg.cgcsgid); - - for(i=0;i < cfg.len; i++) - { - lib3270_remap_char(hSession,cfg.map[i].ebc,cfg.map[i].iso, BOTH, 0); - } - + lib3270_remap_char(terminal->host,cfg.map[i].ebc,cfg.map[i].iso, BOTH, 0); } - } - - g_free(text); g_free(cfg.host); g_free(cfg.display); diff --git a/src/terminal/properties.c b/src/terminal/properties.c deleted file mode 100644 index 0aa6370..0000000 --- a/src/terminal/properties.c +++ /dev/null @@ -1,485 +0,0 @@ -/* - * "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 properties.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) - * - */ - -#ifdef WIN32 - #include - #include - #include -#endif // WIN32 - - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - enum _v3270_internal_property - { - V3270_PROPERTY_FONT_FAMILY = 2, ///< @brief Name of the font-family used by widget. - V3270_PROPERTY_CLIPBOARD = 3, ///< @brief Name of the selected clipboard. - V3270_PROPERTY_SESSION_NAME = 4, ///< @brief Widget's session name. - V3270_PROPERTY_AUTO_DISCONNECT = 5, ///< @brief Auto disconnect. - - - V3270_PROPERTY_DYNAMIC = 6 ///< @brief Id of the first LIB3270 internal property. - }; - -/*--[ Implement ]------------------------------------------------------------------------------------*/ - - static void v3270_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) - { - v3270 * window = GTK_V3270(object); - v3270Class * klass = GTK_V3270_GET_CLASS(object); - - debug("%s(%u,%s)",__FUNCTION__,prop_id,g_param_spec_get_name(pspec)); - - if(prop_id >= klass->properties.type.str) - { - const LIB3270_STRING_PROPERTY * prop = (lib3270_get_string_properties_list()+(prop_id - klass->properties.type.str)); - debug("%s.%s.%s=%s",__FUNCTION__,"string",prop->name,g_value_get_string(value)); - - if(prop->set) - prop->set(window->host,g_value_get_string(value)); - - } - else if(prop_id >= klass->properties.type.uint) - { - const LIB3270_UINT_PROPERTY * prop = (lib3270_get_unsigned_properties_list()+(prop_id - klass->properties.type.uint)); - debug("%s.%s.%s",__FUNCTION__,"unsigned",prop->name); - - if(prop->set) - prop->set(window->host,g_value_get_uint(value)); - - } - else if(prop_id >= klass->properties.type.integer) - { - const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer)); - debug("%s.%s.%s",__FUNCTION__,"integer",prop->name); - - if(prop->set) - prop->set(window->host,g_value_get_int(value)); - - } - else if(prop_id >= klass->properties.type.boolean) - { - const LIB3270_INT_PROPERTY * prop = (lib3270_get_boolean_properties_list()+(prop_id - klass->properties.type.boolean)); - debug("%s.%s.%s",__FUNCTION__,"boolean",prop->name); - - if(prop->set) - prop->set(window->host,g_value_get_boolean(value) ? 1 : 0); - - } - else if(prop_id >= klass->properties.type.toggle) - { - debug("%s.%s",__FUNCTION__,"toggle"); - lib3270_set_toggle(window->host,prop_id - klass->properties.type.toggle, (int) g_value_get_boolean (value)); - - } - else - { - // Check for internal properties. - switch(prop_id) { - case V3270_PROPERTY_FONT_FAMILY: // Font-family - v3270_set_font_family(GTK_WIDGET(object), g_value_get_string(value)); - break; - - case V3270_PROPERTY_CLIPBOARD: // Clipboard - { - const gchar * name = g_value_get_string(value); - if(!*name) { - g_message("Setting default clipboard"); - window->selection.target = GDK_SELECTION_CLIPBOARD; - } - else - { - GdkAtom clipboard = gdk_atom_intern(name,TRUE); - if(clipboard == GDK_NONE) - { - g_warning("\"%s\" is not a valid clipboard name",name); - } - else - { - window->selection.target = clipboard; - } - } - } - break; - - case V3270_PROPERTY_SESSION_NAME: // Session Name - v3270_set_session_name(GTK_WIDGET(object), g_value_get_string(value)); - break; - - case V3270_PROPERTY_AUTO_DISCONNECT: - v3270_set_auto_disconnect(GTK_WIDGET(object), g_value_get_uint(value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - - } - - } - - - } - - static void v3270_get_property(GObject *object,guint prop_id, GValue *value, GParamSpec *pspec) - { - v3270 * window = GTK_V3270(object); - v3270Class * klass = GTK_V3270_GET_CLASS(object); - - debug("%s(%u,%s)",__FUNCTION__,prop_id,g_param_spec_get_name(pspec)); - - if(prop_id >= klass->properties.type.str) - { - const LIB3270_STRING_PROPERTY * prop = (lib3270_get_string_properties_list()+(prop_id - klass->properties.type.str)); - debug("%s.%s.%s",__FUNCTION__,"string",prop->name); - - if(prop->get) - g_value_set_string(value,prop->get(window->host)); - - } - else if(prop_id >= klass->properties.type.uint) - { - const LIB3270_UINT_PROPERTY * prop = (lib3270_get_unsigned_properties_list()+(prop_id - klass->properties.type.uint)); - debug("%s.%s.%s",__FUNCTION__,"unsigned",prop->name); - - if(prop->get) - g_value_set_uint(value,prop->get(window->host)); - - } - else if(prop_id >= klass->properties.type.integer) - { - const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer)); - debug("%s.%s.%s",__FUNCTION__,"integer",prop->name); - - if(prop->get) - g_value_set_int(value,prop->get(window->host)); - - } - else if(prop_id >= klass->properties.type.boolean) - { - const LIB3270_INT_PROPERTY * prop = (lib3270_get_boolean_properties_list()+(prop_id - klass->properties.type.boolean)); - debug("%s.%s.%s",__FUNCTION__,"boolean",prop->name); - - if(prop->get) - g_value_set_boolean(value,prop->get(window->host) != 0 ? TRUE : FALSE); - - } - else if(prop_id >= klass->properties.type.toggle) - { - debug("%s.%s.%s",__FUNCTION__,"toggle",lib3270_get_toggle_name(prop_id - klass->properties.type.toggle)); - g_value_set_boolean(value,lib3270_get_toggle(window->host,prop_id - klass->properties.type.toggle) ? TRUE : FALSE ); - - } - else - { - // Check for internal properties. - switch(prop_id) { - case V3270_PROPERTY_FONT_FAMILY: // Font-family - g_value_set_string(value,v3270_get_font_family(GTK_WIDGET(object))); - break; - - case V3270_PROPERTY_CLIPBOARD: // Clipboard - g_value_take_string(value,gdk_atom_name(window->selection.target)); - break; - - case V3270_PROPERTY_SESSION_NAME: - g_value_set_string(value,v3270_get_session_name(GTK_WIDGET(object))); - break; - - case V3270_PROPERTY_AUTO_DISCONNECT: - g_value_set_uint(value,window->activity.disconnect); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - - } - } - - } - - void v3270_install_property(GObjectClass *oclass, guint property_id, GParamSpec *pspec) - { - v3270Class * klass = GTK_V3270_CLASS(oclass); - - const struct - { - const char *name; - GParamSpec **prop; - } properties[] = { - { "connected", &klass->properties.online }, - { "luname", &klass->properties.luname }, - { "model", &klass->properties.model }, - { "has-selection", &klass->properties.selection }, - }; - - size_t ix; - -// debug("Property %s=%u",g_param_spec_get_name(pspec),(unsigned int) property_id); - g_object_class_install_property(oclass, property_id, pspec); - - for(ix = 0; ix < G_N_ELEMENTS(properties); ix++) - { - if(!g_ascii_strcasecmp(properties[ix].name,g_param_spec_get_name(pspec))) - { -// debug("Property \"%s\" is special",g_param_spec_get_name(pspec)); - *properties[ix].prop = pspec; - break; - } - } - - } - - void v3270_init_properties(GObjectClass * gobject_class) - { - size_t ix; - GParamSpec * spec; - v3270Class * klass = GTK_V3270_CLASS(gobject_class); - - debug("%s",__FUNCTION__); - - gobject_class->set_property = v3270_set_property; - gobject_class->get_property = v3270_get_property; - - // Setup internal properties. - - // Font family - klass->properties.font_family = g_param_spec_string( - "font_family", - "font_family", - _("Font family for terminal contents"), - FALSE, - G_PARAM_READABLE|G_PARAM_WRITABLE - ); - - g_object_class_install_property( - gobject_class, - V3270_PROPERTY_FONT_FAMILY, - klass->properties.font_family - ); - - // Session name. - spec = g_param_spec_string( - "session_name", - "session_name", - _("TN3270 Session name"), - FALSE, - G_PARAM_READABLE|G_PARAM_WRITABLE - ); - - g_object_class_install_property( - gobject_class, - V3270_PROPERTY_SESSION_NAME, - spec - ); - - // Auto disconnect - spec = g_param_spec_string( - "auto_disconnect", - "auto_disconnect", - _("IDLE minutes for automatic disconnection"), - FALSE, - G_PARAM_READABLE|G_PARAM_WRITABLE - ); - - g_object_class_install_property( - gobject_class, - V3270_PROPERTY_AUTO_DISCONNECT, - spec - ); - - // Clipboard - spec = g_param_spec_string( - "clipboard", - "clipboard", - _("Clipboard name"), - FALSE, - G_PARAM_READABLE|G_PARAM_WRITABLE - ); - - g_object_class_install_property( - gobject_class, - V3270_PROPERTY_CLIPBOARD, - spec - ); - - // - // Create dynamic properties - klass->properties.count = V3270_PROPERTY_DYNAMIC; - - // - // Extract properties from LIB3270 control tables - // - // Extract toggle class. - klass->properties.type.toggle = klass->properties.count; - for(ix = 0; ix < LIB3270_TOGGLE_COUNT; ix++) - { - debug("Property %u=%s (Toggle)",(unsigned int) klass->properties.type.toggle + ix, lib3270_get_toggle_name(ix)); - - klass->properties.toggle[ix] = - g_param_spec_boolean( - lib3270_get_toggle_name(ix), - lib3270_get_toggle_name(ix), - lib3270_get_toggle_description(ix), - FALSE, - G_PARAM_WRITABLE|G_PARAM_READABLE - ); - - v3270_install_property(gobject_class, klass->properties.count++, klass->properties.toggle[ix]); - - } - - // Creating boolean properties. - klass->properties.type.boolean = klass->properties.count; - const LIB3270_INT_PROPERTY * bool_props = lib3270_get_boolean_properties_list(); - - for(ix = 0; bool_props[ix].name; ix++) - { - debug("Property %u=%s (Boolean)",(unsigned int) klass->properties.type.boolean + ix, bool_props[ix].name); - spec = g_param_spec_boolean( - bool_props[ix].name, - bool_props[ix].name, - bool_props[ix].description, - FALSE, - (bool_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE)) - ); - - v3270_install_property(gobject_class, klass->properties.count++, spec); - - } - - // Creating signed integer properties. - const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list(); - klass->properties.type.integer = klass->properties.count; - - for(ix = 0; int_props[ix].name; ix++) - { - debug("Property %u=%s (Integer)",(unsigned int) klass->properties.type.integer + ix, int_props[ix].name); - - spec = g_param_spec_int( - int_props[ix].name, - int_props[ix].name, - int_props[ix].description, - 0, // Minimo - INT_MAX, // Máximo - 0, // Default - (int_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE)) - ); - - v3270_install_property(gobject_class, klass->properties.count++, spec); - - } - - // Creating unsigned integer properties. - const LIB3270_UINT_PROPERTY * uint_props = lib3270_get_unsigned_properties_list(); - klass->properties.type.uint = klass->properties.count; - - for(ix = 0; uint_props[ix].name; ix++) - { - debug("Property %u=%s (unsigned)",(unsigned int) klass->properties.type.integer + ix, uint_props[ix].name); - - spec = g_param_spec_uint( - uint_props[ix].name, - uint_props[ix].name, - uint_props[ix].description, - 0, // Minimo - UINT_MAX, // Máximo - 0, // Default - (uint_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE)) - ); - - v3270_install_property(gobject_class, klass->properties.count++, spec); - - } - - // Creating string properties. - const LIB3270_STRING_PROPERTY * str_props = lib3270_get_string_properties_list(); - klass->properties.type.str = klass->properties.count; - - for(ix = 0; str_props[ix].name; ix++) - { - - debug("Property %u=%s (String)",(unsigned int) klass->properties.type.str + ix, str_props[ix].name); - - spec = g_param_spec_string( - str_props[ix].name, - str_props[ix].name, - str_props[ix].description, - FALSE, - (str_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE)) - ); - - v3270_install_property(gobject_class, klass->properties.count++, spec); - - } - - } - - LIB3270_EXPORT void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes) - { - g_return_if_fail(GTK_IS_V3270(widget)); - GTK_V3270(widget)->activity.disconnect = minutes; - } - - LIB3270_EXPORT guint v3270_get_auto_disconnect(GtkWidget *widget) - { - g_return_val_if_fail(GTK_IS_V3270(widget),0); - return GTK_V3270(widget)->activity.disconnect; - } - -LIB3270_EXPORT gboolean v3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix) -{ - g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); - - if(ix < LIB3270_TOGGLE_COUNT) - return lib3270_get_toggle(GTK_V3270(widget)->host,ix) ? TRUE : FALSE; - - return FALSE; -} - -LIB3270_EXPORT gboolean v3270_set_toggle(GtkWidget *widget, LIB3270_TOGGLE ix, gboolean state) -{ - g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); - - if(ix < LIB3270_TOGGLE_COUNT) - return lib3270_set_toggle(GTK_V3270(widget)->host,ix,state ? 1 : 0) ? TRUE : FALSE; - - return FALSE; - -} - diff --git a/src/terminal/properties/get.c b/src/terminal/properties/get.c new file mode 100644 index 0000000..cea40fd --- /dev/null +++ b/src/terminal/properties/get.c @@ -0,0 +1,113 @@ +/* + * "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 properties.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 "private.h" + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + + void v3270_get_property(GObject *object,guint prop_id, GValue *value, GParamSpec *pspec) + { + v3270 * window = GTK_V3270(object); + v3270Class * klass = GTK_V3270_GET_CLASS(object); + + debug("%s(%u,%s)",__FUNCTION__,prop_id,g_param_spec_get_name(pspec)); + + if(prop_id >= klass->properties.type.str) + { + const LIB3270_STRING_PROPERTY * prop = (lib3270_get_string_properties_list()+(prop_id - klass->properties.type.str)); + debug("%s.%s.%s",__FUNCTION__,"string",prop->name); + + if(prop->get) + g_value_set_string(value,prop->get(window->host)); + + } + else if(prop_id >= klass->properties.type.uint) + { + const LIB3270_UINT_PROPERTY * prop = (lib3270_get_unsigned_properties_list()+(prop_id - klass->properties.type.uint)); + debug("%s.%s.%s",__FUNCTION__,"unsigned",prop->name); + + if(prop->get) + g_value_set_uint(value,prop->get(window->host)); + + } + else if(prop_id >= klass->properties.type.integer) + { + const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer)); + debug("%s.%s.%s",__FUNCTION__,"integer",prop->name); + + if(prop->get) + g_value_set_int(value,prop->get(window->host)); + + } + else if(prop_id >= klass->properties.type.boolean) + { + const LIB3270_INT_PROPERTY * prop = (lib3270_get_boolean_properties_list()+(prop_id - klass->properties.type.boolean)); + debug("%s.%s.%s",__FUNCTION__,"boolean",prop->name); + + if(prop->get) + g_value_set_boolean(value,prop->get(window->host) != 0 ? TRUE : FALSE); + + } + else if(prop_id >= klass->properties.type.toggle) + { + debug("%s.%s.%s",__FUNCTION__,"toggle",lib3270_get_toggle_name(prop_id - klass->properties.type.toggle)); + g_value_set_boolean(value,lib3270_get_toggle(window->host,prop_id - klass->properties.type.toggle) ? TRUE : FALSE ); + + } + else + { + // Check for internal properties. + switch(prop_id) { + case V3270_PROPERTY_FONT_FAMILY: // Font-family + g_value_set_string(value,v3270_get_font_family(GTK_WIDGET(object))); + break; + + case V3270_PROPERTY_CLIPBOARD: // Clipboard + g_value_take_string(value,gdk_atom_name(window->selection.target)); + break; + + case V3270_PROPERTY_SESSION_NAME: + g_value_set_string(value,v3270_get_session_name(GTK_WIDGET(object))); + break; + + case V3270_PROPERTY_AUTO_DISCONNECT: + g_value_set_uint(value,window->activity.disconnect); + break; + + case V3270_PROPERTY_REMAP_FILE: // Remap file + g_value_set_string(value,v3270_get_remap_filename(GTK_WIDGET(object))); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + + } + } + + } diff --git a/src/terminal/properties/init.c b/src/terminal/properties/init.c new file mode 100644 index 0000000..d8efced --- /dev/null +++ b/src/terminal/properties/init.c @@ -0,0 +1,265 @@ +/* + * "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 properties.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 "private.h" + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + + void v3270_install_property(GObjectClass *oclass, guint property_id, GParamSpec *pspec) + { + v3270Class * klass = GTK_V3270_CLASS(oclass); + + const struct + { + const char *name; + GParamSpec **prop; + } properties[] = { + { "connected", &klass->properties.online }, + { "luname", &klass->properties.luname }, + { "model", &klass->properties.model }, + { "has-selection", &klass->properties.selection }, + }; + + size_t ix; + +// debug("Property %s=%u",g_param_spec_get_name(pspec),(unsigned int) property_id); + g_object_class_install_property(oclass, property_id, pspec); + + for(ix = 0; ix < G_N_ELEMENTS(properties); ix++) + { + if(!g_ascii_strcasecmp(properties[ix].name,g_param_spec_get_name(pspec))) + { +// debug("Property \"%s\" is special",g_param_spec_get_name(pspec)); + *properties[ix].prop = pspec; + break; + } + } + + } + + void v3270_init_properties(GObjectClass * gobject_class) + { + size_t ix; + GParamSpec * spec; + v3270Class * klass = GTK_V3270_CLASS(gobject_class); + + debug("%s",__FUNCTION__); + + gobject_class->set_property = v3270_set_property; + gobject_class->get_property = v3270_get_property; + + // Setup internal properties. + + // Font family + klass->properties.font_family = g_param_spec_string( + "font_family", + "font_family", + _("Font family for terminal contents"), + FALSE, + G_PARAM_READABLE|G_PARAM_WRITABLE + ); + + g_object_class_install_property( + gobject_class, + V3270_PROPERTY_FONT_FAMILY, + klass->properties.font_family + ); + + // Session name. + spec = g_param_spec_string( + "session_name", + "session_name", + _("TN3270 Session name"), + FALSE, + G_PARAM_READABLE|G_PARAM_WRITABLE + ); + + g_object_class_install_property( + gobject_class, + V3270_PROPERTY_SESSION_NAME, + spec + ); + + // Auto disconnect + spec = g_param_spec_string( + "auto_disconnect", + "auto_disconnect", + _("IDLE minutes for automatic disconnection"), + FALSE, + G_PARAM_READABLE|G_PARAM_WRITABLE + ); + + g_object_class_install_property( + gobject_class, + V3270_PROPERTY_AUTO_DISCONNECT, + spec + ); + + // Clipboard + spec = g_param_spec_string( + "clipboard", + "clipboard", + _("Clipboard name"), + FALSE, + G_PARAM_READABLE|G_PARAM_WRITABLE + ); + + g_object_class_install_property( + gobject_class, + V3270_PROPERTY_CLIPBOARD, + spec + ); + + // Remap file + spec = g_param_spec_string( + "remap", + "remap", + _("XML file with remap table"), + FALSE, + G_PARAM_READABLE|G_PARAM_WRITABLE + ); + + g_object_class_install_property( + gobject_class, + V3270_PROPERTY_REMAP_FILE, + spec + ); + + // + // Create dynamic properties + klass->properties.count = V3270_PROPERTY_DYNAMIC; + + // + // Extract properties from LIB3270 control tables + // + // Extract toggle class. + klass->properties.type.toggle = klass->properties.count; + for(ix = 0; ix < LIB3270_TOGGLE_COUNT; ix++) + { + debug("Property %u=%s (Toggle)",(unsigned int) klass->properties.type.toggle + ix, lib3270_get_toggle_name(ix)); + + klass->properties.toggle[ix] = + g_param_spec_boolean( + lib3270_get_toggle_name(ix), + lib3270_get_toggle_name(ix), + lib3270_get_toggle_description(ix), + FALSE, + G_PARAM_WRITABLE|G_PARAM_READABLE + ); + + v3270_install_property(gobject_class, klass->properties.count++, klass->properties.toggle[ix]); + + } + + // Creating boolean properties. + klass->properties.type.boolean = klass->properties.count; + const LIB3270_INT_PROPERTY * bool_props = lib3270_get_boolean_properties_list(); + + for(ix = 0; bool_props[ix].name; ix++) + { + debug("Property %u=%s (Boolean)",(unsigned int) klass->properties.type.boolean + ix, bool_props[ix].name); + spec = g_param_spec_boolean( + bool_props[ix].name, + bool_props[ix].name, + bool_props[ix].description, + FALSE, + (bool_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE)) + ); + + v3270_install_property(gobject_class, klass->properties.count++, spec); + + } + + // Creating signed integer properties. + const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list(); + klass->properties.type.integer = klass->properties.count; + + for(ix = 0; int_props[ix].name; ix++) + { + debug("Property %u=%s (Integer)",(unsigned int) klass->properties.type.integer + ix, int_props[ix].name); + + spec = g_param_spec_int( + int_props[ix].name, + int_props[ix].name, + int_props[ix].description, + 0, // Minimo + INT_MAX, // Máximo + 0, // Default + (int_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE)) + ); + + v3270_install_property(gobject_class, klass->properties.count++, spec); + + } + + // Creating unsigned integer properties. + const LIB3270_UINT_PROPERTY * uint_props = lib3270_get_unsigned_properties_list(); + klass->properties.type.uint = klass->properties.count; + + for(ix = 0; uint_props[ix].name; ix++) + { + debug("Property %u=%s (unsigned)",(unsigned int) klass->properties.type.integer + ix, uint_props[ix].name); + + spec = g_param_spec_uint( + uint_props[ix].name, + uint_props[ix].name, + uint_props[ix].description, + 0, // Minimo + UINT_MAX, // Máximo + 0, // Default + (uint_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE)) + ); + + v3270_install_property(gobject_class, klass->properties.count++, spec); + + } + + // Creating string properties. + const LIB3270_STRING_PROPERTY * str_props = lib3270_get_string_properties_list(); + klass->properties.type.str = klass->properties.count; + + for(ix = 0; str_props[ix].name; ix++) + { + + debug("Property %u=%s (String)",(unsigned int) klass->properties.type.str + ix, str_props[ix].name); + + spec = g_param_spec_string( + str_props[ix].name, + str_props[ix].name, + str_props[ix].description, + FALSE, + (str_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE)) + ); + + v3270_install_property(gobject_class, klass->properties.count++, spec); + + } + + } + diff --git a/src/terminal/properties/methods.c b/src/terminal/properties/methods.c new file mode 100644 index 0000000..f473a5a --- /dev/null +++ b/src/terminal/properties/methods.c @@ -0,0 +1,66 @@ +/* + * "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 properties.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 "private.h" + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + + LIB3270_EXPORT void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes) + { + g_return_if_fail(GTK_IS_V3270(widget)); + GTK_V3270(widget)->activity.disconnect = minutes; + } + + LIB3270_EXPORT guint v3270_get_auto_disconnect(GtkWidget *widget) + { + g_return_val_if_fail(GTK_IS_V3270(widget),0); + return GTK_V3270(widget)->activity.disconnect; + } + +LIB3270_EXPORT gboolean v3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix) +{ + g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); + + if(ix < LIB3270_TOGGLE_COUNT) + return lib3270_get_toggle(GTK_V3270(widget)->host,ix) ? TRUE : FALSE; + + return FALSE; +} + +LIB3270_EXPORT gboolean v3270_set_toggle(GtkWidget *widget, LIB3270_TOGGLE ix, gboolean state) +{ + g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); + + if(ix < LIB3270_TOGGLE_COUNT) + return lib3270_set_toggle(GTK_V3270(widget)->host,ix,state ? 1 : 0) ? TRUE : FALSE; + + return FALSE; + +} + diff --git a/src/terminal/properties/private.h b/src/terminal/properties/private.h new file mode 100644 index 0000000..369ba4a --- /dev/null +++ b/src/terminal/properties/private.h @@ -0,0 +1,64 @@ +/* + * "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 properties.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) + * + */ + +#ifdef WIN32 + #include + #include + #include +#endif // WIN32 + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + enum _v3270_internal_property + { + V3270_PROPERTY_FONT_FAMILY = 2, ///< @brief Name of the font-family used by widget. + V3270_PROPERTY_CLIPBOARD = 3, ///< @brief Name of the selected clipboard. + V3270_PROPERTY_SESSION_NAME = 4, ///< @brief Widget's session name. + V3270_PROPERTY_AUTO_DISCONNECT = 5, ///< @brief Auto disconnect. + V3270_PROPERTY_REMAP_FILE = 6, ///< @brief Path of the remap file. + + + V3270_PROPERTY_DYNAMIC = 7 ///< @brief Id of the first LIB3270 internal property. + }; + + G_GNUC_INTERNAL void v3270_get_property(GObject *object,guint prop_id, GValue *value, GParamSpec *pspec); + G_GNUC_INTERNAL void v3270_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); + + diff --git a/src/terminal/properties/set.c b/src/terminal/properties/set.c new file mode 100644 index 0000000..9f20c9f --- /dev/null +++ b/src/terminal/properties/set.c @@ -0,0 +1,134 @@ +/* + * "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 properties.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 "private.h" + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + + void v3270_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) + { + v3270 * window = GTK_V3270(object); + v3270Class * klass = GTK_V3270_GET_CLASS(object); + + debug("%s(%u,%s)",__FUNCTION__,prop_id,g_param_spec_get_name(pspec)); + + if(prop_id >= klass->properties.type.str) + { + const LIB3270_STRING_PROPERTY * prop = (lib3270_get_string_properties_list()+(prop_id - klass->properties.type.str)); + debug("%s.%s.%s=%s",__FUNCTION__,"string",prop->name,g_value_get_string(value)); + + if(prop->set) + prop->set(window->host,g_value_get_string(value)); + + } + else if(prop_id >= klass->properties.type.uint) + { + const LIB3270_UINT_PROPERTY * prop = (lib3270_get_unsigned_properties_list()+(prop_id - klass->properties.type.uint)); + debug("%s.%s.%s",__FUNCTION__,"unsigned",prop->name); + + if(prop->set) + prop->set(window->host,g_value_get_uint(value)); + + } + else if(prop_id >= klass->properties.type.integer) + { + const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer)); + debug("%s.%s.%s",__FUNCTION__,"integer",prop->name); + + if(prop->set) + prop->set(window->host,g_value_get_int(value)); + + } + else if(prop_id >= klass->properties.type.boolean) + { + const LIB3270_INT_PROPERTY * prop = (lib3270_get_boolean_properties_list()+(prop_id - klass->properties.type.boolean)); + debug("%s.%s.%s",__FUNCTION__,"boolean",prop->name); + + if(prop->set) + prop->set(window->host,g_value_get_boolean(value) ? 1 : 0); + + } + else if(prop_id >= klass->properties.type.toggle) + { + debug("%s.%s",__FUNCTION__,"toggle"); + lib3270_set_toggle(window->host,prop_id - klass->properties.type.toggle, (int) g_value_get_boolean (value)); + + } + else + { + // Check for internal properties. + switch(prop_id) { + case V3270_PROPERTY_FONT_FAMILY: // Font-family + v3270_set_font_family(GTK_WIDGET(object), g_value_get_string(value)); + break; + + case V3270_PROPERTY_CLIPBOARD: // Clipboard + { + const gchar * name = g_value_get_string(value); + if(!*name) { + g_message("Setting default clipboard"); + window->selection.target = GDK_SELECTION_CLIPBOARD; + } + else + { + GdkAtom clipboard = gdk_atom_intern(name,TRUE); + if(clipboard == GDK_NONE) + { + g_warning("\"%s\" is not a valid clipboard name",name); + } + else + { + window->selection.target = clipboard; + } + } + } + break; + + case V3270_PROPERTY_SESSION_NAME: // Session Name + v3270_set_session_name(GTK_WIDGET(object), g_value_get_string(value)); + break; + + case V3270_PROPERTY_AUTO_DISCONNECT: + v3270_set_auto_disconnect(GTK_WIDGET(object), g_value_get_uint(value)); + break; + + case V3270_PROPERTY_REMAP_FILE: // Remap file + v3270_set_remap_filename(GTK_WIDGET(object), g_value_get_string(value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + + } + + } + + + } + diff --git a/src/terminal/widget.c b/src/terminal/widget.c index 9a624fa..3d74941 100644 --- a/src/terminal/widget.c +++ b/src/terminal/widget.c @@ -186,6 +186,12 @@ static void finalize(GObject *object) v3270 * terminal = GTK_V3270(object); + if(terminal->remap_filename) + { + g_free(terminal->remap_filename); + terminal->remap_filename = NULL; + } + if(terminal->host) { // Release session diff --git a/src/trace/exec.c b/src/trace/exec.c index c13755b..777ae40 100644 --- a/src/trace/exec.c +++ b/src/trace/exec.c @@ -285,6 +285,14 @@ return lib3270_disconnect(hSession); } + if(g_str_has_prefix(cmdline,"remap")) + { + gchar *txtptr = cmdline+5; + g_strstrip(txtptr); + v3270_set_remap_filename(widget,txtptr); + return 0; + } + if(g_str_has_prefix(cmdline,"set")) { gchar *txtptr = cmdline+3; diff --git a/v3270.cbp b/v3270.cbp index 81655e2..f46ce90 100644 --- a/v3270.cbp +++ b/v3270.cbp @@ -239,7 +239,17 @@ - + + + + + + + + -- libgit2 0.21.2