Mercurial > vim
comparison src/gui_gtk.c @ 2275:e4d849f4df03 vim73
Remove the old and not well supported GTK 1 code. (James Vega)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 25 Jun 2010 05:37:59 +0200 |
parents | 89dc68c0ab6f |
children | 6f63294a1781 |
comparison
equal
deleted
inserted
replaced
2274:7c31d761ffa9 | 2275:e4d849f4df03 |
---|---|
60 # define ENABLE_NLS /* so the texts in the dialog boxes are translated */ | 60 # define ENABLE_NLS /* so the texts in the dialog boxes are translated */ |
61 # endif | 61 # endif |
62 # include <gnome.h> | 62 # include <gnome.h> |
63 #endif | 63 #endif |
64 | 64 |
65 #if defined(FEAT_GUI_DIALOG) && !defined(HAVE_GTK2) | |
66 # include "../pixmaps/alert.xpm" | |
67 # include "../pixmaps/error.xpm" | |
68 # include "../pixmaps/generic.xpm" | |
69 # include "../pixmaps/info.xpm" | |
70 # include "../pixmaps/quest.xpm" | |
71 #endif | |
72 | |
73 #if defined(FEAT_TOOLBAR) && !defined(HAVE_GTK2) | |
74 /* | |
75 * Icons used by the toolbar code. | |
76 */ | |
77 #include "../pixmaps/tb_new.xpm" | |
78 #include "../pixmaps/tb_open.xpm" | |
79 #include "../pixmaps/tb_close.xpm" | |
80 #include "../pixmaps/tb_save.xpm" | |
81 #include "../pixmaps/tb_print.xpm" | |
82 #include "../pixmaps/tb_cut.xpm" | |
83 #include "../pixmaps/tb_copy.xpm" | |
84 #include "../pixmaps/tb_paste.xpm" | |
85 #include "../pixmaps/tb_find.xpm" | |
86 #include "../pixmaps/tb_find_next.xpm" | |
87 #include "../pixmaps/tb_find_prev.xpm" | |
88 #include "../pixmaps/tb_find_help.xpm" | |
89 #include "../pixmaps/tb_exit.xpm" | |
90 #include "../pixmaps/tb_undo.xpm" | |
91 #include "../pixmaps/tb_redo.xpm" | |
92 #include "../pixmaps/tb_help.xpm" | |
93 #include "../pixmaps/tb_macro.xpm" | |
94 #include "../pixmaps/tb_make.xpm" | |
95 #include "../pixmaps/tb_save_all.xpm" | |
96 #include "../pixmaps/tb_jump.xpm" | |
97 #include "../pixmaps/tb_ctags.xpm" | |
98 #include "../pixmaps/tb_load_session.xpm" | |
99 #include "../pixmaps/tb_save_session.xpm" | |
100 #include "../pixmaps/tb_new_session.xpm" | |
101 #include "../pixmaps/tb_blank.xpm" | |
102 #include "../pixmaps/tb_maximize.xpm" | |
103 #include "../pixmaps/tb_split.xpm" | |
104 #include "../pixmaps/tb_minimize.xpm" | |
105 #include "../pixmaps/tb_shell.xpm" | |
106 #include "../pixmaps/tb_replace.xpm" | |
107 #include "../pixmaps/tb_vsplit.xpm" | |
108 #include "../pixmaps/tb_maxwidth.xpm" | |
109 #include "../pixmaps/tb_minwidth.xpm" | |
110 #endif /* FEAT_TOOLBAR && !HAVE_GTK2 */ | |
111 | |
112 #ifdef FEAT_GUI_GTK | 65 #ifdef FEAT_GUI_GTK |
113 # include <gdk/gdkkeysyms.h> | 66 # include <gdk/gdkkeysyms.h> |
114 # include <gdk/gdk.h> | 67 # include <gdk/gdk.h> |
115 # ifdef WIN3264 | 68 # ifdef WIN3264 |
116 # include <gdk/gdkwin32.h> | 69 # include <gdk/gdkwin32.h> |
135 #endif | 88 #endif |
136 | 89 |
137 static void entry_activate_cb(GtkWidget *widget, gpointer data); | 90 static void entry_activate_cb(GtkWidget *widget, gpointer data); |
138 static void entry_changed_cb(GtkWidget *entry, GtkWidget *dialog); | 91 static void entry_changed_cb(GtkWidget *entry, GtkWidget *dialog); |
139 static void find_replace_cb(GtkWidget *widget, gpointer data); | 92 static void find_replace_cb(GtkWidget *widget, gpointer data); |
140 #ifndef HAVE_GTK2 | 93 |
141 static void gui_gtk_position_in_parent(GtkWidget *parent, GtkWidget *child, gui_win_pos_T where); | 94 #if defined(FEAT_TOOLBAR) |
142 #endif | |
143 | |
144 #if defined(FEAT_TOOLBAR) && defined(HAVE_GTK2) | |
145 /* | 95 /* |
146 * Table from BuiltIn## icon indices to GTK+ stock IDs. Order must exactly | 96 * Table from BuiltIn## icon indices to GTK+ stock IDs. Order must exactly |
147 * match toolbar_names[] in menu.c! All stock icons including the "vim-*" | 97 * match toolbar_names[] in menu.c! All stock icons including the "vim-*" |
148 * ones can be overridden in your gtkrc file. | 98 * ones can be overridden in your gtkrc file. |
149 */ | 99 */ |
296 if (gtk_socket_id != 0) | 246 if (gtk_socket_id != 0) |
297 gtk_widget_grab_focus(gui.drawarea); | 247 gtk_widget_grab_focus(gui.drawarea); |
298 | 248 |
299 return TRUE; | 249 return TRUE; |
300 } | 250 } |
301 #endif /* FEAT_TOOLBAR && HAVE_GTK2 */ | 251 #endif /* FEAT_TOOLBAR */ |
302 | 252 |
303 #if (defined(FEAT_TOOLBAR) && defined(HAVE_GTK2)) || defined(PROTO) | 253 #if defined(FEAT_TOOLBAR) || defined(PROTO) |
304 | 254 |
305 void | 255 void |
306 gui_gtk_register_stock_icons(void) | 256 gui_gtk_register_stock_icons(void) |
307 { | 257 { |
308 # include "../pixmaps/stock_icons.h" | 258 # include "../pixmaps/stock_icons.h" |
328 # undef ADD_ICON | 278 # undef ADD_ICON |
329 gtk_icon_factory_add_default(factory); | 279 gtk_icon_factory_add_default(factory); |
330 g_object_unref(factory); | 280 g_object_unref(factory); |
331 } | 281 } |
332 | 282 |
333 #endif /* FEAT_TOOLBAR && HAVE_GTK2 */ | 283 #endif /* FEAT_TOOLBAR */ |
334 | 284 |
335 | |
336 /* | |
337 * Only use accelerators when gtk_menu_ensure_uline_accel_group() is | |
338 * available, which is in version 1.2.1. That was the first version where | |
339 * accelerators properly worked (according to the change log). | |
340 */ | |
341 #ifdef GTK_CHECK_VERSION | |
342 # if GTK_CHECK_VERSION(1, 2, 1) | |
343 # define GTK_USE_ACCEL | |
344 # endif | |
345 #endif | |
346 | 285 |
347 #if defined(FEAT_MENU) || defined(PROTO) | 286 #if defined(FEAT_MENU) || defined(PROTO) |
348 | 287 |
349 /* | 288 /* |
350 * Translate Vim's mnemonic tagging to GTK+ style and convert to UTF-8 | 289 * Translate Vim's mnemonic tagging to GTK+ style and convert to UTF-8 |
362 char_u *buf; | 301 char_u *buf; |
363 char_u *psrc; | 302 char_u *psrc; |
364 char_u *pdest; | 303 char_u *pdest; |
365 int n_underscores = 0; | 304 int n_underscores = 0; |
366 | 305 |
367 # ifdef HAVE_GTK2 | |
368 name = CONVERT_TO_UTF8(name); | 306 name = CONVERT_TO_UTF8(name); |
369 # endif | |
370 if (name == NULL) | 307 if (name == NULL) |
371 return NULL; | 308 return NULL; |
372 | 309 |
373 for (psrc = name; *psrc != NUL && *psrc != TAB; ++psrc) | 310 for (psrc = name; *psrc != NUL && *psrc != TAB; ++psrc) |
374 if (*psrc == '_') | 311 if (*psrc == '_') |
399 } | 336 } |
400 } | 337 } |
401 *pdest = NUL; | 338 *pdest = NUL; |
402 } | 339 } |
403 | 340 |
404 # ifdef HAVE_GTK2 | |
405 CONVERT_TO_UTF8_FREE(name); | 341 CONVERT_TO_UTF8_FREE(name); |
406 # endif | |
407 return buf; | 342 return buf; |
408 } | 343 } |
409 | |
410 # ifdef HAVE_GTK2 | |
411 | 344 |
412 static void | 345 static void |
413 menu_item_new(vimmenu_T *menu, GtkWidget *parent_widget) | 346 menu_item_new(vimmenu_T *menu, GtkWidget *parent_widget) |
414 { | 347 { |
415 GtkWidget *box; | 348 GtkWidget *box; |
443 | 376 |
444 gtk_container_add(GTK_CONTAINER(menu->id), box); | 377 gtk_container_add(GTK_CONTAINER(menu->id), box); |
445 gtk_widget_show_all(menu->id); | 378 gtk_widget_show_all(menu->id); |
446 } | 379 } |
447 | 380 |
448 # else /* !HAVE_GTK2 */ | |
449 | |
450 /* | |
451 * Create a highly customized menu item by hand instead of by using: | |
452 * | |
453 * gtk_menu_item_new_with_label(menu->dname); | |
454 * | |
455 * This is necessary, since there is no other way in GTK+ 1 to get the | |
456 * not automatically parsed accelerator stuff right. | |
457 */ | |
458 static void | |
459 menu_item_new(vimmenu_T *menu, GtkWidget *parent_widget) | |
460 { | |
461 GtkWidget *widget; | |
462 GtkWidget *bin; | |
463 GtkWidget *label; | |
464 char_u *name; | |
465 guint accel_key; | |
466 | |
467 widget = gtk_widget_new(GTK_TYPE_MENU_ITEM, | |
468 "GtkWidget::visible", TRUE, | |
469 "GtkWidget::sensitive", TRUE, | |
470 /* "GtkWidget::parent", parent->submenu_id, */ | |
471 NULL); | |
472 bin = gtk_widget_new(GTK_TYPE_HBOX, | |
473 "GtkWidget::visible", TRUE, | |
474 "GtkWidget::parent", widget, | |
475 "GtkBox::spacing", 16, | |
476 NULL); | |
477 label = gtk_widget_new(GTK_TYPE_ACCEL_LABEL, | |
478 "GtkWidget::visible", TRUE, | |
479 "GtkWidget::parent", bin, | |
480 "GtkAccelLabel::accel_widget", widget, | |
481 "GtkMisc::xalign", 0.0, | |
482 NULL); | |
483 menu->label = label; | |
484 | |
485 if (menu->actext) | |
486 gtk_widget_new(GTK_TYPE_LABEL, | |
487 "GtkWidget::visible", TRUE, | |
488 "GtkWidget::parent", bin, | |
489 "GtkLabel::label", menu->actext, | |
490 "GtkMisc::xalign", 1.0, | |
491 NULL); | |
492 | |
493 /* | |
494 * Translate VIM accelerator tagging into GTK+'s. Note that since GTK uses | |
495 * underscores as the accelerator key, we need to add an additional under- | |
496 * score for each understore that appears in the menu name. | |
497 */ | |
498 # ifdef GTK_USE_ACCEL | |
499 name = translate_mnemonic_tag(menu->name, | |
500 (p_wak[0] != 'n' || !GTK_IS_MENU_BAR(parent_widget))); | |
501 # else | |
502 name = translate_mnemonic_tag(menu->name, FALSE); | |
503 # endif | |
504 | |
505 /* let GTK do its thing */ | |
506 accel_key = gtk_label_parse_uline(GTK_LABEL(label), (const char *)name); | |
507 vim_free(name); | |
508 | |
509 # ifdef GTK_USE_ACCEL | |
510 /* Don't add accelator if 'winaltkeys' is "no". */ | |
511 if (accel_key != GDK_VoidSymbol) | |
512 { | |
513 if (GTK_IS_MENU_BAR(parent_widget)) | |
514 { | |
515 if (*p_wak != 'n') | |
516 gtk_widget_add_accelerator(widget, | |
517 "activate_item", | |
518 gui.accel_group, | |
519 accel_key, GDK_MOD1_MASK, | |
520 (GtkAccelFlags)0); | |
521 } | |
522 else | |
523 { | |
524 gtk_widget_add_accelerator(widget, | |
525 "activate_item", | |
526 gtk_menu_ensure_uline_accel_group(GTK_MENU(parent_widget)), | |
527 accel_key, 0, | |
528 (GtkAccelFlags)0); | |
529 } | |
530 } | |
531 # endif /* GTK_USE_ACCEL */ | |
532 | |
533 menu->id = widget; | |
534 } | |
535 | |
536 # endif /* !HAVE_GTK2 */ | |
537 | |
538 void | 381 void |
539 gui_mch_add_menu(vimmenu_T *menu, int idx) | 382 gui_mch_add_menu(vimmenu_T *menu, int idx) |
540 { | 383 { |
541 vimmenu_T *parent; | 384 vimmenu_T *parent; |
542 GtkWidget *parent_widget; | 385 GtkWidget *parent_widget; |
559 /* since the tearoff should always appear first, increment idx */ | 402 /* since the tearoff should always appear first, increment idx */ |
560 if (parent != NULL && !menu_is_popup(parent->name)) | 403 if (parent != NULL && !menu_is_popup(parent->name)) |
561 ++idx; | 404 ++idx; |
562 | 405 |
563 gtk_menu_shell_insert(GTK_MENU_SHELL(parent_widget), menu->id, idx); | 406 gtk_menu_shell_insert(GTK_MENU_SHELL(parent_widget), menu->id, idx); |
564 | |
565 #ifndef HAVE_GTK2 | |
566 /* | |
567 * The "Help" menu is a special case, and should be placed at the far | |
568 * right hand side of the menu-bar. It's detected by its high priority. | |
569 * | |
570 * Right-aligning "Help" is considered bad UI design nowadays. | |
571 * Thus lets disable this for GTK+ 2 to match the environment. | |
572 */ | |
573 if (parent == NULL && menu->priority >= 9999) | |
574 gtk_menu_item_right_justify(GTK_MENU_ITEM(menu->id)); | |
575 #endif | |
576 | 407 |
577 menu->submenu_id = gtk_menu_new(); | 408 menu->submenu_id = gtk_menu_new(); |
578 | 409 |
579 gtk_menu_set_accel_group(GTK_MENU(menu->submenu_id), gui.accel_group); | 410 gtk_menu_set_accel_group(GTK_MENU(menu->submenu_id), gui.accel_group); |
580 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu->id), menu->submenu_id); | 411 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu->id), menu->submenu_id); |
588 static void | 419 static void |
589 menu_item_activate(GtkWidget *widget UNUSED, gpointer data) | 420 menu_item_activate(GtkWidget *widget UNUSED, gpointer data) |
590 { | 421 { |
591 gui_menu_cb((vimmenu_T *)data); | 422 gui_menu_cb((vimmenu_T *)data); |
592 | 423 |
593 # ifndef HAVE_GTK2 | |
594 /* Work around a bug in GTK+ 1: we don't seem to get a focus-in | |
595 * event after clicking a menu item shown via :popup. */ | |
596 if (!gui.in_focus) | |
597 gui_focus_change(TRUE); | |
598 # endif | |
599 | |
600 /* make sure the menu action is taken immediately */ | 424 /* make sure the menu action is taken immediately */ |
601 if (gtk_main_level() > 0) | 425 if (gtk_main_level() > 0) |
602 gtk_main_quit(); | 426 gtk_main_quit(); |
603 } | 427 } |
604 | |
605 # if defined(FEAT_TOOLBAR) && !defined(HAVE_GTK2) | |
606 /* | |
607 * These are the pixmaps used for the default buttons. | |
608 * Order must exactly match toolbar_names[] in menu.c! | |
609 */ | |
610 static char **(built_in_pixmaps[]) = | |
611 { | |
612 tb_new_xpm, | |
613 tb_open_xpm, | |
614 tb_save_xpm, | |
615 tb_undo_xpm, | |
616 tb_redo_xpm, | |
617 tb_cut_xpm, | |
618 tb_copy_xpm, | |
619 tb_paste_xpm, | |
620 tb_print_xpm, | |
621 tb_help_xpm, | |
622 tb_find_xpm, | |
623 tb_save_all_xpm, | |
624 tb_save_session_xpm, | |
625 tb_new_session_xpm, | |
626 tb_load_session_xpm, | |
627 tb_macro_xpm, | |
628 tb_replace_xpm, | |
629 tb_close_xpm, | |
630 tb_maximize_xpm, | |
631 tb_minimize_xpm, | |
632 tb_split_xpm, | |
633 tb_shell_xpm, | |
634 tb_find_prev_xpm, | |
635 tb_find_next_xpm, | |
636 tb_find_help_xpm, | |
637 tb_make_xpm, | |
638 tb_jump_xpm, | |
639 tb_ctags_xpm, | |
640 tb_vsplit_xpm, | |
641 tb_maxwidth_xpm, | |
642 tb_minwidth_xpm, | |
643 tb_exit_xpm | |
644 }; | |
645 | |
646 /* | |
647 * creates a blank pixmap using tb_blank | |
648 */ | |
649 static void | |
650 pixmap_create_from_xpm(char **xpm, GdkPixmap **pixmap, GdkBitmap **mask) | |
651 { | |
652 *pixmap = gdk_pixmap_colormap_create_from_xpm_d( | |
653 NULL, | |
654 gtk_widget_get_colormap(gui.mainwin), | |
655 mask, | |
656 NULL, | |
657 xpm); | |
658 } | |
659 | |
660 /* | |
661 * creates a pixmap by using a built-in number | |
662 */ | |
663 static void | |
664 pixmap_create_by_num(int pixmap_num, GdkPixmap **pixmap, GdkBitmap **mask) | |
665 { | |
666 if (pixmap_num >= 0 && pixmap_num < (sizeof(built_in_pixmaps) | |
667 / sizeof(built_in_pixmaps[0]))) | |
668 pixmap_create_from_xpm(built_in_pixmaps[pixmap_num], pixmap, mask); | |
669 } | |
670 | |
671 /* | |
672 * Creates a pixmap by using the pixmap "name" found in 'runtimepath'/bitmaps/ | |
673 */ | |
674 static void | |
675 pixmap_create_by_dir(char_u *name, GdkPixmap **pixmap, GdkBitmap **mask) | |
676 { | |
677 char_u full_pathname[MAXPATHL + 1]; | |
678 | |
679 if (gui_find_bitmap(name, full_pathname, "xpm") == OK) | |
680 *pixmap = gdk_pixmap_colormap_create_from_xpm( | |
681 NULL, | |
682 gtk_widget_get_colormap(gui.mainwin), | |
683 mask, | |
684 &gui.mainwin->style->bg[GTK_STATE_NORMAL], | |
685 (const char *)full_pathname); | |
686 } | |
687 | |
688 /* | |
689 * Creates a pixmap by using the pixmap "fname". | |
690 */ | |
691 static void | |
692 pixmap_create_from_file(char_u *fname, GdkPixmap **pixmap, GdkBitmap **mask) | |
693 { | |
694 *pixmap = gdk_pixmap_colormap_create_from_xpm( | |
695 NULL, | |
696 gtk_widget_get_colormap(gui.mainwin), | |
697 mask, | |
698 &gui.mainwin->style->bg[GTK_STATE_NORMAL], | |
699 (const char *)fname); | |
700 } | |
701 | |
702 # endif /* FEAT_TOOLBAR && !HAVE_GTK2 */ | |
703 | 428 |
704 void | 429 void |
705 gui_mch_add_menu_item(vimmenu_T *menu, int idx) | 430 gui_mch_add_menu_item(vimmenu_T *menu, int idx) |
706 { | 431 { |
707 vimmenu_T *parent; | 432 vimmenu_T *parent; |
721 gtk_toolbar_insert_space(toolbar, idx); | 446 gtk_toolbar_insert_space(toolbar, idx); |
722 menu->id = NULL; | 447 menu->id = NULL; |
723 } | 448 } |
724 else | 449 else |
725 { | 450 { |
726 # ifdef HAVE_GTK2 | |
727 char_u *text; | 451 char_u *text; |
728 char_u *tooltip; | 452 char_u *tooltip; |
729 | 453 |
730 text = CONVERT_TO_UTF8(menu->dname); | 454 text = CONVERT_TO_UTF8(menu->dname); |
731 tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); | 455 tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); |
748 gtk_signal_connect(GTK_OBJECT(menu->id), "focus_in_event", | 472 gtk_signal_connect(GTK_OBJECT(menu->id), "focus_in_event", |
749 GTK_SIGNAL_FUNC(toolbar_button_focus_in_event), NULL); | 473 GTK_SIGNAL_FUNC(toolbar_button_focus_in_event), NULL); |
750 | 474 |
751 CONVERT_TO_UTF8_FREE(text); | 475 CONVERT_TO_UTF8_FREE(text); |
752 CONVERT_TO_UTF8_FREE(tooltip); | 476 CONVERT_TO_UTF8_FREE(tooltip); |
753 | |
754 # else /* !HAVE_GTK2 */ | |
755 | |
756 GdkPixmap *pixmap = NULL; | |
757 GdkBitmap *mask = NULL; | |
758 | |
759 /* First try user specified bitmap, then builtin, the a blank. */ | |
760 if (menu->iconfile != NULL) | |
761 { | |
762 char_u buf[MAXPATHL + 1]; | |
763 | |
764 gui_find_iconfile(menu->iconfile, buf, "xpm"); | |
765 pixmap_create_from_file(buf, &pixmap, &mask); | |
766 } | |
767 if (pixmap == NULL && !menu->icon_builtin) | |
768 pixmap_create_by_dir(menu->name, &pixmap, &mask); | |
769 if (pixmap == NULL && menu->iconidx >= 0) | |
770 pixmap_create_by_num(menu->iconidx, &pixmap, &mask); | |
771 if (pixmap == NULL) | |
772 pixmap_create_from_xpm(tb_blank_xpm, &pixmap, &mask); | |
773 if (pixmap == NULL) | |
774 return; /* should at least have blank pixmap, but if not... */ | |
775 | |
776 menu->id = gtk_toolbar_insert_item( | |
777 toolbar, | |
778 (char *)(menu->dname), | |
779 (char *)(menu->strings[MENU_INDEX_TIP]), | |
780 (char *)(menu->dname), | |
781 gtk_pixmap_new(pixmap, mask), | |
782 GTK_SIGNAL_FUNC(menu_item_activate), | |
783 (gpointer)menu, | |
784 idx); | |
785 # endif /* !HAVE_GTK2 */ | |
786 } | 477 } |
787 } | 478 } |
788 else | 479 else |
789 # endif /* FEAT_TOOLBAR */ | 480 # endif /* FEAT_TOOLBAR */ |
790 { | 481 { |
835 void | 526 void |
836 gui_gtk_set_mnemonics(int enable) | 527 gui_gtk_set_mnemonics(int enable) |
837 { | 528 { |
838 vimmenu_T *menu; | 529 vimmenu_T *menu; |
839 char_u *name; | 530 char_u *name; |
840 # if !defined(HAVE_GTK2) && defined(GTK_USE_ACCEL) | |
841 guint accel_key; | |
842 # endif | |
843 | 531 |
844 for (menu = root_menu; menu != NULL; menu = menu->next) | 532 for (menu = root_menu; menu != NULL; menu = menu->next) |
845 { | 533 { |
846 if (menu->id == NULL) | 534 if (menu->id == NULL) |
847 continue; | 535 continue; |
848 | 536 |
849 # if defined(HAVE_GTK2) | |
850 name = translate_mnemonic_tag(menu->name, enable); | 537 name = translate_mnemonic_tag(menu->name, enable); |
851 gtk_label_set_text_with_mnemonic(GTK_LABEL(menu->label), | 538 gtk_label_set_text_with_mnemonic(GTK_LABEL(menu->label), |
852 (const char *)name); | 539 (const char *)name); |
853 vim_free(name); | 540 vim_free(name); |
854 # else | |
855 # if defined(GTK_USE_ACCEL) | |
856 name = translate_mnemonic_tag(menu->name, TRUE); | |
857 if (name != NULL) | |
858 { | |
859 accel_key = gtk_label_parse_uline(GTK_LABEL(menu->label), | |
860 (const char *)name); | |
861 if (accel_key != GDK_VoidSymbol) | |
862 gtk_widget_remove_accelerator(menu->id, gui.accel_group, | |
863 accel_key, GDK_MOD1_MASK); | |
864 if (enable && accel_key != GDK_VoidSymbol) | |
865 gtk_widget_add_accelerator(menu->id, "activate_item", | |
866 gui.accel_group, | |
867 accel_key, GDK_MOD1_MASK, | |
868 (GtkAccelFlags)0); | |
869 vim_free(name); | |
870 } | |
871 if (!enable) | |
872 { | |
873 name = translate_mnemonic_tag(menu->name, FALSE); | |
874 gtk_label_parse_uline(GTK_LABEL(menu->label), (const char *)name); | |
875 vim_free(name); | |
876 } | |
877 # endif | |
878 # endif | |
879 } | 541 } |
880 } | 542 } |
881 | 543 |
882 static void | 544 static void |
883 recurse_tearoffs(vimmenu_T *menu, int val) | 545 recurse_tearoffs(vimmenu_T *menu, int val) |
901 { | 563 { |
902 recurse_tearoffs(root_menu, enable); | 564 recurse_tearoffs(root_menu, enable); |
903 } | 565 } |
904 #endif /* FEAT_MENU */ | 566 #endif /* FEAT_MENU */ |
905 | 567 |
906 | 568 #if defined(FEAT_TOOLBAR) |
907 #if defined(FEAT_TOOLBAR) && !defined(HAVE_GTK2) | |
908 /* | |
909 * Seems like there's a hole in the GTK Toolbar API: there's no provision for | |
910 * removing an item from the toolbar. Therefore I need to resort to going | |
911 * really deeply into the internal widget structures. | |
912 * | |
913 * <danielk> I'm not sure the statement above is true -- at least with | |
914 * GTK+ 2 one can just call gtk_widget_destroy() and be done with it. | |
915 * It is true though that you couldn't remove space items before GTK+ 2 | |
916 * (without digging into the internals that is). But the code below | |
917 * doesn't seem to handle those either. Well, it's obsolete anyway. | |
918 */ | |
919 static void | |
920 toolbar_remove_item_by_text(GtkToolbar *tb, const char *text) | |
921 { | |
922 GtkContainer *container; | |
923 GList *childl; | |
924 GtkToolbarChild *gtbc; | |
925 | |
926 g_return_if_fail(tb != NULL); | |
927 g_return_if_fail(GTK_IS_TOOLBAR(tb)); | |
928 container = GTK_CONTAINER(&tb->container); | |
929 | |
930 for (childl = tb->children; childl; childl = childl->next) | |
931 { | |
932 gtbc = (GtkToolbarChild *)childl->data; | |
933 | |
934 if (gtbc->type != GTK_TOOLBAR_CHILD_SPACE | |
935 && strcmp(GTK_LABEL(gtbc->label)->label, text) == 0) | |
936 { | |
937 gboolean was_visible; | |
938 | |
939 was_visible = GTK_WIDGET_VISIBLE(gtbc->widget); | |
940 gtk_widget_unparent(gtbc->widget); | |
941 | |
942 tb->children = g_list_remove_link(tb->children, childl); | |
943 g_free(gtbc); | |
944 g_list_free(childl); | |
945 tb->num_children--; | |
946 | |
947 if (was_visible && GTK_WIDGET_VISIBLE(container)) | |
948 gtk_widget_queue_resize(GTK_WIDGET(container)); | |
949 | |
950 break; | |
951 } | |
952 } | |
953 } | |
954 #endif /* FEAT_TOOLBAR && !HAVE_GTK2 */ | |
955 | |
956 | |
957 #if defined(FEAT_TOOLBAR) && defined(HAVE_GTK2) | |
958 static int | 569 static int |
959 get_menu_position(vimmenu_T *menu) | 570 get_menu_position(vimmenu_T *menu) |
960 { | 571 { |
961 vimmenu_T *node; | 572 vimmenu_T *node; |
962 int idx = 0; | 573 int idx = 0; |
967 ++idx; | 578 ++idx; |
968 } | 579 } |
969 | 580 |
970 return idx; | 581 return idx; |
971 } | 582 } |
972 #endif /* FEAT_TOOLBAR && HAVE_GTK2 */ | 583 #endif /* FEAT_TOOLBAR */ |
973 | 584 |
974 | 585 |
975 #if defined(FEAT_TOOLBAR) || defined(PROTO) | 586 #if defined(FEAT_TOOLBAR) || defined(PROTO) |
976 void | 587 void |
977 gui_mch_menu_set_tip(vimmenu_T *menu) | 588 gui_mch_menu_set_tip(vimmenu_T *menu) |
979 if (menu->id != NULL && menu->parent != NULL | 590 if (menu->id != NULL && menu->parent != NULL |
980 && gui.toolbar != NULL && menu_is_toolbar(menu->parent->name)) | 591 && gui.toolbar != NULL && menu_is_toolbar(menu->parent->name)) |
981 { | 592 { |
982 char_u *tooltip; | 593 char_u *tooltip; |
983 | 594 |
984 # ifdef HAVE_GTK2 | |
985 tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); | 595 tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); |
986 if (tooltip == NULL || utf_valid_string(tooltip, NULL)) | 596 if (tooltip == NULL || utf_valid_string(tooltip, NULL)) |
987 /* Only set the tooltip when it's valid utf-8. */ | 597 /* Only set the tooltip when it's valid utf-8. */ |
988 # else | |
989 tooltip = menu->strings[MENU_INDEX_TIP]; | |
990 # endif | |
991 gtk_tooltips_set_tip(GTK_TOOLBAR(gui.toolbar)->tooltips, | 598 gtk_tooltips_set_tip(GTK_TOOLBAR(gui.toolbar)->tooltips, |
992 menu->id, (const char *)tooltip, NULL); | 599 menu->id, (const char *)tooltip, NULL); |
993 # ifdef HAVE_GTK2 | |
994 CONVERT_TO_UTF8_FREE(tooltip); | 600 CONVERT_TO_UTF8_FREE(tooltip); |
995 # endif | |
996 } | 601 } |
997 } | 602 } |
998 #endif /* FEAT_TOOLBAR */ | 603 #endif /* FEAT_TOOLBAR */ |
999 | 604 |
1000 | 605 |
1006 gui_mch_destroy_menu(vimmenu_T *menu) | 611 gui_mch_destroy_menu(vimmenu_T *menu) |
1007 { | 612 { |
1008 # ifdef FEAT_TOOLBAR | 613 # ifdef FEAT_TOOLBAR |
1009 if (menu->parent != NULL && menu_is_toolbar(menu->parent->name)) | 614 if (menu->parent != NULL && menu_is_toolbar(menu->parent->name)) |
1010 { | 615 { |
1011 # ifdef HAVE_GTK2 | |
1012 if (menu_is_separator(menu->name)) | 616 if (menu_is_separator(menu->name)) |
1013 gtk_toolbar_remove_space(GTK_TOOLBAR(gui.toolbar), | 617 gtk_toolbar_remove_space(GTK_TOOLBAR(gui.toolbar), |
1014 get_menu_position(menu)); | 618 get_menu_position(menu)); |
1015 else if (menu->id != NULL) | 619 else if (menu->id != NULL) |
1016 gtk_widget_destroy(menu->id); | 620 gtk_widget_destroy(menu->id); |
1017 # else | |
1018 toolbar_remove_item_by_text(GTK_TOOLBAR(gui.toolbar), | |
1019 (const char *)menu->dname); | |
1020 # endif | |
1021 } | 621 } |
1022 else | 622 else |
1023 # endif /* FEAT_TOOLBAR */ | 623 # endif /* FEAT_TOOLBAR */ |
1024 { | 624 { |
1025 if (menu->submenu_id != NULL) | 625 if (menu->submenu_id != NULL) |
1052 adjustment->upper = max + 1; | 652 adjustment->upper = max + 1; |
1053 adjustment->page_size = size; | 653 adjustment->page_size = size; |
1054 adjustment->page_increment = size < 3L ? 1L : size - 2L; | 654 adjustment->page_increment = size < 3L ? 1L : size - 2L; |
1055 adjustment->step_increment = 1.0; | 655 adjustment->step_increment = 1.0; |
1056 | 656 |
1057 #ifdef HAVE_GTK2 | |
1058 g_signal_handler_block(GTK_OBJECT(adjustment), | 657 g_signal_handler_block(GTK_OBJECT(adjustment), |
1059 (gulong)sb->handler_id); | 658 (gulong)sb->handler_id); |
1060 #else | |
1061 gtk_signal_handler_block(GTK_OBJECT(adjustment), | |
1062 (guint)sb->handler_id); | |
1063 #endif | |
1064 gtk_adjustment_changed(adjustment); | 659 gtk_adjustment_changed(adjustment); |
1065 #ifdef HAVE_GTK2 | |
1066 g_signal_handler_unblock(GTK_OBJECT(adjustment), | 660 g_signal_handler_unblock(GTK_OBJECT(adjustment), |
1067 (gulong)sb->handler_id); | 661 (gulong)sb->handler_id); |
1068 #else | |
1069 gtk_signal_handler_unblock(GTK_OBJECT(adjustment), | |
1070 (guint)sb->handler_id); | |
1071 #endif | |
1072 } | 662 } |
1073 } | 663 } |
1074 | 664 |
1075 void | 665 void |
1076 gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h) | 666 gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h) |
1106 * HACK: Get the mouse pointer position, if it appears to be on an arrow | 696 * HACK: Get the mouse pointer position, if it appears to be on an arrow |
1107 * button set "dragging" to FALSE. This assumes square buttons! | 697 * button set "dragging" to FALSE. This assumes square buttons! |
1108 */ | 698 */ |
1109 if (sb != NULL) | 699 if (sb != NULL) |
1110 { | 700 { |
1111 #ifdef HAVE_GTK2 | |
1112 dragging = TRUE; | 701 dragging = TRUE; |
1113 | 702 |
1114 if (sb->wp != NULL) | 703 if (sb->wp != NULL) |
1115 { | 704 { |
1116 int x; | 705 int x; |
1137 dragging = FALSE; | 726 dragging = FALSE; |
1138 value = sb->wp->w_topline; | 727 value = sb->wp->w_topline; |
1139 } | 728 } |
1140 } | 729 } |
1141 } | 730 } |
1142 #else | |
1143 dragging = (GTK_RANGE(sb->id)->scroll_type == GTK_SCROLL_NONE); | |
1144 #endif | |
1145 } | 731 } |
1146 | 732 |
1147 gui_drag_scrollbar(sb, value, dragging); | 733 gui_drag_scrollbar(sb, value, dragging); |
1148 | 734 |
1149 if (gtk_main_level() > 0) | 735 if (gtk_main_level() > 0) |
1191 | 777 |
1192 #if defined(FEAT_BROWSE) || defined(PROTO) | 778 #if defined(FEAT_BROWSE) || defined(PROTO) |
1193 /* | 779 /* |
1194 * Implementation of the file selector related stuff | 780 * Implementation of the file selector related stuff |
1195 */ | 781 */ |
1196 #if defined(HAVE_GTK2) && GTK_CHECK_VERSION(2,4,0) | 782 #if GTK_CHECK_VERSION(2,4,0) |
1197 /* This has been disabled, because the GTK library rewrites | 783 /* This has been disabled, because the GTK library rewrites |
1198 * ~/.recently-used.xbel every time the main loop is quit. For Vim that means | 784 * ~/.recently-used.xbel every time the main loop is quit. For Vim that means |
1199 * on just about any event. */ | 785 * on just about any event. */ |
1200 /* # define USE_FILE_CHOOSER */ | 786 /* # define USE_FILE_CHOOSER */ |
1201 #endif | 787 #endif |
1269 #ifdef USE_FILE_CHOOSER | 855 #ifdef USE_FILE_CHOOSER |
1270 GtkWidget *fc; | 856 GtkWidget *fc; |
1271 #endif | 857 #endif |
1272 char_u dirbuf[MAXPATHL]; | 858 char_u dirbuf[MAXPATHL]; |
1273 | 859 |
1274 # ifdef HAVE_GTK2 | |
1275 title = CONVERT_TO_UTF8(title); | 860 title = CONVERT_TO_UTF8(title); |
1276 # endif | |
1277 | 861 |
1278 /* GTK has a bug, it only works with an absolute path. */ | 862 /* GTK has a bug, it only works with an absolute path. */ |
1279 if (initdir == NULL || *initdir == NUL) | 863 if (initdir == NULL || *initdir == NUL) |
1280 mch_dirname(dirbuf, MAXPATHL); | 864 mch_dirname(dirbuf, MAXPATHL); |
1281 else if (vim_FullName(initdir, dirbuf, MAXPATHL - 2, FALSE) == FAIL) | 865 else if (vim_FullName(initdir, dirbuf, MAXPATHL - 2, FALSE) == FAIL) |
1341 && STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL) | 925 && STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL) |
1342 STRCAT(dirbuf, dflt); | 926 STRCAT(dirbuf, dflt); |
1343 | 927 |
1344 gtk_file_selection_set_filename(GTK_FILE_SELECTION(gui.filedlg), | 928 gtk_file_selection_set_filename(GTK_FILE_SELECTION(gui.filedlg), |
1345 (const gchar *)dirbuf); | 929 (const gchar *)dirbuf); |
1346 # ifndef HAVE_GTK2 | |
1347 gui_gtk_position_in_parent(GTK_WIDGET(gui.mainwin), | |
1348 GTK_WIDGET(gui.filedlg), VW_POS_MOUSE); | |
1349 # endif | |
1350 | 930 |
1351 gtk_widget_show(gui.filedlg); | 931 gtk_widget_show(gui.filedlg); |
1352 while (gui.filedlg && GTK_WIDGET_DRAWABLE(gui.filedlg)) | 932 while (gui.filedlg && GTK_WIDGET_DRAWABLE(gui.filedlg)) |
1353 gtk_main_iteration_do(TRUE); | 933 gtk_main_iteration_do(TRUE); |
1354 #endif | 934 #endif |
1355 | 935 |
1356 # ifdef HAVE_GTK2 | |
1357 CONVERT_TO_UTF8_FREE(title); | 936 CONVERT_TO_UTF8_FREE(title); |
1358 # endif | |
1359 if (gui.browse_fname == NULL) | 937 if (gui.browse_fname == NULL) |
1360 return NULL; | 938 return NULL; |
1361 | 939 |
1362 /* shorten the file name if possible */ | 940 /* shorten the file name if possible */ |
1363 return vim_strsave(shorten_fname1(gui.browse_fname)); | 941 return vim_strsave(shorten_fname1(gui.browse_fname)); |
1364 } | 942 } |
1365 | |
1366 #if defined(HAVE_GTK2) || defined(PROTO) | |
1367 | 943 |
1368 /* | 944 /* |
1369 * Put up a directory selector | 945 * Put up a directory selector |
1370 * Returns the selected name in allocated memory, or NULL for Cancel. | 946 * Returns the selected name in allocated memory, or NULL for Cancel. |
1371 * title title for the window | 947 * title title for the window |
1426 # else | 1002 # else |
1427 /* For GTK 2.2 and earlier: fall back to ordinary file selector. */ | 1003 /* For GTK 2.2 and earlier: fall back to ordinary file selector. */ |
1428 return gui_mch_browse(0, title, NULL, NULL, initdir, NULL); | 1004 return gui_mch_browse(0, title, NULL, NULL, initdir, NULL); |
1429 # endif | 1005 # endif |
1430 } | 1006 } |
1431 #endif | |
1432 | 1007 |
1433 | 1008 |
1434 #endif /* FEAT_BROWSE */ | 1009 #endif /* FEAT_BROWSE */ |
1435 | 1010 |
1436 #if defined(FEAT_GUI_DIALOG) && !defined(HAVE_GTK2) | 1011 #if defined(FEAT_GUI_DIALOG) || defined(PROTO) |
1437 | |
1438 static char_u *dialog_textfield = NULL; | |
1439 static GtkWidget *dialog_textentry; | |
1440 | |
1441 static void | |
1442 dlg_destroy(GtkWidget *dlg) | |
1443 { | |
1444 if (dialog_textfield != NULL) | |
1445 { | |
1446 const char *text; | |
1447 | |
1448 text = gtk_entry_get_text(GTK_ENTRY(dialog_textentry)); | |
1449 vim_strncpy(dialog_textfield, (char_u *)text, IOSIZE - 1); | |
1450 } | |
1451 | |
1452 /* Destroy the dialog, will break the waiting loop. */ | |
1453 gtk_widget_destroy(dlg); | |
1454 } | |
1455 | |
1456 # ifdef FEAT_GUI_GNOME | |
1457 static int | |
1458 gui_gnome_dialog( int type, | |
1459 char_u *title, | |
1460 char_u *message, | |
1461 char_u *buttons, | |
1462 int dfltbutton, | |
1463 char_u *textfield) | |
1464 { | |
1465 GtkWidget *dlg; | |
1466 char *gdtype; | |
1467 char_u *buttons_copy, *p, *next; | |
1468 char **buttons_list; | |
1469 int butcount, cur; | |
1470 | |
1471 /* make a copy, so that we can insert NULs */ | |
1472 if ((buttons_copy = vim_strsave(buttons)) == NULL) | |
1473 return -1; | |
1474 | |
1475 /* determine exact number of buttons and allocate array to hold them */ | |
1476 for (butcount = 0, p = buttons; *p; p++) | |
1477 { | |
1478 if (*p == '\n') | |
1479 butcount++; | |
1480 } | |
1481 butcount++; | |
1482 buttons_list = g_new0(char *, butcount + 1); | |
1483 | |
1484 /* Add pixmap */ | |
1485 switch (type) | |
1486 { | |
1487 case VIM_ERROR: | |
1488 gdtype = GNOME_MESSAGE_BOX_ERROR; | |
1489 break; | |
1490 case VIM_WARNING: | |
1491 gdtype = GNOME_MESSAGE_BOX_WARNING; | |
1492 break; | |
1493 case VIM_INFO: | |
1494 gdtype = GNOME_MESSAGE_BOX_INFO; | |
1495 break; | |
1496 case VIM_QUESTION: | |
1497 gdtype = GNOME_MESSAGE_BOX_QUESTION; | |
1498 break; | |
1499 default: | |
1500 gdtype = GNOME_MESSAGE_BOX_GENERIC; | |
1501 }; | |
1502 | |
1503 p = buttons_copy; | |
1504 for (cur = 0; cur < butcount; ++cur) | |
1505 { | |
1506 for (next = p; *next; ++next) | |
1507 { | |
1508 if (*next == DLG_HOTKEY_CHAR) | |
1509 STRMOVE(next, next + 1); | |
1510 if (*next == DLG_BUTTON_SEP) | |
1511 { | |
1512 *next++ = NUL; | |
1513 break; | |
1514 } | |
1515 } | |
1516 | |
1517 /* this should probably go into a table, but oh well */ | |
1518 if (g_strcasecmp((char *)p, "Ok") == 0) | |
1519 buttons_list[cur] = g_strdup(GNOME_STOCK_BUTTON_OK); | |
1520 else if (g_strcasecmp((char *)p, "Cancel") == 0) | |
1521 buttons_list[cur] = g_strdup(GNOME_STOCK_BUTTON_CANCEL); | |
1522 else if (g_strcasecmp((char *)p, "Yes") == 0) | |
1523 buttons_list[cur] = g_strdup(GNOME_STOCK_BUTTON_YES); | |
1524 else if (g_strcasecmp((char *)p, "No") == 0) | |
1525 buttons_list[cur] = g_strdup(GNOME_STOCK_BUTTON_NO); | |
1526 else if (g_strcasecmp((char *)p, "Close") == 0) | |
1527 buttons_list[cur] = g_strdup(GNOME_STOCK_BUTTON_CLOSE); | |
1528 else if (g_strcasecmp((char *)p, "Help") == 0) | |
1529 buttons_list[cur] = g_strdup(GNOME_STOCK_BUTTON_HELP); | |
1530 else if (g_strcasecmp((char *)p, "Apply") == 0) | |
1531 buttons_list[cur] = g_strdup(GNOME_STOCK_BUTTON_APPLY); | |
1532 #if 0 | |
1533 /* | |
1534 * these aren't really used that often anyway, but are listed here as | |
1535 * placeholders in case we need them. | |
1536 */ | |
1537 else if (g_strcasecmp((char *)p, "Next") == 0) | |
1538 buttons_list[cur] = g_strdup(GNOME_STOCK_BUTTON_NEXT); | |
1539 else if (g_strcasecmp((char *)p, "Prev") == 0) | |
1540 buttons_list[cur] = g_strdup(GNOME_STOCK_BUTTON_PREV); | |
1541 else if (g_strcasecmp((char *)p, "Up") == 0) | |
1542 buttons_list[cur] = g_strdup(GNOME_STOCK_BUTTON_UP); | |
1543 else if (g_strcasecmp((char *)p, "Down") == 0) | |
1544 buttons_list[cur] = g_strdup(GNOME_STOCK_BUTTON_DOWN); | |
1545 else if (g_strcasecmp((char *)p, "Font") == 0) | |
1546 buttons_list[cur] = g_strdup(GNOME_STOCK_BUTTON_FONT); | |
1547 #endif | |
1548 else | |
1549 buttons_list[cur] = g_strdup((char *)p); | |
1550 | |
1551 if (*next == NUL) | |
1552 break; | |
1553 | |
1554 p = next; | |
1555 } | |
1556 vim_free(buttons_copy); | |
1557 | |
1558 dlg = gnome_message_box_newv((const char *)message, | |
1559 (const char *)gdtype, | |
1560 (const char **)buttons_list); | |
1561 for (cur = 0; cur < butcount; ++cur) | |
1562 g_free(buttons_list[cur]); | |
1563 g_free(buttons_list); | |
1564 | |
1565 dialog_textfield = textfield; | |
1566 if (textfield != NULL) | |
1567 { | |
1568 /* Add text entry field */ | |
1569 dialog_textentry = gtk_entry_new(); | |
1570 gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dlg)->vbox), dialog_textentry, | |
1571 TRUE, TRUE, 0); | |
1572 gtk_entry_set_text(GTK_ENTRY(dialog_textentry), | |
1573 (const gchar *)textfield); | |
1574 gtk_entry_select_region(GTK_ENTRY(dialog_textentry), 0, | |
1575 STRLEN(textfield)); | |
1576 gtk_entry_set_max_length(GTK_ENTRY(dialog_textentry), IOSIZE - 1); | |
1577 gtk_entry_set_position(GTK_ENTRY(dialog_textentry), STRLEN(textfield)); | |
1578 gtk_widget_show(dialog_textentry); | |
1579 gtk_window_set_focus(GTK_WINDOW(dlg), dialog_textentry); | |
1580 } | |
1581 | |
1582 gtk_signal_connect_object(GTK_OBJECT(dlg), "destroy", | |
1583 GTK_SIGNAL_FUNC(dlg_destroy), GTK_OBJECT(dlg)); | |
1584 gnome_dialog_set_default(GNOME_DIALOG(dlg), dfltbutton + 1); | |
1585 gui_gtk_position_in_parent(GTK_WIDGET(gui.mainwin), | |
1586 GTK_WIDGET(dlg), VW_POS_MOUSE); | |
1587 | |
1588 return (1 + gnome_dialog_run_and_close(GNOME_DIALOG(dlg))); | |
1589 } | |
1590 | |
1591 # endif /* FEAT_GUI_GNOME */ | |
1592 | |
1593 typedef struct _ButtonData | |
1594 { | |
1595 int *status; | |
1596 int index; | |
1597 GtkWidget *dialog; | |
1598 } ButtonData; | |
1599 | |
1600 typedef struct _CancelData | |
1601 { | |
1602 int *status; | |
1603 int ignore_enter; | |
1604 GtkWidget *dialog; | |
1605 } CancelData; | |
1606 | |
1607 static void | |
1608 dlg_button_clicked(GtkWidget * widget, ButtonData *data) | |
1609 { | |
1610 *(data->status) = data->index + 1; | |
1611 dlg_destroy(data->dialog); | |
1612 } | |
1613 | |
1614 /* | |
1615 * This makes the Escape key equivalent to the cancel button. | |
1616 */ | |
1617 static int | |
1618 dlg_key_press_event(GtkWidget *widget, GdkEventKey *event, CancelData *data) | |
1619 { | |
1620 /* Ignore hitting Enter (or Space) when there is no default button. */ | |
1621 if (data->ignore_enter && (event->keyval == GDK_Return | |
1622 || event->keyval == ' ')) | |
1623 return TRUE; | |
1624 else /* A different key was pressed, return to normal behavior */ | |
1625 data->ignore_enter = FALSE; | |
1626 | |
1627 if (event->keyval != GDK_Escape && event->keyval != GDK_Return) | |
1628 return FALSE; | |
1629 | |
1630 /* The result value of 0 from a dialog is signaling cancelation. | |
1631 * 1 means OK. */ | |
1632 *(data->status) = (event->keyval == GDK_Return); | |
1633 dlg_destroy(data->dialog); | |
1634 | |
1635 return TRUE; | |
1636 } | |
1637 | |
1638 /* | |
1639 * Callback function for when the dialog was destroyed by a window manager. | |
1640 */ | |
1641 static void | |
1642 dlg_destroy_cb(int *p) | |
1643 { | |
1644 *p = TRUE; /* set dialog_destroyed to break out of the loop */ | |
1645 if (gtk_main_level() > 0) | |
1646 gtk_main_quit(); | |
1647 } | |
1648 | |
1649 int | |
1650 gui_mch_dialog( int type, /* type of dialog */ | |
1651 char_u *title, /* title of dialog */ | |
1652 char_u *message, /* message text */ | |
1653 char_u *buttons, /* names of buttons */ | |
1654 int def_but, /* default button */ | |
1655 char_u *textfield) /* text for textfield or NULL */ | |
1656 { | |
1657 char_u *names; | |
1658 char_u *p; | |
1659 int i; | |
1660 int butcount; | |
1661 int dialog_status = -1; | |
1662 int dialog_destroyed = FALSE; | |
1663 int vertical; | |
1664 | |
1665 GtkWidget *dialog; | |
1666 GtkWidget *frame; | |
1667 GtkWidget *vbox; | |
1668 GtkWidget *table; | |
1669 GtkWidget *dialogmessage; | |
1670 GtkWidget *action_area; | |
1671 GtkWidget *sub_area; | |
1672 GtkWidget *separator; | |
1673 GtkAccelGroup *accel_group; | |
1674 GtkWidget *pixmap; | |
1675 GdkPixmap *icon = NULL; | |
1676 GdkBitmap *mask = NULL; | |
1677 char **icon_data = NULL; | |
1678 | |
1679 GtkWidget **button; | |
1680 ButtonData *data; | |
1681 CancelData cancel_data; | |
1682 | |
1683 /* if our pointer is currently hidden, then we should show it. */ | |
1684 gui_mch_mousehide(FALSE); | |
1685 | |
1686 # ifdef FEAT_GUI_GNOME | |
1687 /* If Gnome is available, use it for the dialog. */ | |
1688 if (gtk_socket_id == 0) | |
1689 return gui_gnome_dialog(type, title, message, buttons, def_but, | |
1690 textfield); | |
1691 # endif | |
1692 | |
1693 if (title == NULL) | |
1694 title = (char_u *)_("Vim dialog..."); | |
1695 | |
1696 if ((type < 0) || (type > VIM_LAST_TYPE)) | |
1697 type = VIM_GENERIC; | |
1698 | |
1699 /* Check 'v' flag in 'guioptions': vertical button placement. */ | |
1700 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL); | |
1701 | |
1702 dialog = gtk_window_new(GTK_WINDOW_DIALOG); | |
1703 gtk_window_set_title(GTK_WINDOW(dialog), (const gchar *)title); | |
1704 gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(gui.mainwin)); | |
1705 gtk_widget_realize(dialog); | |
1706 gdk_window_set_decorations(dialog->window, GDK_DECOR_BORDER); | |
1707 gdk_window_set_functions(dialog->window, GDK_FUNC_MOVE); | |
1708 | |
1709 cancel_data.status = &dialog_status; | |
1710 cancel_data.dialog = dialog; | |
1711 gtk_signal_connect_after(GTK_OBJECT(dialog), "key_press_event", | |
1712 GTK_SIGNAL_FUNC(dlg_key_press_event), | |
1713 (gpointer) &cancel_data); | |
1714 /* Catch the destroy signal, otherwise we don't notice a window manager | |
1715 * destroying the dialog window. */ | |
1716 gtk_signal_connect_object(GTK_OBJECT(dialog), "destroy", | |
1717 GTK_SIGNAL_FUNC(dlg_destroy_cb), | |
1718 (gpointer)&dialog_destroyed); | |
1719 | |
1720 gtk_grab_add(dialog); | |
1721 | |
1722 /* this makes it look beter on Motif style window managers */ | |
1723 frame = gtk_frame_new(NULL); | |
1724 gtk_container_add(GTK_CONTAINER(dialog), frame); | |
1725 gtk_widget_show(frame); | |
1726 | |
1727 vbox = gtk_vbox_new(FALSE, 0); | |
1728 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
1729 gtk_widget_show(vbox); | |
1730 | |
1731 table = gtk_table_new(1, 3, FALSE); | |
1732 gtk_table_set_row_spacings(GTK_TABLE(table), 4); | |
1733 gtk_table_set_col_spacings(GTK_TABLE(table), 8); | |
1734 gtk_container_border_width(GTK_CONTAINER(table), 4); | |
1735 gtk_box_pack_start(GTK_BOX(vbox), table, 4, 4, 0); | |
1736 gtk_widget_show(table); | |
1737 | |
1738 /* Add pixmap */ | |
1739 switch (type) | |
1740 { | |
1741 case VIM_GENERIC: | |
1742 icon_data = generic_xpm; | |
1743 break; | |
1744 case VIM_ERROR: | |
1745 icon_data = error_xpm; | |
1746 break; | |
1747 case VIM_WARNING: | |
1748 icon_data = alert_xpm; | |
1749 break; | |
1750 case VIM_INFO: | |
1751 icon_data = info_xpm; | |
1752 break; | |
1753 case VIM_QUESTION: | |
1754 icon_data = quest_xpm; | |
1755 break; | |
1756 default: | |
1757 icon_data = generic_xpm; | |
1758 }; | |
1759 icon = gdk_pixmap_colormap_create_from_xpm_d(NULL, | |
1760 gtk_widget_get_colormap(dialog), | |
1761 &mask, NULL, icon_data); | |
1762 if (icon) | |
1763 { | |
1764 pixmap = gtk_pixmap_new(icon, mask); | |
1765 /* gtk_misc_set_alignment(GTK_MISC(pixmap), 0.5, 0.5); */ | |
1766 gtk_table_attach_defaults(GTK_TABLE(table), pixmap, 0, 1, 0, 1); | |
1767 gtk_widget_show(pixmap); | |
1768 } | |
1769 | |
1770 /* Add label */ | |
1771 dialogmessage = gtk_label_new((const gchar *)message); | |
1772 gtk_table_attach_defaults(GTK_TABLE(table), dialogmessage, 1, 2, 0, 1); | |
1773 gtk_widget_show(dialogmessage); | |
1774 | |
1775 dialog_textfield = textfield; | |
1776 if (textfield != NULL) | |
1777 { | |
1778 /* Add text entry field */ | |
1779 dialog_textentry = gtk_entry_new(); | |
1780 gtk_widget_set_usize(dialog_textentry, 400, -2); | |
1781 gtk_box_pack_start(GTK_BOX(vbox), dialog_textentry, TRUE, TRUE, 0); | |
1782 gtk_entry_set_text(GTK_ENTRY(dialog_textentry), | |
1783 (const gchar *)textfield); | |
1784 gtk_entry_select_region(GTK_ENTRY(dialog_textentry), 0, | |
1785 STRLEN(textfield)); | |
1786 gtk_entry_set_max_length(GTK_ENTRY(dialog_textentry), IOSIZE - 1); | |
1787 gtk_entry_set_position(GTK_ENTRY(dialog_textentry), STRLEN(textfield)); | |
1788 gtk_widget_show(dialog_textentry); | |
1789 } | |
1790 | |
1791 /* Add box for buttons */ | |
1792 action_area = gtk_hbox_new(FALSE, 0); | |
1793 gtk_container_border_width(GTK_CONTAINER(action_area), 4); | |
1794 gtk_box_pack_end(GTK_BOX(vbox), action_area, FALSE, TRUE, 0); | |
1795 gtk_widget_show(action_area); | |
1796 | |
1797 /* Add a [vh]box in the hbox to center the buttons in the dialog. */ | |
1798 if (vertical) | |
1799 sub_area = gtk_vbox_new(FALSE, 0); | |
1800 else | |
1801 sub_area = gtk_hbox_new(FALSE, 0); | |
1802 gtk_container_set_border_width(GTK_CONTAINER(sub_area), 0); | |
1803 gtk_box_pack_start(GTK_BOX(action_area), sub_area, TRUE, FALSE, 0); | |
1804 gtk_widget_show(sub_area); | |
1805 | |
1806 /* | |
1807 * Create the buttons. | |
1808 */ | |
1809 | |
1810 /* | |
1811 * Translate the Vim accelerator character into an underscore for GTK+. | |
1812 * Double underscores to keep them in the label. | |
1813 */ | |
1814 /* count the number of underscores */ | |
1815 i = 1; | |
1816 for (p = buttons; *p; ++p) | |
1817 if (*p == '_') | |
1818 ++i; | |
1819 | |
1820 /* make a copy of "buttons" with the translated characters */ | |
1821 names = alloc(STRLEN(buttons) + i); | |
1822 if (names == NULL) | |
1823 return -1; | |
1824 | |
1825 p = names; | |
1826 for (i = 0; buttons[i]; ++i) | |
1827 { | |
1828 if (buttons[i] == DLG_HOTKEY_CHAR) | |
1829 *p++ = '_'; | |
1830 else | |
1831 { | |
1832 if (buttons[i] == '_') | |
1833 *p++ = '_'; | |
1834 *p++ = buttons[i]; | |
1835 } | |
1836 } | |
1837 *p = NUL; | |
1838 | |
1839 /* Count the number of buttons and allocate button[] and data[]. */ | |
1840 butcount = 1; | |
1841 for (p = names; *p; ++p) | |
1842 if (*p == DLG_BUTTON_SEP) | |
1843 ++butcount; | |
1844 button = (GtkWidget **)alloc((unsigned)(butcount * sizeof(GtkWidget *))); | |
1845 data = (ButtonData *)alloc((unsigned)(butcount * sizeof(ButtonData))); | |
1846 if (button == NULL || data == NULL) | |
1847 { | |
1848 vim_free(names); | |
1849 vim_free(button); | |
1850 vim_free(data); | |
1851 return -1; | |
1852 } | |
1853 | |
1854 /* Attach the new accelerator group to the window. */ | |
1855 accel_group = gtk_accel_group_new(); | |
1856 gtk_accel_group_attach(accel_group, GTK_OBJECT(dialog)); | |
1857 | |
1858 p = names; | |
1859 for (butcount = 0; *p; ++butcount) | |
1860 { | |
1861 char_u *next; | |
1862 GtkWidget *label; | |
1863 # ifdef GTK_USE_ACCEL | |
1864 guint accel_key; | |
1865 # endif | |
1866 | |
1867 /* Chunk out this single button. */ | |
1868 for (next = p; *next; ++next) | |
1869 { | |
1870 if (*next == DLG_BUTTON_SEP) | |
1871 { | |
1872 *next++ = NUL; | |
1873 break; | |
1874 } | |
1875 } | |
1876 | |
1877 button[butcount] = gtk_button_new(); | |
1878 GTK_WIDGET_SET_FLAGS(button[butcount], GTK_CAN_DEFAULT); | |
1879 | |
1880 label = gtk_accel_label_new(""); | |
1881 gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), dialog); | |
1882 | |
1883 # ifdef GTK_USE_ACCEL | |
1884 accel_key = gtk_label_parse_uline(GTK_LABEL(label), (const gchar *)p); | |
1885 /* Don't add accelator if 'winaltkeys' is "no". */ | |
1886 if (accel_key != GDK_VoidSymbol) | |
1887 { | |
1888 gtk_widget_add_accelerator(button[butcount], | |
1889 "clicked", | |
1890 accel_group, | |
1891 accel_key, 0, | |
1892 (GtkAccelFlags)0); | |
1893 } | |
1894 # else | |
1895 (void)gtk_label_parse_uline(GTK_LABEL(label), (const gchar *)p); | |
1896 # endif | |
1897 | |
1898 gtk_container_add(GTK_CONTAINER(button[butcount]), label); | |
1899 gtk_widget_show_all(button[butcount]); | |
1900 | |
1901 data[butcount].status = &dialog_status; | |
1902 data[butcount].index = butcount; | |
1903 data[butcount].dialog = dialog; | |
1904 gtk_signal_connect(GTK_OBJECT(button[butcount]), | |
1905 (const char *)"clicked", | |
1906 GTK_SIGNAL_FUNC(dlg_button_clicked), | |
1907 (gpointer) &data[butcount]); | |
1908 | |
1909 gtk_box_pack_start(GTK_BOX(sub_area), button[butcount], | |
1910 TRUE, FALSE, 0); | |
1911 p = next; | |
1912 } | |
1913 | |
1914 vim_free(names); | |
1915 | |
1916 cancel_data.ignore_enter = FALSE; | |
1917 if (butcount > 0) | |
1918 { | |
1919 --def_but; /* 1 is first button */ | |
1920 if (def_but >= butcount) | |
1921 def_but = -1; | |
1922 if (def_but >= 0) | |
1923 { | |
1924 gtk_widget_grab_focus(button[def_but]); | |
1925 gtk_widget_grab_default(button[def_but]); | |
1926 } | |
1927 else | |
1928 /* No default, ignore hitting Enter. */ | |
1929 cancel_data.ignore_enter = TRUE; | |
1930 } | |
1931 | |
1932 if (textfield != NULL) | |
1933 gtk_window_set_focus(GTK_WINDOW(dialog), dialog_textentry); | |
1934 | |
1935 separator = gtk_hseparator_new(); | |
1936 gtk_box_pack_end(GTK_BOX(vbox), separator, FALSE, TRUE, 0); | |
1937 gtk_widget_show(separator); | |
1938 | |
1939 dialog_status = -1; | |
1940 | |
1941 gui_gtk_position_in_parent(GTK_WIDGET(gui.mainwin), | |
1942 GTK_WIDGET(dialog), VW_POS_MOUSE); | |
1943 | |
1944 gtk_widget_show(dialog); | |
1945 | |
1946 /* loop here until the dialog goes away */ | |
1947 while (dialog_status == -1 && !dialog_destroyed | |
1948 && GTK_WIDGET_DRAWABLE(dialog)) | |
1949 gtk_main_iteration_do(TRUE); | |
1950 | |
1951 if (dialog_status < 0) | |
1952 dialog_status = 0; | |
1953 if (dialog_status != 1 && textfield != NULL) | |
1954 *textfield = NUL; /* dialog was cancelled */ | |
1955 | |
1956 /* let the garbage collector know that we don't need it any longer */ | |
1957 gtk_accel_group_unref(accel_group); | |
1958 | |
1959 vim_free(button); | |
1960 vim_free(data); | |
1961 | |
1962 return dialog_status; | |
1963 } | |
1964 | |
1965 #endif /* FEAT_GUI_DIALOG && !HAVE_GTK2 */ | |
1966 | |
1967 | |
1968 #if (defined(FEAT_GUI_DIALOG) && defined(HAVE_GTK2)) || defined(PROTO) | |
1969 | 1012 |
1970 static GtkWidget * | 1013 static GtkWidget * |
1971 create_message_dialog(int type, char_u *title, char_u *message) | 1014 create_message_dialog(int type, char_u *title, char_u *message) |
1972 { | 1015 { |
1973 GtkWidget *dialog; | 1016 GtkWidget *dialog; |
2314 } | 1357 } |
2315 | 1358 |
2316 return response > 0 ? response : 0; | 1359 return response > 0 ? response : 0; |
2317 } | 1360 } |
2318 | 1361 |
2319 #endif /* FEAT_GUI_DIALOG && HAVE_GTK2 */ | 1362 #endif /* FEAT_GUI_DIALOG */ |
2320 | 1363 |
2321 | 1364 |
2322 #if defined(FEAT_MENU) || defined(PROTO) | 1365 #if defined(FEAT_MENU) || defined(PROTO) |
2323 | 1366 |
2324 void | 1367 void |
2325 gui_mch_show_popupmenu(vimmenu_T *menu) | 1368 gui_mch_show_popupmenu(vimmenu_T *menu) |
2326 { | 1369 { |
2327 # if defined(FEAT_XIM) && defined(HAVE_GTK2) | 1370 # if defined(FEAT_XIM) |
2328 /* | 1371 /* |
2329 * Append a submenu for selecting an input method. This is | 1372 * Append a submenu for selecting an input method. This is |
2330 * currently the only way to switch input methods at runtime. | 1373 * currently the only way to switch input methods at runtime. |
2331 */ | 1374 */ |
2332 if (xic != NULL && g_object_get_data(G_OBJECT(menu->submenu_id), | 1375 if (xic != NULL && g_object_get_data(G_OBJECT(menu->submenu_id), |
2353 gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(xic), | 1396 gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(xic), |
2354 GTK_MENU_SHELL(submenu)); | 1397 GTK_MENU_SHELL(submenu)); |
2355 g_object_set_data(G_OBJECT(menu->submenu_id), | 1398 g_object_set_data(G_OBJECT(menu->submenu_id), |
2356 "vim-has-im-menu", GINT_TO_POINTER(TRUE)); | 1399 "vim-has-im-menu", GINT_TO_POINTER(TRUE)); |
2357 } | 1400 } |
2358 # endif /* FEAT_XIM && HAVE_GTK2 */ | 1401 # endif /* FEAT_XIM */ |
2359 | 1402 |
2360 gtk_menu_popup(GTK_MENU(menu->submenu_id), | 1403 gtk_menu_popup(GTK_MENU(menu->submenu_id), |
2361 NULL, NULL, | 1404 NULL, NULL, |
2362 (GtkMenuPositionFunc)NULL, NULL, | 1405 (GtkMenuPositionFunc)NULL, NULL, |
2363 3U, (guint32)GDK_CURRENT_TIME); | 1406 3U, (guint32)GDK_CURRENT_TIME); |
2375 * menus that don't fit on the screen. Leave it at the default for now. | 1418 * menus that don't fit on the screen. Leave it at the default for now. |
2376 */ | 1419 */ |
2377 static void | 1420 static void |
2378 popup_menu_position_func(GtkMenu *menu UNUSED, | 1421 popup_menu_position_func(GtkMenu *menu UNUSED, |
2379 gint *x, gint *y, | 1422 gint *x, gint *y, |
2380 # ifdef HAVE_GTK2 | |
2381 gboolean *push_in UNUSED, | 1423 gboolean *push_in UNUSED, |
2382 # endif | |
2383 gpointer user_data UNUSED) | 1424 gpointer user_data UNUSED) |
2384 { | 1425 { |
2385 gdk_window_get_origin(gui.drawarea->window, x, y); | 1426 gdk_window_get_origin(gui.drawarea->window, x, y); |
2386 | 1427 |
2387 if (popup_mouse_pos) | 1428 if (popup_mouse_pos) |
2459 { | 1500 { |
2460 gtk_widget_hide(frdp->dialog); | 1501 gtk_widget_hide(frdp->dialog); |
2461 | 1502 |
2462 return TRUE; | 1503 return TRUE; |
2463 } | 1504 } |
2464 /* | |
2465 * What the **** is this for? Disabled for GTK+ 2 because due to | |
2466 * gtk_signal_connect_after() it doesn't have any effect anyway. | |
2467 * (Fortunately.) | |
2468 */ | |
2469 #ifndef HAVE_GTK2 | |
2470 /* block traversal resulting from those keys */ | |
2471 if (event->keyval == GDK_Left | |
2472 || event->keyval == GDK_Right | |
2473 || event->keyval == GDK_space) | |
2474 return TRUE; | |
2475 #endif | |
2476 | 1505 |
2477 /* It would be delightful if it where possible to do search history | 1506 /* It would be delightful if it where possible to do search history |
2478 * operations on the K_UP and K_DOWN keys here. | 1507 * operations on the K_UP and K_DOWN keys here. |
2479 */ | 1508 */ |
2480 | 1509 |
2481 return FALSE; | 1510 return FALSE; |
2482 } | 1511 } |
2483 | 1512 |
2484 #ifdef HAVE_GTK2 | |
2485 static GtkWidget * | 1513 static GtkWidget * |
2486 create_image_button(const char *stock_id, const char *label) | 1514 create_image_button(const char *stock_id, const char *label) |
2487 { | 1515 { |
2488 char_u *text; | 1516 char_u *text; |
2489 GtkWidget *box; | 1517 GtkWidget *box; |
2527 vim_free(*buffer); | 1555 vim_free(*buffer); |
2528 *buffer = string_convert(&output_conv, (char_u *)message, NULL); | 1556 *buffer = string_convert(&output_conv, (char_u *)message, NULL); |
2529 | 1557 |
2530 return (const char *)*buffer; | 1558 return (const char *)*buffer; |
2531 } | 1559 } |
2532 #endif /* HAVE_GTK2 */ | |
2533 | 1560 |
2534 static void | 1561 static void |
2535 find_replace_dialog_create(char_u *arg, int do_replace) | 1562 find_replace_dialog_create(char_u *arg, int do_replace) |
2536 { | 1563 { |
2537 #ifndef HAVE_GTK2 | |
2538 GtkWidget *frame; | |
2539 #endif | |
2540 GtkWidget *hbox; /* main top down box */ | 1564 GtkWidget *hbox; /* main top down box */ |
2541 GtkWidget *actionarea; | 1565 GtkWidget *actionarea; |
2542 GtkWidget *table; | 1566 GtkWidget *table; |
2543 GtkWidget *tmp; | 1567 GtkWidget *tmp; |
2544 GtkWidget *vbox; | 1568 GtkWidget *vbox; |
2545 gboolean sensitive; | 1569 gboolean sensitive; |
2546 SharedFindReplace *frdp; | 1570 SharedFindReplace *frdp; |
2547 char_u *entry_text; | 1571 char_u *entry_text; |
2548 int wword = FALSE; | 1572 int wword = FALSE; |
2549 int mcase = !p_ic; | 1573 int mcase = !p_ic; |
2550 #ifdef HAVE_GTK2 | |
2551 char_u *conv_buffer = NULL; | 1574 char_u *conv_buffer = NULL; |
2552 # define CONV(message) convert_localized_message(&conv_buffer, (message)) | 1575 # define CONV(message) convert_localized_message(&conv_buffer, (message)) |
2553 #else | |
2554 # define CONV(message) (message) | |
2555 #endif | |
2556 | 1576 |
2557 frdp = (do_replace) ? (&repl_widgets) : (&find_widgets); | 1577 frdp = (do_replace) ? (&repl_widgets) : (&find_widgets); |
2558 | 1578 |
2559 /* Get the search string to use. */ | 1579 /* Get the search string to use. */ |
2560 entry_text = get_find_dialog_text(arg, &wword, &mcase); | 1580 entry_text = get_find_dialog_text(arg, &wword, &mcase); |
2561 | 1581 |
2562 #ifdef HAVE_GTK2 | |
2563 if (entry_text != NULL && output_conv.vc_type != CONV_NONE) | 1582 if (entry_text != NULL && output_conv.vc_type != CONV_NONE) |
2564 { | 1583 { |
2565 char_u *old_text = entry_text; | 1584 char_u *old_text = entry_text; |
2566 entry_text = string_convert(&output_conv, entry_text, NULL); | 1585 entry_text = string_convert(&output_conv, entry_text, NULL); |
2567 vim_free(old_text); | 1586 vim_free(old_text); |
2568 } | 1587 } |
2569 #endif | |
2570 | 1588 |
2571 /* | 1589 /* |
2572 * If the dialog already exists, just raise it. | 1590 * If the dialog already exists, just raise it. |
2573 */ | 1591 */ |
2574 if (frdp->dialog) | 1592 if (frdp->dialog) |
2575 { | 1593 { |
2576 #ifndef HAVE_GTK2 | |
2577 /* always make the dialog appear where you want it even if the mainwin | |
2578 * has moved -- dbv */ | |
2579 gui_gtk_position_in_parent(GTK_WIDGET(gui.mainwin), | |
2580 GTK_WIDGET(frdp->dialog), VW_POS_MOUSE); | |
2581 gui_gtk_synch_fonts(); | |
2582 | |
2583 if (!GTK_WIDGET_VISIBLE(frdp->dialog)) | |
2584 { | |
2585 gtk_widget_grab_focus(frdp->what); | |
2586 gtk_widget_show(frdp->dialog); | |
2587 } | |
2588 #endif | |
2589 if (entry_text != NULL) | 1594 if (entry_text != NULL) |
2590 { | 1595 { |
2591 gtk_entry_set_text(GTK_ENTRY(frdp->what), (char *)entry_text); | 1596 gtk_entry_set_text(GTK_ENTRY(frdp->what), (char *)entry_text); |
2592 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->wword), | 1597 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->wword), |
2593 (gboolean)wword); | 1598 (gboolean)wword); |
2594 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->mcase), | 1599 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->mcase), |
2595 (gboolean)mcase); | 1600 (gboolean)mcase); |
2596 } | 1601 } |
2597 #ifdef HAVE_GTK2 | |
2598 gtk_window_present(GTK_WINDOW(frdp->dialog)); | 1602 gtk_window_present(GTK_WINDOW(frdp->dialog)); |
2599 #else | |
2600 gdk_window_raise(frdp->dialog->window); | |
2601 #endif | |
2602 vim_free(entry_text); | 1603 vim_free(entry_text); |
2603 return; | 1604 return; |
2604 } | 1605 } |
2605 | 1606 |
2606 #ifdef HAVE_GTK2 | |
2607 frdp->dialog = gtk_dialog_new(); | 1607 frdp->dialog = gtk_dialog_new(); |
2608 gtk_dialog_set_has_separator(GTK_DIALOG(frdp->dialog), FALSE); | 1608 gtk_dialog_set_has_separator(GTK_DIALOG(frdp->dialog), FALSE); |
2609 gtk_window_set_transient_for(GTK_WINDOW(frdp->dialog), GTK_WINDOW(gui.mainwin)); | 1609 gtk_window_set_transient_for(GTK_WINDOW(frdp->dialog), GTK_WINDOW(gui.mainwin)); |
2610 gtk_window_set_destroy_with_parent(GTK_WINDOW(frdp->dialog), TRUE); | 1610 gtk_window_set_destroy_with_parent(GTK_WINDOW(frdp->dialog), TRUE); |
2611 #else | |
2612 frdp->dialog = gtk_window_new(GTK_WINDOW_DIALOG); | |
2613 #endif | |
2614 | 1611 |
2615 if (do_replace) | 1612 if (do_replace) |
2616 { | 1613 { |
2617 #ifndef HAVE_GTK2 | |
2618 gtk_window_set_wmclass(GTK_WINDOW(frdp->dialog), "searchrepl", "gvim"); | |
2619 #endif | |
2620 gtk_window_set_title(GTK_WINDOW(frdp->dialog), | 1614 gtk_window_set_title(GTK_WINDOW(frdp->dialog), |
2621 CONV(_("VIM - Search and Replace..."))); | 1615 CONV(_("VIM - Search and Replace..."))); |
2622 } | 1616 } |
2623 else | 1617 else |
2624 { | 1618 { |
2625 #ifndef HAVE_GTK2 | |
2626 gtk_window_set_wmclass(GTK_WINDOW(frdp->dialog), "search", "gvim"); | |
2627 #endif | |
2628 gtk_window_set_title(GTK_WINDOW(frdp->dialog), | 1619 gtk_window_set_title(GTK_WINDOW(frdp->dialog), |
2629 CONV(_("VIM - Search..."))); | 1620 CONV(_("VIM - Search..."))); |
2630 } | 1621 } |
2631 | 1622 |
2632 #ifndef HAVE_GTK2 /* Utter crack. Shudder. */ | |
2633 gtk_widget_realize(frdp->dialog); | |
2634 gdk_window_set_decorations(frdp->dialog->window, | |
2635 GDK_DECOR_TITLE | GDK_DECOR_BORDER | GDK_DECOR_RESIZEH); | |
2636 gdk_window_set_functions(frdp->dialog->window, | |
2637 GDK_FUNC_RESIZE | GDK_FUNC_MOVE); | |
2638 #endif | |
2639 | |
2640 #ifndef HAVE_GTK2 | |
2641 /* this makes it look better on Motif style window managers */ | |
2642 frame = gtk_frame_new(NULL); | |
2643 gtk_container_add(GTK_CONTAINER(frdp->dialog), frame); | |
2644 #endif | |
2645 | |
2646 hbox = gtk_hbox_new(FALSE, 0); | 1623 hbox = gtk_hbox_new(FALSE, 0); |
2647 #ifdef HAVE_GTK2 | |
2648 gtk_container_set_border_width(GTK_CONTAINER(hbox), 10); | 1624 gtk_container_set_border_width(GTK_CONTAINER(hbox), 10); |
2649 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(frdp->dialog)->vbox), hbox); | 1625 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(frdp->dialog)->vbox), hbox); |
2650 #else | |
2651 gtk_container_add(GTK_CONTAINER(frame), hbox); | |
2652 #endif | |
2653 | 1626 |
2654 if (do_replace) | 1627 if (do_replace) |
2655 table = gtk_table_new(1024, 4, FALSE); | 1628 table = gtk_table_new(1024, 4, FALSE); |
2656 else | 1629 else |
2657 table = gtk_table_new(1024, 3, FALSE); | 1630 table = gtk_table_new(1024, 3, FALSE); |
2745 gtk_box_pack_start(GTK_BOX(vbox), frdp->up, TRUE, TRUE, 0); | 1718 gtk_box_pack_start(GTK_BOX(vbox), frdp->up, TRUE, TRUE, 0); |
2746 frdp->down = gtk_radio_button_new_with_label( | 1719 frdp->down = gtk_radio_button_new_with_label( |
2747 gtk_radio_button_group(GTK_RADIO_BUTTON(frdp->up)), | 1720 gtk_radio_button_group(GTK_RADIO_BUTTON(frdp->up)), |
2748 CONV(_("Down"))); | 1721 CONV(_("Down"))); |
2749 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->down), TRUE); | 1722 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->down), TRUE); |
2750 #ifdef HAVE_GTK2 | |
2751 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2); | 1723 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2); |
2752 #endif | |
2753 gtk_box_pack_start(GTK_BOX(vbox), frdp->down, TRUE, TRUE, 0); | 1724 gtk_box_pack_start(GTK_BOX(vbox), frdp->down, TRUE, TRUE, 0); |
2754 | 1725 |
2755 /* vbox to hold the action buttons */ | 1726 /* vbox to hold the action buttons */ |
2756 actionarea = gtk_vbutton_box_new(); | 1727 actionarea = gtk_vbutton_box_new(); |
2757 gtk_container_border_width(GTK_CONTAINER(actionarea), 2); | 1728 gtk_container_border_width(GTK_CONTAINER(actionarea), 2); |
2758 #ifndef HAVE_GTK2 | |
2759 if (do_replace) | |
2760 { | |
2761 gtk_button_box_set_layout(GTK_BUTTON_BOX(actionarea), | |
2762 GTK_BUTTONBOX_END); | |
2763 gtk_button_box_set_spacing(GTK_BUTTON_BOX(actionarea), 0); | |
2764 } | |
2765 #endif | |
2766 gtk_box_pack_end(GTK_BOX(hbox), actionarea, FALSE, FALSE, 0); | 1729 gtk_box_pack_end(GTK_BOX(hbox), actionarea, FALSE, FALSE, 0); |
2767 | 1730 |
2768 /* 'Find Next' button */ | 1731 /* 'Find Next' button */ |
2769 #ifdef HAVE_GTK2 | |
2770 frdp->find = create_image_button(GTK_STOCK_FIND, _("Find Next")); | 1732 frdp->find = create_image_button(GTK_STOCK_FIND, _("Find Next")); |
2771 #else | |
2772 frdp->find = gtk_button_new_with_label(_("Find Next")); | |
2773 #endif | |
2774 gtk_widget_set_sensitive(frdp->find, sensitive); | 1733 gtk_widget_set_sensitive(frdp->find, sensitive); |
2775 | 1734 |
2776 gtk_signal_connect(GTK_OBJECT(frdp->find), "clicked", | 1735 gtk_signal_connect(GTK_OBJECT(frdp->find), "clicked", |
2777 GTK_SIGNAL_FUNC(find_replace_cb), | 1736 GTK_SIGNAL_FUNC(find_replace_cb), |
2778 (do_replace) ? GINT_TO_POINTER(FRD_R_FINDNEXT) | 1737 (do_replace) ? GINT_TO_POINTER(FRD_R_FINDNEXT) |
2783 gtk_widget_grab_default(frdp->find); | 1742 gtk_widget_grab_default(frdp->find); |
2784 | 1743 |
2785 if (do_replace) | 1744 if (do_replace) |
2786 { | 1745 { |
2787 /* 'Replace' button */ | 1746 /* 'Replace' button */ |
2788 #ifdef HAVE_GTK2 | |
2789 frdp->replace = create_image_button(GTK_STOCK_CONVERT, _("Replace")); | 1747 frdp->replace = create_image_button(GTK_STOCK_CONVERT, _("Replace")); |
2790 #else | |
2791 frdp->replace = gtk_button_new_with_label(_("Replace")); | |
2792 #endif | |
2793 gtk_widget_set_sensitive(frdp->replace, sensitive); | 1748 gtk_widget_set_sensitive(frdp->replace, sensitive); |
2794 GTK_WIDGET_SET_FLAGS(frdp->replace, GTK_CAN_DEFAULT); | 1749 GTK_WIDGET_SET_FLAGS(frdp->replace, GTK_CAN_DEFAULT); |
2795 gtk_box_pack_start(GTK_BOX(actionarea), frdp->replace, FALSE, FALSE, 0); | 1750 gtk_box_pack_start(GTK_BOX(actionarea), frdp->replace, FALSE, FALSE, 0); |
2796 gtk_signal_connect(GTK_OBJECT(frdp->replace), "clicked", | 1751 gtk_signal_connect(GTK_OBJECT(frdp->replace), "clicked", |
2797 GTK_SIGNAL_FUNC(find_replace_cb), | 1752 GTK_SIGNAL_FUNC(find_replace_cb), |
2798 GINT_TO_POINTER(FRD_REPLACE)); | 1753 GINT_TO_POINTER(FRD_REPLACE)); |
2799 | 1754 |
2800 /* 'Replace All' button */ | 1755 /* 'Replace All' button */ |
2801 #ifdef HAVE_GTK2 | |
2802 frdp->all = create_image_button(GTK_STOCK_CONVERT, _("Replace All")); | 1756 frdp->all = create_image_button(GTK_STOCK_CONVERT, _("Replace All")); |
2803 #else | |
2804 frdp->all = gtk_button_new_with_label(_("Replace All")); | |
2805 #endif | |
2806 gtk_widget_set_sensitive(frdp->all, sensitive); | 1757 gtk_widget_set_sensitive(frdp->all, sensitive); |
2807 GTK_WIDGET_SET_FLAGS(frdp->all, GTK_CAN_DEFAULT); | 1758 GTK_WIDGET_SET_FLAGS(frdp->all, GTK_CAN_DEFAULT); |
2808 gtk_box_pack_start(GTK_BOX(actionarea), frdp->all, FALSE, FALSE, 0); | 1759 gtk_box_pack_start(GTK_BOX(actionarea), frdp->all, FALSE, FALSE, 0); |
2809 gtk_signal_connect(GTK_OBJECT(frdp->all), "clicked", | 1760 gtk_signal_connect(GTK_OBJECT(frdp->all), "clicked", |
2810 GTK_SIGNAL_FUNC(find_replace_cb), | 1761 GTK_SIGNAL_FUNC(find_replace_cb), |
2811 GINT_TO_POINTER(FRD_REPLACEALL)); | 1762 GINT_TO_POINTER(FRD_REPLACEALL)); |
2812 } | 1763 } |
2813 | 1764 |
2814 /* 'Cancel' button */ | 1765 /* 'Cancel' button */ |
2815 #ifdef HAVE_GTK2 | |
2816 tmp = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | 1766 tmp = gtk_button_new_from_stock(GTK_STOCK_CLOSE); |
2817 #else | |
2818 tmp = gtk_button_new_with_label(_("Cancel")); | |
2819 #endif | |
2820 GTK_WIDGET_SET_FLAGS(tmp, GTK_CAN_DEFAULT); | 1767 GTK_WIDGET_SET_FLAGS(tmp, GTK_CAN_DEFAULT); |
2821 gtk_box_pack_end(GTK_BOX(actionarea), tmp, FALSE, FALSE, 0); | 1768 gtk_box_pack_end(GTK_BOX(actionarea), tmp, FALSE, FALSE, 0); |
2822 gtk_signal_connect_object(GTK_OBJECT(tmp), | 1769 gtk_signal_connect_object(GTK_OBJECT(tmp), |
2823 "clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), | 1770 "clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), |
2824 GTK_OBJECT(frdp->dialog)); | 1771 GTK_OBJECT(frdp->dialog)); |
2825 gtk_signal_connect_object(GTK_OBJECT(frdp->dialog), | 1772 gtk_signal_connect_object(GTK_OBJECT(frdp->dialog), |
2826 "delete_event", GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete), | 1773 "delete_event", GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete), |
2827 GTK_OBJECT(frdp->dialog)); | 1774 GTK_OBJECT(frdp->dialog)); |
2828 | 1775 |
2829 tmp = gtk_vseparator_new(); | 1776 tmp = gtk_vseparator_new(); |
2830 #ifdef HAVE_GTK2 | |
2831 gtk_box_pack_end(GTK_BOX(hbox), tmp, FALSE, FALSE, 10); | 1777 gtk_box_pack_end(GTK_BOX(hbox), tmp, FALSE, FALSE, 10); |
2832 #else | 1778 |
2833 gtk_box_pack_end(GTK_BOX(hbox), tmp, FALSE, TRUE, 0); | |
2834 #endif | |
2835 | |
2836 #ifndef HAVE_GTK2 | |
2837 gtk_widget_grab_focus(frdp->what); | |
2838 | |
2839 /* show the frame and realize the frdp->dialog this gives us a window size | |
2840 * request that we'll use to position the window within the boundary of | |
2841 * the mainwin --dbv */ | |
2842 gtk_widget_show_all(frame); | |
2843 gui_gtk_position_in_parent(GTK_WIDGET(gui.mainwin), | |
2844 GTK_WIDGET(frdp->dialog), VW_POS_MOUSE); | |
2845 gui_gtk_synch_fonts(); | |
2846 gtk_widget_show_all(frdp->dialog); | |
2847 #endif | |
2848 | |
2849 #ifdef HAVE_GTK2 | |
2850 /* Suppress automatic show of the unused action area */ | 1779 /* Suppress automatic show of the unused action area */ |
2851 gtk_widget_hide(GTK_DIALOG(frdp->dialog)->action_area); | 1780 gtk_widget_hide(GTK_DIALOG(frdp->dialog)->action_area); |
2852 gtk_widget_show_all(hbox); | 1781 gtk_widget_show_all(hbox); |
2853 gtk_widget_show(frdp->dialog); | 1782 gtk_widget_show(frdp->dialog); |
2854 #endif | |
2855 | 1783 |
2856 vim_free(entry_text); | 1784 vim_free(entry_text); |
2857 #ifdef HAVE_GTK2 | |
2858 vim_free(conv_buffer); | 1785 vim_free(conv_buffer); |
2859 #endif | |
2860 #undef CONV | 1786 #undef CONV |
2861 } | 1787 } |
2862 | 1788 |
2863 void | 1789 void |
2864 gui_mch_find_dialog(exarg_T *eap) | 1790 gui_mch_find_dialog(exarg_T *eap) |
2871 gui_mch_replace_dialog(exarg_T *eap) | 1797 gui_mch_replace_dialog(exarg_T *eap) |
2872 { | 1798 { |
2873 if (gui.in_use) | 1799 if (gui.in_use) |
2874 find_replace_dialog_create(eap->arg, TRUE); | 1800 find_replace_dialog_create(eap->arg, TRUE); |
2875 } | 1801 } |
2876 | |
2877 | |
2878 #if !defined(HAVE_GTK2) || defined(PROTO) | |
2879 /* | |
2880 * Synchronize all gui elements, which are dependant upon the | |
2881 * main text font used. Those are in esp. the find/replace dialogs. | |
2882 * If you don't understand why this should be needed, please try to | |
2883 * search for "pięść" in iso8859-2. | |
2884 * | |
2885 * (<danielk> I converted the comment above to UTF-8 to put | |
2886 * a stopper to the encoding mess. Forgive me :) | |
2887 * | |
2888 * Obsolete with GTK2. | |
2889 */ | |
2890 void | |
2891 gui_gtk_synch_fonts(void) | |
2892 { | |
2893 SharedFindReplace *frdp; | |
2894 int do_replace; | |
2895 | |
2896 /* OK this loop is a bit tricky... */ | |
2897 for (do_replace = 0; do_replace <= 1; ++do_replace) | |
2898 { | |
2899 frdp = (do_replace) ? (&repl_widgets) : (&find_widgets); | |
2900 if (frdp->dialog) | |
2901 { | |
2902 GtkStyle *style; | |
2903 | |
2904 /* synch the font with whats used by the text itself */ | |
2905 style = gtk_style_copy(gtk_widget_get_style(frdp->what)); | |
2906 gdk_font_unref(style->font); | |
2907 # ifdef FEAT_XFONTSET | |
2908 if (gui.fontset != NOFONTSET) | |
2909 style->font = gui.fontset; | |
2910 else | |
2911 # endif | |
2912 style->font = gui.norm_font; | |
2913 gdk_font_ref(style->font); | |
2914 gtk_widget_set_style(frdp->what, style); | |
2915 gtk_style_unref(style); | |
2916 if (do_replace) | |
2917 { | |
2918 style = gtk_style_copy(gtk_widget_get_style(frdp->with)); | |
2919 gdk_font_unref(style->font); | |
2920 # ifdef FEAT_XFONTSET | |
2921 if (gui.fontset != NOFONTSET) | |
2922 style->font = gui.fontset; | |
2923 else | |
2924 # endif | |
2925 style->font = gui.norm_font; | |
2926 gdk_font_ref(style->font); | |
2927 gtk_widget_set_style(frdp->with, style); | |
2928 gtk_style_unref(style); | |
2929 } | |
2930 } | |
2931 } | |
2932 } | |
2933 #endif /* !HAVE_GTK2 */ | |
2934 | |
2935 | 1802 |
2936 /* | 1803 /* |
2937 * Callback for actions of the find and replace dialogs | 1804 * Callback for actions of the find and replace dialogs |
2938 */ | 1805 */ |
2939 static void | 1806 static void |
2966 if (GTK_TOGGLE_BUTTON(sfr->wword)->active) | 1833 if (GTK_TOGGLE_BUTTON(sfr->wword)->active) |
2967 flags |= FRD_WHOLE_WORD; | 1834 flags |= FRD_WHOLE_WORD; |
2968 if (GTK_TOGGLE_BUTTON(sfr->mcase)->active) | 1835 if (GTK_TOGGLE_BUTTON(sfr->mcase)->active) |
2969 flags |= FRD_MATCH_CASE; | 1836 flags |= FRD_MATCH_CASE; |
2970 | 1837 |
2971 #ifdef HAVE_GTK2 | |
2972 repl_text = CONVERT_FROM_UTF8(repl_text); | 1838 repl_text = CONVERT_FROM_UTF8(repl_text); |
2973 find_text = CONVERT_FROM_UTF8(find_text); | 1839 find_text = CONVERT_FROM_UTF8(find_text); |
2974 #endif | |
2975 rc = gui_do_findrepl(flags, find_text, repl_text, direction_down); | 1840 rc = gui_do_findrepl(flags, find_text, repl_text, direction_down); |
2976 #ifdef HAVE_GTK2 | |
2977 CONVERT_FROM_UTF8_FREE(repl_text); | 1841 CONVERT_FROM_UTF8_FREE(repl_text); |
2978 CONVERT_FROM_UTF8_FREE(find_text); | 1842 CONVERT_FROM_UTF8_FREE(find_text); |
2979 #endif | |
2980 | 1843 |
2981 if (rc && gtk_main_level() > 0) | 1844 if (rc && gtk_main_level() > 0) |
2982 gtk_main_quit(); /* make sure cmd will be handled immediately */ | 1845 gtk_main_quit(); /* make sure cmd will be handled immediately */ |
2983 } | 1846 } |
2984 | 1847 |
3033 { | 1896 { |
3034 /* This will fail when menus are not loaded. Well, it's only for | 1897 /* This will fail when menus are not loaded. Well, it's only for |
3035 * backwards compatibility anyway. */ | 1898 * backwards compatibility anyway. */ |
3036 do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp"); | 1899 do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp"); |
3037 } | 1900 } |
3038 | |
3039 #if !defined(HAVE_GTK2) || defined(PROTO) /* Crack crack crack. Brrrr. */ | |
3040 | |
3041 /* gui_gtk_position_in_parent | |
3042 * | |
3043 * this function causes a child window to be placed within the boundary of | |
3044 * the parent (mainwin) window. | |
3045 * | |
3046 * you can specify where the window will be positioned by the third argument | |
3047 * (defined in gui.h): | |
3048 * VW_POS_CENTER at center of parent window | |
3049 * VW_POS_MOUSE center of child at mouse position | |
3050 * VW_POS_TOP_CENTER top of child at top of parent centered | |
3051 * horizontally about the mouse. | |
3052 * | |
3053 * NOTE: for this function to act as desired the child window must have a | |
3054 * window size requested. this can be accomplished by packing/placing | |
3055 * child widgets onto a gtk_frame widget rather than the gtk_window | |
3056 * widget... | |
3057 * | |
3058 * brent -- dbv | |
3059 */ | |
3060 static void | |
3061 gui_gtk_position_in_parent( | |
3062 GtkWidget *parent, | |
3063 GtkWidget *child, | |
3064 gui_win_pos_T where) | |
3065 { | |
3066 GtkRequisition c_size; | |
3067 gint xPm, yPm; | |
3068 gint xP, yP, wP, hP, pos_x, pos_y; | |
3069 | |
3070 /* make sure the child widget is set up then get its size. */ | |
3071 gtk_widget_size_request(child, &c_size); | |
3072 | |
3073 /* get origin and size of parent window */ | |
3074 gdk_window_get_origin((GdkWindow *)(parent->window), &xP, &yP); | |
3075 gdk_window_get_size((GdkWindow *)(parent->window), &wP, &hP); | |
3076 | |
3077 if (c_size.width > wP || c_size.height > hP) | |
3078 { | |
3079 /* doh! maybe the user should consider giving gVim a little more | |
3080 * screen real estate */ | |
3081 gtk_widget_set_uposition(child , xP + 2 , yP + 2); | |
3082 return; | |
3083 } | |
3084 | |
3085 if (where == VW_POS_MOUSE) | |
3086 { | |
3087 /* position window at mouse pointer */ | |
3088 gtk_widget_get_pointer(parent, &xPm, &yPm); | |
3089 pos_x = xP + xPm - (c_size.width) / 2; | |
3090 pos_y = yP + yPm - (c_size.height) / 2; | |
3091 } | |
3092 else | |
3093 { | |
3094 /* set child x origin so it is in center of Vim window */ | |
3095 pos_x = xP + (wP - c_size.width) / 2; | |
3096 | |
3097 if (where == VW_POS_TOP_CENTER) | |
3098 pos_y = yP + 2; | |
3099 else | |
3100 /* where == VW_POS_CENTER */ | |
3101 pos_y = yP + (hP - c_size.height) / 2; | |
3102 } | |
3103 | |
3104 /* now, make sure the window will be inside the Vim window... */ | |
3105 if (pos_x < xP) | |
3106 pos_x = xP + 2; | |
3107 if (pos_y < yP) | |
3108 pos_y = yP + 2; | |
3109 if ((pos_x + c_size.width) > (wP + xP)) | |
3110 pos_x = xP + wP - c_size.width - 2; | |
3111 /* Assume 'guiheadroom' indicates the title bar height... */ | |
3112 if ((pos_y + c_size.height + p_ghr / 2) > (hP + yP)) | |
3113 | |
3114 gtk_widget_set_uposition(child, pos_x, pos_y); | |
3115 } | |
3116 | |
3117 #endif /* !HAVE_GTK2 */ |