Mercurial > vim
comparison src/gui_gtk_x11.c @ 14786:11978f68a8c3 v8.1.0405
patch 8.1.0405: too many #ifdefs for GTK
commit https://github.com/vim/vim/commit/664323e7c82c35eabb9056efca0df6cc8d6cfd60
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Sep 18 22:30:07 2018 +0200
patch 8.1.0405: too many #ifdefs for GTK
Problem: Too many #ifdefs for GTK.
Solution: Define macros instead of using #ifdef. (Ken Takata, closes https://github.com/vim/vim/issues/3436)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 18 Sep 2018 22:45:05 +0200 |
parents | 82e7ce311065 |
children | 40e19745ad12 |
comparison
equal
deleted
inserted
replaced
14785:7f365a30fe7c | 14786:11978f68a8c3 |
---|---|
802 gui_mch_init_font(*p_guifont == NUL ? NULL : p_guifont, FALSE); | 802 gui_mch_init_font(*p_guifont == NUL ? NULL : p_guifont, FALSE); |
803 gui_set_shellsize(TRUE, FALSE, RESIZE_BOTH); | 803 gui_set_shellsize(TRUE, FALSE, RESIZE_BOTH); |
804 } | 804 } |
805 } | 805 } |
806 | 806 |
807 #if GTK_CHECK_VERSION(3,0,0) | |
808 typedef gboolean timeout_cb_type; | 807 typedef gboolean timeout_cb_type; |
809 #else | |
810 typedef gint timeout_cb_type; | |
811 #endif | |
812 | 808 |
813 /* | 809 /* |
814 * Start a timer that will invoke the specified callback. | 810 * Start a timer that will invoke the specified callback. |
815 * Returns the ID of the timer. | 811 * Returns the ID of the timer. |
816 */ | 812 */ |
817 static guint | 813 static guint |
818 timeout_add(int time, timeout_cb_type (*callback)(gpointer), int *flagp) | 814 timeout_add(int time, timeout_cb_type (*callback)(gpointer), int *flagp) |
819 { | 815 { |
820 #if GTK_CHECK_VERSION(3,0,0) | |
821 return g_timeout_add((guint)time, (GSourceFunc)callback, flagp); | 816 return g_timeout_add((guint)time, (GSourceFunc)callback, flagp); |
822 #else | |
823 return gtk_timeout_add((guint32)time, (GtkFunction)callback, flagp); | |
824 #endif | |
825 } | 817 } |
826 | 818 |
827 static void | 819 static void |
828 timeout_remove(guint timer) | 820 timeout_remove(guint timer) |
829 { | 821 { |
830 #if GTK_CHECK_VERSION(3,0,0) | |
831 g_source_remove(timer); | 822 g_source_remove(timer); |
832 #else | |
833 gtk_timeout_remove(timer); | |
834 #endif | |
835 } | 823 } |
836 | 824 |
837 | 825 |
838 /**************************************************************************** | 826 /**************************************************************************** |
839 * Focus handlers: | 827 * Focus handlers: |
972 { | 960 { |
973 if (blink_state == BLINK_NONE) | 961 if (blink_state == BLINK_NONE) |
974 gui_mch_start_blink(); | 962 gui_mch_start_blink(); |
975 | 963 |
976 /* make sure keyboard input goes there */ | 964 /* make sure keyboard input goes there */ |
977 #if GTK_CHECK_VERSION(3,0,0) | |
978 if (gtk_socket_id == 0 || !gtk_widget_has_focus(gui.drawarea)) | 965 if (gtk_socket_id == 0 || !gtk_widget_has_focus(gui.drawarea)) |
979 #else | |
980 if (gtk_socket_id == 0 || !GTK_WIDGET_HAS_FOCUS(gui.drawarea)) | |
981 #endif | |
982 gtk_widget_grab_focus(gui.drawarea); | 966 gtk_widget_grab_focus(gui.drawarea); |
983 | 967 |
984 return FALSE; | 968 return FALSE; |
985 } | 969 } |
986 | 970 |
1416 char_u *tmpbuf = NULL; | 1400 char_u *tmpbuf = NULL; |
1417 guchar *tmpbuf_utf8 = NULL; | 1401 guchar *tmpbuf_utf8 = NULL; |
1418 int len; | 1402 int len; |
1419 int motion_type = MAUTO; | 1403 int motion_type = MAUTO; |
1420 | 1404 |
1421 #if GTK_CHECK_VERSION(3,0,0) | |
1422 if (gtk_selection_data_get_selection(data) == clip_plus.gtk_sel_atom) | 1405 if (gtk_selection_data_get_selection(data) == clip_plus.gtk_sel_atom) |
1423 #else | |
1424 if (data->selection == clip_plus.gtk_sel_atom) | |
1425 #endif | |
1426 cbd = &clip_plus; | 1406 cbd = &clip_plus; |
1427 else | 1407 else |
1428 cbd = &clip_star; | 1408 cbd = &clip_star; |
1429 | 1409 |
1430 #if GTK_CHECK_VERSION(3,0,0) | |
1431 text = (char_u *)gtk_selection_data_get_data(data); | 1410 text = (char_u *)gtk_selection_data_get_data(data); |
1432 len = gtk_selection_data_get_length(data); | 1411 len = gtk_selection_data_get_length(data); |
1433 #else | |
1434 text = (char_u *)data->data; | |
1435 len = data->length; | |
1436 #endif | |
1437 | 1412 |
1438 if (text == NULL || len <= 0) | 1413 if (text == NULL || len <= 0) |
1439 { | 1414 { |
1440 received_selection = RS_FAIL; | 1415 received_selection = RS_FAIL; |
1441 /* clip_free_selection(cbd); ??? */ | 1416 /* clip_free_selection(cbd); ??? */ |
1442 | 1417 |
1443 return; | 1418 return; |
1444 } | 1419 } |
1445 | 1420 |
1446 #if GTK_CHECK_VERSION(3,0,0) | |
1447 if (gtk_selection_data_get_data_type(data) == vim_atom) | 1421 if (gtk_selection_data_get_data_type(data) == vim_atom) |
1448 #else | |
1449 if (data->type == vim_atom) | |
1450 #endif | |
1451 { | 1422 { |
1452 motion_type = *text++; | 1423 motion_type = *text++; |
1453 --len; | 1424 --len; |
1454 } | 1425 } |
1455 #if GTK_CHECK_VERSION(3,0,0) | |
1456 else if (gtk_selection_data_get_data_type(data) == vimenc_atom) | 1426 else if (gtk_selection_data_get_data_type(data) == vimenc_atom) |
1457 #else | |
1458 else if (data->type == vimenc_atom) | |
1459 #endif | |
1460 { | 1427 { |
1461 char_u *enc; | 1428 char_u *enc; |
1462 vimconv_T conv; | 1429 vimconv_T conv; |
1463 | 1430 |
1464 motion_type = *text++; | 1431 motion_type = *text++; |
1545 int length; | 1512 int length; |
1546 int motion_type; | 1513 int motion_type; |
1547 GdkAtom type; | 1514 GdkAtom type; |
1548 VimClipboard *cbd; | 1515 VimClipboard *cbd; |
1549 | 1516 |
1550 #if GTK_CHECK_VERSION(3,0,0) | |
1551 if (gtk_selection_data_get_selection(selection_data) | 1517 if (gtk_selection_data_get_selection(selection_data) |
1552 == clip_plus.gtk_sel_atom) | 1518 == clip_plus.gtk_sel_atom) |
1553 #else | |
1554 if (selection_data->selection == clip_plus.gtk_sel_atom) | |
1555 #endif | |
1556 cbd = &clip_plus; | 1519 cbd = &clip_plus; |
1557 else | 1520 else |
1558 cbd = &clip_star; | 1521 cbd = &clip_star; |
1559 | 1522 |
1560 if (!cbd->owned) | 1523 if (!cbd->owned) |
1783 static void | 1746 static void |
1784 process_motion_notify(int x, int y, GdkModifierType state) | 1747 process_motion_notify(int x, int y, GdkModifierType state) |
1785 { | 1748 { |
1786 int button; | 1749 int button; |
1787 int_u vim_modifiers; | 1750 int_u vim_modifiers; |
1788 #if GTK_CHECK_VERSION(3,0,0) | |
1789 GtkAllocation allocation; | 1751 GtkAllocation allocation; |
1790 #endif | |
1791 | 1752 |
1792 button = (state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | | 1753 button = (state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | |
1793 GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | | 1754 GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | |
1794 GDK_BUTTON5_MASK)) | 1755 GDK_BUTTON5_MASK)) |
1795 ? MOUSE_DRAG : ' '; | 1756 ? MOUSE_DRAG : ' '; |
1812 gui_send_mouse_event(button, x, y, FALSE, vim_modifiers); | 1773 gui_send_mouse_event(button, x, y, FALSE, vim_modifiers); |
1813 | 1774 |
1814 /* | 1775 /* |
1815 * Auto repeat timer handling. | 1776 * Auto repeat timer handling. |
1816 */ | 1777 */ |
1817 #if GTK_CHECK_VERSION(3,0,0) | |
1818 gtk_widget_get_allocation(gui.drawarea, &allocation); | 1778 gtk_widget_get_allocation(gui.drawarea, &allocation); |
1819 | 1779 |
1820 if (x < 0 || y < 0 | 1780 if (x < 0 || y < 0 |
1821 || x >= allocation.width | 1781 || x >= allocation.width |
1822 || y >= allocation.height) | 1782 || y >= allocation.height) |
1823 #else | |
1824 if (x < 0 || y < 0 | |
1825 || x >= gui.drawarea->allocation.width | |
1826 || y >= gui.drawarea->allocation.height) | |
1827 #endif | |
1828 { | 1783 { |
1829 | 1784 |
1830 int dx; | 1785 int dx; |
1831 int dy; | 1786 int dy; |
1832 int offshoot; | 1787 int offshoot; |
1833 int delay = 10; | 1788 int delay = 10; |
1834 | 1789 |
1835 /* Calculate the maximal distance of the cursor from the drawing area. | 1790 /* Calculate the maximal distance of the cursor from the drawing area. |
1836 * (offshoot can't become negative here!). | 1791 * (offshoot can't become negative here!). |
1837 */ | 1792 */ |
1838 #if GTK_CHECK_VERSION(3,0,0) | |
1839 dx = x < 0 ? -x : x - allocation.width; | 1793 dx = x < 0 ? -x : x - allocation.width; |
1840 dy = y < 0 ? -y : y - allocation.height; | 1794 dy = y < 0 ? -y : y - allocation.height; |
1841 #else | |
1842 dx = x < 0 ? -x : x - gui.drawarea->allocation.width; | |
1843 dy = y < 0 ? -y : y - gui.drawarea->allocation.height; | |
1844 #endif | |
1845 | 1795 |
1846 offshoot = dx > dy ? dx : dy; | 1796 offshoot = dx > dy ? dx : dy; |
1847 | 1797 |
1848 /* Make a linearly decaying timer delay with a threshold of 5 at a | 1798 /* Make a linearly decaying timer delay with a threshold of 5 at a |
1849 * distance of 127 pixels from the main window. | 1799 * distance of 127 pixels from the main window. |
1905 { | 1855 { |
1906 GdkDevice * const dev = gui_gtk_get_pointer_device(widget); | 1856 GdkDevice * const dev = gui_gtk_get_pointer_device(widget); |
1907 return gdk_device_get_window_at_position(dev, x, y); | 1857 return gdk_device_get_window_at_position(dev, x, y); |
1908 } | 1858 } |
1909 # endif | 1859 # endif |
1860 #else /* !GTK_CHECK_VERSION(3,0,0) */ | |
1861 # define gui_gtk_get_pointer(wid, x, y, s) \ | |
1862 gdk_window_get_pointer((wid)->window, x, y, s) | |
1863 # define gui_gtk_window_at_position(wid, x, y) gdk_window_at_pointer(x, y) | |
1910 #endif | 1864 #endif |
1911 | 1865 |
1912 /* | 1866 /* |
1913 * Timer used to recognize multiple clicks of the mouse button. | 1867 * Timer used to recognize multiple clicks of the mouse button. |
1914 */ | 1868 */ |
1917 { | 1871 { |
1918 int x; | 1872 int x; |
1919 int y; | 1873 int y; |
1920 GdkModifierType state; | 1874 GdkModifierType state; |
1921 | 1875 |
1922 #if GTK_CHECK_VERSION(3,0,0) | |
1923 gui_gtk_get_pointer(gui.drawarea, &x, &y, &state); | 1876 gui_gtk_get_pointer(gui.drawarea, &x, &y, &state); |
1924 #else | |
1925 gdk_window_get_pointer(gui.drawarea->window, &x, &y, &state); | |
1926 #endif | |
1927 | 1877 |
1928 if (!(state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | | 1878 if (!(state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | |
1929 GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | | 1879 GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | |
1930 GDK_BUTTON5_MASK))) | 1880 GDK_BUTTON5_MASK))) |
1931 { | 1881 { |
1966 { | 1916 { |
1967 int x; | 1917 int x; |
1968 int y; | 1918 int y; |
1969 GdkModifierType state; | 1919 GdkModifierType state; |
1970 | 1920 |
1971 #if GTK_CHECK_VERSION(3,0,0) | |
1972 gui_gtk_get_pointer(widget, &x, &y, &state); | 1921 gui_gtk_get_pointer(widget, &x, &y, &state); |
1973 #else | |
1974 gdk_window_get_pointer(widget->window, &x, &y, &state); | |
1975 #endif | |
1976 process_motion_notify(x, y, state); | 1922 process_motion_notify(x, y, state); |
1977 } | 1923 } |
1978 else | 1924 else |
1979 { | 1925 { |
1980 process_motion_notify((int)event->x, (int)event->y, | 1926 process_motion_notify((int)event->x, (int)event->y, |
2001 int_u vim_modifiers; | 1947 int_u vim_modifiers; |
2002 | 1948 |
2003 gui.event_time = event->time; | 1949 gui.event_time = event->time; |
2004 | 1950 |
2005 /* Make sure we have focus now we've been selected */ | 1951 /* Make sure we have focus now we've been selected */ |
2006 #if GTK_CHECK_VERSION(3,0,0) | |
2007 if (gtk_socket_id != 0 && !gtk_widget_has_focus(widget)) | 1952 if (gtk_socket_id != 0 && !gtk_widget_has_focus(widget)) |
2008 #else | |
2009 if (gtk_socket_id != 0 && !GTK_WIDGET_HAS_FOCUS(widget)) | |
2010 #endif | |
2011 gtk_widget_grab_focus(widget); | 1953 gtk_widget_grab_focus(widget); |
2012 | 1954 |
2013 /* | 1955 /* |
2014 * Don't let additional events about multiple clicks send by GTK to us | 1956 * Don't let additional events about multiple clicks send by GTK to us |
2015 * after the initial button press event confuse us. | 1957 * after the initial button press event confuse us. |
2067 gpointer data UNUSED) | 2009 gpointer data UNUSED) |
2068 { | 2010 { |
2069 int button; | 2011 int button; |
2070 int_u vim_modifiers; | 2012 int_u vim_modifiers; |
2071 | 2013 |
2072 #if GTK_CHECK_VERSION(3,0,0) | |
2073 if (gtk_socket_id != 0 && !gtk_widget_has_focus(widget)) | 2014 if (gtk_socket_id != 0 && !gtk_widget_has_focus(widget)) |
2074 #else | |
2075 if (gtk_socket_id != 0 && !GTK_WIDGET_HAS_FOCUS(widget)) | |
2076 #endif | |
2077 gtk_widget_grab_focus(widget); | 2015 gtk_widget_grab_focus(widget); |
2078 | 2016 |
2079 switch (event->direction) | 2017 switch (event->direction) |
2080 { | 2018 { |
2081 case GDK_SCROLL_UP: | 2019 case GDK_SCROLL_UP: |
2237 gint y) | 2175 gint y) |
2238 { | 2176 { |
2239 char_u **fnames; | 2177 char_u **fnames; |
2240 int nfiles = 0; | 2178 int nfiles = 0; |
2241 | 2179 |
2242 # if GTK_CHECK_VERSION(3,0,0) | |
2243 fnames = parse_uri_list(&nfiles, | 2180 fnames = parse_uri_list(&nfiles, |
2244 (char_u *)gtk_selection_data_get_data(data), | 2181 (char_u *)gtk_selection_data_get_data(data), |
2245 gtk_selection_data_get_length(data)); | 2182 gtk_selection_data_get_length(data)); |
2246 # else | |
2247 fnames = parse_uri_list(&nfiles, data->data, data->length); | |
2248 # endif | |
2249 | 2183 |
2250 if (fnames != NULL && nfiles > 0) | 2184 if (fnames != NULL && nfiles > 0) |
2251 { | 2185 { |
2252 int_u modifiers; | 2186 int_u modifiers; |
2253 | 2187 |
2270 char_u dropkey[6] = {CSI, KS_MODIFIER, 0, CSI, KS_EXTRA, (char_u)KE_DROP}; | 2204 char_u dropkey[6] = {CSI, KS_MODIFIER, 0, CSI, KS_EXTRA, (char_u)KE_DROP}; |
2271 char_u *text; | 2205 char_u *text; |
2272 int len; | 2206 int len; |
2273 char_u *tmpbuf = NULL; | 2207 char_u *tmpbuf = NULL; |
2274 | 2208 |
2275 # if GTK_CHECK_VERSION(3,0,0) | |
2276 text = (char_u *)gtk_selection_data_get_data(data); | 2209 text = (char_u *)gtk_selection_data_get_data(data); |
2277 len = gtk_selection_data_get_length(data); | 2210 len = gtk_selection_data_get_length(data); |
2278 # else | 2211 |
2279 text = data->data; | |
2280 len = data->length; | |
2281 # endif | |
2282 | |
2283 # if GTK_CHECK_VERSION(3,0,0) | |
2284 if (gtk_selection_data_get_data_type(data) == utf8_string_atom) | 2212 if (gtk_selection_data_get_data_type(data) == utf8_string_atom) |
2285 # else | |
2286 if (data->type == utf8_string_atom) | |
2287 # endif | |
2288 { | 2213 { |
2289 if (input_conv.vc_type != CONV_NONE) | 2214 if (input_conv.vc_type != CONV_NONE) |
2290 tmpbuf = string_convert(&input_conv, text, &len); | 2215 tmpbuf = string_convert(&input_conv, text, &len); |
2291 if (tmpbuf != NULL) | 2216 if (tmpbuf != NULL) |
2292 text = tmpbuf; | 2217 text = tmpbuf; |
2318 gpointer user_data UNUSED) | 2243 gpointer user_data UNUSED) |
2319 { | 2244 { |
2320 GdkModifierType state; | 2245 GdkModifierType state; |
2321 | 2246 |
2322 /* Guard against trash */ | 2247 /* Guard against trash */ |
2323 # if GTK_CHECK_VERSION(3,0,0) | |
2324 const guchar * const data_data = gtk_selection_data_get_data(data); | 2248 const guchar * const data_data = gtk_selection_data_get_data(data); |
2325 const gint data_length = gtk_selection_data_get_length(data); | 2249 const gint data_length = gtk_selection_data_get_length(data); |
2326 const gint data_format = gtk_selection_data_get_format(data); | 2250 const gint data_format = gtk_selection_data_get_format(data); |
2327 | 2251 |
2328 if (data_data == NULL | 2252 if (data_data == NULL |
2329 || data_length <= 0 | 2253 || data_length <= 0 |
2330 || data_format != 8 | 2254 || data_format != 8 |
2331 || data_data[data_length] != '\0') | 2255 || data_data[data_length] != '\0') |
2332 # else | |
2333 if (data->data == NULL | |
2334 || data->length <= 0 | |
2335 || data->format != 8 | |
2336 || data->data[data->length] != '\0') | |
2337 # endif | |
2338 { | 2256 { |
2339 gtk_drag_finish(context, FALSE, FALSE, time_); | 2257 gtk_drag_finish(context, FALSE, FALSE, time_); |
2340 return; | 2258 return; |
2341 } | 2259 } |
2342 | 2260 |
2343 /* Get the current modifier state for proper distinguishment between | 2261 /* Get the current modifier state for proper distinguishment between |
2344 * different operations later. */ | 2262 * different operations later. */ |
2345 #if GTK_CHECK_VERSION(3,0,0) | |
2346 gui_gtk_get_pointer(widget, NULL, NULL, &state); | 2263 gui_gtk_get_pointer(widget, NULL, NULL, &state); |
2347 # else | |
2348 gdk_window_get_pointer(widget->window, NULL, NULL, &state); | |
2349 # endif | |
2350 | 2264 |
2351 /* Not sure about the role of "text/plain" here... */ | 2265 /* Not sure about the role of "text/plain" here... */ |
2352 if (info == (guint)TARGET_TEXT_URI_LIST) | 2266 if (info == (guint)TARGET_TEXT_URI_LIST) |
2353 drag_handle_uri_list(context, data, time_, state, x, y); | 2267 drag_handle_uri_list(context, data, time_, state, x, y); |
2354 else | 2268 else |
2808 */ | 2722 */ |
2809 serverChangeRegisteredWindow(GDK_WINDOW_XDISPLAY(mainwin_win), | 2723 serverChangeRegisteredWindow(GDK_WINDOW_XDISPLAY(mainwin_win), |
2810 GDK_WINDOW_XID(mainwin_win)); | 2724 GDK_WINDOW_XID(mainwin_win)); |
2811 } | 2725 } |
2812 gtk_widget_add_events(gui.mainwin, GDK_PROPERTY_CHANGE_MASK); | 2726 gtk_widget_add_events(gui.mainwin, GDK_PROPERTY_CHANGE_MASK); |
2813 # if GTK_CHECK_VERSION(3,0,0) | |
2814 g_signal_connect(G_OBJECT(gui.mainwin), "property-notify-event", | 2727 g_signal_connect(G_OBJECT(gui.mainwin), "property-notify-event", |
2815 G_CALLBACK(property_event), NULL); | 2728 G_CALLBACK(property_event), NULL); |
2816 # else | |
2817 gtk_signal_connect(GTK_OBJECT(gui.mainwin), "property_notify_event", | |
2818 GTK_SIGNAL_FUNC(property_event), NULL); | |
2819 # endif | |
2820 #endif | 2729 #endif |
2821 } | 2730 } |
2822 | 2731 |
2823 static GdkCursor * | 2732 static GdkCursor * |
2824 create_blank_pointer(void) | 2733 create_blank_pointer(void) |
2933 */ | 2842 */ |
2934 static void | 2843 static void |
2935 drawarea_realize_cb(GtkWidget *widget, gpointer data UNUSED) | 2844 drawarea_realize_cb(GtkWidget *widget, gpointer data UNUSED) |
2936 { | 2845 { |
2937 GtkWidget *sbar; | 2846 GtkWidget *sbar; |
2938 #if GTK_CHECK_VERSION(3,0,0) | |
2939 GtkAllocation allocation; | 2847 GtkAllocation allocation; |
2940 #endif | |
2941 | 2848 |
2942 #ifdef FEAT_XIM | 2849 #ifdef FEAT_XIM |
2943 xim_init(); | 2850 xim_init(); |
2944 #endif | 2851 #endif |
2945 gui_mch_new_colors(); | 2852 gui_mch_new_colors(); |
2960 /* get the actual size of the scrollbars, if they are realized */ | 2867 /* get the actual size of the scrollbars, if they are realized */ |
2961 sbar = firstwin->w_scrollbars[SBAR_LEFT].id; | 2868 sbar = firstwin->w_scrollbars[SBAR_LEFT].id; |
2962 if (!sbar || (!gui.which_scrollbars[SBAR_LEFT] | 2869 if (!sbar || (!gui.which_scrollbars[SBAR_LEFT] |
2963 && firstwin->w_scrollbars[SBAR_RIGHT].id)) | 2870 && firstwin->w_scrollbars[SBAR_RIGHT].id)) |
2964 sbar = firstwin->w_scrollbars[SBAR_RIGHT].id; | 2871 sbar = firstwin->w_scrollbars[SBAR_RIGHT].id; |
2965 #if GTK_CHECK_VERSION(3,0,0) | |
2966 gtk_widget_get_allocation(sbar, &allocation); | 2872 gtk_widget_get_allocation(sbar, &allocation); |
2967 if (sbar && gtk_widget_get_realized(sbar) && allocation.width) | 2873 if (sbar && gtk_widget_get_realized(sbar) && allocation.width) |
2968 gui.scrollbar_width = allocation.width; | 2874 gui.scrollbar_width = allocation.width; |
2969 #else | |
2970 if (sbar && GTK_WIDGET_REALIZED(sbar) && sbar->allocation.width) | |
2971 gui.scrollbar_width = sbar->allocation.width; | |
2972 #endif | |
2973 | 2875 |
2974 sbar = gui.bottom_sbar.id; | 2876 sbar = gui.bottom_sbar.id; |
2975 #if GTK_CHECK_VERSION(3,0,0) | |
2976 if (sbar && gtk_widget_get_realized(sbar) && allocation.height) | 2877 if (sbar && gtk_widget_get_realized(sbar) && allocation.height) |
2977 gui.scrollbar_height = allocation.height; | 2878 gui.scrollbar_height = allocation.height; |
2978 #else | |
2979 if (sbar && GTK_WIDGET_REALIZED(sbar) && sbar->allocation.height) | |
2980 gui.scrollbar_height = sbar->allocation.height; | |
2981 #endif | |
2982 } | 2879 } |
2983 | 2880 |
2984 /* | 2881 /* |
2985 * Properly clean up on shutdown. | 2882 * Properly clean up on shutdown. |
2986 */ | 2883 */ |
3140 } | 3037 } |
3141 # else | 3038 # else |
3142 # define item_orientation GTK_ORIENTATION_HORIZONTAL | 3039 # define item_orientation GTK_ORIENTATION_HORIZONTAL |
3143 # endif | 3040 # endif |
3144 | 3041 |
3145 # if GTK_CHECK_VERSION(3,0,0) | |
3146 if (widget != NULL | 3042 if (widget != NULL |
3147 && item_orientation == orientation | 3043 && item_orientation == orientation |
3148 && gtk_widget_get_realized(widget) | 3044 && gtk_widget_get_realized(widget) |
3149 && gtk_widget_get_visible(widget)) | 3045 && gtk_widget_get_visible(widget)) |
3150 # else | 3046 { |
3151 if (widget != NULL | 3047 # if GTK_CHECK_VERSION(3,0,0) || !defined(FEAT_GUI_GNOME) |
3152 && item_orientation == orientation | |
3153 && GTK_WIDGET_REALIZED(widget) | |
3154 && GTK_WIDGET_VISIBLE(widget)) | |
3155 # endif | |
3156 { | |
3157 # if GTK_CHECK_VERSION(3,0,0) | |
3158 GtkAllocation allocation; | 3048 GtkAllocation allocation; |
3159 | 3049 |
3160 gtk_widget_get_allocation(widget, &allocation); | 3050 gtk_widget_get_allocation(widget, &allocation); |
3161 return allocation.height; | 3051 return allocation.height; |
3162 # else | 3052 # else |
3163 # ifdef FEAT_GUI_GNOME | |
3164 if (orientation == GTK_ORIENTATION_HORIZONTAL) | 3053 if (orientation == GTK_ORIENTATION_HORIZONTAL) |
3165 return widget->allocation.height; | 3054 return widget->allocation.height; |
3166 else | 3055 else |
3167 return widget->allocation.width; | 3056 return widget->allocation.width; |
3168 # else | |
3169 return widget->allocation.height; | |
3170 # endif | |
3171 # endif | 3057 # endif |
3172 } | 3058 } |
3173 return 0; | 3059 return 0; |
3174 } | 3060 } |
3175 #endif | 3061 #endif |
3436 item = gtk_menu_item_new_with_label((const char *)utf_text); | 3322 item = gtk_menu_item_new_with_label((const char *)utf_text); |
3437 gtk_widget_show(item); | 3323 gtk_widget_show(item); |
3438 CONVERT_TO_UTF8_FREE(utf_text); | 3324 CONVERT_TO_UTF8_FREE(utf_text); |
3439 | 3325 |
3440 gtk_container_add(GTK_CONTAINER(menu), item); | 3326 gtk_container_add(GTK_CONTAINER(menu), item); |
3441 # if GTK_CHECK_VERSION(3,0,0) | |
3442 g_signal_connect(G_OBJECT(item), "activate", | 3327 g_signal_connect(G_OBJECT(item), "activate", |
3443 G_CALLBACK(tabline_menu_handler), | 3328 G_CALLBACK(tabline_menu_handler), |
3444 GINT_TO_POINTER(resp)); | 3329 GINT_TO_POINTER(resp)); |
3445 # else | |
3446 gtk_signal_connect(GTK_OBJECT(item), "activate", | |
3447 GTK_SIGNAL_FUNC(tabline_menu_handler), | |
3448 (gpointer)(long)resp); | |
3449 # endif | |
3450 } | 3330 } |
3451 | 3331 |
3452 /* | 3332 /* |
3453 * Create a menu for the tab line. | 3333 * Create a menu for the tab line. |
3454 */ | 3334 */ |
3486 || cmdwin_type != 0 | 3366 || cmdwin_type != 0 |
3487 # endif | 3367 # endif |
3488 ) | 3368 ) |
3489 return TRUE; | 3369 return TRUE; |
3490 | 3370 |
3491 # if GTK_CHECK_VERSION(3,0,0) | |
3492 tabwin = gui_gtk_window_at_position(gui.mainwin, &x, &y); | 3371 tabwin = gui_gtk_window_at_position(gui.mainwin, &x, &y); |
3493 # else | |
3494 tabwin = gdk_window_at_pointer(&x, &y); | |
3495 # endif | |
3496 | 3372 |
3497 gdk_window_get_user_data(tabwin, (gpointer)&tabwidget); | 3373 gdk_window_get_user_data(tabwin, (gpointer)&tabwidget); |
3498 # if GTK_CHECK_VERSION(3,0,0) | |
3499 clicked_page = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(tabwidget), | 3374 clicked_page = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(tabwidget), |
3500 "tab_num")); | 3375 "tab_num")); |
3501 # else | |
3502 clicked_page = (int)(long)gtk_object_get_user_data( | |
3503 GTK_OBJECT(tabwidget)); | |
3504 # endif | |
3505 | 3376 |
3506 /* If the event was generated for 3rd button popup the menu. */ | 3377 /* If the event was generated for 3rd button popup the menu. */ |
3507 if (bevent->button == 3) | 3378 if (bevent->button == 3) |
3508 { | 3379 { |
3509 # if GTK_CHECK_VERSION(3,22,2) | 3380 # if GTK_CHECK_VERSION(3,22,2) |
3534 * Handle selecting one of the tabs. | 3405 * Handle selecting one of the tabs. |
3535 */ | 3406 */ |
3536 static void | 3407 static void |
3537 on_select_tab( | 3408 on_select_tab( |
3538 GtkNotebook *notebook UNUSED, | 3409 GtkNotebook *notebook UNUSED, |
3539 # if GTK_CHECK_VERSION(3,0,0) | |
3540 gpointer *page UNUSED, | 3410 gpointer *page UNUSED, |
3541 # else | |
3542 GtkNotebookPage *page UNUSED, | |
3543 # endif | |
3544 gint idx, | 3411 gint idx, |
3545 gpointer data UNUSED) | 3412 gpointer data UNUSED) |
3546 { | 3413 { |
3547 if (!ignore_tabline_evt) | 3414 if (!ignore_tabline_evt) |
3548 send_tabline_event(idx + 1); | 3415 send_tabline_event(idx + 1); |
3552 * Handle reordering the tabs (using D&D). | 3419 * Handle reordering the tabs (using D&D). |
3553 */ | 3420 */ |
3554 static void | 3421 static void |
3555 on_tab_reordered( | 3422 on_tab_reordered( |
3556 GtkNotebook *notebook UNUSED, | 3423 GtkNotebook *notebook UNUSED, |
3557 # if GTK_CHECK_VERSION(3,0,0) | |
3558 gpointer *page UNUSED, | 3424 gpointer *page UNUSED, |
3559 # else | |
3560 GtkNotebookPage *page UNUSED, | |
3561 # endif | |
3562 gint idx, | 3425 gint idx, |
3563 gpointer data UNUSED) | 3426 gpointer data UNUSED) |
3564 { | 3427 { |
3565 if (!ignore_tabline_evt) | 3428 if (!ignore_tabline_evt) |
3566 { | 3429 { |
3584 { | 3447 { |
3585 /* Note: this may cause a resize event */ | 3448 /* Note: this may cause a resize event */ |
3586 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gui.tabline), showit); | 3449 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gui.tabline), showit); |
3587 update_window_manager_hints(0, 0); | 3450 update_window_manager_hints(0, 0); |
3588 if (showit) | 3451 if (showit) |
3589 # if GTK_CHECK_VERSION(3,0,0) | |
3590 gtk_widget_set_can_focus(GTK_WIDGET(gui.tabline), FALSE); | 3452 gtk_widget_set_can_focus(GTK_WIDGET(gui.tabline), FALSE); |
3591 # else | |
3592 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(gui.tabline), GTK_CAN_FOCUS); | |
3593 # endif | |
3594 } | 3453 } |
3595 | 3454 |
3596 gui_mch_update(); | 3455 gui_mch_update(); |
3597 } | 3456 } |
3598 | 3457 |
3661 page, | 3520 page, |
3662 TRUE); | 3521 TRUE); |
3663 } | 3522 } |
3664 | 3523 |
3665 event_box = gtk_notebook_get_tab_label(GTK_NOTEBOOK(gui.tabline), page); | 3524 event_box = gtk_notebook_get_tab_label(GTK_NOTEBOOK(gui.tabline), page); |
3666 # if GTK_CHECK_VERSION(3,0,0) | |
3667 g_object_set_data(G_OBJECT(event_box), "tab_num", | 3525 g_object_set_data(G_OBJECT(event_box), "tab_num", |
3668 GINT_TO_POINTER(tab_num)); | 3526 GINT_TO_POINTER(tab_num)); |
3669 # else | |
3670 gtk_object_set_user_data(GTK_OBJECT(event_box), | |
3671 (gpointer)(long)tab_num); | |
3672 # endif | |
3673 # if GTK_CHECK_VERSION(3,0,0) | |
3674 label = gtk_bin_get_child(GTK_BIN(event_box)); | 3527 label = gtk_bin_get_child(GTK_BIN(event_box)); |
3675 # else | |
3676 label = GTK_BIN(event_box)->child; | |
3677 # endif | |
3678 get_tabline_label(tp, FALSE); | 3528 get_tabline_label(tp, FALSE); |
3679 labeltext = CONVERT_TO_UTF8(NameBuff); | 3529 labeltext = CONVERT_TO_UTF8(NameBuff); |
3680 gtk_label_set_text(GTK_LABEL(label), (const char *)labeltext); | 3530 gtk_label_set_text(GTK_LABEL(label), (const char *)labeltext); |
3681 CONVERT_TO_UTF8_FREE(labeltext); | 3531 CONVERT_TO_UTF8_FREE(labeltext); |
3682 | 3532 |
3693 | 3543 |
3694 /* Remove any old labels. */ | 3544 /* Remove any old labels. */ |
3695 while (gtk_notebook_get_nth_page(GTK_NOTEBOOK(gui.tabline), nr) != NULL) | 3545 while (gtk_notebook_get_nth_page(GTK_NOTEBOOK(gui.tabline), nr) != NULL) |
3696 gtk_notebook_remove_page(GTK_NOTEBOOK(gui.tabline), nr); | 3546 gtk_notebook_remove_page(GTK_NOTEBOOK(gui.tabline), nr); |
3697 | 3547 |
3698 # if GTK_CHECK_VERSION(3,0,0) | |
3699 if (gtk_notebook_get_current_page(GTK_NOTEBOOK(gui.tabline)) != curtabidx) | 3548 if (gtk_notebook_get_current_page(GTK_NOTEBOOK(gui.tabline)) != curtabidx) |
3700 gtk_notebook_set_current_page(GTK_NOTEBOOK(gui.tabline), curtabidx); | 3549 gtk_notebook_set_current_page(GTK_NOTEBOOK(gui.tabline), curtabidx); |
3701 # else | |
3702 if (gtk_notebook_current_page(GTK_NOTEBOOK(gui.tabline)) != curtabidx) | |
3703 gtk_notebook_set_page(GTK_NOTEBOOK(gui.tabline), curtabidx); | |
3704 # endif | |
3705 | 3550 |
3706 /* Make sure everything is in place before drawing text. */ | 3551 /* Make sure everything is in place before drawing text. */ |
3707 gui_mch_update(); | 3552 gui_mch_update(); |
3708 | 3553 |
3709 ignore_tabline_evt = FALSE; | 3554 ignore_tabline_evt = FALSE; |
3717 { | 3562 { |
3718 if (gui.tabline == NULL) | 3563 if (gui.tabline == NULL) |
3719 return; | 3564 return; |
3720 | 3565 |
3721 ignore_tabline_evt = TRUE; | 3566 ignore_tabline_evt = TRUE; |
3722 # if GTK_CHECK_VERSION(3,0,0) | |
3723 if (gtk_notebook_get_current_page(GTK_NOTEBOOK(gui.tabline)) != nr - 1) | 3567 if (gtk_notebook_get_current_page(GTK_NOTEBOOK(gui.tabline)) != nr - 1) |
3724 gtk_notebook_set_current_page(GTK_NOTEBOOK(gui.tabline), nr - 1); | 3568 gtk_notebook_set_current_page(GTK_NOTEBOOK(gui.tabline), nr - 1); |
3725 # else | |
3726 if (gtk_notebook_current_page(GTK_NOTEBOOK(gui.tabline)) != nr - 1) | |
3727 gtk_notebook_set_page(GTK_NOTEBOOK(gui.tabline), nr - 1); | |
3728 # endif | |
3729 ignore_tabline_evt = FALSE; | 3569 ignore_tabline_evt = FALSE; |
3730 } | 3570 } |
3731 | 3571 |
3732 #endif /* FEAT_GUI_TABLINE */ | 3572 #endif /* FEAT_GUI_TABLINE */ |
3733 | 3573 |
3870 GtkWidget *plug; | 3710 GtkWidget *plug; |
3871 | 3711 |
3872 /* Use GtkSocket from another app. */ | 3712 /* Use GtkSocket from another app. */ |
3873 plug = gtk_plug_new_for_display(gdk_display_get_default(), | 3713 plug = gtk_plug_new_for_display(gdk_display_get_default(), |
3874 gtk_socket_id); | 3714 gtk_socket_id); |
3875 #if GTK_CHECK_VERSION(3,0,0) | |
3876 if (plug != NULL && gtk_plug_get_socket_window(GTK_PLUG(plug)) != NULL) | 3715 if (plug != NULL && gtk_plug_get_socket_window(GTK_PLUG(plug)) != NULL) |
3877 #else | |
3878 if (plug != NULL && GTK_PLUG(plug)->socket_window != NULL) | |
3879 #endif | |
3880 { | 3716 { |
3881 gui.mainwin = plug; | 3717 gui.mainwin = plug; |
3882 } | 3718 } |
3883 else | 3719 else |
3884 { | 3720 { |
3909 | 3745 |
3910 /* Create the PangoContext used for drawing all text. */ | 3746 /* Create the PangoContext used for drawing all text. */ |
3911 gui.text_context = gtk_widget_create_pango_context(gui.mainwin); | 3747 gui.text_context = gtk_widget_create_pango_context(gui.mainwin); |
3912 pango_context_set_base_dir(gui.text_context, PANGO_DIRECTION_LTR); | 3748 pango_context_set_base_dir(gui.text_context, PANGO_DIRECTION_LTR); |
3913 | 3749 |
3914 #if GTK_CHECK_VERSION(3,0,0) | |
3915 gtk_container_set_border_width(GTK_CONTAINER(gui.mainwin), 0); | 3750 gtk_container_set_border_width(GTK_CONTAINER(gui.mainwin), 0); |
3916 #else | |
3917 gtk_container_border_width(GTK_CONTAINER(gui.mainwin), 0); | |
3918 #endif | |
3919 gtk_widget_add_events(gui.mainwin, GDK_VISIBILITY_NOTIFY_MASK); | 3751 gtk_widget_add_events(gui.mainwin, GDK_VISIBILITY_NOTIFY_MASK); |
3920 | 3752 |
3921 #if GTK_CHECK_VERSION(3,0,0) | |
3922 g_signal_connect(G_OBJECT(gui.mainwin), "delete-event", | 3753 g_signal_connect(G_OBJECT(gui.mainwin), "delete-event", |
3923 G_CALLBACK(&delete_event_cb), NULL); | 3754 G_CALLBACK(&delete_event_cb), NULL); |
3924 | 3755 |
3925 g_signal_connect(G_OBJECT(gui.mainwin), "realize", | 3756 g_signal_connect(G_OBJECT(gui.mainwin), "realize", |
3926 G_CALLBACK(&mainwin_realize), NULL); | 3757 G_CALLBACK(&mainwin_realize), NULL); |
3927 #else | |
3928 gtk_signal_connect(GTK_OBJECT(gui.mainwin), "delete_event", | |
3929 GTK_SIGNAL_FUNC(&delete_event_cb), NULL); | |
3930 | |
3931 gtk_signal_connect(GTK_OBJECT(gui.mainwin), "realize", | |
3932 GTK_SIGNAL_FUNC(&mainwin_realize), NULL); | |
3933 #endif | |
3934 | 3758 |
3935 g_signal_connect(G_OBJECT(gui.mainwin), "screen-changed", | 3759 g_signal_connect(G_OBJECT(gui.mainwin), "screen-changed", |
3936 G_CALLBACK(&mainwin_screen_changed_cb), NULL); | 3760 G_CALLBACK(&mainwin_screen_changed_cb), NULL); |
3937 | 3761 |
3938 gui.accel_group = gtk_accel_group_new(); | 3762 gui.accel_group = gtk_accel_group_new(); |
4082 gtk_container_add(GTK_CONTAINER(gui.tabline), page); | 3906 gtk_container_add(GTK_CONTAINER(gui.tabline), page); |
4083 label = gtk_label_new("-Empty-"); | 3907 label = gtk_label_new("-Empty-"); |
4084 gtk_widget_show(label); | 3908 gtk_widget_show(label); |
4085 event_box = gtk_event_box_new(); | 3909 event_box = gtk_event_box_new(); |
4086 gtk_widget_show(event_box); | 3910 gtk_widget_show(event_box); |
4087 # if GTK_CHECK_VERSION(3,0,0) | |
4088 g_object_set_data(G_OBJECT(event_box), "tab_num", GINT_TO_POINTER(1L)); | 3911 g_object_set_data(G_OBJECT(event_box), "tab_num", GINT_TO_POINTER(1L)); |
4089 # else | |
4090 gtk_object_set_user_data(GTK_OBJECT(event_box), (gpointer)1L); | |
4091 # endif | |
4092 # if !GTK_CHECK_VERSION(3,14,0) | 3912 # if !GTK_CHECK_VERSION(3,14,0) |
4093 gtk_misc_set_padding(GTK_MISC(label), 2, 2); | 3913 gtk_misc_set_padding(GTK_MISC(label), 2, 2); |
4094 # endif | 3914 # endif |
4095 gtk_container_add(GTK_CONTAINER(event_box), label); | 3915 gtk_container_add(GTK_CONTAINER(event_box), label); |
4096 gtk_notebook_set_tab_label(GTK_NOTEBOOK(gui.tabline), page, event_box); | 3916 gtk_notebook_set_tab_label(GTK_NOTEBOOK(gui.tabline), page, event_box); |
4097 gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(gui.tabline), page, TRUE); | 3917 gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(gui.tabline), page, TRUE); |
4098 } | 3918 } |
4099 | 3919 |
4100 # if GTK_CHECK_VERSION(3,0,0) | |
4101 g_signal_connect(G_OBJECT(gui.tabline), "switch-page", | 3920 g_signal_connect(G_OBJECT(gui.tabline), "switch-page", |
4102 G_CALLBACK(on_select_tab), NULL); | 3921 G_CALLBACK(on_select_tab), NULL); |
4103 g_signal_connect(G_OBJECT(gui.tabline), "page-reordered", | 3922 g_signal_connect(G_OBJECT(gui.tabline), "page-reordered", |
4104 G_CALLBACK(on_tab_reordered), NULL); | 3923 G_CALLBACK(on_tab_reordered), NULL); |
4105 # else | |
4106 gtk_signal_connect(GTK_OBJECT(gui.tabline), "switch_page", | |
4107 GTK_SIGNAL_FUNC(on_select_tab), NULL); | |
4108 gtk_signal_connect(GTK_OBJECT(gui.tabline), "page-reordered", | |
4109 GTK_SIGNAL_FUNC(on_tab_reordered), NULL); | |
4110 # endif | |
4111 | 3924 |
4112 /* Create a popup menu for the tab line and connect it. */ | 3925 /* Create a popup menu for the tab line and connect it. */ |
4113 tabline_menu = create_tabline_menu(); | 3926 tabline_menu = create_tabline_menu(); |
4114 # if GTK_CHECK_VERSION(3,0,0) | |
4115 g_signal_connect_swapped(G_OBJECT(gui.tabline), "button-press-event", | 3927 g_signal_connect_swapped(G_OBJECT(gui.tabline), "button-press-event", |
4116 G_CALLBACK(on_tabline_menu), G_OBJECT(tabline_menu)); | 3928 G_CALLBACK(on_tabline_menu), G_OBJECT(tabline_menu)); |
4117 # else | |
4118 gtk_signal_connect_object(GTK_OBJECT(gui.tabline), "button_press_event", | |
4119 GTK_SIGNAL_FUNC(on_tabline_menu), GTK_OBJECT(tabline_menu)); | |
4120 # endif | |
4121 #endif /* FEAT_GUI_TABLINE */ | 3929 #endif /* FEAT_GUI_TABLINE */ |
4122 | 3930 |
4123 gui.formwin = gtk_form_new(); | 3931 gui.formwin = gtk_form_new(); |
4124 #if GTK_CHECK_VERSION(3,0,0) | |
4125 gtk_container_set_border_width(GTK_CONTAINER(gui.formwin), 0); | 3932 gtk_container_set_border_width(GTK_CONTAINER(gui.formwin), 0); |
4126 #else | |
4127 gtk_container_border_width(GTK_CONTAINER(gui.formwin), 0); | |
4128 #endif | |
4129 #if !GTK_CHECK_VERSION(3,0,0) | 3933 #if !GTK_CHECK_VERSION(3,0,0) |
4130 gtk_widget_set_events(gui.formwin, GDK_EXPOSURE_MASK); | 3934 gtk_widget_set_events(gui.formwin, GDK_EXPOSURE_MASK); |
4131 #endif | 3935 #endif |
4132 | 3936 |
4133 gui.drawarea = gtk_drawing_area_new(); | 3937 gui.drawarea = gtk_drawing_area_new(); |
4157 gtk_widget_show(gui.formwin); | 3961 gtk_widget_show(gui.formwin); |
4158 gtk_box_pack_start(GTK_BOX(vbox), gui.formwin, TRUE, TRUE, 0); | 3962 gtk_box_pack_start(GTK_BOX(vbox), gui.formwin, TRUE, TRUE, 0); |
4159 | 3963 |
4160 /* For GtkSockets, key-presses must go to the focus widget (drawarea) | 3964 /* For GtkSockets, key-presses must go to the focus widget (drawarea) |
4161 * and not the window. */ | 3965 * and not the window. */ |
4162 #if GTK_CHECK_VERSION(3,0,0) | |
4163 g_signal_connect((gtk_socket_id == 0) ? G_OBJECT(gui.mainwin) | 3966 g_signal_connect((gtk_socket_id == 0) ? G_OBJECT(gui.mainwin) |
4164 : G_OBJECT(gui.drawarea), | 3967 : G_OBJECT(gui.drawarea), |
4165 "key-press-event", | 3968 "key-press-event", |
4166 G_CALLBACK(key_press_event), NULL); | 3969 G_CALLBACK(key_press_event), NULL); |
4167 #else | |
4168 gtk_signal_connect((gtk_socket_id == 0) ? GTK_OBJECT(gui.mainwin) | |
4169 : GTK_OBJECT(gui.drawarea), | |
4170 "key_press_event", | |
4171 GTK_SIGNAL_FUNC(key_press_event), NULL); | |
4172 #endif | |
4173 #if defined(FEAT_XIM) || GTK_CHECK_VERSION(3,0,0) | 3970 #if defined(FEAT_XIM) || GTK_CHECK_VERSION(3,0,0) |
4174 /* Also forward key release events for the benefit of GTK+ 2 input | 3971 /* Also forward key release events for the benefit of GTK+ 2 input |
4175 * modules. Try CTRL-SHIFT-xdigits to enter a Unicode code point. */ | 3972 * modules. Try CTRL-SHIFT-xdigits to enter a Unicode code point. */ |
4176 g_signal_connect((gtk_socket_id == 0) ? G_OBJECT(gui.mainwin) | 3973 g_signal_connect((gtk_socket_id == 0) ? G_OBJECT(gui.mainwin) |
4177 : G_OBJECT(gui.drawarea), | 3974 : G_OBJECT(gui.drawarea), |
4178 "key-release-event", | 3975 "key-release-event", |
4179 G_CALLBACK(&key_release_event), NULL); | 3976 G_CALLBACK(&key_release_event), NULL); |
4180 #endif | 3977 #endif |
4181 #if GTK_CHECK_VERSION(3,0,0) | |
4182 g_signal_connect(G_OBJECT(gui.drawarea), "realize", | 3978 g_signal_connect(G_OBJECT(gui.drawarea), "realize", |
4183 G_CALLBACK(drawarea_realize_cb), NULL); | 3979 G_CALLBACK(drawarea_realize_cb), NULL); |
4184 g_signal_connect(G_OBJECT(gui.drawarea), "unrealize", | 3980 g_signal_connect(G_OBJECT(gui.drawarea), "unrealize", |
4185 G_CALLBACK(drawarea_unrealize_cb), NULL); | 3981 G_CALLBACK(drawarea_unrealize_cb), NULL); |
3982 #if GTK_CHECK_VERSION(3,0,0) | |
4186 g_signal_connect(G_OBJECT(gui.drawarea), "configure-event", | 3983 g_signal_connect(G_OBJECT(gui.drawarea), "configure-event", |
4187 G_CALLBACK(drawarea_configure_event_cb), NULL); | 3984 G_CALLBACK(drawarea_configure_event_cb), NULL); |
4188 # if GTK_CHECK_VERSION(3,22,2) | 3985 #endif |
3986 #if GTK_CHECK_VERSION(3,22,2) | |
4189 g_signal_connect_after(G_OBJECT(gui.drawarea), "style-updated", | 3987 g_signal_connect_after(G_OBJECT(gui.drawarea), "style-updated", |
4190 G_CALLBACK(&drawarea_style_updated_cb), NULL); | 3988 G_CALLBACK(&drawarea_style_updated_cb), NULL); |
4191 # else | 3989 #else |
4192 g_signal_connect_after(G_OBJECT(gui.drawarea), "style-set", | 3990 g_signal_connect_after(G_OBJECT(gui.drawarea), "style-set", |
4193 G_CALLBACK(&drawarea_style_set_cb), NULL); | 3991 G_CALLBACK(&drawarea_style_set_cb), NULL); |
4194 # endif | |
4195 #else | |
4196 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "realize", | |
4197 GTK_SIGNAL_FUNC(drawarea_realize_cb), NULL); | |
4198 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "unrealize", | |
4199 GTK_SIGNAL_FUNC(drawarea_unrealize_cb), NULL); | |
4200 | |
4201 gtk_signal_connect_after(GTK_OBJECT(gui.drawarea), "style_set", | |
4202 GTK_SIGNAL_FUNC(&drawarea_style_set_cb), NULL); | |
4203 #endif | 3992 #endif |
4204 | 3993 |
4205 #if !GTK_CHECK_VERSION(3,0,0) | 3994 #if !GTK_CHECK_VERSION(3,0,0) |
4206 gui.visibility = GDK_VISIBILITY_UNOBSCURED; | 3995 gui.visibility = GDK_VISIBILITY_UNOBSCURED; |
4207 #endif | 3996 #endif |
4211 save_yourself_atom = gdk_atom_intern("WM_SAVE_YOURSELF", FALSE); | 4000 save_yourself_atom = gdk_atom_intern("WM_SAVE_YOURSELF", FALSE); |
4212 #endif | 4001 #endif |
4213 | 4002 |
4214 if (gtk_socket_id != 0) | 4003 if (gtk_socket_id != 0) |
4215 /* make sure keyboard input can go to the drawarea */ | 4004 /* make sure keyboard input can go to the drawarea */ |
4216 #if GTK_CHECK_VERSION(3,0,0) | |
4217 gtk_widget_set_can_focus(gui.drawarea, TRUE); | 4005 gtk_widget_set_can_focus(gui.drawarea, TRUE); |
4218 #else | |
4219 GTK_WIDGET_SET_FLAGS(gui.drawarea, GTK_CAN_FOCUS); | |
4220 #endif | |
4221 | 4006 |
4222 /* | 4007 /* |
4223 * Set clipboard specific atoms | 4008 * Set clipboard specific atoms |
4224 */ | 4009 */ |
4225 vim_atom = gdk_atom_intern(VIM_ATOM_NAME, FALSE); | 4010 vim_atom = gdk_atom_intern(VIM_ATOM_NAME, FALSE); |
4246 * Only install these enter/leave callbacks when 'p' in 'guioptions'. | 4031 * Only install these enter/leave callbacks when 'p' in 'guioptions'. |
4247 * Only needed for some window managers. | 4032 * Only needed for some window managers. |
4248 */ | 4033 */ |
4249 if (vim_strchr(p_go, GO_POINTER) != NULL) | 4034 if (vim_strchr(p_go, GO_POINTER) != NULL) |
4250 { | 4035 { |
4251 #if GTK_CHECK_VERSION(3,0,0) | |
4252 g_signal_connect(G_OBJECT(gui.drawarea), "leave-notify-event", | 4036 g_signal_connect(G_OBJECT(gui.drawarea), "leave-notify-event", |
4253 G_CALLBACK(leave_notify_event), NULL); | 4037 G_CALLBACK(leave_notify_event), NULL); |
4254 g_signal_connect(G_OBJECT(gui.drawarea), "enter-notify-event", | 4038 g_signal_connect(G_OBJECT(gui.drawarea), "enter-notify-event", |
4255 G_CALLBACK(enter_notify_event), NULL); | 4039 G_CALLBACK(enter_notify_event), NULL); |
4256 #else | |
4257 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "leave_notify_event", | |
4258 GTK_SIGNAL_FUNC(leave_notify_event), NULL); | |
4259 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "enter_notify_event", | |
4260 GTK_SIGNAL_FUNC(enter_notify_event), NULL); | |
4261 #endif | |
4262 } | 4040 } |
4263 | 4041 |
4264 /* Real windows can get focus ... GtkPlug, being a mere container can't, | 4042 /* Real windows can get focus ... GtkPlug, being a mere container can't, |
4265 * only its widgets. Arguably, this could be common code and we not use | 4043 * only its widgets. Arguably, this could be common code and we not use |
4266 * the window focus at all, but let's be safe. | 4044 * the window focus at all, but let's be safe. |
4267 */ | 4045 */ |
4268 if (gtk_socket_id == 0) | 4046 if (gtk_socket_id == 0) |
4269 { | 4047 { |
4270 #if GTK_CHECK_VERSION(3,0,0) | |
4271 g_signal_connect(G_OBJECT(gui.mainwin), "focus-out-event", | 4048 g_signal_connect(G_OBJECT(gui.mainwin), "focus-out-event", |
4272 G_CALLBACK(focus_out_event), NULL); | 4049 G_CALLBACK(focus_out_event), NULL); |
4273 g_signal_connect(G_OBJECT(gui.mainwin), "focus-in-event", | 4050 g_signal_connect(G_OBJECT(gui.mainwin), "focus-in-event", |
4274 G_CALLBACK(focus_in_event), NULL); | 4051 G_CALLBACK(focus_in_event), NULL); |
4275 #else | |
4276 gtk_signal_connect(GTK_OBJECT(gui.mainwin), "focus_out_event", | |
4277 GTK_SIGNAL_FUNC(focus_out_event), NULL); | |
4278 gtk_signal_connect(GTK_OBJECT(gui.mainwin), "focus_in_event", | |
4279 GTK_SIGNAL_FUNC(focus_in_event), NULL); | |
4280 #endif | |
4281 } | 4052 } |
4282 else | 4053 else |
4283 { | 4054 { |
4284 #if GTK_CHECK_VERSION(3,0,0) | |
4285 g_signal_connect(G_OBJECT(gui.drawarea), "focus-out-event", | 4055 g_signal_connect(G_OBJECT(gui.drawarea), "focus-out-event", |
4286 G_CALLBACK(focus_out_event), NULL); | 4056 G_CALLBACK(focus_out_event), NULL); |
4287 g_signal_connect(G_OBJECT(gui.drawarea), "focus-in-event", | 4057 g_signal_connect(G_OBJECT(gui.drawarea), "focus-in-event", |
4288 G_CALLBACK(focus_in_event), NULL); | 4058 G_CALLBACK(focus_in_event), NULL); |
4289 #else | |
4290 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "focus_out_event", | |
4291 GTK_SIGNAL_FUNC(focus_out_event), NULL); | |
4292 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "focus_in_event", | |
4293 GTK_SIGNAL_FUNC(focus_in_event), NULL); | |
4294 #endif | |
4295 #ifdef FEAT_GUI_TABLINE | 4059 #ifdef FEAT_GUI_TABLINE |
4296 # if GTK_CHECK_VERSION(3,0,0) | |
4297 g_signal_connect(G_OBJECT(gui.tabline), "focus-out-event", | 4060 g_signal_connect(G_OBJECT(gui.tabline), "focus-out-event", |
4298 G_CALLBACK(focus_out_event), NULL); | 4061 G_CALLBACK(focus_out_event), NULL); |
4299 g_signal_connect(G_OBJECT(gui.tabline), "focus-in-event", | 4062 g_signal_connect(G_OBJECT(gui.tabline), "focus-in-event", |
4300 G_CALLBACK(focus_in_event), NULL); | 4063 G_CALLBACK(focus_in_event), NULL); |
4301 # else | |
4302 gtk_signal_connect(GTK_OBJECT(gui.tabline), "focus_out_event", | |
4303 GTK_SIGNAL_FUNC(focus_out_event), NULL); | |
4304 gtk_signal_connect(GTK_OBJECT(gui.tabline), "focus_in_event", | |
4305 GTK_SIGNAL_FUNC(focus_in_event), NULL); | |
4306 # endif | |
4307 #endif /* FEAT_GUI_TABLINE */ | 4064 #endif /* FEAT_GUI_TABLINE */ |
4308 } | 4065 } |
4309 | 4066 |
4310 #if GTK_CHECK_VERSION(3,0,0) | |
4311 g_signal_connect(G_OBJECT(gui.drawarea), "motion-notify-event", | 4067 g_signal_connect(G_OBJECT(gui.drawarea), "motion-notify-event", |
4312 G_CALLBACK(motion_notify_event), NULL); | 4068 G_CALLBACK(motion_notify_event), NULL); |
4313 g_signal_connect(G_OBJECT(gui.drawarea), "button-press-event", | 4069 g_signal_connect(G_OBJECT(gui.drawarea), "button-press-event", |
4314 G_CALLBACK(button_press_event), NULL); | 4070 G_CALLBACK(button_press_event), NULL); |
4315 g_signal_connect(G_OBJECT(gui.drawarea), "button-release-event", | 4071 g_signal_connect(G_OBJECT(gui.drawarea), "button-release-event", |
4316 G_CALLBACK(button_release_event), NULL); | 4072 G_CALLBACK(button_release_event), NULL); |
4317 g_signal_connect(G_OBJECT(gui.drawarea), "scroll-event", | 4073 g_signal_connect(G_OBJECT(gui.drawarea), "scroll-event", |
4318 G_CALLBACK(&scroll_event), NULL); | 4074 G_CALLBACK(&scroll_event), NULL); |
4319 #else | |
4320 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "motion_notify_event", | |
4321 GTK_SIGNAL_FUNC(motion_notify_event), NULL); | |
4322 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "button_press_event", | |
4323 GTK_SIGNAL_FUNC(button_press_event), NULL); | |
4324 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "button_release_event", | |
4325 GTK_SIGNAL_FUNC(button_release_event), NULL); | |
4326 g_signal_connect(G_OBJECT(gui.drawarea), "scroll_event", | |
4327 G_CALLBACK(&scroll_event), NULL); | |
4328 #endif | |
4329 | 4075 |
4330 /* | 4076 /* |
4331 * Add selection handler functions. | 4077 * Add selection handler functions. |
4332 */ | 4078 */ |
4333 #if GTK_CHECK_VERSION(3,0,0) | |
4334 g_signal_connect(G_OBJECT(gui.drawarea), "selection-clear-event", | 4079 g_signal_connect(G_OBJECT(gui.drawarea), "selection-clear-event", |
4335 G_CALLBACK(selection_clear_event), NULL); | 4080 G_CALLBACK(selection_clear_event), NULL); |
4336 g_signal_connect(G_OBJECT(gui.drawarea), "selection-received", | 4081 g_signal_connect(G_OBJECT(gui.drawarea), "selection-received", |
4337 G_CALLBACK(selection_received_cb), NULL); | 4082 G_CALLBACK(selection_received_cb), NULL); |
4338 #else | |
4339 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_clear_event", | |
4340 GTK_SIGNAL_FUNC(selection_clear_event), NULL); | |
4341 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_received", | |
4342 GTK_SIGNAL_FUNC(selection_received_cb), NULL); | |
4343 #endif | |
4344 | 4083 |
4345 gui_gtk_set_selection_targets(); | 4084 gui_gtk_set_selection_targets(); |
4346 | 4085 |
4347 #if GTK_CHECK_VERSION(3,0,0) | |
4348 g_signal_connect(G_OBJECT(gui.drawarea), "selection-get", | 4086 g_signal_connect(G_OBJECT(gui.drawarea), "selection-get", |
4349 G_CALLBACK(selection_get_cb), NULL); | 4087 G_CALLBACK(selection_get_cb), NULL); |
4350 #else | |
4351 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_get", | |
4352 GTK_SIGNAL_FUNC(selection_get_cb), NULL); | |
4353 #endif | |
4354 | 4088 |
4355 /* Pretend we don't have input focus, we will get an event if we do. */ | 4089 /* Pretend we don't have input focus, we will get an event if we do. */ |
4356 gui.in_focus = FALSE; | 4090 gui.in_focus = FALSE; |
4357 | 4091 |
4358 // Handle changes to the "Xft/DPI" setting. | 4092 // Handle changes to the "Xft/DPI" setting. |
4413 * currently manipulating them where desired. | 4147 * currently manipulating them where desired. |
4414 */ | 4148 */ |
4415 void | 4149 void |
4416 gui_mch_new_colors(void) | 4150 gui_mch_new_colors(void) |
4417 { | 4151 { |
4418 #if GTK_CHECK_VERSION(3,0,0) | |
4419 # if !GTK_CHECK_VERSION(3,22,2) | |
4420 GdkWindow * const da_win = gtk_widget_get_window(gui.drawarea); | |
4421 # endif | |
4422 | |
4423 if (gui.drawarea != NULL && gtk_widget_get_window(gui.drawarea) != NULL) | 4152 if (gui.drawarea != NULL && gtk_widget_get_window(gui.drawarea) != NULL) |
4424 #else | 4153 { |
4425 if (gui.drawarea != NULL && gui.drawarea->window != NULL) | 4154 #if !GTK_CHECK_VERSION(3,22,2) |
4426 #endif | 4155 GdkWindow * const da_win = gtk_widget_get_window(gui.drawarea); |
4427 { | 4156 #endif |
4157 | |
4428 #if GTK_CHECK_VERSION(3,22,2) | 4158 #if GTK_CHECK_VERSION(3,22,2) |
4429 GtkStyleContext * const context | 4159 GtkStyleContext * const context |
4430 = gtk_widget_get_style_context(gui.drawarea); | 4160 = gtk_widget_get_style_context(gui.drawarea); |
4431 GtkCssProvider * const provider = gtk_css_provider_new(); | 4161 GtkCssProvider * const provider = gtk_css_provider_new(); |
4432 gchar * const css = g_strdup_printf( | 4162 gchar * const css = g_strdup_printf( |
4460 } | 4190 } |
4461 #else /* !GTK_CHECK_VERSION(3,4,0) */ | 4191 #else /* !GTK_CHECK_VERSION(3,4,0) */ |
4462 GdkColor color = { 0, 0, 0, 0 }; | 4192 GdkColor color = { 0, 0, 0, 0 }; |
4463 | 4193 |
4464 color.pixel = gui.back_pixel; | 4194 color.pixel = gui.back_pixel; |
4465 # if GTK_CHECK_VERSION(3,0,0) | |
4466 gdk_window_set_background(da_win, &color); | 4195 gdk_window_set_background(da_win, &color); |
4467 # else | |
4468 gdk_window_set_background(gui.drawarea->window, &color); | |
4469 # endif | |
4470 #endif /* !GTK_CHECK_VERSION(3,22,2) */ | 4196 #endif /* !GTK_CHECK_VERSION(3,22,2) */ |
4471 } | 4197 } |
4472 } | 4198 } |
4473 | 4199 |
4474 /* | 4200 /* |
4522 /* | 4248 /* |
4523 * Function called when window already closed. | 4249 * Function called when window already closed. |
4524 * We can't do much more here than to trying to preserve what had been done, | 4250 * We can't do much more here than to trying to preserve what had been done, |
4525 * since the window is already inevitably going away. | 4251 * since the window is already inevitably going away. |
4526 */ | 4252 */ |
4527 #if GTK_CHECK_VERSION(3,0,0) | |
4528 static void | 4253 static void |
4529 mainwin_destroy_cb(GObject *object UNUSED, gpointer data UNUSED) | 4254 mainwin_destroy_cb(GObject *object UNUSED, gpointer data UNUSED) |
4530 #else | |
4531 static void | |
4532 mainwin_destroy_cb(GtkObject *object UNUSED, gpointer data UNUSED) | |
4533 #endif | |
4534 { | 4255 { |
4535 /* Don't write messages to the GUI anymore */ | 4256 /* Don't write messages to the GUI anymore */ |
4536 full_screen = FALSE; | 4257 full_screen = FALSE; |
4537 | 4258 |
4538 gui.mainwin = NULL; | 4259 gui.mainwin = NULL; |
4707 | 4428 |
4708 /* Get the colors for the highlight groups (gui_check_colors() might have | 4429 /* Get the colors for the highlight groups (gui_check_colors() might have |
4709 * changed them). */ | 4430 * changed them). */ |
4710 highlight_gui_started(); /* re-init colors and fonts */ | 4431 highlight_gui_started(); /* re-init colors and fonts */ |
4711 | 4432 |
4712 #if GTK_CHECK_VERSION(3,0,0) | |
4713 g_signal_connect(G_OBJECT(gui.mainwin), "destroy", | 4433 g_signal_connect(G_OBJECT(gui.mainwin), "destroy", |
4714 G_CALLBACK(mainwin_destroy_cb), NULL); | 4434 G_CALLBACK(mainwin_destroy_cb), NULL); |
4715 #else | |
4716 gtk_signal_connect(GTK_OBJECT(gui.mainwin), "destroy", | |
4717 GTK_SIGNAL_FUNC(mainwin_destroy_cb), NULL); | |
4718 #endif | |
4719 | 4435 |
4720 #ifdef FEAT_HANGULIN | 4436 #ifdef FEAT_HANGULIN |
4721 hangul_keyboard_set(); | 4437 hangul_keyboard_set(); |
4722 #endif | 4438 #endif |
4723 | 4439 |
4729 * We connect this signal deferred finally after anything is in place, | 4445 * We connect this signal deferred finally after anything is in place, |
4730 * since this is intended to handle resizements coming from the window | 4446 * since this is intended to handle resizements coming from the window |
4731 * manager upon us and should not interfere with what VIM is requesting | 4447 * manager upon us and should not interfere with what VIM is requesting |
4732 * upon startup. | 4448 * upon startup. |
4733 */ | 4449 */ |
4734 #if GTK_CHECK_VERSION(3,0,0) | |
4735 g_signal_connect(G_OBJECT(gui.formwin), "configure-event", | 4450 g_signal_connect(G_OBJECT(gui.formwin), "configure-event", |
4736 G_CALLBACK(form_configure_event), NULL); | 4451 G_CALLBACK(form_configure_event), NULL); |
4737 #else | |
4738 gtk_signal_connect(GTK_OBJECT(gui.formwin), "configure_event", | |
4739 GTK_SIGNAL_FUNC(form_configure_event), NULL); | |
4740 #endif | |
4741 | 4452 |
4742 #ifdef FEAT_DND | 4453 #ifdef FEAT_DND |
4743 /* Set up for receiving DND items. */ | 4454 /* Set up for receiving DND items. */ |
4744 gui_gtk_set_dnd_targets(); | 4455 gui_gtk_set_dnd_targets(); |
4745 | 4456 |
4746 # if GTK_CHECK_VERSION(3,0,0) | |
4747 g_signal_connect(G_OBJECT(gui.drawarea), "drag-data-received", | 4457 g_signal_connect(G_OBJECT(gui.drawarea), "drag-data-received", |
4748 G_CALLBACK(drag_data_received_cb), NULL); | 4458 G_CALLBACK(drag_data_received_cb), NULL); |
4749 # else | |
4750 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "drag_data_received", | |
4751 GTK_SIGNAL_FUNC(drag_data_received_cb), NULL); | |
4752 # endif | |
4753 #endif | 4459 #endif |
4754 | 4460 |
4755 /* With GTK+ 2, we need to iconify the window before calling show() | 4461 /* With GTK+ 2, we need to iconify the window before calling show() |
4756 * to avoid mapping the window for a short time. */ | 4462 * to avoid mapping the window for a short time. */ |
4757 if (found_iconic_arg && gtk_socket_id == 0) | 4463 if (found_iconic_arg && gtk_socket_id == 0) |
5034 else | 4740 else |
5035 # endif | 4741 # endif |
5036 widget = gui.menubar; | 4742 widget = gui.menubar; |
5037 | 4743 |
5038 /* Do not disable the menu while starting up, otherwise F10 doesn't work. */ | 4744 /* Do not disable the menu while starting up, otherwise F10 doesn't work. */ |
5039 # if GTK_CHECK_VERSION(3,0,0) | |
5040 if (!showit != !gtk_widget_get_visible(widget) && !gui.starting) | 4745 if (!showit != !gtk_widget_get_visible(widget) && !gui.starting) |
5041 # else | |
5042 if (!showit != !GTK_WIDGET_VISIBLE(widget) && !gui.starting) | |
5043 # endif | |
5044 { | 4746 { |
5045 if (showit) | 4747 if (showit) |
5046 gtk_widget_show(widget); | 4748 gtk_widget_show(widget); |
5047 else | 4749 else |
5048 gtk_widget_hide(widget); | 4750 gtk_widget_hide(widget); |
5069 widget = gui.toolbar; | 4771 widget = gui.toolbar; |
5070 | 4772 |
5071 if (showit) | 4773 if (showit) |
5072 set_toolbar_style(GTK_TOOLBAR(gui.toolbar)); | 4774 set_toolbar_style(GTK_TOOLBAR(gui.toolbar)); |
5073 | 4775 |
5074 # if GTK_CHECK_VERSION(3,0,0) | |
5075 if (!showit != !gtk_widget_get_visible(widget)) | 4776 if (!showit != !gtk_widget_get_visible(widget)) |
5076 # else | |
5077 if (!showit != !GTK_WIDGET_VISIBLE(widget)) | |
5078 # endif | |
5079 { | 4777 { |
5080 if (showit) | 4778 if (showit) |
5081 gtk_widget_show(widget); | 4779 gtk_widget_show(widget); |
5082 else | 4780 else |
5083 gtk_widget_hide(widget); | 4781 gtk_widget_hide(widget); |
6334 void | 6032 void |
6335 gui_mch_beep(void) | 6033 gui_mch_beep(void) |
6336 { | 6034 { |
6337 GdkDisplay *display; | 6035 GdkDisplay *display; |
6338 | 6036 |
6339 #if GTK_CHECK_VERSION(3,0,0) | |
6340 if (gui.mainwin != NULL && gtk_widget_get_realized(gui.mainwin)) | 6037 if (gui.mainwin != NULL && gtk_widget_get_realized(gui.mainwin)) |
6341 #else | |
6342 if (gui.mainwin != NULL && GTK_WIDGET_REALIZED(gui.mainwin)) | |
6343 #endif | |
6344 display = gtk_widget_get_display(gui.mainwin); | 6038 display = gtk_widget_get_display(gui.mainwin); |
6345 else | 6039 else |
6346 display = gdk_display_get_default(); | 6040 display = gdk_display_get_default(); |
6347 | 6041 |
6348 if (display != NULL) | 6042 if (display != NULL) |
6698 | 6392 |
6699 /* Flush any output to the screen */ | 6393 /* Flush any output to the screen */ |
6700 void | 6394 void |
6701 gui_mch_flush(void) | 6395 gui_mch_flush(void) |
6702 { | 6396 { |
6703 #if GTK_CHECK_VERSION(3,0,0) | |
6704 if (gui.mainwin != NULL && gtk_widget_get_realized(gui.mainwin)) | 6397 if (gui.mainwin != NULL && gtk_widget_get_realized(gui.mainwin)) |
6705 #else | |
6706 if (gui.mainwin != NULL && GTK_WIDGET_REALIZED(gui.mainwin)) | |
6707 #endif | |
6708 gdk_display_flush(gtk_widget_get_display(gui.mainwin)); | 6398 gdk_display_flush(gtk_widget_get_display(gui.mainwin)); |
6709 } | 6399 } |
6710 | 6400 |
6711 /* | 6401 /* |
6712 * Clear a rectangular region of the screen from text pos (row1, col1) to | 6402 * Clear a rectangular region of the screen from text pos (row1, col1) to |
7058 if (menu_is_separator(menu->name)) | 6748 if (menu_is_separator(menu->name)) |
7059 grey = TRUE; | 6749 grey = TRUE; |
7060 | 6750 |
7061 gui_mch_menu_hidden(menu, FALSE); | 6751 gui_mch_menu_hidden(menu, FALSE); |
7062 /* Be clever about bitfields versus true booleans here! */ | 6752 /* Be clever about bitfields versus true booleans here! */ |
7063 # if GTK_CHECK_VERSION(3,0,0) | |
7064 if (!gtk_widget_get_sensitive(menu->id) == !grey) | 6753 if (!gtk_widget_get_sensitive(menu->id) == !grey) |
7065 # else | |
7066 if (!GTK_WIDGET_SENSITIVE(menu->id) == !grey) | |
7067 # endif | |
7068 { | 6754 { |
7069 gtk_widget_set_sensitive(menu->id, !grey); | 6755 gtk_widget_set_sensitive(menu->id, !grey); |
7070 gui_mch_update(); | 6756 gui_mch_update(); |
7071 } | 6757 } |
7072 } | 6758 } |
7080 if (menu->id == 0) | 6766 if (menu->id == 0) |
7081 return; | 6767 return; |
7082 | 6768 |
7083 if (hidden) | 6769 if (hidden) |
7084 { | 6770 { |
7085 # if GTK_CHECK_VERSION(3,0,0) | |
7086 if (gtk_widget_get_visible(menu->id)) | 6771 if (gtk_widget_get_visible(menu->id)) |
7087 # else | |
7088 if (GTK_WIDGET_VISIBLE(menu->id)) | |
7089 # endif | |
7090 { | 6772 { |
7091 gtk_widget_hide(menu->id); | 6773 gtk_widget_hide(menu->id); |
7092 gui_mch_update(); | 6774 gui_mch_update(); |
7093 } | 6775 } |
7094 } | 6776 } |
7095 else | 6777 else |
7096 { | 6778 { |
7097 # if GTK_CHECK_VERSION(3,0,0) | |
7098 if (!gtk_widget_get_visible(menu->id)) | 6779 if (!gtk_widget_get_visible(menu->id)) |
7099 # else | |
7100 if (!GTK_WIDGET_VISIBLE(menu->id)) | |
7101 # endif | |
7102 { | 6780 { |
7103 gtk_widget_show(menu->id); | 6781 gtk_widget_show(menu->id); |
7104 gui_mch_update(); | 6782 gui_mch_update(); |
7105 } | 6783 } |
7106 } | 6784 } |
7124 gui_mch_enable_scrollbar(scrollbar_T *sb, int flag) | 6802 gui_mch_enable_scrollbar(scrollbar_T *sb, int flag) |
7125 { | 6803 { |
7126 if (sb->id == NULL) | 6804 if (sb->id == NULL) |
7127 return; | 6805 return; |
7128 | 6806 |
7129 #if GTK_CHECK_VERSION(3,0,0) | |
7130 gtk_widget_set_visible(sb->id, flag); | 6807 gtk_widget_set_visible(sb->id, flag); |
7131 #else | |
7132 if (flag) | |
7133 gtk_widget_show(sb->id); | |
7134 else | |
7135 gtk_widget_hide(sb->id); | |
7136 #endif | |
7137 | |
7138 update_window_manager_hints(0, 0); | 6808 update_window_manager_hints(0, 0); |
7139 } | 6809 } |
7140 | 6810 |
7141 | 6811 |
7142 /* | 6812 /* |
7164 * Get current mouse coordinates in text window. | 6834 * Get current mouse coordinates in text window. |
7165 */ | 6835 */ |
7166 void | 6836 void |
7167 gui_mch_getmouse(int *x, int *y) | 6837 gui_mch_getmouse(int *x, int *y) |
7168 { | 6838 { |
7169 #if GTK_CHECK_VERSION(3,0,0) | |
7170 gui_gtk_get_pointer(gui.drawarea, x, y, NULL); | 6839 gui_gtk_get_pointer(gui.drawarea, x, y, NULL); |
7171 #else | |
7172 gdk_window_get_pointer(gui.drawarea->window, x, y, NULL); | |
7173 #endif | |
7174 } | 6840 } |
7175 | 6841 |
7176 void | 6842 void |
7177 gui_mch_setmouse(int x, int y) | 6843 gui_mch_setmouse(int x, int y) |
7178 { | 6844 { |