/* * "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., 59 Temple * Place, Suite 330, Boston, MA, 02111-1307, USA * * Este programa está nomeado como actions.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) * licinio@bb.com.br (Licínio Luis Branco) * kraucer@bb.com.br (Kraucer Fernandes Mazuco) * */ #include "globals.h" #include "uiparser/parser.h" #include "v3270/v3270.h" #include #include #include #define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME) #define TOGGLE_GDKDEBUG LIB3270_TOGGLE_COUNT+1 /*--[ Implement ]------------------------------------------------------------------------------------*/ static void lib3270_action(GtkAction *action, GtkWidget *widget) { int (*call)(H3270 *h) = (int (*)(H3270 *h)) g_object_get_data(G_OBJECT(action),"lib3270_call"); trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); call(v3270_get_session(widget)); } static void connect_action(GtkAction *action, GtkWidget *widget) { gchar *host = (gchar *) g_object_get_data(G_OBJECT(action),"host"); trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); if(host) { v3270_connect(widget,host); return; } host = get_string_from_config("host","uri",""); if(*host) { v3270_connect(widget,host); g_free(host); return; } g_free(host); hostname_action(action,widget); } static void nop_action(GtkAction *action, GtkWidget *widget) { trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); } static void disconnect_action(GtkAction *action, GtkWidget *widget) { trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); v3270_disconnect(widget); } static void activate_action(GtkAction *action, GtkWidget *widget) { trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); gtk_widget_activate(widget); } static void reload_action(GtkAction *action, GtkWidget *widget) { trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); v3270_reload(widget); } static void copy_action(GtkAction *action, GtkWidget *widget) { V3270_SELECT_FORMAT mode = V3270_SELECT_TEXT; const gchar * str = (const gchar *) g_object_get_data(G_OBJECT(action),"format"); if(str) { static const struct _format { V3270_SELECT_FORMAT mode; const gchar * name; } format[] = { { V3270_SELECT_TEXT, "text" }, { V3270_SELECT_TABLE, "table" }, }; int f; for(f=0;f }; static const struct _gtk_action { const gchar * name; void (*call)(GtkAction *action, GtkWidget *widget); } gtk_action[] = { { "activate", activate_action }, { "reload", reload_action }, { "connect", connect_action }, { "disconnect", disconnect_action }, { "hostname", hostname_action }, { "editcolors", editcolors_action }, { "about", about_dialog_action }, }; int f; // Search for lib3270 predefined actions for(f=0;f= 0) { if(*nm) g_free(*nm); *nm = g_strconcat(name,attr,NULL); return id; } if(!*error) *error = g_error_new(ERROR_DOMAIN,EINVAL,_("Unexpected or invalid %s attribute: \"%s\"" ), key, attr); return -1; } static int setup_block_action(const gchar *name, const gchar *attr, GError **error) { int id = -1; if(!attr) { *error = g_error_new(ERROR_DOMAIN,EINVAL,_("%s action needs src attribute" ), name); } else { static const gchar * src[] = { "all", "selected", "copy", NULL }; id = id_from_array(attr,src,error); if(id < 0) { *error = g_error_new(ERROR_DOMAIN,EINVAL,_("Unexpected or invalid src attribute: \"%s\"" ), attr); } } return id; } GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash, const gchar **names, const gchar **values, GError **error) { static const gchar *actionname[ACTION_COUNT] = { "pastenext", "reselect", "setfullscreen", "resetfullscreen" }; GtkAction * action = NULL; GtkAction **toggle_action = (GtkAction **) g_object_get_data(G_OBJECT(widget),"toggle_actions"); const gchar * direction = ui_get_attribute("direction",names,values); unsigned short flags = 0; const GCallback * callback = NULL; const gchar * attr; int id = 0; gchar * nm = NULL; int f; enum _action_type { ACTION_TYPE_DEFAULT, ACTION_TYPE_TOGGLE, ACTION_TYPE_MOVE, ACTION_TYPE_PFKEY, ACTION_TYPE_PAKEY, ACTION_TYPE_SET, ACTION_TYPE_RESET, ACTION_TYPE_TABLE, } action_type = ACTION_TYPE_DEFAULT; if(direction) { static const gchar *dirname[] = { "up", "down", "left", "right" }; int f; for(f=0;f