Mercurial > vim
comparison src/gui_gtk.c @ 8218:3456e2ebebd4 v7.4.1402
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 23 17:14:37 2016 +0100
patch 7.4.1402
Problem: GTK 3 is not supported.
Solution: Add GTK 3 support. (Kazunobu Kuriyama)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 23 Feb 2016 17:15:05 +0100 |
parents | 81794242a275 |
children | 738c2929d6ad |
comparison
equal
deleted
inserted
replaced
8217:c52abf35df88 | 8218:3456e2ebebd4 |
---|---|
20 * (C) 2002,2003 Jason Hildebrand <jason@peaceworks.ca> | 20 * (C) 2002,2003 Jason Hildebrand <jason@peaceworks.ca> |
21 * Daniel Elstner <daniel.elstner@gmx.net> | 21 * Daniel Elstner <daniel.elstner@gmx.net> |
22 * | 22 * |
23 * Best supporting actor (He helped somewhat, aesthetically speaking): | 23 * Best supporting actor (He helped somewhat, aesthetically speaking): |
24 * Maxime Romano <verbophobe@hotmail.com> | 24 * Maxime Romano <verbophobe@hotmail.com> |
25 * | |
26 * Support for GTK+ 3 was added by: | |
27 * | |
28 * 2016 Kazunobu Kuriyama <kazunobu.kuriyama@gmail.com> | |
29 * | |
30 * With the help of Marius Gedminas and the word of Bram Moolenaar, | |
31 * "Let's give this some time to mature." | |
25 */ | 32 */ |
33 | |
34 #include "vim.h" | |
26 | 35 |
27 #ifdef FEAT_GUI_GTK | 36 #ifdef FEAT_GUI_GTK |
28 # include "gui_gtk_f.h" | 37 # include "gui_gtk_f.h" |
29 #endif | 38 #endif |
30 | 39 |
34 # undef MIN | 43 # undef MIN |
35 #endif | 44 #endif |
36 #ifdef MAX | 45 #ifdef MAX |
37 # undef MAX | 46 # undef MAX |
38 #endif | 47 #endif |
39 | |
40 #include "vim.h" | |
41 | 48 |
42 #ifdef FEAT_GUI_GNOME | 49 #ifdef FEAT_GUI_GNOME |
43 /* Gnome redefines _() and N_(). Grrr... */ | 50 /* Gnome redefines _() and N_(). Grrr... */ |
44 # ifdef _ | 51 # ifdef _ |
45 # undef _ | 52 # undef _ |
61 # endif | 68 # endif |
62 # include <gnome.h> | 69 # include <gnome.h> |
63 #endif | 70 #endif |
64 | 71 |
65 #ifdef FEAT_GUI_GTK | 72 #ifdef FEAT_GUI_GTK |
66 # include <gdk/gdkkeysyms.h> | 73 # if GTK_CHECK_VERSION(3,0,0) |
74 # include <gdk/gdkkeysyms-compat.h> | |
75 # else | |
76 # include <gdk/gdkkeysyms.h> | |
77 # endif | |
67 # include <gdk/gdk.h> | 78 # include <gdk/gdk.h> |
68 # ifdef WIN3264 | 79 # ifdef WIN3264 |
69 # include <gdk/gdkwin32.h> | 80 # include <gdk/gdkwin32.h> |
70 # else | 81 # else |
71 # include <gdk/gdkx.h> | 82 # include <gdk/gdkx.h> |
102 /* | 113 /* |
103 * Table from BuiltIn## icon indices to GTK+ stock IDs. Order must exactly | 114 * Table from BuiltIn## icon indices to GTK+ stock IDs. Order must exactly |
104 * match toolbar_names[] in menu.c! All stock icons including the "vim-*" | 115 * match toolbar_names[] in menu.c! All stock icons including the "vim-*" |
105 * ones can be overridden in your gtkrc file. | 116 * ones can be overridden in your gtkrc file. |
106 */ | 117 */ |
118 # if GTK_CHECK_VERSION(3,10,0) | |
119 static const char * const menu_themed_names[] = | |
120 { | |
121 /* 00 */ "document-new", /* sub. GTK_STOCK_NEW */ | |
122 /* 01 */ "document-open", /* sub. GTK_STOCK_OPEN */ | |
123 /* 02 */ "document-save", /* sub. GTK_STOCK_SAVE */ | |
124 /* 03 */ "edit-undo", /* sub. GTK_STOCK_UNDO */ | |
125 /* 04 */ "edit-redo", /* sub. GTK_STOCK_REDO */ | |
126 /* 05 */ "edit-cut", /* sub. GTK_STOCK_CUT */ | |
127 /* 06 */ "edit-copy", /* sub. GTK_STOCK_COPY */ | |
128 /* 07 */ "edit-paste", /* sub. GTK_STOCK_PASTE */ | |
129 /* 08 */ "document-print", /* sub. GTK_STOCK_PRINT */ | |
130 /* 09 */ "help-browser", /* sub. GTK_STOCK_HELP */ | |
131 /* 10 */ "edit-find", /* sub. GTK_STOCK_FIND */ | |
132 # if GTK_CHECK_VERSION(3,14,0) | |
133 /* Use the file names in gui_gtk_res.xml, cutting off the extension. | |
134 * Similar changes follow. */ | |
135 /* 11 */ "stock_vim_save_all", | |
136 /* 12 */ "stock_vim_session_save", | |
137 /* 13 */ "stock_vim_session_new", | |
138 /* 14 */ "stock_vim_session_load", | |
139 # else | |
140 /* 11 */ "vim-save-all", | |
141 /* 12 */ "vim-session-save", | |
142 /* 13 */ "vim-session-new", | |
143 /* 14 */ "vim-session-load", | |
144 # endif | |
145 /* 15 */ "system-run", /* sub. GTK_STOCK_EXECUTE */ | |
146 /* 16 */ "edit-find-replace", /* sub. GTK_STOCK_FIND_AND_REPLACE */ | |
147 /* 17 */ "window-close", /* sub. GTK_STOCK_CLOSE, FIXME: fuzzy */ | |
148 # if GTK_CHECK_VERSION(3,14,0) | |
149 /* 18 */ "stock_vim_window_maximize", | |
150 /* 19 */ "stock_vim_window_minimize", | |
151 /* 20 */ "stock_vim_window_split", | |
152 /* 21 */ "stock_vim_shell", | |
153 # else | |
154 /* 18 */ "vim-window-maximize", | |
155 /* 19 */ "vim-window-minimize", | |
156 /* 20 */ "vim-window-split", | |
157 /* 21 */ "vim-shell", | |
158 # endif | |
159 /* 22 */ "go-previous", /* sub. GTK_STOCK_GO_BACK */ | |
160 /* 23 */ "go-next", /* sub. GTK_STOCK_GO_FORWARD */ | |
161 # if GTK_CHECK_VERSION(3,14,0) | |
162 /* 24 */ "stock_vim_find_help", | |
163 # else | |
164 /* 24 */ "vim-find-help", | |
165 # endif | |
166 /* 25 */ "gtk-convert", /* sub. GTK_STOCK_CONVERT */ | |
167 /* 26 */ "go-jump", /* sub. GTK_STOCK_JUMP_TO */ | |
168 # if GTK_CHECK_VERSION(3,14,0) | |
169 /* 27 */ "stock_vim_build_tags", | |
170 /* 28 */ "stock_vim_window_split_vertical", | |
171 /* 29 */ "stock_vim_window_maximize_width", | |
172 /* 30 */ "stock_vim_window_minimize_width", | |
173 # else | |
174 /* 27 */ "vim-build-tags", | |
175 /* 28 */ "vim-window-split-vertical", | |
176 /* 29 */ "vim-window-maximize-width", | |
177 /* 30 */ "vim-window-minimize-width", | |
178 # endif | |
179 /* 31 */ "application-exit", /* GTK_STOCK_QUIT */ | |
180 }; | |
181 # else /* !GTK_CHECK_VERSION(3,10,0) */ | |
107 static const char * const menu_stock_ids[] = | 182 static const char * const menu_stock_ids[] = |
108 { | 183 { |
109 /* 00 */ GTK_STOCK_NEW, | 184 /* 00 */ GTK_STOCK_NEW, |
110 /* 01 */ GTK_STOCK_OPEN, | 185 /* 01 */ GTK_STOCK_OPEN, |
111 /* 02 */ GTK_STOCK_SAVE, | 186 /* 02 */ GTK_STOCK_SAVE, |
137 /* 28 */ "vim-window-split-vertical", | 212 /* 28 */ "vim-window-split-vertical", |
138 /* 29 */ "vim-window-maximize-width", | 213 /* 29 */ "vim-window-maximize-width", |
139 /* 30 */ "vim-window-minimize-width", | 214 /* 30 */ "vim-window-minimize-width", |
140 /* 31 */ GTK_STOCK_QUIT | 215 /* 31 */ GTK_STOCK_QUIT |
141 }; | 216 }; |
142 | 217 # endif /* !GTK_CHECK_VERSION(3,10,0) */ |
143 #ifdef USE_GRESOURCE | 218 |
219 # ifdef USE_GRESOURCE | |
220 # if !GTK_CHECK_VERSION(3,10,0) | |
144 typedef struct IconNames { | 221 typedef struct IconNames { |
145 const char *icon_name; | 222 const char *icon_name; |
146 const char *file_name; | 223 const char *file_name; |
147 } IconNames; | 224 } IconNames; |
148 | 225 |
160 { "vim-window-minimize-width", "stock_vim_window_minimize_width.png" }, | 237 { "vim-window-minimize-width", "stock_vim_window_minimize_width.png" }, |
161 { "vim-window-split", "stock_vim_window_split.png" }, | 238 { "vim-window-split", "stock_vim_window_split.png" }, |
162 { "vim-window-split-vertical", "stock_vim_window_split_vertical.png" }, | 239 { "vim-window-split-vertical", "stock_vim_window_split_vertical.png" }, |
163 { NULL, NULL } | 240 { NULL, NULL } |
164 }; | 241 }; |
165 #endif | 242 # endif |
166 | 243 # endif /* USE_G_RESOURCE */ |
167 #ifndef USE_GRESOURCE | 244 |
245 # ifndef USE_GRESOURCE | |
168 static void | 246 static void |
169 add_stock_icon(GtkIconFactory *factory, | 247 add_stock_icon(GtkIconFactory *factory, |
170 const char *stock_id, | 248 const char *stock_id, |
171 const guint8 *inline_data, | 249 const guint8 *inline_data, |
172 int data_length) | 250 int data_length) |
180 gtk_icon_factory_add(factory, stock_id, icon_set); | 258 gtk_icon_factory_add(factory, stock_id, icon_set); |
181 | 259 |
182 gtk_icon_set_unref(icon_set); | 260 gtk_icon_set_unref(icon_set); |
183 g_object_unref(pixbuf); | 261 g_object_unref(pixbuf); |
184 } | 262 } |
185 #endif | 263 # endif |
186 | 264 |
187 static int | 265 static int |
188 lookup_menu_iconfile(char_u *iconfile, char_u *dest) | 266 lookup_menu_iconfile(char_u *iconfile, char_u *dest) |
189 { | 267 { |
190 expand_env(iconfile, dest, MAXPATHL); | 268 expand_env(iconfile, dest, MAXPATHL); |
212 | 290 |
213 static GtkWidget * | 291 static GtkWidget * |
214 load_menu_iconfile(char_u *name, GtkIconSize icon_size) | 292 load_menu_iconfile(char_u *name, GtkIconSize icon_size) |
215 { | 293 { |
216 GtkWidget *image = NULL; | 294 GtkWidget *image = NULL; |
295 # if GTK_CHECK_VERSION(3,10,0) | |
296 int pixel_size = -1; | |
297 | |
298 switch (icon_size) | |
299 { | |
300 case GTK_ICON_SIZE_MENU: | |
301 pixel_size = 16; | |
302 break; | |
303 case GTK_ICON_SIZE_SMALL_TOOLBAR: | |
304 pixel_size = 16; | |
305 break; | |
306 case GTK_ICON_SIZE_LARGE_TOOLBAR: | |
307 pixel_size = 24; | |
308 break; | |
309 case GTK_ICON_SIZE_BUTTON: | |
310 pixel_size = 16; | |
311 break; | |
312 case GTK_ICON_SIZE_DND: | |
313 pixel_size = 32; | |
314 break; | |
315 case GTK_ICON_SIZE_DIALOG: | |
316 pixel_size = 48; | |
317 break; | |
318 case GTK_ICON_SIZE_INVALID: | |
319 /* FALLTHROUGH */ | |
320 default: | |
321 pixel_size = 0; | |
322 break; | |
323 } | |
324 | |
325 if (pixel_size > 0 || pixel_size == -1) | |
326 { | |
327 GdkPixbuf * const pixbuf | |
328 = gdk_pixbuf_new_from_file_at_scale((const char *)name, | |
329 pixel_size, pixel_size, TRUE, NULL); | |
330 if (pixbuf != NULL) | |
331 { | |
332 image = gtk_image_new_from_pixbuf(pixbuf); | |
333 g_object_unref(pixbuf); | |
334 } | |
335 } | |
336 if (image == NULL) | |
337 image = gtk_image_new_from_icon_name("image-missing", icon_size); | |
338 | |
339 return image; | |
340 # else /* !GTK_CHECK_VERSION(3,10,0) */ | |
217 GtkIconSet *icon_set; | 341 GtkIconSet *icon_set; |
218 GtkIconSource *icon_source; | 342 GtkIconSource *icon_source; |
219 | 343 |
220 /* | 344 /* |
221 * Rather than loading the icon directly into a GtkImage, create | 345 * Rather than loading the icon directly into a GtkImage, create |
232 | 356 |
233 gtk_icon_source_free(icon_source); | 357 gtk_icon_source_free(icon_source); |
234 gtk_icon_set_unref(icon_set); | 358 gtk_icon_set_unref(icon_set); |
235 | 359 |
236 return image; | 360 return image; |
361 # endif /* !GTK_CHECK_VERSION(3,10,0) */ | |
237 } | 362 } |
238 | 363 |
239 static GtkWidget * | 364 static GtkWidget * |
240 create_menu_icon(vimmenu_T *menu, GtkIconSize icon_size) | 365 create_menu_icon(vimmenu_T *menu, GtkIconSize icon_size) |
241 { | 366 { |
252 image = load_menu_iconfile(buf, icon_size); | 377 image = load_menu_iconfile(buf, icon_size); |
253 | 378 |
254 /* Still not found? Then use a builtin icon, a blank one as fallback. */ | 379 /* Still not found? Then use a builtin icon, a blank one as fallback. */ |
255 if (image == NULL) | 380 if (image == NULL) |
256 { | 381 { |
382 # if GTK_CHECK_VERSION(3,10,0) | |
383 const char *icon_name = NULL; | |
384 const int n_names = G_N_ELEMENTS(menu_themed_names); | |
385 | |
386 if (menu->iconidx >= 0 && menu->iconidx < n_names) | |
387 icon_name = menu_themed_names[menu->iconidx]; | |
388 if (icon_name == NULL) | |
389 icon_name = "image-missing"; | |
390 | |
391 image = gtk_image_new_from_icon_name(icon_name, icon_size); | |
392 # else | |
257 const char *stock_id; | 393 const char *stock_id; |
258 const int n_ids = G_N_ELEMENTS(menu_stock_ids); | 394 const int n_ids = G_N_ELEMENTS(menu_stock_ids); |
259 | 395 |
260 if (menu->iconidx >= 0 && menu->iconidx < n_ids) | 396 if (menu->iconidx >= 0 && menu->iconidx < n_ids) |
261 stock_id = menu_stock_ids[menu->iconidx]; | 397 stock_id = menu_stock_ids[menu->iconidx]; |
262 else | 398 else |
263 stock_id = GTK_STOCK_MISSING_IMAGE; | 399 stock_id = GTK_STOCK_MISSING_IMAGE; |
264 | 400 |
265 image = gtk_image_new_from_stock(stock_id, icon_size); | 401 image = gtk_image_new_from_stock(stock_id, icon_size); |
402 # endif | |
266 } | 403 } |
267 | 404 |
268 return image; | 405 return image; |
269 } | 406 } |
270 | 407 |
286 #if defined(FEAT_TOOLBAR) || defined(PROTO) | 423 #if defined(FEAT_TOOLBAR) || defined(PROTO) |
287 | 424 |
288 void | 425 void |
289 gui_gtk_register_stock_icons(void) | 426 gui_gtk_register_stock_icons(void) |
290 { | 427 { |
291 #ifndef USE_GRESOURCE | 428 # ifndef USE_GRESOURCE |
292 # include "../pixmaps/stock_icons.h" | 429 # include "../pixmaps/stock_icons.h" |
293 GtkIconFactory *factory; | 430 GtkIconFactory *factory; |
294 | 431 |
295 factory = gtk_icon_factory_new(); | 432 factory = gtk_icon_factory_new(); |
296 # define ADD_ICON(Name, Data) add_stock_icon(factory, Name, Data, (int)sizeof(Data)) | 433 # define ADD_ICON(Name, Data) add_stock_icon(factory, Name, Data, (int)sizeof(Data)) |
297 | 434 |
298 ADD_ICON("vim-build-tags", stock_vim_build_tags); | 435 ADD_ICON("vim-build-tags", stock_vim_build_tags); |
299 ADD_ICON("vim-find-help", stock_vim_find_help); | 436 ADD_ICON("vim-find-help", stock_vim_find_help); |
300 ADD_ICON("vim-save-all", stock_vim_save_all); | 437 ADD_ICON("vim-save-all", stock_vim_save_all); |
301 ADD_ICON("vim-session-load", stock_vim_session_load); | 438 ADD_ICON("vim-session-load", stock_vim_session_load); |
307 ADD_ICON("vim-window-minimize", stock_vim_window_minimize); | 444 ADD_ICON("vim-window-minimize", stock_vim_window_minimize); |
308 ADD_ICON("vim-window-minimize-width", stock_vim_window_minimize_width); | 445 ADD_ICON("vim-window-minimize-width", stock_vim_window_minimize_width); |
309 ADD_ICON("vim-window-split", stock_vim_window_split); | 446 ADD_ICON("vim-window-split", stock_vim_window_split); |
310 ADD_ICON("vim-window-split-vertical", stock_vim_window_split_vertical); | 447 ADD_ICON("vim-window-split-vertical", stock_vim_window_split_vertical); |
311 | 448 |
312 # undef ADD_ICON | 449 # undef ADD_ICON |
313 #else | 450 |
314 GtkIconFactory * const factory = gtk_icon_factory_new(); | |
315 const char * const path_prefix = "/org/vim/gui/icon"; | |
316 IconNames *names; | |
317 | |
318 for (names = stock_vim_icons; names->icon_name != NULL; names++) | |
319 { | |
320 char path[MAXPATHL]; | |
321 GdkPixbuf *pixbuf; | |
322 | |
323 vim_snprintf(path, MAXPATHL, "%s/%s", path_prefix, names->file_name); | |
324 pixbuf = gdk_pixbuf_new_from_resource(path, NULL); | |
325 if (pixbuf != NULL) | |
326 { | |
327 GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf(pixbuf); | |
328 gtk_icon_factory_add(factory, names->icon_name, icon_set); | |
329 gtk_icon_set_unref(icon_set); | |
330 g_object_unref(pixbuf); | |
331 } | |
332 } | |
333 #endif | |
334 gtk_icon_factory_add_default(factory); | 451 gtk_icon_factory_add_default(factory); |
335 g_object_unref(factory); | 452 g_object_unref(factory); |
453 # else /* defined(USE_GRESOURCE) */ | |
454 const char * const path_prefix = "/org/vim/gui/icon"; | |
455 # if GTK_CHECK_VERSION(3,14,0) | |
456 GdkScreen *screen = NULL; | |
457 GtkIconTheme *icon_theme = NULL; | |
458 | |
459 if (GTK_IS_WIDGET(gui.mainwin)) | |
460 screen = gtk_widget_get_screen(gui.mainwin); | |
461 else | |
462 screen = gdk_screen_get_default(); | |
463 icon_theme = gtk_icon_theme_get_for_screen(screen); | |
464 gtk_icon_theme_add_resource_path(icon_theme, path_prefix); | |
465 # elif GTK_CHECK_VERSION(3,0,0) | |
466 IconNames *names; | |
467 | |
468 for (names = stock_vim_icons; names->icon_name != NULL; names++) | |
469 { | |
470 char path[MAXPATHL]; | |
471 | |
472 vim_snprintf(path, MAXPATHL, "%s/%s", path_prefix, names->file_name); | |
473 GdkPixbuf *pixbuf = NULL; | |
474 pixbuf = gdk_pixbuf_new_from_resource(path, NULL); | |
475 if (pixbuf != NULL) | |
476 { | |
477 const gint size = MAX(gdk_pixbuf_get_width(pixbuf), | |
478 gdk_pixbuf_get_height(pixbuf)); | |
479 if (size > 16) | |
480 { | |
481 /* An icon theme is supposed to provide fixed-size | |
482 * image files for each size, e.g., 16, 22, 24, ... | |
483 * Naturally, in contrast to GtkIconSet, GtkIconTheme | |
484 * won't prepare size variants for us out of a single | |
485 * fixed-size image. | |
486 * | |
487 * Currently, Vim provides 24x24 images only while the | |
488 * icon size on the menu and the toolbar is set to 16x16 | |
489 * by default. | |
490 * | |
491 * Resize them by ourselves until we have our own fully | |
492 * fledged icon theme. */ | |
493 GdkPixbuf *src = pixbuf; | |
494 pixbuf = gdk_pixbuf_scale_simple(src, | |
495 16, 16, | |
496 GDK_INTERP_BILINEAR); | |
497 if (pixbuf == NULL) | |
498 pixbuf = src; | |
499 else | |
500 g_object_unref(src); | |
501 } | |
502 gtk_icon_theme_add_builtin_icon(names->icon_name, size, pixbuf); | |
503 g_object_unref(pixbuf); | |
504 } | |
505 } | |
506 # else /* !GTK_CHECK_VERSION(3,0.0) */ | |
507 GtkIconFactory * const factory = gtk_icon_factory_new(); | |
508 IconNames *names; | |
509 | |
510 for (names = stock_vim_icons; names->icon_name != NULL; names++) | |
511 { | |
512 char path[MAXPATHL]; | |
513 GdkPixbuf *pixbuf; | |
514 | |
515 vim_snprintf(path, MAXPATHL, "%s/%s", path_prefix, names->file_name); | |
516 pixbuf = gdk_pixbuf_new_from_resource(path, NULL); | |
517 if (pixbuf != NULL) | |
518 { | |
519 GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf(pixbuf); | |
520 gtk_icon_factory_add(factory, names->icon_name, icon_set); | |
521 gtk_icon_set_unref(icon_set); | |
522 g_object_unref(pixbuf); | |
523 } | |
524 } | |
525 | |
526 gtk_icon_factory_add_default(factory); | |
527 g_object_unref(factory); | |
528 # endif /* !GTK_CHECK_VERSION(3,0,0) */ | |
529 # endif /* defined(USE_GRESOURCE) */ | |
336 } | 530 } |
337 | 531 |
338 #endif /* FEAT_TOOLBAR */ | 532 #endif /* FEAT_TOOLBAR */ |
339 | |
340 | 533 |
341 #if defined(FEAT_MENU) || defined(PROTO) | 534 #if defined(FEAT_MENU) || defined(PROTO) |
342 | 535 |
343 /* | 536 /* |
344 * Translate Vim's mnemonic tagging to GTK+ style and convert to UTF-8 | 537 * Translate Vim's mnemonic tagging to GTK+ style and convert to UTF-8 |
406 | 599 |
407 /* It would be neat to have image menu items, but that would require major | 600 /* It would be neat to have image menu items, but that would require major |
408 * changes to Vim's menu system. Not to mention that all the translations | 601 * changes to Vim's menu system. Not to mention that all the translations |
409 * had to be updated. */ | 602 * had to be updated. */ |
410 menu->id = gtk_menu_item_new(); | 603 menu->id = gtk_menu_item_new(); |
604 # if GTK_CHECK_VERSION(3,2,0) | |
605 box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 20); | |
606 gtk_box_set_homogeneous(GTK_BOX(box), FALSE); | |
607 # else | |
411 box = gtk_hbox_new(FALSE, 20); | 608 box = gtk_hbox_new(FALSE, 20); |
609 # endif | |
412 | 610 |
413 use_mnemonic = (p_wak[0] != 'n' || !GTK_IS_MENU_BAR(parent_widget)); | 611 use_mnemonic = (p_wak[0] != 'n' || !GTK_IS_MENU_BAR(parent_widget)); |
414 text = translate_mnemonic_tag(menu->name, use_mnemonic); | 612 text = translate_mnemonic_tag(menu->name, use_mnemonic); |
415 | 613 |
416 menu->label = gtk_label_new_with_mnemonic((const char *)text); | 614 menu->label = gtk_label_new_with_mnemonic((const char *)text); |
463 menu->submenu_id = gtk_menu_new(); | 661 menu->submenu_id = gtk_menu_new(); |
464 | 662 |
465 gtk_menu_set_accel_group(GTK_MENU(menu->submenu_id), gui.accel_group); | 663 gtk_menu_set_accel_group(GTK_MENU(menu->submenu_id), gui.accel_group); |
466 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu->id), menu->submenu_id); | 664 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu->id), menu->submenu_id); |
467 | 665 |
666 # if !GTK_CHECK_VERSION(3,4,0) | |
468 menu->tearoff_handle = gtk_tearoff_menu_item_new(); | 667 menu->tearoff_handle = gtk_tearoff_menu_item_new(); |
469 if (vim_strchr(p_go, GO_TEAROFF) != NULL) | 668 if (vim_strchr(p_go, GO_TEAROFF) != NULL) |
470 gtk_widget_show(menu->tearoff_handle); | 669 gtk_widget_show(menu->tearoff_handle); |
670 # if GTK_CHECK_VERSION(3,0,0) | |
671 gtk_menu_shell_prepend(GTK_MENU_SHELL(menu->submenu_id), | |
672 menu->tearoff_handle); | |
673 # else | |
471 gtk_menu_prepend(GTK_MENU(menu->submenu_id), menu->tearoff_handle); | 674 gtk_menu_prepend(GTK_MENU(menu->submenu_id), menu->tearoff_handle); |
675 # endif | |
676 # endif | |
472 } | 677 } |
473 | 678 |
474 static void | 679 static void |
475 menu_item_activate(GtkWidget *widget UNUSED, gpointer data) | 680 menu_item_activate(GtkWidget *widget UNUSED, gpointer data) |
476 { | 681 { |
492 toolbar = GTK_TOOLBAR(gui.toolbar); | 697 toolbar = GTK_TOOLBAR(gui.toolbar); |
493 menu->submenu_id = NULL; | 698 menu->submenu_id = NULL; |
494 | 699 |
495 if (menu_is_separator(menu->name)) | 700 if (menu_is_separator(menu->name)) |
496 { | 701 { |
702 # if GTK_CHECK_VERSION(3,0,0) | |
703 GtkToolItem *item = gtk_separator_tool_item_new(); | |
704 gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(item), | |
705 TRUE); | |
706 gtk_tool_item_set_expand(GTK_TOOL_ITEM(item), FALSE); | |
707 gtk_widget_show(GTK_WIDGET(item)); | |
708 | |
709 gtk_toolbar_insert(toolbar, item, idx); | |
710 # else | |
497 gtk_toolbar_insert_space(toolbar, idx); | 711 gtk_toolbar_insert_space(toolbar, idx); |
712 # endif | |
498 menu->id = NULL; | 713 menu->id = NULL; |
499 } | 714 } |
500 else | 715 else |
501 { | 716 { |
502 char_u *text; | 717 char_u *text; |
507 if (tooltip != NULL && !utf_valid_string(tooltip, NULL)) | 722 if (tooltip != NULL && !utf_valid_string(tooltip, NULL)) |
508 /* Invalid text, can happen when 'encoding' is changed. Avoid | 723 /* Invalid text, can happen when 'encoding' is changed. Avoid |
509 * a nasty GTK error message, skip the tooltip. */ | 724 * a nasty GTK error message, skip the tooltip. */ |
510 CONVERT_TO_UTF8_FREE(tooltip); | 725 CONVERT_TO_UTF8_FREE(tooltip); |
511 | 726 |
727 # if GTK_CHECK_VERSION(3,0,0) | |
728 { | |
729 GtkWidget *icon; | |
730 GtkToolItem *item; | |
731 | |
732 icon = create_menu_icon(menu, | |
733 gtk_toolbar_get_icon_size(toolbar)); | |
734 item = gtk_tool_button_new(icon, (const gchar *)text); | |
735 gtk_tool_item_set_tooltip_text(item, (const gchar *)tooltip); | |
736 g_signal_connect(G_OBJECT(item), "clicked", | |
737 G_CALLBACK(&menu_item_activate), menu); | |
738 gtk_widget_show_all(GTK_WIDGET(item)); | |
739 | |
740 gtk_toolbar_insert(toolbar, item, idx); | |
741 | |
742 menu->id = GTK_WIDGET(item); | |
743 } | |
744 # else | |
512 menu->id = gtk_toolbar_insert_item( | 745 menu->id = gtk_toolbar_insert_item( |
513 toolbar, | 746 toolbar, |
514 (const char *)text, | 747 (const char *)text, |
515 (const char *)tooltip, | 748 (const char *)tooltip, |
516 NULL, | 749 NULL, |
517 create_menu_icon(menu, gtk_toolbar_get_icon_size(toolbar)), | 750 create_menu_icon(menu, gtk_toolbar_get_icon_size(toolbar)), |
518 G_CALLBACK(&menu_item_activate), | 751 G_CALLBACK(&menu_item_activate), |
519 menu, | 752 menu, |
520 idx); | 753 idx); |
754 # endif | |
521 | 755 |
522 if (gtk_socket_id != 0) | 756 if (gtk_socket_id != 0) |
757 # if GTK_CHECK_VERSION(3,0,0) | |
758 g_signal_connect(G_OBJECT(menu->id), "focus-in-event", | |
759 G_CALLBACK(toolbar_button_focus_in_event), NULL); | |
760 # else | |
523 gtk_signal_connect(GTK_OBJECT(menu->id), "focus_in_event", | 761 gtk_signal_connect(GTK_OBJECT(menu->id), "focus_in_event", |
524 GTK_SIGNAL_FUNC(toolbar_button_focus_in_event), NULL); | 762 GTK_SIGNAL_FUNC(toolbar_button_focus_in_event), NULL); |
763 # endif | |
525 | 764 |
526 CONVERT_TO_UTF8_FREE(text); | 765 CONVERT_TO_UTF8_FREE(text); |
527 CONVERT_TO_UTF8_FREE(tooltip); | 766 CONVERT_TO_UTF8_FREE(tooltip); |
528 } | 767 } |
529 } | 768 } |
543 { | 782 { |
544 /* Separator: Just add it */ | 783 /* Separator: Just add it */ |
545 menu->id = gtk_menu_item_new(); | 784 menu->id = gtk_menu_item_new(); |
546 gtk_widget_set_sensitive(menu->id, FALSE); | 785 gtk_widget_set_sensitive(menu->id, FALSE); |
547 gtk_widget_show(menu->id); | 786 gtk_widget_show(menu->id); |
787 # if GTK_CHECK_VERSION(3,0,0) | |
788 gtk_menu_shell_insert(GTK_MENU_SHELL(parent->submenu_id), | |
789 menu->id, idx); | |
790 # else | |
548 gtk_menu_insert(GTK_MENU(parent->submenu_id), menu->id, idx); | 791 gtk_menu_insert(GTK_MENU(parent->submenu_id), menu->id, idx); |
792 # endif | |
549 | 793 |
550 return; | 794 return; |
551 } | 795 } |
552 | 796 |
553 /* Add textual menu item. */ | 797 /* Add textual menu item. */ |
554 menu_item_new(menu, parent->submenu_id); | 798 menu_item_new(menu, parent->submenu_id); |
555 gtk_widget_show(menu->id); | 799 gtk_widget_show(menu->id); |
800 # if GTK_CHECK_VERSION(3,0,0) | |
801 gtk_menu_shell_insert(GTK_MENU_SHELL(parent->submenu_id), | |
802 menu->id, idx); | |
803 # else | |
556 gtk_menu_insert(GTK_MENU(parent->submenu_id), menu->id, idx); | 804 gtk_menu_insert(GTK_MENU(parent->submenu_id), menu->id, idx); |
805 # endif | |
557 | 806 |
558 if (menu->id != NULL) | 807 if (menu->id != NULL) |
808 # if GTK_CHECK_VERSION(3,0,0) | |
809 g_signal_connect(G_OBJECT(menu->id), "activate", | |
810 G_CALLBACK(menu_item_activate), menu); | |
811 # else | |
559 gtk_signal_connect(GTK_OBJECT(menu->id), "activate", | 812 gtk_signal_connect(GTK_OBJECT(menu->id), "activate", |
560 GTK_SIGNAL_FUNC(menu_item_activate), menu); | 813 GTK_SIGNAL_FUNC(menu_item_activate), menu); |
814 # endif | |
561 } | 815 } |
562 } | 816 } |
563 #endif /* FEAT_MENU */ | 817 #endif /* FEAT_MENU */ |
564 | 818 |
565 | 819 |
590 (const char *)name); | 844 (const char *)name); |
591 vim_free(name); | 845 vim_free(name); |
592 } | 846 } |
593 } | 847 } |
594 | 848 |
849 # if !GTK_CHECK_VERSION(3,4,0) | |
595 static void | 850 static void |
596 recurse_tearoffs(vimmenu_T *menu, int val) | 851 recurse_tearoffs(vimmenu_T *menu, int val) |
597 { | 852 { |
598 for (; menu != NULL; menu = menu->next) | 853 for (; menu != NULL; menu = menu->next) |
599 { | 854 { |
606 gtk_widget_hide(menu->tearoff_handle); | 861 gtk_widget_hide(menu->tearoff_handle); |
607 } | 862 } |
608 recurse_tearoffs(menu->children, val); | 863 recurse_tearoffs(menu->children, val); |
609 } | 864 } |
610 } | 865 } |
611 | 866 # endif |
867 | |
868 # if GTK_CHECK_VERSION(3,4,0) | |
869 void | |
870 gui_mch_toggle_tearoffs(int enable UNUSED) | |
871 { | |
872 /* Do nothing */ | |
873 } | |
874 # else | |
612 void | 875 void |
613 gui_mch_toggle_tearoffs(int enable) | 876 gui_mch_toggle_tearoffs(int enable) |
614 { | 877 { |
615 recurse_tearoffs(root_menu, enable); | 878 recurse_tearoffs(root_menu, enable); |
616 } | 879 } |
880 # endif | |
617 #endif /* FEAT_MENU */ | 881 #endif /* FEAT_MENU */ |
618 | 882 |
619 #if defined(FEAT_TOOLBAR) | 883 #if defined(FEAT_TOOLBAR) |
620 static int | 884 static int |
621 get_menu_position(vimmenu_T *menu) | 885 get_menu_position(vimmenu_T *menu) |
642 && gui.toolbar != NULL && menu_is_toolbar(menu->parent->name)) | 906 && gui.toolbar != NULL && menu_is_toolbar(menu->parent->name)) |
643 { | 907 { |
644 char_u *tooltip; | 908 char_u *tooltip; |
645 | 909 |
646 tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); | 910 tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); |
647 if (tooltip == NULL || utf_valid_string(tooltip, NULL)) | 911 if (tooltip != NULL && utf_valid_string(tooltip, NULL)) |
912 # if GTK_CHECK_VERSION(3,0,0) | |
648 /* Only set the tooltip when it's valid utf-8. */ | 913 /* Only set the tooltip when it's valid utf-8. */ |
649 gtk_tooltips_set_tip(GTK_TOOLBAR(gui.toolbar)->tooltips, | 914 gtk_widget_set_tooltip_text(menu->id, (const gchar *)tooltip); |
650 menu->id, (const char *)tooltip, NULL); | 915 # else |
916 /* Only set the tooltip when it's valid utf-8. */ | |
917 gtk_tooltips_set_tip(GTK_TOOLBAR(gui.toolbar)->tooltips, | |
918 menu->id, (const char *)tooltip, NULL); | |
919 # endif | |
651 CONVERT_TO_UTF8_FREE(tooltip); | 920 CONVERT_TO_UTF8_FREE(tooltip); |
652 } | 921 } |
653 } | 922 } |
654 #endif /* FEAT_TOOLBAR */ | 923 #endif /* FEAT_TOOLBAR */ |
655 | 924 |
674 | 943 |
675 # ifdef FEAT_TOOLBAR | 944 # ifdef FEAT_TOOLBAR |
676 if (menu->parent != NULL && menu_is_toolbar(menu->parent->name)) | 945 if (menu->parent != NULL && menu_is_toolbar(menu->parent->name)) |
677 { | 946 { |
678 if (menu_is_separator(menu->name)) | 947 if (menu_is_separator(menu->name)) |
948 # if GTK_CHECK_VERSION(3,0,0) | |
949 { | |
950 GtkToolItem *item = NULL; | |
951 | |
952 item = gtk_toolbar_get_nth_item(GTK_TOOLBAR(gui.toolbar), | |
953 get_menu_position(menu)); | |
954 if (item != NULL) | |
955 gtk_container_remove(GTK_CONTAINER(gui.toolbar), | |
956 GTK_WIDGET(item)); | |
957 } | |
958 # else | |
679 gtk_toolbar_remove_space(GTK_TOOLBAR(gui.toolbar), | 959 gtk_toolbar_remove_space(GTK_TOOLBAR(gui.toolbar), |
680 get_menu_position(menu)); | 960 get_menu_position(menu)); |
961 # endif | |
681 else if (menu->id != NULL) | 962 else if (menu->id != NULL) |
682 gtk_widget_destroy(menu->id); | 963 gtk_widget_destroy(menu->id); |
683 } | 964 } |
684 else | 965 else |
685 # endif /* FEAT_TOOLBAR */ | 966 # endif /* FEAT_TOOLBAR */ |
709 { | 990 { |
710 GtkAdjustment *adjustment; | 991 GtkAdjustment *adjustment; |
711 | 992 |
712 adjustment = gtk_range_get_adjustment(GTK_RANGE(sb->id)); | 993 adjustment = gtk_range_get_adjustment(GTK_RANGE(sb->id)); |
713 | 994 |
995 #if GTK_CHECK_VERSION(3,0,0) | |
996 gtk_adjustment_set_lower(adjustment, 0.0); | |
997 gtk_adjustment_set_value(adjustment, val); | |
998 gtk_adjustment_set_upper(adjustment, max + 1); | |
999 gtk_adjustment_set_page_size(adjustment, size); | |
1000 gtk_adjustment_set_page_increment(adjustment, | |
1001 size < 3L ? 1L : size - 2L); | |
1002 gtk_adjustment_set_step_increment(adjustment, 1.0); | |
1003 #else | |
714 adjustment->lower = 0.0; | 1004 adjustment->lower = 0.0; |
715 adjustment->value = val; | 1005 adjustment->value = val; |
716 adjustment->upper = max + 1; | 1006 adjustment->upper = max + 1; |
717 adjustment->page_size = size; | 1007 adjustment->page_size = size; |
718 adjustment->page_increment = size < 3L ? 1L : size - 2L; | 1008 adjustment->page_increment = size < 3L ? 1L : size - 2L; |
719 adjustment->step_increment = 1.0; | 1009 adjustment->step_increment = 1.0; |
720 | 1010 #endif |
1011 | |
1012 #if GTK_CHECK_VERSION(3,0,0) | |
1013 g_signal_handler_block(G_OBJECT(adjustment), | |
1014 (gulong)sb->handler_id); | |
1015 #else | |
721 g_signal_handler_block(GTK_OBJECT(adjustment), | 1016 g_signal_handler_block(GTK_OBJECT(adjustment), |
722 (gulong)sb->handler_id); | 1017 (gulong)sb->handler_id); |
1018 #endif | |
1019 | |
1020 #if !GTK_CHECK_VERSION(3,18,0) | |
723 gtk_adjustment_changed(adjustment); | 1021 gtk_adjustment_changed(adjustment); |
1022 #endif | |
1023 | |
1024 #if GTK_CHECK_VERSION(3,0,0) | |
1025 g_signal_handler_unblock(G_OBJECT(adjustment), | |
1026 (gulong)sb->handler_id); | |
1027 #else | |
724 g_signal_handler_unblock(GTK_OBJECT(adjustment), | 1028 g_signal_handler_unblock(GTK_OBJECT(adjustment), |
725 (gulong)sb->handler_id); | 1029 (gulong)sb->handler_id); |
1030 #endif | |
726 } | 1031 } |
727 } | 1032 } |
728 | 1033 |
729 void | 1034 void |
730 gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h) | 1035 gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h) |
748 if (im_is_preediting()) | 1053 if (im_is_preediting()) |
749 xim_reset(); | 1054 xim_reset(); |
750 #endif | 1055 #endif |
751 | 1056 |
752 sb = gui_find_scrollbar((long)data); | 1057 sb = gui_find_scrollbar((long)data); |
1058 #if GTK_CHECK_VERSION(3,0,0) | |
1059 value = gtk_adjustment_get_value(adjustment); | |
1060 #else | |
753 value = (long)adjustment->value; | 1061 value = (long)adjustment->value; |
1062 #endif | |
1063 #if !GTK_CHECK_VERSION(3,0,0) | |
754 /* | 1064 /* |
755 * The dragging argument must be right for the scrollbar to work with | 1065 * The dragging argument must be right for the scrollbar to work with |
756 * closed folds. This isn't documented, hopefully this will keep on | 1066 * closed folds. This isn't documented, hopefully this will keep on |
757 * working in later GTK versions. | 1067 * working in later GTK versions. |
758 * | 1068 * |
791 value = sb->wp->w_topline; | 1101 value = sb->wp->w_topline; |
792 } | 1102 } |
793 } | 1103 } |
794 } | 1104 } |
795 } | 1105 } |
796 | 1106 #endif /* !GTK_CHECK_VERSION(3,0,0) */ |
797 gui_drag_scrollbar(sb, value, dragging); | 1107 gui_drag_scrollbar(sb, value, dragging); |
798 } | 1108 } |
799 | 1109 |
800 /* SBAR_VERT or SBAR_HORIZ */ | 1110 /* SBAR_VERT or SBAR_HORIZ */ |
801 void | 1111 void |
802 gui_mch_create_scrollbar(scrollbar_T *sb, int orient) | 1112 gui_mch_create_scrollbar(scrollbar_T *sb, int orient) |
803 { | 1113 { |
804 if (orient == SBAR_HORIZ) | 1114 if (orient == SBAR_HORIZ) |
1115 #if GTK_CHECK_VERSION(3,2,0) | |
1116 sb->id = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL); | |
1117 #else | |
805 sb->id = gtk_hscrollbar_new(NULL); | 1118 sb->id = gtk_hscrollbar_new(NULL); |
1119 #endif | |
806 else if (orient == SBAR_VERT) | 1120 else if (orient == SBAR_VERT) |
1121 #if GTK_CHECK_VERSION(3,2,0) | |
1122 sb->id = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL); | |
1123 #else | |
807 sb->id = gtk_vscrollbar_new(NULL); | 1124 sb->id = gtk_vscrollbar_new(NULL); |
1125 #endif | |
808 | 1126 |
809 if (sb->id != NULL) | 1127 if (sb->id != NULL) |
810 { | 1128 { |
811 GtkAdjustment *adjustment; | 1129 GtkAdjustment *adjustment; |
812 | 1130 |
1131 #if GTK_CHECK_VERSION(3,0,0) | |
1132 gtk_widget_set_can_focus(sb->id, FALSE); | |
1133 #else | |
813 GTK_WIDGET_UNSET_FLAGS(sb->id, GTK_CAN_FOCUS); | 1134 GTK_WIDGET_UNSET_FLAGS(sb->id, GTK_CAN_FOCUS); |
1135 #endif | |
814 gtk_form_put(GTK_FORM(gui.formwin), sb->id, 0, 0); | 1136 gtk_form_put(GTK_FORM(gui.formwin), sb->id, 0, 0); |
815 | 1137 |
816 adjustment = gtk_range_get_adjustment(GTK_RANGE(sb->id)); | 1138 adjustment = gtk_range_get_adjustment(GTK_RANGE(sb->id)); |
817 | 1139 |
1140 #if GTK_CHECK_VERSION(3,0,0) | |
1141 sb->handler_id = g_signal_connect( | |
1142 G_OBJECT(adjustment), "value-changed", | |
1143 G_CALLBACK(adjustment_value_changed), | |
1144 GINT_TO_POINTER(sb->ident)); | |
1145 #else | |
818 sb->handler_id = gtk_signal_connect( | 1146 sb->handler_id = gtk_signal_connect( |
819 GTK_OBJECT(adjustment), "value_changed", | 1147 GTK_OBJECT(adjustment), "value_changed", |
820 GTK_SIGNAL_FUNC(adjustment_value_changed), | 1148 GTK_SIGNAL_FUNC(adjustment_value_changed), |
821 GINT_TO_POINTER(sb->ident)); | 1149 GINT_TO_POINTER(sb->ident)); |
1150 #endif | |
822 gui_mch_update(); | 1151 gui_mch_update(); |
823 } | 1152 } |
824 } | 1153 } |
825 | 1154 |
826 #if defined(FEAT_WINDOWS) || defined(PROTO) | 1155 #if defined(FEAT_WINDOWS) || defined(PROTO) |
930 * or "Save" according to the action. */ | 1259 * or "Save" according to the action. */ |
931 fc = gtk_file_chooser_dialog_new((const gchar *)title, | 1260 fc = gtk_file_chooser_dialog_new((const gchar *)title, |
932 GTK_WINDOW(gui.mainwin), | 1261 GTK_WINDOW(gui.mainwin), |
933 saving ? GTK_FILE_CHOOSER_ACTION_SAVE | 1262 saving ? GTK_FILE_CHOOSER_ACTION_SAVE |
934 : GTK_FILE_CHOOSER_ACTION_OPEN, | 1263 : GTK_FILE_CHOOSER_ACTION_OPEN, |
1264 # if GTK_CHECK_VERSION(3,10,0) | |
1265 _("_Cancel"), GTK_RESPONSE_CANCEL, | |
1266 saving ? _("_Save") : _("_Open"), GTK_RESPONSE_ACCEPT, | |
1267 # else | |
935 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | 1268 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
936 saving ? GTK_STOCK_SAVE : GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, | 1269 saving ? GTK_STOCK_SAVE : GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, |
1270 # endif | |
937 NULL); | 1271 NULL); |
938 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc), | 1272 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc), |
939 (const gchar *)dirbuf); | 1273 (const gchar *)dirbuf); |
940 | 1274 |
941 if (filter != NULL && *filter != NUL) | 1275 if (filter != NULL && *filter != NUL) |
989 gui.browse_fname = (char_u *)g_strdup(filename); | 1323 gui.browse_fname = (char_u *)g_strdup(filename); |
990 g_free(filename); | 1324 g_free(filename); |
991 } | 1325 } |
992 gtk_widget_destroy(GTK_WIDGET(fc)); | 1326 gtk_widget_destroy(GTK_WIDGET(fc)); |
993 | 1327 |
994 #else | 1328 #else /* !USE_FILE_CHOOSER */ |
995 | 1329 |
996 if (gui.filedlg == NULL) | 1330 if (gui.filedlg == NULL) |
997 { | 1331 { |
998 GtkFileSelection *fs; /* shortcut */ | 1332 GtkFileSelection *fs; /* shortcut */ |
999 | 1333 |
1025 gtk_file_selection_set_filename(GTK_FILE_SELECTION(gui.filedlg), | 1359 gtk_file_selection_set_filename(GTK_FILE_SELECTION(gui.filedlg), |
1026 (const gchar *)dirbuf); | 1360 (const gchar *)dirbuf); |
1027 | 1361 |
1028 gtk_widget_show(gui.filedlg); | 1362 gtk_widget_show(gui.filedlg); |
1029 gtk_main(); | 1363 gtk_main(); |
1030 #endif | 1364 #endif /* !USE_FILE_CHOOSER */ |
1031 g_log_remove_handler(domain, log_handler); | 1365 g_log_remove_handler(domain, log_handler); |
1032 | 1366 |
1033 CONVERT_TO_UTF8_FREE(title); | 1367 CONVERT_TO_UTF8_FREE(title); |
1034 if (gui.browse_fname == NULL) | 1368 if (gui.browse_fname == NULL) |
1035 return NULL; | 1369 return NULL; |
1060 | 1394 |
1061 dirdlg = gtk_file_chooser_dialog_new( | 1395 dirdlg = gtk_file_chooser_dialog_new( |
1062 (const gchar *)title, | 1396 (const gchar *)title, |
1063 GTK_WINDOW(gui.mainwin), | 1397 GTK_WINDOW(gui.mainwin), |
1064 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, | 1398 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, |
1399 # if GTK_CHECK_VERSION(3,10,0) | |
1400 _("_Cancel"), GTK_RESPONSE_CANCEL, | |
1401 _("_OK"), GTK_RESPONSE_ACCEPT, | |
1402 # else | |
1065 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | 1403 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
1066 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, | 1404 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
1405 # endif | |
1067 NULL); | 1406 NULL); |
1068 | 1407 |
1069 CONVERT_TO_UTF8_FREE(title); | 1408 CONVERT_TO_UTF8_FREE(title); |
1070 | 1409 |
1071 /* if our pointer is currently hidden, then we should show it. */ | 1410 /* if our pointer is currently hidden, then we should show it. */ |
1094 /* shorten the file name if possible */ | 1433 /* shorten the file name if possible */ |
1095 p = vim_strsave(shorten_fname1(dirname)); | 1434 p = vim_strsave(shorten_fname1(dirname)); |
1096 g_free(dirname); | 1435 g_free(dirname); |
1097 return p; | 1436 return p; |
1098 | 1437 |
1099 # else | 1438 # else /* !defined(GTK_FILE_CHOOSER) */ |
1100 /* For GTK 2.2 and earlier: fall back to ordinary file selector. */ | 1439 /* For GTK 2.2 and earlier: fall back to ordinary file selector. */ |
1101 return gui_mch_browse(0, title, NULL, NULL, initdir, NULL); | 1440 return gui_mch_browse(0, title, NULL, NULL, initdir, NULL); |
1102 # endif | 1441 # endif /* !defined(GTK_FILE_CHOOSER) */ |
1103 } | 1442 } |
1104 | 1443 |
1105 | 1444 |
1106 #endif /* FEAT_BROWSE */ | 1445 #endif /* FEAT_BROWSE */ |
1107 | 1446 |
1264 return; | 1603 return; |
1265 | 1604 |
1266 /* Check 'v' flag in 'guioptions': vertical button placement. */ | 1605 /* Check 'v' flag in 'guioptions': vertical button placement. */ |
1267 if (vim_strchr(p_go, GO_VERTICAL) != NULL) | 1606 if (vim_strchr(p_go, GO_VERTICAL) != NULL) |
1268 { | 1607 { |
1608 # if GTK_CHECK_VERSION(3,0,0) | |
1609 /* Add GTK+ 3 code if necessary. */ | |
1610 /* N.B. GTK+ 3 doesn't allow you to access vbox and action_area via | |
1611 * the C API. */ | |
1612 # else | |
1269 GtkWidget *vbutton_box; | 1613 GtkWidget *vbutton_box; |
1270 | 1614 |
1271 vbutton_box = gtk_vbutton_box_new(); | 1615 vbutton_box = gtk_vbutton_box_new(); |
1272 gtk_widget_show(vbutton_box); | 1616 gtk_widget_show(vbutton_box); |
1273 gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->vbox), | 1617 gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
1274 vbutton_box, TRUE, FALSE, 0); | 1618 vbutton_box, TRUE, FALSE, 0); |
1275 /* Overrule the "action_area" value, hopefully this works... */ | 1619 /* Overrule the "action_area" value, hopefully this works... */ |
1276 GTK_DIALOG(dialog)->action_area = vbutton_box; | 1620 GTK_DIALOG(dialog)->action_area = vbutton_box; |
1621 # endif | |
1277 } | 1622 } |
1278 | 1623 |
1279 /* | 1624 /* |
1280 * Yes this is ugly, I don't particularly like it either. But doing it | 1625 * Yes this is ugly, I don't particularly like it either. But doing it |
1281 * this way has the compelling advantage that translations need not to | 1626 * this way has the compelling advantage that translations need not to |
1306 * since anyone can create their own dialogs using Vim functions. | 1651 * since anyone can create their own dialogs using Vim functions. |
1307 * Thus we have to check for those too. | 1652 * Thus we have to check for those too. |
1308 */ | 1653 */ |
1309 if (ok != NULL && ync != NULL) /* almost impossible to fail */ | 1654 if (ok != NULL && ync != NULL) /* almost impossible to fail */ |
1310 { | 1655 { |
1656 # if GTK_CHECK_VERSION(3,10,0) | |
1657 if (button_equal(label, ok[0])) label = _("OK"); | |
1658 else if (button_equal(label, ync[0])) label = _("Yes"); | |
1659 else if (button_equal(label, ync[1])) label = _("No"); | |
1660 else if (button_equal(label, ync[2])) label = _("Cancel"); | |
1661 else if (button_equal(label, "Ok")) label = _("OK"); | |
1662 else if (button_equal(label, "Yes")) label = _("Yes"); | |
1663 else if (button_equal(label, "No")) label = _("No"); | |
1664 else if (button_equal(label, "Cancel")) label = _("Canccl"); | |
1665 # else | |
1311 if (button_equal(label, ok[0])) label = GTK_STOCK_OK; | 1666 if (button_equal(label, ok[0])) label = GTK_STOCK_OK; |
1312 else if (button_equal(label, ync[0])) label = GTK_STOCK_YES; | 1667 else if (button_equal(label, ync[0])) label = GTK_STOCK_YES; |
1313 else if (button_equal(label, ync[1])) label = GTK_STOCK_NO; | 1668 else if (button_equal(label, ync[1])) label = GTK_STOCK_NO; |
1314 else if (button_equal(label, ync[2])) label = GTK_STOCK_CANCEL; | 1669 else if (button_equal(label, ync[2])) label = GTK_STOCK_CANCEL; |
1315 else if (button_equal(label, "Ok")) label = GTK_STOCK_OK; | 1670 else if (button_equal(label, "Ok")) label = GTK_STOCK_OK; |
1316 else if (button_equal(label, "Yes")) label = GTK_STOCK_YES; | 1671 else if (button_equal(label, "Yes")) label = GTK_STOCK_YES; |
1317 else if (button_equal(label, "No")) label = GTK_STOCK_NO; | 1672 else if (button_equal(label, "No")) label = GTK_STOCK_NO; |
1318 else if (button_equal(label, "Cancel")) label = GTK_STOCK_CANCEL; | 1673 else if (button_equal(label, "Cancel")) label = GTK_STOCK_CANCEL; |
1674 # endif | |
1319 } | 1675 } |
1320 label8 = CONVERT_TO_UTF8((char_u *)label); | 1676 label8 = CONVERT_TO_UTF8((char_u *)label); |
1321 gtk_dialog_add_button(dialog, (const gchar *)label8, idx); | 1677 gtk_dialog_add_button(dialog, (const gchar *)label8, idx); |
1322 CONVERT_TO_UTF8_FREE(label8); | 1678 CONVERT_TO_UTF8_FREE(label8); |
1323 } | 1679 } |
1406 | 1762 |
1407 text = CONVERT_TO_UTF8(textfield); | 1763 text = CONVERT_TO_UTF8(textfield); |
1408 gtk_entry_set_text(GTK_ENTRY(entry), (const char *)text); | 1764 gtk_entry_set_text(GTK_ENTRY(entry), (const char *)text); |
1409 CONVERT_TO_UTF8_FREE(text); | 1765 CONVERT_TO_UTF8_FREE(text); |
1410 | 1766 |
1767 # if GTK_CHECK_VERSION(3,14,0) | |
1768 gtk_widget_set_halign(GTK_WIDGET(entry), GTK_ALIGN_CENTER); | |
1769 gtk_widget_set_valign(GTK_WIDGET(entry), GTK_ALIGN_CENTER); | |
1770 gtk_widget_set_hexpand(GTK_WIDGET(entry), TRUE); | |
1771 gtk_widget_set_vexpand(GTK_WIDGET(entry), TRUE); | |
1772 | |
1773 alignment = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); | |
1774 # else | |
1411 alignment = gtk_alignment_new((float)0.5, (float)0.5, | 1775 alignment = gtk_alignment_new((float)0.5, (float)0.5, |
1412 (float)1.0, (float)1.0); | 1776 (float)1.0, (float)1.0); |
1777 # endif | |
1413 gtk_container_add(GTK_CONTAINER(alignment), entry); | 1778 gtk_container_add(GTK_CONTAINER(alignment), entry); |
1414 gtk_container_set_border_width(GTK_CONTAINER(alignment), 5); | 1779 gtk_container_set_border_width(GTK_CONTAINER(alignment), 5); |
1415 gtk_widget_show(alignment); | 1780 gtk_widget_show(alignment); |
1416 | 1781 |
1782 # if GTK_CHECK_VERSION(3,0,0) | |
1783 { | |
1784 GtkWidget * const vbox | |
1785 = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); | |
1786 gtk_box_pack_start(GTK_BOX(vbox), | |
1787 alignment, TRUE, FALSE, 0); | |
1788 } | |
1789 # else | |
1417 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), | 1790 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
1418 alignment, TRUE, FALSE, 0); | 1791 alignment, TRUE, FALSE, 0); |
1792 # endif | |
1419 dialoginfo.noalt = FALSE; | 1793 dialoginfo.noalt = FALSE; |
1420 } | 1794 } |
1421 else | 1795 else |
1422 dialoginfo.noalt = TRUE; | 1796 dialoginfo.noalt = TRUE; |
1423 | 1797 |
1471 # if defined(FEAT_XIM) | 1845 # if defined(FEAT_XIM) |
1472 /* | 1846 /* |
1473 * Append a submenu for selecting an input method. This is | 1847 * Append a submenu for selecting an input method. This is |
1474 * currently the only way to switch input methods at runtime. | 1848 * currently the only way to switch input methods at runtime. |
1475 */ | 1849 */ |
1850 # if !GTK_CHECK_VERSION(3,10,0) | |
1476 if (xic != NULL && g_object_get_data(G_OBJECT(menu->submenu_id), | 1851 if (xic != NULL && g_object_get_data(G_OBJECT(menu->submenu_id), |
1477 "vim-has-im-menu") == NULL) | 1852 "vim-has-im-menu") == NULL) |
1478 { | 1853 { |
1479 GtkWidget *menuitem; | 1854 GtkWidget *menuitem; |
1480 GtkWidget *submenu; | 1855 GtkWidget *submenu; |
1497 gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(xic), | 1872 gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(xic), |
1498 GTK_MENU_SHELL(submenu)); | 1873 GTK_MENU_SHELL(submenu)); |
1499 g_object_set_data(G_OBJECT(menu->submenu_id), | 1874 g_object_set_data(G_OBJECT(menu->submenu_id), |
1500 "vim-has-im-menu", GINT_TO_POINTER(TRUE)); | 1875 "vim-has-im-menu", GINT_TO_POINTER(TRUE)); |
1501 } | 1876 } |
1877 # endif | |
1502 # endif /* FEAT_XIM */ | 1878 # endif /* FEAT_XIM */ |
1503 | 1879 |
1504 gtk_menu_popup(GTK_MENU(menu->submenu_id), | 1880 gtk_menu_popup(GTK_MENU(menu->submenu_id), |
1505 NULL, NULL, | 1881 NULL, NULL, |
1506 (GtkMenuPositionFunc)NULL, NULL, | 1882 (GtkMenuPositionFunc)NULL, NULL, |
1522 popup_menu_position_func(GtkMenu *menu UNUSED, | 1898 popup_menu_position_func(GtkMenu *menu UNUSED, |
1523 gint *x, gint *y, | 1899 gint *x, gint *y, |
1524 gboolean *push_in UNUSED, | 1900 gboolean *push_in UNUSED, |
1525 gpointer user_data UNUSED) | 1901 gpointer user_data UNUSED) |
1526 { | 1902 { |
1903 # if GTK_CHECK_VERSION(3,0,0) | |
1904 gdk_window_get_origin(gtk_widget_get_window(gui.drawarea), x, y); | |
1905 # else | |
1527 gdk_window_get_origin(gui.drawarea->window, x, y); | 1906 gdk_window_get_origin(gui.drawarea->window, x, y); |
1907 # endif | |
1528 | 1908 |
1529 if (popup_mouse_pos) | 1909 if (popup_mouse_pos) |
1530 { | 1910 { |
1531 int mx, my; | 1911 int mx, my; |
1532 | 1912 |
1533 gui_mch_getmouse(&mx, &my); | 1913 gui_mch_getmouse(&mx, &my); |
1534 *x += mx; | 1914 *x += mx; |
1535 *y += my; | 1915 *y += my; |
1536 } | 1916 } |
1917 # if GTK_CHECK_VERSION(3,0,0) | |
1918 else if (curwin != NULL && gui.drawarea != NULL && | |
1919 gtk_widget_get_window(gui.drawarea) != NULL) | |
1920 # else | |
1537 else if (curwin != NULL && gui.drawarea != NULL && gui.drawarea->window != NULL) | 1921 else if (curwin != NULL && gui.drawarea != NULL && gui.drawarea->window != NULL) |
1922 # endif | |
1538 { | 1923 { |
1539 /* Find the cursor position in the current window */ | 1924 /* Find the cursor position in the current window */ |
1540 *x += FILL_X(W_WINCOL(curwin) + curwin->w_wcol + 1) + 1; | 1925 *x += FILL_X(W_WINCOL(curwin) + curwin->w_wcol + 1) + 1; |
1541 *y += FILL_Y(W_WINROW(curwin) + curwin->w_wrow + 1) + 1; | 1926 *y += FILL_Y(W_WINROW(curwin) + curwin->w_wrow + 1) + 1; |
1542 } | 1927 } |
1610 | 1995 |
1611 return FALSE; | 1996 return FALSE; |
1612 } | 1997 } |
1613 | 1998 |
1614 static GtkWidget * | 1999 static GtkWidget * |
1615 create_image_button(const char *stock_id, const char *label) | 2000 #if GTK_CHECK_VERSION(3,10,0) |
2001 create_image_button(const char *stock_id UNUSED, | |
2002 const char *label) | |
2003 #else | |
2004 create_image_button(const char *stock_id, | |
2005 const char *label) | |
2006 #endif | |
1616 { | 2007 { |
1617 char_u *text; | 2008 char_u *text; |
1618 GtkWidget *box; | 2009 GtkWidget *box; |
1619 GtkWidget *alignment; | 2010 GtkWidget *alignment; |
1620 GtkWidget *button; | 2011 GtkWidget *button; |
1621 | 2012 |
1622 text = CONVERT_TO_UTF8((char_u *)label); | 2013 text = CONVERT_TO_UTF8((char_u *)label); |
1623 | 2014 |
2015 #if GTK_CHECK_VERSION(3,2,0) | |
2016 box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3); | |
2017 gtk_box_set_homogeneous(GTK_BOX(box), FALSE); | |
2018 #else | |
1624 box = gtk_hbox_new(FALSE, 3); | 2019 box = gtk_hbox_new(FALSE, 3); |
1625 gtk_box_pack_start(GTK_BOX(box), | 2020 #endif |
1626 gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_BUTTON), | 2021 #if !GTK_CHECK_VERSION(3,10,0) |
1627 FALSE, FALSE, 0); | 2022 if (stock_id != NULL) |
2023 gtk_box_pack_start(GTK_BOX(box), | |
2024 gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_BUTTON), | |
2025 FALSE, FALSE, 0); | |
2026 #endif | |
1628 gtk_box_pack_start(GTK_BOX(box), | 2027 gtk_box_pack_start(GTK_BOX(box), |
1629 gtk_label_new((const char *)text), | 2028 gtk_label_new((const char *)text), |
1630 FALSE, FALSE, 0); | 2029 FALSE, FALSE, 0); |
1631 | 2030 |
1632 CONVERT_TO_UTF8_FREE(text); | 2031 CONVERT_TO_UTF8_FREE(text); |
1633 | 2032 |
2033 #if GTK_CHECK_VERSION(3,14,0) | |
2034 gtk_widget_set_halign(GTK_WIDGET(box), GTK_ALIGN_CENTER); | |
2035 gtk_widget_set_valign(GTK_WIDGET(box), GTK_ALIGN_CENTER); | |
2036 gtk_widget_set_hexpand(GTK_WIDGET(box), TRUE); | |
2037 gtk_widget_set_vexpand(GTK_WIDGET(box), TRUE); | |
2038 | |
2039 alignment = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); | |
2040 #else | |
1634 alignment = gtk_alignment_new((float)0.5, (float)0.5, | 2041 alignment = gtk_alignment_new((float)0.5, (float)0.5, |
1635 (float)0.0, (float)0.0); | 2042 (float)0.0, (float)0.0); |
2043 #endif | |
1636 gtk_container_add(GTK_CONTAINER(alignment), box); | 2044 gtk_container_add(GTK_CONTAINER(alignment), box); |
1637 gtk_widget_show_all(alignment); | 2045 gtk_widget_show_all(alignment); |
1638 | 2046 |
1639 button = gtk_button_new(); | 2047 button = gtk_button_new(); |
1640 gtk_container_add(GTK_CONTAINER(button), alignment); | 2048 gtk_container_add(GTK_CONTAINER(button), alignment); |
1693 if (frdp->dialog) | 2101 if (frdp->dialog) |
1694 { | 2102 { |
1695 if (entry_text != NULL) | 2103 if (entry_text != NULL) |
1696 { | 2104 { |
1697 gtk_entry_set_text(GTK_ENTRY(frdp->what), (char *)entry_text); | 2105 gtk_entry_set_text(GTK_ENTRY(frdp->what), (char *)entry_text); |
2106 #if GTK_CHECK_VERSION(3,0,0) | |
2107 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->wword), | |
2108 (gboolean)wword); | |
2109 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->mcase), | |
2110 (gboolean)mcase); | |
2111 #else | |
1698 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->wword), | 2112 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->wword), |
1699 (gboolean)wword); | 2113 (gboolean)wword); |
1700 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->mcase), | 2114 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->mcase), |
1701 (gboolean)mcase); | 2115 (gboolean)mcase); |
2116 #endif | |
1702 } | 2117 } |
1703 gtk_window_present(GTK_WINDOW(frdp->dialog)); | 2118 gtk_window_present(GTK_WINDOW(frdp->dialog)); |
1704 vim_free(entry_text); | 2119 vim_free(entry_text); |
1705 return; | 2120 return; |
1706 } | 2121 } |
1707 | 2122 |
1708 frdp->dialog = gtk_dialog_new(); | 2123 frdp->dialog = gtk_dialog_new(); |
2124 #if GTK_CHECK_VERSION(3,0,0) | |
2125 /* Nothing equivalent to gtk_dialog_set_has_separator() in GTK+ 3. */ | |
2126 #else | |
1709 gtk_dialog_set_has_separator(GTK_DIALOG(frdp->dialog), FALSE); | 2127 gtk_dialog_set_has_separator(GTK_DIALOG(frdp->dialog), FALSE); |
2128 #endif | |
1710 gtk_window_set_transient_for(GTK_WINDOW(frdp->dialog), GTK_WINDOW(gui.mainwin)); | 2129 gtk_window_set_transient_for(GTK_WINDOW(frdp->dialog), GTK_WINDOW(gui.mainwin)); |
1711 gtk_window_set_destroy_with_parent(GTK_WINDOW(frdp->dialog), TRUE); | 2130 gtk_window_set_destroy_with_parent(GTK_WINDOW(frdp->dialog), TRUE); |
1712 | 2131 |
1713 if (do_replace) | 2132 if (do_replace) |
1714 { | 2133 { |
1719 { | 2138 { |
1720 gtk_window_set_title(GTK_WINDOW(frdp->dialog), | 2139 gtk_window_set_title(GTK_WINDOW(frdp->dialog), |
1721 CONV(_("VIM - Search..."))); | 2140 CONV(_("VIM - Search..."))); |
1722 } | 2141 } |
1723 | 2142 |
2143 #if GTK_CHECK_VERSION(3,2,0) | |
2144 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); | |
2145 gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE); | |
2146 #else | |
1724 hbox = gtk_hbox_new(FALSE, 0); | 2147 hbox = gtk_hbox_new(FALSE, 0); |
2148 #endif | |
1725 gtk_container_set_border_width(GTK_CONTAINER(hbox), 10); | 2149 gtk_container_set_border_width(GTK_CONTAINER(hbox), 10); |
2150 #if GTK_CHECK_VERSION(3,0,0) | |
2151 { | |
2152 GtkWidget * const dialog_vbox | |
2153 = gtk_dialog_get_content_area(GTK_DIALOG(frdp->dialog)); | |
2154 gtk_container_add(GTK_CONTAINER(dialog_vbox), hbox); | |
2155 } | |
2156 #else | |
1726 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(frdp->dialog)->vbox), hbox); | 2157 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(frdp->dialog)->vbox), hbox); |
2158 #endif | |
1727 | 2159 |
1728 if (do_replace) | 2160 if (do_replace) |
2161 #if GTK_CHECK_VERSION(3,4,0) | |
2162 table = gtk_grid_new(); | |
2163 #else | |
1729 table = gtk_table_new(1024, 4, FALSE); | 2164 table = gtk_table_new(1024, 4, FALSE); |
2165 #endif | |
1730 else | 2166 else |
2167 #if GTK_CHECK_VERSION(3,4,0) | |
2168 table = gtk_grid_new(); | |
2169 #else | |
1731 table = gtk_table_new(1024, 3, FALSE); | 2170 table = gtk_table_new(1024, 3, FALSE); |
2171 #endif | |
1732 gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 0); | 2172 gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 0); |
2173 #if GTK_CHECK_VERSION(3,0,0) | |
2174 gtk_container_set_border_width(GTK_CONTAINER(table), 4); | |
2175 #else | |
1733 gtk_container_border_width(GTK_CONTAINER(table), 4); | 2176 gtk_container_border_width(GTK_CONTAINER(table), 4); |
2177 #endif | |
1734 | 2178 |
1735 tmp = gtk_label_new(CONV(_("Find what:"))); | 2179 tmp = gtk_label_new(CONV(_("Find what:"))); |
2180 #if GTK_CHECK_VERSION(3,16,0) | |
2181 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0); | |
2182 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5); | |
2183 #elif GTK_CHECK_VERSION(3,14,0) | |
2184 { | |
2185 GValue align_val = G_VALUE_INIT; | |
2186 | |
2187 g_value_init(&align_val, G_TYPE_FLOAT); | |
2188 | |
2189 g_value_set_float(&align_val, 0.0); | |
2190 g_object_set_property(G_OBJECT(tmp), "xalign", &align_val); | |
2191 | |
2192 g_value_set_float(&align_val, 0.5); | |
2193 g_object_set_property(G_OBJECT(tmp), "yalign", &align_val); | |
2194 | |
2195 g_value_unset(&align_val); | |
2196 } | |
2197 #else | |
1736 gtk_misc_set_alignment(GTK_MISC(tmp), (gfloat)0.0, (gfloat)0.5); | 2198 gtk_misc_set_alignment(GTK_MISC(tmp), (gfloat)0.0, (gfloat)0.5); |
2199 #endif | |
2200 #if GTK_CHECK_VERSION(3,4,0) | |
2201 gtk_grid_attach(GTK_GRID(table), tmp, 0, 0, 2, 1); | |
2202 #else | |
1737 gtk_table_attach(GTK_TABLE(table), tmp, 0, 1, 0, 1, | 2203 gtk_table_attach(GTK_TABLE(table), tmp, 0, 1, 0, 1, |
1738 GTK_FILL, GTK_EXPAND, 2, 2); | 2204 GTK_FILL, GTK_EXPAND, 2, 2); |
2205 #endif | |
1739 frdp->what = gtk_entry_new(); | 2206 frdp->what = gtk_entry_new(); |
1740 sensitive = (entry_text != NULL && entry_text[0] != NUL); | 2207 sensitive = (entry_text != NULL && entry_text[0] != NUL); |
1741 if (entry_text != NULL) | 2208 if (entry_text != NULL) |
1742 gtk_entry_set_text(GTK_ENTRY(frdp->what), (char *)entry_text); | 2209 gtk_entry_set_text(GTK_ENTRY(frdp->what), (char *)entry_text); |
2210 #if GTK_CHECK_VERSION(3,0,0) | |
2211 g_signal_connect(G_OBJECT(frdp->what), "changed", | |
2212 G_CALLBACK(entry_changed_cb), frdp->dialog); | |
2213 g_signal_connect_after(G_OBJECT(frdp->what), "key-press-event", | |
2214 G_CALLBACK(find_key_press_event), | |
2215 (gpointer) frdp); | |
2216 #else | |
1743 gtk_signal_connect(GTK_OBJECT(frdp->what), "changed", | 2217 gtk_signal_connect(GTK_OBJECT(frdp->what), "changed", |
1744 GTK_SIGNAL_FUNC(entry_changed_cb), frdp->dialog); | 2218 GTK_SIGNAL_FUNC(entry_changed_cb), frdp->dialog); |
1745 gtk_signal_connect_after(GTK_OBJECT(frdp->what), "key_press_event", | 2219 gtk_signal_connect_after(GTK_OBJECT(frdp->what), "key_press_event", |
1746 GTK_SIGNAL_FUNC(find_key_press_event), | 2220 GTK_SIGNAL_FUNC(find_key_press_event), |
1747 (gpointer) frdp); | 2221 (gpointer) frdp); |
2222 #endif | |
2223 #if GTK_CHECK_VERSION(3,4,0) | |
2224 gtk_grid_attach(GTK_GRID(table), frdp->what, 2, 0, 5, 1); | |
2225 #else | |
1748 gtk_table_attach(GTK_TABLE(table), frdp->what, 1, 1024, 0, 1, | 2226 gtk_table_attach(GTK_TABLE(table), frdp->what, 1, 1024, 0, 1, |
1749 GTK_EXPAND | GTK_FILL, GTK_EXPAND, 2, 2); | 2227 GTK_EXPAND | GTK_FILL, GTK_EXPAND, 2, 2); |
2228 #endif | |
1750 | 2229 |
1751 if (do_replace) | 2230 if (do_replace) |
1752 { | 2231 { |
1753 tmp = gtk_label_new(CONV(_("Replace with:"))); | 2232 tmp = gtk_label_new(CONV(_("Replace with:"))); |
2233 #if GTK_CHECK_VERSION(3,16,0) | |
2234 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0); | |
2235 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5); | |
2236 #elif GTK_CHECK_VERSION(3,14,0) | |
2237 { | |
2238 GValue align_val = G_VALUE_INIT; | |
2239 | |
2240 g_value_init(&align_val, G_TYPE_FLOAT); | |
2241 | |
2242 g_value_set_float(&align_val, 0.0); | |
2243 g_object_set_property(G_OBJECT(tmp), "xalign", &align_val); | |
2244 | |
2245 g_value_set_float(&align_val, 0.5); | |
2246 g_object_set_property(G_OBJECT(tmp), "yalign", &align_val); | |
2247 | |
2248 g_value_unset(&align_val); | |
2249 } | |
2250 #else | |
1754 gtk_misc_set_alignment(GTK_MISC(tmp), (gfloat)0.0, (gfloat)0.5); | 2251 gtk_misc_set_alignment(GTK_MISC(tmp), (gfloat)0.0, (gfloat)0.5); |
2252 #endif | |
2253 #if GTK_CHECK_VERSION(3,4,0) | |
2254 gtk_grid_attach(GTK_GRID(table), tmp, 0, 1, 2, 1); | |
2255 #else | |
1755 gtk_table_attach(GTK_TABLE(table), tmp, 0, 1, 1, 2, | 2256 gtk_table_attach(GTK_TABLE(table), tmp, 0, 1, 1, 2, |
1756 GTK_FILL, GTK_EXPAND, 2, 2); | 2257 GTK_FILL, GTK_EXPAND, 2, 2); |
2258 #endif | |
1757 frdp->with = gtk_entry_new(); | 2259 frdp->with = gtk_entry_new(); |
2260 #if GTK_CHECK_VERSION(3,0,0) | |
2261 g_signal_connect(G_OBJECT(frdp->with), "activate", | |
2262 G_CALLBACK(find_replace_cb), | |
2263 GINT_TO_POINTER(FRD_R_FINDNEXT)); | |
2264 g_signal_connect_after(G_OBJECT(frdp->with), "key-press-event", | |
2265 G_CALLBACK(find_key_press_event), | |
2266 (gpointer) frdp); | |
2267 #else | |
1758 gtk_signal_connect(GTK_OBJECT(frdp->with), "activate", | 2268 gtk_signal_connect(GTK_OBJECT(frdp->with), "activate", |
1759 GTK_SIGNAL_FUNC(find_replace_cb), | 2269 GTK_SIGNAL_FUNC(find_replace_cb), |
1760 GINT_TO_POINTER(FRD_R_FINDNEXT)); | 2270 GINT_TO_POINTER(FRD_R_FINDNEXT)); |
1761 gtk_signal_connect_after(GTK_OBJECT(frdp->with), "key_press_event", | 2271 gtk_signal_connect_after(GTK_OBJECT(frdp->with), "key_press_event", |
1762 GTK_SIGNAL_FUNC(find_key_press_event), | 2272 GTK_SIGNAL_FUNC(find_key_press_event), |
1763 (gpointer) frdp); | 2273 (gpointer) frdp); |
2274 #endif | |
2275 #if GTK_CHECK_VERSION(3,4,0) | |
2276 gtk_grid_attach(GTK_GRID(table), frdp->with, 2, 1, 5, 1); | |
2277 #else | |
1764 gtk_table_attach(GTK_TABLE(table), frdp->with, 1, 1024, 1, 2, | 2278 gtk_table_attach(GTK_TABLE(table), frdp->with, 1, 1024, 1, 2, |
1765 GTK_EXPAND | GTK_FILL, GTK_EXPAND, 2, 2); | 2279 GTK_EXPAND | GTK_FILL, GTK_EXPAND, 2, 2); |
2280 #endif | |
1766 | 2281 |
1767 /* | 2282 /* |
1768 * Make the entry activation only change the input focus onto the | 2283 * Make the entry activation only change the input focus onto the |
1769 * with item. | 2284 * with item. |
1770 */ | 2285 */ |
2286 #if GTK_CHECK_VERSION(3,0,0) | |
2287 g_signal_connect(G_OBJECT(frdp->what), "activate", | |
2288 G_CALLBACK(entry_activate_cb), frdp->with); | |
2289 #else | |
1771 gtk_signal_connect(GTK_OBJECT(frdp->what), "activate", | 2290 gtk_signal_connect(GTK_OBJECT(frdp->what), "activate", |
1772 GTK_SIGNAL_FUNC(entry_activate_cb), frdp->with); | 2291 GTK_SIGNAL_FUNC(entry_activate_cb), frdp->with); |
2292 #endif | |
1773 } | 2293 } |
1774 else | 2294 else |
1775 { | 2295 { |
1776 /* | 2296 /* |
1777 * Make the entry activation do the search. | 2297 * Make the entry activation do the search. |
1778 */ | 2298 */ |
2299 #if GTK_CHECK_VERSION(3,0,0) | |
2300 g_signal_connect(G_OBJECT(frdp->what), "activate", | |
2301 G_CALLBACK(find_replace_cb), | |
2302 GINT_TO_POINTER(FRD_FINDNEXT)); | |
2303 #else | |
1779 gtk_signal_connect(GTK_OBJECT(frdp->what), "activate", | 2304 gtk_signal_connect(GTK_OBJECT(frdp->what), "activate", |
1780 GTK_SIGNAL_FUNC(find_replace_cb), | 2305 GTK_SIGNAL_FUNC(find_replace_cb), |
1781 GINT_TO_POINTER(FRD_FINDNEXT)); | 2306 GINT_TO_POINTER(FRD_FINDNEXT)); |
2307 #endif | |
1782 } | 2308 } |
1783 | 2309 |
1784 /* whole word only button */ | 2310 /* whole word only button */ |
1785 frdp->wword = gtk_check_button_new_with_label(CONV(_("Match whole word only"))); | 2311 frdp->wword = gtk_check_button_new_with_label(CONV(_("Match whole word only"))); |
2312 #if GTK_CHECK_VERSION(3,0,0) | |
2313 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->wword), | |
2314 (gboolean)wword); | |
2315 #else | |
1786 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->wword), | 2316 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->wword), |
1787 (gboolean)wword); | 2317 (gboolean)wword); |
2318 #endif | |
1788 if (do_replace) | 2319 if (do_replace) |
2320 #if GTK_CHECK_VERSION(3,4,0) | |
2321 gtk_grid_attach(GTK_GRID(table), frdp->wword, 0, 2, 5, 1); | |
2322 #else | |
1789 gtk_table_attach(GTK_TABLE(table), frdp->wword, 0, 1023, 2, 3, | 2323 gtk_table_attach(GTK_TABLE(table), frdp->wword, 0, 1023, 2, 3, |
1790 GTK_FILL, GTK_EXPAND, 2, 2); | 2324 GTK_FILL, GTK_EXPAND, 2, 2); |
2325 #endif | |
1791 else | 2326 else |
2327 #if GTK_CHECK_VERSION(3,4,0) | |
2328 gtk_grid_attach(GTK_GRID(table), frdp->wword, 0, 3, 5, 1); | |
2329 #else | |
1792 gtk_table_attach(GTK_TABLE(table), frdp->wword, 0, 1023, 1, 2, | 2330 gtk_table_attach(GTK_TABLE(table), frdp->wword, 0, 1023, 1, 2, |
1793 GTK_FILL, GTK_EXPAND, 2, 2); | 2331 GTK_FILL, GTK_EXPAND, 2, 2); |
2332 #endif | |
1794 | 2333 |
1795 /* match case button */ | 2334 /* match case button */ |
1796 frdp->mcase = gtk_check_button_new_with_label(CONV(_("Match case"))); | 2335 frdp->mcase = gtk_check_button_new_with_label(CONV(_("Match case"))); |
2336 #if GTK_CHECK_VERSION(3,0,0) | |
2337 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->mcase), | |
2338 (gboolean)mcase); | |
2339 #else | |
1797 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->mcase), | 2340 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->mcase), |
1798 (gboolean)mcase); | 2341 (gboolean)mcase); |
2342 #endif | |
1799 if (do_replace) | 2343 if (do_replace) |
2344 #if GTK_CHECK_VERSION(3,4,0) | |
2345 gtk_grid_attach(GTK_GRID(table), frdp->mcase, 0, 3, 5, 1); | |
2346 #else | |
1800 gtk_table_attach(GTK_TABLE(table), frdp->mcase, 0, 1023, 3, 4, | 2347 gtk_table_attach(GTK_TABLE(table), frdp->mcase, 0, 1023, 3, 4, |
1801 GTK_FILL, GTK_EXPAND, 2, 2); | 2348 GTK_FILL, GTK_EXPAND, 2, 2); |
2349 #endif | |
1802 else | 2350 else |
2351 #if GTK_CHECK_VERSION(3,4,0) | |
2352 gtk_grid_attach(GTK_GRID(table), frdp->mcase, 0, 4, 5, 1); | |
2353 #else | |
1803 gtk_table_attach(GTK_TABLE(table), frdp->mcase, 0, 1023, 2, 3, | 2354 gtk_table_attach(GTK_TABLE(table), frdp->mcase, 0, 1023, 2, 3, |
1804 GTK_FILL, GTK_EXPAND, 2, 2); | 2355 GTK_FILL, GTK_EXPAND, 2, 2); |
2356 #endif | |
1805 | 2357 |
1806 tmp = gtk_frame_new(CONV(_("Direction"))); | 2358 tmp = gtk_frame_new(CONV(_("Direction"))); |
1807 if (do_replace) | 2359 if (do_replace) |
2360 #if GTK_CHECK_VERSION(3,4,0) | |
2361 gtk_grid_attach(GTK_GRID(table), tmp, 5, 2, 2, 4); | |
2362 #else | |
1808 gtk_table_attach(GTK_TABLE(table), tmp, 1023, 1024, 2, 4, | 2363 gtk_table_attach(GTK_TABLE(table), tmp, 1023, 1024, 2, 4, |
1809 GTK_FILL, GTK_FILL, 2, 2); | 2364 GTK_FILL, GTK_FILL, 2, 2); |
2365 #endif | |
1810 else | 2366 else |
2367 #if GTK_CHECK_VERSION(3,4,0) | |
2368 gtk_grid_attach(GTK_GRID(table), tmp, 5, 2, 1, 3); | |
2369 #else | |
1811 gtk_table_attach(GTK_TABLE(table), tmp, 1023, 1024, 1, 3, | 2370 gtk_table_attach(GTK_TABLE(table), tmp, 1023, 1024, 1, 3, |
1812 GTK_FILL, GTK_FILL, 2, 2); | 2371 GTK_FILL, GTK_FILL, 2, 2); |
2372 #endif | |
2373 #if GTK_CHECK_VERSION(3,2,0) | |
2374 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); | |
2375 gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE); | |
2376 #else | |
1813 vbox = gtk_vbox_new(FALSE, 0); | 2377 vbox = gtk_vbox_new(FALSE, 0); |
2378 #endif | |
2379 #if GTK_CHECK_VERSION(3,0,0) | |
2380 gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); | |
2381 #else | |
1814 gtk_container_border_width(GTK_CONTAINER(vbox), 0); | 2382 gtk_container_border_width(GTK_CONTAINER(vbox), 0); |
2383 #endif | |
1815 gtk_container_add(GTK_CONTAINER(tmp), vbox); | 2384 gtk_container_add(GTK_CONTAINER(tmp), vbox); |
1816 | 2385 |
1817 /* 'Up' and 'Down' buttons */ | 2386 /* 'Up' and 'Down' buttons */ |
1818 frdp->up = gtk_radio_button_new_with_label(NULL, CONV(_("Up"))); | 2387 frdp->up = gtk_radio_button_new_with_label(NULL, CONV(_("Up"))); |
1819 gtk_box_pack_start(GTK_BOX(vbox), frdp->up, TRUE, TRUE, 0); | 2388 gtk_box_pack_start(GTK_BOX(vbox), frdp->up, TRUE, TRUE, 0); |
2389 #if GTK_CHECK_VERSION(3,0,0) | |
2390 frdp->down = gtk_radio_button_new_with_label( | |
2391 gtk_radio_button_get_group(GTK_RADIO_BUTTON(frdp->up)), | |
2392 CONV(_("Down"))); | |
2393 #else | |
1820 frdp->down = gtk_radio_button_new_with_label( | 2394 frdp->down = gtk_radio_button_new_with_label( |
1821 gtk_radio_button_group(GTK_RADIO_BUTTON(frdp->up)), | 2395 gtk_radio_button_group(GTK_RADIO_BUTTON(frdp->up)), |
1822 CONV(_("Down"))); | 2396 CONV(_("Down"))); |
2397 #endif | |
2398 #if GTK_CHECK_VERSION(3,0,0) | |
2399 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->down), TRUE); | |
2400 #else | |
1823 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->down), TRUE); | 2401 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->down), TRUE); |
2402 #endif | |
1824 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2); | 2403 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2); |
1825 gtk_box_pack_start(GTK_BOX(vbox), frdp->down, TRUE, TRUE, 0); | 2404 gtk_box_pack_start(GTK_BOX(vbox), frdp->down, TRUE, TRUE, 0); |
1826 | 2405 |
1827 /* vbox to hold the action buttons */ | 2406 /* vbox to hold the action buttons */ |
2407 #if GTK_CHECK_VERSION(3,2,0) | |
2408 actionarea = gtk_button_box_new(GTK_ORIENTATION_VERTICAL); | |
2409 #else | |
1828 actionarea = gtk_vbutton_box_new(); | 2410 actionarea = gtk_vbutton_box_new(); |
2411 #endif | |
2412 #if GTK_CHECK_VERSION(3,0,0) | |
2413 gtk_container_set_border_width(GTK_CONTAINER(actionarea), 2); | |
2414 #else | |
1829 gtk_container_border_width(GTK_CONTAINER(actionarea), 2); | 2415 gtk_container_border_width(GTK_CONTAINER(actionarea), 2); |
2416 #endif | |
1830 gtk_box_pack_end(GTK_BOX(hbox), actionarea, FALSE, FALSE, 0); | 2417 gtk_box_pack_end(GTK_BOX(hbox), actionarea, FALSE, FALSE, 0); |
1831 | 2418 |
1832 /* 'Find Next' button */ | 2419 /* 'Find Next' button */ |
2420 #if GTK_CHECK_VERSION(3,10,0) | |
2421 frdp->find = create_image_button(NULL, _("Find Next")); | |
2422 #else | |
1833 frdp->find = create_image_button(GTK_STOCK_FIND, _("Find Next")); | 2423 frdp->find = create_image_button(GTK_STOCK_FIND, _("Find Next")); |
2424 #endif | |
1834 gtk_widget_set_sensitive(frdp->find, sensitive); | 2425 gtk_widget_set_sensitive(frdp->find, sensitive); |
1835 | 2426 |
2427 #if GTK_CHECK_VERSION(3,0,0) | |
2428 g_signal_connect(G_OBJECT(frdp->find), "clicked", | |
2429 G_CALLBACK(find_replace_cb), | |
2430 (do_replace) ? GINT_TO_POINTER(FRD_R_FINDNEXT) | |
2431 : GINT_TO_POINTER(FRD_FINDNEXT)); | |
2432 #else | |
1836 gtk_signal_connect(GTK_OBJECT(frdp->find), "clicked", | 2433 gtk_signal_connect(GTK_OBJECT(frdp->find), "clicked", |
1837 GTK_SIGNAL_FUNC(find_replace_cb), | 2434 GTK_SIGNAL_FUNC(find_replace_cb), |
1838 (do_replace) ? GINT_TO_POINTER(FRD_R_FINDNEXT) | 2435 (do_replace) ? GINT_TO_POINTER(FRD_R_FINDNEXT) |
1839 : GINT_TO_POINTER(FRD_FINDNEXT)); | 2436 : GINT_TO_POINTER(FRD_FINDNEXT)); |
1840 | 2437 #endif |
2438 | |
2439 #if GTK_CHECK_VERSION(3,0,0) | |
2440 gtk_widget_set_can_default(frdp->find, TRUE); | |
2441 #else | |
1841 GTK_WIDGET_SET_FLAGS(frdp->find, GTK_CAN_DEFAULT); | 2442 GTK_WIDGET_SET_FLAGS(frdp->find, GTK_CAN_DEFAULT); |
2443 #endif | |
1842 gtk_box_pack_start(GTK_BOX(actionarea), frdp->find, FALSE, FALSE, 0); | 2444 gtk_box_pack_start(GTK_BOX(actionarea), frdp->find, FALSE, FALSE, 0); |
1843 gtk_widget_grab_default(frdp->find); | 2445 gtk_widget_grab_default(frdp->find); |
1844 | 2446 |
1845 if (do_replace) | 2447 if (do_replace) |
1846 { | 2448 { |
1847 /* 'Replace' button */ | 2449 /* 'Replace' button */ |
2450 #if GTK_CHECK_VERSION(3,10,0) | |
2451 frdp->replace = create_image_button(NULL, _("Replace")); | |
2452 #else | |
1848 frdp->replace = create_image_button(GTK_STOCK_CONVERT, _("Replace")); | 2453 frdp->replace = create_image_button(GTK_STOCK_CONVERT, _("Replace")); |
2454 #endif | |
1849 gtk_widget_set_sensitive(frdp->replace, sensitive); | 2455 gtk_widget_set_sensitive(frdp->replace, sensitive); |
2456 #if GTK_CHECK_VERSION(3,0,0) | |
2457 gtk_widget_set_can_default(frdp->find, TRUE); | |
2458 #else | |
1850 GTK_WIDGET_SET_FLAGS(frdp->replace, GTK_CAN_DEFAULT); | 2459 GTK_WIDGET_SET_FLAGS(frdp->replace, GTK_CAN_DEFAULT); |
2460 #endif | |
1851 gtk_box_pack_start(GTK_BOX(actionarea), frdp->replace, FALSE, FALSE, 0); | 2461 gtk_box_pack_start(GTK_BOX(actionarea), frdp->replace, FALSE, FALSE, 0); |
2462 #if GTK_CHECK_VERSION(3,0,0) | |
2463 g_signal_connect(G_OBJECT(frdp->replace), "clicked", | |
2464 G_CALLBACK(find_replace_cb), | |
2465 GINT_TO_POINTER(FRD_REPLACE)); | |
2466 #else | |
1852 gtk_signal_connect(GTK_OBJECT(frdp->replace), "clicked", | 2467 gtk_signal_connect(GTK_OBJECT(frdp->replace), "clicked", |
1853 GTK_SIGNAL_FUNC(find_replace_cb), | 2468 GTK_SIGNAL_FUNC(find_replace_cb), |
1854 GINT_TO_POINTER(FRD_REPLACE)); | 2469 GINT_TO_POINTER(FRD_REPLACE)); |
2470 #endif | |
1855 | 2471 |
1856 /* 'Replace All' button */ | 2472 /* 'Replace All' button */ |
2473 #if GTK_CHECK_VERSION(3,10,0) | |
2474 frdp->all = create_image_button(NULL, _("Replace All")); | |
2475 #else | |
1857 frdp->all = create_image_button(GTK_STOCK_CONVERT, _("Replace All")); | 2476 frdp->all = create_image_button(GTK_STOCK_CONVERT, _("Replace All")); |
2477 #endif | |
1858 gtk_widget_set_sensitive(frdp->all, sensitive); | 2478 gtk_widget_set_sensitive(frdp->all, sensitive); |
2479 #if GTK_CHECK_VERSION(3,0,0) | |
2480 gtk_widget_set_can_default(frdp->all, TRUE); | |
2481 #else | |
1859 GTK_WIDGET_SET_FLAGS(frdp->all, GTK_CAN_DEFAULT); | 2482 GTK_WIDGET_SET_FLAGS(frdp->all, GTK_CAN_DEFAULT); |
2483 #endif | |
1860 gtk_box_pack_start(GTK_BOX(actionarea), frdp->all, FALSE, FALSE, 0); | 2484 gtk_box_pack_start(GTK_BOX(actionarea), frdp->all, FALSE, FALSE, 0); |
2485 #if GTK_CHECK_VERSION(3,0,0) | |
2486 g_signal_connect(G_OBJECT(frdp->all), "clicked", | |
2487 G_CALLBACK(find_replace_cb), | |
2488 GINT_TO_POINTER(FRD_REPLACEALL)); | |
2489 #else | |
1861 gtk_signal_connect(GTK_OBJECT(frdp->all), "clicked", | 2490 gtk_signal_connect(GTK_OBJECT(frdp->all), "clicked", |
1862 GTK_SIGNAL_FUNC(find_replace_cb), | 2491 GTK_SIGNAL_FUNC(find_replace_cb), |
1863 GINT_TO_POINTER(FRD_REPLACEALL)); | 2492 GINT_TO_POINTER(FRD_REPLACEALL)); |
2493 #endif | |
1864 } | 2494 } |
1865 | 2495 |
1866 /* 'Cancel' button */ | 2496 /* 'Cancel' button */ |
2497 #if GTK_CHECK_VERSION(3,10,0) | |
2498 tmp = gtk_button_new_with_mnemonic(_("_Close")); | |
2499 #else | |
1867 tmp = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | 2500 tmp = gtk_button_new_from_stock(GTK_STOCK_CLOSE); |
2501 #endif | |
2502 #if GTK_CHECK_VERSION(3,0,0) | |
2503 gtk_widget_set_can_default(tmp, TRUE); | |
2504 #else | |
1868 GTK_WIDGET_SET_FLAGS(tmp, GTK_CAN_DEFAULT); | 2505 GTK_WIDGET_SET_FLAGS(tmp, GTK_CAN_DEFAULT); |
2506 #endif | |
1869 gtk_box_pack_end(GTK_BOX(actionarea), tmp, FALSE, FALSE, 0); | 2507 gtk_box_pack_end(GTK_BOX(actionarea), tmp, FALSE, FALSE, 0); |
2508 #if GTK_CHECK_VERSION(3,0,0) | |
2509 g_signal_connect_swapped(G_OBJECT(tmp), | |
2510 "clicked", G_CALLBACK(gtk_widget_hide), | |
2511 G_OBJECT(frdp->dialog)); | |
2512 g_signal_connect_swapped(G_OBJECT(frdp->dialog), | |
2513 "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), | |
2514 G_OBJECT(frdp->dialog)); | |
2515 #else | |
1870 gtk_signal_connect_object(GTK_OBJECT(tmp), | 2516 gtk_signal_connect_object(GTK_OBJECT(tmp), |
1871 "clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), | 2517 "clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), |
1872 GTK_OBJECT(frdp->dialog)); | 2518 GTK_OBJECT(frdp->dialog)); |
1873 gtk_signal_connect_object(GTK_OBJECT(frdp->dialog), | 2519 gtk_signal_connect_object(GTK_OBJECT(frdp->dialog), |
1874 "delete_event", GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete), | 2520 "delete_event", GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete), |
1875 GTK_OBJECT(frdp->dialog)); | 2521 GTK_OBJECT(frdp->dialog)); |
1876 | 2522 #endif |
2523 | |
2524 #if GTK_CHECK_VERSION(3,2,0) | |
2525 tmp = gtk_separator_new(GTK_ORIENTATION_VERTICAL); | |
2526 #else | |
1877 tmp = gtk_vseparator_new(); | 2527 tmp = gtk_vseparator_new(); |
2528 #endif | |
1878 gtk_box_pack_end(GTK_BOX(hbox), tmp, FALSE, FALSE, 10); | 2529 gtk_box_pack_end(GTK_BOX(hbox), tmp, FALSE, FALSE, 10); |
1879 | 2530 |
1880 /* Suppress automatic show of the unused action area */ | 2531 /* Suppress automatic show of the unused action area */ |
2532 #if GTK_CHECK_VERSION(3,0,0) | |
2533 # if !GTK_CHECK_VERSION(3,12,0) | |
2534 gtk_widget_hide(gtk_dialog_get_action_area(GTK_DIALOG(frdp->dialog))); | |
2535 # endif | |
2536 #else | |
1881 gtk_widget_hide(GTK_DIALOG(frdp->dialog)->action_area); | 2537 gtk_widget_hide(GTK_DIALOG(frdp->dialog)->action_area); |
2538 #endif | |
1882 gtk_widget_show_all(hbox); | 2539 gtk_widget_show_all(hbox); |
1883 gtk_widget_show(frdp->dialog); | 2540 gtk_widget_show(frdp->dialog); |
1884 | 2541 |
1885 vim_free(entry_text); | 2542 vim_free(entry_text); |
1886 vim_free(conv_buffer); | 2543 vim_free(conv_buffer); |
1926 repl_text = (char_u *)gtk_entry_get_text(GTK_ENTRY(repl_widgets.with)); | 2583 repl_text = (char_u *)gtk_entry_get_text(GTK_ENTRY(repl_widgets.with)); |
1927 sfr = &repl_widgets; | 2584 sfr = &repl_widgets; |
1928 } | 2585 } |
1929 | 2586 |
1930 find_text = (char_u *)gtk_entry_get_text(GTK_ENTRY(sfr->what)); | 2587 find_text = (char_u *)gtk_entry_get_text(GTK_ENTRY(sfr->what)); |
2588 #if GTK_CHECK_VERSION(3,0,0) | |
2589 direction_down = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->down)); | |
2590 #else | |
1931 direction_down = GTK_TOGGLE_BUTTON(sfr->down)->active; | 2591 direction_down = GTK_TOGGLE_BUTTON(sfr->down)->active; |
1932 | 2592 #endif |
2593 | |
2594 #if GTK_CHECK_VERSION(3,0,0) | |
2595 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->wword))) | |
2596 #else | |
1933 if (GTK_TOGGLE_BUTTON(sfr->wword)->active) | 2597 if (GTK_TOGGLE_BUTTON(sfr->wword)->active) |
2598 #endif | |
1934 flags |= FRD_WHOLE_WORD; | 2599 flags |= FRD_WHOLE_WORD; |
2600 #if GTK_CHECK_VERSION(3,0,0) | |
2601 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->mcase))) | |
2602 #else | |
1935 if (GTK_TOGGLE_BUTTON(sfr->mcase)->active) | 2603 if (GTK_TOGGLE_BUTTON(sfr->mcase)->active) |
2604 #endif | |
1936 flags |= FRD_MATCH_CASE; | 2605 flags |= FRD_MATCH_CASE; |
1937 | 2606 |
1938 repl_text = CONVERT_FROM_UTF8(repl_text); | 2607 repl_text = CONVERT_FROM_UTF8(repl_text); |
1939 find_text = CONVERT_FROM_UTF8(find_text); | 2608 find_text = CONVERT_FROM_UTF8(find_text); |
1940 gui_do_findrepl(flags, find_text, repl_text, direction_down); | 2609 gui_do_findrepl(flags, find_text, repl_text, direction_down); |