diff --git a/pw3270.cbp b/pw3270.cbp
index 477eead..a91e8e6 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -416,6 +416,9 @@
+
+
+
diff --git a/src/include/lib3270.h b/src/include/lib3270.h
index e31b4bf..6d1b9ae 100644
--- a/src/include/lib3270.h
+++ b/src/include/lib3270.h
@@ -415,6 +415,9 @@
*/
LIB3270_EXPORT const char * lib3270_get_hostname(H3270 *h);
+ LIB3270_EXPORT void lib3270_set_hostname(H3270 *h, const char *hostname);
+
+
/**
* Get servic or port for the connect/reconnect operations.
*
@@ -425,6 +428,7 @@
*/
LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h);
+ LIB3270_EXPORT void lib3270_set_srvcname(H3270 *h, const char *srvc);
/**
* Get session options.
@@ -1055,6 +1059,8 @@
LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, unsigned short colortype);
LIB3270_EXPORT unsigned short lib3270_get_color_type(H3270 *hSession);
+ LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, const char *name);
+
LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void);
/**
diff --git a/src/include/pw3270/v3270.h b/src/include/pw3270/v3270.h
index d914104..d0fd6e1 100644
--- a/src/include/pw3270/v3270.h
+++ b/src/include/pw3270/v3270.h
@@ -232,6 +232,7 @@
// Auxiliary widgets
LIB3270_EXPORT GtkWidget * v3270_host_select_new(GtkWidget *widget);
+ LIB3270_EXPORT void v3270_select_host(GtkWidget *widget);
G_END_DECLS
diff --git a/src/lib3270/host.c b/src/lib3270/host.c
index 82e2706..402320c 100644
--- a/src/lib3270/host.c
+++ b/src/lib3270/host.c
@@ -492,6 +492,20 @@ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode)
trace("%s ends",__FUNCTION__);
}
+static void update_host(H3270 *h)
+{
+ Replace(h->host.full,
+ lib3270_strdup_printf(
+ "%s%s:%s",
+ h->options&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://",
+ h->host.current,
+ h->host.srvc
+ ));
+
+ trace("hosturl=[%s]",h->host.full);
+
+}
+
LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n)
{
CHECK_SESSION_HANDLE(h);
@@ -558,17 +572,8 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n)
Replace(h->host.current,strdup(hostname));
Replace(h->host.srvc,strdup(srvc));
- Replace(h->host.full,
- lib3270_strdup_printf(
- "%s%s:%s%s%s",
- h->options&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://",
- hostname,
- srvc,
- *query ? "?" : "",
- query
- ));
-
- trace("hosturl=[%s]",h->host.full);
+
+ update_host(h);
free(str);
}
@@ -586,6 +591,13 @@ LIB3270_EXPORT const char * lib3270_get_hostname(H3270 *h)
return "";
}
+LIB3270_EXPORT void lib3270_set_hostname(H3270 *h, const char *hostname)
+{
+ CHECK_SESSION_HANDLE(h);
+ Replace(h->host.current,strdup(hostname));
+ update_host(h);
+}
+
LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h)
{
CHECK_SESSION_HANDLE(h);
@@ -594,6 +606,13 @@ LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h)
return "telnet";
}
+LIB3270_EXPORT void lib3270_set_srvcname(H3270 *h, const char *srvc)
+{
+ CHECK_SESSION_HANDLE(h);
+ Replace(h->host.srvc,strdup(srvc));
+ update_host(h);
+}
+
LIB3270_EXPORT const char * lib3270_get_host(H3270 *h)
{
CHECK_SESSION_HANDLE(h);
diff --git a/src/lib3270/options.c b/src/lib3270/options.c
index 588b62e..77cd22a 100644
--- a/src/lib3270/options.c
+++ b/src/lib3270/options.c
@@ -134,3 +134,33 @@ LIB3270_EXPORT int lib3270_is_tso(H3270 *hSession)
CHECK_SESSION_HANDLE(hSession);
return (hSession->options & LIB3270_OPTION_TSO) != 0;
}
+
+LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, const char *name)
+{
+ static const struct _host_type
+ {
+ const char * name;
+ LIB3270_OPTION option;
+ } host_type[] =
+ {
+ { "S390", LIB3270_OPTION_S390 },
+ { "AS400", LIB3270_OPTION_AS400 },
+ { "TSO", LIB3270_OPTION_TSO },
+ { "VM/CMS", 0 }
+ };
+
+ int f;
+
+ for(f=0;f<(sizeof(host_type)/sizeof(host_type[0]));f++)
+ {
+ if(!strcasecmp(host_type[f].name,name))
+ {
+ hSession->options &= ~LIB3270_OPTION_HOST_TYPE;
+ hSession->options |= host_type[f].option;
+ return 0;
+ }
+ }
+
+ return EINVAL;
+}
+
diff --git a/src/pw3270/actions.c b/src/pw3270/actions.c
index 3e97b02..ebf749b 100644
--- a/src/pw3270/actions.c
+++ b/src/pw3270/actions.c
@@ -75,6 +75,9 @@ static void connect_action(GtkAction *action, GtkWidget *widget)
trace_action(action,widget);
+ #warning Reimplementar
+
+ /*
if(!systype)
systype = get_string_from_config("host","systype","S390");
@@ -87,6 +90,7 @@ static void connect_action(GtkAction *action, GtkWidget *widget)
v3270_set_session_color_type(widget,colors);
v3270_set_session_options(widget,pw3270_options_by_hosttype(systype));
+ */
if(host)
{
diff --git a/src/pw3270/hostdialog.c b/src/pw3270/hostdialog.c
index 027c18c..9403239 100644
--- a/src/pw3270/hostdialog.c
+++ b/src/pw3270/hostdialog.c
@@ -32,6 +32,7 @@
/*--[ Globals ]--------------------------------------------------------------------------------------*/
+/*
static const struct _host_type
{
const gchar * name;
@@ -55,9 +56,11 @@
{ 8, N_( "8 colors" ) },
{ 2, N_( "Monochrome" ) },
};
+*/
/*--[ Implement ]------------------------------------------------------------------------------------*/
+/*
LIB3270_OPTION pw3270_options_by_hosttype(const gchar *systype)
{
int f;
@@ -129,12 +132,23 @@
trace("Selected color type: %d",(int) colortable[*iColorTable].colors);
}
-
+*/
void hostname_action(GtkAction *action, GtkWidget *widget)
{
+ H3270 * hSession = v3270_get_session(widget);
+ gchar * ptr;
+
+ lib3270_set_color_type(hSession,(unsigned short) get_integer_from_config("host","colortype",16));
+
+ ptr = get_string_from_config("host","systype","s390");
+ if(*ptr)
+ lib3270_set_host_type(hSession,ptr);
+ g_free(ptr);
+
+ v3270_select_host(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;
int iHostType = 0;
@@ -367,37 +381,6 @@
gtk_toggle_button_set_active(sslcheck,(lib3270_get_options(hSession) & LIB3270_OPTION_SSL) ? TRUE : FALSE);
}
-/*
- hostname = cfghost;
-
- trace("hostname=[%s]",hostname);
-
-#ifdef HAVE_LIBSSL
- if(!g_ascii_strncasecmp(hostname,"L:",2))
- {
- gtk_toggle_button_set_active(sslcheck,TRUE);
- hostname += 2;
- }
-#else
- gtk_toggle_button_set_active(sslcheck,FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(sslcheck),FALSE);
- if(!g_ascii_strncasecmp(hostname,"L:",2))
- hostname += 2;
-#endif
-
- trace("hostname=[%s]",hostname);
-
- ptr = strchr(hostname,':');
- if(ptr)
- {
- *(ptr++) = 0;
- gtk_entry_set_text(port,ptr);
- }
- else
- {
- gtk_entry_set_text(port,"23");
- }
-*/
while(again)
{
@@ -407,15 +390,6 @@
case GTK_RESPONSE_ACCEPT:
gtk_widget_set_sensitive(dialog,FALSE);
- /*
- hostname = g_strconcat( gtk_toggle_button_get_active(sslcheck) ? "L:" : "",
- gtk_entry_get_text(host),
- ":",
- gtk_entry_get_text(port),
- NULL
- );
- */
-
#if GTK_CHECK_VERSION(2,18,0)
gtk_widget_set_visible(dialog,FALSE);
#else
@@ -455,5 +429,6 @@
gtk_widget_destroy(dialog);
// g_free(cfghost);
+*/
}
diff --git a/src/pw3270/v3270/hostselect.c b/src/pw3270/v3270/hostselect.c
new file mode 100644
index 0000000..f53994a
--- /dev/null
+++ b/src/pw3270/v3270/hostselect.c
@@ -0,0 +1,417 @@
+/*
+ * "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 hostdialog.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 "hostselect.h"
+ #include
+
+/*--[ Widget definition ]----------------------------------------------------------------------------*/
+
+ static const struct _host_type
+ {
+ const gchar * name;
+ const gchar * description;
+ LIB3270_OPTION option;
+ } host_type[] =
+ {
+ { "S390", N_( "IBM S/390" ), LIB3270_OPTION_S390 },
+ { "AS400", N_( "IBM AS/400" ), LIB3270_OPTION_AS400 },
+ { "TSO", N_( "Other (TSO)" ), LIB3270_OPTION_TSO },
+ { "VM/CMS", N_( "Other (VM/CMS)" ), 0 }
+ };
+
+ static const struct _colortable
+ {
+ unsigned short colors;
+ const gchar * description;
+ } colortable[] =
+ {
+ { 16, N_( "16 colors" ) },
+ { 8, N_( "8 colors" ) },
+ { 2, N_( "Monochrome" ) },
+ };
+
+ enum _entry
+ {
+ ENTRY_HOSTNAME,
+ ENTRY_SRVCNAME,
+
+ ENTRY_COUNT
+ };
+
+ static const gchar *comboLabel[] = { N_("System _type:"), N_("_Color table:") };
+
+ struct _V3270HostSelectWidget
+ {
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkBin parent;
+#else
+ GtkVBox parent;
+#endif // GTK_CHECK_VERSION
+
+ LIB3270_OPTION options; /**< Connect option */
+
+ GtkEntry * entry[ENTRY_COUNT]; /**< Entry fields for host & service name */
+ GtkToggleButton * ssl; /**< SSL Connection? */
+ GtkComboBox * combo[G_N_ELEMENTS(comboLabel)]; /**< Model & Color combobox */
+ unsigned short colors; /**< Number of colors */
+ H3270 * hSession; /**< lib3270's session handle */
+
+ };
+
+ struct _V3270HostSelectWidgetClass
+ {
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkBinClass parent_class;
+#else
+ GtkVBoxClass parent_class;
+#endif // GTK_CHECK_VERSION
+ };
+
+
+#if GTK_CHECK_VERSION(3,0,0)
+ G_DEFINE_TYPE(V3270HostSelectWidget, V3270HostSelectWidget, GTK_TYPE_BIN);
+#else
+ G_DEFINE_TYPE(V3270HostSelectWidget, V3270HostSelectWidget, GTK_TYPE_VBOX);
+#endif // GTK_CHECK_VERSION
+
+/*--[ Implement ]------------------------------------------------------------------------------------*/
+
+static void V3270HostSelectWidget_class_init(V3270HostSelectWidgetClass *klass)
+{
+#if GTK_CHECK_VERSION(3,0,0)
+#else
+#endif // GTK_CHECK_VERSION
+}
+
+static void toggle_ssl(GtkToggleButton *button, V3270HostSelectWidget *dialog)
+{
+ if(gtk_toggle_button_get_active(button))
+ dialog->options |= LIB3270_OPTION_SSL;
+ else
+ dialog->options &= ~LIB3270_OPTION_SSL;
+}
+
+static void systype_changed(GtkComboBox *widget, V3270HostSelectWidget *dialog)
+{
+ GValue value = { 0, };
+ GtkTreeIter iter;
+
+ if(!gtk_combo_box_get_active_iter(widget,&iter))
+ return;
+
+ gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value);
+
+ dialog->options &= ~(LIB3270_OPTION_HOST_TYPE);
+ dialog->options |= g_value_get_int(&value);
+
+}
+
+static void colortable_changed(GtkComboBox *widget, V3270HostSelectWidget *dialog)
+{
+ GValue value = { 0, };
+ GtkTreeIter iter;
+
+ if(!gtk_combo_box_get_active_iter(widget,&iter))
+ return;
+
+ gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value);
+
+ dialog->colors = g_value_get_int(&value);
+
+}
+
+static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget)
+{
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkGrid * grid = GTK_GRID(gtk_grid_new());
+#else
+ GtkTable * grid = gtk_table_new(?,?,FALSE);
+#endif // GTK_CHECK_VERSION
+
+ GtkWidget * label[ENTRY_COUNT] =
+ {
+ gtk_label_new_with_mnemonic( _( "_Host:" ) ),
+ gtk_label_new_with_mnemonic( _( "_Service:" ) )
+ };
+
+ int f;
+
+ gtk_container_set_border_width(GTK_CONTAINER(grid),3);
+
+ for(f=0;fentry[f] = GTK_ENTRY(gtk_entry_new());
+ gtk_misc_set_alignment(GTK_MISC(label[f]),0,0.5);
+ gtk_label_set_mnemonic_widget(GTK_LABEL(label[f]),GTK_WIDGET(widget->entry[f]));
+ }
+
+ gtk_widget_set_tooltip_text(GTK_WIDGET(widget->entry[ENTRY_HOSTNAME]),_("Address or name of the host to connect.") );
+ gtk_widget_set_tooltip_text(GTK_WIDGET(widget->entry[ENTRY_SRVCNAME]),_("Port or service name (empty for \"telnet\").") );
+
+ // SSL checkbox
+ widget->ssl = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic(_( "_Secure connection." )));
+ gtk_widget_set_tooltip_text(GTK_WIDGET(widget->ssl),_( "Check for SSL secure connection." ));
+ g_signal_connect(G_OBJECT(widget->ssl),"toggled",G_CALLBACK(toggle_ssl),widget);
+
+ // Extended options
+ GtkWidget * expander = gtk_expander_new_with_mnemonic(_( "_Host options"));
+
+ // Host type
+ {
+ GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT);
+ GtkCellRenderer * renderer = gtk_cell_renderer_text_new();
+
+ widget->combo[0] = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model));
+
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->combo[0]), renderer, TRUE);
+ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->combo[0]), renderer, "text", 0, NULL);
+
+ for(f=0;fcombo[0]),"changed",G_CALLBACK(systype_changed),widget);
+
+ }
+
+ // Color table
+ {
+ GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT);
+ GtkCellRenderer * renderer = gtk_cell_renderer_text_new();
+
+ widget->combo[1] = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model));
+
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->combo[1]), renderer, TRUE);
+ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->combo[1]), renderer, "text", 0, NULL);
+
+ for(f=0;fcombo[1]),"changed",G_CALLBACK(colortable_changed),widget);
+
+ }
+
+ gtk_entry_set_max_length(widget->entry[ENTRY_HOSTNAME],0xFF);
+ gtk_entry_set_width_chars(widget->entry[ENTRY_HOSTNAME],50);
+
+ gtk_entry_set_max_length(widget->entry[ENTRY_SRVCNAME],6);
+ gtk_entry_set_width_chars(widget->entry[ENTRY_SRVCNAME],7);
+
+ gtk_entry_set_placeholder_text(widget->entry[ENTRY_SRVCNAME],"telnet");
+
+#if GTK_CHECK_VERSION(3,0,0)
+
+ gtk_widget_set_hexpand(GTK_WIDGET(widget->entry[ENTRY_HOSTNAME]),TRUE);
+ gtk_widget_set_hexpand(GTK_WIDGET(widget->ssl),TRUE);
+ gtk_widget_set_hexpand(GTK_WIDGET(expander),TRUE);
+
+ gtk_grid_set_row_homogeneous(grid,FALSE);
+ gtk_grid_set_column_homogeneous(grid,FALSE);
+ gtk_grid_set_column_spacing(grid,5);
+ gtk_grid_set_row_spacing(grid,5);
+
+ gtk_grid_attach(grid,label[ENTRY_HOSTNAME],0,0,1,1);
+ gtk_grid_attach(grid,GTK_WIDGET(widget->entry[ENTRY_HOSTNAME]),1,0,3,1);
+
+ gtk_grid_attach(grid,label[ENTRY_SRVCNAME],4,0,1,1);
+ gtk_grid_attach(grid,GTK_WIDGET(widget->entry[ENTRY_SRVCNAME]),5,0,1,1);
+
+ gtk_grid_attach(grid,GTK_WIDGET(widget->ssl),1,1,3,1);
+
+
+ // Host options
+ {
+ GtkGrid *opt = GTK_GRID(gtk_grid_new());
+ gtk_grid_set_column_spacing(opt,5);
+ gtk_grid_set_row_spacing(opt,5);
+
+ for(f=0;fcombo[f]),1,f+1,2,1);
+ }
+
+ gtk_container_add(GTK_CONTAINER(expander),GTK_WIDGET(opt));
+ }
+ gtk_grid_attach(grid,GTK_WIDGET(expander),1,2,5,2);
+
+
+#else
+
+ gtk_table_set_row_spacings(grid,5);
+ gtk_table_set_col_spacings(grid,5);
+
+ #error Implementar
+
+#endif // GTK_CHECK_VERSION
+
+
+ gtk_widget_show_all(GTK_WIDGET(grid));
+ gtk_container_add(GTK_CONTAINER(widget),GTK_WIDGET(grid));
+}
+
+GtkWidget * v3270_host_select_new(GtkWidget *widget)
+{
+ g_return_val_if_fail(GTK_IS_V3270(widget),NULL);
+
+ V3270HostSelectWidget * selector = GTK_V3270HostSelectWidget(g_object_new(GTK_TYPE_V3270HostSelectWidget, NULL));
+
+ v3270_host_select_set_session(selector,widget);
+
+ return GTK_WIDGET(selector);
+}
+
+void v3270_host_select_set_session(V3270HostSelectWidget *widget, GtkWidget *session)
+{
+ g_return_if_fail(GTK_IS_V3270(session));
+ g_return_if_fail(GTK_IS_V3270HostSelectWidget(widget));
+
+ widget->hSession = v3270_get_session(session);
+
+ gtk_entry_set_text(widget->entry[ENTRY_HOSTNAME],lib3270_get_hostname(widget->hSession));
+ gtk_entry_set_text(widget->entry[ENTRY_SRVCNAME],lib3270_get_srvcname(widget->hSession));
+
+ LIB3270_OPTION opt = lib3270_get_options(widget->hSession);
+
+ gtk_toggle_button_set_active(widget->ssl,(opt & LIB3270_OPTION_SSL) != 0);
+
+ // Set host type
+ {
+ GtkTreeModel * model = gtk_combo_box_get_model(widget->combo[0]);
+ GtkTreeIter iter;
+
+ if(gtk_tree_model_get_iter_first(model,&iter))
+ {
+ do
+ {
+ GValue value = { 0, };
+
+ gtk_tree_model_get_value(model,&iter,1,&value);
+
+ if(g_value_get_int(&value) == (opt&LIB3270_OPTION_HOST_TYPE))
+ {
+ gtk_combo_box_set_active_iter(widget->combo[0],&iter);
+ break;
+ }
+
+ } while(gtk_tree_model_iter_next(model,&iter));
+ }
+ }
+
+ // Set color type
+ {
+ GtkTreeModel * model = gtk_combo_box_get_model(widget->combo[1]);
+ GtkTreeIter iter;
+ int colors = (int) lib3270_get_color_type(widget->hSession);
+
+ if(gtk_tree_model_get_iter_first(model,&iter))
+ {
+ do
+ {
+ GValue value = { 0, };
+
+ gtk_tree_model_get_value(model,&iter,1,&value);
+
+ g_message("%d - %d",g_value_get_int(&value),colors);
+
+ if(g_value_get_int(&value) == colors)
+ {
+ gtk_combo_box_set_active_iter(widget->combo[1],&iter);
+ break;
+ }
+
+ } while(gtk_tree_model_iter_next(model,&iter));
+ }
+ }
+
+ // Just in case
+ widget->options = opt;
+}
+
+LIB3270_EXPORT void v3270_select_host(GtkWidget *widget)
+{
+ g_return_if_fail(GTK_IS_V3270(widget));
+
+ GtkWidget * dialog = v3270_host_select_new(widget);
+ GtkWidget * win = gtk_dialog_new_with_buttons(
+ _( "Select hostname" ),
+ GTK_WINDOW(gtk_widget_get_toplevel(widget)),
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ _( "C_onnect" ), GTK_RESPONSE_ACCEPT,
+ _( "_Cancel" ), GTK_RESPONSE_REJECT,
+ NULL );
+
+
+ gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(win))),dialog,FALSE,FALSE,2);
+ gtk_widget_show_all(dialog);
+
+ gboolean again = TRUE;
+ while(again)
+ {
+ gtk_widget_set_sensitive(win,TRUE);
+ gtk_widget_set_visible(win,TRUE);
+
+ switch(gtk_dialog_run(GTK_DIALOG(win)))
+ {
+ case GTK_RESPONSE_ACCEPT:
+ gtk_widget_set_visible(win,FALSE);
+ gtk_widget_set_sensitive(win,FALSE);
+ again = v3270_host_select_apply(GTK_V3270HostSelectWidget(dialog)) != 0;
+ break;
+
+ case GTK_RESPONSE_REJECT:
+ again = FALSE;
+ break;
+ }
+ }
+
+ gtk_widget_destroy(win);
+
+}
+
+LIB3270_EXPORT int v3270_host_select_apply(V3270HostSelectWidget *widget)
+{
+ g_return_if_fail(GTK_IS_V3270HostSelectWidget(widget));
+
+ lib3270_set_hostname(widget->hSession,gtk_entry_get_text(widget->entry[ENTRY_HOSTNAME]));
+ lib3270_set_srvcname(widget->hSession,gtk_entry_get_text(widget->entry[ENTRY_SRVCNAME]));
+ lib3270_set_options(widget->hSession,widget->options);
+
+ return lib3270_connect(widget->hSession,0);
+}
+
diff --git a/src/pw3270/v3270/hostselect.h b/src/pw3270/v3270/hostselect.h
new file mode 100644
index 0000000..c68738d
--- /dev/null
+++ b/src/pw3270/v3270/hostselect.h
@@ -0,0 +1,67 @@
+/*
+ * "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 hostdialog.h e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ */
+
+#ifndef V3270HOST_H_INCLUDED
+
+ #include
+ #define ENABLE_NLS
+
+ #ifndef GETTEXT_PACKAGE
+ #define GETTEXT_PACKAGE PACKAGE_NAME
+ #endif
+
+ #include
+ #include
+ #include
+ #include
+
+ #define V3270FT_H_INCLUDED 1
+
+ G_BEGIN_DECLS
+
+/*--[ Progress widget ]------------------------------------------------------------------------------*/
+
+ #define GTK_TYPE_V3270HostSelectWidget (V3270HostSelectWidget_get_type ())
+ #define GTK_V3270HostSelectWidget(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270HostSelectWidget, V3270HostSelectWidget))
+ #define GTK_V3270HostSelectWidget_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270HostSelectWidget, V3270HostSelectWidgetClass))
+ #define GTK_IS_V3270HostSelectWidget(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270HostSelectWidget))
+ #define GTK_IS_V3270HostSelectWidget_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270HostSelectWidget))
+ #define GTK_V3270HostSelectWidget_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270HostSelectWidget, V3270HostSelectWidgetClass))
+
+ typedef struct _V3270HostSelectWidget V3270HostSelectWidget;
+ typedef struct _V3270HostSelectWidgetClass V3270HostSelectWidgetClass;
+
+/*--[ Prototipes ]-----------------------------------------------------------------------------------*/
+
+ LIB3270_EXPORT void v3270_host_select_set_session(V3270HostSelectWidget *widget, GtkWidget *session);
+ LIB3270_EXPORT int v3270_host_select_apply(V3270HostSelectWidget *widget);
+
+ G_END_DECLS
+
+#endif // V3270HOST_H_INCLUDED
diff --git a/src/pw3270/v3270/mouse.c b/src/pw3270/v3270/mouse.c
index 8c89395..8507263 100644
--- a/src/pw3270/v3270/mouse.c
+++ b/src/pw3270/v3270/mouse.c
@@ -49,6 +49,8 @@ gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y)
GdkPoint point;
int r,c;
+ g_return_val_if_fail(widget->metrics.width > 0,-1);
+
if(x > 0 && y > 0)
{
point.x = ((x-widget->metrics.left)/widget->metrics.width);
diff --git a/src/pw3270/v3270/sources.mak b/src/pw3270/v3270/sources.mak
index eeecbef..2060b7e 100644
--- a/src/pw3270/v3270/sources.mak
+++ b/src/pw3270/v3270/sources.mak
@@ -27,5 +27,5 @@
#
V3270_SRC=marshal.c widget.c oia.c iocallback.c keyboard.c draw.c mouse.c selection.c \
- accessible.c security.c macros.c
+ accessible.c security.c macros.c hostselect.c
diff --git a/src/pw3270/window.c b/src/pw3270/window.c
index 51c7fcc..01d5392 100644
--- a/src/pw3270/window.c
+++ b/src/pw3270/window.c
@@ -180,6 +180,9 @@
{
GtkWidget * widget = g_object_new(GTK_TYPE_PW3270, NULL);
+ #warning Reimplementar
+
+ /*
if(systype)
{
set_string_to_config("host","uri","%s",systype);
@@ -197,6 +200,8 @@
else
colors = get_integer_from_config("host","colortype",16);
+ */
+
pw3270_set_session_color_type(widget,colors);
if(host)
--
libgit2 0.21.2