annotate src/gui_gtk.c @ 20665:6ff992bf4c82 v8.2.0886

patch 8.2.0886: cannot use octal numbers in scriptversion 4 Commit: https://github.com/vim/vim/commit/c17e66c5c0acd5038f1eb3d7b3049b64bb6ea30b Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 2 21:38:22 2020 +0200 patch 8.2.0886: cannot use octal numbers in scriptversion 4 Problem: Cannot use octal numbers in scriptversion 4. Solution: Add the "0o" notation. (Ken Takata, closes https://github.com/vim/vim/issues/5304)
author Bram Moolenaar <Bram@vim.org>
date Tue, 02 Jun 2020 21:45:03 +0200
parents 3ff714d765ba
children fcccc29bd386
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 9035
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * Porting to GTK+ was done by:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 *
68
a97c6902ecd9 updated for version 7.0030
vimboss
parents: 41
diff changeset
13 * (C) 1998,1999,2000 by Marcin Dalecki <martin@dalecki.de>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 * With GREAT support and continuous encouragements by Andy Kahn and of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 * course Bram Moolenaar!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 * Support for GTK+ 2 was added by:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 * (C) 2002,2003 Jason Hildebrand <jason@peaceworks.ca>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 * Daniel Elstner <daniel.elstner@gmx.net>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 * Best supporting actor (He helped somewhat, aesthetically speaking):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 * Maxime Romano <verbophobe@hotmail.com>
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
25 *
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
26 * Support for GTK+ 3 was added by:
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
27 *
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
28 * 2016 Kazunobu Kuriyama <kazunobu.kuriyama@gmail.com>
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
29 *
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
30 * With the help of Marius Gedminas and the word of Bram Moolenaar,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
31 * "Let's give this some time to mature."
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
34 #include "vim.h"
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
35
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 #ifdef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 # include "gui_gtk_f.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
40 // GTK defines MAX and MIN, but some system header files as well. Undefine
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
41 // them and don't use them.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 #ifdef MIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 # undef MIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 #ifdef MAX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 # undef MAX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 #ifdef FEAT_GUI_GNOME
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
50 // Gnome redefines _() and N_(). Grrr...
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 # ifdef _
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 # undef _
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 # ifdef N_
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 # undef N_
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 # ifdef textdomain
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 # undef textdomain
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 # ifdef bindtextdomain
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 # undef bindtextdomain
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 # endif
1286
152e52624521 updated for version 7.1-001
vimboss
parents: 1215
diff changeset
63 # ifdef bind_textdomain_codeset
152e52624521 updated for version 7.1-001
vimboss
parents: 1215
diff changeset
64 # undef bind_textdomain_codeset
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1025
diff changeset
65 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 # if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS)
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
67 # define ENABLE_NLS // so the texts in the dialog boxes are translated
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 # include <gnome.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 #ifdef FEAT_GUI_GTK
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
73 # if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
74 # include <gdk/gdkkeysyms-compat.h>
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
75 # else
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
76 # include <gdk/gdkkeysyms.h>
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
77 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 # include <gdk/gdk.h>
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
79 # ifdef MSWIN
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 # include <gdk/gdkwin32.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 # include <gdk/gdkx.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 # include <gtk/gtk.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 #else
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
87 // define these items to be able to generate prototypes without GTK
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 typedef int GtkWidget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 # define gpointer int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 # define guint8 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 # define GdkPixmap int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 # define GdkBitmap int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 # define GtkIconFactory int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 # define GtkToolbar int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 # define GtkAdjustment int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 # define gboolean int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 # define GdkEventKey int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 # define CancelData int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 static void entry_activate_cb(GtkWidget *widget, gpointer data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 static void entry_changed_cb(GtkWidget *entry, GtkWidget *dialog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 static void find_replace_cb(GtkWidget *widget, gpointer data);
3564
8d1b63e6d317 updated for version 7.3.542
Bram Moolenaar <bram@vim.org>
parents: 3484
diff changeset
104 #if defined(FEAT_BROWSE) || defined(PROTO)
3484
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
105 static void recent_func_log_func(
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
106 const gchar *log_domain,
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
107 GLogLevelFlags log_level,
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
108 const gchar *message,
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
109 gpointer user_data);
3564
8d1b63e6d317 updated for version 7.3.542
Bram Moolenaar <bram@vim.org>
parents: 3484
diff changeset
110 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
2275
e4d849f4df03 Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2103
diff changeset
112 #if defined(FEAT_TOOLBAR)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 * Table from BuiltIn## icon indices to GTK+ stock IDs. Order must exactly
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 * match toolbar_names[] in menu.c! All stock icons including the "vim-*"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 * ones can be overridden in your gtkrc file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 */
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
118 # if GTK_CHECK_VERSION(3,10,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
119 static const char * const menu_themed_names[] =
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
120 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
121 /* 00 */ "document-new", // sub. GTK_STOCK_NEW
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
122 /* 01 */ "document-open", // sub. GTK_STOCK_OPEN
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
123 /* 02 */ "document-save", // sub. GTK_STOCK_SAVE
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
124 /* 03 */ "edit-undo", // sub. GTK_STOCK_UNDO
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
125 /* 04 */ "edit-redo", // sub. GTK_STOCK_REDO
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
126 /* 05 */ "edit-cut", // sub. GTK_STOCK_CUT
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
127 /* 06 */ "edit-copy", // sub. GTK_STOCK_COPY
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
128 /* 07 */ "edit-paste", // sub. GTK_STOCK_PASTE
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
129 /* 08 */ "document-print", // sub. GTK_STOCK_PRINT
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
130 /* 09 */ "help-browser", // sub. GTK_STOCK_HELP
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
131 /* 10 */ "edit-find", // sub. GTK_STOCK_FIND
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
132 # if GTK_CHECK_VERSION(3,14,0)
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
133 // Use the file names in gui_gtk_res.xml, cutting off the extension.
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
134 // Similar changes follow.
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
135 /* 11 */ "stock_vim_save_all",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
136 /* 12 */ "stock_vim_session_save",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
137 /* 13 */ "stock_vim_session_new",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
138 /* 14 */ "stock_vim_session_load",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
139 # else
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
140 /* 11 */ "vim-save-all",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
141 /* 12 */ "vim-session-save",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
142 /* 13 */ "vim-session-new",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
143 /* 14 */ "vim-session-load",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
144 # endif
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
145 /* 15 */ "system-run", // sub. GTK_STOCK_EXECUTE
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
146 /* 16 */ "edit-find-replace", // sub. GTK_STOCK_FIND_AND_REPLACE
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
147 /* 17 */ "window-close", // sub. GTK_STOCK_CLOSE, FIXME: fuzzy
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
148 # if GTK_CHECK_VERSION(3,14,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
149 /* 18 */ "stock_vim_window_maximize",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
150 /* 19 */ "stock_vim_window_minimize",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
151 /* 20 */ "stock_vim_window_split",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
152 /* 21 */ "stock_vim_shell",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
153 # else
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
154 /* 18 */ "vim-window-maximize",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
155 /* 19 */ "vim-window-minimize",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
156 /* 20 */ "vim-window-split",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
157 /* 21 */ "vim-shell",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
158 # endif
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
159 /* 22 */ "go-previous", // sub. GTK_STOCK_GO_BACK
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
160 /* 23 */ "go-next", // sub. GTK_STOCK_GO_FORWARD
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
161 # if GTK_CHECK_VERSION(3,14,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
162 /* 24 */ "stock_vim_find_help",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
163 # else
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
164 /* 24 */ "vim-find-help",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
165 # endif
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
166 /* 25 */ "gtk-convert", // sub. GTK_STOCK_CONVERT
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
167 /* 26 */ "go-jump", // sub. GTK_STOCK_JUMP_TO
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
168 # if GTK_CHECK_VERSION(3,14,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
169 /* 27 */ "stock_vim_build_tags",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
170 /* 28 */ "stock_vim_window_split_vertical",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
171 /* 29 */ "stock_vim_window_maximize_width",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
172 /* 30 */ "stock_vim_window_minimize_width",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
173 # else
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
174 /* 27 */ "vim-build-tags",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
175 /* 28 */ "vim-window-split-vertical",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
176 /* 29 */ "vim-window-maximize-width",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
177 /* 30 */ "vim-window-minimize-width",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
178 # endif
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
179 /* 31 */ "application-exit", // GTK_STOCK_QUIT
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
180 };
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
181 # else // !GTK_CHECK_VERSION(3,10,0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 static const char * const menu_stock_ids[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 /* 00 */ GTK_STOCK_NEW,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 /* 01 */ GTK_STOCK_OPEN,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 /* 02 */ GTK_STOCK_SAVE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 /* 03 */ GTK_STOCK_UNDO,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 /* 04 */ GTK_STOCK_REDO,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 /* 05 */ GTK_STOCK_CUT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 /* 06 */ GTK_STOCK_COPY,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 /* 07 */ GTK_STOCK_PASTE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 /* 08 */ GTK_STOCK_PRINT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 /* 09 */ GTK_STOCK_HELP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 /* 10 */ GTK_STOCK_FIND,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 /* 11 */ "vim-save-all",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 /* 12 */ "vim-session-save",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 /* 13 */ "vim-session-new",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 /* 14 */ "vim-session-load",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 /* 15 */ GTK_STOCK_EXECUTE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 /* 16 */ GTK_STOCK_FIND_AND_REPLACE,
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
201 /* 17 */ GTK_STOCK_CLOSE, // FIXME: fuzzy
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 /* 18 */ "vim-window-maximize",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 /* 19 */ "vim-window-minimize",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 /* 20 */ "vim-window-split",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 /* 21 */ "vim-shell",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 /* 22 */ GTK_STOCK_GO_BACK,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 /* 23 */ GTK_STOCK_GO_FORWARD,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 /* 24 */ "vim-find-help",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 /* 25 */ GTK_STOCK_CONVERT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 /* 26 */ GTK_STOCK_JUMP_TO,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 /* 27 */ "vim-build-tags",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 /* 28 */ "vim-window-split-vertical",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 /* 29 */ "vim-window-maximize-width",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 /* 30 */ "vim-window-minimize-width",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 /* 31 */ GTK_STOCK_QUIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 };
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
217 # endif // !GTK_CHECK_VERSION(3,10,0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
219 # ifdef USE_GRESOURCE
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
220 # if !GTK_CHECK_VERSION(3,10,0)
7380
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
221 typedef struct IconNames {
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
222 const char *icon_name;
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
223 const char *file_name;
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
224 } IconNames;
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
225
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
226 static IconNames stock_vim_icons[] = {
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
227 { "vim-build-tags", "stock_vim_build_tags.png" },
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
228 { "vim-find-help", "stock_vim_find_help.png" },
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
229 { "vim-save-all", "stock_vim_save_all.png" },
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
230 { "vim-session-load", "stock_vim_session_load.png" },
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
231 { "vim-session-new", "stock_vim_session_new.png" },
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
232 { "vim-session-save", "stock_vim_session_save.png" },
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
233 { "vim-shell", "stock_vim_shell.png" },
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
234 { "vim-window-maximize", "stock_vim_window_maximize.png" },
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
235 { "vim-window-maximize-width", "stock_vim_window_maximize_width.png" },
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
236 { "vim-window-minimize", "stock_vim_window_minimize.png" },
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
237 { "vim-window-minimize-width", "stock_vim_window_minimize_width.png" },
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
238 { "vim-window-split", "stock_vim_window_split.png" },
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
239 { "vim-window-split-vertical", "stock_vim_window_split_vertical.png" },
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
240 { NULL, NULL }
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
241 };
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
242 # endif
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
243 # endif // USE_G_RESOURCE
7380
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
244
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
245 # ifndef USE_GRESOURCE
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 add_stock_icon(GtkIconFactory *factory,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 const char *stock_id,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 const guint8 *inline_data,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 int data_length)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 GdkPixbuf *pixbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 GtkIconSet *icon_set;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 pixbuf = gdk_pixbuf_new_from_inline(data_length, inline_data, FALSE, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 icon_set = gtk_icon_set_new_from_pixbuf(pixbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 gtk_icon_factory_add(factory, stock_id, icon_set);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 gtk_icon_set_unref(icon_set);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 g_object_unref(pixbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 }
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
263 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 lookup_menu_iconfile(char_u *iconfile, char_u *dest)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 expand_env(iconfile, dest, MAXPATHL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 if (mch_isFullName(dest))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 return vim_fexists(dest);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 static const char suffixes[][4] = {"png", "xpm", "bmp"};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 char_u buf[MAXPATHL];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 unsigned int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 for (i = 0; i < G_N_ELEMENTS(suffixes); ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 if (gui_find_bitmap(dest, buf, (char *)suffixes[i]) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 STRCPY(dest, buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 static GtkWidget *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 load_menu_iconfile(char_u *name, GtkIconSize icon_size)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 GtkWidget *image = NULL;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
295 # if GTK_CHECK_VERSION(3,10,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
296 int pixel_size = -1;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
297
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
298 switch (icon_size)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
299 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
300 case GTK_ICON_SIZE_MENU:
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
301 pixel_size = 16;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
302 break;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
303 case GTK_ICON_SIZE_SMALL_TOOLBAR:
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
304 pixel_size = 16;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
305 break;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
306 case GTK_ICON_SIZE_LARGE_TOOLBAR:
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
307 pixel_size = 24;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
308 break;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
309 case GTK_ICON_SIZE_BUTTON:
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
310 pixel_size = 16;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
311 break;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
312 case GTK_ICON_SIZE_DND:
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
313 pixel_size = 32;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
314 break;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
315 case GTK_ICON_SIZE_DIALOG:
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
316 pixel_size = 48;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
317 break;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
318 case GTK_ICON_SIZE_INVALID:
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
319 // FALLTHROUGH
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
320 default:
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
321 pixel_size = 0;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
322 break;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
323 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
324
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
325 if (pixel_size > 0 || pixel_size == -1)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
326 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
327 GdkPixbuf * const pixbuf
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
328 = gdk_pixbuf_new_from_file_at_scale((const char *)name,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
329 pixel_size, pixel_size, TRUE, NULL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
330 if (pixbuf != NULL)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
331 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
332 image = gtk_image_new_from_pixbuf(pixbuf);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
333 g_object_unref(pixbuf);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
334 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
335 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
336 if (image == NULL)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
337 image = gtk_image_new_from_icon_name("image-missing", icon_size);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
338
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
339 return image;
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
340 # else // !GTK_CHECK_VERSION(3,10,0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 GtkIconSet *icon_set;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 GtkIconSource *icon_source;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 * Rather than loading the icon directly into a GtkImage, create
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 * a new GtkIconSet and put it in there. This way we can easily
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 * scale the toolbar icons on the fly when needed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 icon_set = gtk_icon_set_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 icon_source = gtk_icon_source_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 gtk_icon_source_set_filename(icon_source, (const char *)name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 gtk_icon_set_add_source(icon_set, icon_source);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 image = gtk_image_new_from_icon_set(icon_set, icon_size);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 gtk_icon_source_free(icon_source);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 gtk_icon_set_unref(icon_set);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 return image;
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
361 # endif // !GTK_CHECK_VERSION(3,10,0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 static GtkWidget *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 create_menu_icon(vimmenu_T *menu, GtkIconSize icon_size)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 GtkWidget *image = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 char_u buf[MAXPATHL];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
370 // First use a specified "icon=" argument.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 if (menu->iconfile != NULL && lookup_menu_iconfile(menu->iconfile, buf))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 image = load_menu_iconfile(buf, icon_size);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
374 // If not found and not builtin specified try using the menu name.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 if (image == NULL && !menu->icon_builtin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 && lookup_menu_iconfile(menu->name, buf))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 image = load_menu_iconfile(buf, icon_size);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
379 // Still not found? Then use a builtin icon, a blank one as fallback.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 if (image == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
382 # if GTK_CHECK_VERSION(3,10,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
383 const char *icon_name = NULL;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
384 const int n_names = G_N_ELEMENTS(menu_themed_names);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
385
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
386 if (menu->iconidx >= 0 && menu->iconidx < n_names)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
387 icon_name = menu_themed_names[menu->iconidx];
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
388 if (icon_name == NULL)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
389 icon_name = "image-missing";
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
390
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
391 image = gtk_image_new_from_icon_name(icon_name, icon_size);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
392 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 const char *stock_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 const int n_ids = G_N_ELEMENTS(menu_stock_ids);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 if (menu->iconidx >= 0 && menu->iconidx < n_ids)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 stock_id = menu_stock_ids[menu->iconidx];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 stock_id = GTK_STOCK_MISSING_IMAGE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 image = gtk_image_new_from_stock(stock_id, icon_size);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
402 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 return image;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407
790
c8680debe1cc updated for version 7.0230
vimboss
parents: 419
diff changeset
408 static gint
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
409 toolbar_button_focus_in_event(GtkWidget *widget UNUSED,
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
410 GdkEventFocus *event UNUSED,
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
411 gpointer data UNUSED)
790
c8680debe1cc updated for version 7.0230
vimboss
parents: 419
diff changeset
412 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
413 // When we're in a GtkPlug, we don't have window focus events, only widget
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
414 // focus. To emulate stand-alone gvim, if a button gets focus (e.g.,
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
415 // <Tab> into GtkPlug) immediately pass it to mainwin.
790
c8680debe1cc updated for version 7.0230
vimboss
parents: 419
diff changeset
416 if (gtk_socket_id != 0)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
417 gtk_widget_grab_focus(gui.drawarea);
790
c8680debe1cc updated for version 7.0230
vimboss
parents: 419
diff changeset
418
c8680debe1cc updated for version 7.0230
vimboss
parents: 419
diff changeset
419 return TRUE;
c8680debe1cc updated for version 7.0230
vimboss
parents: 419
diff changeset
420 }
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
421 #endif // FEAT_TOOLBAR
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422
2275
e4d849f4df03 Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2103
diff changeset
423 #if defined(FEAT_TOOLBAR) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 gui_gtk_register_stock_icons(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
428 # ifndef USE_GRESOURCE
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
429 # include "../pixmaps/stock_icons.h"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 GtkIconFactory *factory;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 factory = gtk_icon_factory_new();
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
433 # define ADD_ICON(Name, Data) add_stock_icon(factory, Name, Data, (int)sizeof(Data))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 ADD_ICON("vim-build-tags", stock_vim_build_tags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 ADD_ICON("vim-find-help", stock_vim_find_help);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 ADD_ICON("vim-save-all", stock_vim_save_all);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 ADD_ICON("vim-session-load", stock_vim_session_load);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 ADD_ICON("vim-session-new", stock_vim_session_new);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 ADD_ICON("vim-session-save", stock_vim_session_save);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 ADD_ICON("vim-shell", stock_vim_shell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 ADD_ICON("vim-window-maximize", stock_vim_window_maximize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 ADD_ICON("vim-window-maximize-width", stock_vim_window_maximize_width);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 ADD_ICON("vim-window-minimize", stock_vim_window_minimize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 ADD_ICON("vim-window-minimize-width", stock_vim_window_minimize_width);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 ADD_ICON("vim-window-split", stock_vim_window_split);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 ADD_ICON("vim-window-split-vertical", stock_vim_window_split_vertical);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
449 # undef ADD_ICON
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
450
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
451 gtk_icon_factory_add_default(factory);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
452 g_object_unref(factory);
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
453 # else // defined(USE_GRESOURCE)
7380
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
454 const char * const path_prefix = "/org/vim/gui/icon";
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
455 # if GTK_CHECK_VERSION(3,14,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
456 GdkScreen *screen = NULL;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
457 GtkIconTheme *icon_theme = NULL;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
458
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
459 if (GTK_IS_WIDGET(gui.mainwin))
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
460 screen = gtk_widget_get_screen(gui.mainwin);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
461 else
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
462 screen = gdk_screen_get_default();
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
463 icon_theme = gtk_icon_theme_get_for_screen(screen);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
464 gtk_icon_theme_add_resource_path(icon_theme, path_prefix);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
465 # elif GTK_CHECK_VERSION(3,0,0)
7380
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
466 IconNames *names;
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
467
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
468 for (names = stock_vim_icons; names->icon_name != NULL; names++)
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
469 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
470 char path[MAXPATHL];
7380
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
471
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
472 vim_snprintf(path, MAXPATHL, "%s/%s", path_prefix, names->file_name);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
473 GdkPixbuf *pixbuf = NULL;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
474 pixbuf = gdk_pixbuf_new_from_resource(path, NULL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
475 if (pixbuf != NULL)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
476 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
477 const gint size = MAX(gdk_pixbuf_get_width(pixbuf),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
478 gdk_pixbuf_get_height(pixbuf));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
479 if (size > 16)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
480 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
481 // An icon theme is supposed to provide fixed-size
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
482 // image files for each size, e.g., 16, 22, 24, ...
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
483 // Naturally, in contrast to GtkIconSet, GtkIconTheme
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
484 // won't prepare size variants for us out of a single
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
485 // fixed-size image.
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
486 //
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
487 // Currently, Vim provides 24x24 images only while the
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
488 // icon size on the menu and the toolbar is set to 16x16
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
489 // by default.
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
490 //
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
491 // Resize them by ourselves until we have our own fully
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
492 // fledged icon theme.
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
493 GdkPixbuf *src = pixbuf;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
494 pixbuf = gdk_pixbuf_scale_simple(src,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
495 16, 16,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
496 GDK_INTERP_BILINEAR);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
497 if (pixbuf == NULL)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
498 pixbuf = src;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
499 else
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
500 g_object_unref(src);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
501 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
502 gtk_icon_theme_add_builtin_icon(names->icon_name, size, pixbuf);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
503 g_object_unref(pixbuf);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
504 }
7380
055a0b587a3e commit https://github.com/vim/vim/commit/36e294c00c784b9ddd05a4fdbea2e331ab2b1ca8
Christian Brabandt <cb@256bit.org>
parents: 5092
diff changeset
505 }
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
506 # else // !GTK_CHECK_VERSION(3,0.0)
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
507 GtkIconFactory * const factory = gtk_icon_factory_new();
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
508 IconNames *names;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
509
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
510 for (names = stock_vim_icons; names->icon_name != NULL; names++)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
511 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
512 char path[MAXPATHL];
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
513 GdkPixbuf *pixbuf;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
514
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
515 vim_snprintf(path, MAXPATHL, "%s/%s", path_prefix, names->file_name);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
516 pixbuf = gdk_pixbuf_new_from_resource(path, NULL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
517 if (pixbuf != NULL)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
518 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
519 GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf(pixbuf);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
520 gtk_icon_factory_add(factory, names->icon_name, icon_set);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
521 gtk_icon_set_unref(icon_set);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
522 g_object_unref(pixbuf);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
523 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
524 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
525
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 gtk_icon_factory_add_default(factory);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 g_object_unref(factory);
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
528 # endif // !GTK_CHECK_VERSION(3,0,0)
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
529 # endif // defined(USE_GRESOURCE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
532 #endif // FEAT_TOOLBAR
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 #if defined(FEAT_MENU) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 * Translate Vim's mnemonic tagging to GTK+ style and convert to UTF-8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 * if necessary. The caller must vim_free() the returned string.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 * Input Output
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 * _ __
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 * && &
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 * & _ stripped if use_mnemonic == FALSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 * <Tab> end of menu label text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 translate_mnemonic_tag(char_u *name, int use_mnemonic)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 char_u *psrc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 char_u *pdest;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 int n_underscores = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 name = CONVERT_TO_UTF8(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 for (psrc = name; *psrc != NUL && *psrc != TAB; ++psrc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 if (*psrc == '_')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 ++n_underscores;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561
16764
ef00b6bc186b patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
562 buf = alloc(psrc - name + n_underscores + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 if (buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 pdest = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 for (psrc = name; *psrc != NUL && *psrc != TAB; ++psrc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 if (*psrc == '_')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 *pdest++ = '_';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 *pdest++ = '_';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 else if (*psrc != '&')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 *pdest++ = *psrc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 else if (*(psrc + 1) == '&')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 *pdest++ = *psrc++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 else if (use_mnemonic)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 *pdest++ = '_';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 *pdest = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 CONVERT_TO_UTF8_FREE(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 menu_item_new(vimmenu_T *menu, GtkWidget *parent_widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 GtkWidget *box;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 char_u *text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 int use_mnemonic;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
600 // It would be neat to have image menu items, but that would require major
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
601 // changes to Vim's menu system. Not to mention that all the translations
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
602 // had to be updated.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 menu->id = gtk_menu_item_new();
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
604 # if GTK_CHECK_VERSION(3,2,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
605 box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 20);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
606 gtk_box_set_homogeneous(GTK_BOX(box), FALSE);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
607 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 box = gtk_hbox_new(FALSE, 20);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
609 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 use_mnemonic = (p_wak[0] != 'n' || !GTK_IS_MENU_BAR(parent_widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 text = translate_mnemonic_tag(menu->name, use_mnemonic);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 menu->label = gtk_label_new_with_mnemonic((const char *)text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 vim_free(text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 gtk_box_pack_start(GTK_BOX(box), menu->label, FALSE, FALSE, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 if (menu->actext != NULL && menu->actext[0] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 text = CONVERT_TO_UTF8(menu->actext);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 gtk_box_pack_end(GTK_BOX(box),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 gtk_label_new((const char *)text),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 FALSE, FALSE, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 CONVERT_TO_UTF8_FREE(text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 gtk_container_add(GTK_CONTAINER(menu->id), box);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 gtk_widget_show_all(menu->id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 gui_mch_add_menu(vimmenu_T *menu, int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 vimmenu_T *parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 GtkWidget *parent_widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 if (menu->name[0] == ']' || menu_is_popup(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 menu->submenu_id = gtk_menu_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 if ((parent != NULL && parent->submenu_id == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 || !menu_is_menubar(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 parent_widget = (parent != NULL) ? parent->submenu_id : gui.menubar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 menu_item_new(menu, parent_widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654
11508
9b1077d33c68 patch 8.0.0637: crash when using some version of GTK 3
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
655 # if !GTK_CHECK_VERSION(3,4,0)
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
656 // since the tearoff should always appear first, increment idx
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 if (parent != NULL && !menu_is_popup(parent->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 ++idx;
11508
9b1077d33c68 patch 8.0.0637: crash when using some version of GTK 3
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
659 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 gtk_menu_shell_insert(GTK_MENU_SHELL(parent_widget), menu->id, idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 menu->submenu_id = gtk_menu_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 gtk_menu_set_accel_group(GTK_MENU(menu->submenu_id), gui.accel_group);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu->id), menu->submenu_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
668 # if !GTK_CHECK_VERSION(3,4,0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 menu->tearoff_handle = gtk_tearoff_menu_item_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 if (vim_strchr(p_go, GO_TEAROFF) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 gtk_widget_show(menu->tearoff_handle);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
672 # if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
673 gtk_menu_shell_prepend(GTK_MENU_SHELL(menu->submenu_id),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
674 menu->tearoff_handle);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
675 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 gtk_menu_prepend(GTK_MENU(menu->submenu_id), menu->tearoff_handle);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
677 # endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
678 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 static void
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
682 menu_item_activate(GtkWidget *widget UNUSED, gpointer data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 gui_menu_cb((vimmenu_T *)data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 gui_mch_add_menu_item(vimmenu_T *menu, int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 vimmenu_T *parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 # ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 if (menu_is_toolbar(parent->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 GtkToolbar *toolbar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 toolbar = GTK_TOOLBAR(gui.toolbar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 menu->submenu_id = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 if (menu_is_separator(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
704 # if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
705 GtkToolItem *item = gtk_separator_tool_item_new();
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
706 gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(item),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
707 TRUE);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
708 gtk_tool_item_set_expand(GTK_TOOL_ITEM(item), FALSE);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
709 gtk_widget_show(GTK_WIDGET(item));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
710
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
711 gtk_toolbar_insert(toolbar, item, idx);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
712 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 gtk_toolbar_insert_space(toolbar, idx);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
714 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 menu->id = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 char_u *text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 char_u *tooltip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 text = CONVERT_TO_UTF8(menu->dname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]);
26
404aac550f35 updated for version 7.0017
vimboss
parents: 7
diff changeset
724 if (tooltip != NULL && !utf_valid_string(tooltip, NULL))
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
725 // Invalid text, can happen when 'encoding' is changed. Avoid
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
726 // a nasty GTK error message, skip the tooltip.
26
404aac550f35 updated for version 7.0017
vimboss
parents: 7
diff changeset
727 CONVERT_TO_UTF8_FREE(tooltip);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
729 # if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
730 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
731 GtkWidget *icon;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
732 GtkToolItem *item;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
733
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
734 icon = create_menu_icon(menu,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
735 gtk_toolbar_get_icon_size(toolbar));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
736 item = gtk_tool_button_new(icon, (const gchar *)text);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
737 gtk_tool_item_set_tooltip_text(item, (const gchar *)tooltip);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
738 g_signal_connect(G_OBJECT(item), "clicked",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
739 G_CALLBACK(&menu_item_activate), menu);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
740 gtk_widget_show_all(GTK_WIDGET(item));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
741
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
742 gtk_toolbar_insert(toolbar, item, idx);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
743
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
744 menu->id = GTK_WIDGET(item);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
745 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
746 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 menu->id = gtk_toolbar_insert_item(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 toolbar,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 (const char *)text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 (const char *)tooltip,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 create_menu_icon(menu, gtk_toolbar_get_icon_size(toolbar)),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 G_CALLBACK(&menu_item_activate),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 idx);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
756 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757
856
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
758 if (gtk_socket_id != 0)
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
759 g_signal_connect(G_OBJECT(menu->id), "focus-in-event",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
760 G_CALLBACK(toolbar_button_focus_in_event), NULL);
790
c8680debe1cc updated for version 7.0230
vimboss
parents: 419
diff changeset
761
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 CONVERT_TO_UTF8_FREE(text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 CONVERT_TO_UTF8_FREE(tooltip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 else
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
767 # endif // FEAT_TOOLBAR
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
769 // No parent, must be a non-menubar menu
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 836
diff changeset
770 if (parent == NULL || parent->submenu_id == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772
11508
9b1077d33c68 patch 8.0.0637: crash when using some version of GTK 3
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
773 # if !GTK_CHECK_VERSION(3,4,0)
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
774 // Make place for the possible tearoff handle item. Not in the popup
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
775 // menu, it doesn't have a tearoff item.
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 836
diff changeset
776 if (!menu_is_popup(parent->name))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 ++idx;
11508
9b1077d33c68 patch 8.0.0637: crash when using some version of GTK 3
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
778 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 if (menu_is_separator(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
782 // Separator: Just add it
9035
08854bb267b2 commit https://github.com/vim/vim/commit/0b6cf69c038b9af198542edc349ebe8e53a8f847
Christian Brabandt <cb@256bit.org>
parents: 8279
diff changeset
783 # if GTK_CHECK_VERSION(3,0,0)
08854bb267b2 commit https://github.com/vim/vim/commit/0b6cf69c038b9af198542edc349ebe8e53a8f847
Christian Brabandt <cb@256bit.org>
parents: 8279
diff changeset
784 menu->id = gtk_separator_menu_item_new();
08854bb267b2 commit https://github.com/vim/vim/commit/0b6cf69c038b9af198542edc349ebe8e53a8f847
Christian Brabandt <cb@256bit.org>
parents: 8279
diff changeset
785 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 menu->id = gtk_menu_item_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 gtk_widget_set_sensitive(menu->id, FALSE);
9035
08854bb267b2 commit https://github.com/vim/vim/commit/0b6cf69c038b9af198542edc349ebe8e53a8f847
Christian Brabandt <cb@256bit.org>
parents: 8279
diff changeset
788 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 gtk_widget_show(menu->id);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
790 gtk_menu_shell_insert(GTK_MENU_SHELL(parent->submenu_id),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
791 menu->id, idx);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
796 // Add textual menu item.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 menu_item_new(menu, parent->submenu_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 gtk_widget_show(menu->id);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
799 gtk_menu_shell_insert(GTK_MENU_SHELL(parent->submenu_id),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
800 menu->id, idx);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 if (menu->id != NULL)
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
803 g_signal_connect(G_OBJECT(menu->id), "activate",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
804 G_CALLBACK(menu_item_activate), menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 }
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
807 #endif // FEAT_MENU
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 gui_mch_set_text_area_pos(int x, int y, int w, int h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 gtk_form_move_resize(GTK_FORM(gui.formwin), gui.drawarea, x, y, w, h);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 #if defined(FEAT_MENU) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 /*
1215
1d08aac0aea9 updated for version 7.1b
vimboss
parents: 1025
diff changeset
819 * Enable or disable accelerators for the toplevel menus.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 gui_gtk_set_mnemonics(int enable)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826
19934
3ff714d765ba patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents: 18781
diff changeset
827 FOR_ALL_MENUS(menu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 if (menu->id == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 name = translate_mnemonic_tag(menu->name, enable);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 gtk_label_set_text_with_mnemonic(GTK_LABEL(menu->label),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 (const char *)name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
839 # if !GTK_CHECK_VERSION(3,4,0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 recurse_tearoffs(vimmenu_T *menu, int val)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 for (; menu != NULL; menu = menu->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 if (menu->submenu_id != NULL && menu->tearoff_handle != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 && menu->name[0] != ']' && !menu_is_popup(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 if (val)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 gtk_widget_show(menu->tearoff_handle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 gtk_widget_hide(menu->tearoff_handle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 recurse_tearoffs(menu->children, val);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 }
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
856 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
858 # if GTK_CHECK_VERSION(3,4,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
859 void
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
860 gui_mch_toggle_tearoffs(int enable UNUSED)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
861 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
862 // Do nothing
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
863 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
864 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 gui_mch_toggle_tearoffs(int enable)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 recurse_tearoffs(root_menu, enable);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 }
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
870 # endif
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
871 #endif // FEAT_MENU
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872
2275
e4d849f4df03 Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2103
diff changeset
873 #if defined(FEAT_TOOLBAR)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 get_menu_position(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 vimmenu_T *node;
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 867
diff changeset
878 int idx = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 for (node = menu->parent->children; node != menu; node = node->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 g_return_val_if_fail(node != NULL, -1);
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 867
diff changeset
883 ++idx;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 867
diff changeset
886 return idx;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 }
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
888 #endif // FEAT_TOOLBAR
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 #if defined(FEAT_TOOLBAR) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 gui_mch_menu_set_tip(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 if (menu->id != NULL && menu->parent != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 && gui.toolbar != NULL && menu_is_toolbar(menu->parent->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 char_u *tooltip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
901 if (tooltip != NULL && utf_valid_string(tooltip, NULL))
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
902 # if GTK_CHECK_VERSION(3,0,0)
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
903 // Only set the tooltip when it's valid utf-8.
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
904 gtk_widget_set_tooltip_text(menu->id, (const gchar *)tooltip);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
905 # else
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
906 // Only set the tooltip when it's valid utf-8.
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
907 gtk_tooltips_set_tip(GTK_TOOLBAR(gui.toolbar)->tooltips,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
908 menu->id, (const char *)tooltip, NULL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
909 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 CONVERT_TO_UTF8_FREE(tooltip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 }
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
913 #endif // FEAT_TOOLBAR
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 #if defined(FEAT_MENU) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 * Destroy the machine specific menu widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 gui_mch_destroy_menu(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
923 // Don't let gtk_container_remove automatically destroy menu->id.
5092
1ed945570d47 updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents: 3871
diff changeset
924 if (menu->id != NULL)
1ed945570d47 updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents: 3871
diff changeset
925 g_object_ref(menu->id);
1ed945570d47 updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents: 3871
diff changeset
926
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
927 // Workaround for a spurious gtk warning in Ubuntu: "Trying to remove
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
928 // a child that doesn't believe we're its parent."
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
929 // Remove widget from gui.menubar before destroying it.
5092
1ed945570d47 updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents: 3871
diff changeset
930 if (menu->id != NULL && gui.menubar != NULL
1ed945570d47 updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents: 3871
diff changeset
931 && gtk_widget_get_parent(menu->id) == gui.menubar)
1ed945570d47 updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents: 3871
diff changeset
932 gtk_container_remove(GTK_CONTAINER(gui.menubar), menu->id);
1ed945570d47 updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents: 3871
diff changeset
933
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 # ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 if (menu->parent != NULL && menu_is_toolbar(menu->parent->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 if (menu_is_separator(menu->name))
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
938 # if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
939 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
940 GtkToolItem *item = NULL;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
941
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
942 item = gtk_toolbar_get_nth_item(GTK_TOOLBAR(gui.toolbar),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
943 get_menu_position(menu));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
944 if (item != NULL)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
945 gtk_container_remove(GTK_CONTAINER(gui.toolbar),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
946 GTK_WIDGET(item));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
947 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
948 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 gtk_toolbar_remove_space(GTK_TOOLBAR(gui.toolbar),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 get_menu_position(menu));
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
951 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 else if (menu->id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 gtk_widget_destroy(menu->id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 else
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
956 # endif // FEAT_TOOLBAR
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 if (menu->submenu_id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 gtk_widget_destroy(menu->submenu_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 if (menu->id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 gtk_widget_destroy(menu->id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964
5092
1ed945570d47 updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents: 3871
diff changeset
965 if (menu->id != NULL)
1ed945570d47 updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents: 3871
diff changeset
966 g_object_unref(menu->id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 menu->submenu_id = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 menu->id = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 }
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
970 #endif // FEAT_MENU
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 * Scrollbar stuff.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 if (sb->id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 GtkAdjustment *adjustment;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 adjustment = gtk_range_get_adjustment(GTK_RANGE(sb->id));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
985 gtk_adjustment_set_lower(adjustment, 0.0);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
986 gtk_adjustment_set_value(adjustment, val);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
987 gtk_adjustment_set_upper(adjustment, max + 1);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
988 gtk_adjustment_set_page_size(adjustment, size);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
989 gtk_adjustment_set_page_increment(adjustment,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
990 size < 3L ? 1L : size - 2L);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
991 gtk_adjustment_set_step_increment(adjustment, 1.0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992
14786
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
993 g_signal_handler_block(G_OBJECT(adjustment), (gulong)sb->handler_id);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
994
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
995 #if !GTK_CHECK_VERSION(3,18,0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 gtk_adjustment_changed(adjustment);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
997 #endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
998
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
999 g_signal_handler_unblock(G_OBJECT(adjustment),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1000 (gulong)sb->handler_id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 if (sb->id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 gtk_form_move_resize(GTK_FORM(gui.formwin), sb->id, x, y, w, h);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 * Take action upon scrollbar dragging.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 adjustment_value_changed(GtkAdjustment *adjustment, gpointer data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 long value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 int dragging = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 #ifdef FEAT_XIM
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1022 // cancel any preediting
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 if (im_is_preediting())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 xim_reset();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 sb = gui_find_scrollbar((long)data);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1028 value = gtk_adjustment_get_value(adjustment);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1029 #if !GTK_CHECK_VERSION(3,0,0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 * The dragging argument must be right for the scrollbar to work with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 * closed folds. This isn't documented, hopefully this will keep on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 * working in later GTK versions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 * FIXME: Well, it doesn't work in GTK2. :)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 * HACK: Get the mouse pointer position, if it appears to be on an arrow
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 * button set "dragging" to FALSE. This assumes square buttons!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 if (sb != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 dragging = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 if (sb->wp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 GdkModifierType state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 int width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 int height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1051 // vertical scrollbar: need to set "dragging" properly in case
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1052 // there are closed folds.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 gdk_window_get_pointer(sb->id->window, &x, &y, &state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 gdk_window_get_size(sb->id->window, &width, &height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 if (x >= 0 && x < width && y >= 0 && y < height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 if (y < width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1059 // up arrow: move one (closed fold) line up
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 dragging = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 value = sb->wp->w_topline - 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 else if (y > height - width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1065 // down arrow: move one (closed fold) line down
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 dragging = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 value = sb->wp->w_topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 }
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1072 #endif // !GTK_CHECK_VERSION(3,0,0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 gui_drag_scrollbar(sb, value, dragging);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1076 // SBAR_VERT or SBAR_HORIZ
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 gui_mch_create_scrollbar(scrollbar_T *sb, int orient)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 if (orient == SBAR_HORIZ)
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1081 #if GTK_CHECK_VERSION(3,2,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1082 sb->id = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1083 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 sb->id = gtk_hscrollbar_new(NULL);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1085 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 else if (orient == SBAR_VERT)
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1087 #if GTK_CHECK_VERSION(3,2,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1088 sb->id = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1089 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 sb->id = gtk_vscrollbar_new(NULL);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1091 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 if (sb->id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 GtkAdjustment *adjustment;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1097 gtk_widget_set_can_focus(sb->id, FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 gtk_form_put(GTK_FORM(gui.formwin), sb->id, 0, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 adjustment = gtk_range_get_adjustment(GTK_RANGE(sb->id));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1102 sb->handler_id = g_signal_connect(
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1103 G_OBJECT(adjustment), "value-changed",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1104 G_CALLBACK(adjustment_value_changed),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1105 GINT_TO_POINTER(sb->ident));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 gui_mch_update();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 gui_mch_destroy_scrollbar(scrollbar_T *sb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 if (sb->id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 gtk_widget_destroy(sb->id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 sb->id = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 gui_mch_update();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 #if defined(FEAT_BROWSE) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 * Implementation of the file selector related stuff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 */
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1125
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1126 #ifndef USE_FILE_CHOOSER
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 static void
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
1128 browse_ok_cb(GtkWidget *widget UNUSED, gpointer cbdata)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 gui_T *vw = (gui_T *)cbdata;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 if (vw->browse_fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 g_free(vw->browse_fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 vw->browse_fname = (char_u *)g_strdup(gtk_file_selection_get_filename(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 GTK_FILE_SELECTION(vw->filedlg)));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 gtk_widget_hide(vw->filedlg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 static void
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
1141 browse_cancel_cb(GtkWidget *widget UNUSED, gpointer cbdata)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 gui_T *vw = (gui_T *)cbdata;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 if (vw->browse_fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 g_free(vw->browse_fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 vw->browse_fname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 gtk_widget_hide(vw->filedlg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 static gboolean
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
1154 browse_destroy_cb(GtkWidget *widget UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 if (gui.browse_fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 g_free(gui.browse_fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 gui.browse_fname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 gui.filedlg = NULL;
2301
6f63294a1781 Avoid use of the GTK mail_loop() so that the GtkFileChooser can be used.
Bram Moolenaar <bram@vim.org>
parents: 2275
diff changeset
1162 gtk_main_quit();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 }
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1165 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 * Put up a file requester.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 * Returns the selected name in allocated memory, or NULL for Cancel.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 * saving, select file to write
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 * title title for the window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 * dflt default name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 * ext not used (extension added)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 * initdir initial directory, NULL for current dir
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 * filter not used (file name filter)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 char_u *
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
1178 gui_mch_browse(int saving UNUSED,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 char_u *title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 char_u *dflt,
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
1181 char_u *ext UNUSED,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 char_u *initdir,
3664
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1183 char_u *filter)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 {
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1185 #ifdef USE_FILE_CHOOSER
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1186 GtkWidget *fc;
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1187 #endif
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1188 char_u dirbuf[MAXPATHL];
3484
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
1189 guint log_handler;
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
1190 const gchar *domain = "Gtk";
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 title = CONVERT_TO_UTF8(title);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1194 // GTK has a bug, it only works with an absolute path.
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1195 if (initdir == NULL || *initdir == NUL)
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1196 mch_dirname(dirbuf, MAXPATHL);
1003
a1c1f001b99d updated for version 7.0-129
vimboss
parents: 944
diff changeset
1197 else if (vim_FullName(initdir, dirbuf, MAXPATHL - 2, FALSE) == FAIL)
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1198 dirbuf[0] = NUL;
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1199 // Always need a trailing slash for a directory.
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1200 add_pathsep(dirbuf);
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1201
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1202 // If our pointer is currently hidden, then we should show it.
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1203 gui_mch_mousehide(FALSE);
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1204
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1205 // Hack: The GTK file dialog warns when it can't access a new file, this
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1206 // makes it shut up. http://bugzilla.gnome.org/show_bug.cgi?id=664587
3484
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
1207 log_handler = g_log_set_handler(domain, G_LOG_LEVEL_WARNING,
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
1208 recent_func_log_func, NULL);
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
1209
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1210 #ifdef USE_FILE_CHOOSER
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1211 // We create the dialog each time, so that the button text can be "Open"
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1212 // or "Save" according to the action.
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1213 fc = gtk_file_chooser_dialog_new((const gchar *)title,
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1214 GTK_WINDOW(gui.mainwin),
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1215 saving ? GTK_FILE_CHOOSER_ACTION_SAVE
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1216 : GTK_FILE_CHOOSER_ACTION_OPEN,
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1217 # if GTK_CHECK_VERSION(3,10,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1218 _("_Cancel"), GTK_RESPONSE_CANCEL,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1219 saving ? _("_Save") : _("_Open"), GTK_RESPONSE_ACCEPT,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1220 # else
1025
b6627f01c67d updated for version 7.0-151
vimboss
parents: 1003
diff changeset
1221 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1222 saving ? GTK_STOCK_SAVE : GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1223 # endif
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1224 NULL);
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1225 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc),
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1226 (const gchar *)dirbuf);
3664
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1227
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1228 if (filter != NULL && *filter != NUL)
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1229 {
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1230 int i = 0;
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1231 char_u *patt;
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1232 char_u *p = filter;
3871
337a4368fd2b updated for version 7.3.692
Bram Moolenaar <bram@vim.org>
parents: 3666
diff changeset
1233 GtkFileFilter *gfilter;
3664
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1234
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1235 gfilter = gtk_file_filter_new();
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1236 patt = alloc(STRLEN(filter));
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1237 while (p != NULL && *p != NUL)
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1238 {
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1239 if (*p == '\n' || *p == ';' || *p == '\t')
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1240 {
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1241 STRNCPY(patt, filter, i);
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1242 patt[i] = '\0';
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1243 if (*p == '\t')
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1244 gtk_file_filter_set_name(gfilter, (gchar *)patt);
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1245 else
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1246 {
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1247 gtk_file_filter_add_pattern(gfilter, (gchar *)patt);
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1248 if (*p == '\n')
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1249 {
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1250 gtk_file_chooser_add_filter((GtkFileChooser *)fc,
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1251 gfilter);
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1252 if (*(p + 1) != NUL)
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1253 gfilter = gtk_file_filter_new();
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1254 }
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1255 }
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1256 filter = ++p;
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1257 i = 0;
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1258 }
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1259 else
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1260 {
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1261 p++;
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1262 i++;
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1263 }
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1264 }
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1265 vim_free(patt);
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1266 }
2301
6f63294a1781 Avoid use of the GTK mail_loop() so that the GtkFileChooser can be used.
Bram Moolenaar <bram@vim.org>
parents: 2275
diff changeset
1267 if (saving && dflt != NULL && *dflt != NUL)
6f63294a1781 Avoid use of the GTK mail_loop() so that the GtkFileChooser can be used.
Bram Moolenaar <bram@vim.org>
parents: 2275
diff changeset
1268 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), (char *)dflt);
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1269
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1270 gui.browse_fname = NULL;
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1271 if (gtk_dialog_run(GTK_DIALOG(fc)) == GTK_RESPONSE_ACCEPT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
1273 char *filename;
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
1274
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
1275 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc));
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
1276 gui.browse_fname = (char_u *)g_strdup(filename);
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
1277 g_free(filename);
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1278 }
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1279 gtk_widget_destroy(GTK_WIDGET(fc));
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1280
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1281 #else // !USE_FILE_CHOOSER
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1282
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1283 if (gui.filedlg == NULL)
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1284 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1285 GtkFileSelection *fs; // shortcut
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1286
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 gui.filedlg = gtk_file_selection_new((const gchar *)title);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 gtk_window_set_modal(GTK_WINDOW(gui.filedlg), TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 gtk_window_set_transient_for(GTK_WINDOW(gui.filedlg),
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1290 GTK_WINDOW(gui.mainwin));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 fs = GTK_FILE_SELECTION(gui.filedlg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 gtk_container_border_width(GTK_CONTAINER(fs), 4);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 gtk_signal_connect(GTK_OBJECT(fs->ok_button),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 "clicked", GTK_SIGNAL_FUNC(browse_ok_cb), &gui);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 gtk_signal_connect(GTK_OBJECT(fs->cancel_button),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 "clicked", GTK_SIGNAL_FUNC(browse_cancel_cb), &gui);
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1299 // gtk_signal_connect() doesn't work for destroy, it causes a hang
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 gtk_signal_connect_object(GTK_OBJECT(gui.filedlg),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 "destroy", GTK_SIGNAL_FUNC(browse_destroy_cb),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 GTK_OBJECT(gui.filedlg));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 gtk_window_set_title(GTK_WINDOW(gui.filedlg), (const gchar *)title);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1307 // Concatenate "initdir" and "dflt".
1003
a1c1f001b99d updated for version 7.0-129
vimboss
parents: 944
diff changeset
1308 if (dflt != NULL && *dflt != NUL
a1c1f001b99d updated for version 7.0-129
vimboss
parents: 944
diff changeset
1309 && STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL)
a1c1f001b99d updated for version 7.0-129
vimboss
parents: 944
diff changeset
1310 STRCAT(dirbuf, dflt);
a1c1f001b99d updated for version 7.0-129
vimboss
parents: 944
diff changeset
1311
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 gtk_file_selection_set_filename(GTK_FILE_SELECTION(gui.filedlg),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 (const gchar *)dirbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 gtk_widget_show(gui.filedlg);
2301
6f63294a1781 Avoid use of the GTK mail_loop() so that the GtkFileChooser can be used.
Bram Moolenaar <bram@vim.org>
parents: 2275
diff changeset
1316 gtk_main();
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1317 #endif // !USE_FILE_CHOOSER
3484
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
1318 g_log_remove_handler(domain, log_handler);
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1319
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1320 CONVERT_TO_UTF8_FREE(title);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 if (gui.browse_fname == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1324 // shorten the file name if possible
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1355
diff changeset
1325 return vim_strsave(shorten_fname1(gui.browse_fname));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1328 /*
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1329 * Put up a directory selector
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1330 * Returns the selected name in allocated memory, or NULL for Cancel.
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1331 * title title for the window
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1332 * dflt default name
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1333 * initdir initial directory, NULL for current dir
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1334 */
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1335 char_u *
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1336 gui_mch_browsedir(
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1337 char_u *title,
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1338 char_u *initdir)
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1339 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1340 # if defined(GTK_FILE_CHOOSER) // Only in GTK 2.4 and later.
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1341 char_u dirbuf[MAXPATHL];
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1342 char_u *p;
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1343 GtkWidget *dirdlg; // file selection dialog
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1344 char_u *dirname = NULL;
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1345
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1346 title = CONVERT_TO_UTF8(title);
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1347
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1348 dirdlg = gtk_file_chooser_dialog_new(
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1349 (const gchar *)title,
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1350 GTK_WINDOW(gui.mainwin),
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1351 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1352 # if GTK_CHECK_VERSION(3,10,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1353 _("_Cancel"), GTK_RESPONSE_CANCEL,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1354 _("_OK"), GTK_RESPONSE_ACCEPT,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1355 # else
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1356 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1357 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1358 # endif
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1359 NULL);
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1360
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1361 CONVERT_TO_UTF8_FREE(title);
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1362
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1363 // if our pointer is currently hidden, then we should show it.
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1364 gui_mch_mousehide(FALSE);
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1365
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1366 // GTK appears to insist on an absolute path.
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1367 if (initdir == NULL || *initdir == NUL
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1368 || vim_FullName(initdir, dirbuf, MAXPATHL - 10, FALSE) == FAIL)
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1369 mch_dirname(dirbuf, MAXPATHL - 10);
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1370
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1371 // Always need a trailing slash for a directory.
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1372 // Also add a dummy file name, so that we get to the directory.
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1373 add_pathsep(dirbuf);
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1374 STRCAT(dirbuf, "@zd(*&1|");
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1375 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dirdlg),
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1376 (const gchar *)dirbuf);
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1377
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1378 // Run the dialog.
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1379 if (gtk_dialog_run(GTK_DIALOG(dirdlg)) == GTK_RESPONSE_ACCEPT)
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1380 dirname = (char_u *)gtk_file_chooser_get_filename(
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1381 GTK_FILE_CHOOSER(dirdlg));
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1382 gtk_widget_destroy(dirdlg);
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1383 if (dirname == NULL)
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1384 return NULL;
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1385
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1386 // shorten the file name if possible
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1355
diff changeset
1387 p = vim_strsave(shorten_fname1(dirname));
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1388 g_free(dirname);
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1389 return p;
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1390
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1391 # else // !defined(GTK_FILE_CHOOSER)
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1392 // For GTK 2.2 and earlier: fall back to ordinary file selector.
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1393 return gui_mch_browse(0, title, NULL, NULL, initdir, NULL);
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1394 # endif // !defined(GTK_FILE_CHOOSER)
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1395 }
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
1396
270
a20218704019 updated for version 7.0072
vimboss
parents: 133
diff changeset
1397
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1398 #endif // FEAT_BROWSE
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399
2275
e4d849f4df03 Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2103
diff changeset
1400 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 static GtkWidget *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 create_message_dialog(int type, char_u *title, char_u *message)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 GtkWidget *dialog;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 GtkMessageType message_type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 switch (type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 case VIM_ERROR: message_type = GTK_MESSAGE_ERROR; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 case VIM_WARNING: message_type = GTK_MESSAGE_WARNING; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 case VIM_QUESTION: message_type = GTK_MESSAGE_QUESTION; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 default: message_type = GTK_MESSAGE_INFO; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 message = CONVERT_TO_UTF8(message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417 dialog = gtk_message_dialog_new(GTK_WINDOW(gui.mainwin),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 GTK_DIALOG_DESTROY_WITH_PARENT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419 message_type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 GTK_BUTTONS_NONE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421 "%s", (const char *)message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422 CONVERT_TO_UTF8_FREE(message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 if (title != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 title = CONVERT_TO_UTF8(title);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 gtk_window_set_title(GTK_WINDOW(dialog), (const char *)title);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 CONVERT_TO_UTF8_FREE(title);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 else if (type == VIM_GENERIC)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 gtk_window_set_title(GTK_WINDOW(dialog), "VIM");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 return dialog;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 * Split up button_string into individual button labels by inserting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440 * NUL bytes. Also replace the Vim-style mnemonic accelerator prefix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 * '&' with '_'. button_string must point to allocated memory!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442 * Return an allocated array of pointers into button_string.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444 static char **
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 split_button_string(char_u *button_string, int *n_buttons)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 char **array;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 unsigned int count = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 for (p = button_string; *p != NUL; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1452 if (*p == DLG_BUTTON_SEP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453 ++count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16764
diff changeset
1455 array = ALLOC_MULT(char *, count + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1456 count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 if (array != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 array[count++] = (char *)button_string;
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
1461 for (p = button_string; *p != NUL; )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 if (*p == DLG_BUTTON_SEP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 {
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
1465 *p++ = NUL;
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
1466 array[count++] = (char *)p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 else if (*p == DLG_HOTKEY_CHAR)
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
1469 *p++ = '_';
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
1470 else
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10544
diff changeset
1471 MB_PTR_ADV(p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 }
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1473 array[count] = NULL; // currently not relied upon, but doesn't hurt
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 *n_buttons = count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 return array;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 static char **
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 split_button_translation(const char *message)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 char **buttons = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 char_u *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 int n_buttons = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 int n_expected = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488 for (str = (char_u *)message; *str != NUL; ++str)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 if (*str == DLG_BUTTON_SEP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 ++n_expected;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 str = (char_u *)_(message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 if (str != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 if (output_conv.vc_type != CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496 str = string_convert(&output_conv, str, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498 str = vim_strsave(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 if (str != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1501 buttons = split_button_string(str, &n_buttons);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 * Uh-oh... this should never ever happen. But we don't wanna crash
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 * if the translation is broken, thus fall back to the untranslated
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 * buttons string in case of emergency.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 if (buttons == NULL || n_buttons != n_expected)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 vim_free(buttons);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 vim_free(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 buttons = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 str = vim_strsave((char_u *)message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515 if (str != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 buttons = split_button_string(str, &n_buttons);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 if (buttons == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 vim_free(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 return buttons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 button_equal(const char *a, const char *b)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 while (*a != '\0' && *b != '\0')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 if (*a == '_' && *++a == '\0')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 if (*b == '_' && *++b == '\0')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 if (g_unichar_tolower(g_utf8_get_char(a))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 != g_unichar_tolower(g_utf8_get_char(b)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538 a = g_utf8_next_char(a);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539 b = g_utf8_next_char(b);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 return (*a == '\0' && *b == '\0');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 dialog_add_buttons(GtkDialog *dialog, char_u *button_string)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1548 char **ok;
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1549 char **ync; // "yes no cancel"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 char **buttons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 int n_buttons = 0;
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 867
diff changeset
1552 int idx;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1554 button_string = vim_strsave(button_string); // must be writable
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 if (button_string == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1558 // Check 'v' flag in 'guioptions': vertical button placement.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1559 if (vim_strchr(p_go, GO_VERTICAL) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1560 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1561 # if GTK_CHECK_VERSION(3,0,0)
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1562 // Add GTK+ 3 code if necessary.
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1563 // N.B. GTK+ 3 doesn't allow you to access vbox and action_area via
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1564 // the C API.
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1565 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 GtkWidget *vbutton_box;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1567
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 vbutton_box = gtk_vbutton_box_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569 gtk_widget_show(vbutton_box);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570 gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->vbox),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1571 vbutton_box, TRUE, FALSE, 0);
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1572 // Overrule the "action_area" value, hopefully this works...
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1573 GTK_DIALOG(dialog)->action_area = vbutton_box;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1574 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1575 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578 * Yes this is ugly, I don't particularly like it either. But doing it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1579 * this way has the compelling advantage that translations need not to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1580 * be touched at all. See below what 'ok' and 'ync' are used for.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1581 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1582 ok = split_button_translation(N_("&Ok"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1583 ync = split_button_translation(N_("&Yes\n&No\n&Cancel"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1584 buttons = split_button_string(button_string, &n_buttons);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1585
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1586 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1587 * Yes, the buttons are in reversed order to match the GNOME 2 desktop
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1588 * environment. Don't hit me -- it's all about consistency.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1589 * Well, apparently somebody changed his mind: with GTK 2.2.4 it works the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1590 * other way around...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1591 */
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 867
diff changeset
1592 for (idx = 1; idx <= n_buttons; ++idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1593 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1594 char *label;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1595 char_u *label8;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1596
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 867
diff changeset
1597 label = buttons[idx - 1];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1598 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1599 * Perform some guesswork to find appropriate stock items for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1600 * buttons. We have to compare with a sample of the translated
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1601 * button string to get things right. Yes, this is hackish :/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1602 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1603 * But even the common button labels aren't necessarily translated,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1604 * since anyone can create their own dialogs using Vim functions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1605 * Thus we have to check for those too.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1606 */
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1607 if (ok != NULL && ync != NULL) // almost impossible to fail
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1608 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1609 # if GTK_CHECK_VERSION(3,10,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1610 if (button_equal(label, ok[0])) label = _("OK");
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1611 else if (button_equal(label, ync[0])) label = _("Yes");
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1612 else if (button_equal(label, ync[1])) label = _("No");
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1613 else if (button_equal(label, ync[2])) label = _("Cancel");
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1614 else if (button_equal(label, "Ok")) label = _("OK");
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1615 else if (button_equal(label, "Yes")) label = _("Yes");
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1616 else if (button_equal(label, "No")) label = _("No");
8279
738c2929d6ad commit https://github.com/vim/vim/commit/4d1961783fdcb133b6b181acb7166b9f1872bf09
Christian Brabandt <cb@256bit.org>
parents: 8218
diff changeset
1617 else if (button_equal(label, "Cancel")) label = _("Cancel");
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1618 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1619 if (button_equal(label, ok[0])) label = GTK_STOCK_OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1620 else if (button_equal(label, ync[0])) label = GTK_STOCK_YES;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1621 else if (button_equal(label, ync[1])) label = GTK_STOCK_NO;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1622 else if (button_equal(label, ync[2])) label = GTK_STOCK_CANCEL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1623 else if (button_equal(label, "Ok")) label = GTK_STOCK_OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1624 else if (button_equal(label, "Yes")) label = GTK_STOCK_YES;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1625 else if (button_equal(label, "No")) label = GTK_STOCK_NO;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1626 else if (button_equal(label, "Cancel")) label = GTK_STOCK_CANCEL;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1627 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1628 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1629 label8 = CONVERT_TO_UTF8((char_u *)label);
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 867
diff changeset
1630 gtk_dialog_add_button(dialog, (const gchar *)label8, idx);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1631 CONVERT_TO_UTF8_FREE(label8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1632 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1633
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1634 if (ok != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1635 vim_free(*ok);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1636 if (ync != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1637 vim_free(*ync);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1638 vim_free(ok);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1639 vim_free(ync);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1640 vim_free(buttons);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1641 vim_free(button_string);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1642 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1643
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1644 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1645 * Allow mnemonic accelerators to be activated without pressing <Alt>.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1646 * I'm not sure if it's a wise idea to do this. However, the old GTK+ 1.2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1647 * GUI used to work this way, and I consider the impact on UI consistency
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1648 * low enough to justify implementing this as a special Vim feature.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1649 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1650 typedef struct _DialogInfo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1651 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1652 int ignore_enter; // no default button, ignore "Enter"
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1653 int noalt; // accept accelerators without Alt
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1654 GtkDialog *dialog; // Widget of the dialog
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1655 } DialogInfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1656
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1657 static gboolean
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1658 dialog_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1659 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1660 DialogInfo *di = (DialogInfo *)data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1661
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1662 // Ignore hitting Enter (or Space) when there is no default button.
1355
888c0645d64f updated for version 7.1-069
vimboss
parents: 1286
diff changeset
1663 if (di->ignore_enter && (event->keyval == GDK_Return
888c0645d64f updated for version 7.1-069
vimboss
parents: 1286
diff changeset
1664 || event->keyval == ' '))
888c0645d64f updated for version 7.1-069
vimboss
parents: 1286
diff changeset
1665 return TRUE;
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1666 else // A different key was pressed, return to normal behavior
1355
888c0645d64f updated for version 7.1-069
vimboss
parents: 1286
diff changeset
1667 di->ignore_enter = FALSE;
888c0645d64f updated for version 7.1-069
vimboss
parents: 1286
diff changeset
1668
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1669 // Close the dialog when hitting "Esc".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1670 if (event->keyval == GDK_Escape)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1671 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1672 gtk_dialog_response(di->dialog, GTK_RESPONSE_REJECT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1673 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1675
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1676 if (di->noalt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1677 && (event->state & gtk_accelerator_get_default_mod_mask()) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1678 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679 return gtk_window_mnemonic_activate(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 GTK_WINDOW(widget), event->keyval,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681 gtk_window_get_mnemonic_modifier(GTK_WINDOW(widget)));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1682 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1683
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1684 return FALSE; // continue emission
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1685 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1686
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1687 int
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1688 gui_mch_dialog(int type, // type of dialog
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1689 char_u *title, // title of dialog
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1690 char_u *message, // message text
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1691 char_u *buttons, // names of buttons
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1692 int def_but, // default button
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1693 char_u *textfield, // text for textfield or NULL
2684
951641b8784d updated for version 7.3.102
Bram Moolenaar <bram@vim.org>
parents: 2656
diff changeset
1694 int ex_cmd UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1695 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696 GtkWidget *dialog;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 GtkWidget *entry = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1698 char_u *text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1699 int response;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1700 DialogInfo dialoginfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 dialog = create_message_dialog(type, title, message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1703 dialoginfo.dialog = GTK_DIALOG(dialog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1704 dialog_add_buttons(GTK_DIALOG(dialog), buttons);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1705
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1706 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1707 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1708 GtkWidget *alignment;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1710 entry = gtk_entry_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1711 gtk_widget_show(entry);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1712
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1713 // Make Enter work like pressing OK.
3664
0e06193d4bd7 updated for version 7.3.592
Bram Moolenaar <bram@vim.org>
parents: 3564
diff changeset
1714 gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
2649
b2789846ed39 updated for version 7.3.069
Bram Moolenaar <bram@vim.org>
parents: 2301
diff changeset
1715
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1716 text = CONVERT_TO_UTF8(textfield);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1717 gtk_entry_set_text(GTK_ENTRY(entry), (const char *)text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1718 CONVERT_TO_UTF8_FREE(text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1719
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1720 # if GTK_CHECK_VERSION(3,14,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1721 gtk_widget_set_halign(GTK_WIDGET(entry), GTK_ALIGN_CENTER);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1722 gtk_widget_set_valign(GTK_WIDGET(entry), GTK_ALIGN_CENTER);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1723 gtk_widget_set_hexpand(GTK_WIDGET(entry), TRUE);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1724 gtk_widget_set_vexpand(GTK_WIDGET(entry), TRUE);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1725
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1726 alignment = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1727 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1728 alignment = gtk_alignment_new((float)0.5, (float)0.5,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1729 (float)1.0, (float)1.0);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1730 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1731 gtk_container_add(GTK_CONTAINER(alignment), entry);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1732 gtk_container_set_border_width(GTK_CONTAINER(alignment), 5);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1733 gtk_widget_show(alignment);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1734
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1735 # if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1736 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1737 GtkWidget * const vbox
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1738 = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1739 gtk_box_pack_start(GTK_BOX(vbox),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1740 alignment, TRUE, FALSE, 0);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1741 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1742 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1744 alignment, TRUE, FALSE, 0);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1745 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746 dialoginfo.noalt = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1747 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1749 dialoginfo.noalt = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1750
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1751 // Allow activation of mnemonic accelerators without pressing <Alt> when
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1752 // there is no textfield. Handle pressing Esc.
14786
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
1753 g_signal_connect(G_OBJECT(dialog), "key-press-event",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 G_CALLBACK(&dialog_key_press_event_cb), &dialoginfo);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756 if (def_but > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 gtk_dialog_set_default_response(GTK_DIALOG(dialog), def_but);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 dialoginfo.ignore_enter = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761 else
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1762 // No default button, ignore pressing Enter.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1763 dialoginfo.ignore_enter = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1765 // Show the mouse pointer if it's currently hidden.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 gui_mch_mousehide(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 response = gtk_dialog_run(GTK_DIALOG(dialog));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1770 // GTK_RESPONSE_NONE means the dialog was programmatically destroyed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 if (response != GTK_RESPONSE_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1773 if (response == GTK_RESPONSE_ACCEPT) // Enter pressed
314
529f887b5cb7 updated for version 7.0082
vimboss
parents: 270
diff changeset
1774 response = def_but;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777 text = (char_u *)gtk_entry_get_text(GTK_ENTRY(entry));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1778 text = CONVERT_FROM_UTF8(text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 401
diff changeset
1780 vim_strncpy(textfield, text, IOSIZE - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1781
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 CONVERT_FROM_UTF8_FREE(text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 gtk_widget_destroy(dialog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787 return response > 0 ? response : 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1790 #endif // FEAT_GUI_DIALOG
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793 #if defined(FEAT_MENU) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796 gui_mch_show_popupmenu(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797 {
2275
e4d849f4df03 Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2103
diff changeset
1798 # if defined(FEAT_XIM)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800 * Append a submenu for selecting an input method. This is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801 * currently the only way to switch input methods at runtime.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 */
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1803 # if !GTK_CHECK_VERSION(3,10,0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804 if (xic != NULL && g_object_get_data(G_OBJECT(menu->submenu_id),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1805 "vim-has-im-menu") == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807 GtkWidget *menuitem;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1808 GtkWidget *submenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1809 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1810
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1811 menuitem = gtk_separator_menu_item_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1812 gtk_widget_show(menuitem);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1813 gtk_menu_shell_append(GTK_MENU_SHELL(menu->submenu_id), menuitem);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1814
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1815 name = (char_u *)_("Input _Methods");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1816 name = CONVERT_TO_UTF8(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1817 menuitem = gtk_menu_item_new_with_mnemonic((const char *)name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818 CONVERT_TO_UTF8_FREE(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1819 gtk_widget_show(menuitem);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1820
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1821 submenu = gtk_menu_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1822 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1823 gtk_menu_shell_append(GTK_MENU_SHELL(menu->submenu_id), menuitem);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1824
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1825 gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(xic),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826 GTK_MENU_SHELL(submenu));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827 g_object_set_data(G_OBJECT(menu->submenu_id),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1828 "vim-has-im-menu", GINT_TO_POINTER(TRUE));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1829 }
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1830 # endif
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1831 # endif // FEAT_XIM
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1832
10390
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1833 # if GTK_CHECK_VERSION(3,22,2)
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1834 {
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1835 GdkEventButton trigger;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1836
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1837 // A pseudo event to have gtk_menu_popup_at_pointer() work. Since the
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1838 // function calculates the popup menu position on the basis of the
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1839 // actual pointer position when it is invoked, the fields x, y, x_root
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1840 // and y_root are set to zero for convenience.
10390
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1841 trigger.type = GDK_BUTTON_PRESS;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1842 trigger.window = gtk_widget_get_window(gui.drawarea);
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1843 trigger.send_event = FALSE;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1844 trigger.time = gui.event_time;
13353
8412df1479a3 patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents: 13184
diff changeset
1845 trigger.x = 0.0;
8412df1479a3 patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents: 13184
diff changeset
1846 trigger.y = 0.0;
10390
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1847 trigger.axes = NULL;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1848 trigger.state = 0;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1849 trigger.button = 3;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1850 trigger.device = NULL;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1851 trigger.x_root = 0.0;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1852 trigger.y_root = 0.0;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1853
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1854 gtk_menu_popup_at_pointer(GTK_MENU(menu->submenu_id),
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1855 (GdkEvent *)&trigger);
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1856 }
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1857 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 gtk_menu_popup(GTK_MENU(menu->submenu_id),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1859 NULL, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860 (GtkMenuPositionFunc)NULL, NULL,
2923
7653420fdc45 updated for version 7.3.234
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1861 3U, gui.event_time);
10390
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1862 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1864
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1865 // Ugly global variable to pass "mouse_pos" flag from gui_make_popup() to
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1866 // popup_menu_position_func().
401
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1867 static int popup_mouse_pos;
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1868
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1869 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 * Menu position callback; used by gui_make_popup() to place the menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1871 * at the current text cursor position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1872 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1873 * Note: The push_in output argument seems to affect scrolling of huge
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1874 * menus that don't fit on the screen. Leave it at the default for now.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1875 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1876 static void
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
1877 popup_menu_position_func(GtkMenu *menu UNUSED,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1878 gint *x, gint *y,
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
1879 gboolean *push_in UNUSED,
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
1880 gpointer user_data UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1881 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1882 gdk_window_get_origin(gtk_widget_get_window(gui.drawarea), x, y);
401
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1883
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1884 if (popup_mouse_pos)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1885 {
401
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1886 int mx, my;
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1887
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1888 gui_mch_getmouse(&mx, &my);
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1889 *x += mx;
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1890 *y += my;
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1891 }
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1892 else if (curwin != NULL && gui.drawarea != NULL &&
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1893 gtk_widget_get_window(gui.drawarea) != NULL)
401
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1894 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1895 // Find the cursor position in the current window
12513
3ca08bf99396 patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
1896 *x += FILL_X(curwin->w_wincol + curwin->w_wcol + 1) + 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1897 *y += FILL_Y(W_WINROW(curwin) + curwin->w_wrow + 1) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1900
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 void
401
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1902 gui_make_popup(char_u *path_name, int mouse_pos)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1904 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905
401
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1906 popup_mouse_pos = mouse_pos;
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
1907
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 menu = gui_find_menu(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 if (menu != NULL && menu->submenu_id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 {
10390
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1912 # if GTK_CHECK_VERSION(3,22,2)
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1913 GdkWindow * const win = gtk_widget_get_window(gui.drawarea);
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1914 GdkEventButton trigger;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1915
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1916 // A pseudo event to have gtk_menu_popup_at_*() functions work. Since
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1917 // the position where the menu pops up is automatically adjusted by
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1918 // the functions, none of the fields x, y, x_root and y_root has to be
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1919 // set to a specific value here; therefore, they are set to zero for
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1920 // convenience.
10390
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1921 trigger.type = GDK_BUTTON_PRESS;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1922 trigger.window = win;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1923 trigger.send_event = FALSE;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1924 trigger.time = GDK_CURRENT_TIME;
13353
8412df1479a3 patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents: 13184
diff changeset
1925 trigger.x = 0.0;
8412df1479a3 patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents: 13184
diff changeset
1926 trigger.y = 0.0;
10390
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1927 trigger.axes = NULL;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1928 trigger.state = 0;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1929 trigger.button = 0;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1930 trigger.device = NULL;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1931 trigger.x_root = 0.0;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1932 trigger.y_root = 0.0;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1933
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1934 if (mouse_pos)
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1935 gtk_menu_popup_at_pointer(GTK_MENU(menu->submenu_id),
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1936 (GdkEvent *)&trigger);
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1937 else
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1938 {
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1939 gint origin_x, origin_y;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1940 GdkRectangle rect = { 0, 0, 0, 0 };
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1941
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1942 gdk_window_get_origin(win, &origin_x, &origin_y);
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1943 popup_menu_position_func(NULL, &rect.x, &rect.y, NULL, NULL);
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1944
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1945 rect.x -= origin_x;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1946 rect.y -= origin_y;
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1947
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1948 gtk_menu_popup_at_rect(GTK_MENU(menu->submenu_id),
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1949 win,
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1950 &rect,
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1951 GDK_GRAVITY_SOUTH_EAST,
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1952 GDK_GRAVITY_NORTH_WEST,
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1953 (GdkEvent *)&trigger);
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1954 }
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1955 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1956 gtk_menu_popup(GTK_MENU(menu->submenu_id),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1957 NULL, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1958 &popup_menu_position_func, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1959 0U, (guint32)GDK_CURRENT_TIME);
10390
6c8a4d21b873 commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1960 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1961 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1962 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1963
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1964 #endif // FEAT_MENU
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1965
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1966
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1967 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1968 * We don't create it twice.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1969 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1970
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1971 typedef struct _SharedFindReplace
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1972 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1973 GtkWidget *dialog; // the main dialog widget
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1974 GtkWidget *wword; // 'Whole word only' check button
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1975 GtkWidget *mcase; // 'Match case' check button
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1976 GtkWidget *up; // search direction 'Up' radio button
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1977 GtkWidget *down; // search direction 'Down' radio button
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1978 GtkWidget *what; // 'Find what' entry text widget
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1979 GtkWidget *with; // 'Replace with' entry text widget
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1980 GtkWidget *find; // 'Find Next' action button
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1981 GtkWidget *replace; // 'Replace With' action button
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1982 GtkWidget *all; // 'Replace All' action button
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1983 } SharedFindReplace;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1984
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
1985 static SharedFindReplace find_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
1986 static SharedFindReplace repl_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
1987
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1988 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1989 find_key_press_event(
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
1990 GtkWidget *widget UNUSED,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 GdkEventKey *event,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992 SharedFindReplace *frdp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1993 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1994 // If the user is holding one of the key modifiers we will just bail out,
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1995 // thus preserving the possibility of normal focus traversal.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1999 // the Escape key synthesizes a cancellation action
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000 if (event->keyval == GDK_Escape)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2001 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 gtk_widget_hide(frdp->dialog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2003
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2004 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2006
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2007 // It would be delightful if it where possible to do search history
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2008 // operations on the K_UP and K_DOWN keys here.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2009
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2010 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2012
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2013 static GtkWidget *
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2014 #if GTK_CHECK_VERSION(3,10,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2015 create_image_button(const char *stock_id UNUSED,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2016 const char *label)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2017 #else
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2018 create_image_button(const char *stock_id,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2019 const char *label)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2020 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2021 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2022 char_u *text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2023 GtkWidget *box;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2024 GtkWidget *alignment;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2025 GtkWidget *button;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2026
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027 text = CONVERT_TO_UTF8((char_u *)label);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2028
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2029 #if GTK_CHECK_VERSION(3,2,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2030 box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2031 gtk_box_set_homogeneous(GTK_BOX(box), FALSE);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2032 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 box = gtk_hbox_new(FALSE, 3);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2034 #endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2035 #if !GTK_CHECK_VERSION(3,10,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2036 if (stock_id != NULL)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2037 gtk_box_pack_start(GTK_BOX(box),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2038 gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_BUTTON),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2039 FALSE, FALSE, 0);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2040 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2041 gtk_box_pack_start(GTK_BOX(box),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2042 gtk_label_new((const char *)text),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2043 FALSE, FALSE, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2044
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2045 CONVERT_TO_UTF8_FREE(text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2046
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2047 #if GTK_CHECK_VERSION(3,14,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2048 gtk_widget_set_halign(GTK_WIDGET(box), GTK_ALIGN_CENTER);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2049 gtk_widget_set_valign(GTK_WIDGET(box), GTK_ALIGN_CENTER);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2050 gtk_widget_set_hexpand(GTK_WIDGET(box), TRUE);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2051 gtk_widget_set_vexpand(GTK_WIDGET(box), TRUE);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2052
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2053 alignment = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2054 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2055 alignment = gtk_alignment_new((float)0.5, (float)0.5,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2056 (float)0.0, (float)0.0);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2057 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2058 gtk_container_add(GTK_CONTAINER(alignment), box);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 gtk_widget_show_all(alignment);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2061 button = gtk_button_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 gtk_container_add(GTK_CONTAINER(button), alignment);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064 return button;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2065 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2066
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2067 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2068 * This is currently only used by find_replace_dialog_create(), and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2069 * I'd really like to keep it at that. In other words: don't spread
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2070 * this nasty hack all over the code. Think twice.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2071 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2072 static const char *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2073 convert_localized_message(char_u **buffer, const char *message)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2074 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2075 if (output_conv.vc_type == CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2076 return message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2077
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2078 vim_free(*buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079 *buffer = string_convert(&output_conv, (char_u *)message, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2080
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2081 return (const char *)*buffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2082 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2083
13184
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2084 /*
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2085 * Returns the number of characters in GtkEntry.
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2086 */
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2087 static unsigned long
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2088 entry_get_text_length(GtkEntry *entry)
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2089 {
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2090 g_return_val_if_fail(entry != NULL, 0);
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2091 g_return_val_if_fail(GTK_IS_ENTRY(entry) == TRUE, 0);
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2092
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2093 #if GTK_CHECK_VERSION(2,18,0)
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2094 // 2.18 introduced a new object GtkEntryBuffer to handle text data for
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2095 // GtkEntry instead of letting each instance of the latter have its own
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2096 // storage for that. The code below is almost identical to the
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2097 // implementation of gtk_entry_get_text_length() for the versions >= 2.18.
13184
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2098 return gtk_entry_buffer_get_length(gtk_entry_get_buffer(entry));
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2099 #elif GTK_CHECK_VERSION(2,14,0)
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2100 // 2.14 introduced a new function to avoid memory management bugs which can
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2101 // happen when gtk_entry_get_text() is used without due care and attention.
13184
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2102 return gtk_entry_get_text_length(entry);
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2103 #else
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2104 // gtk_entry_get_text() returns the pointer to the storage allocated
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2105 // internally by the widget. Accordingly, use the one with great care:
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2106 // Don't free it nor modify the contents it points to; call the function
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2107 // every time you need the pointer since its value may have been changed
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2108 // by the widget.
13184
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2109 return g_utf8_strlen(gtk_entry_get_text(entry), -1);
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2110 #endif
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2111 }
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2112
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2113 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2114 find_replace_dialog_create(char_u *arg, int do_replace)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2115 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2116 GtkWidget *hbox; // main top down box
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2117 GtkWidget *actionarea;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2118 GtkWidget *table;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2119 GtkWidget *tmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2120 GtkWidget *vbox;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2121 gboolean sensitive;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2122 SharedFindReplace *frdp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2123 char_u *entry_text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2124 int wword = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2125 int mcase = !p_ic;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2126 char_u *conv_buffer = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2127 # define CONV(message) convert_localized_message(&conv_buffer, (message))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2128
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2129 frdp = (do_replace) ? (&repl_widgets) : (&find_widgets);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2130
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2131 // Get the search string to use.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2132 entry_text = get_find_dialog_text(arg, &wword, &mcase);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2133
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2134 if (entry_text != NULL && output_conv.vc_type != CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2135 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2136 char_u *old_text = entry_text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2137 entry_text = string_convert(&output_conv, entry_text, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2138 vim_free(old_text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2139 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2141 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2142 * If the dialog already exists, just raise it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2143 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2144 if (frdp->dialog)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2145 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2146 if (entry_text != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2147 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2148 gtk_entry_set_text(GTK_ENTRY(frdp->what), (char *)entry_text);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2149 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->wword),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2150 (gboolean)wword);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2151 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->mcase),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2152 (gboolean)mcase);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2153 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2154 gtk_window_present(GTK_WINDOW(frdp->dialog));
13119
729f279fda8d patch 8.0.1434: GTK: :promtfind does not put focus on text input
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
2155
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2156 // For :promptfind dialog, always give keyboard focus to 'what' entry.
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2157 // For :promptrepl dialog, give it to 'with' entry if 'what' has an
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2158 // non-empty entry; otherwise, to 'what' entry.
13119
729f279fda8d patch 8.0.1434: GTK: :promtfind does not put focus on text input
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
2159 gtk_widget_grab_focus(frdp->what);
13184
2ede8acf65dc patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents: 13119
diff changeset
2160 if (do_replace && entry_get_text_length(GTK_ENTRY(frdp->what)) > 0)
13119
729f279fda8d patch 8.0.1434: GTK: :promtfind does not put focus on text input
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
2161 gtk_widget_grab_focus(frdp->with);
729f279fda8d patch 8.0.1434: GTK: :promtfind does not put focus on text input
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
2162
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2163 vim_free(entry_text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2164 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2165 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2167 frdp->dialog = gtk_dialog_new();
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2168 #if GTK_CHECK_VERSION(3,0,0)
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2169 // Nothing equivalent to gtk_dialog_set_has_separator() in GTK+ 3.
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2170 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2171 gtk_dialog_set_has_separator(GTK_DIALOG(frdp->dialog), FALSE);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2172 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2173 gtk_window_set_transient_for(GTK_WINDOW(frdp->dialog), GTK_WINDOW(gui.mainwin));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2174 gtk_window_set_destroy_with_parent(GTK_WINDOW(frdp->dialog), TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2175
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2176 if (do_replace)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2177 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2178 gtk_window_set_title(GTK_WINDOW(frdp->dialog),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2179 CONV(_("VIM - Search and Replace...")));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2180 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2181 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2182 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2183 gtk_window_set_title(GTK_WINDOW(frdp->dialog),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2184 CONV(_("VIM - Search...")));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2185 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2186
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2187 #if GTK_CHECK_VERSION(3,2,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2188 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2189 gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2190 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2191 hbox = gtk_hbox_new(FALSE, 0);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2192 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2193 gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2194 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2195 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2196 GtkWidget * const dialog_vbox
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2197 = gtk_dialog_get_content_area(GTK_DIALOG(frdp->dialog));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2198 gtk_container_add(GTK_CONTAINER(dialog_vbox), hbox);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2199 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2200 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2201 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(frdp->dialog)->vbox), hbox);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2202 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2203
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2204 if (do_replace)
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2205 #if GTK_CHECK_VERSION(3,4,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2206 table = gtk_grid_new();
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2207 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2208 table = gtk_table_new(1024, 4, FALSE);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2209 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2210 else
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2211 #if GTK_CHECK_VERSION(3,4,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2212 table = gtk_grid_new();
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2213 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2214 table = gtk_table_new(1024, 3, FALSE);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2215 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2216 gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 0);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2217 gtk_container_set_border_width(GTK_CONTAINER(table), 4);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2219 tmp = gtk_label_new(CONV(_("Find what:")));
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2220 #if GTK_CHECK_VERSION(3,16,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2221 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2222 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2223 #elif GTK_CHECK_VERSION(3,14,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2224 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2225 GValue align_val = G_VALUE_INIT;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2226
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2227 g_value_init(&align_val, G_TYPE_FLOAT);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2228
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2229 g_value_set_float(&align_val, 0.0);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2230 g_object_set_property(G_OBJECT(tmp), "xalign", &align_val);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2231
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2232 g_value_set_float(&align_val, 0.5);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2233 g_object_set_property(G_OBJECT(tmp), "yalign", &align_val);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2234
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2235 g_value_unset(&align_val);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2236 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2237 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2238 gtk_misc_set_alignment(GTK_MISC(tmp), (gfloat)0.0, (gfloat)0.5);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2239 #endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2240 #if GTK_CHECK_VERSION(3,4,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2241 gtk_grid_attach(GTK_GRID(table), tmp, 0, 0, 2, 1);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2242 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2243 gtk_table_attach(GTK_TABLE(table), tmp, 0, 1, 0, 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2244 GTK_FILL, GTK_EXPAND, 2, 2);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2245 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2246 frdp->what = gtk_entry_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2247 sensitive = (entry_text != NULL && entry_text[0] != NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2248 if (entry_text != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2249 gtk_entry_set_text(GTK_ENTRY(frdp->what), (char *)entry_text);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2250 g_signal_connect(G_OBJECT(frdp->what), "changed",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2251 G_CALLBACK(entry_changed_cb), frdp->dialog);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2252 g_signal_connect_after(G_OBJECT(frdp->what), "key-press-event",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2253 G_CALLBACK(find_key_press_event),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2254 (gpointer) frdp);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2255 #if GTK_CHECK_VERSION(3,4,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2256 gtk_grid_attach(GTK_GRID(table), frdp->what, 2, 0, 5, 1);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2257 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2258 gtk_table_attach(GTK_TABLE(table), frdp->what, 1, 1024, 0, 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2259 GTK_EXPAND | GTK_FILL, GTK_EXPAND, 2, 2);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2260 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2261
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2262 if (do_replace)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2263 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2264 tmp = gtk_label_new(CONV(_("Replace with:")));
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2265 #if GTK_CHECK_VERSION(3,16,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2266 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2267 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2268 #elif GTK_CHECK_VERSION(3,14,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2269 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2270 GValue align_val = G_VALUE_INIT;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2271
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2272 g_value_init(&align_val, G_TYPE_FLOAT);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2273
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2274 g_value_set_float(&align_val, 0.0);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2275 g_object_set_property(G_OBJECT(tmp), "xalign", &align_val);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2276
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2277 g_value_set_float(&align_val, 0.5);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2278 g_object_set_property(G_OBJECT(tmp), "yalign", &align_val);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2279
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2280 g_value_unset(&align_val);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2281 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2282 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2283 gtk_misc_set_alignment(GTK_MISC(tmp), (gfloat)0.0, (gfloat)0.5);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2284 #endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2285 #if GTK_CHECK_VERSION(3,4,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2286 gtk_grid_attach(GTK_GRID(table), tmp, 0, 1, 2, 1);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2287 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2288 gtk_table_attach(GTK_TABLE(table), tmp, 0, 1, 1, 2,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2289 GTK_FILL, GTK_EXPAND, 2, 2);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2290 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2291 frdp->with = gtk_entry_new();
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2292 g_signal_connect(G_OBJECT(frdp->with), "activate",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2293 G_CALLBACK(find_replace_cb),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2294 GINT_TO_POINTER(FRD_R_FINDNEXT));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2295 g_signal_connect_after(G_OBJECT(frdp->with), "key-press-event",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2296 G_CALLBACK(find_key_press_event),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2297 (gpointer) frdp);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2298 #if GTK_CHECK_VERSION(3,4,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2299 gtk_grid_attach(GTK_GRID(table), frdp->with, 2, 1, 5, 1);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2300 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2301 gtk_table_attach(GTK_TABLE(table), frdp->with, 1, 1024, 1, 2,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2302 GTK_EXPAND | GTK_FILL, GTK_EXPAND, 2, 2);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2303 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2304
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2305 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2306 * Make the entry activation only change the input focus onto the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2307 * with item.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2308 */
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2309 g_signal_connect(G_OBJECT(frdp->what), "activate",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2310 G_CALLBACK(entry_activate_cb), frdp->with);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2311 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2312 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2313 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2314 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2315 * Make the entry activation do the search.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2316 */
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2317 g_signal_connect(G_OBJECT(frdp->what), "activate",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2318 G_CALLBACK(find_replace_cb),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2319 GINT_TO_POINTER(FRD_FINDNEXT));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2320 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2321
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2322 // whole word only button
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2323 frdp->wword = gtk_check_button_new_with_label(CONV(_("Match whole word only")));
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2324 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->wword),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2325 (gboolean)wword);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2326 if (do_replace)
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2327 #if GTK_CHECK_VERSION(3,4,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2328 gtk_grid_attach(GTK_GRID(table), frdp->wword, 0, 2, 5, 1);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2329 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2330 gtk_table_attach(GTK_TABLE(table), frdp->wword, 0, 1023, 2, 3,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2331 GTK_FILL, GTK_EXPAND, 2, 2);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2332 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2333 else
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2334 #if GTK_CHECK_VERSION(3,4,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2335 gtk_grid_attach(GTK_GRID(table), frdp->wword, 0, 3, 5, 1);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2336 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2337 gtk_table_attach(GTK_TABLE(table), frdp->wword, 0, 1023, 1, 2,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2338 GTK_FILL, GTK_EXPAND, 2, 2);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2339 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2340
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2341 // match case button
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2342 frdp->mcase = gtk_check_button_new_with_label(CONV(_("Match case")));
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2343 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->mcase),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2344 (gboolean)mcase);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2345 if (do_replace)
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2346 #if GTK_CHECK_VERSION(3,4,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2347 gtk_grid_attach(GTK_GRID(table), frdp->mcase, 0, 3, 5, 1);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2348 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2349 gtk_table_attach(GTK_TABLE(table), frdp->mcase, 0, 1023, 3, 4,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2350 GTK_FILL, GTK_EXPAND, 2, 2);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2351 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2352 else
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2353 #if GTK_CHECK_VERSION(3,4,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2354 gtk_grid_attach(GTK_GRID(table), frdp->mcase, 0, 4, 5, 1);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2355 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2356 gtk_table_attach(GTK_TABLE(table), frdp->mcase, 0, 1023, 2, 3,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2357 GTK_FILL, GTK_EXPAND, 2, 2);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2358 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2359
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2360 tmp = gtk_frame_new(CONV(_("Direction")));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2361 if (do_replace)
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2362 #if GTK_CHECK_VERSION(3,4,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2363 gtk_grid_attach(GTK_GRID(table), tmp, 5, 2, 2, 4);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2364 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2365 gtk_table_attach(GTK_TABLE(table), tmp, 1023, 1024, 2, 4,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2366 GTK_FILL, GTK_FILL, 2, 2);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2367 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2368 else
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2369 #if GTK_CHECK_VERSION(3,4,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2370 gtk_grid_attach(GTK_GRID(table), tmp, 5, 2, 1, 3);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2371 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2372 gtk_table_attach(GTK_TABLE(table), tmp, 1023, 1024, 1, 3,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2373 GTK_FILL, GTK_FILL, 2, 2);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2374 #endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2375 #if GTK_CHECK_VERSION(3,2,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2376 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2377 gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2378 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2379 vbox = gtk_vbox_new(FALSE, 0);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2380 #endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2381 gtk_container_set_border_width(GTK_CONTAINER(vbox), 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2382 gtk_container_add(GTK_CONTAINER(tmp), vbox);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2383
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2384 // 'Up' and 'Down' buttons
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2385 frdp->up = gtk_radio_button_new_with_label(NULL, CONV(_("Up")));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2386 gtk_box_pack_start(GTK_BOX(vbox), frdp->up, TRUE, TRUE, 0);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2387 frdp->down = gtk_radio_button_new_with_label(
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2388 gtk_radio_button_get_group(GTK_RADIO_BUTTON(frdp->up)),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2389 CONV(_("Down")));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2390 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->down), TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2391 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2392 gtk_box_pack_start(GTK_BOX(vbox), frdp->down, TRUE, TRUE, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2393
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2394 // vbox to hold the action buttons
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2395 #if GTK_CHECK_VERSION(3,2,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2396 actionarea = gtk_button_box_new(GTK_ORIENTATION_VERTICAL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2397 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2398 actionarea = gtk_vbutton_box_new();
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2399 #endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2400 gtk_container_set_border_width(GTK_CONTAINER(actionarea), 2);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2401 gtk_box_pack_end(GTK_BOX(hbox), actionarea, FALSE, FALSE, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2402
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2403 // 'Find Next' button
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2404 #if GTK_CHECK_VERSION(3,10,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2405 frdp->find = create_image_button(NULL, _("Find Next"));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2406 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2407 frdp->find = create_image_button(GTK_STOCK_FIND, _("Find Next"));
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2408 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2409 gtk_widget_set_sensitive(frdp->find, sensitive);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2410
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2411 g_signal_connect(G_OBJECT(frdp->find), "clicked",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2412 G_CALLBACK(find_replace_cb),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2413 (do_replace) ? GINT_TO_POINTER(FRD_R_FINDNEXT)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2414 : GINT_TO_POINTER(FRD_FINDNEXT));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2415
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2416 gtk_widget_set_can_default(frdp->find, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2417 gtk_box_pack_start(GTK_BOX(actionarea), frdp->find, FALSE, FALSE, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2418 gtk_widget_grab_default(frdp->find);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2419
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2420 if (do_replace)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2421 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2422 // 'Replace' button
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2423 #if GTK_CHECK_VERSION(3,10,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2424 frdp->replace = create_image_button(NULL, _("Replace"));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2425 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2426 frdp->replace = create_image_button(GTK_STOCK_CONVERT, _("Replace"));
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2427 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2428 gtk_widget_set_sensitive(frdp->replace, sensitive);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2429 gtk_widget_set_can_default(frdp->find, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2430 gtk_box_pack_start(GTK_BOX(actionarea), frdp->replace, FALSE, FALSE, 0);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2431 g_signal_connect(G_OBJECT(frdp->replace), "clicked",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2432 G_CALLBACK(find_replace_cb),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2433 GINT_TO_POINTER(FRD_REPLACE));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2434
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2435 // 'Replace All' button
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2436 #if GTK_CHECK_VERSION(3,10,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2437 frdp->all = create_image_button(NULL, _("Replace All"));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2438 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2439 frdp->all = create_image_button(GTK_STOCK_CONVERT, _("Replace All"));
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2440 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2441 gtk_widget_set_sensitive(frdp->all, sensitive);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2442 gtk_widget_set_can_default(frdp->all, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2443 gtk_box_pack_start(GTK_BOX(actionarea), frdp->all, FALSE, FALSE, 0);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2444 g_signal_connect(G_OBJECT(frdp->all), "clicked",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2445 G_CALLBACK(find_replace_cb),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2446 GINT_TO_POINTER(FRD_REPLACEALL));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2447 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2448
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2449 // 'Cancel' button
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2450 #if GTK_CHECK_VERSION(3,10,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2451 tmp = gtk_button_new_with_mnemonic(_("_Close"));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2452 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2453 tmp = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2454 #endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2455 gtk_widget_set_can_default(tmp, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2456 gtk_box_pack_end(GTK_BOX(actionarea), tmp, FALSE, FALSE, 0);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2457 g_signal_connect_swapped(G_OBJECT(tmp),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2458 "clicked", G_CALLBACK(gtk_widget_hide),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2459 G_OBJECT(frdp->dialog));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2460 g_signal_connect_swapped(G_OBJECT(frdp->dialog),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2461 "delete-event", G_CALLBACK(gtk_widget_hide_on_delete),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2462 G_OBJECT(frdp->dialog));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2463
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2464 #if GTK_CHECK_VERSION(3,2,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2465 tmp = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2466 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2467 tmp = gtk_vseparator_new();
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2468 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2469 gtk_box_pack_end(GTK_BOX(hbox), tmp, FALSE, FALSE, 10);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2470
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2471 // Suppress automatic show of the unused action area
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2472 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2473 # if !GTK_CHECK_VERSION(3,12,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2474 gtk_widget_hide(gtk_dialog_get_action_area(GTK_DIALOG(frdp->dialog)));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2475 # endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2476 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2477 gtk_widget_hide(GTK_DIALOG(frdp->dialog)->action_area);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2478 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2479 gtk_widget_show_all(hbox);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2480 gtk_widget_show(frdp->dialog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2481
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2482 vim_free(entry_text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2483 vim_free(conv_buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2484 #undef CONV
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2485 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2486
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2487 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2488 gui_mch_find_dialog(exarg_T *eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2489 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2490 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2491 find_replace_dialog_create(eap->arg, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2492 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2493
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2494 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2495 gui_mch_replace_dialog(exarg_T *eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2496 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2497 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2498 find_replace_dialog_create(eap->arg, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2499 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2500
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2501 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2502 * Callback for actions of the find and replace dialogs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2503 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2504 static void
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
2505 find_replace_cb(GtkWidget *widget UNUSED, gpointer data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2506 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2507 int flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2508 char_u *find_text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2509 char_u *repl_text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2510 gboolean direction_down;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2511 SharedFindReplace *sfr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2512
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2513 flags = (int)(long)data; // avoid a lint warning here
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2514
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2515 // Get the search/replace strings from the dialog
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2516 if (flags == FRD_FINDNEXT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2517 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2518 repl_text = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2519 sfr = &find_widgets;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2520 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2521 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2522 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2523 repl_text = (char_u *)gtk_entry_get_text(GTK_ENTRY(repl_widgets.with));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2524 sfr = &repl_widgets;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2525 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2526
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2527 find_text = (char_u *)gtk_entry_get_text(GTK_ENTRY(sfr->what));
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2528 direction_down = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->down));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2530 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->wword)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2531 flags |= FRD_WHOLE_WORD;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
2532 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->mcase)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533 flags |= FRD_MATCH_CASE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2535 repl_text = CONVERT_FROM_UTF8(repl_text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2536 find_text = CONVERT_FROM_UTF8(find_text);
2656
4549e0e7fbb6 updated for version 7.3.076
Bram Moolenaar <bram@vim.org>
parents: 2649
diff changeset
2537 gui_do_findrepl(flags, find_text, repl_text, direction_down);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2538 CONVERT_FROM_UTF8_FREE(repl_text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2539 CONVERT_FROM_UTF8_FREE(find_text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2540 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2541
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2542 /*
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2543 * our usual callback function
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2544 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2545 static void
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1693
diff changeset
2546 entry_activate_cb(GtkWidget *widget UNUSED, gpointer data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2547 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2548 gtk_widget_grab_focus(GTK_WIDGET(data));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2549 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2550
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2551 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2552 * Syncing the find/replace dialogs on the fly is utterly useless crack,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2553 * and causes nothing but problems. Please tell me a use case for which
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2554 * you'd need both a find dialog and a find/replace one at the same time,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2555 * without being able to actually use them separately since they're syncing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2556 * all the time. I don't think it's worthwhile to fix this nonsense,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2557 * particularly evil incarnation of braindeadness, whatever; I'd much rather
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2558 * see it extinguished from this planet. Thanks for listening. Sorry.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2560 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2561 entry_changed_cb(GtkWidget * entry, GtkWidget * dialog)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563 const gchar *entry_text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2564 gboolean nonempty;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2566 entry_text = gtk_entry_get_text(GTK_ENTRY(entry));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2567
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2568 if (!entry_text)
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2569 return; // shouldn't happen
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2570
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2571 nonempty = (entry_text[0] != '\0');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2573 if (dialog == find_widgets.dialog)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2574 gtk_widget_set_sensitive(find_widgets.find, nonempty);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2575
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2576 if (dialog == repl_widgets.dialog)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2577 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2578 gtk_widget_set_sensitive(repl_widgets.find, nonempty);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2579 gtk_widget_set_sensitive(repl_widgets.replace, nonempty);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2580 gtk_widget_set_sensitive(repl_widgets.all, nonempty);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2582 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2583
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2584 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2585 * ":helpfind"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2586 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2587 void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7380
diff changeset
2588 ex_helpfind(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2589 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2590 // This will fail when menus are not loaded. Well, it's only for
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2591 // backwards compatibility anyway.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2592 do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2593 }
3484
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
2594
3564
8d1b63e6d317 updated for version 7.3.542
Bram Moolenaar <bram@vim.org>
parents: 3484
diff changeset
2595 #if defined(FEAT_BROWSE) || defined(PROTO)
3484
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
2596 static void
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
2597 recent_func_log_func(const gchar *log_domain UNUSED,
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
2598 GLogLevelFlags log_level UNUSED,
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
2599 const gchar *message UNUSED,
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
2600 gpointer user_data UNUSED)
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
2601 {
18781
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2602 // We just want to suppress the warnings.
79e10adc821d patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2603 // http://bugzilla.gnome.org/show_bug.cgi?id=664587
3484
982f84487daf updated for version 7.3.506
Bram Moolenaar <bram@vim.org>
parents: 2923
diff changeset
2604 }
3564
8d1b63e6d317 updated for version 7.3.542
Bram Moolenaar <bram@vim.org>
parents: 3484
diff changeset
2605 #endif