diff --git a/src/terminal/callbacks.c b/src/terminal/callbacks.c index 2dad66f..455b833 100644 --- a/src/terminal/callbacks.c +++ b/src/terminal/callbacks.c @@ -72,6 +72,8 @@ static void update_toggle(H3270 *session, LIB3270_TOGGLE ix, unsigned char value { GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); + trace("%s(%s,%d)",__FUNCTION__,name,(int) value); + switch(ix) { case LIB3270_TOGGLE_CURSOR_POS: @@ -138,7 +140,7 @@ static void update_toggle(H3270 *session, LIB3270_TOGGLE ix, unsigned char value static gboolean bg_update_message(H3270 *session) { void *widget = lib3270_get_user_data(session); - trace("-----A %s %p",__FUNCTION__, lib3270_get_user_data(session)); + // trace("-----A %s %p",__FUNCTION__, lib3270_get_user_data(session)); g_signal_emit( GTK_WIDGET(widget), @@ -147,7 +149,7 @@ static gboolean bg_update_message(H3270 *session) (gint) lib3270_get_program_message(session) ); - trace("-----B %s %p",__FUNCTION__, lib3270_get_user_data(session)); + //trace("-----B %s %p",__FUNCTION__, lib3270_get_user_data(session)); return FALSE; } @@ -378,7 +380,7 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title static gboolean bg_update_ssl(H3270 *session) { - trace("%s(%p,%p)",__FUNCTION__,session,lib3270_get_user_data(session)); +// trace("%s(%p,%p)",__FUNCTION__,session,lib3270_get_user_data(session)); v3270_blink_ssl(GTK_V3270(lib3270_get_user_data(session))); diff --git a/src/terminal/draw.c b/src/terminal/draw.c index bac7e22..5249ed5 100644 --- a/src/terminal/draw.c +++ b/src/terminal/draw.c @@ -371,13 +371,8 @@ LIB3270_EXPORT void v3270_reload(GtkWidget *widget) { v3270 * terminal = GTK_V3270(widget); -#if GTK_CHECK_VERSION(3,0,0) gint width = gtk_widget_get_allocated_width(widget); gint height = gtk_widget_get_allocated_height(widget); -#else - gint width = terminal->width; - gint height = terminal->height; -#endif GdkRectangle rect; int addr, cursor, r, rows, cols; @@ -385,7 +380,9 @@ LIB3270_EXPORT void v3270_reload(GtkWidget *widget) cairo_t * cr; if(!(gtk_widget_get_realized(widget) && terminal->drawing)) + { return; + } // Create new terminal image if(terminal->surface) diff --git a/src/terminal/font.c b/src/terminal/font.c index 3208229..3b8abea 100644 --- a/src/terminal/font.c +++ b/src/terminal/font.c @@ -36,7 +36,7 @@ #define HEIGHT_IN_PIXELS(terminal,x) (x * (rows+1)) #define CONTENTS_WIDTH(terminal) (cols * terminal->font.width) - #define CONTENTS_HEIGHT(terminal) (((rows+1) * terminal->font.spacing)+OIA_TOP_MARGIN+2) + #define CONTENTS_HEIGHT(terminal) (((rows+2) * terminal->font.spacing)+OIA_TOP_MARGIN+2) /*--[ Globals ]--------------------------------------------------------------------------------------*/ @@ -56,11 +56,12 @@ const gchar * v3270_get_default_font_name() void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int height) { // update font metrics - int rows, cols, hFont, size; + unsigned int rows, cols, hFont, size; cairo_font_extents_t extents; lib3270_get_screen_size(terminal->host,&rows,&cols); + debug("Screen_size: %ux%u Scalled=%s",rows,cols,terminal->font.scaled ? "Yes" : "No"); terminal->font.weight = lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; @@ -143,7 +144,19 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig // Center image size = CONTENTS_WIDTH(terminal); - terminal->font.left = (width >> 1) - ((size) >> 1); + + if(width >= size) { + + terminal->font.left = ((width - size) / 2); + + } else { + + terminal->font.left = 0; + } + + // terminal->font.left = (width >> 1) - ((size) >> 1); + + debug("Width=%u size=%u left=%d",height, size, terminal->font.left); terminal->font.spacing = height / (rows+2); if((int) terminal->font.spacing < hFont) @@ -151,7 +164,19 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig size = CONTENTS_HEIGHT(terminal); - terminal->font.top = (height >> 1) - (size >> 1); + if(height >= size) { + + terminal->font.top = ((height - size) /2); + + } else { + + terminal->font.top = 0; + + } + + //terminal->font.top = (height >> 1) - (size >> 1); + + debug("screen_height=%u content_height=%u top=%d",height, size, terminal->font.top); } diff --git a/src/terminal/iocallback.c b/src/terminal/iocallback.c index ce38a10..66238b5 100644 --- a/src/terminal/iocallback.c +++ b/src/terminal/iocallback.c @@ -148,7 +148,7 @@ static int static_RunTask(H3270 *hSession, int(*callback)(H3270 *, void *), void struct bgParameter p = { TRUE, hSession, -1, callback, parm }; - trace("%s starts -------------------------------------", __FUNCTION__); +// trace("%s starts -------------------------------------", __FUNCTION__); p.running = TRUE; @@ -167,7 +167,7 @@ static int static_RunTask(H3270 *hSession, int(*callback)(H3270 *, void *), void g_thread_join(thread); - trace("%s ends ---------------------------------------", __FUNCTION__); +// trace("%s ends ---------------------------------------", __FUNCTION__); return p.rc; diff --git a/src/terminal/oia.c b/src/terminal/oia.c index 4ea5a3d..d29e722 100644 --- a/src/terminal/oia.c +++ b/src/terminal/oia.c @@ -104,7 +104,7 @@ static gint draw_spinner(cairo_t *cr, GdkRectangle *r, GdkRGBA *color, gint step step++; step %= num_steps; - debug("%s step=%d",__FUNCTION__,step); +// debug("%s step=%d",__FUNCTION__,step); for (i = 0; i < ((gint) num_steps); i++) { @@ -1108,7 +1108,7 @@ void v3270_update_oia(v3270 *terminal, LIB3270_FLAG id, unsigned char on) switch(id) { case LIB3270_FLAG_BOXSOLID: - debug("%s LIB3270_FLAG_BOXSOLID",__FUNCTION__); +// debug("%s LIB3270_FLAG_BOXSOLID",__FUNCTION__); cr = v3270_oia_set_update_region(terminal,&r,V3270_OIA_CONNECTION); v3270_draw_connection(cr,terminal->host,&terminal->font,terminal->color,r); cairo_destroy(cr); @@ -1116,25 +1116,25 @@ void v3270_update_oia(v3270 *terminal, LIB3270_FLAG id, unsigned char on) break; case LIB3270_FLAG_UNDERA: - debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); +// debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); cr = v3270_oia_set_update_region(terminal,&r,V3270_OIA_UNDERA); - debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); +// debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); draw_undera(cr,terminal->host,&terminal->font,terminal->color,r); - debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); +// debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); cairo_destroy(cr); - debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); +// debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); v3270_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height); - debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); +// debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); break; case LIB3270_FLAG_TYPEAHEAD: - debug("%s LIB3270_FLAG_TYPEAHEAD",__FUNCTION__); +// debug("%s LIB3270_FLAG_TYPEAHEAD",__FUNCTION__); v3270_oia_update_text_field(terminal,on,V3270_OIA_TYPEAHEAD,'T'); break; #ifdef HAVE_PRINTER case LIB3270_FLAG_PRINTER: - debug("%s LIB3270_FLAG_PRINTER",__FUNCTION__); +// debug("%s LIB3270_FLAG_PRINTER",__FUNCTION__); v3270_oia_update_text_field(terminal,on,V3270_OIA_PRINTER,'P'); break; #endif // HAVE_PRINTER diff --git a/src/terminal/properties.c b/src/terminal/properties.c index 97ca116..0d0174f 100644 --- a/src/terminal/properties.c +++ b/src/terminal/properties.c @@ -156,14 +156,14 @@ size_t ix; - debug("Property %s=%u",g_param_spec_get_name(pspec),(unsigned int) property_id); +// debug("Property %s=%u",g_param_spec_get_name(pspec),(unsigned int) property_id); g_object_class_install_property(oclass, property_id, pspec); for(ix = 0; ix < G_N_ELEMENTS(properties); ix++) { if(!g_ascii_strcasecmp(properties[ix].name,g_param_spec_get_name(pspec))) { - debug("Property \"%s\" is special",g_param_spec_get_name(pspec)); +// debug("Property \"%s\" is special",g_param_spec_get_name(pspec)); *properties[ix].prop = pspec; break; } @@ -250,7 +250,7 @@ // Creating string properties. for(ix = 0; str_props[ix].name; ix++) { - debug("Property %u=%s (String)",(unsigned int) v3270_properties.type.str + ix, str_props[ix].name); +// debug("Property %u=%s (String)",(unsigned int) v3270_properties.type.str + ix, str_props[ix].name); spec = g_param_spec_string(str_props[ix].name, str_props[ix].name, str_props[ix].description, FALSE,(str_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))); v3270_install_property(gobject_class, v3270_properties.type.str + ix, spec); diff --git a/src/terminal/widget.c b/src/terminal/widget.c index 33f1528..aafd8b3 100644 --- a/src/terminal/widget.c +++ b/src/terminal/widget.c @@ -794,30 +794,12 @@ static void v3270_size_allocate(GtkWidget * widget, GtkAllocation * allocation) g_return_if_fail(GTK_IS_V3270(widget)); g_return_if_fail(allocation != NULL); -#if GTK_CHECK_VERSION(2,18,0) gtk_widget_set_allocation(widget, allocation); -#else - widget->allocation = *allocation; -#endif // GTK(2,18) - -#if !GTK_CHECK_VERSION(3,0,0) - { - v3270 *terminal = GTK_V3270(widget); - - terminal->width = allocation->width; - terminal->height = allocation->height; - } -#endif if(gtk_widget_get_realized(widget)) { -#if GTK_CHECK_VERSION(2,18,0) if(gtk_widget_get_has_window(widget)) gdk_window_move_resize(gtk_widget_get_window (widget),allocation->x, allocation->y,allocation->width, allocation->height); -#else - if(widget->window) - gdk_window_move_resize(widget->window,allocation->x, allocation->y,allocation->width, allocation->height); -#endif // GTK(2,18,0) v3270_reload(widget); v3270_send_configure(GTK_V3270(widget)); diff --git a/src/trace/exec.c b/src/trace/exec.c index ff2f6f7..e7df93f 100644 --- a/src/trace/exec.c +++ b/src/trace/exec.c @@ -62,8 +62,51 @@ return rc; } - static int set_property(H3270 *hSession, const gchar *name, const gchar * value) + static int set_property(GtkWidget *widget, const gchar *name, const gchar * value) { + + GParamSpec * spec = g_object_class_find_property(G_OBJECT_GET_CLASS(widget),name); + + if(!spec) { + return errno = ENOENT; + } + + GValue val = G_VALUE_INIT; + + g_value_init(&val, spec->value_type); + + switch(spec->value_type) + { + case G_TYPE_STRING: + { + g_value_set_string(&val,value); + g_object_set_property(G_OBJECT(widget),name,&val); + } + break; + + case G_TYPE_BOOLEAN: + { + g_value_set_boolean(&val,(atoi(value) == 0 ? FALSE : TRUE)); + g_object_set_property(G_OBJECT(widget),name,&val); + } + break; + + case G_TYPE_INT: + { + g_value_set_int(&val,atoi(value)); + g_object_set_property(G_OBJECT(widget),name,&val); + } + break; + + default: + lib3270_write_trace(v3270_get_session(widget),"%s has an unexpected value type\n",spec->name); + + } + + g_value_unset(&val); + return 0; + + /* size_t ix; debug("%s=%s",name,value); @@ -102,6 +145,7 @@ return sProp[ix].set(hSession,value); } + */ return errno = ENOENT; @@ -123,19 +167,19 @@ switch(spec->value_type) { case G_TYPE_STRING: - lib3270_write_trace(v3270_get_session(widget),"%s=%s",spec->name,g_value_get_string(&val)); + lib3270_write_trace(v3270_get_session(widget),"%s=%s\n",spec->name,g_value_get_string(&val)); break; case G_TYPE_BOOLEAN: - lib3270_write_trace(v3270_get_session(widget),"%s=%s",spec->name,(g_value_get_boolean(&val) ? "true" : "false")); + lib3270_write_trace(v3270_get_session(widget),"%s=%s\n",spec->name,(g_value_get_boolean(&val) ? "true" : "false")); break; case G_TYPE_INT: - lib3270_write_trace(v3270_get_session(widget),"%s=%d",spec->name,g_value_get_int(&val)); + lib3270_write_trace(v3270_get_session(widget),"%s=%d\n",spec->name,g_value_get_int(&val)); break; default: - lib3270_write_trace(v3270_get_session(widget),"%s has an unexpected value type",spec->name); + lib3270_write_trace(v3270_get_session(widget),"%s has an unexpected value type\n",spec->name); } @@ -161,6 +205,29 @@ return lib3270_reconnect(hSession,0); } + if(g_str_has_prefix(cmdline,"reload")) + { + v3270_reload(widget); + return 0; + } + + if(g_str_has_suffix(cmdline,"?")) + { + gchar * str = strchr(cmdline,'?'); + *str = 0; + g_strstrip(cmdline); + return get_property(widget,cmdline); + } + + if(strchr(cmdline,'=')) + { + gchar * value = strchr(cmdline,'='); + *(value++) = 0; + g_strstrip(cmdline); + g_strstrip(value); + return set_property(widget,cmdline,value); + } + if(g_str_has_prefix(cmdline,"disconnect")) { return lib3270_disconnect(hSession); @@ -171,7 +238,7 @@ gchar *txtptr = cmdline+3; const gchar * name = get_word(&txtptr); g_strstrip(txtptr); - return set_property(hSession,name,(*txtptr ? txtptr : "1")); + return set_property(widget,name,(*txtptr ? txtptr : "1")); } if(g_str_has_prefix(cmdline,"get")) @@ -187,14 +254,14 @@ gchar *txtptr = cmdline+3; const gchar * name = get_word(&txtptr); g_strstrip(txtptr); - return set_property(hSession,name,(*txtptr ? txtptr : "0")); + return set_property(widget,name,(*txtptr ? txtptr : "0")); } gchar * sep = strchr(cmdline,'='); if(sep) { *(sep++) = 0; - return set_property(hSession,g_strstrip(cmdline),g_strstrip(sep)); + return set_property(widget,g_strstrip(cmdline),g_strstrip(sep)); } else { -- libgit2 0.21.2