diff options
-rw-r--r-- | src/gui_beval.c | 44 | ||||
-rw-r--r-- | src/gui_gtk.c | 180 | ||||
-rw-r--r-- | src/gui_gtk_f.c | 180 | ||||
-rw-r--r-- | src/gui_gtk_x11.c | 360 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim.h | 49 |
6 files changed, 89 insertions, 726 deletions
diff --git a/src/gui_beval.c b/src/gui_beval.c index 99651da5d9..8b90362d79 100644 --- a/src/gui_beval.c +++ b/src/gui_beval.c @@ -244,16 +244,9 @@ addEventHandler(GtkWidget *target, BalloonEval *beval) * This allows us to catch events independently of the signal handlers * in gui_gtk_x11.c. */ -# if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(target), "event", G_CALLBACK(target_event_cb), beval); -# else - /* Should use GTK_OBJECT() here, but that causes a lint warning... */ - gtk_signal_connect((GtkObject*)(target), "event", - GTK_SIGNAL_FUNC(target_event_cb), - beval); -# endif /* * Nasty: Key press events go to the main window thus the drawing area * will never see them. This means we have to connect to the main window @@ -262,45 +255,25 @@ addEventHandler(GtkWidget *target, BalloonEval *beval) if (gtk_socket_id == 0 && gui.mainwin != NULL && gtk_widget_is_ancestor(target, gui.mainwin)) { -# if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(gui.mainwin), "event", G_CALLBACK(mainwin_event_cb), beval); -# else - gtk_signal_connect((GtkObject*)(gui.mainwin), "event", - GTK_SIGNAL_FUNC(mainwin_event_cb), - beval); -# endif } } static void removeEventHandler(BalloonEval *beval) { - /* LINTED: avoid warning: dubious operation on enum */ -# if GTK_CHECK_VERSION(3,0,0) g_signal_handlers_disconnect_by_func(G_OBJECT(beval->target), FUNC2GENERIC(target_event_cb), beval); -# else - gtk_signal_disconnect_by_func((GtkObject*)(beval->target), - GTK_SIGNAL_FUNC(target_event_cb), - beval); -# endif if (gtk_socket_id == 0 && gui.mainwin != NULL && gtk_widget_is_ancestor(beval->target, gui.mainwin)) { - /* LINTED: avoid warning: dubious operation on enum */ -# if GTK_CHECK_VERSION(3,0,0) g_signal_handlers_disconnect_by_func(G_OBJECT(gui.mainwin), FUNC2GENERIC(mainwin_event_cb), beval); -# else - gtk_signal_disconnect_by_func((GtkObject*)(gui.mainwin), - GTK_SIGNAL_FUNC(mainwin_event_cb), - beval); -# endif } } @@ -433,13 +406,8 @@ pointer_event(BalloonEval *beval, int x, int y, unsigned state) } else { -# if GTK_CHECK_VERSION(3,0,0) beval->timerID = g_timeout_add((guint)p_bdlay, &timeout_cb, beval); -# else - beval->timerID = gtk_timeout_add((guint32)p_bdlay, - &timeout_cb, beval); -# endif } } } @@ -1039,11 +1007,7 @@ cancelBalloon(BalloonEval *beval) if (beval->timerID != 0) { -# if GTK_CHECK_VERSION(3,0,0) g_source_remove(beval->timerID); -# else - gtk_timeout_remove(beval->timerID); -# endif beval->timerID = 0; } beval->showState = ShS_NEUTRAL; @@ -1055,17 +1019,9 @@ createBalloonEvalWindow(BalloonEval *beval) beval->balloonShell = gtk_window_new(GTK_WINDOW_POPUP); gtk_widget_set_app_paintable(beval->balloonShell, TRUE); -# if GTK_CHECK_VERSION(3,0,0) gtk_window_set_resizable(GTK_WINDOW(beval->balloonShell), FALSE); -# else - gtk_window_set_policy(GTK_WINDOW(beval->balloonShell), FALSE, FALSE, TRUE); -# endif gtk_widget_set_name(beval->balloonShell, "gtk-tooltips"); -# if GTK_CHECK_VERSION(3,0,0) gtk_container_set_border_width(GTK_CONTAINER(beval->balloonShell), 4); -# else - gtk_container_border_width(GTK_CONTAINER(beval->balloonShell), 4); -# endif # if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(beval->balloonShell), "draw", diff --git a/src/gui_gtk.c b/src/gui_gtk.c index 5c47f5ae93..40b3db65e7 100644 --- a/src/gui_gtk.c +++ b/src/gui_gtk.c @@ -756,13 +756,8 @@ gui_mch_add_menu_item(vimmenu_T *menu, int idx) # endif if (gtk_socket_id != 0) -# if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(menu->id), "focus-in-event", G_CALLBACK(toolbar_button_focus_in_event), NULL); -# else - gtk_signal_connect(GTK_OBJECT(menu->id), "focus_in_event", - GTK_SIGNAL_FUNC(toolbar_button_focus_in_event), NULL); -# endif CONVERT_TO_UTF8_FREE(text); CONVERT_TO_UTF8_FREE(tooltip); @@ -792,12 +787,8 @@ gui_mch_add_menu_item(vimmenu_T *menu, int idx) gtk_widget_set_sensitive(menu->id, FALSE); # endif gtk_widget_show(menu->id); -# if GTK_CHECK_VERSION(3,0,0) gtk_menu_shell_insert(GTK_MENU_SHELL(parent->submenu_id), menu->id, idx); -# else - gtk_menu_insert(GTK_MENU(parent->submenu_id), menu->id, idx); -# endif return; } @@ -805,21 +796,12 @@ gui_mch_add_menu_item(vimmenu_T *menu, int idx) /* Add textual menu item. */ menu_item_new(menu, parent->submenu_id); gtk_widget_show(menu->id); -# if GTK_CHECK_VERSION(3,0,0) gtk_menu_shell_insert(GTK_MENU_SHELL(parent->submenu_id), menu->id, idx); -# else - gtk_menu_insert(GTK_MENU(parent->submenu_id), menu->id, idx); -# endif if (menu->id != NULL) -# if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(menu->id), "activate", G_CALLBACK(menu_item_activate), menu); -# else - gtk_signal_connect(GTK_OBJECT(menu->id), "activate", - GTK_SIGNAL_FUNC(menu_item_activate), menu); -# endif } } #endif /* FEAT_MENU */ @@ -1000,7 +982,6 @@ gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max) adjustment = gtk_range_get_adjustment(GTK_RANGE(sb->id)); -#if GTK_CHECK_VERSION(3,0,0) gtk_adjustment_set_lower(adjustment, 0.0); gtk_adjustment_set_value(adjustment, val); gtk_adjustment_set_upper(adjustment, max + 1); @@ -1008,34 +989,15 @@ gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max) gtk_adjustment_set_page_increment(adjustment, size < 3L ? 1L : size - 2L); gtk_adjustment_set_step_increment(adjustment, 1.0); -#else - adjustment->lower = 0.0; - adjustment->value = val; - adjustment->upper = max + 1; - adjustment->page_size = size; - adjustment->page_increment = size < 3L ? 1L : size - 2L; - adjustment->step_increment = 1.0; -#endif -#if GTK_CHECK_VERSION(3,0,0) - g_signal_handler_block(G_OBJECT(adjustment), - (gulong)sb->handler_id); -#else - g_signal_handler_block(GTK_OBJECT(adjustment), - (gulong)sb->handler_id); -#endif + g_signal_handler_block(G_OBJECT(adjustment), (gulong)sb->handler_id); #if !GTK_CHECK_VERSION(3,18,0) gtk_adjustment_changed(adjustment); #endif -#if GTK_CHECK_VERSION(3,0,0) g_signal_handler_unblock(G_OBJECT(adjustment), (gulong)sb->handler_id); -#else - g_signal_handler_unblock(GTK_OBJECT(adjustment), - (gulong)sb->handler_id); -#endif } } @@ -1063,11 +1025,7 @@ adjustment_value_changed(GtkAdjustment *adjustment, gpointer data) #endif sb = gui_find_scrollbar((long)data); -#if GTK_CHECK_VERSION(3,0,0) value = gtk_adjustment_get_value(adjustment); -#else - value = (long)adjustment->value; -#endif #if !GTK_CHECK_VERSION(3,0,0) /* * The dragging argument must be right for the scrollbar to work with @@ -1136,26 +1094,15 @@ gui_mch_create_scrollbar(scrollbar_T *sb, int orient) { GtkAdjustment *adjustment; -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_can_focus(sb->id, FALSE); -#else - GTK_WIDGET_UNSET_FLAGS(sb->id, GTK_CAN_FOCUS); -#endif gtk_form_put(GTK_FORM(gui.formwin), sb->id, 0, 0); adjustment = gtk_range_get_adjustment(GTK_RANGE(sb->id)); -#if GTK_CHECK_VERSION(3,0,0) sb->handler_id = g_signal_connect( G_OBJECT(adjustment), "value-changed", G_CALLBACK(adjustment_value_changed), GINT_TO_POINTER(sb->ident)); -#else - sb->handler_id = gtk_signal_connect( - GTK_OBJECT(adjustment), "value_changed", - GTK_SIGNAL_FUNC(adjustment_value_changed), - GINT_TO_POINTER(sb->ident)); -#endif gui_mch_update(); } } @@ -1803,7 +1750,7 @@ gui_mch_dialog(int type, /* type of dialog */ /* Allow activation of mnemonic accelerators without pressing <Alt> when * there is no textfield. Handle pressing Esc. */ - g_signal_connect(G_OBJECT(dialog), "key_press_event", + g_signal_connect(G_OBJECT(dialog), "key-press-event", G_CALLBACK(&dialog_key_press_event_cb), &dialoginfo); if (def_but > 0) @@ -2203,17 +2150,10 @@ find_replace_dialog_create(char_u *arg, int do_replace) if (entry_text != NULL) { gtk_entry_set_text(GTK_ENTRY(frdp->what), (char *)entry_text); -#if GTK_CHECK_VERSION(3,0,0) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->wword), (gboolean)wword); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->mcase), (gboolean)mcase); -#else - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->wword), - (gboolean)wword); - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->mcase), - (gboolean)mcase); -#endif } gtk_window_present(GTK_WINDOW(frdp->dialog)); @@ -2278,11 +2218,7 @@ find_replace_dialog_create(char_u *arg, int do_replace) table = gtk_table_new(1024, 3, FALSE); #endif gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 0); -#if GTK_CHECK_VERSION(3,0,0) gtk_container_set_border_width(GTK_CONTAINER(table), 4); -#else - gtk_container_border_width(GTK_CONTAINER(table), 4); -#endif tmp = gtk_label_new(CONV(_("Find what:"))); #if GTK_CHECK_VERSION(3,16,0) @@ -2315,19 +2251,11 @@ find_replace_dialog_create(char_u *arg, int do_replace) sensitive = (entry_text != NULL && entry_text[0] != NUL); if (entry_text != NULL) gtk_entry_set_text(GTK_ENTRY(frdp->what), (char *)entry_text); -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(frdp->what), "changed", G_CALLBACK(entry_changed_cb), frdp->dialog); g_signal_connect_after(G_OBJECT(frdp->what), "key-press-event", G_CALLBACK(find_key_press_event), (gpointer) frdp); -#else - gtk_signal_connect(GTK_OBJECT(frdp->what), "changed", - GTK_SIGNAL_FUNC(entry_changed_cb), frdp->dialog); - gtk_signal_connect_after(GTK_OBJECT(frdp->what), "key_press_event", - GTK_SIGNAL_FUNC(find_key_press_event), - (gpointer) frdp); -#endif #if GTK_CHECK_VERSION(3,4,0) gtk_grid_attach(GTK_GRID(table), frdp->what, 2, 0, 5, 1); #else @@ -2365,21 +2293,12 @@ find_replace_dialog_create(char_u *arg, int do_replace) GTK_FILL, GTK_EXPAND, 2, 2); #endif frdp->with = gtk_entry_new(); -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(frdp->with), "activate", G_CALLBACK(find_replace_cb), GINT_TO_POINTER(FRD_R_FINDNEXT)); g_signal_connect_after(G_OBJECT(frdp->with), "key-press-event", G_CALLBACK(find_key_press_event), (gpointer) frdp); -#else - gtk_signal_connect(GTK_OBJECT(frdp->with), "activate", - GTK_SIGNAL_FUNC(find_replace_cb), - GINT_TO_POINTER(FRD_R_FINDNEXT)); - gtk_signal_connect_after(GTK_OBJECT(frdp->with), "key_press_event", - GTK_SIGNAL_FUNC(find_key_press_event), - (gpointer) frdp); -#endif #if GTK_CHECK_VERSION(3,4,0) gtk_grid_attach(GTK_GRID(table), frdp->with, 2, 1, 5, 1); #else @@ -2391,39 +2310,23 @@ find_replace_dialog_create(char_u *arg, int do_replace) * Make the entry activation only change the input focus onto the * with item. */ -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(frdp->what), "activate", G_CALLBACK(entry_activate_cb), frdp->with); -#else - gtk_signal_connect(GTK_OBJECT(frdp->what), "activate", - GTK_SIGNAL_FUNC(entry_activate_cb), frdp->with); -#endif } else { /* * Make the entry activation do the search. */ -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(frdp->what), "activate", G_CALLBACK(find_replace_cb), GINT_TO_POINTER(FRD_FINDNEXT)); -#else - gtk_signal_connect(GTK_OBJECT(frdp->what), "activate", - GTK_SIGNAL_FUNC(find_replace_cb), - GINT_TO_POINTER(FRD_FINDNEXT)); -#endif } /* whole word only button */ frdp->wword = gtk_check_button_new_with_label(CONV(_("Match whole word only"))); -#if GTK_CHECK_VERSION(3,0,0) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->wword), (gboolean)wword); -#else - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->wword), - (gboolean)wword); -#endif if (do_replace) #if GTK_CHECK_VERSION(3,4,0) gtk_grid_attach(GTK_GRID(table), frdp->wword, 0, 2, 5, 1); @@ -2441,13 +2344,8 @@ find_replace_dialog_create(char_u *arg, int do_replace) /* match case button */ frdp->mcase = gtk_check_button_new_with_label(CONV(_("Match case"))); -#if GTK_CHECK_VERSION(3,0,0) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->mcase), (gboolean)mcase); -#else - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->mcase), - (gboolean)mcase); -#endif if (do_replace) #if GTK_CHECK_VERSION(3,4,0) gtk_grid_attach(GTK_GRID(table), frdp->mcase, 0, 3, 5, 1); @@ -2484,30 +2382,16 @@ find_replace_dialog_create(char_u *arg, int do_replace) #else vbox = gtk_vbox_new(FALSE, 0); #endif -#if GTK_CHECK_VERSION(3,0,0) gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); -#else - gtk_container_border_width(GTK_CONTAINER(vbox), 0); -#endif gtk_container_add(GTK_CONTAINER(tmp), vbox); /* 'Up' and 'Down' buttons */ frdp->up = gtk_radio_button_new_with_label(NULL, CONV(_("Up"))); gtk_box_pack_start(GTK_BOX(vbox), frdp->up, TRUE, TRUE, 0); -#if GTK_CHECK_VERSION(3,0,0) frdp->down = gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(frdp->up)), CONV(_("Down"))); -#else - frdp->down = gtk_radio_button_new_with_label( - gtk_radio_button_group(GTK_RADIO_BUTTON(frdp->up)), - CONV(_("Down"))); -#endif -#if GTK_CHECK_VERSION(3,0,0) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->down), TRUE); -#else - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->down), TRUE); -#endif gtk_container_set_border_width(GTK_CONTAINER(vbox), 2); gtk_box_pack_start(GTK_BOX(vbox), frdp->down, TRUE, TRUE, 0); @@ -2517,11 +2401,7 @@ find_replace_dialog_create(char_u *arg, int do_replace) #else actionarea = gtk_vbutton_box_new(); #endif -#if GTK_CHECK_VERSION(3,0,0) gtk_container_set_border_width(GTK_CONTAINER(actionarea), 2); -#else - gtk_container_border_width(GTK_CONTAINER(actionarea), 2); -#endif gtk_box_pack_end(GTK_BOX(hbox), actionarea, FALSE, FALSE, 0); /* 'Find Next' button */ @@ -2532,23 +2412,12 @@ find_replace_dialog_create(char_u *arg, int do_replace) #endif gtk_widget_set_sensitive(frdp->find, sensitive); -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(frdp->find), "clicked", G_CALLBACK(find_replace_cb), (do_replace) ? GINT_TO_POINTER(FRD_R_FINDNEXT) : GINT_TO_POINTER(FRD_FINDNEXT)); -#else - gtk_signal_connect(GTK_OBJECT(frdp->find), "clicked", - GTK_SIGNAL_FUNC(find_replace_cb), - (do_replace) ? GINT_TO_POINTER(FRD_R_FINDNEXT) - : GINT_TO_POINTER(FRD_FINDNEXT)); -#endif -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_can_default(frdp->find, TRUE); -#else - GTK_WIDGET_SET_FLAGS(frdp->find, GTK_CAN_DEFAULT); -#endif gtk_box_pack_start(GTK_BOX(actionarea), frdp->find, FALSE, FALSE, 0); gtk_widget_grab_default(frdp->find); @@ -2561,21 +2430,11 @@ find_replace_dialog_create(char_u *arg, int do_replace) frdp->replace = create_image_button(GTK_STOCK_CONVERT, _("Replace")); #endif gtk_widget_set_sensitive(frdp->replace, sensitive); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_can_default(frdp->find, TRUE); -#else - GTK_WIDGET_SET_FLAGS(frdp->replace, GTK_CAN_DEFAULT); -#endif gtk_box_pack_start(GTK_BOX(actionarea), frdp->replace, FALSE, FALSE, 0); -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(frdp->replace), "clicked", G_CALLBACK(find_replace_cb), GINT_TO_POINTER(FRD_REPLACE)); -#else - gtk_signal_connect(GTK_OBJECT(frdp->replace), "clicked", - GTK_SIGNAL_FUNC(find_replace_cb), - GINT_TO_POINTER(FRD_REPLACE)); -#endif /* 'Replace All' button */ #if GTK_CHECK_VERSION(3,10,0) @@ -2584,21 +2443,11 @@ find_replace_dialog_create(char_u *arg, int do_replace) frdp->all = create_image_button(GTK_STOCK_CONVERT, _("Replace All")); #endif gtk_widget_set_sensitive(frdp->all, sensitive); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_can_default(frdp->all, TRUE); -#else - GTK_WIDGET_SET_FLAGS(frdp->all, GTK_CAN_DEFAULT); -#endif gtk_box_pack_start(GTK_BOX(actionarea), frdp->all, FALSE, FALSE, 0); -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(frdp->all), "clicked", G_CALLBACK(find_replace_cb), GINT_TO_POINTER(FRD_REPLACEALL)); -#else - gtk_signal_connect(GTK_OBJECT(frdp->all), "clicked", - GTK_SIGNAL_FUNC(find_replace_cb), - GINT_TO_POINTER(FRD_REPLACEALL)); -#endif } /* 'Cancel' button */ @@ -2607,27 +2456,14 @@ find_replace_dialog_create(char_u *arg, int do_replace) #else tmp = gtk_button_new_from_stock(GTK_STOCK_CLOSE); #endif -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_can_default(tmp, TRUE); -#else - GTK_WIDGET_SET_FLAGS(tmp, GTK_CAN_DEFAULT); -#endif gtk_box_pack_end(GTK_BOX(actionarea), tmp, FALSE, FALSE, 0); -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect_swapped(G_OBJECT(tmp), "clicked", G_CALLBACK(gtk_widget_hide), G_OBJECT(frdp->dialog)); g_signal_connect_swapped(G_OBJECT(frdp->dialog), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), G_OBJECT(frdp->dialog)); -#else - gtk_signal_connect_object(GTK_OBJECT(tmp), - "clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), - GTK_OBJECT(frdp->dialog)); - gtk_signal_connect_object(GTK_OBJECT(frdp->dialog), - "delete_event", GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete), - GTK_OBJECT(frdp->dialog)); -#endif #if GTK_CHECK_VERSION(3,2,0) tmp = gtk_separator_new(GTK_ORIENTATION_VERTICAL); @@ -2693,23 +2529,11 @@ find_replace_cb(GtkWidget *widget UNUSED, gpointer data) } find_text = (char_u *)gtk_entry_get_text(GTK_ENTRY(sfr->what)); -#if GTK_CHECK_VERSION(3,0,0) direction_down = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->down)); -#else - direction_down = GTK_TOGGLE_BUTTON(sfr->down)->active; -#endif -#if GTK_CHECK_VERSION(3,0,0) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->wword))) -#else - if (GTK_TOGGLE_BUTTON(sfr->wword)->active) -#endif flags |= FRD_WHOLE_WORD; -#if GTK_CHECK_VERSION(3,0,0) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->mcase))) -#else - if (GTK_TOGGLE_BUTTON(sfr->mcase)->active) -#endif flags |= FRD_MATCH_CASE; repl_text = CONVERT_FROM_UTF8(repl_text); diff --git a/src/gui_gtk_f.c b/src/gui_gtk_f.c index 04e25aa598..3f376c0484 100644 --- a/src/gui_gtk_f.c +++ b/src/gui_gtk_f.c @@ -150,21 +150,13 @@ gtk_form_put(GtkForm *form, * that gtk_widget_set_parent() realizes the widget if it's visible * and its parent is mapped. */ -#if GTK_CHECK_VERSION(3,0,0) if (gtk_widget_get_realized(GTK_WIDGET(form))) -#else - if (GTK_WIDGET_REALIZED(form)) -#endif gtk_form_attach_child_window(form, child); gtk_widget_set_parent(child_widget, GTK_WIDGET(form)); -#if GTK_CHECK_VERSION(3,0,0) if (gtk_widget_get_realized(GTK_WIDGET(form)) && !gtk_widget_get_realized(child_widget)) -#else - if (GTK_WIDGET_REALIZED(form) && !GTK_WIDGET_REALIZED(child_widget)) -#endif gtk_form_realize_child(form, child); gtk_form_position_child(form, child, TRUE); @@ -300,32 +292,19 @@ gtk_form_realize(GtkWidget *widget) GtkForm *form; GdkWindowAttr attributes; gint attributes_mask; + GtkAllocation allocation; g_return_if_fail(GTK_IS_FORM(widget)); form = GTK_FORM(widget); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_realized(widget, TRUE); -#else - GTK_WIDGET_SET_FLAGS(form, GTK_REALIZED); -#endif + gtk_widget_get_allocation(widget, &allocation); attributes.window_type = GDK_WINDOW_CHILD; -#if GTK_CHECK_VERSION(3,0,0) - { - GtkAllocation allocation; - gtk_widget_get_allocation(widget, &allocation); - attributes.x = allocation.x; - attributes.y = allocation.y; - attributes.width = allocation.width; - attributes.height = allocation.height; - } -#else - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; -#endif + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual(widget); #if GTK_CHECK_VERSION(3,0,0) @@ -341,14 +320,9 @@ gtk_form_realize(GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; #endif -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_window(widget, gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask)); -#else - widget->window = gdk_window_new(gtk_widget_get_parent_window(widget), - &attributes, attributes_mask); -#endif gdk_window_set_user_data(gtk_widget_get_window(widget), widget); attributes.x = 0; @@ -382,11 +356,7 @@ gtk_form_realize(GtkWidget *widget) gtk_form_attach_child_window(form, child); -#if GTK_CHECK_VERSION(3,0,0) if (gtk_widget_get_visible(child->widget)) -#else - if (GTK_WIDGET_VISIBLE(child->widget)) -#endif gtk_form_realize_child(form, child); } } @@ -410,11 +380,7 @@ gtk_form_map(GtkWidget *widget) form = GTK_FORM(widget); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_mapped(widget, TRUE); -#else - GTK_WIDGET_SET_FLAGS(widget, GTK_MAPPED); -#endif gdk_window_show(gtk_widget_get_window(widget)); gdk_window_show(form->bin_window); @@ -423,13 +389,8 @@ gtk_form_map(GtkWidget *widget) { GtkFormChild *child = tmp_list->data; -#if GTK_CHECK_VERSION(3,0,0) if (gtk_widget_get_visible(child->widget) && !gtk_widget_get_mapped(child->widget)) -#else - if (GTK_WIDGET_VISIBLE(child->widget) - && !GTK_WIDGET_MAPPED(child->widget)) -#endif gtk_widget_map(child->widget); } } @@ -456,21 +417,12 @@ gtk_form_unrealize(GtkWidget *widget) if (child->window != NULL) { -#if GTK_CHECK_VERSION(3,0,0) g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), FUNC2GENERIC(gtk_form_child_map), child); g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), FUNC2GENERIC(gtk_form_child_unmap), child); -#else - gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget), - GTK_SIGNAL_FUNC(gtk_form_child_map), - child); - gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget), - GTK_SIGNAL_FUNC(gtk_form_child_unmap), - child); -#endif gdk_window_set_user_data(child->window, NULL); gdk_window_destroy(child->window); @@ -534,34 +486,20 @@ gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation) GList *tmp_list; GtkForm *form; gboolean need_reposition; -#if GTK_CHECK_VERSION(3,0,0) GtkAllocation cur_alloc; -#endif g_return_if_fail(GTK_IS_FORM(widget)); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_allocation(widget, &cur_alloc); if (cur_alloc.x == allocation->x && cur_alloc.y == allocation->y && cur_alloc.width == allocation->width && cur_alloc.height == allocation->height) -#else - if (widget->allocation.x == allocation->x - && widget->allocation.y == allocation->y - && widget->allocation.width == allocation->width - && widget->allocation.height == allocation->height) -#endif return; -#if GTK_CHECK_VERSION(3,0,0) need_reposition = cur_alloc.width != allocation->width || cur_alloc.height != allocation->height; -#else - need_reposition = widget->allocation.width != allocation->width - || widget->allocation.height != allocation->height; -#endif form = GTK_FORM(widget); if (need_reposition) @@ -577,11 +515,7 @@ gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation) } } -#if GTK_CHECK_VERSION(3,0,0) if (gtk_widget_get_realized(widget)) -#else - if (GTK_WIDGET_REALIZED(widget)) -#endif { gdk_window_move_resize(gtk_widget_get_window(widget), allocation->x, allocation->y, @@ -590,11 +524,7 @@ gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation) 0, 0, allocation->width, allocation->height); } -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_allocation(widget, allocation); -#else - widget->allocation = *allocation; -#endif if (need_reposition) gtk_form_send_configure(form); } @@ -697,17 +627,10 @@ gtk_form_remove(GtkContainer *container, GtkWidget *widget) #endif if (child->window) { -#if GTK_CHECK_VERSION(3,0,0) g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), FUNC2GENERIC(>k_form_child_map), child); g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), FUNC2GENERIC(>k_form_child_unmap), child); -#else - gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget), - GTK_SIGNAL_FUNC(>k_form_child_map), child); - gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget), - GTK_SIGNAL_FUNC(>k_form_child_unmap), child); -#endif /* FIXME: This will cause problems for reparenting NO_WINDOW * widgets out of a GtkForm @@ -760,34 +683,25 @@ gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child) if (child->window != NULL) return; /* been there, done that */ -#if GTK_CHECK_VERSION(3,0,0) if (!gtk_widget_get_has_window(child->widget)) -#else - if (GTK_WIDGET_NO_WINDOW(child->widget)) -#endif { GtkWidget *widget; GdkWindowAttr attributes; gint attributes_mask; + GtkRequisition requisition; widget = GTK_WIDGET(form); - attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = child->x; - attributes.y = child->y; #if GTK_CHECK_VERSION(3,0,0) - { - GtkRequisition requisition; - - gtk_widget_get_preferred_size(child->widget, &requisition, NULL); - - attributes.width = requisition.width; - attributes.height = requisition.height; - } + gtk_widget_get_preferred_size(child->widget, &requisition, NULL); #else - attributes.width = child->widget->requisition.width; - attributes.height = child->widget->requisition.height; + requisition = child->widget->requisition; #endif + attributes.window_type = GDK_WINDOW_CHILD; + attributes.x = child->x; + attributes.y = child->y; + attributes.width = requisition.width; + attributes.height = requisition.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual(widget); #if !GTK_CHECK_VERSION(3,0,0) @@ -824,23 +738,12 @@ gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child) * Install signal handlers to map/unmap child->window * alongside with the actual widget. */ -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(child->widget), "map", G_CALLBACK(>k_form_child_map), child); g_signal_connect(G_OBJECT(child->widget), "unmap", G_CALLBACK(>k_form_child_unmap), child); -#else - gtk_signal_connect(GTK_OBJECT(child->widget), "map", - GTK_SIGNAL_FUNC(>k_form_child_map), child); - gtk_signal_connect(GTK_OBJECT(child->widget), "unmap", - GTK_SIGNAL_FUNC(>k_form_child_unmap), child); -#endif } -#if GTK_CHECK_VERSION(3,0,0) else if (!gtk_widget_get_realized(child->widget)) -#else - else if (!GTK_WIDGET_REALIZED(child->widget)) -#endif { gtk_widget_set_parent_window(child->widget, form->bin_window); } @@ -868,18 +771,10 @@ gtk_form_position_child(GtkForm *form, GtkFormChild *child, { if (!child->mapped) { -#if GTK_CHECK_VERSION(3,0,0) if (gtk_widget_get_mapped(GTK_WIDGET(form)) && gtk_widget_get_visible(child->widget)) -#else - if (GTK_WIDGET_MAPPED(form) && GTK_WIDGET_VISIBLE(child->widget)) -#endif { -#if GTK_CHECK_VERSION(3,0,0) if (!gtk_widget_get_mapped(child->widget)) -#else - if (!GTK_WIDGET_MAPPED(child->widget)) -#endif gtk_widget_map(child->widget); child->mapped = TRUE; @@ -890,31 +785,22 @@ gtk_form_position_child(GtkForm *form, GtkFormChild *child, if (force_allocate) { GtkAllocation allocation; -#if GTK_CHECK_VERSION(3,0,0) GtkRequisition requisition; +#if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_preferred_size(child->widget, &requisition, NULL); +#else + requisition = child->widget->requisition; #endif -#if GTK_CHECK_VERSION(3,0,0) if (!gtk_widget_get_has_window(child->widget)) -#else - if (GTK_WIDGET_NO_WINDOW(child->widget)) -#endif { if (child->window) { -#if GTK_CHECK_VERSION(3,0,0) gdk_window_move_resize(child->window, x, y, requisition.width, requisition.height); -#else - gdk_window_move_resize(child->window, - x, y, - child->widget->requisition.width, - child->widget->requisition.height); -#endif } allocation.x = 0; @@ -926,13 +812,8 @@ gtk_form_position_child(GtkForm *form, GtkFormChild *child, allocation.y = y; } -#if GTK_CHECK_VERSION(3,0,0) allocation.width = requisition.width; allocation.height = requisition.height; -#else - allocation.width = child->widget->requisition.width; - allocation.height = child->widget->requisition.height; -#endif gtk_widget_size_allocate(child->widget, &allocation); } @@ -943,11 +824,7 @@ gtk_form_position_child(GtkForm *form, GtkFormChild *child, { child->mapped = FALSE; -#if GTK_CHECK_VERSION(3,0,0) if (gtk_widget_get_mapped(child->widget)) -#else - if (GTK_WIDGET_MAPPED(child->widget)) -#endif gtk_widget_unmap(child->widget); } } @@ -981,28 +858,17 @@ gtk_form_send_configure(GtkForm *form) { GtkWidget *widget; GdkEventConfigure event; + GtkAllocation allocation; widget = GTK_WIDGET(form); + gtk_widget_get_allocation(widget, &allocation); event.type = GDK_CONFIGURE; -#if GTK_CHECK_VERSION(3,0,0) event.window = gtk_widget_get_window(widget); - { - GtkAllocation allocation; - - gtk_widget_get_allocation(widget, &allocation); - event.x = allocation.x; - event.y = allocation.y; - event.width = allocation.width; - event.height = allocation.height; - } -#else - event.window = widget->window; - event.x = widget->allocation.x; - event.y = widget->allocation.y; - event.width = widget->allocation.width; - event.height = widget->allocation.height; -#endif + event.x = allocation.x; + event.y = allocation.y; + event.width = allocation.width; + event.height = allocation.height; gtk_main_do_event((GdkEvent*)&event); } 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 = (st |