Commit f1519680e3c053a627cd052d3e7439330359664e
1 parent
61f733b9
Exists in
master
and in
1 other branch
Ajustes para compilar numa versão um pouco mais antiga do gtk posto que o gtk3 p…
…ara windows está muito instável
Showing
3 changed files
with
87 additions
and
5 deletions
Show diff stats
accessible.c
@@ -147,8 +147,13 @@ static gboolean v3270_accessible_do_action(AtkAction *action, gint i) | @@ -147,8 +147,13 @@ static gboolean v3270_accessible_do_action(AtkAction *action, gint i) | ||
147 | if(widget == NULL) | 147 | if(widget == NULL) |
148 | return FALSE; | 148 | return FALSE; |
149 | 149 | ||
150 | - if(!gtk_widget_get_sensitive (widget) || !gtk_widget_get_visible (widget)) | 150 | +#if GTK_CHECK_VERSION(2,18,0) |
151 | + if(!gtk_widget_get_sensitive(widget) || !gtk_widget_get_visible(widget)) | ||
151 | return FALSE; | 152 | return FALSE; |
153 | +#else | ||
154 | + if(!GTK_WIDGET_SENSITIVE(widget) || !GTK_WIDGET_VISIBLE(widget)) | ||
155 | + return FALSE; | ||
156 | +#endif // GTK(2,18,0) | ||
152 | 157 | ||
153 | if (i != 0) | 158 | if (i != 0) |
154 | return FALSE; | 159 | return FALSE; |
@@ -747,7 +752,12 @@ static gboolean v3270_accessible_grab_focus(AtkComponent *component) | @@ -747,7 +752,12 @@ static gboolean v3270_accessible_grab_focus(AtkComponent *component) | ||
747 | gtk_widget_grab_focus (widget); | 752 | gtk_widget_grab_focus (widget); |
748 | 753 | ||
749 | toplevel = gtk_widget_get_toplevel (widget); | 754 | toplevel = gtk_widget_get_toplevel (widget); |
750 | - if (gtk_widget_is_toplevel (toplevel)) | 755 | + |
756 | +#if GTK_CHECK_VERSION(2,20,0) | ||
757 | + if(gtk_widget_is_toplevel(toplevel)) | ||
758 | +#else | ||
759 | + if(GTK_WIDGET_TOPLEVEL(toplevel)) | ||
760 | +#endif // GTK(2,20,0) | ||
751 | { | 761 | { |
752 | #ifdef GDK_WINDOWING_X11 | 762 | #ifdef GDK_WINDOWING_X11 |
753 | gtk_window_present_with_time (GTK_WINDOW (toplevel),gdk_x11_get_server_time(gtk_widget_get_window(widget))); | 763 | gtk_window_present_with_time (GTK_WINDOW (toplevel),gdk_x11_get_server_time(gtk_widget_get_window(widget))); |
private.h
@@ -194,6 +194,10 @@ gboolean v3270_draw(GtkWidget * widget, cairo_t * cr); | @@ -194,6 +194,10 @@ gboolean v3270_draw(GtkWidget * widget, cairo_t * cr); | ||
194 | void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect); | 194 | void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect); |
195 | void v3270_update_mouse_pointer(GtkWidget *widget); | 195 | void v3270_update_mouse_pointer(GtkWidget *widget); |
196 | 196 | ||
197 | +#if ! GTK_CHECK_VERSION(2,18,0) | ||
198 | + G_GNUC_INTERNAL void gtk_widget_get_allocation(GtkWidget *widget,GtkAllocation *allocation); | ||
199 | +#endif // !GTK(2,18) | ||
200 | + | ||
197 | #if ! GTK_CHECK_VERSION(2,20,0) | 201 | #if ! GTK_CHECK_VERSION(2,20,0) |
198 | #define gtk_widget_get_realized(w) GTK_WIDGET_REALIZED(w) | 202 | #define gtk_widget_get_realized(w) GTK_WIDGET_REALIZED(w) |
199 | #define gtk_widget_set_realized(w,r) if(r) { GTK_WIDGET_SET_FLAGS(w,GTK_REALIZED); } else { GTK_WIDGET_UNSET_FLAGS(w,GTK_REALIZED); } | 203 | #define gtk_widget_set_realized(w,r) if(r) { GTK_WIDGET_SET_FLAGS(w,GTK_REALIZED); } else { GTK_WIDGET_UNSET_FLAGS(w,GTK_REALIZED); } |
widget.c
@@ -635,7 +635,11 @@ static void select_cursor(H3270 *session, LIB3270_CURSOR id) | @@ -635,7 +635,11 @@ static void select_cursor(H3270 *session, LIB3270_CURSOR id) | ||
635 | { | 635 | { |
636 | GtkWidget *widget = GTK_WIDGET(session->widget); | 636 | GtkWidget *widget = GTK_WIDGET(session->widget); |
637 | 637 | ||
638 | +#if GTK_CHECK_VERSION(2,20,0) | ||
638 | if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) | 639 | if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) |
640 | +#else | ||
641 | + if(GTK_WIDGET_REALIZED(widget) && widget->window) | ||
642 | +#endif // GTK(2,20) | ||
639 | { | 643 | { |
640 | GTK_V3270(widget)->pointer_id = id; | 644 | GTK_V3270(widget)->pointer_id = id; |
641 | v3270_update_mouse_pointer(widget); | 645 | v3270_update_mouse_pointer(widget); |
@@ -646,7 +650,11 @@ static void ctlr_done(H3270 *session) | @@ -646,7 +650,11 @@ static void ctlr_done(H3270 *session) | ||
646 | { | 650 | { |
647 | GtkWidget *widget = GTK_WIDGET(session->widget); | 651 | GtkWidget *widget = GTK_WIDGET(session->widget); |
648 | 652 | ||
653 | +#if GTK_CHECK_VERSION(2,20,0) | ||
649 | if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) | 654 | if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) |
655 | +#else | ||
656 | + if(GTK_WIDGET_REALIZED(widget) && widget->window) | ||
657 | +#endif // GTK(2,20) | ||
650 | { | 658 | { |
651 | v3270_update_mouse_pointer(widget); | 659 | v3270_update_mouse_pointer(widget); |
652 | } | 660 | } |
@@ -764,7 +772,7 @@ static void v3270_init(v3270 *widget) | @@ -764,7 +772,7 @@ static void v3270_init(v3270 *widget) | ||
764 | { | 772 | { |
765 | widget->host = lib3270_session_new(""); | 773 | widget->host = lib3270_session_new(""); |
766 | 774 | ||
767 | - trace("%s",__FUNCTION__); | 775 | + trace("%s host->sz=%d expected=%d revision=%s expected=%s",__FUNCTION__,widget->host->sz,sizeof(H3270),lib3270_get_revision(),PACKAGE_REVISION); |
768 | 776 | ||
769 | if(widget->host->sz != sizeof(H3270)) | 777 | if(widget->host->sz != sizeof(H3270)) |
770 | { | 778 | { |
@@ -799,8 +807,12 @@ static void v3270_init(v3270 *widget) | @@ -799,8 +807,12 @@ static void v3270_init(v3270 *widget) | ||
799 | widget->input_method = gtk_im_multicontext_new(); | 807 | widget->input_method = gtk_im_multicontext_new(); |
800 | g_signal_connect(G_OBJECT(widget->input_method),"commit",G_CALLBACK(v3270_key_commit),widget); | 808 | g_signal_connect(G_OBJECT(widget->input_method),"commit",G_CALLBACK(v3270_key_commit),widget); |
801 | 809 | ||
810 | +#if GTK_CHECK_VERSION(2,18,0) | ||
802 | gtk_widget_set_can_default(GTK_WIDGET(widget),TRUE); | 811 | gtk_widget_set_can_default(GTK_WIDGET(widget),TRUE); |
803 | gtk_widget_set_can_focus(GTK_WIDGET(widget),TRUE); | 812 | gtk_widget_set_can_focus(GTK_WIDGET(widget),TRUE); |
813 | +#else | ||
814 | + GTK_WIDGET_SET_FLAGS(GTK_WIDGET(widget),(GTK_CAN_DEFAULT|GTK_CAN_FOCUS)); | ||
815 | +#endif // GTK(2,18) | ||
804 | 816 | ||
805 | // Setup events | 817 | // Setup events |
806 | gtk_widget_add_events(GTK_WIDGET(widget),GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_MOTION_MASK|GDK_BUTTON_RELEASE_MASK|GDK_POINTER_MOTION_MASK|GDK_ENTER_NOTIFY_MASK); | 818 | gtk_widget_add_events(GTK_WIDGET(widget),GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_MOTION_MASK|GDK_BUTTON_RELEASE_MASK|GDK_POINTER_MOTION_MASK|GDK_ENTER_NOTIFY_MASK); |
@@ -915,6 +927,7 @@ static void release_timer(v3270 *widget) | @@ -915,6 +927,7 @@ static void release_timer(v3270 *widget) | ||
915 | 927 | ||
916 | static void v3270_realize(GtkWidget * widget) | 928 | static void v3270_realize(GtkWidget * widget) |
917 | { | 929 | { |
930 | +#if GTK_CHECK_VERSION(2,18,0) | ||
918 | if(!gtk_widget_get_has_window(widget)) | 931 | if(!gtk_widget_get_has_window(widget)) |
919 | { | 932 | { |
920 | GTK_WIDGET_CLASS(v3270_parent_class)->realize(widget); | 933 | GTK_WIDGET_CLASS(v3270_parent_class)->realize(widget); |
@@ -926,7 +939,6 @@ static void v3270_realize(GtkWidget * widget) | @@ -926,7 +939,6 @@ static void v3270_realize(GtkWidget * widget) | ||
926 | GdkWindowAttr attributes; | 939 | GdkWindowAttr attributes; |
927 | gint attributes_mask; | 940 | gint attributes_mask; |
928 | 941 | ||
929 | - | ||
930 | gtk_widget_set_realized (widget, TRUE); | 942 | gtk_widget_set_realized (widget, TRUE); |
931 | 943 | ||
932 | gtk_widget_get_allocation (widget, &allocation); | 944 | gtk_widget_get_allocation (widget, &allocation); |
@@ -949,6 +961,44 @@ static void v3270_realize(GtkWidget * widget) | @@ -949,6 +961,44 @@ static void v3270_realize(GtkWidget * widget) | ||
949 | gtk_im_context_set_client_window(GTK_V3270(widget)->input_method,window); | 961 | gtk_im_context_set_client_window(GTK_V3270(widget)->input_method,window); |
950 | 962 | ||
951 | } | 963 | } |
964 | +#else | ||
965 | + { | ||
966 | + if(GTK_WIDGET_NO_WINDOW (widget)) | ||
967 | + { | ||
968 | + GTK_WIDGET_CLASS(v3270_parent_class)->realize (widget); | ||
969 | + } | ||
970 | + else | ||
971 | + { | ||
972 | + GdkWindowAttr attributes; | ||
973 | + gint attributes_mask; | ||
974 | + | ||
975 | + GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); | ||
976 | + | ||
977 | + memset(&attributes,0,sizeof(attributes)); | ||
978 | + | ||
979 | + attributes.window_type = GDK_WINDOW_CHILD; | ||
980 | + attributes.x = widget->allocation.x; | ||
981 | + attributes.y = widget->allocation.y; | ||
982 | + attributes.width = widget->allocation.width; | ||
983 | + attributes.height = widget->allocation.height; | ||
984 | + attributes.wclass = GDK_INPUT_OUTPUT; | ||
985 | + attributes.visual = gtk_widget_get_visual (widget); | ||
986 | + attributes.colormap = gtk_widget_get_colormap (widget); | ||
987 | + attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; | ||
988 | + | ||
989 | + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; | ||
990 | + | ||
991 | + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),&attributes, attributes_mask); | ||
992 | + gdk_window_set_user_data(widget->window, widget); | ||
993 | + | ||
994 | + widget->style = gtk_style_attach (widget->style, widget->window); | ||
995 | + gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); | ||
996 | + } | ||
997 | + | ||
998 | + gtk_im_context_set_client_window(GTK_V3270(widget)->input_method,widget->window); | ||
999 | + } | ||
1000 | + | ||
1001 | +#endif // GTK(2,18,0) | ||
952 | 1002 | ||
953 | #if !GTK_CHECK_VERSION(3,0,0) | 1003 | #if !GTK_CHECK_VERSION(3,0,0) |
954 | widget->style = gtk_style_attach (widget->style, widget->window); | 1004 | widget->style = gtk_style_attach (widget->style, widget->window); |
@@ -979,8 +1029,11 @@ static void v3270_size_allocate(GtkWidget * widget, GtkAllocation * allocation) | @@ -979,8 +1029,11 @@ static void v3270_size_allocate(GtkWidget * widget, GtkAllocation * allocation) | ||
979 | g_return_if_fail(allocation != NULL); | 1029 | g_return_if_fail(allocation != NULL); |
980 | 1030 | ||
981 | // trace("Widget size changes to %dx%d",allocation->width,allocation->height); | 1031 | // trace("Widget size changes to %dx%d",allocation->width,allocation->height); |
982 | - | 1032 | +#if GTK_CHECK_VERSION(2,18,0) |
983 | gtk_widget_set_allocation(widget, allocation); | 1033 | gtk_widget_set_allocation(widget, allocation); |
1034 | +#else | ||
1035 | + widget->allocation = *allocation; | ||
1036 | +#endif // GTK(2,18) | ||
984 | 1037 | ||
985 | #if !GTK_CHECK_VERSION(3,0,0) | 1038 | #if !GTK_CHECK_VERSION(3,0,0) |
986 | { | 1039 | { |
@@ -993,14 +1046,27 @@ static void v3270_size_allocate(GtkWidget * widget, GtkAllocation * allocation) | @@ -993,14 +1046,27 @@ static void v3270_size_allocate(GtkWidget * widget, GtkAllocation * allocation) | ||
993 | 1046 | ||
994 | if(gtk_widget_get_realized(widget)) | 1047 | if(gtk_widget_get_realized(widget)) |
995 | { | 1048 | { |
1049 | +#if GTK_CHECK_VERSION(2,18,0) | ||
996 | if(gtk_widget_get_has_window(widget)) | 1050 | if(gtk_widget_get_has_window(widget)) |
997 | gdk_window_move_resize(gtk_widget_get_window (widget),allocation->x, allocation->y,allocation->width, allocation->height); | 1051 | gdk_window_move_resize(gtk_widget_get_window (widget),allocation->x, allocation->y,allocation->width, allocation->height); |
1052 | +#else | ||
1053 | + if(widget->window) | ||
1054 | + gdk_window_move_resize(widget->window,allocation->x, allocation->y,allocation->width, allocation->height); | ||
1055 | +#endif // GTK(2,18,0) | ||
998 | 1056 | ||
999 | v3270_reload(widget); | 1057 | v3270_reload(widget); |
1000 | v3270_send_configure(GTK_V3270(widget)); | 1058 | v3270_send_configure(GTK_V3270(widget)); |
1001 | } | 1059 | } |
1002 | } | 1060 | } |
1003 | 1061 | ||
1062 | +#if ! GTK_CHECK_VERSION(2,18,0) | ||
1063 | +G_GNUC_INTERNAL void gtk_widget_get_allocation(GtkWidget *widget, GtkAllocation *allocation) | ||
1064 | +{ | ||
1065 | + *allocation = widget->allocation; | ||
1066 | +} | ||
1067 | +#endif // !GTK(2,18) | ||
1068 | + | ||
1069 | + | ||
1004 | static void v3270_send_configure(v3270 * terminal) | 1070 | static void v3270_send_configure(v3270 * terminal) |
1005 | { | 1071 | { |
1006 | GtkAllocation allocation; | 1072 | GtkAllocation allocation; |
@@ -1068,6 +1134,8 @@ void v3270_set_colors(GtkWidget *widget, const gchar *colors) | @@ -1068,6 +1134,8 @@ void v3270_set_colors(GtkWidget *widget, const gchar *colors) | ||
1068 | 1134 | ||
1069 | } | 1135 | } |
1070 | 1136 | ||
1137 | + trace("Widget %p colors:\n%s\n",widget,colors); | ||
1138 | + | ||
1071 | v3270_set_color_table(GTK_V3270(widget)->color,colors); | 1139 | v3270_set_color_table(GTK_V3270(widget)->color,colors); |
1072 | g_signal_emit(widget,v3270_widget_signal[SIGNAL_UPDATE_CONFIG], 0, "colors", colors); | 1140 | g_signal_emit(widget,v3270_widget_signal[SIGNAL_UPDATE_CONFIG], 0, "colors", colors); |
1073 | v3270_reload(widget); | 1141 | v3270_reload(widget); |