diff --git a/glade/widget-test.glade b/glade/widget-test.glade new file mode 100644 index 0000000..6ebf35a --- /dev/null +++ b/glade/widget-test.glade @@ -0,0 +1,178 @@ + + + + + + False + + + True + False + vertical + + + True + False + + + True + False + _Arquivo + True + + + True + False + + + gtk-new + True + False + True + True + + + + + gtk-open + True + False + True + True + + + + + gtk-save + True + False + True + True + + + + + gtk-save-as + True + False + True + True + + + + + True + False + + + + + gtk-quit + True + False + True + True + + + + + + + + + True + False + _Editar + True + + + True + False + + + gtk-cut + True + False + True + True + + + + + gtk-copy + True + False + True + True + + + + + gtk-paste + True + False + True + True + + + + + gtk-delete + True + False + True + True + + + + + + + + + True + False + _Ver + True + + + + + True + False + Aj_uda + True + + + True + False + + + gtk-about + True + False + True + True + + + + + + + + + False + True + 0 + + + + + + + + + + + + diff --git a/src/include/v3270.h b/src/include/v3270.h index 9b15cce..32b2b5b 100644 --- a/src/include/v3270.h +++ b/src/include/v3270.h @@ -174,7 +174,7 @@ void v3270_reload(GtkWidget * widget); void v3270_set_font_family(GtkWidget *widget, const gchar *name); - const gchar * v3270_get_font_family(GtkWidget *widget); + const gchar * v3270_get_font_family(GtkWidget *widget); H3270 * v3270_get_session(GtkWidget *widget); gboolean v3270_is_connected(GtkWidget *widget); diff --git a/src/testprogram/testprogram.c b/src/testprogram/testprogram.c index 198b3a7..6fce03b 100644 --- a/src/testprogram/testprogram.c +++ b/src/testprogram/testprogram.c @@ -91,10 +91,11 @@ static void activate(GtkApplication* app, gpointer user_data) { GtkWidget * terminal = v3270_new(); gchar * filename = NULL; - // Setup terminal - GKeyFile * conf = g_key_file_new(); - - // v3270_connect(terminal); + const gchar *url = getenv("LIB3270_DEFAULT_HOST"); + if(url) { + v3270_set_url(terminal,url); + v3270_connect(terminal); + } g_signal_connect(terminal,"popup",G_CALLBACK(popup_menu),NULL); diff --git a/src/v3270/private.h b/src/v3270/private.h index 471fb30..da61376 100644 --- a/src/v3270/private.h +++ b/src/v3270/private.h @@ -226,9 +226,11 @@ G_BEGIN_DECLS /*--[ Globals ]--------------------------------------------------------------------------------------*/ - G_GNUC_INTERNAL guint v3270_widget_signal[LAST_SIGNAL]; - G_GNUC_INTERNAL GdkCursor * v3270_cursor[LIB3270_POINTER_COUNT]; - G_GNUC_INTERNAL GParamSpec * v3270_properties[PROP_LAST]; + G_GNUC_INTERNAL guint v3270_widget_signal[LAST_SIGNAL]; + G_GNUC_INTERNAL GdkCursor * v3270_cursor[LIB3270_POINTER_COUNT]; + G_GNUC_INTERNAL GParamSpec * v3270_properties[PROP_LAST]; + G_GNUC_INTERNAL const gchar * v3270_default_colors; + G_GNUC_INTERNAL const gchar * v3270_default_font; /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ diff --git a/src/v3270/properties.c b/src/v3270/properties.c index 25351d4..ea97df8 100644 --- a/src/v3270/properties.c +++ b/src/v3270/properties.c @@ -51,6 +51,8 @@ static void v3270_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { + debug("%s(%u)",__FUNCTION__,prop_id); + v3270 *window = GTK_V3270(object); switch (prop_id) @@ -80,6 +82,8 @@ static void v3270_get_property(GObject *object,guint prop_id, GValue *value, GParamSpec *pspec) { + debug("%s(%u)",__FUNCTION__,prop_id); + v3270 *window = GTK_V3270(object); switch (prop_id) @@ -124,6 +128,8 @@ void v3270_init_properties(GObjectClass * gobject_class) { + debug("%s",__FUNCTION__); + memset(v3270_properties,0,sizeof(v3270_properties)); gobject_class->set_property = v3270_set_property; diff --git a/src/v3270/widget.c b/src/v3270/widget.c index 078fd47..e03049f 100644 --- a/src/v3270/widget.c +++ b/src/v3270/widget.c @@ -934,8 +934,10 @@ static int popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title, return 0; } -static void v3270_init(v3270 *widget) -{ + const gchar * v3270_default_font = "monospace"; + + static void v3270_init(v3270 *widget) + { struct lib3270_session_callbacks *cbk; widget->host = lib3270_session_new(""); @@ -999,6 +1001,10 @@ static void v3270_init(v3270 *widget) // Enable drawing widget->drawing = 1; + // Set defaults + widget->font.family = g_strdup(v3270_default_font); + v3270_set_color_table(widget->color,v3270_default_colors); + } GtkWidget * v3270_new(void) @@ -1302,46 +1308,50 @@ static void v3270_send_configure(v3270 * terminal) gdk_event_free(event); } +const gchar * v3270_default_colors = + "#000000," // V3270_COLOR_BACKGROUND + "#7890F0," // V3270_COLOR_BLUE + "#FF0000," // V3270_COLOR_RED + "#FF00FF," // V3270_COLOR_PINK + "#00FF00," // V3270_COLOR_GREEN + "#00FFFF," // V3270_COLOR_TURQUOISE + "#FFFF00," // V3270_COLOR_YELLOW + "#FFFFFF," // V3270_COLOR_WHITE + "#000000," // V3270_COLOR_BLACK + "#000080," // V3270_COLOR_DARK_BLUE + "#FFA200," // V3270_COLOR_ORANGE + "#800080," // V3270_COLOR_PURPLE + "#008000," // V3270_COLOR_DARK_GREEN + "#008080," // V3270_COLOR_DARK_TURQUOISE + "#A0A000," // V3270_COLOR_MUSTARD + "#C0C0C0," // V3270_COLOR_GRAY + + "#00FF00," // V3270_COLOR_FIELD_DEFAULT + "#FF0000," // V3270_COLOR_FIELD_INTENSIFIED + "#00FFFF," // V3270_COLOR_FIELD_PROTECTED + "#FFFFFF," // V3270_COLOR_FIELD_PROTECTED_INTENSIFIED + + "#404040," // V3270_COLOR_SELECTED_BG + "#FFFFFF," // V3270_COLOR_SELECTED_FG, + + "#00FF00," // V3270_COLOR_CROSS_HAIR + + "#000000," // V3270_COLOR_OIA_BACKGROUND + "#00FF00," // V3270_COLOR_OIA + "#7890F0," // V3270_COLOR_OIA_SEPARATOR + "#FFFFFF," // V3270_COLOR_OIA_STATUS_OK + "#FFFF00," // V3270_COLOR_OIA_STATUS_WARNING + "#FF0000"; // V3270_COLOR_OIA_STATUS_INVALID + + + void v3270_set_colors(GtkWidget *widget, const gchar *colors) { g_return_if_fail(GTK_IS_V3270(widget)); if(!colors) { - colors = "#000000," // V3270_COLOR_BACKGROUND - "#7890F0," // V3270_COLOR_BLUE - "#FF0000," // V3270_COLOR_RED - "#FF00FF," // V3270_COLOR_PINK - "#00FF00," // V3270_COLOR_GREEN - "#00FFFF," // V3270_COLOR_TURQUOISE - "#FFFF00," // V3270_COLOR_YELLOW - "#FFFFFF," // V3270_COLOR_WHITE - "#000000," // V3270_COLOR_BLACK - "#000080," // V3270_COLOR_DARK_BLUE - "#FFA200," // V3270_COLOR_ORANGE - "#800080," // V3270_COLOR_PURPLE - "#008000," // V3270_COLOR_DARK_GREEN - "#008080," // V3270_COLOR_DARK_TURQUOISE - "#A0A000," // V3270_COLOR_MUSTARD - "#C0C0C0," // V3270_COLOR_GRAY - - "#00FF00," // V3270_COLOR_FIELD_DEFAULT - "#FF0000," // V3270_COLOR_FIELD_INTENSIFIED - "#00FFFF," // V3270_COLOR_FIELD_PROTECTED - "#FFFFFF," // V3270_COLOR_FIELD_PROTECTED_INTENSIFIED - - "#404040," // V3270_COLOR_SELECTED_BG - "#FFFFFF," // V3270_COLOR_SELECTED_FG, - - "#00FF00," // V3270_COLOR_CROSS_HAIR - - "#000000," // V3270_COLOR_OIA_BACKGROUND - "#00FF00," // V3270_COLOR_OIA - "#7890F0," // V3270_COLOR_OIA_SEPARATOR - "#FFFFFF," // V3270_COLOR_OIA_STATUS_OK - "#FFFF00," // V3270_COLOR_OIA_STATUS_WARNING - "#FF0000"; // V3270_COLOR_OIA_STATUS_INVALID - + colors = v3270_default_colors; } v3270_set_color_table(GTK_V3270(widget)->color,colors); @@ -1457,25 +1467,23 @@ void v3270_set_font_family(GtkWidget *widget, const gchar *name) if(!name) { - // TODO (perry#3#): Get default font family from currrent style - name = "courier new"; + name = v3270_default_font; } - if(terminal->font.family) + if(g_ascii_strcasecmp(terminal->font.family,name)) { - if(!g_ascii_strcasecmp(terminal->font.family,name)) - return; + // Font has changed, update it g_free(terminal->font.family); - terminal->font.family = NULL; - } - terminal->font.family = g_strdup(name); - terminal->font.weight = lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; + terminal->font.family = g_strdup(name); + terminal->font.weight = lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; - g_signal_emit(widget,v3270_widget_signal[SIGNAL_UPDATE_CONFIG], 0, "font-family", name); + g_signal_emit(widget,v3270_widget_signal[SIGNAL_UPDATE_CONFIG], 0, "font-family", name); - v3270_reload(widget); - gtk_widget_queue_draw(widget); + v3270_reload(widget); + gtk_widget_queue_draw(widget); + + } } -- libgit2 0.21.2