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 | 147 | if(widget == NULL) |
148 | 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 | 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 | 158 | if (i != 0) |
154 | 159 | return FALSE; |
... | ... | @@ -747,7 +752,12 @@ static gboolean v3270_accessible_grab_focus(AtkComponent *component) |
747 | 752 | gtk_widget_grab_focus (widget); |
748 | 753 | |
749 | 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 | 762 | #ifdef GDK_WINDOWING_X11 |
753 | 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 | 194 | void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect); |
195 | 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 | 201 | #if ! GTK_CHECK_VERSION(2,20,0) |
198 | 202 | #define gtk_widget_get_realized(w) GTK_WIDGET_REALIZED(w) |
199 | 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 | 635 | { |
636 | 636 | GtkWidget *widget = GTK_WIDGET(session->widget); |
637 | 637 | |
638 | +#if GTK_CHECK_VERSION(2,20,0) | |
638 | 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 | 644 | GTK_V3270(widget)->pointer_id = id; |
641 | 645 | v3270_update_mouse_pointer(widget); |
... | ... | @@ -646,7 +650,11 @@ static void ctlr_done(H3270 *session) |
646 | 650 | { |
647 | 651 | GtkWidget *widget = GTK_WIDGET(session->widget); |
648 | 652 | |
653 | +#if GTK_CHECK_VERSION(2,20,0) | |
649 | 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 | 659 | v3270_update_mouse_pointer(widget); |
652 | 660 | } |
... | ... | @@ -764,7 +772,7 @@ static void v3270_init(v3270 *widget) |
764 | 772 | { |
765 | 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 | 777 | if(widget->host->sz != sizeof(H3270)) |
770 | 778 | { |
... | ... | @@ -799,8 +807,12 @@ static void v3270_init(v3270 *widget) |
799 | 807 | widget->input_method = gtk_im_multicontext_new(); |
800 | 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 | 811 | gtk_widget_set_can_default(GTK_WIDGET(widget),TRUE); |
803 | 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 | 817 | // Setup events |
806 | 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 | 927 | |
916 | 928 | static void v3270_realize(GtkWidget * widget) |
917 | 929 | { |
930 | +#if GTK_CHECK_VERSION(2,18,0) | |
918 | 931 | if(!gtk_widget_get_has_window(widget)) |
919 | 932 | { |
920 | 933 | GTK_WIDGET_CLASS(v3270_parent_class)->realize(widget); |
... | ... | @@ -926,7 +939,6 @@ static void v3270_realize(GtkWidget * widget) |
926 | 939 | GdkWindowAttr attributes; |
927 | 940 | gint attributes_mask; |
928 | 941 | |
929 | - | |
930 | 942 | gtk_widget_set_realized (widget, TRUE); |
931 | 943 | |
932 | 944 | gtk_widget_get_allocation (widget, &allocation); |
... | ... | @@ -949,6 +961,44 @@ static void v3270_realize(GtkWidget * widget) |
949 | 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 | 1003 | #if !GTK_CHECK_VERSION(3,0,0) |
954 | 1004 | widget->style = gtk_style_attach (widget->style, widget->window); |
... | ... | @@ -979,8 +1029,11 @@ static void v3270_size_allocate(GtkWidget * widget, GtkAllocation * allocation) |
979 | 1029 | g_return_if_fail(allocation != NULL); |
980 | 1030 | |
981 | 1031 | // trace("Widget size changes to %dx%d",allocation->width,allocation->height); |
982 | - | |
1032 | +#if GTK_CHECK_VERSION(2,18,0) | |
983 | 1033 | gtk_widget_set_allocation(widget, allocation); |
1034 | +#else | |
1035 | + widget->allocation = *allocation; | |
1036 | +#endif // GTK(2,18) | |
984 | 1037 | |
985 | 1038 | #if !GTK_CHECK_VERSION(3,0,0) |
986 | 1039 | { |
... | ... | @@ -993,14 +1046,27 @@ static void v3270_size_allocate(GtkWidget * widget, GtkAllocation * allocation) |
993 | 1046 | |
994 | 1047 | if(gtk_widget_get_realized(widget)) |
995 | 1048 | { |
1049 | +#if GTK_CHECK_VERSION(2,18,0) | |
996 | 1050 | if(gtk_widget_get_has_window(widget)) |
997 | 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 | 1057 | v3270_reload(widget); |
1000 | 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 | 1070 | static void v3270_send_configure(v3270 * terminal) |
1005 | 1071 | { |
1006 | 1072 | GtkAllocation allocation; |
... | ... | @@ -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 | 1139 | v3270_set_color_table(GTK_V3270(widget)->color,colors); |
1072 | 1140 | g_signal_emit(widget,v3270_widget_signal[SIGNAL_UPDATE_CONFIG], 0, "colors", colors); |
1073 | 1141 | v3270_reload(widget); | ... | ... |