Commit f28e2c9964a9323e8a847e546c37955de03afd60
1 parent
c8028070
Exists in
master
and in
5 other branches
Ajustes para compilar numa versão um pouco mais antiga do gtk posto que o gtk3 p…
…ara windows está muito instável
Showing
11 changed files
with
118 additions
and
10 deletions
Show diff stats
configure.ac
| ... | ... | @@ -110,6 +110,7 @@ case "$host" in |
| 110 | 110 | DLLEXT=".dll" |
| 111 | 111 | EXEEXT=".exe" |
| 112 | 112 | SOCKET_LIBS="-lws2_32" |
| 113 | + CFLAGS="$CFLAGS -mms-bitfields" | |
| 113 | 114 | AC_PATH_TOOL([STRIP], [strip]) |
| 114 | 115 | ;; |
| 115 | 116 | |
| ... | ... | @@ -201,7 +202,11 @@ AC_ARG_ENABLE([pic], |
| 201 | 202 | [ |
| 202 | 203 | app_cv_pic="$enableval" |
| 203 | 204 | ],[ |
| 204 | - app_cv_pic="yes" | |
| 205 | + if test "$host_cpu" = "x86_64"; then | |
| 206 | + app_cv_pic="yes" | |
| 207 | + else | |
| 208 | + app_cv_pic="no" | |
| 209 | + fi | |
| 205 | 210 | ]) |
| 206 | 211 | |
| 207 | 212 | if test "$app_cv_pic" == "yes"; then |
| ... | ... | @@ -227,7 +232,7 @@ AC_CHECK_FUNCS(getaddrinfo, AC_DEFINE(HAVE_GETADDRINFO) ) |
| 227 | 232 | |
| 228 | 233 | PKG_CHECK_EXISTS |
| 229 | 234 | |
| 230 | -PKG_CHECK_MODULES( [GTK], [gtk+-3.0], [ GTK_VERSION="3" ], [ PKG_CHECK_MODULES( [GTK], [gtk+-2.0 >= 2.8], [ GTK_VERSION="2" ] ) ], [ ] ) | |
| 235 | +PKG_CHECK_MODULES( [GTK], [gtk+-3.0], [ GTK_VERSION="3" ], [ PKG_CHECK_MODULES( [GTK], [gtk+-2.0 >= 2.8 gthread-2.0 gmodule-2.0], [ GTK_VERSION="2" ] ) ], [ ] ) | |
| 231 | 236 | |
| 232 | 237 | AC_SUBST(GTK_LIBS) |
| 233 | 238 | AC_SUBST(GTK_CFLAGS) | ... | ... |
src/pw3270/common/config.c
| ... | ... | @@ -336,7 +336,11 @@ gchar * get_last_error_msg(void) |
| 336 | 336 | BYTE * data; |
| 337 | 337 | |
| 338 | 338 | if(!registry_open_key(group,KEY_READ,&key_handle)) |
| 339 | - return g_strdup(def); | |
| 339 | + { | |
| 340 | + if(def) | |
| 341 | + return g_strdup(def); | |
| 342 | + return NULL; | |
| 343 | + } | |
| 340 | 344 | |
| 341 | 345 | data = (BYTE *) g_malloc0(datalen+2); |
| 342 | 346 | ... | ... |
src/pw3270/filetransfer.c
| ... | ... | @@ -422,7 +422,11 @@ static void run_ft_dialog(GObject *action, GtkWidget *widget, struct ftdialog *d |
| 422 | 422 | &msg ); |
| 423 | 423 | |
| 424 | 424 | |
| 425 | +#if GTK_CHECK_VERSION(2,18,0) | |
| 425 | 426 | gtk_widget_set_visible(dlg->dialog,FALSE); |
| 427 | +#else | |
| 428 | + gtk_widget_hide(dlg->dialog); | |
| 429 | +#endif // GTK(2,18,0) | |
| 426 | 430 | |
| 427 | 431 | if(msg) |
| 428 | 432 | { | ... | ... |
src/pw3270/main.c
| ... | ... | @@ -29,6 +29,7 @@ |
| 29 | 29 | * |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | +#include <glib.h> | |
| 32 | 33 | #include "globals.h" |
| 33 | 34 | #include "v3270/v3270.h" |
| 34 | 35 | #include "v3270/accessible.h" |
| ... | ... | @@ -151,6 +152,10 @@ int main(int argc, char *argv[]) |
| 151 | 152 | |
| 152 | 153 | g_option_context_add_main_entries(options, app_options, NULL); |
| 153 | 154 | |
| 155 | +#if ! GLIB_CHECK_VERSION(2,32,0) | |
| 156 | + g_thread_init(NULL); | |
| 157 | +#endif // !GLIB(2,32) | |
| 158 | + | |
| 154 | 159 | gtk_init(&argc, &argv); |
| 155 | 160 | |
| 156 | 161 | if(!g_option_context_parse( options, &argc, &argv, &error )) | ... | ... |
src/pw3270/uiparser/parsefile.c
| ... | ... | @@ -224,7 +224,6 @@ |
| 224 | 224 | { |
| 225 | 225 | g_object_set_data(G_OBJECT(widget),"parent",info->element); |
| 226 | 226 | info->element = G_OBJECT(widget); |
| 227 | - gtk_widget_set_visible(widget,ui_get_bool_attribute("visible",names,values,TRUE)); | |
| 228 | 227 | |
| 229 | 228 | #if GTK_CHECK_VERSION(2,18,0) |
| 230 | 229 | gtk_widget_set_visible(widget,ui_get_bool_attribute("visible",names,values,TRUE)); | ... | ... |
src/pw3270/uiparser/toolbar.c
| ... | ... | @@ -65,7 +65,12 @@ |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | widget = gtk_toolbar_new(); |
| 68 | + | |
| 69 | +#if GTK_CHECK_VERSION(2,18,0) | |
| 68 | 70 | gtk_widget_set_can_focus(widget,FALSE); |
| 71 | +#else | |
| 72 | + GTK_WIDGET_UNSET_FLAGS(widget,GTK_CAN_FOCUS); | |
| 73 | +#endif // GTK(2,18) | |
| 69 | 74 | |
| 70 | 75 | if(ui_get_attribute("label",names,values)) |
| 71 | 76 | { | ... | ... |
src/pw3270/uiparser/toolitem.c
| ... | ... | @@ -63,7 +63,11 @@ |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | +#if GTK_CHECK_VERSION(2,18,0) | |
| 66 | 67 | gtk_widget_set_can_focus(widget,FALSE); |
| 68 | +#else | |
| 69 | + GTK_WIDGET_UNSET_FLAGS(widget,GTK_CAN_FOCUS); | |
| 70 | +#endif // GTK(2,18) | |
| 67 | 71 | |
| 68 | 72 | gtk_toolbar_insert(GTK_TOOLBAR(info->element),GTK_TOOL_ITEM(widget),-1); |
| 69 | 73 | ... | ... |
src/pw3270/v3270/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))); | ... | ... |
src/pw3270/v3270/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); } | ... | ... |
src/pw3270/v3270/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); | ... | ... |
src/pw3270/window.c
| ... | ... | @@ -378,7 +378,7 @@ |
| 378 | 378 | for(f=0;f<G_N_ELEMENTS(widget_config);f++) |
| 379 | 379 | { |
| 380 | 380 | gchar *str = get_string_from_config("terminal",widget_config[f].key,NULL); |
| 381 | - trace("str=%p strlen=%d",str,strlen(str)); | |
| 381 | +// trace("str=%p strlen=%d",str,strlen(str)); | |
| 382 | 382 | widget_config[f].set(widget->terminal,str); |
| 383 | 383 | if(str) |
| 384 | 384 | g_free(str); | ... | ... |