diff --git a/pw3270.cbp b/pw3270.cbp
index 6b2c9f4..17018b5 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -263,6 +263,9 @@
+
+
+
diff --git a/src/include/lib3270.h b/src/include/lib3270.h
index afb07eb..0c7bd18 100644
--- a/src/include/lib3270.h
+++ b/src/include/lib3270.h
@@ -241,12 +241,14 @@
*/
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_KYBD_AS400 = 0x0002, /**< Prefix every PF with PA1 */
- LIB3270_OPTION_TSO = 0x0004, /**< Host is TSO? */
+ LIB3270_OPTION_KYBD_AS400 = 0x0001, /**< Prefix every PF with PA1 */
+ LIB3270_OPTION_TSO = 0x0002, /**< Host is TSO? */
} LIB3270_OPTION;
+
+// LIB3270_OPTION_COLOR8 = 0x0001, /**< If active, pw3270 will respond to a Query(Color) with a list of 8 supported colors. */
+
#define LIB3270_OPTION_DEFAULT 0
#define LIB3270_OPTION_COUNT 3
@@ -979,6 +981,7 @@
LIB3270_EXPORT LIB3270_OPTION lib3270_get_options(H3270 *hSession);
LIB3270_EXPORT void lib3270_set_options(H3270 *hSession, LIB3270_OPTION opt);
+ LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, unsigned short colortype);
LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void);
diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h
index a23e071..70f8bfe 100644
--- a/src/include/lib3270/session.h
+++ b/src/include/lib3270/session.h
@@ -98,7 +98,7 @@
int oerr_lock : 1;
int unlock_delay : 1;
int auto_reconnect_inprogress : 1;
-// int color8 : 1;
+ int colors : 5;
int apl_mode : 1;
int icrnl : 1;
int inlcr : 1;
diff --git a/src/include/pw3270.h b/src/include/pw3270.h
index a848201..7f301a3 100644
--- a/src/include/pw3270.h
+++ b/src/include/pw3270.h
@@ -66,6 +66,7 @@
LIB3270_EXPORT const gchar * pw3270_get_session_name(GtkWidget *widget);
LIB3270_EXPORT void pw3270_set_session_name(GtkWidget *widget, const gchar *name);
LIB3270_EXPORT void pw3270_set_session_options(GtkWidget *widget, LIB3270_OPTION options);
+ LIB3270_EXPORT int pw3270_set_session_color_type(GtkWidget *widget, unsigned short color_type);
LIB3270_EXPORT gint pw3270_get_integer(GtkWidget *widget, const gchar *group, const gchar *key, gint def);
LIB3270_EXPORT void pw3270_set_integer(GtkWidget *widget, const gchar *group, const gchar *key, gint val);
diff --git a/src/include/pw3270/v3270.h b/src/include/pw3270/v3270.h
index 3d450c1..5e7812c 100644
--- a/src/include/pw3270/v3270.h
+++ b/src/include/pw3270/v3270.h
@@ -189,6 +189,7 @@
LIB3270_EXPORT int v3270_set_script(GtkWidget *widget, const gchar id, gboolean on);
LIB3270_EXPORT void v3270_set_scaled_fonts(GtkWidget *widget, gboolean on);
LIB3270_EXPORT void v3270_set_session_options(GtkWidget *widget, LIB3270_OPTION options);
+ LIB3270_EXPORT int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype);
LIB3270_EXPORT void v3270_set_host(GtkWidget *widget, const gchar *uri);
// Keyboard & Mouse special actions
diff --git a/src/lib3270/options.c b/src/lib3270/options.c
index 9dd5389..6288c77 100644
--- a/src/lib3270/options.c
+++ b/src/lib3270/options.c
@@ -39,13 +39,6 @@
static const const LIB3270_OPTION_ENTRY options[LIB3270_OPTION_COUNT+1] =
{
{
- LIB3270_OPTION_COLOR8,
- "color8",
- N_( "_8 colors" ),
- N_( "If active, pw3270 will respond to a Query(Color) with a list of 8 supported colors." )
- },
-
- {
LIB3270_OPTION_KYBD_AS400,
"as400",
N_( "Host is AS/400" ),
@@ -84,6 +77,37 @@ LIB3270_EXPORT void lib3270_set_options(H3270 *hSession, LIB3270_OPTION opt)
hSession->options = opt;
}
+LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, unsigned short colortype)
+{
+ CHECK_SESSION_HANDLE(hSession);
+
+ switch(colortype)
+ {
+ case 0:
+ case 16:
+ hSession->colors = 16;
+ hSession->mono = 0;
+ break;
+
+ case 8:
+ hSession->colors = 8;
+ hSession->mono = 0;
+ break;
+
+ case 2:
+ hSession->colors = 16;
+ hSession->mono = 1;
+ break;
+
+ default:
+ return EINVAL;
+ }
+
+
+ return 0;
+}
+
+
LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void)
{
return options;
diff --git a/src/lib3270/sf.c b/src/lib3270/sf.c
index 48cf776..2d1fcc0 100644
--- a/src/lib3270/sf.c
+++ b/src/lib3270/sf.c
@@ -820,13 +820,13 @@ static void do_qr_color(H3270 *hSession)
trace_ds(hSession,"> QueryReply(Color)\n");
- color_max = (hSession->options & LIB3270_OPTION_COLOR8) ? 8: 16; /* report on 8 or 16 colors */
+ color_max = (hSession->colors == 8) ? 8: 16; /* report on 8 or 16 colors */
space3270out(hSession,4 + 2*15);
- *hSession->obptr++ = 0x00; /* no options */
- *hSession->obptr++ = color_max; /* report on 8 or 16 colors */
- *hSession->obptr++ = 0x00; /* default color: */
- *hSession->obptr++ = 0xf0 + COLOR_GREEN; /* green */
+ *hSession->obptr++ = 0x00; /* no options */
+ *hSession->obptr++ = color_max; /* report on 8 or 16 colors */
+ *hSession->obptr++ = 0x00; /* default color: */
+ *hSession->obptr++ = 0xf0 + COLOR_GREEN; /* green */
for (i = 0xf1; i < 0xf1 + color_max - 1; i++)
{
*hSession->obptr++ = i;
diff --git a/src/pw3270/Makefile.in b/src/pw3270/Makefile.in
index bb910a3..5c55449 100644
--- a/src/pw3270/Makefile.in
+++ b/src/pw3270/Makefile.in
@@ -58,7 +58,7 @@ include uiparser/sources.mak
APP_SOURCES= main.c @APP_GUI_SRC@
-LIB_SOURCES= window.c actions.c fonts.c dialog.c print.c colors.c \
+LIB_SOURCES= window.c actions.c fonts.c dialog.c hostdialog.c print.c colors.c \
filetransfer.c tools.c plugin.c macros.c\
$(foreach SRC, $(UI_PARSER_SRC), uiparser/$(SRC)) \
$(foreach SRC, $(V3270_SRC), v3270/$(SRC)) \
diff --git a/src/pw3270/actions.c b/src/pw3270/actions.c
index 12e0b12..4d96068 100644
--- a/src/pw3270/actions.c
+++ b/src/pw3270/actions.c
@@ -74,6 +74,7 @@ static void connect_action(GtkAction *action, GtkWidget *widget)
if(host)
{
v3270_set_session_options(widget,0);
+ v3270_set_session_color_type(widget,0);
v3270_connect(widget,host);
return;
}
diff --git a/src/pw3270/dialog.c b/src/pw3270/dialog.c
index dd67350..ee5a2b2 100644
--- a/src/pw3270/dialog.c
+++ b/src/pw3270/dialog.c
@@ -34,19 +34,6 @@
/*--[ Globals ]--------------------------------------------------------------------------------------*/
- static const struct _host_type
- {
- const gchar * name;
- const gchar * description;
- LIB3270_OPTION option;
- } host_type[] =
- {
- { "S390", N_( "IBM S/390" ), LIB3270_OPTION_TSO },
- { "AS400", N_( "IBM AS/400" ), LIB3270_OPTION_KYBD_AS400 },
- { "TSO", N_( "Other (TSO)" ), LIB3270_OPTION_TSO },
- { "VM/CMS", N_( "Other (VM/CMS)" ), 0 }
- };
-
static const struct _charset
{
const gchar *name;
@@ -317,193 +304,6 @@
return 0;
}
-
- void hostname_action(GtkAction *action, GtkWidget *widget)
- {
-// const LIB3270_OPTION_ENTRY *options = lib3270_get_option_list();
-
- const gchar * title = g_object_get_data(G_OBJECT(action),"title");
- const gchar * systype = g_object_get_data(G_OBJECT(action),"type");
- gchar * cfghost = get_string_from_config("host","uri","");
- gchar * hostname;
- gchar * ptr;
- gboolean again = TRUE;
- GtkWidget * label;
- GtkTable * table = GTK_TABLE(gtk_table_new(3,4,FALSE));
- GtkEntry * host = GTK_ENTRY(gtk_entry_new());
- GtkEntry * port = GTK_ENTRY(gtk_entry_new());
- GtkToggleButton * sslcheck = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic( _( "_Secure connection" ) ));
-// GtkToggleButton * optcheck[LIB3270_OPTION_COUNT];
- 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,
- 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,50);
-
- 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);
- gtk_table_attach(table,GTK_WIDGET(host), 1,2,0,1,GTK_EXPAND|GTK_FILL,0,0,0);
-
- label = gtk_label_new_with_mnemonic( _( "_Port:" ) );
- gtk_label_set_mnemonic_widget(GTK_LABEL(label),GTK_WIDGET(port));
- 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(sslcheck), 1,2,1,2,GTK_EXPAND|GTK_FILL,0,0,0);
-
- {
- GtkWidget * expander = gtk_expander_new_with_mnemonic(_( "_Host options"));
- GtkBox * container = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL,0));
-
- // Host options
- if(!systype)
- {
- // No system type defined, ask user
- GtkTable * frame = GTK_TABLE(gtk_table_new(2,2,FALSE));
- GtkWidget * widget = gtk_combo_box_text_new();
- gchar * str = get_string_from_config("host","systype",host_type[0].name);
- int f;
-
- label = gtk_label_new_with_mnemonic( _("System _Type:") );
- gtk_table_attach(frame,label,0,1,0,1,0,0,5,0);
-
- for(f=0;f 1)
- {
- col = 0;
- row++;
- }
-
- }
-
- gtk_container_add(GTK_CONTAINER(container),GTK_WIDGET(frame));
-
-*/
- gtk_container_add(GTK_CONTAINER(expander),GTK_WIDGET(container));
- gtk_table_attach(table,expander,1,2,2,3,GTK_EXPAND|GTK_FILL,0,0,0);
- }
-
-
- gtk_container_set_border_width(GTK_CONTAINER(table),5);
-
- gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(table),FALSE,FALSE,2);
-
- hostname = cfghost;
-
-#ifdef HAVE_LIBSSL
- if(!strncmp(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(!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);
-
- hostname = g_strconcat( gtk_toggle_button_get_active(sslcheck) ? "L:" : "",
- gtk_entry_get_text(host),
- ":",
- gtk_entry_get_text(port),
- NULL
- );
-
- {
-// int f;
- LIB3270_OPTION opt = 0;
-
-/*
- for(f=0;f
+ *
+ * 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 "globals.h"
+ #include
+
+/*--[ Globals ]--------------------------------------------------------------------------------------*/
+
+ static const struct _host_type
+ {
+ const gchar * name;
+ const gchar * description;
+ LIB3270_OPTION option;
+ } host_type[] =
+ {
+ { "S390", N_( "IBM S/390" ), LIB3270_OPTION_TSO },
+ { "AS400", N_( "IBM AS/400" ), LIB3270_OPTION_KYBD_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" ) },
+ };
+
+/*--[ Implement ]------------------------------------------------------------------------------------*/
+
+ static void set_row(int row, GtkWidget *widget, GtkTable *container, const gchar *text)
+ {
+ GtkWidget *label = gtk_label_new_with_mnemonic(text);
+
+ gtk_misc_set_alignment(GTK_MISC(label),0,0.5);
+
+ gtk_table_attach(container,label,0,1,row,row+1,GTK_FILL,0,5,0);
+ gtk_table_attach(container,widget,1,2,row,row+1,GTK_FILL,0,0,0);
+ gtk_label_set_mnemonic_widget(GTK_LABEL(label),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;
+ int iHostType = 0;
+ int iColorTable = 0;
+ GtkTable * table = GTK_TABLE(gtk_table_new(3,4,FALSE));
+ GtkEntry * host = GTK_ENTRY(gtk_entry_new());
+ GtkEntry * port = GTK_ENTRY(gtk_entry_new());
+ GtkToggleButton * sslcheck = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic( _( "_Secure connection" ) ));
+ 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,
+ 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,50);
+
+ gtk_entry_set_max_length(port,6);
+ gtk_entry_set_width_chars(port,7);
+
+
+ {
+ GtkWidget * label;
+
+ 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);
+ gtk_table_attach(table,GTK_WIDGET(host), 1,2,0,1,GTK_EXPAND|GTK_FILL,0,0,0);
+
+ label = gtk_label_new_with_mnemonic( _( "_Port:" ) );
+ gtk_label_set_mnemonic_widget(GTK_LABEL(label),GTK_WIDGET(port));
+ 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(sslcheck), 1,2,1,2,GTK_EXPAND|GTK_FILL,0,0,0);
+ }
+
+ {
+ // Host options
+ const gchar * systype = g_object_get_data(G_OBJECT(action),"type");
+ const gchar * colortype = g_object_get_data(G_OBJECT(action),"colors");
+
+ int row = 0;
+ GtkWidget * expander = gtk_expander_new_with_mnemonic(_( "_Host options"));
+ GtkTable * container = GTK_TABLE(gtk_table_new(3,2,FALSE));
+
+ if(!systype)
+ {
+ // No system type defined, ask user
+ gchar * str = get_string_from_config("host","systype",host_type[0].name);
+ GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT);
+ GtkWidget * widget = gtk_combo_box_new_with_model(model);
+ GtkCellRenderer * renderer = gtk_cell_renderer_text_new();
+
+ int f;
+
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE);
+ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "text", 0, NULL);
+
+ for(f=0;fhost |= LIB3270_OPTION_COLOR8;
- break;
-
- case 16:
- break;
+ static const unsigned char valid[] = { 2,8,16 };
+ int f;
+ unsigned char optval = (unsigned char) atoi(value);
- default:
- *error = g_error_new(ERROR_DOMAIN,EINVAL, _("Unexpected or invalid color value \"%s\""), value );
- return FALSE;
+ for(f=0;fcolors = optval;
+ return TRUE;
+ }
}
- return TRUE;
+ *error = g_error_new(ERROR_DOMAIN,EINVAL, _("Unexpected or invalid color value \"%s\""), value );
+ return FALSE;
}
int main(int argc, char *argv[])
@@ -344,7 +344,8 @@ int main(int argc, char *argv[])
toplevel = pw3270_new(host);
pw3270_set_session_name(toplevel,session_name);
- pw3270_set_session_options(toplevel,cmdline_opt.host);
+ pw3270_set_session_color_type(toplevel,cmdline_opt.colors);
+ // pw3270_set_session_options(toplevel,cmdline_opt.host);
toplevel_setup(GTK_WINDOW(toplevel));
diff --git a/src/pw3270/v3270/widget.c b/src/pw3270/v3270/widget.c
index cab60c0..b0e7961 100644
--- a/src/pw3270/v3270/widget.c
+++ b/src/pw3270/v3270/widget.c
@@ -1444,6 +1444,12 @@ void v3270_set_session_options(GtkWidget *widget, LIB3270_OPTION options)
lib3270_set_options(GTK_V3270(widget)->host,options);
}
+int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype)
+{
+ g_return_val_if_fail(GTK_IS_V3270(widget),EFAULT);
+ return lib3270_set_color_type(GTK_V3270(widget)->host,colortype);
+}
+
gboolean v3270_is_connected(GtkWidget *widget)
{
g_return_val_if_fail(GTK_IS_V3270(widget),FALSE);
diff --git a/src/pw3270/window.c b/src/pw3270/window.c
index 88cd058..8e12801 100644
--- a/src/pw3270/window.c
+++ b/src/pw3270/window.c
@@ -239,6 +239,12 @@
v3270_set_session_options(GTK_PW3270(widget)->terminal,options);
}
+ LIB3270_EXPORT int pw3270_set_session_color_type(GtkWidget *widget, unsigned short colortype)
+ {
+ g_return_val_if_fail(GTK_IS_PW3270(widget),EFAULT);
+ return v3270_set_session_color_type(GTK_PW3270(widget)->terminal,colortype);
+ }
+
static void chktoplevel(GtkWidget *window, GtkWidget **widget)
{
if(*widget)
--
libgit2 0.21.2