diff options
Diffstat (limited to 'src/gui_gtk_x11.c')
-rw-r--r-- | src/gui_gtk_x11.c | 360 |
1 files changed, 13 insertions, 347 deletions
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index d1a705b992..2e9cae368f 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -804,11 +804,7 @@ gtk_settings_xft_dpi_changed_cb(GtkSettings *gtk_settings UNUSED, } } -#if GTK_CHECK_VERSION(3,0,0) typedef gboolean timeout_cb_type; -#else -typedef gint timeout_cb_type; -#endif /* * Start a timer that will invoke the specified callback. @@ -817,21 +813,13 @@ typedef gint timeout_cb_type; static guint timeout_add(int time, timeout_cb_type (*callback)(gpointer), int *flagp) { -#if GTK_CHECK_VERSION(3,0,0) return g_timeout_add((guint)time, (GSourceFunc)callback, flagp); -#else - return gtk_timeout_add((guint32)time, (GtkFunction)callback, flagp); -#endif } static void timeout_remove(guint timer) { -#if GTK_CHECK_VERSION(3,0,0) g_source_remove(timer); -#else - gtk_timeout_remove(timer); -#endif } @@ -974,11 +962,7 @@ enter_notify_event(GtkWidget *widget UNUSED, gui_mch_start_blink(); /* make sure keyboard input goes there */ -#if GTK_CHECK_VERSION(3,0,0) if (gtk_socket_id == 0 || !gtk_widget_has_focus(gui.drawarea)) -#else - if (gtk_socket_id == 0 || !GTK_WIDGET_HAS_FOCUS(gui.drawarea)) -#endif gtk_widget_grab_focus(gui.drawarea); return FALSE; @@ -1418,22 +1402,13 @@ selection_received_cb(GtkWidget *widget UNUSED, int len; int motion_type = MAUTO; -#if GTK_CHECK_VERSION(3,0,0) if (gtk_selection_data_get_selection(data) == clip_plus.gtk_sel_atom) -#else - if (data->selection == clip_plus.gtk_sel_atom) -#endif cbd = &clip_plus; else cbd = &clip_star; -#if GTK_CHECK_VERSION(3,0,0) text = (char_u *)gtk_selection_data_get_data(data); len = gtk_selection_data_get_length(data); -#else - text = (char_u *)data->data; - len = data->length; -#endif if (text == NULL || len <= 0) { @@ -1443,20 +1418,12 @@ selection_received_cb(GtkWidget *widget UNUSED, return; } -#if GTK_CHECK_VERSION(3,0,0) if (gtk_selection_data_get_data_type(data) == vim_atom) -#else - if (data->type == vim_atom) -#endif { motion_type = *text++; --len; } -#if GTK_CHECK_VERSION(3,0,0) else if (gtk_selection_data_get_data_type(data) == vimenc_atom) -#else - else if (data->type == vimenc_atom) -#endif { char_u *enc; vimconv_T conv; @@ -1547,12 +1514,8 @@ selection_get_cb(GtkWidget *widget UNUSED, GdkAtom type; VimClipboard *cbd; -#if GTK_CHECK_VERSION(3,0,0) if (gtk_selection_data_get_selection(selection_data) == clip_plus.gtk_sel_atom) -#else - if (selection_data->selection == clip_plus.gtk_sel_atom) -#endif cbd = &clip_plus; else cbd = &clip_star; @@ -1785,9 +1748,7 @@ process_motion_notify(int x, int y, GdkModifierType state) { int button; int_u vim_modifiers; -#if GTK_CHECK_VERSION(3,0,0) GtkAllocation allocation; -#endif button = (state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | @@ -1814,17 +1775,11 @@ process_motion_notify(int x, int y, GdkModifierType state) /* * Auto repeat timer handling. */ -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_allocation(gui.drawarea, &allocation); if (x < 0 || y < 0 || x >= allocation.width || y >= allocation.height) -#else - if (x < 0 || y < 0 - || x >= gui.drawarea->allocation.width - || y >= gui.drawarea->allocation.height) -#endif { int dx; @@ -1835,13 +1790,8 @@ process_motion_notify(int x, int y, GdkModifierType state) /* Calculate the maximal distance of the cursor from the drawing area. * (offshoot can't become negative here!). */ -#if GTK_CHECK_VERSION(3,0,0) dx = x < 0 ? -x : x - allocation.width; dy = y < 0 ? -y : y - allocation.height; -#else - dx = x < 0 ? -x : x - gui.drawarea->allocation.width; - dy = y < 0 ? -y : y - gui.drawarea->allocation.height; -#endif offshoot = dx > dy ? dx : dy; @@ -1907,6 +1857,10 @@ gui_gtk_window_at_position(GtkWidget *widget, return gdk_device_get_window_at_position(dev, x, y); } # endif +#else /* !GTK_CHECK_VERSION(3,0,0) */ +# define gui_gtk_get_pointer(wid, x, y, s) \ + gdk_window_get_pointer((wid)->window, x, y, s) +# define gui_gtk_window_at_position(wid, x, y) gdk_window_at_pointer(x, y) #endif /* @@ -1919,11 +1873,7 @@ motion_repeat_timer_cb(gpointer data UNUSED) int y; GdkModifierType state; -#if GTK_CHECK_VERSION(3,0,0) gui_gtk_get_pointer(gui.drawarea, &x, &y, &state); -#else - gdk_window_get_pointer(gui.drawarea->window, &x, &y, &state); -#endif if (!(state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | @@ -1968,11 +1918,7 @@ motion_notify_event(GtkWidget *widget, int y; GdkModifierType state; -#if GTK_CHECK_VERSION(3,0,0) gui_gtk_get_pointer(widget, &x, &y, &state); -#else - gdk_window_get_pointer(widget->window, &x, &y, &state); -#endif process_motion_notify(x, y, state); } else @@ -2003,11 +1949,7 @@ button_press_event(GtkWidget *widget, gui.event_time = event->time; /* Make sure we have focus now we've been selected */ -#if GTK_CHECK_VERSION(3,0,0) if (gtk_socket_id != 0 && !gtk_widget_has_focus(widget)) -#else - if (gtk_socket_id != 0 && !GTK_WIDGET_HAS_FOCUS(widget)) -#endif gtk_widget_grab_focus(widget); /* @@ -2069,11 +2011,7 @@ scroll_event(GtkWidget *widget, int button; int_u vim_modifiers; -#if GTK_CHECK_VERSION(3,0,0) if (gtk_socket_id != 0 && !gtk_widget_has_focus(widget)) -#else - if (gtk_socket_id != 0 && !GTK_WIDGET_HAS_FOCUS(widget)) -#endif gtk_widget_grab_focus(widget); switch (event->direction) @@ -2239,13 +2177,9 @@ drag_handle_uri_list(GdkDragContext *context, char_u **fnames; int nfiles = 0; -# if GTK_CHECK_VERSION(3,0,0) fnames = parse_uri_list(&nfiles, (char_u *)gtk_selection_data_get_data(data), gtk_selection_data_get_length(data)); -# else - fnames = parse_uri_list(&nfiles, data->data, data->length); -# endif if (fnames != NULL && nfiles > 0) { @@ -2272,19 +2206,10 @@ drag_handle_text(GdkDragContext *context, int len; char_u *tmpbuf = NULL; -# if GTK_CHECK_VERSION(3,0,0) text = (char_u *)gtk_selection_data_get_data(data); len = gtk_selection_data_get_length(data); -# else - text = data->data; - len = data->length; -# endif -# if GTK_CHECK_VERSION(3,0,0) if (gtk_selection_data_get_data_type(data) == utf8_string_atom) -# else - if (data->type == utf8_string_atom) -# endif { if (input_conv.vc_type != CONV_NONE) tmpbuf = string_convert(&input_conv, text, &len); @@ -2320,7 +2245,6 @@ drag_data_received_cb(GtkWidget *widget, GdkModifierType state; /* Guard against trash */ -# if GTK_CHECK_VERSION(3,0,0) const guchar * const data_data = gtk_selection_data_get_data(data); const gint data_length = gtk_selection_data_get_length(data); const gint data_format = gtk_selection_data_get_format(data); @@ -2329,12 +2253,6 @@ drag_data_received_cb(GtkWidget *widget, || data_length <= 0 || data_format != 8 || data_data[data_length] != '\0') -# else - if (data->data == NULL - || data->length <= 0 - || data->format != 8 - || data->data[data->length] != '\0') -# endif { gtk_drag_finish(context, FALSE, FALSE, time_); return; @@ -2342,11 +2260,7 @@ drag_data_received_cb(GtkWidget *widget, /* Get the current modifier state for proper distinguishment between * different operations later. */ -#if GTK_CHECK_VERSION(3,0,0) gui_gtk_get_pointer(widget, NULL, NULL, &state); -# else - gdk_window_get_pointer(widget->window, NULL, NULL, &state); -# endif /* Not sure about the role of "text/plain" here... */ if (info == (guint)TARGET_TEXT_URI_LIST) @@ -2810,13 +2724,8 @@ mainwin_realize(GtkWidget *widget UNUSED, gpointer data UNUSED) GDK_WINDOW_XID(mainwin_win)); } gtk_widget_add_events(gui.mainwin, GDK_PROPERTY_CHANGE_MASK); -# if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.mainwin), "property-notify-event", G_CALLBACK(property_event), NULL); -# else - gtk_signal_connect(GTK_OBJECT(gui.mainwin), "property_notify_event", - GTK_SIGNAL_FUNC(property_event), NULL); -# endif #endif } @@ -2935,9 +2844,7 @@ mainwin_screen_changed_cb(GtkWidget *widget, drawarea_realize_cb(GtkWidget *widget, gpointer data UNUSED) { GtkWidget *sbar; -#if GTK_CHECK_VERSION(3,0,0) GtkAllocation allocation; -#endif #ifdef FEAT_XIM xim_init(); @@ -2962,23 +2869,13 @@ drawarea_realize_cb(GtkWidget *widget, gpointer data UNUSED) if (!sbar || (!gui.which_scrollbars[SBAR_LEFT] && firstwin->w_scrollbars[SBAR_RIGHT].id)) sbar = firstwin->w_scrollbars[SBAR_RIGHT].id; -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_allocation(sbar, &allocation); if (sbar && gtk_widget_get_realized(sbar) && allocation.width) gui.scrollbar_width = allocation.width; -#else - if (sbar && GTK_WIDGET_REALIZED(sbar) && sbar->allocation.width) - gui.scrollbar_width = sbar->allocation.width; -#endif sbar = gui.bottom_sbar.id; -#if GTK_CHECK_VERSION(3,0,0) if (sbar && gtk_widget_get_realized(sbar) && allocation.height) gui.scrollbar_height = allocation.height; -#else - if (sbar && GTK_WIDGET_REALIZED(sbar) && sbar->allocation.height) - gui.scrollbar_height = sbar->allocation.height; -#endif } /* @@ -3142,32 +3039,21 @@ get_item_dimensions(GtkWidget *widget, GtkOrientation orientation) # define item_orientation GTK_ORIENTATION_HORIZONTAL # endif -# if GTK_CHECK_VERSION(3,0,0) if (widget != NULL && item_orientation == orientation && gtk_widget_get_realized(widget) && gtk_widget_get_visible(widget)) -# else - if (widget != NULL - && item_orientation == orientation - && GTK_WIDGET_REALIZED(widget) - && GTK_WIDGET_VISIBLE(widget)) -# endif { -# if GTK_CHECK_VERSION(3,0,0) +# if GTK_CHECK_VERSION(3,0,0) || !defined(FEAT_GUI_GNOME) GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); return allocation.height; # else -# ifdef FEAT_GUI_GNOME if (orientation == GTK_ORIENTATION_HORIZONTAL) return widget->allocation.height; else return widget->allocation.width; -# else - return widget->allocation.height; -# endif # endif } return 0; @@ -3438,15 +3324,9 @@ add_tabline_menu_item(GtkWidget *menu, char_u *text, int resp) CONVERT_TO_UTF8_FREE(utf_text); gtk_container_add(GTK_CONTAINER(menu), item); -# if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(tabline_menu_handler), GINT_TO_POINTER(resp)); -# else - gtk_signal_connect(GTK_OBJECT(item), "activate", - GTK_SIGNAL_FUNC(tabline_menu_handler), - (gpointer)(long)resp); -# endif } /* @@ -3488,20 +3368,11 @@ on_tabline_menu(GtkWidget *widget, GdkEvent *event) ) return TRUE; -# if GTK_CHECK_VERSION(3,0,0) tabwin = gui_gtk_window_at_position(gui.mainwin, &x, &y); -# else - tabwin = gdk_window_at_pointer(&x, &y); -# endif gdk_window_get_user_data(tabwin, (gpointer)&tabwidget); -# if GTK_CHECK_VERSION(3,0,0) clicked_page = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(tabwidget), "tab_num")); -# else - clicked_page = (int)(long)gtk_object_get_user_data( - GTK_OBJECT(tabwidget)); -# endif /* If the event was generated for 3rd button popup the menu. */ if (bevent->button == 3) @@ -3536,11 +3407,7 @@ on_tabline_menu(GtkWidget *widget, GdkEvent *event) static void on_select_tab( GtkNotebook *notebook UNUSED, -# if GTK_CHECK_VERSION(3,0,0) gpointer *page UNUSED, -# else - GtkNotebookPage *page UNUSED, -# endif gint idx, gpointer data UNUSED) { @@ -3554,11 +3421,7 @@ on_select_tab( static void on_tab_reordered( GtkNotebook *notebook UNUSED, -# if GTK_CHECK_VERSION(3,0,0) gpointer *page UNUSED, -# else - GtkNotebookPage *page UNUSED, -# endif gint idx, gpointer data UNUSED) { @@ -3586,11 +3449,7 @@ gui_mch_show_tabline(int showit) gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gui.tabline), showit); update_window_manager_hints(0, 0); if (showit) -# if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_can_focus(GTK_WIDGET(gui.tabline), FALSE); -# else - GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(gui.tabline), GTK_CAN_FOCUS); -# endif } gui_mch_update(); @@ -3663,18 +3522,9 @@ gui_mch_update_tabline(void) } event_box = gtk_notebook_get_tab_label(GTK_NOTEBOOK(gui.tabline), page); -# if GTK_CHECK_VERSION(3,0,0) g_object_set_data(G_OBJECT(event_box), "tab_num", GINT_TO_POINTER(tab_num)); -# else - gtk_object_set_user_data(GTK_OBJECT(event_box), - (gpointer)(long)tab_num); -# endif -# if GTK_CHECK_VERSION(3,0,0) label = gtk_bin_get_child(GTK_BIN(event_box)); -# else - label = GTK_BIN(event_box)->child; -# endif get_tabline_label(tp, FALSE); labeltext = CONVERT_TO_UTF8(NameBuff); gtk_label_set_text(GTK_LABEL(label), (const char *)labeltext); @@ -3695,13 +3545,8 @@ gui_mch_update_tabline(void) while (gtk_notebook_get_nth_page(GTK_NOTEBOOK(gui.tabline), nr) != NULL) gtk_notebook_remove_page(GTK_NOTEBOOK(gui.tabline), nr); -# if GTK_CHECK_VERSION(3,0,0) if (gtk_notebook_get_current_page(GTK_NOTEBOOK(gui.tabline)) != curtabidx) gtk_notebook_set_current_page(GTK_NOTEBOOK(gui.tabline), curtabidx); -# else - if (gtk_notebook_current_page(GTK_NOTEBOOK(gui.tabline)) != curtabidx) - gtk_notebook_set_page(GTK_NOTEBOOK(gui.tabline), curtabidx); -# endif /* Make sure everything is in place before drawing text. */ gui_mch_update(); @@ -3719,13 +3564,8 @@ gui_mch_set_curtab(int nr) return; ignore_tabline_evt = TRUE; -# if GTK_CHECK_VERSION(3,0,0) if (gtk_notebook_get_current_page(GTK_NOTEBOOK(gui.tabline)) != nr - 1) gtk_notebook_set_current_page(GTK_NOTEBOOK(gui.tabline), nr - 1); -# else - if (gtk_notebook_current_page(GTK_NOTEBOOK(gui.tabline)) != nr - 1) - gtk_notebook_set_page(GTK_NOTEBOOK(gui.tabline), nr - 1); -# endif ignore_tabline_evt = FALSE; } @@ -3872,11 +3712,7 @@ gui_mch_init(void) /* Use GtkSocket from another app. */ plug = gtk_plug_new_for_display(gdk_display_get_default(), gtk_socket_id); -#if GTK_CHECK_VERSION(3,0,0) if (plug != NULL && gtk_plug_get_socket_window(GTK_PLUG(plug)) != NULL) -#else - if (plug != NULL && GTK_PLUG(plug)->socket_window != NULL) -#endif { gui.mainwin = plug; } @@ -3911,26 +3747,14 @@ gui_mch_init(void) gui.text_context = gtk_widget_create_pango_context(gui.mainwin); pango_context_set_base_dir(gui.text_context, PANGO_DIRECTION_LTR); -#if GTK_CHECK_VERSION(3,0,0) gtk_container_set_border_width(GTK_CONTAINER(gui.mainwin), 0); -#else - gtk_container_border_width(GTK_CONTAINER(gui.mainwin), 0); -#endif gtk_widget_add_events(gui.mainwin, GDK_VISIBILITY_NOTIFY_MASK); -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.mainwin), "delete-event", G_CALLBACK(&delete_event_cb), NULL); g_signal_connect(G_OBJECT(gui.mainwin), "realize", G_CALLBACK(&mainwin_realize), NULL); -#else - gtk_signal_connect(GTK_OBJECT(gui.mainwin), "delete_event", - GTK_SIGNAL_FUNC(&delete_event_cb), NULL); - - gtk_signal_connect(GTK_OBJECT(gui.mainwin), "realize", - GTK_SIGNAL_FUNC(&mainwin_realize), NULL); -#endif g_signal_connect(G_OBJECT(gui.mainwin), "screen-changed", G_CALLBACK(&mainwin_screen_changed_cb), NULL); @@ -4084,11 +3908,7 @@ gui_mch_init(void) gtk_widget_show(label); event_box = gtk_event_box_new(); gtk_widget_show(event_box); -# if GTK_CHECK_VERSION(3,0,0) g_object_set_data(G_OBJECT(event_box), "tab_num", GINT_TO_POINTER(1L)); -# else - gtk_object_set_user_data(GTK_OBJECT(event_box), (gpointer)1L); -# endif # if !GTK_CHECK_VERSION(3,14,0) gtk_misc_set_padding(GTK_MISC(label), 2, 2); # endif @@ -4097,35 +3917,19 @@ gui_mch_init(void) gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(gui.tabline), page, TRUE); } -# if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.tabline), "switch-page", G_CALLBACK(on_select_tab), NULL); g_signal_connect(G_OBJECT(gui.tabline), "page-reordered", G_CALLBACK(on_tab_reordered), NULL); -# else - gtk_signal_connect(GTK_OBJECT(gui.tabline), "switch_page", - GTK_SIGNAL_FUNC(on_select_tab), NULL); - gtk_signal_connect(GTK_OBJECT(gui.tabline), "page-reordered", - GTK_SIGNAL_FUNC(on_tab_reordered), NULL); -# endif /* Create a popup menu for the tab line and connect it. */ tabline_menu = create_tabline_menu(); -# if GTK_CHECK_VERSION(3,0,0) g_signal_connect_swapped(G_OBJECT(gui.tabline), "button-press-event", G_CALLBACK(on_tabline_menu), G_OBJECT(tabline_menu)); -# else - gtk_signal_connect_object(GTK_OBJECT(gui.tabline), "button_press_event", - GTK_SIGNAL_FUNC(on_tabline_menu), GTK_OBJECT(tabline_menu)); -# endif #endif /* FEAT_GUI_TABLINE */ gui.formwin = gtk_form_new(); -#if GTK_CHECK_VERSION(3,0,0) gtk_container_set_border_width(GTK_CONTAINER(gui.formwin), 0); -#else - gtk_container_border_width(GTK_CONTAINER(gui.formwin), 0); -#endif #if !GTK_CHECK_VERSION(3,0,0) gtk_widget_set_events(gui.formwin, GDK_EXPOSURE_MASK); #endif @@ -4159,17 +3963,10 @@ gui_mch_init(void) /* For GtkSockets, key-presses must go to the focus widget (drawarea) * and not the window. */ -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect((gtk_socket_id == 0) ? G_OBJECT(gui.mainwin) : G_OBJECT(gui.drawarea), "key-press-event", G_CALLBACK(key_press_event), NULL); -#else - gtk_signal_connect((gtk_socket_id == 0) ? GTK_OBJECT(gui.mainwin) - : GTK_OBJECT(gui.drawarea), - "key_press_event", - GTK_SIGNAL_FUNC(key_press_event), NULL); -#endif #if defined(FEAT_XIM) || GTK_CHECK_VERSION(3,0,0) /* Also forward key release events for the benefit of GTK+ 2 input * modules. Try CTRL-SHIFT-xdigits to enter a Unicode code point. */ @@ -4178,28 +3975,20 @@ gui_mch_init(void) "key-release-event", G_CALLBACK(&key_release_event), NULL); #endif -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.drawarea), "realize", G_CALLBACK(drawarea_realize_cb), NULL); g_signal_connect(G_OBJECT(gui.drawarea), "unrealize", G_CALLBACK(drawarea_unrealize_cb), NULL); +#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.drawarea), "configure-event", G_CALLBACK(drawarea_configure_event_cb), NULL); -# if GTK_CHECK_VERSION(3,22,2) +#endif +#if GTK_CHECK_VERSION(3,22,2) g_signal_connect_after(G_OBJECT(gui.drawarea), "style-updated", G_CALLBACK(&drawarea_style_updated_cb), NULL); -# else +#else g_signal_connect_after(G_OBJECT(gui.drawarea), "style-set", G_CALLBACK(&drawarea_style_set_cb), NULL); -# endif -#else - gtk_signal_connect(GTK_OBJECT(gui.drawarea), "realize", - GTK_SIGNAL_FUNC(drawarea_realize_cb), NULL); - gtk_signal_connect(GTK_OBJECT(gui.drawarea), "unrealize", - GTK_SIGNAL_FUNC(drawarea_unrealize_cb), NULL); - - gtk_signal_connect_after(GTK_OBJECT(gui.drawarea), "style_set", - GTK_SIGNAL_FUNC(&drawarea_style_set_cb), NULL); #endif #if !GTK_CHECK_VERSION(3,0,0) @@ -4213,11 +4002,7 @@ gui_mch_init(void) if (gtk_socket_id != 0) /* make sure keyboard input can go to the drawarea */ -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_can_focus(gui.drawarea, TRUE); -#else - GTK_WIDGET_SET_FLAGS(gui.drawarea, GTK_CAN_FOCUS); -#endif /* * Set clipboard specific atoms @@ -4248,17 +4033,10 @@ gui_mch_init(void) */ if (vim_strchr(p_go, GO_POINTER) != NULL) { -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.drawarea), "leave-notify-event", G_CALLBACK(leave_notify_event), NULL); g_signal_connect(G_OBJECT(gui.drawarea), "enter-notify-event", G_CALLBACK(enter_notify_event), NULL); -#else - gtk_signal_connect(GTK_OBJECT(gui.drawarea), "leave_notify_event", - GTK_SIGNAL_FUNC(leave_notify_event), NULL); - gtk_signal_connect(GTK_OBJECT(gui.drawarea), "enter_notify_event", - GTK_SIGNAL_FUNC(enter_notify_event), NULL); -#endif } /* Real windows can get focus ... GtkPlug, being a mere container can't, @@ -4267,47 +4045,25 @@ gui_mch_init(void) */ if (gtk_socket_id == 0) { -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.mainwin), "focus-out-event", G_CALLBACK(focus_out_event), NULL); g_signal_connect(G_OBJECT(gui.mainwin), "focus-in-event", G_CALLBACK(focus_in_event), NULL); -#else - gtk_signal_connect(GTK_OBJECT(gui.mainwin), "focus_out_event", - GTK_SIGNAL_FUNC(focus_out_event), NULL); - gtk_signal_connect(GTK_OBJECT(gui.mainwin), "focus_in_event", - GTK_SIGNAL_FUNC(focus_in_event), NULL); -#endif } else { -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.drawarea), "focus-out-event", G_CALLBACK(focus_out_event), NULL); g_signal_connect(G_OBJECT(gui.drawarea), "focus-in-event", G_CALLBACK(focus_in_event), NULL); -#else - gtk_signal_connect(GTK_OBJECT(gui.drawarea), "focus_out_event", - GTK_SIGNAL_FUNC(focus_out_event), NULL); - gtk_signal_connect(GTK_OBJECT(gui.drawarea), "focus_in_event", - GTK_SIGNAL_FUNC(focus_in_event), NULL); -#endif #ifdef FEAT_GUI_TABLINE -# if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.tabline), "focus-out-event", G_CALLBACK(focus_out_event), NULL); g_signal_connect(G_OBJECT(gui.tabline), "focus-in-event", G_CALLBACK(focus_in_event), NULL); -# else - gtk_signal_connect(GTK_OBJECT(gui.tabline), "focus_out_event", - GTK_SIGNAL_FUNC(focus_out_event), NULL); - gtk_signal_connect(GTK_OBJECT(gui.tabline), "focus_in_event", - GTK_SIGNAL_FUNC(focus_in_event), NULL); -# endif #endif /* FEAT_GUI_TABLINE */ } -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.drawarea), "motion-notify-event", G_CALLBACK(motion_notify_event), NULL); g_signal_connect(G_OBJECT(gui.drawarea), "button-press-event", @@ -4316,41 +4072,19 @@ gui_mch_init(void) G_CALLBACK(button_release_event), NULL); g_signal_connect(G_OBJECT(gui.drawarea), "scroll-event", G_CALLBACK(&scroll_event), NULL); -#else - gtk_signal_connect(GTK_OBJECT(gui.drawarea), "motion_notify_event", - GTK_SIGNAL_FUNC(motion_notify_event), NULL); - gtk_signal_connect(GTK_OBJECT(gui.drawarea), "button_press_event", - GTK_SIGNAL_FUNC(button_press_event), NULL); - gtk_signal_connect(GTK_OBJECT(gui.drawarea), "button_release_event", - GTK_SIGNAL_FUNC(button_release_event), NULL); - g_signal_connect(G_OBJECT(gui.drawarea), "scroll_event", - G_CALLBACK(&scroll_event), NULL); -#endif /* * Add selection handler functions. */ -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.drawarea), "selection-clear-event", G_CALLBACK(selection_clear_event), NULL); g_signal_connect(G_OBJECT(gui.drawarea), "selection-received", G_CALLBACK(selection_received_cb), NULL); -#else - gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_clear_event", - GTK_SIGNAL_FUNC(selection_clear_event), NULL); - gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_received", - GTK_SIGNAL_FUNC(selection_received_cb), NULL); -#endif gui_gtk_set_selection_targets(); -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.drawarea), "selection-get", G_CALLBACK(selection_get_cb), NULL); -#else - gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_get", - GTK_SIGNAL_FUNC(selection_get_cb), NULL); -#endif /* Pretend we don't have input focus, we will get an event if we do. */ gui.in_focus = FALSE; @@ -4415,16 +4149,12 @@ set_cairo_source_rgba_from_color(cairo_t *cr, guicolor_T color) void gui_mch_new_colors(void) { -#if GTK_CHECK_VERSION(3,0,0) -# if !GTK_CHECK_VERSION(3,22,2) - GdkWindow * const da_win = gtk_widget_get_window(gui.drawarea); -# endif - if (gui.drawarea != NULL && gtk_widget_get_window(gui.drawarea) != NULL) -#else - if (gui.drawarea != NULL && gui.drawarea->window != NULL) -#endif { +#if !GTK_CHECK_VERSION(3,22,2) + GdkWindow * const da_win = gtk_widget_get_window(gui.drawarea); +#endif + #if GTK_CHECK_VERSION(3,22,2) GtkStyleContext * const context = gtk_widget_get_style_context(gui.drawarea); @@ -4462,11 +4192,7 @@ gui_mch_new_colors(void) GdkColor color = { 0, 0, 0, 0 }; color.pixel = gui.back_pixel; -# if GTK_CHECK_VERSION(3,0,0) gdk_window_set_background(da_win, &color); -# else - gdk_window_set_background(gui.drawarea->window, &color); -# endif #endif /* !GTK_CHECK_VERSION(3,22,2) */ } } @@ -4524,13 +4250,8 @@ form_configure_event(GtkWidget *widget UNUSED, * We can't do much more here than to trying to preserve what had been done, * since the window is already inevitably going away. */ -#if GTK_CHECK_VERSION(3,0,0) static void mainwin_destroy_cb(GObject *object UNUSED, gpointer data UNUSED) -#else - static void -mainwin_destroy_cb(GtkObject *object UNUSED, gpointer data UNUSED) -#endif { /* Don't write messages to the GUI anymore */ full_screen = FALSE; @@ -4709,13 +4430,8 @@ gui_mch_open(void) * changed them). */ highlight_gui_started(); /* re-init colors and fonts */ -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.mainwin), "destroy", G_CALLBACK(mainwin_destroy_cb), NULL); -#else - gtk_signal_connect(GTK_OBJECT(gui.mainwin), "destroy", - GTK_SIGNAL_FUNC(mainwin_destroy_cb), NULL); -#endif #ifdef FEAT_HANGULIN hangul_keyboard_set(); @@ -4731,25 +4447,15 @@ gui_mch_open(void) * manager upon us and should not interfere with what VIM is requesting * upon startup. */ -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.formwin), "configure-event", G_CALLBACK(form_configure_event), NULL); -#else - gtk_signal_connect(GTK_OBJECT(gui.formwin), "configure_event", - GTK_SIGNAL_FUNC(form_configure_event), NULL); -#endif #ifdef FEAT_DND /* Set up for receiving DND items. */ gui_gtk_set_dnd_targets(); -# if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.drawarea), "drag-data-received", G_CALLBACK(drag_data_received_cb), NULL); -# else - gtk_signal_connect(GTK_OBJECT(gui.drawarea), "drag_data_received", - GTK_SIGNAL_FUNC(drag_data_received_cb), NULL); -# endif #endif /* With GTK+ 2, we need to iconify the window before calling show() @@ -5036,11 +4742,7 @@ gui_mch_enable_menu(int showit) widget = gui.menubar; /* Do not disable the menu while starting up, otherwise F10 doesn't work. */ -# if GTK_CHECK_VERSION(3,0,0) if (!showit != !gtk_widget_get_visible(widget) && !gui.starting) -# else - if (!showit != !GTK_WIDGET_VISIBLE(widget) && !gui.starting) -# endif { if (showit) gtk_widget_show(widget); @@ -5071,11 +4773,7 @@ gui_mch_show_toolbar(int showit) if (showit) set_toolbar_style(GTK_TOOLBAR(gui.toolbar)); -# if GTK_CHECK_VERSION(3,0,0) if (!showit != !gtk_widget_get_visible(widget)) -# else - if (!showit != !GTK_WIDGET_VISIBLE(widget)) -# endif { if (showit) gtk_widget_show(widget); @@ -6336,11 +6034,7 @@ gui_mch_beep(void) { GdkDisplay *display; -#if GTK_CHECK_VERSION(3,0,0) if (gui.mainwin != NULL && gtk_widget_get_realized(gui.mainwin)) -#else - if (gui.mainwin != NULL && GTK_WIDGET_REALIZED(gui.mainwin)) -#endif display = gtk_widget_get_display(gui.mainwin); else display = gdk_display_get_default(); @@ -6700,11 +6394,7 @@ theend: void gui_mch_flush(void) { -#if GTK_CHECK_VERSION(3,0,0) if (gui.mainwin != NULL && gtk_widget_get_realized(gui.mainwin)) -#else - if (gui.mainwin != NULL && GTK_WIDGET_REALIZED(gui.mainwin)) -#endif gdk_display_flush(gtk_widget_get_display(gui.mainwin)); } @@ -7060,11 +6750,7 @@ gui_mch_menu_grey(vimmenu_T *menu, int grey) gui_mch_menu_hidden(menu, FALSE); /* Be clever about bitfields versus true booleans here! */ -# if GTK_CHECK_VERSION(3,0,0) if (!gtk_widget_get_sensitive(menu->id) == !grey) -# else - if (!GTK_WIDGET_SENSITIVE(menu->id) == !grey) -# endif { gtk_widget_set_sensitive(menu->id, !grey); gui_mch_update(); @@ -7082,11 +6768,7 @@ gui_mch_menu_hidden(vimmenu_T *menu, int hidden) if (hidden) { -# if GTK_CHECK_VERSION(3,0,0) if (gtk_widget_get_visible(menu->id)) -# else - if (GTK_WIDGET_VISIBLE(menu->id)) -# endif { gtk_widget_hide(menu->id); gui_mch_update(); @@ -7094,11 +6776,7 @@ gui_mch_menu_hidden(vimmenu_T *menu, int hidden) } else { -# if GTK_CHECK_VERSION(3,0,0) if (!gtk_widget_get_visible(menu->id)) -# else - if (!GTK_WIDGET_VISIBLE(menu->id)) -# endif { gtk_widget_show(menu->id); gui_mch_update(); @@ -7126,15 +6804,7 @@ gui_mch_enable_scrollbar(scrollbar_T *sb, int flag) if (sb->id == NULL) return; -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_visible(sb->id, flag); -#else - if (flag) - gtk_widget_show(sb->id); - else - gtk_widget_hide(sb->id); -#endif - update_window_manager_hints(0, 0); } @@ -7166,11 +6836,7 @@ gui_mch_get_rgb(guicolor_T pixel) void gui_mch_getmouse(int *x, int *y) { -#if GTK_CHECK_VERSION(3,0,0) gui_gtk_get_pointer(gui.drawarea, x, y, NULL); -#else - gdk_window_get_pointer(gui.drawarea->window, x, y, NULL); -#endif } void |