diff --git a/pw3270.cbp b/pw3270.cbp
index 5bac0e6..e9cc58b 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -8,8 +8,8 @@
-
-
+
+
@@ -18,8 +18,8 @@
-
-
+
+
@@ -33,7 +33,7 @@
-
+
@@ -41,274 +41,276 @@
-
-
+
+
-
-
+
+
-
+
-
-
+
-
+
+
-
-
+
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
-
-
+
+
-
+
+
-
-
+
-
+
+
-
+
-
+
-
-
+
-
+
+
-
+
-
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
-
+
+
-
-
-
-
-
+
+
+
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
-
+
+
+
+
-
+
-
-
-
+
-
-
-
-
-
+
+
+
-
-
+
+
+
+
+
-
-
-
+
+
-
-
+
+
+
-
-
-
+
+
-
+
+
+
-
+
-
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
-
-
+
+
+
+
-
+
+
-
-
-
-
+
-
-
+
+
+
+
-
-
+
+
-
-
-
+
+
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
+
-
-
-
+
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/gtk/Makefile.in b/src/gtk/Makefile.in
index f94b248..1b52d8f 100644
--- a/src/gtk/Makefile.in
+++ b/src/gtk/Makefile.in
@@ -50,7 +50,7 @@ include uiparser/sources.mak
#---[ Targets ]----------------------------------------------------------------
-SOURCES=main.c mainwindow.c actions.c fonts.c \
+SOURCES=main.c mainwindow.c actions.c fonts.c dialog.c \
$(foreach SRC, $(V3270_SRC), v3270/$(SRC)) \
$(foreach SRC, $(COMMON_SRC), common/$(SRC)) \
$(foreach SRC, $(UI_PARSER_SRC), uiparser/$(SRC))
diff --git a/src/gtk/actions.c b/src/gtk/actions.c
index 727578c..68222af 100644
--- a/src/gtk/actions.c
+++ b/src/gtk/actions.c
@@ -48,8 +48,27 @@ static void lib3270_action(GtkAction *action, GtkWidget *widget)
static void connect_action(GtkAction *action, GtkWidget *widget)
{
+ gchar *host = (gchar *) g_object_get_data(G_OBJECT(action),"host");
+ int f;
+
trace("Action %s activated on widget %p",gtk_action_get_name(action),widget);
- v3270_connect(widget,g_object_get_data(G_OBJECT(action),"host"));
+
+ 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 disconnect_action(GtkAction *action, GtkWidget *widget)
@@ -88,11 +107,6 @@ static void paste_next_action(GtkAction *action, GtkWidget *widget)
lib3270_pastenext(GTK_V3270(widget)->host);
}
-static void paste_file_action(GtkAction *action, GtkWidget *widget)
-{
- trace("Action %s activated on widget %p",gtk_action_get_name(action),widget);
-}
-
static void connect_standard_action(GtkAction *action, GtkWidget *widget, const gchar *name)
{
#undef DECLARE_LIB3270_ACTION
@@ -128,6 +142,7 @@ static void connect_standard_action(GtkAction *action, GtkWidget *widget, const
{ "connect", connect_action },
{ "copy", copy_action },
{ "disconnect", disconnect_action },
+ { "hostname", hostname_action }
};
int f;
@@ -307,10 +322,13 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash
{
action_type = ACTION_TYPE_TOGGLE;
attr = ui_get_attribute("id",names,values);
- id = lib3270_get_toggle_id(attr);
+ if(!attr)
+ attr = ui_get_attribute("toggle",names,values);
+
+ id = lib3270_get_toggle_id(attr);
if(id < 0)
{
- *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_("Toggle action needs a valid toggle id" ));
+ *error = g_error_new(ERROR_DOMAIN,EINVAL,_("%s action needs a valid toggle name" ), name);
return NULL;
}
nm = g_strconcat(name,attr,NULL);
@@ -336,7 +354,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash
if(!attr)
{
- *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_("Paste action needs src attribute" ));
+ *error = g_error_new(ERROR_DOMAIN,EINVAL,_("%s action needs src attribute" ), name);
return NULL;
}
else
@@ -367,7 +385,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash
id = lib3270_get_toggle_id(attr);
if(id < 0)
{
- *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_("Set action needs a valid toggle name" ));
+ *error = g_error_new(ERROR_DOMAIN,EINVAL,_("%s action needs a valid toggle name" ), name);
return NULL;
}
nm = g_strconcat("set",attr,NULL);
@@ -379,7 +397,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash
id = lib3270_get_toggle_id(attr);
if(id < 0)
{
- *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_("Reset action needs a valid toggle name" ));
+ *error = g_error_new(ERROR_DOMAIN,EINVAL,_("%s action needs a valid toggle name" ), name);
return NULL;
}
nm = g_strconcat("reset",attr,NULL);
@@ -390,7 +408,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash
attr = ui_get_attribute("id",names,values);
if(!attr)
{
- *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_("pf action needs a valid id attribute" ));
+ *error = g_error_new(ERROR_DOMAIN,EINVAL,_("%s action needs a valid id attribute" ),name);
return NULL;
}
id = atoi(attr);
@@ -402,7 +420,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash
attr = ui_get_attribute("id",names,values);
if(!attr)
{
- *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_("pf action needs a valid id attribute" ));
+ *error = g_error_new(ERROR_DOMAIN,EINVAL,_("%s action needs a valid id attribute" ),name);
return NULL;
}
id = atoi(attr);
@@ -410,7 +428,8 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash
}
else
{
- nm = g_strdup(name);
+ attr = ui_get_attribute("name",names,values);
+ nm = g_strdup(attr ? attr : name);
}
// Check if action is available
@@ -426,7 +445,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash
{
case ACTION_TYPE_DEFAULT:
action = gtk_action_new(nm,NULL,NULL,NULL);
- connect_standard_action(action,widget,nm);
+ connect_standard_action(action,widget,name);
break;
case ACTION_TYPE_TOGGLE:
diff --git a/src/gtk/dialog.c b/src/gtk/dialog.c
new file mode 100644
index 0000000..c0b55bd
--- /dev/null
+++ b/src/gtk/dialog.c
@@ -0,0 +1,150 @@
+/*
+ * "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 dialog.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 "v3270/v3270.h"
+
+/*--[ Implement ]------------------------------------------------------------------------------------*/
+
+ void paste_file_action(GtkAction *action, GtkWidget *widget)
+ {
+ trace("Action %s activated on widget %p",gtk_action_get_name(action),widget);
+
+ }
+
+ void hostname_action(GtkAction *action, GtkWidget *widget)
+ {
+ const gchar * title = g_object_get_data(G_OBJECT(action),"title");
+ gchar * cfghost = get_string_from_config("host","uri","");
+ gchar * hostname;
+ gchar * ptr;
+ gboolean again = TRUE;
+ GtkTable * table = GTK_TABLE(gtk_table_new(2,4,FALSE));
+ GtkEntry * host = GTK_ENTRY(gtk_entry_new());
+ GtkEntry * port = GTK_ENTRY(gtk_entry_new());
+ GtkToggleButton * checkbox = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_label( _( "Secure connection" ) ));
+ GtkWidget * dialog = gtk_dialog_new_with_buttons( gettext(title ? title : "Select hostname"),
+ GTK_WINDOW(gtk_widget_get_toplevel(widget)),
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+ NULL );
+
+ gtk_window_set_icon_name(GTK_WINDOW(dialog),GTK_STOCK_HOME);
+ gtk_entry_set_max_length(host,0xFF);
+ gtk_entry_set_width_chars(host,60);
+
+ gtk_entry_set_max_length(port,6);
+ gtk_entry_set_width_chars(port,7);
+
+ gtk_table_attach(table,gtk_label_new( _( "Hostname:" ) ), 0,1,0,1,0,0,5,0);
+ gtk_table_attach(table,GTK_WIDGET(host), 1,2,0,1,GTK_EXPAND|GTK_FILL,0,0,0);
+
+ gtk_table_attach(table,gtk_label_new( _( "Port:" ) ), 2,3,0,1,0,0,5,0);
+ gtk_table_attach(table,GTK_WIDGET(port), 3,4,0,1,GTK_FILL,0,0,0);
+
+ gtk_table_attach(table,GTK_WIDGET(checkbox), 1,2,1,2,GTK_EXPAND|GTK_FILL,0,0,0);
+
+ gtk_container_set_border_width(GTK_CONTAINER(table),5);
+
+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),GTK_WIDGET(table),FALSE,FALSE,2);
+
+ hostname = cfghost;
+
+#ifdef HAVE_LIBSSL
+ if(!strncmp(hostname,"L:",2))
+ {
+ gtk_toggle_button_set_active(checkbox,TRUE);
+ hostname += 2;
+ }
+#else
+ gtk_toggle_button_set_active(checkbox,FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(checkbox),FALSE);
+ if(!strncmp(hostname,"L:",2))
+ hostname += 2;
+#endif
+
+ ptr = strchr(hostname,':');
+ if(ptr)
+ {
+ *(ptr++) = 0;
+ gtk_entry_set_text(port,ptr);
+ }
+ else
+ {
+ gtk_entry_set_text(port,"23");
+ }
+
+ gtk_entry_set_text(host,hostname);
+
+ gtk_widget_show_all(GTK_WIDGET(table));
+
+ while(again)
+ {
+ gtk_widget_set_sensitive(dialog,TRUE);
+ switch(gtk_dialog_run(GTK_DIALOG(dialog)))
+ {
+ case GTK_RESPONSE_ACCEPT:
+
+/*
+ gtk_widget_set_sensitive(dialog,FALSE);
+
+ if(gtk_toggle_button_get_active(checkbox))
+ strcpy(buffer,"L:");
+ else
+ *buffer = 0;
+
+ strncat(buffer,gtk_entry_get_text(host),1023);
+ strncat(buffer,":",1023);
+ strncat(buffer,gtk_entry_get_text(port),1023);
+
+ #warning Need more work
+ if(!host_connect(buffer,1))
+ {
+ // Connection OK
+ again = FALSE;
+ set_string_to_config("host","uri","%s",buffer);
+ SetString("Network","Hostname",buffer);
+ }
+*/
+ break;
+
+ case GTK_RESPONSE_REJECT:
+ again = FALSE;
+ break;
+ }
+ }
+
+ gtk_widget_destroy(dialog);
+
+ g_free(cfghost);
+ }
+
diff --git a/src/gtk/globals.h b/src/gtk/globals.h
index f8773d5..2ab2567 100644
--- a/src/gtk/globals.h
+++ b/src/gtk/globals.h
@@ -56,6 +56,7 @@
GtkWidget * create_main_window(void);
void setup_font_list(GtkWidget *widget, GtkWidget *obj);
-
-
+ // actions
+ void paste_file_action(GtkAction *action, GtkWidget *widget);
+ void hostname_action(GtkAction *action, GtkWidget *widget);
diff --git a/src/gtk/v3270/widget.c b/src/gtk/v3270/widget.c
index 71d7a75..498161f 100644
--- a/src/gtk/v3270/widget.c
+++ b/src/gtk/v3270/widget.c
@@ -874,8 +874,13 @@ int v3270_connect(GtkWidget *widget, const gchar *host)
g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL);
+
+
terminal = GTK_V3270(widget);
+ rc = lib3270_connect(terminal->host,host,0);
+
+/*
if(host)
{
set_string_to_config("host","uri","%s",host);
@@ -892,7 +897,7 @@ int v3270_connect(GtkWidget *widget, const gchar *host)
g_free(hs);
}
-
+*/
trace("%s exits with rc=%d (%s)",__FUNCTION__,rc,strerror(rc));
return rc;
diff --git a/ui/00default.xml b/ui/00default.xml
index 0401888..c449046 100644
--- a/ui/00default.xml
+++ b/ui/00default.xml
@@ -78,9 +78,18 @@