From 0c06052f3c10589b288c136f256e3f0de7c961e7 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 29 Oct 2012 19:00:45 +0000 Subject: [PATCH] Implementando options na caixa de diálogo de host --- src/include/lib3270.h | 15 +++++++++++++++ src/include/lib3270/session.h | 4 +++- src/lib3270/api.h | 6 ++++-- src/lib3270/host.c | 2 +- src/lib3270/session.c | 12 ++++++++++++ src/lib3270/sf.c | 2 +- src/pw3270/dialog.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 7 files changed, 92 insertions(+), 12 deletions(-) diff --git a/src/include/lib3270.h b/src/include/lib3270.h index cb8ec14..e4ebab5 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -236,6 +236,17 @@ /** + * Connect options + * + */ + typedef enum lib3270_option + { + LIB3270_OPTION_COLOR8 = 0x0001, /**< If active, pw3270 will respond to a Query(Color) with a list of 8 supported colors. */ + LIB3270_OPTION_AS400 = 0x0002, /**< Host is AS400? */ + + } LIB3270_OPTION; + + /** * SSL state * */ @@ -954,6 +965,10 @@ LIB3270_EXPORT void lib3270_set_trace_handler( void (*handler)(H3270 *session, const char *fmt, va_list args) ); LIB3270_EXPORT void lib3270_write_dstrace(H3270 *session, const char *fmt, ...) LIB3270_GNUC_FORMAT(2,3); + LIB3270_EXPORT LIB3270_OPTION lib3270_get_options(H3270 *hSession); + LIB3270_EXPORT void lib3270_set_options(H3270 *hSession, LIB3270_OPTION opt); + + #ifdef __cplusplus } #endif diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h index c3af9d2..144c08c 100644 --- a/src/include/lib3270/session.h +++ b/src/include/lib3270/session.h @@ -83,6 +83,8 @@ LIB3270_CSTATE cstate; /**< Connection state */ // flags + LIB3270_OPTION options; /**< Session options */ + int bgthread : 1; /**< Running on a background thread ? */ int selected : 1; /**< Has selected region? */ int rectsel : 1; /**< Selected region is a rectangle ? */ @@ -96,7 +98,7 @@ int oerr_lock : 1; int unlock_delay : 1; int auto_reconnect_inprogress : 1; - int color8 : 1; +// int color8 : 1; int apl_mode : 1; int icrnl : 1; int inlcr : 1; diff --git a/src/lib3270/api.h b/src/lib3270/api.h index 26aeea5..f30f6b7 100644 --- a/src/lib3270/api.h +++ b/src/lib3270/api.h @@ -299,7 +299,8 @@ #define CHAR_ATTR_UNCONVERTED LIB3270_ATTR_CG - struct lib3270_option +/* + struct _lib3270_option { const char *name; enum @@ -320,7 +321,8 @@ #define new_3270_session(m) lib3270_session_new(m) - LOCAL_EXTERN const struct lib3270_option * get_3270_option_table(int sz); + LOCAL_EXTERN const struct _lib3270_option * get_3270_option_table(int sz); +*/ /* Set/Get screen contents */ diff --git a/src/lib3270/host.c b/src/lib3270/host.c index fbd5263..45b6ad4 100644 --- a/src/lib3270/host.c +++ b/src/lib3270/host.c @@ -607,7 +607,7 @@ static int do_connect(H3270 *hSession, const char *n) */ int lib3270_connect(H3270 *hSession, const char *n, int wait) { - int rc; + int rc; CHECK_SESSION_HANDLE(hSession); diff --git a/src/lib3270/session.c b/src/lib3270/session.c index 1fabc5b..2f26953 100644 --- a/src/lib3270/session.c +++ b/src/lib3270/session.c @@ -453,3 +453,15 @@ LIB3270_EXPORT void * lib3270_get_widget(H3270 *h) CHECK_SESSION_HANDLE(h); return h->widget; } + +LIB3270_EXPORT LIB3270_OPTION lib3270_get_options(H3270 *hSession) +{ + CHECK_SESSION_HANDLE(hSession); + return hSession->options; +} + +LIB3270_EXPORT void lib3270_set_options(H3270 *hSession, LIB3270_OPTION opt) +{ + CHECK_SESSION_HANDLE(hSession); + hSession->options = opt; +} diff --git a/src/lib3270/sf.c b/src/lib3270/sf.c index a5251d7..48cf776 100644 --- a/src/lib3270/sf.c +++ b/src/lib3270/sf.c @@ -820,7 +820,7 @@ static void do_qr_color(H3270 *hSession) trace_ds(hSession,"> QueryReply(Color)\n"); - color_max = hSession->color8 ? 8: 16; /* report on 8 or 16 colors */ + color_max = (hSession->options & LIB3270_OPTION_COLOR8) ? 8: 16; /* report on 8 or 16 colors */ space3270out(hSession,4 + 2*15); *hSession->obptr++ = 0x00; /* no options */ diff --git a/src/pw3270/dialog.c b/src/pw3270/dialog.c index a7649ae..e38fa64 100644 --- a/src/pw3270/dialog.c +++ b/src/pw3270/dialog.c @@ -288,6 +288,26 @@ void hostname_action(GtkAction *action, GtkWidget *widget) { + static const struct _option + { + LIB3270_OPTION value; + const gchar * text; + const gchar * tooltip; + } option[] = + { + { + LIB3270_OPTION_COLOR8, + N_( "_8 colors" ), + N_( "If active, pw3270 will respond to a Query(Color) with a list of 8 supported colors." ) + }, + + { + LIB3270_OPTION_AS400, + N_( "Host is AS_400" ), + NULL + }, + }; + const gchar * title = g_object_get_data(G_OBJECT(action),"title"); gchar * cfghost = get_string_from_config("host","uri",""); gchar * hostname; @@ -297,7 +317,8 @@ 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_mnemonic( _( "_Secure connection" ) )); + GtkToggleButton * sslcheck = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic( _( "_Secure connection" ) )); + GtkToggleButton * optcheck[G_N_ELEMENTS(option)]; GtkWidget * dialog = gtk_dialog_new_with_buttons( gettext(title ? title : N_( "Select hostname" )), GTK_WINDOW(gtk_widget_get_toplevel(widget)), GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, @@ -312,7 +333,6 @@ gtk_entry_set_max_length(port,6); gtk_entry_set_width_chars(port,7); - label = gtk_label_new_with_mnemonic( _("_Hostname:") ); gtk_label_set_mnemonic_widget(GTK_LABEL(label),GTK_WIDGET(host)); gtk_table_attach(table,label,0,1,0,1,0,0,5,0); @@ -323,7 +343,36 @@ gtk_table_attach(table, label, 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); + { + int f; + int col = 1; + int row = 0; + LIB3270_OPTION optval = lib3270_get_options(v3270_get_session(widget)); + + GtkTable * frame = GTK_TABLE(gtk_table_new(2,2,FALSE)); + gtk_table_attach(frame,GTK_WIDGET(sslcheck), 0,1,0,1,GTK_EXPAND|GTK_FILL,0,0,0); + + for(f=0;f 1); + { + col = 0; + row++; + } + + } + + gtk_table_attach(table,GTK_WIDGET(frame),1,2,1,2,GTK_EXPAND|GTK_FILL,0,0,0); + } + gtk_container_set_border_width(GTK_CONTAINER(table),5); @@ -334,12 +383,12 @@ #ifdef HAVE_LIBSSL if(!strncmp(hostname,"L:",2)) { - gtk_toggle_button_set_active(checkbox,TRUE); + gtk_toggle_button_set_active(sslcheck,TRUE); hostname += 2; } #else - gtk_toggle_button_set_active(checkbox,FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(checkbox),FALSE); + gtk_toggle_button_set_active(sslcheck,FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(sslcheck),FALSE); if(!strncmp(hostname,"L:",2)) hostname += 2; #endif @@ -367,7 +416,7 @@ case GTK_RESPONSE_ACCEPT: gtk_widget_set_sensitive(dialog,FALSE); - hostname = g_strconcat( gtk_toggle_button_get_active(checkbox) ? "L:" : "", + hostname = g_strconcat( gtk_toggle_button_get_active(sslcheck) ? "L:" : "", gtk_entry_get_text(host), ":", gtk_entry_get_text(port), -- libgit2 0.21.2