Mercurial > vim
annotate src/gui_gtk.c @ 32777:1be7af7425f6 v9.0.1705
patch 9.0.1705: cursor position wrong when clicking on an unprintable char
Commit: https://github.com/vim/vim/commit/b25dbb3f9b5885dd623af7a9fae890b8366b64e2
Author: zeertzjq <zeertzjq@outlook.com>
Date: Sun Aug 13 18:11:05 2023 +0200
patch 9.0.1705: cursor position wrong when clicking on an unprintable char
Problem: cursor position wrong when clicking on an unprintable char
Solution: Don't update prev_ptr when wlv.n_extra is not zero.
closes: #12664
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 13 Aug 2023 18:15:05 +0200 |
parents | e5ee2ffd826a |
children | 7279c963c926 |
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 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * Porting to GTK+ was done by: | |
12 * | |
68 | 13 * (C) 1998,1999,2000 by Marcin Dalecki <martin@dalecki.de> |
7 | 14 * |
15 * With GREAT support and continuous encouragements by Andy Kahn and of | |
16 * course Bram Moolenaar! | |
17 * | |
18 * Support for GTK+ 2 was added by: | |
19 * | |
20 * (C) 2002,2003 Jason Hildebrand <jason@peaceworks.ca> | |
21 * Daniel Elstner <daniel.elstner@gmx.net> | |
22 * | |
23 * Best supporting actor (He helped somewhat, aesthetically speaking): | |
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 | 32 */ |
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 | 36 #ifdef FEAT_GUI_GTK |
37 # include "gui_gtk_f.h" | |
38 #endif | |
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 | 42 #ifdef MIN |
43 # undef MIN | |
44 #endif | |
45 #ifdef MAX | |
46 # undef MAX | |
47 #endif | |
48 | |
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 | 51 # ifdef _ |
52 # undef _ | |
53 # endif | |
54 # ifdef N_ | |
55 # undef N_ | |
56 # endif | |
57 # ifdef textdomain | |
58 # undef textdomain | |
59 # endif | |
60 # ifdef bindtextdomain | |
61 # undef bindtextdomain | |
62 # endif | |
1286 | 63 # ifdef bind_textdomain_codeset |
64 # undef bind_textdomain_codeset | |
1215 | 65 # endif |
7 | 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 | 68 # endif |
69 # include <gnome.h> | |
70 #endif | |
71 | |
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 | 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 | 80 # include <gdk/gdkwin32.h> |
81 # else | |
82 # include <gdk/gdkx.h> | |
83 # endif | |
84 | |
85 # include <gtk/gtk.h> | |
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 | 88 typedef int GtkWidget; |
89 # define gpointer int | |
90 # define guint8 int | |
91 # define GdkPixmap int | |
92 # define GdkBitmap int | |
93 # define GtkIconFactory int | |
94 # define GtkToolbar int | |
95 # define GtkAdjustment int | |
96 # define gboolean int | |
97 # define GdkEventKey int | |
98 # define CancelData int | |
99 #endif | |
100 | |
101 static void entry_activate_cb(GtkWidget *widget, gpointer data); | |
102 static void entry_changed_cb(GtkWidget *entry, GtkWidget *dialog); | |
103 static void find_replace_cb(GtkWidget *widget, gpointer data); | |
3564 | 104 #if defined(FEAT_BROWSE) || defined(PROTO) |
3484 | 105 static void recent_func_log_func( |
106 const gchar *log_domain, | |
107 GLogLevelFlags log_level, | |
108 const gchar *message, | |
109 gpointer user_data); | |
3564 | 110 #endif |
7 | 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 | 113 /* |
114 * Table from BuiltIn## icon indices to GTK+ stock IDs. Order must exactly | |
115 * match toolbar_names[] in menu.c! All stock icons including the "vim-*" | |
116 * ones can be overridden in your gtkrc file. | |
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 | 182 static const char * const menu_stock_ids[] = |
183 { | |
184 /* 00 */ GTK_STOCK_NEW, | |
185 /* 01 */ GTK_STOCK_OPEN, | |
186 /* 02 */ GTK_STOCK_SAVE, | |
187 /* 03 */ GTK_STOCK_UNDO, | |
188 /* 04 */ GTK_STOCK_REDO, | |
189 /* 05 */ GTK_STOCK_CUT, | |
190 /* 06 */ GTK_STOCK_COPY, | |
191 /* 07 */ GTK_STOCK_PASTE, | |
192 /* 08 */ GTK_STOCK_PRINT, | |
193 /* 09 */ GTK_STOCK_HELP, | |
194 /* 10 */ GTK_STOCK_FIND, | |
195 /* 11 */ "vim-save-all", | |
196 /* 12 */ "vim-session-save", | |
197 /* 13 */ "vim-session-new", | |
198 /* 14 */ "vim-session-load", | |
199 /* 15 */ GTK_STOCK_EXECUTE, | |
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 | 202 /* 18 */ "vim-window-maximize", |
203 /* 19 */ "vim-window-minimize", | |
204 /* 20 */ "vim-window-split", | |
205 /* 21 */ "vim-shell", | |
206 /* 22 */ GTK_STOCK_GO_BACK, | |
207 /* 23 */ GTK_STOCK_GO_FORWARD, | |
208 /* 24 */ "vim-find-help", | |
209 /* 25 */ GTK_STOCK_CONVERT, | |
210 /* 26 */ GTK_STOCK_JUMP_TO, | |
211 /* 27 */ "vim-build-tags", | |
212 /* 28 */ "vim-window-split-vertical", | |
213 /* 29 */ "vim-window-maximize-width", | |
214 /* 30 */ "vim-window-minimize-width", | |
215 /* 31 */ GTK_STOCK_QUIT | |
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 | 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 | 246 static void |
247 add_stock_icon(GtkIconFactory *factory, | |
248 const char *stock_id, | |
249 const guint8 *inline_data, | |
250 int data_length) | |
251 { | |
252 GdkPixbuf *pixbuf; | |
253 GtkIconSet *icon_set; | |
254 | |
255 pixbuf = gdk_pixbuf_new_from_inline(data_length, inline_data, FALSE, NULL); | |
256 icon_set = gtk_icon_set_new_from_pixbuf(pixbuf); | |
257 | |
258 gtk_icon_factory_add(factory, stock_id, icon_set); | |
259 | |
260 gtk_icon_set_unref(icon_set); | |
261 g_object_unref(pixbuf); | |
262 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
263 # endif |
7 | 264 |
265 static int | |
266 lookup_menu_iconfile(char_u *iconfile, char_u *dest) | |
267 { | |
268 expand_env(iconfile, dest, MAXPATHL); | |
269 | |
270 if (mch_isFullName(dest)) | |
271 { | |
272 return vim_fexists(dest); | |
273 } | |
274 else | |
275 { | |
276 static const char suffixes[][4] = {"png", "xpm", "bmp"}; | |
277 char_u buf[MAXPATHL]; | |
278 unsigned int i; | |
279 | |
280 for (i = 0; i < G_N_ELEMENTS(suffixes); ++i) | |
281 if (gui_find_bitmap(dest, buf, (char *)suffixes[i]) == OK) | |
282 { | |
283 STRCPY(dest, buf); | |
284 return TRUE; | |
285 } | |
286 | |
287 return FALSE; | |
288 } | |
289 } | |
290 | |
291 static GtkWidget * | |
292 load_menu_iconfile(char_u *name, GtkIconSize icon_size) | |
293 { | |
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 | 341 GtkIconSet *icon_set; |
342 GtkIconSource *icon_source; | |
343 | |
344 /* | |
345 * Rather than loading the icon directly into a GtkImage, create | |
346 * a new GtkIconSet and put it in there. This way we can easily | |
347 * scale the toolbar icons on the fly when needed. | |
348 */ | |
349 icon_set = gtk_icon_set_new(); | |
350 icon_source = gtk_icon_source_new(); | |
351 | |
352 gtk_icon_source_set_filename(icon_source, (const char *)name); | |
353 gtk_icon_set_add_source(icon_set, icon_source); | |
354 | |
355 image = gtk_image_new_from_icon_set(icon_set, icon_size); | |
356 | |
357 gtk_icon_source_free(icon_source); | |
358 gtk_icon_set_unref(icon_set); | |
359 | |
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 | 362 } |
363 | |
364 static GtkWidget * | |
365 create_menu_icon(vimmenu_T *menu, GtkIconSize icon_size) | |
366 { | |
367 GtkWidget *image = NULL; | |
368 char_u buf[MAXPATHL]; | |
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 | 371 if (menu->iconfile != NULL && lookup_menu_iconfile(menu->iconfile, buf)) |
372 image = load_menu_iconfile(buf, icon_size); | |
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 | 375 if (image == NULL && !menu->icon_builtin |
376 && lookup_menu_iconfile(menu->name, buf)) | |
377 image = load_menu_iconfile(buf, icon_size); | |
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 | 380 if (image == NULL) |
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 | 393 const char *stock_id; |
394 const int n_ids = G_N_ELEMENTS(menu_stock_ids); | |
395 | |
396 if (menu->iconidx >= 0 && menu->iconidx < n_ids) | |
397 stock_id = menu_stock_ids[menu->iconidx]; | |
398 else | |
399 stock_id = GTK_STOCK_MISSING_IMAGE; | |
400 | |
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 | 403 } |
404 | |
405 return image; | |
406 } | |
407 | |
790 | 408 static gint |
1884 | 409 toolbar_button_focus_in_event(GtkWidget *widget UNUSED, |
410 GdkEventFocus *event UNUSED, | |
411 gpointer data UNUSED) | |
790 | 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 | 416 if (gtk_socket_id != 0) |
856 | 417 gtk_widget_grab_focus(gui.drawarea); |
790 | 418 |
419 return TRUE; | |
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 | 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 | 424 |
425 void | |
426 gui_gtk_register_stock_icons(void) | |
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 | 430 GtkIconFactory *factory; |
431 | |
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 | 434 |
435 ADD_ICON("vim-build-tags", stock_vim_build_tags); | |
436 ADD_ICON("vim-find-help", stock_vim_find_help); | |
437 ADD_ICON("vim-save-all", stock_vim_save_all); | |
438 ADD_ICON("vim-session-load", stock_vim_session_load); | |
439 ADD_ICON("vim-session-new", stock_vim_session_new); | |
440 ADD_ICON("vim-session-save", stock_vim_session_save); | |
441 ADD_ICON("vim-shell", stock_vim_shell); | |
442 ADD_ICON("vim-window-maximize", stock_vim_window_maximize); | |
443 ADD_ICON("vim-window-maximize-width", stock_vim_window_maximize_width); | |
444 ADD_ICON("vim-window-minimize", stock_vim_window_minimize); | |
445 ADD_ICON("vim-window-minimize-width", stock_vim_window_minimize_width); | |
446 ADD_ICON("vim-window-split", stock_vim_window_split); | |
447 ADD_ICON("vim-window-split-vertical", stock_vim_window_split_vertical); | |
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 | 526 gtk_icon_factory_add_default(factory); |
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 | 530 } |
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 | 533 |
534 #if defined(FEAT_MENU) || defined(PROTO) | |
535 | |
536 /* | |
537 * Translate Vim's mnemonic tagging to GTK+ style and convert to UTF-8 | |
538 * if necessary. The caller must vim_free() the returned string. | |
539 * | |
540 * Input Output | |
541 * _ __ | |
542 * && & | |
543 * & _ stripped if use_mnemonic == FALSE | |
544 * <Tab> end of menu label text | |
545 */ | |
546 static char_u * | |
547 translate_mnemonic_tag(char_u *name, int use_mnemonic) | |
548 { | |
549 char_u *buf; | |
550 char_u *psrc; | |
551 char_u *pdest; | |
552 int n_underscores = 0; | |
553 | |
554 name = CONVERT_TO_UTF8(name); | |
555 if (name == NULL) | |
556 return NULL; | |
557 | |
558 for (psrc = name; *psrc != NUL && *psrc != TAB; ++psrc) | |
559 if (*psrc == '_') | |
560 ++n_underscores; | |
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 | 563 if (buf != NULL) |
564 { | |
565 pdest = buf; | |
566 for (psrc = name; *psrc != NUL && *psrc != TAB; ++psrc) | |
567 { | |
568 if (*psrc == '_') | |
569 { | |
570 *pdest++ = '_'; | |
571 *pdest++ = '_'; | |
572 } | |
573 else if (*psrc != '&') | |
574 { | |
575 *pdest++ = *psrc; | |
576 } | |
577 else if (*(psrc + 1) == '&') | |
578 { | |
579 *pdest++ = *psrc++; | |
580 } | |
581 else if (use_mnemonic) | |
582 { | |
583 *pdest++ = '_'; | |
584 } | |
585 } | |
586 *pdest = NUL; | |
587 } | |
588 | |
589 CONVERT_TO_UTF8_FREE(name); | |
590 return buf; | |
591 } | |
592 | |
593 static void | |
594 menu_item_new(vimmenu_T *menu, GtkWidget *parent_widget) | |
595 { | |
596 GtkWidget *box; | |
597 char_u *text; | |
598 int use_mnemonic; | |
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 | 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 | 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 | 610 |
611 use_mnemonic = (p_wak[0] != 'n' || !GTK_IS_MENU_BAR(parent_widget)); | |
612 text = translate_mnemonic_tag(menu->name, use_mnemonic); | |
613 | |
614 menu->label = gtk_label_new_with_mnemonic((const char *)text); | |
615 vim_free(text); | |
616 | |
617 gtk_box_pack_start(GTK_BOX(box), menu->label, FALSE, FALSE, 0); | |
618 | |
619 if (menu->actext != NULL && menu->actext[0] != NUL) | |
620 { | |
621 text = CONVERT_TO_UTF8(menu->actext); | |
622 | |
623 gtk_box_pack_end(GTK_BOX(box), | |
624 gtk_label_new((const char *)text), | |
625 FALSE, FALSE, 0); | |
626 | |
627 CONVERT_TO_UTF8_FREE(text); | |
628 } | |
629 | |
630 gtk_container_add(GTK_CONTAINER(menu->id), box); | |
631 gtk_widget_show_all(menu->id); | |
632 } | |
633 | |
634 void | |
635 gui_mch_add_menu(vimmenu_T *menu, int idx) | |
636 { | |
637 vimmenu_T *parent; | |
638 GtkWidget *parent_widget; | |
639 | |
640 if (menu->name[0] == ']' || menu_is_popup(menu->name)) | |
641 { | |
642 menu->submenu_id = gtk_menu_new(); | |
643 return; | |
644 } | |
645 | |
646 parent = menu->parent; | |
647 | |
648 if ((parent != NULL && parent->submenu_id == NULL) | |
649 || !menu_is_menubar(menu->name)) | |
650 return; | |
651 | |
652 parent_widget = (parent != NULL) ? parent->submenu_id : gui.menubar; | |
653 menu_item_new(menu, parent_widget); | |
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 | 657 if (parent != NULL && !menu_is_popup(parent->name)) |
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 | 660 |
661 gtk_menu_shell_insert(GTK_MENU_SHELL(parent_widget), menu->id, idx); | |
662 | |
663 menu->submenu_id = gtk_menu_new(); | |
664 | |
665 gtk_menu_set_accel_group(GTK_MENU(menu->submenu_id), gui.accel_group); | |
666 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu->id), menu->submenu_id); | |
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 | 669 menu->tearoff_handle = gtk_tearoff_menu_item_new(); |
670 if (vim_strchr(p_go, GO_TEAROFF) != NULL) | |
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 | 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 | 679 } |
680 | |
681 static void | |
1884 | 682 menu_item_activate(GtkWidget *widget UNUSED, gpointer data) |
7 | 683 { |
684 gui_menu_cb((vimmenu_T *)data); | |
685 } | |
686 | |
24353
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
687 static void |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
688 menu_item_select(GtkWidget *widget UNUSED, gpointer data) |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
689 { |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
690 vimmenu_T *menu; |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
691 char_u *tooltip; |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
692 static int did_msg = FALSE; |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
693 |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28150
diff
changeset
|
694 if (State & MODE_CMDLINE) |
24359
db86c2b0d5c6
patch 8.2.2720: GTK menu tooltip moves the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24353
diff
changeset
|
695 return; |
24353
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
696 menu = (vimmenu_T *)data; |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
697 tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
698 if (tooltip != NULL && utf_valid_string(tooltip, NULL)) |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
699 { |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
700 msg((char *)tooltip); |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
701 did_msg = TRUE; |
24359
db86c2b0d5c6
patch 8.2.2720: GTK menu tooltip moves the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24353
diff
changeset
|
702 setcursor(); |
db86c2b0d5c6
patch 8.2.2720: GTK menu tooltip moves the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24353
diff
changeset
|
703 out_flush_cursor(TRUE, FALSE); |
24353
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
704 } |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
705 else if (did_msg) |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
706 { |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
707 msg(""); |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
708 did_msg = FALSE; |
24359
db86c2b0d5c6
patch 8.2.2720: GTK menu tooltip moves the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24353
diff
changeset
|
709 setcursor(); |
db86c2b0d5c6
patch 8.2.2720: GTK menu tooltip moves the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24353
diff
changeset
|
710 out_flush_cursor(TRUE, FALSE); |
24353
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
711 } |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
712 CONVERT_TO_UTF8_FREE(tooltip); |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
713 } |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
714 |
7 | 715 void |
716 gui_mch_add_menu_item(vimmenu_T *menu, int idx) | |
717 { | |
718 vimmenu_T *parent; | |
719 | |
720 parent = menu->parent; | |
721 | |
722 # ifdef FEAT_TOOLBAR | |
723 if (menu_is_toolbar(parent->name)) | |
724 { | |
725 GtkToolbar *toolbar; | |
726 | |
727 toolbar = GTK_TOOLBAR(gui.toolbar); | |
728 menu->submenu_id = NULL; | |
729 | |
730 if (menu_is_separator(menu->name)) | |
731 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
732 # 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
|
733 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
|
734 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
|
735 TRUE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
736 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
|
737 gtk_widget_show(GTK_WIDGET(item)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
738 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
739 gtk_toolbar_insert(toolbar, item, idx); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
740 # else |
7 | 741 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
|
742 # endif |
7 | 743 menu->id = NULL; |
744 } | |
745 else | |
746 { | |
747 char_u *text; | |
748 char_u *tooltip; | |
749 | |
750 text = CONVERT_TO_UTF8(menu->dname); | |
751 tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); | |
26 | 752 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
|
753 // 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
|
754 // a nasty GTK error message, skip the tooltip. |
26 | 755 CONVERT_TO_UTF8_FREE(tooltip); |
7 | 756 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
757 # 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
|
758 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
759 GtkWidget *icon; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
760 GtkToolItem *item; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
761 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
762 icon = create_menu_icon(menu, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
763 gtk_toolbar_get_icon_size(toolbar)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
764 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
|
765 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
|
766 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
|
767 G_CALLBACK(&menu_item_activate), menu); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
768 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
|
769 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
770 gtk_toolbar_insert(toolbar, item, idx); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
771 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
772 menu->id = GTK_WIDGET(item); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
773 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
774 # else |
7 | 775 menu->id = gtk_toolbar_insert_item( |
776 toolbar, | |
777 (const char *)text, | |
778 (const char *)tooltip, | |
779 NULL, | |
780 create_menu_icon(menu, gtk_toolbar_get_icon_size(toolbar)), | |
781 G_CALLBACK(&menu_item_activate), | |
782 menu, | |
783 idx); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
784 # endif |
7 | 785 |
856 | 786 if (gtk_socket_id != 0) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
787 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
|
788 G_CALLBACK(toolbar_button_focus_in_event), NULL); |
790 | 789 |
7 | 790 CONVERT_TO_UTF8_FREE(text); |
791 CONVERT_TO_UTF8_FREE(tooltip); | |
792 } | |
793 } | |
794 else | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
795 # endif // FEAT_TOOLBAR |
7 | 796 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
797 // No parent, must be a non-menubar menu |
840 | 798 if (parent == NULL || parent->submenu_id == NULL) |
7 | 799 return; |
800 | |
11508
9b1077d33c68
patch 8.0.0637: crash when using some version of GTK 3
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
801 # 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
|
802 // 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
|
803 // menu, it doesn't have a tearoff item. |
840 | 804 if (!menu_is_popup(parent->name)) |
7 | 805 ++idx; |
11508
9b1077d33c68
patch 8.0.0637: crash when using some version of GTK 3
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
806 # endif |
7 | 807 |
808 if (menu_is_separator(menu->name)) | |
809 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
810 // Separator: Just add it |
9035
08854bb267b2
commit https://github.com/vim/vim/commit/0b6cf69c038b9af198542edc349ebe8e53a8f847
Christian Brabandt <cb@256bit.org>
parents:
8279
diff
changeset
|
811 # 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
|
812 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
|
813 # else |
7 | 814 menu->id = gtk_menu_item_new(); |
815 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
|
816 # endif |
7 | 817 gtk_widget_show(menu->id); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
818 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
|
819 menu->id, idx); |
7 | 820 |
821 return; | |
822 } | |
823 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
824 // Add textual menu item. |
7 | 825 menu_item_new(menu, parent->submenu_id); |
826 gtk_widget_show(menu->id); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
827 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
|
828 menu->id, idx); |
7 | 829 |
830 if (menu->id != NULL) | |
24353
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
831 { |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
832 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
|
833 G_CALLBACK(menu_item_activate), menu); |
24353
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
834 g_signal_connect(G_OBJECT(menu->id), "select", |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
835 G_CALLBACK(menu_item_select), menu); |
c80daba2b5df
patch 8.2.2717: GTK menu items don't show a tooltip
Bram Moolenaar <Bram@vim.org>
parents:
24337
diff
changeset
|
836 } |
7 | 837 } |
838 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
839 #endif // FEAT_MENU |
7 | 840 |
841 | |
842 void | |
843 gui_mch_set_text_area_pos(int x, int y, int w, int h) | |
844 { | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22200
diff
changeset
|
845 gui_gtk_form_move_resize(GTK_FORM(gui.formwin), gui.drawarea, x, y, w, h); |
7 | 846 } |
847 | |
848 | |
849 #if defined(FEAT_MENU) || defined(PROTO) | |
850 /* | |
1215 | 851 * Enable or disable accelerators for the toplevel menus. |
7 | 852 */ |
853 void | |
854 gui_gtk_set_mnemonics(int enable) | |
855 { | |
856 vimmenu_T *menu; | |
857 char_u *name; | |
858 | |
19934
3ff714d765ba
patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents:
18781
diff
changeset
|
859 FOR_ALL_MENUS(menu) |
7 | 860 { |
861 if (menu->id == NULL) | |
862 continue; | |
863 | |
864 name = translate_mnemonic_tag(menu->name, enable); | |
865 gtk_label_set_text_with_mnemonic(GTK_LABEL(menu->label), | |
866 (const char *)name); | |
867 vim_free(name); | |
868 } | |
869 } | |
870 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
871 # if !GTK_CHECK_VERSION(3,4,0) |
7 | 872 static void |
873 recurse_tearoffs(vimmenu_T *menu, int val) | |
874 { | |
875 for (; menu != NULL; menu = menu->next) | |
876 { | |
877 if (menu->submenu_id != NULL && menu->tearoff_handle != NULL | |
878 && menu->name[0] != ']' && !menu_is_popup(menu->name)) | |
879 { | |
880 if (val) | |
881 gtk_widget_show(menu->tearoff_handle); | |
882 else | |
883 gtk_widget_hide(menu->tearoff_handle); | |
884 } | |
885 recurse_tearoffs(menu->children, val); | |
886 } | |
887 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
888 # endif |
7 | 889 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
890 # 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
|
891 void |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
892 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
|
893 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
894 // Do nothing |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
895 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
896 # else |
7 | 897 void |
898 gui_mch_toggle_tearoffs(int enable) | |
899 { | |
900 recurse_tearoffs(root_menu, enable); | |
901 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
902 # endif |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
903 #endif // FEAT_MENU |
7 | 904 |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2103
diff
changeset
|
905 #if defined(FEAT_TOOLBAR) |
7 | 906 static int |
907 get_menu_position(vimmenu_T *menu) | |
908 { | |
909 vimmenu_T *node; | |
944 | 910 int idx = 0; |
7 | 911 |
912 for (node = menu->parent->children; node != menu; node = node->next) | |
913 { | |
914 g_return_val_if_fail(node != NULL, -1); | |
944 | 915 ++idx; |
7 | 916 } |
917 | |
944 | 918 return idx; |
7 | 919 } |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
920 #endif // FEAT_TOOLBAR |
7 | 921 |
922 | |
923 #if defined(FEAT_TOOLBAR) || defined(PROTO) | |
924 void | |
925 gui_mch_menu_set_tip(vimmenu_T *menu) | |
926 { | |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
927 if (menu->id == NULL || menu->parent == NULL || gui.toolbar == NULL) |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
928 return; |
7 | 929 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
930 char_u *tooltip; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
931 |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
932 tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
933 if (tooltip != NULL && utf_valid_string(tooltip, NULL)) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
934 # if GTK_CHECK_VERSION(3,0,0) |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
935 // Only set the tooltip when it's valid utf-8. |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
936 gtk_widget_set_tooltip_text(menu->id, (const gchar *)tooltip); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
937 # else |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
938 // Only set the tooltip when it's valid utf-8. |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
939 gtk_tooltips_set_tip(GTK_TOOLBAR(gui.toolbar)->tooltips, |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
940 menu->id, (const char *)tooltip, NULL); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
941 # endif |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
942 CONVERT_TO_UTF8_FREE(tooltip); |
7 | 943 } |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
944 #endif // FEAT_TOOLBAR |
7 | 945 |
946 | |
947 #if defined(FEAT_MENU) || defined(PROTO) | |
948 /* | |
949 * Destroy the machine specific menu widget. | |
950 */ | |
951 void | |
952 gui_mch_destroy_menu(vimmenu_T *menu) | |
953 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
954 // 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
|
955 if (menu->id != NULL) |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
956 g_object_ref(menu->id); |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
957 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
958 // 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
|
959 // 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
|
960 // 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
|
961 if (menu->id != NULL && gui.menubar != NULL |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
962 && gtk_widget_get_parent(menu->id) == gui.menubar) |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
963 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
|
964 |
7 | 965 # ifdef FEAT_TOOLBAR |
966 if (menu->parent != NULL && menu_is_toolbar(menu->parent->name)) | |
967 { | |
968 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
|
969 # 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
|
970 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
971 GtkToolItem *item = NULL; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
972 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
973 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
|
974 get_menu_position(menu)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
975 if (item != NULL) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
976 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
|
977 GTK_WIDGET(item)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
978 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
979 # else |
7 | 980 gtk_toolbar_remove_space(GTK_TOOLBAR(gui.toolbar), |
981 get_menu_position(menu)); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
982 # endif |
7 | 983 else if (menu->id != NULL) |
984 gtk_widget_destroy(menu->id); | |
985 } | |
986 else | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
987 # endif // FEAT_TOOLBAR |
7 | 988 { |
989 if (menu->submenu_id != NULL) | |
990 gtk_widget_destroy(menu->submenu_id); | |
991 | |
992 if (menu->id != NULL) | |
993 gtk_widget_destroy(menu->id); | |
994 } | |
995 | |
5092
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
996 if (menu->id != NULL) |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
997 g_object_unref(menu->id); |
7 | 998 menu->submenu_id = NULL; |
999 menu->id = NULL; | |
1000 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1001 #endif // FEAT_MENU |
7 | 1002 |
1003 | |
1004 /* | |
1005 * Scrollbar stuff. | |
1006 */ | |
1007 void | |
1008 gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max) | |
1009 { | |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1010 if (sb->id == NULL) |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1011 return; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1012 |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1013 GtkAdjustment *adjustment; |
7 | 1014 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1015 // ignore events triggered by moving the thumb (happens in GTK 3) |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1016 ++hold_gui_events; |
26010
2fafae9c79e8
patch 8.2.3539: GTK3: with 'rightleft' set scrollbar may move unintentionally
Bram Moolenaar <Bram@vim.org>
parents:
24802
diff
changeset
|
1017 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1018 adjustment = gtk_range_get_adjustment(GTK_RANGE(sb->id)); |
7 | 1019 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1020 gtk_adjustment_set_lower(adjustment, 0.0); |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1021 gtk_adjustment_set_value(adjustment, val); |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1022 gtk_adjustment_set_upper(adjustment, max + 1); |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1023 gtk_adjustment_set_page_size(adjustment, size); |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1024 gtk_adjustment_set_page_increment(adjustment, |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1025 size < 3L ? 1L : size - 2L); |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1026 gtk_adjustment_set_step_increment(adjustment, 1.0); |
7 | 1027 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1028 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
|
1029 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1030 --hold_gui_events; |
26010
2fafae9c79e8
patch 8.2.3539: GTK3: with 'rightleft' set scrollbar may move unintentionally
Bram Moolenaar <Bram@vim.org>
parents:
24802
diff
changeset
|
1031 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1032 #if !GTK_CHECK_VERSION(3,18,0) |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1033 gtk_adjustment_changed(adjustment); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1034 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1035 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1036 g_signal_handler_unblock(G_OBJECT(adjustment), |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1037 (gulong)sb->handler_id); |
7 | 1038 } |
1039 | |
1040 void | |
1041 gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h) | |
1042 { | |
1043 if (sb->id != NULL) | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22200
diff
changeset
|
1044 gui_gtk_form_move_resize(GTK_FORM(gui.formwin), sb->id, x, y, w, h); |
7 | 1045 } |
1046 | |
21355
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
1047 int |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
1048 gui_mch_get_scrollbar_xpadding(void) |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
1049 { |
24337
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1050 int xpad; |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1051 #if GTK_CHECK_VERSION(3,0,0) |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1052 xpad = gtk_widget_get_allocated_width(gui.formwin) |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1053 - gtk_widget_get_allocated_width(gui.drawarea) - gui.scrollbar_width; |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1054 #else |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1055 xpad = gui.formwin->allocation.width - gui.drawarea->allocation.width |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1056 - gui.scrollbar_width; |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1057 #endif |
24802
7342df6f02bb
patch 8.2.2939: GTK: righthand scrollbar does not show with split window
Bram Moolenaar <Bram@vim.org>
parents:
24359
diff
changeset
|
1058 if (gui.which_scrollbars[SBAR_LEFT] && gui.which_scrollbars[SBAR_RIGHT]) |
7342df6f02bb
patch 8.2.2939: GTK: righthand scrollbar does not show with split window
Bram Moolenaar <Bram@vim.org>
parents:
24359
diff
changeset
|
1059 xpad -= gui.scrollbar_width; |
7342df6f02bb
patch 8.2.2939: GTK: righthand scrollbar does not show with split window
Bram Moolenaar <Bram@vim.org>
parents:
24359
diff
changeset
|
1060 |
24337
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1061 return (xpad < 0) ? 0 : xpad; |
21355
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
1062 } |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
1063 |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
1064 int |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
1065 gui_mch_get_scrollbar_ypadding(void) |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
1066 { |
24337
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1067 int ypad; |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1068 #if GTK_CHECK_VERSION(3,0,0) |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1069 ypad = gtk_widget_get_allocated_height(gui.formwin) |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1070 - gtk_widget_get_allocated_height(gui.drawarea) - gui.scrollbar_height; |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1071 #else |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1072 ypad = gui.formwin->allocation.height - gui.drawarea->allocation.height |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1073 - gui.scrollbar_height; |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1074 #endif |
1abd0fc18bcd
patch 8.2.2709: the GTK GUI has a gap next to the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
1075 return (ypad < 0) ? 0 : ypad; |
21355
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
1076 } |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
1077 |
7 | 1078 /* |
1079 * Take action upon scrollbar dragging. | |
1080 */ | |
1081 static void | |
1082 adjustment_value_changed(GtkAdjustment *adjustment, gpointer data) | |
1083 { | |
1084 scrollbar_T *sb; | |
1085 long value; | |
1086 int dragging = FALSE; | |
1087 | |
1088 #ifdef FEAT_XIM | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1089 // cancel any preediting |
7 | 1090 if (im_is_preediting()) |
1091 xim_reset(); | |
1092 #endif | |
1093 | |
1094 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
|
1095 value = gtk_adjustment_get_value(adjustment); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1096 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 1097 /* |
1098 * The dragging argument must be right for the scrollbar to work with | |
1099 * closed folds. This isn't documented, hopefully this will keep on | |
1100 * working in later GTK versions. | |
1101 * | |
1102 * FIXME: Well, it doesn't work in GTK2. :) | |
1103 * HACK: Get the mouse pointer position, if it appears to be on an arrow | |
1104 * button set "dragging" to FALSE. This assumes square buttons! | |
1105 */ | |
1106 if (sb != NULL) | |
1107 { | |
1108 dragging = TRUE; | |
1109 | |
28150
0fa25a1b8451
patch 8.2.4599: GTK: get assertion errors when scrolling a split window
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
1110 if (sb->wp != NULL && GDK_IS_DRAWABLE(sb->id->window)) |
7 | 1111 { |
1112 int x; | |
1113 int y; | |
1114 GdkModifierType state; | |
1115 int width; | |
1116 int height; | |
1117 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1118 // 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
|
1119 // there are closed folds. |
7 | 1120 gdk_window_get_pointer(sb->id->window, &x, &y, &state); |
1121 gdk_window_get_size(sb->id->window, &width, &height); | |
1122 if (x >= 0 && x < width && y >= 0 && y < height) | |
1123 { | |
1124 if (y < width) | |
1125 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1126 // up arrow: move one (closed fold) line up |
7 | 1127 dragging = FALSE; |
1128 value = sb->wp->w_topline - 2; | |
1129 } | |
1130 else if (y > height - width) | |
1131 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1132 // down arrow: move one (closed fold) line down |
7 | 1133 dragging = FALSE; |
1134 value = sb->wp->w_topline; | |
1135 } | |
1136 } | |
1137 } | |
1138 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1139 #endif // !GTK_CHECK_VERSION(3,0,0) |
7 | 1140 gui_drag_scrollbar(sb, value, dragging); |
1141 } | |
1142 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1143 // SBAR_VERT or SBAR_HORIZ |
7 | 1144 void |
1145 gui_mch_create_scrollbar(scrollbar_T *sb, int orient) | |
1146 { | |
1147 if (orient == SBAR_HORIZ) | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1148 #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
|
1149 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
|
1150 #else |
7 | 1151 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
|
1152 #endif |
7 | 1153 else if (orient == SBAR_VERT) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1154 #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
|
1155 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
|
1156 #else |
7 | 1157 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
|
1158 #endif |
7 | 1159 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1160 if (sb->id == NULL) |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1161 return; |
7 | 1162 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1163 GtkAdjustment *adjustment; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1164 |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1165 gtk_widget_set_can_focus(sb->id, FALSE); |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1166 gui_gtk_form_put(GTK_FORM(gui.formwin), sb->id, 0, 0); |
7 | 1167 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1168 adjustment = gtk_range_get_adjustment(GTK_RANGE(sb->id)); |
7 | 1169 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1170 sb->handler_id = g_signal_connect( |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1171 G_OBJECT(adjustment), "value-changed", |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1172 G_CALLBACK(adjustment_value_changed), |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1173 GINT_TO_POINTER(sb->ident)); |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1174 gui_mch_update(); |
7 | 1175 } |
1176 | |
1177 void | |
1178 gui_mch_destroy_scrollbar(scrollbar_T *sb) | |
1179 { | |
1180 if (sb->id != NULL) | |
1181 { | |
1182 gtk_widget_destroy(sb->id); | |
1183 sb->id = NULL; | |
1184 } | |
1185 gui_mch_update(); | |
1186 } | |
1187 | |
1188 #if defined(FEAT_BROWSE) || defined(PROTO) | |
1189 /* | |
1190 * Implementation of the file selector related stuff | |
1191 */ | |
270 | 1192 |
1193 #ifndef USE_FILE_CHOOSER | |
7 | 1194 static void |
1884 | 1195 browse_ok_cb(GtkWidget *widget UNUSED, gpointer cbdata) |
7 | 1196 { |
1197 gui_T *vw = (gui_T *)cbdata; | |
1198 | |
1199 if (vw->browse_fname != NULL) | |
1200 g_free(vw->browse_fname); | |
1201 | |
1202 vw->browse_fname = (char_u *)g_strdup(gtk_file_selection_get_filename( | |
1203 GTK_FILE_SELECTION(vw->filedlg))); | |
1204 gtk_widget_hide(vw->filedlg); | |
1205 } | |
1206 | |
1207 static void | |
1884 | 1208 browse_cancel_cb(GtkWidget *widget UNUSED, gpointer cbdata) |
7 | 1209 { |
1210 gui_T *vw = (gui_T *)cbdata; | |
1211 | |
1212 if (vw->browse_fname != NULL) | |
1213 { | |
1214 g_free(vw->browse_fname); | |
1215 vw->browse_fname = NULL; | |
1216 } | |
1217 gtk_widget_hide(vw->filedlg); | |
1218 } | |
1219 | |
1220 static gboolean | |
1884 | 1221 browse_destroy_cb(GtkWidget *widget UNUSED) |
7 | 1222 { |
1223 if (gui.browse_fname != NULL) | |
1224 { | |
1225 g_free(gui.browse_fname); | |
1226 gui.browse_fname = NULL; | |
1227 } | |
1228 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
|
1229 gtk_main_quit(); |
7 | 1230 return FALSE; |
1231 } | |
270 | 1232 #endif |
7 | 1233 |
1234 /* | |
1235 * Put up a file requester. | |
1236 * Returns the selected name in allocated memory, or NULL for Cancel. | |
1237 * saving, select file to write | |
1238 * title title for the window | |
1239 * dflt default name | |
1240 * ext not used (extension added) | |
1241 * initdir initial directory, NULL for current dir | |
1242 * filter not used (file name filter) | |
1243 */ | |
1244 char_u * | |
1884 | 1245 gui_mch_browse(int saving UNUSED, |
7 | 1246 char_u *title, |
1247 char_u *dflt, | |
1884 | 1248 char_u *ext UNUSED, |
7 | 1249 char_u *initdir, |
3664 | 1250 char_u *filter) |
7 | 1251 { |
270 | 1252 #ifdef USE_FILE_CHOOSER |
22200
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1253 # if GTK_CHECK_VERSION(3,20,0) |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1254 GtkFileChooserNative *fc; |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1255 # else |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1256 GtkWidget *fc; |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1257 # endif |
270 | 1258 #endif |
29 | 1259 char_u dirbuf[MAXPATHL]; |
3484 | 1260 guint log_handler; |
1261 const gchar *domain = "Gtk"; | |
7 | 1262 |
1263 title = CONVERT_TO_UTF8(title); | |
1264 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1265 // GTK has a bug, it only works with an absolute path. |
270 | 1266 if (initdir == NULL || *initdir == NUL) |
1267 mch_dirname(dirbuf, MAXPATHL); | |
1003 | 1268 else if (vim_FullName(initdir, dirbuf, MAXPATHL - 2, FALSE) == FAIL) |
270 | 1269 dirbuf[0] = NUL; |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1270 // Always need a trailing slash for a directory. |
270 | 1271 add_pathsep(dirbuf); |
1272 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1273 // If our pointer is currently hidden, then we should show it. |
270 | 1274 gui_mch_mousehide(FALSE); |
1275 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1276 // 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
|
1277 // makes it shut up. http://bugzilla.gnome.org/show_bug.cgi?id=664587 |
3484 | 1278 log_handler = g_log_set_handler(domain, G_LOG_LEVEL_WARNING, |
1279 recent_func_log_func, NULL); | |
1280 | |
270 | 1281 #ifdef USE_FILE_CHOOSER |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1282 // 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
|
1283 // or "Save" according to the action. |
22200
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1284 # if GTK_CHECK_VERSION(3,20,0) |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1285 fc = gtk_file_chooser_native_new( |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1286 # else |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1287 fc = gtk_file_chooser_dialog_new( |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1288 # endif |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1289 (const gchar *)title, |
270 | 1290 GTK_WINDOW(gui.mainwin), |
1291 saving ? GTK_FILE_CHOOSER_ACTION_SAVE | |
1292 : GTK_FILE_CHOOSER_ACTION_OPEN, | |
22200
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1293 # if GTK_CHECK_VERSION(3,20,0) |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1294 saving ? _("_Save") : _("_Open"), _("_Cancel")); |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1295 # else |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1296 # if GTK_CHECK_VERSION(3,10,0) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1297 _("_Cancel"), GTK_RESPONSE_CANCEL, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1298 saving ? _("_Save") : _("_Open"), GTK_RESPONSE_ACCEPT, |
22200
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1299 # else |
1025 | 1300 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
270 | 1301 saving ? GTK_STOCK_SAVE : GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, |
22200
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1302 # endif |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1303 NULL); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1304 # endif |
270 | 1305 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc), |
1306 (const gchar *)dirbuf); | |
3664 | 1307 |
1308 if (filter != NULL && *filter != NUL) | |
1309 { | |
1310 int i = 0; | |
1311 char_u *patt; | |
1312 char_u *p = filter; | |
3871 | 1313 GtkFileFilter *gfilter; |
3664 | 1314 |
1315 gfilter = gtk_file_filter_new(); | |
1316 patt = alloc(STRLEN(filter)); | |
1317 while (p != NULL && *p != NUL) | |
1318 { | |
1319 if (*p == '\n' || *p == ';' || *p == '\t') | |
1320 { | |
1321 STRNCPY(patt, filter, i); | |
1322 patt[i] = '\0'; | |
1323 if (*p == '\t') | |
1324 gtk_file_filter_set_name(gfilter, (gchar *)patt); | |
1325 else | |
1326 { | |
1327 gtk_file_filter_add_pattern(gfilter, (gchar *)patt); | |
1328 if (*p == '\n') | |
1329 { | |
22200
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1330 gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fc), |
3664 | 1331 gfilter); |
1332 if (*(p + 1) != NUL) | |
1333 gfilter = gtk_file_filter_new(); | |
1334 } | |
1335 } | |
1336 filter = ++p; | |
1337 i = 0; | |
1338 } | |
1339 else | |
1340 { | |
1341 p++; | |
1342 i++; | |
1343 } | |
1344 } | |
1345 vim_free(patt); | |
1346 } | |
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
|
1347 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
|
1348 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), (char *)dflt); |
270 | 1349 |
1350 gui.browse_fname = NULL; | |
22200
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1351 # if GTK_CHECK_VERSION(3,20,0) |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1352 if (gtk_native_dialog_run(GTK_NATIVE_DIALOG(fc)) == GTK_RESPONSE_ACCEPT) |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1353 # else |
270 | 1354 if (gtk_dialog_run(GTK_DIALOG(fc)) == GTK_RESPONSE_ACCEPT) |
22200
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1355 #endif |
7 | 1356 { |
856 | 1357 char *filename; |
1358 | |
1359 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc)); | |
1360 gui.browse_fname = (char_u *)g_strdup(filename); | |
1361 g_free(filename); | |
270 | 1362 } |
22200
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1363 # if GTK_CHECK_VERSION(3,20,0) |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1364 g_object_unref(fc); |
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1365 # else |
270 | 1366 gtk_widget_destroy(GTK_WIDGET(fc)); |
22200
ef7f63b97855
patch 8.2.1649: GTK3: using old file chooser
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
1367 # endif |
270 | 1368 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1369 #else // !USE_FILE_CHOOSER |
270 | 1370 |
1371 if (gui.filedlg == NULL) | |
1372 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1373 GtkFileSelection *fs; // shortcut |
270 | 1374 |
7 | 1375 gui.filedlg = gtk_file_selection_new((const gchar *)title); |
1376 gtk_window_set_modal(GTK_WINDOW(gui.filedlg), TRUE); | |
1377 gtk_window_set_transient_for(GTK_WINDOW(gui.filedlg), | |
270 | 1378 GTK_WINDOW(gui.mainwin)); |
7 | 1379 fs = GTK_FILE_SELECTION(gui.filedlg); |
1380 | |
1381 gtk_container_border_width(GTK_CONTAINER(fs), 4); | |
1382 | |
1383 gtk_signal_connect(GTK_OBJECT(fs->ok_button), | |
1384 "clicked", GTK_SIGNAL_FUNC(browse_ok_cb), &gui); | |
1385 gtk_signal_connect(GTK_OBJECT(fs->cancel_button), | |
1386 "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
|
1387 // gtk_signal_connect() doesn't work for destroy, it causes a hang |
7 | 1388 gtk_signal_connect_object(GTK_OBJECT(gui.filedlg), |
1389 "destroy", GTK_SIGNAL_FUNC(browse_destroy_cb), | |
1390 GTK_OBJECT(gui.filedlg)); | |
1391 } | |
1392 else | |
1393 gtk_window_set_title(GTK_WINDOW(gui.filedlg), (const gchar *)title); | |
1394 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1395 // Concatenate "initdir" and "dflt". |
1003 | 1396 if (dflt != NULL && *dflt != NUL |
1397 && STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL) | |
1398 STRCAT(dirbuf, dflt); | |
1399 | |
7 | 1400 gtk_file_selection_set_filename(GTK_FILE_SELECTION(gui.filedlg), |
1401 (const gchar *)dirbuf); | |
1402 | |
1403 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
|
1404 gtk_main(); |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1405 #endif // !USE_FILE_CHOOSER |
3484 | 1406 g_log_remove_handler(domain, log_handler); |
270 | 1407 |
1408 CONVERT_TO_UTF8_FREE(title); | |
7 | 1409 if (gui.browse_fname == NULL) |
1410 return NULL; | |
1411 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1412 // shorten the file name if possible |
1411 | 1413 return vim_strsave(shorten_fname1(gui.browse_fname)); |
7 | 1414 } |
1415 | |
29 | 1416 /* |
1417 * Put up a directory selector | |
1418 * Returns the selected name in allocated memory, or NULL for Cancel. | |
1419 * title title for the window | |
1420 * dflt default name | |
1421 * initdir initial directory, NULL for current dir | |
1422 */ | |
1423 char_u * | |
1424 gui_mch_browsedir( | |
1425 char_u *title, | |
1426 char_u *initdir) | |
1427 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1428 # if defined(GTK_FILE_CHOOSER) // Only in GTK 2.4 and later. |
29 | 1429 char_u dirbuf[MAXPATHL]; |
1430 char_u *p; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1431 GtkWidget *dirdlg; // file selection dialog |
29 | 1432 char_u *dirname = NULL; |
1433 | |
1434 title = CONVERT_TO_UTF8(title); | |
1435 | |
1436 dirdlg = gtk_file_chooser_dialog_new( | |
1437 (const gchar *)title, | |
1438 GTK_WINDOW(gui.mainwin), | |
1439 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
|
1440 # 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
|
1441 _("_Cancel"), GTK_RESPONSE_CANCEL, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1442 _("_OK"), GTK_RESPONSE_ACCEPT, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1443 # else |
29 | 1444 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
1445 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
|
1446 # endif |
29 | 1447 NULL); |
1448 | |
1449 CONVERT_TO_UTF8_FREE(title); | |
1450 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1451 // if our pointer is currently hidden, then we should show it. |
29 | 1452 gui_mch_mousehide(FALSE); |
1453 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1454 // GTK appears to insist on an absolute path. |
29 | 1455 if (initdir == NULL || *initdir == NUL |
1456 || vim_FullName(initdir, dirbuf, MAXPATHL - 10, FALSE) == FAIL) | |
1457 mch_dirname(dirbuf, MAXPATHL - 10); | |
1458 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1459 // 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
|
1460 // Also add a dummy file name, so that we get to the directory. |
29 | 1461 add_pathsep(dirbuf); |
1462 STRCAT(dirbuf, "@zd(*&1|"); | |
1463 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dirdlg), | |
1464 (const gchar *)dirbuf); | |
1465 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1466 // Run the dialog. |
29 | 1467 if (gtk_dialog_run(GTK_DIALOG(dirdlg)) == GTK_RESPONSE_ACCEPT) |
1468 dirname = (char_u *)gtk_file_chooser_get_filename( | |
1469 GTK_FILE_CHOOSER(dirdlg)); | |
1470 gtk_widget_destroy(dirdlg); | |
1471 if (dirname == NULL) | |
1472 return NULL; | |
1473 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1474 // shorten the file name if possible |
1411 | 1475 p = vim_strsave(shorten_fname1(dirname)); |
29 | 1476 g_free(dirname); |
1477 return p; | |
1478 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1479 # else // !defined(GTK_FILE_CHOOSER) |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1480 // For GTK 2.2 and earlier: fall back to ordinary file selector. |
29 | 1481 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
|
1482 # endif // !defined(GTK_FILE_CHOOSER) |
29 | 1483 } |
1484 | |
270 | 1485 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1486 #endif // FEAT_BROWSE |
7 | 1487 |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2103
diff
changeset
|
1488 #if defined(FEAT_GUI_DIALOG) || defined(PROTO) |
7 | 1489 |
1490 static GtkWidget * | |
1491 create_message_dialog(int type, char_u *title, char_u *message) | |
1492 { | |
1493 GtkWidget *dialog; | |
1494 GtkMessageType message_type; | |
1495 | |
1496 switch (type) | |
1497 { | |
1498 case VIM_ERROR: message_type = GTK_MESSAGE_ERROR; break; | |
1499 case VIM_WARNING: message_type = GTK_MESSAGE_WARNING; break; | |
1500 case VIM_QUESTION: message_type = GTK_MESSAGE_QUESTION; break; | |
1501 default: message_type = GTK_MESSAGE_INFO; break; | |
1502 } | |
1503 | |
1504 message = CONVERT_TO_UTF8(message); | |
1505 dialog = gtk_message_dialog_new(GTK_WINDOW(gui.mainwin), | |
1506 GTK_DIALOG_DESTROY_WITH_PARENT, | |
1507 message_type, | |
1508 GTK_BUTTONS_NONE, | |
1509 "%s", (const char *)message); | |
1510 CONVERT_TO_UTF8_FREE(message); | |
1511 | |
1512 if (title != NULL) | |
1513 { | |
1514 title = CONVERT_TO_UTF8(title); | |
1515 gtk_window_set_title(GTK_WINDOW(dialog), (const char *)title); | |
1516 CONVERT_TO_UTF8_FREE(title); | |
1517 } | |
1518 else if (type == VIM_GENERIC) | |
1519 { | |
1520 gtk_window_set_title(GTK_WINDOW(dialog), "VIM"); | |
1521 } | |
1522 | |
1523 return dialog; | |
1524 } | |
1525 | |
1526 /* | |
1527 * Split up button_string into individual button labels by inserting | |
1528 * NUL bytes. Also replace the Vim-style mnemonic accelerator prefix | |
1529 * '&' with '_'. button_string must point to allocated memory! | |
1530 * Return an allocated array of pointers into button_string. | |
1531 */ | |
1532 static char ** | |
1533 split_button_string(char_u *button_string, int *n_buttons) | |
1534 { | |
1535 char **array; | |
1536 char_u *p; | |
1537 unsigned int count = 1; | |
1538 | |
1539 for (p = button_string; *p != NUL; ++p) | |
1540 if (*p == DLG_BUTTON_SEP) | |
1541 ++count; | |
1542 | |
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
|
1543 array = ALLOC_MULT(char *, count + 1); |
7 | 1544 count = 0; |
1545 | |
1546 if (array != NULL) | |
1547 { | |
1548 array[count++] = (char *)button_string; | |
40 | 1549 for (p = button_string; *p != NUL; ) |
7 | 1550 { |
1551 if (*p == DLG_BUTTON_SEP) | |
1552 { | |
40 | 1553 *p++ = NUL; |
1554 array[count++] = (char *)p; | |
7 | 1555 } |
1556 else if (*p == DLG_HOTKEY_CHAR) | |
40 | 1557 *p++ = '_'; |
1558 else | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10544
diff
changeset
|
1559 MB_PTR_ADV(p); |
7 | 1560 } |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1561 array[count] = NULL; // currently not relied upon, but doesn't hurt |
7 | 1562 } |
1563 | |
1564 *n_buttons = count; | |
1565 return array; | |
1566 } | |
1567 | |
1568 static char ** | |
1569 split_button_translation(const char *message) | |
1570 { | |
1571 char **buttons = NULL; | |
1572 char_u *str; | |
1573 int n_buttons = 0; | |
1574 int n_expected = 1; | |
1575 | |
1576 for (str = (char_u *)message; *str != NUL; ++str) | |
1577 if (*str == DLG_BUTTON_SEP) | |
1578 ++n_expected; | |
1579 | |
1580 str = (char_u *)_(message); | |
1581 if (str != NULL) | |
1582 { | |
1583 if (output_conv.vc_type != CONV_NONE) | |
1584 str = string_convert(&output_conv, str, NULL); | |
1585 else | |
1586 str = vim_strsave(str); | |
1587 | |
1588 if (str != NULL) | |
1589 buttons = split_button_string(str, &n_buttons); | |
1590 } | |
1591 /* | |
1592 * Uh-oh... this should never ever happen. But we don't wanna crash | |
1593 * if the translation is broken, thus fall back to the untranslated | |
1594 * buttons string in case of emergency. | |
1595 */ | |
1596 if (buttons == NULL || n_buttons != n_expected) | |
1597 { | |
1598 vim_free(buttons); | |
1599 vim_free(str); | |
1600 buttons = NULL; | |
1601 str = vim_strsave((char_u *)message); | |
1602 | |
1603 if (str != NULL) | |
1604 buttons = split_button_string(str, &n_buttons); | |
1605 if (buttons == NULL) | |
1606 vim_free(str); | |
1607 } | |
1608 | |
1609 return buttons; | |
1610 } | |
1611 | |
1612 static int | |
1613 button_equal(const char *a, const char *b) | |
1614 { | |
1615 while (*a != '\0' && *b != '\0') | |
1616 { | |
1617 if (*a == '_' && *++a == '\0') | |
1618 break; | |
1619 if (*b == '_' && *++b == '\0') | |
1620 break; | |
1621 | |
1622 if (g_unichar_tolower(g_utf8_get_char(a)) | |
1623 != g_unichar_tolower(g_utf8_get_char(b))) | |
1624 return FALSE; | |
1625 | |
1626 a = g_utf8_next_char(a); | |
1627 b = g_utf8_next_char(b); | |
1628 } | |
1629 | |
1630 return (*a == '\0' && *b == '\0'); | |
1631 } | |
1632 | |
1633 static void | |
1634 dialog_add_buttons(GtkDialog *dialog, char_u *button_string) | |
1635 { | |
1636 char **ok; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1637 char **ync; // "yes no cancel" |
7 | 1638 char **buttons; |
1639 int n_buttons = 0; | |
944 | 1640 int idx; |
7 | 1641 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1642 button_string = vim_strsave(button_string); // must be writable |
7 | 1643 if (button_string == NULL) |
1644 return; | |
1645 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1646 // Check 'v' flag in 'guioptions': vertical button placement. |
7 | 1647 if (vim_strchr(p_go, GO_VERTICAL) != NULL) |
1648 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1649 # 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
|
1650 // 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
|
1651 // 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
|
1652 // the C API. |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1653 # else |
7 | 1654 GtkWidget *vbutton_box; |
1655 | |
1656 vbutton_box = gtk_vbutton_box_new(); | |
1657 gtk_widget_show(vbutton_box); | |
1658 gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->vbox), | |
1659 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
|
1660 // Overrule the "action_area" value, hopefully this works... |
7 | 1661 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
|
1662 # endif |
7 | 1663 } |
1664 | |
1665 /* | |
1666 * Yes this is ugly, I don't particularly like it either. But doing it | |
1667 * this way has the compelling advantage that translations need not to | |
1668 * be touched at all. See below what 'ok' and 'ync' are used for. | |
1669 */ | |
1670 ok = split_button_translation(N_("&Ok")); | |
1671 ync = split_button_translation(N_("&Yes\n&No\n&Cancel")); | |
1672 buttons = split_button_string(button_string, &n_buttons); | |
1673 | |
1674 /* | |
1675 * Yes, the buttons are in reversed order to match the GNOME 2 desktop | |
1676 * environment. Don't hit me -- it's all about consistency. | |
1677 * Well, apparently somebody changed his mind: with GTK 2.2.4 it works the | |
1678 * other way around... | |
1679 */ | |
944 | 1680 for (idx = 1; idx <= n_buttons; ++idx) |
7 | 1681 { |
1682 char *label; | |
1683 char_u *label8; | |
1684 | |
944 | 1685 label = buttons[idx - 1]; |
7 | 1686 /* |
1687 * Perform some guesswork to find appropriate stock items for the | |
1688 * buttons. We have to compare with a sample of the translated | |
1689 * button string to get things right. Yes, this is hackish :/ | |
1690 * | |
1691 * But even the common button labels aren't necessarily translated, | |
1692 * since anyone can create their own dialogs using Vim functions. | |
1693 * Thus we have to check for those too. | |
1694 */ | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1695 if (ok != NULL && ync != NULL) // almost impossible to fail |
7 | 1696 { |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1697 # 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
|
1698 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
|
1699 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
|
1700 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
|
1701 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
|
1702 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
|
1703 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
|
1704 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
|
1705 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
|
1706 # else |
7 | 1707 if (button_equal(label, ok[0])) label = GTK_STOCK_OK; |
1708 else if (button_equal(label, ync[0])) label = GTK_STOCK_YES; | |
1709 else if (button_equal(label, ync[1])) label = GTK_STOCK_NO; | |
1710 else if (button_equal(label, ync[2])) label = GTK_STOCK_CANCEL; | |
1711 else if (button_equal(label, "Ok")) label = GTK_STOCK_OK; | |
1712 else if (button_equal(label, "Yes")) label = GTK_STOCK_YES; | |
1713 else if (button_equal(label, "No")) label = GTK_STOCK_NO; | |
1714 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
|
1715 # endif |
7 | 1716 } |
1717 label8 = CONVERT_TO_UTF8((char_u *)label); | |
944 | 1718 gtk_dialog_add_button(dialog, (const gchar *)label8, idx); |
7 | 1719 CONVERT_TO_UTF8_FREE(label8); |
1720 } | |
1721 | |
1722 if (ok != NULL) | |
1723 vim_free(*ok); | |
1724 if (ync != NULL) | |
1725 vim_free(*ync); | |
1726 vim_free(ok); | |
1727 vim_free(ync); | |
1728 vim_free(buttons); | |
1729 vim_free(button_string); | |
1730 } | |
1731 | |
1732 /* | |
1733 * Allow mnemonic accelerators to be activated without pressing <Alt>. | |
1734 * I'm not sure if it's a wise idea to do this. However, the old GTK+ 1.2 | |
1735 * GUI used to work this way, and I consider the impact on UI consistency | |
1736 * low enough to justify implementing this as a special Vim feature. | |
1737 */ | |
1738 typedef struct _DialogInfo | |
1739 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1740 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
|
1741 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
|
1742 GtkDialog *dialog; // Widget of the dialog |
7 | 1743 } DialogInfo; |
1744 | |
1745 static gboolean | |
1746 dialog_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) | |
1747 { | |
1748 DialogInfo *di = (DialogInfo *)data; | |
1749 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1750 // Ignore hitting Enter (or Space) when there is no default button. |
1355 | 1751 if (di->ignore_enter && (event->keyval == GDK_Return |
1752 || event->keyval == ' ')) | |
1753 return TRUE; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1754 else // A different key was pressed, return to normal behavior |
1355 | 1755 di->ignore_enter = FALSE; |
1756 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1757 // Close the dialog when hitting "Esc". |
7 | 1758 if (event->keyval == GDK_Escape) |
1759 { | |
1760 gtk_dialog_response(di->dialog, GTK_RESPONSE_REJECT); | |
1761 return TRUE; | |
1762 } | |
1763 | |
1764 if (di->noalt | |
1765 && (event->state & gtk_accelerator_get_default_mod_mask()) == 0) | |
1766 { | |
1767 return gtk_window_mnemonic_activate( | |
1768 GTK_WINDOW(widget), event->keyval, | |
1769 gtk_window_get_mnemonic_modifier(GTK_WINDOW(widget))); | |
1770 } | |
1771 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1772 return FALSE; // continue emission |
7 | 1773 } |
1774 | |
1775 int | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1776 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
|
1777 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
|
1778 char_u *message, // message text |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1779 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
|
1780 int def_but, // default button |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1781 char_u *textfield, // text for textfield or NULL |
2684 | 1782 int ex_cmd UNUSED) |
7 | 1783 { |
1784 GtkWidget *dialog; | |
1785 GtkWidget *entry = NULL; | |
1786 char_u *text; | |
1787 int response; | |
1788 DialogInfo dialoginfo; | |
1789 | |
1790 dialog = create_message_dialog(type, title, message); | |
1791 dialoginfo.dialog = GTK_DIALOG(dialog); | |
1792 dialog_add_buttons(GTK_DIALOG(dialog), buttons); | |
1793 | |
1794 if (textfield != NULL) | |
1795 { | |
1796 GtkWidget *alignment; | |
1797 | |
1798 entry = gtk_entry_new(); | |
1799 gtk_widget_show(entry); | |
1800 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1801 // Make Enter work like pressing OK. |
3664 | 1802 gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); |
2649 | 1803 |
7 | 1804 text = CONVERT_TO_UTF8(textfield); |
1805 gtk_entry_set_text(GTK_ENTRY(entry), (const char *)text); | |
1806 CONVERT_TO_UTF8_FREE(text); | |
1807 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1808 # 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
|
1809 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
|
1810 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
|
1811 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
|
1812 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
|
1813 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1814 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
|
1815 # else |
7 | 1816 alignment = gtk_alignment_new((float)0.5, (float)0.5, |
1817 (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
|
1818 # endif |
7 | 1819 gtk_container_add(GTK_CONTAINER(alignment), entry); |
1820 gtk_container_set_border_width(GTK_CONTAINER(alignment), 5); | |
1821 gtk_widget_show(alignment); | |
1822 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1823 # 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
|
1824 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1825 GtkWidget * const vbox |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1826 = 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
|
1827 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
|
1828 alignment, TRUE, FALSE, 0); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1829 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1830 # else |
7 | 1831 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
1832 alignment, TRUE, FALSE, 0); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1833 # endif |
7 | 1834 dialoginfo.noalt = FALSE; |
1835 } | |
1836 else | |
1837 dialoginfo.noalt = TRUE; | |
1838 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1839 // 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
|
1840 // 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
|
1841 g_signal_connect(G_OBJECT(dialog), "key-press-event", |
7 | 1842 G_CALLBACK(&dialog_key_press_event_cb), &dialoginfo); |
1843 | |
1844 if (def_but > 0) | |
1845 { | |
1846 gtk_dialog_set_default_response(GTK_DIALOG(dialog), def_but); | |
1847 dialoginfo.ignore_enter = FALSE; | |
1848 } | |
1849 else | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1850 // No default button, ignore pressing Enter. |
7 | 1851 dialoginfo.ignore_enter = TRUE; |
1852 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1853 // Show the mouse pointer if it's currently hidden. |
7 | 1854 gui_mch_mousehide(FALSE); |
1855 | |
1856 response = gtk_dialog_run(GTK_DIALOG(dialog)); | |
1857 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1858 // GTK_RESPONSE_NONE means the dialog was programmatically destroyed. |
7 | 1859 if (response != GTK_RESPONSE_NONE) |
1860 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1861 if (response == GTK_RESPONSE_ACCEPT) // Enter pressed |
314 | 1862 response = def_but; |
7 | 1863 if (textfield != NULL) |
1864 { | |
1865 text = (char_u *)gtk_entry_get_text(GTK_ENTRY(entry)); | |
1866 text = CONVERT_FROM_UTF8(text); | |
1867 | |
419 | 1868 vim_strncpy(textfield, text, IOSIZE - 1); |
7 | 1869 |
1870 CONVERT_FROM_UTF8_FREE(text); | |
1871 } | |
1872 gtk_widget_destroy(dialog); | |
1873 } | |
1874 | |
1875 return response > 0 ? response : 0; | |
1876 } | |
1877 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1878 #endif // FEAT_GUI_DIALOG |
7 | 1879 |
1880 | |
1881 #if defined(FEAT_MENU) || defined(PROTO) | |
1882 | |
1883 void | |
1884 gui_mch_show_popupmenu(vimmenu_T *menu) | |
1885 { | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2103
diff
changeset
|
1886 # if defined(FEAT_XIM) |
7 | 1887 /* |
1888 * Append a submenu for selecting an input method. This is | |
1889 * currently the only way to switch input methods at runtime. | |
1890 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1891 # if !GTK_CHECK_VERSION(3,10,0) |
7 | 1892 if (xic != NULL && g_object_get_data(G_OBJECT(menu->submenu_id), |
1893 "vim-has-im-menu") == NULL) | |
1894 { | |
1895 GtkWidget *menuitem; | |
1896 GtkWidget *submenu; | |
1897 char_u *name; | |
1898 | |
1899 menuitem = gtk_separator_menu_item_new(); | |
1900 gtk_widget_show(menuitem); | |
1901 gtk_menu_shell_append(GTK_MENU_SHELL(menu->submenu_id), menuitem); | |
1902 | |
1903 name = (char_u *)_("Input _Methods"); | |
1904 name = CONVERT_TO_UTF8(name); | |
1905 menuitem = gtk_menu_item_new_with_mnemonic((const char *)name); | |
1906 CONVERT_TO_UTF8_FREE(name); | |
1907 gtk_widget_show(menuitem); | |
1908 | |
1909 submenu = gtk_menu_new(); | |
1910 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
1911 gtk_menu_shell_append(GTK_MENU_SHELL(menu->submenu_id), menuitem); | |
1912 | |
1913 gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(xic), | |
1914 GTK_MENU_SHELL(submenu)); | |
1915 g_object_set_data(G_OBJECT(menu->submenu_id), | |
1916 "vim-has-im-menu", GINT_TO_POINTER(TRUE)); | |
1917 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1918 # endif |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1919 # endif // FEAT_XIM |
7 | 1920 |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1921 # 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
|
1922 { |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1923 GdkEventButton trigger; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1924 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1925 // 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
|
1926 // 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
|
1927 // 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
|
1928 // 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
|
1929 trigger.type = GDK_BUTTON_PRESS; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1930 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
|
1931 trigger.send_event = FALSE; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1932 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
|
1933 trigger.x = 0.0; |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
13184
diff
changeset
|
1934 trigger.y = 0.0; |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1935 trigger.axes = NULL; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1936 trigger.state = 0; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1937 trigger.button = 3; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1938 trigger.device = NULL; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1939 trigger.x_root = 0.0; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1940 trigger.y_root = 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 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
|
1943 (GdkEvent *)&trigger); |
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 #else |
7 | 1946 gtk_menu_popup(GTK_MENU(menu->submenu_id), |
1947 NULL, NULL, | |
1948 (GtkMenuPositionFunc)NULL, NULL, | |
2923 | 1949 3U, gui.event_time); |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1950 #endif |
7 | 1951 } |
1952 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1953 // 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
|
1954 // popup_menu_position_func(). |
401 | 1955 static int popup_mouse_pos; |
1956 | |
7 | 1957 /* |
1958 * Menu position callback; used by gui_make_popup() to place the menu | |
1959 * at the current text cursor position. | |
1960 * | |
1961 * Note: The push_in output argument seems to affect scrolling of huge | |
1962 * menus that don't fit on the screen. Leave it at the default for now. | |
1963 */ | |
1964 static void | |
1884 | 1965 popup_menu_position_func(GtkMenu *menu UNUSED, |
7 | 1966 gint *x, gint *y, |
1884 | 1967 gboolean *push_in UNUSED, |
1968 gpointer user_data UNUSED) | |
7 | 1969 { |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1970 gdk_window_get_origin(gtk_widget_get_window(gui.drawarea), x, y); |
401 | 1971 |
1972 if (popup_mouse_pos) | |
7 | 1973 { |
401 | 1974 int mx, my; |
1975 | |
1976 gui_mch_getmouse(&mx, &my); | |
1977 *x += mx; | |
1978 *y += my; | |
1979 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1980 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
|
1981 gtk_widget_get_window(gui.drawarea) != NULL) |
401 | 1982 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1983 // 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
|
1984 *x += FILL_X(curwin->w_wincol + curwin->w_wcol + 1) + 1; |
7 | 1985 *y += FILL_Y(W_WINROW(curwin) + curwin->w_wrow + 1) + 1; |
1986 } | |
1987 } | |
1988 | |
1989 void | |
401 | 1990 gui_make_popup(char_u *path_name, int mouse_pos) |
7 | 1991 { |
1992 vimmenu_T *menu; | |
1993 | |
401 | 1994 popup_mouse_pos = mouse_pos; |
1995 | |
7 | 1996 menu = gui_find_menu(path_name); |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1997 if (menu == NULL || menu->submenu_id == NULL) |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
1998 return; |
7 | 1999 |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2000 # if GTK_CHECK_VERSION(3,22,2) |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2001 GdkWindow * const win = gtk_widget_get_window(gui.drawarea); |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2002 GdkEventButton trigger; |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2003 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2004 // A pseudo event to have gtk_menu_popup_at_*() functions work. Since |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2005 // the position where the menu pops up is automatically adjusted by |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2006 // the functions, none of the fields x, y, x_root and y_root has to be |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2007 // set to a specific value here; therefore, they are set to zero for |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2008 // convenience. |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2009 trigger.type = GDK_BUTTON_PRESS; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2010 trigger.window = win; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2011 trigger.send_event = FALSE; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2012 trigger.time = GDK_CURRENT_TIME; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2013 trigger.x = 0.0; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2014 trigger.y = 0.0; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2015 trigger.axes = NULL; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2016 trigger.state = 0; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2017 trigger.button = 0; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2018 trigger.device = NULL; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2019 trigger.x_root = 0.0; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2020 trigger.y_root = 0.0; |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2021 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2022 if (mouse_pos) |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2023 gtk_menu_popup_at_pointer(GTK_MENU(menu->submenu_id), |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2024 (GdkEvent *)&trigger); |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2025 else |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2026 { |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2027 gint origin_x, origin_y; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2028 GdkRectangle rect = { 0, 0, 0, 0 }; |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2029 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2030 gdk_window_get_origin(win, &origin_x, &origin_y); |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2031 popup_menu_position_func(NULL, &rect.x, &rect.y, NULL, NULL); |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2032 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2033 rect.x -= origin_x; |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2034 rect.y -= origin_y; |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2035 |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2036 gtk_menu_popup_at_rect(GTK_MENU(menu->submenu_id), |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2037 win, |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2038 &rect, |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2039 GDK_GRAVITY_SOUTH_EAST, |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2040 GDK_GRAVITY_NORTH_WEST, |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2041 (GdkEvent *)&trigger); |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2042 } |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2043 # else |
31651
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2044 gtk_menu_popup(GTK_MENU(menu->submenu_id), |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2045 NULL, NULL, |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2046 &popup_menu_position_func, NULL, |
e5ee2ffd826a
patch 9.0.1158: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2047 0U, (guint32)GDK_CURRENT_TIME); |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2048 # endif |
7 | 2049 } |
2050 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2051 #endif // FEAT_MENU |
7 | 2052 |
2053 | |
2054 /* | |
2055 * We don't create it twice. | |
2056 */ | |
2057 | |
2058 typedef struct _SharedFindReplace | |
2059 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2060 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
|
2061 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
|
2062 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
|
2063 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
|
2064 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
|
2065 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
|
2066 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
|
2067 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
|
2068 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
|
2069 GtkWidget *all; // 'Replace All' action button |
7 | 2070 } SharedFindReplace; |
2071 | |
1884 | 2072 static SharedFindReplace find_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; |
2073 static SharedFindReplace repl_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; | |
2074 | |
7 | 2075 static int |
2076 find_key_press_event( | |
1884 | 2077 GtkWidget *widget UNUSED, |
7 | 2078 GdkEventKey *event, |
2079 SharedFindReplace *frdp) | |
2080 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2081 // 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
|
2082 // thus preserving the possibility of normal focus traversal. |
7 | 2083 if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) |
2084 return FALSE; | |
2085 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2086 // the Escape key synthesizes a cancellation action |
7 | 2087 if (event->keyval == GDK_Escape) |
2088 { | |
2089 gtk_widget_hide(frdp->dialog); | |
2090 | |
2091 return TRUE; | |
2092 } | |
2093 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2094 // 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
|
2095 // operations on the K_UP and K_DOWN keys here. |
7 | 2096 |
2097 return FALSE; | |
2098 } | |
2099 | |
2100 static GtkWidget * | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2101 #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
|
2102 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
|
2103 const char *label) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2104 #else |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2105 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
|
2106 const char *label) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2107 #endif |
7 | 2108 { |
2109 char_u *text; | |
2110 GtkWidget *box; | |
2111 GtkWidget *alignment; | |
2112 GtkWidget *button; | |
2113 | |
2114 text = CONVERT_TO_UTF8((char_u *)label); | |
2115 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2116 #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
|
2117 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
|
2118 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
|
2119 #else |
7 | 2120 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
|
2121 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2122 #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
|
2123 if (stock_id != NULL) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2124 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
|
2125 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
|
2126 FALSE, FALSE, 0); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2127 #endif |
7 | 2128 gtk_box_pack_start(GTK_BOX(box), |
2129 gtk_label_new((const char *)text), | |
2130 FALSE, FALSE, 0); | |
2131 | |
2132 CONVERT_TO_UTF8_FREE(text); | |
2133 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2134 #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
|
2135 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
|
2136 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
|
2137 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
|
2138 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
|
2139 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2140 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
|
2141 #else |
7 | 2142 alignment = gtk_alignment_new((float)0.5, (float)0.5, |
2143 (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
|
2144 #endif |
7 | 2145 gtk_container_add(GTK_CONTAINER(alignment), box); |
2146 gtk_widget_show_all(alignment); | |
2147 | |
2148 button = gtk_button_new(); | |
2149 gtk_container_add(GTK_CONTAINER(button), alignment); | |
2150 | |
2151 return button; | |
2152 } | |
2153 | |
2154 /* | |
2155 * This is currently only used by find_replace_dialog_create(), and | |
2156 * I'd really like to keep it at that. In other words: don't spread | |
2157 * this nasty hack all over the code. Think twice. | |
2158 */ | |
2159 static const char * | |
2160 convert_localized_message(char_u **buffer, const char *message) | |
2161 { | |
2162 if (output_conv.vc_type == CONV_NONE) | |
2163 return message; | |
2164 | |
2165 vim_free(*buffer); | |
2166 *buffer = string_convert(&output_conv, (char_u *)message, NULL); | |
2167 | |
2168 return (const char *)*buffer; | |
2169 } | |
2170 | |
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
|
2171 /* |
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
|
2172 * 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
|
2173 */ |
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
|
2174 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
|
2175 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
|
2176 { |
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
|
2177 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
|
2178 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
|
2179 |
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
|
2180 #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
|
2181 // 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
|
2182 // 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
|
2183 // 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
|
2184 // 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
|
2185 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
|
2186 #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
|
2187 // 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
|
2188 // 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
|
2189 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
|
2190 #else |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2191 // 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
|
2192 // 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
|
2193 // 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
|
2194 // 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
|
2195 // 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
|
2196 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
|
2197 #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
|
2198 } |
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
|
2199 |
7 | 2200 static void |
2201 find_replace_dialog_create(char_u *arg, int do_replace) | |
2202 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2203 GtkWidget *hbox; // main top down box |
7 | 2204 GtkWidget *actionarea; |
2205 GtkWidget *table; | |
2206 GtkWidget *tmp; | |
2207 GtkWidget *vbox; | |
2208 gboolean sensitive; | |
2209 SharedFindReplace *frdp; | |
2210 char_u *entry_text; | |
2211 int wword = FALSE; | |
2212 int mcase = !p_ic; | |
2213 char_u *conv_buffer = NULL; | |
2214 # define CONV(message) convert_localized_message(&conv_buffer, (message)) | |
2215 | |
2216 frdp = (do_replace) ? (&repl_widgets) : (&find_widgets); | |
2217 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2218 // Get the search string to use. |
7 | 2219 entry_text = get_find_dialog_text(arg, &wword, &mcase); |
2220 | |
2221 if (entry_text != NULL && output_conv.vc_type != CONV_NONE) | |
2222 { | |
2223 char_u *old_text = entry_text; | |
2224 entry_text = string_convert(&output_conv, entry_text, NULL); | |
2225 vim_free(old_text); | |
2226 } | |
2227 | |
2228 /* | |
2229 * If the dialog already exists, just raise it. | |
2230 */ | |
2231 if (frdp->dialog) | |
2232 { | |
2233 if (entry_text != NULL) | |
2234 { | |
2235 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
|
2236 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
|
2237 (gboolean)wword); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2238 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
|
2239 (gboolean)mcase); |
7 | 2240 } |
2241 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
|
2242 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2243 // For :promptfind dialog, always give keyboard focus to 'what' entry. |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26010
diff
changeset
|
2244 // For :promptrepl dialog, give it to 'with' entry if 'what' has a |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2245 // 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
|
2246 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
|
2247 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
|
2248 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
|
2249 |
7 | 2250 vim_free(entry_text); |
2251 return; | |
2252 } | |
2253 | |
2254 frdp->dialog = gtk_dialog_new(); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2255 #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
|
2256 // 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
|
2257 #else |
7 | 2258 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
|
2259 #endif |
7 | 2260 gtk_window_set_transient_for(GTK_WINDOW(frdp->dialog), GTK_WINDOW(gui.mainwin)); |
2261 gtk_window_set_destroy_with_parent(GTK_WINDOW(frdp->dialog), TRUE); | |
2262 | |
2263 if (do_replace) | |
2264 { | |
2265 gtk_window_set_title(GTK_WINDOW(frdp->dialog), | |
2266 CONV(_("VIM - Search and Replace..."))); | |
2267 } | |
2268 else | |
2269 { | |
2270 gtk_window_set_title(GTK_WINDOW(frdp->dialog), | |
2271 CONV(_("VIM - Search..."))); | |
2272 } | |
2273 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2274 #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
|
2275 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
|
2276 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
|
2277 #else |
7 | 2278 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
|
2279 #endif |
7 | 2280 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
|
2281 #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
|
2282 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2283 GtkWidget * const dialog_vbox |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2284 = 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
|
2285 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
|
2286 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2287 #else |
7 | 2288 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
|
2289 #endif |
7 | 2290 |
2291 if (do_replace) | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2292 #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
|
2293 table = gtk_grid_new(); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2294 #else |
7 | 2295 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
|
2296 #endif |
7 | 2297 else |
8218
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 table = gtk_grid_new(); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2300 #else |
7 | 2301 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
|
2302 #endif |
7 | 2303 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
|
2304 gtk_container_set_border_width(GTK_CONTAINER(table), 4); |
7 | 2305 |
2306 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
|
2307 #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
|
2308 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
|
2309 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
|
2310 #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
|
2311 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2312 GValue align_val = G_VALUE_INIT; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2313 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2314 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
|
2315 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2316 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
|
2317 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
|
2318 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2319 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
|
2320 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
|
2321 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2322 g_value_unset(&align_val); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2323 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2324 #else |
7 | 2325 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
|
2326 #endif |
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), tmp, 0, 0, 2, 1); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2329 #else |
7 | 2330 gtk_table_attach(GTK_TABLE(table), tmp, 0, 1, 0, 1, |
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 | 2333 frdp->what = gtk_entry_new(); |
2334 sensitive = (entry_text != NULL && entry_text[0] != NUL); | |
2335 if (entry_text != NULL) | |
2336 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
|
2337 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
|
2338 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
|
2339 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
|
2340 G_CALLBACK(find_key_press_event), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2341 (gpointer) frdp); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2342 #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
|
2343 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
|
2344 #else |
7 | 2345 gtk_table_attach(GTK_TABLE(table), frdp->what, 1, 1024, 0, 1, |
2346 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
|
2347 #endif |
7 | 2348 |
2349 if (do_replace) | |
2350 { | |
2351 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
|
2352 #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
|
2353 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
|
2354 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
|
2355 #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
|
2356 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2357 GValue align_val = G_VALUE_INIT; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2358 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2359 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
|
2360 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2361 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
|
2362 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
|
2363 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2364 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
|
2365 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
|
2366 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2367 g_value_unset(&align_val); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2368 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2369 #else |
7 | 2370 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
|
2371 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2372 #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
|
2373 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
|
2374 #else |
7 | 2375 gtk_table_attach(GTK_TABLE(table), tmp, 0, 1, 1, 2, |
2376 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
|
2377 #endif |
7 | 2378 frdp->with = gtk_entry_new(); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2379 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
|
2380 G_CALLBACK(find_replace_cb), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2381 GINT_TO_POINTER(FRD_R_FINDNEXT)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2382 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
|
2383 G_CALLBACK(find_key_press_event), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2384 (gpointer) frdp); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2385 #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
|
2386 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
|
2387 #else |
7 | 2388 gtk_table_attach(GTK_TABLE(table), frdp->with, 1, 1024, 1, 2, |
2389 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
|
2390 #endif |
7 | 2391 |
2392 /* | |
2393 * Make the entry activation only change the input focus onto the | |
2394 * with item. | |
2395 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2396 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
|
2397 G_CALLBACK(entry_activate_cb), frdp->with); |
7 | 2398 } |
2399 else | |
2400 { | |
2401 /* | |
2402 * Make the entry activation do the search. | |
2403 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2404 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
|
2405 G_CALLBACK(find_replace_cb), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2406 GINT_TO_POINTER(FRD_FINDNEXT)); |
7 | 2407 } |
2408 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2409 // whole word only button |
7 | 2410 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
|
2411 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
|
2412 (gboolean)wword); |
7 | 2413 if (do_replace) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2414 #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
|
2415 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
|
2416 #else |
7 | 2417 gtk_table_attach(GTK_TABLE(table), frdp->wword, 0, 1023, 2, 3, |
2418 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
|
2419 #endif |
7 | 2420 else |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2421 #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
|
2422 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
|
2423 #else |
7 | 2424 gtk_table_attach(GTK_TABLE(table), frdp->wword, 0, 1023, 1, 2, |
2425 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
|
2426 #endif |
7 | 2427 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2428 // match case button |
7 | 2429 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
|
2430 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
|
2431 (gboolean)mcase); |
7 | 2432 if (do_replace) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2433 #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
|
2434 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
|
2435 #else |
7 | 2436 gtk_table_attach(GTK_TABLE(table), frdp->mcase, 0, 1023, 3, 4, |
2437 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
|
2438 #endif |
7 | 2439 else |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2440 #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
|
2441 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
|
2442 #else |
7 | 2443 gtk_table_attach(GTK_TABLE(table), frdp->mcase, 0, 1023, 2, 3, |
2444 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
|
2445 #endif |
7 | 2446 |
2447 tmp = gtk_frame_new(CONV(_("Direction"))); | |
2448 if (do_replace) | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2449 #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
|
2450 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
|
2451 #else |
7 | 2452 gtk_table_attach(GTK_TABLE(table), tmp, 1023, 1024, 2, 4, |
2453 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
|
2454 #endif |
7 | 2455 else |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2456 #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
|
2457 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
|
2458 #else |
7 | 2459 gtk_table_attach(GTK_TABLE(table), tmp, 1023, 1024, 1, 3, |
2460 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
|
2461 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2462 #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
|
2463 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
|
2464 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
|
2465 #else |
7 | 2466 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
|
2467 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2468 gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); |
7 | 2469 gtk_container_add(GTK_CONTAINER(tmp), vbox); |
2470 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2471 // 'Up' and 'Down' buttons |
7 | 2472 frdp->up = gtk_radio_button_new_with_label(NULL, CONV(_("Up"))); |
2473 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
|
2474 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
|
2475 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
|
2476 CONV(_("Down"))); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2477 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->down), TRUE); |
7 | 2478 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2); |
2479 gtk_box_pack_start(GTK_BOX(vbox), frdp->down, TRUE, TRUE, 0); | |
2480 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2481 // 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
|
2482 #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
|
2483 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
|
2484 #else |
7 | 2485 actionarea = gtk_vbutton_box_new(); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2486 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2487 gtk_container_set_border_width(GTK_CONTAINER(actionarea), 2); |
7 | 2488 gtk_box_pack_end(GTK_BOX(hbox), actionarea, FALSE, FALSE, 0); |
2489 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2490 // 'Find Next' button |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2491 #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
|
2492 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
|
2493 #else |
7 | 2494 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
|
2495 #endif |
7 | 2496 gtk_widget_set_sensitive(frdp->find, sensitive); |
2497 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2498 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
|
2499 G_CALLBACK(find_replace_cb), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2500 (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
|
2501 : GINT_TO_POINTER(FRD_FINDNEXT)); |
7 | 2502 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2503 gtk_widget_set_can_default(frdp->find, TRUE); |
7 | 2504 gtk_box_pack_start(GTK_BOX(actionarea), frdp->find, FALSE, FALSE, 0); |
2505 gtk_widget_grab_default(frdp->find); | |
2506 | |
2507 if (do_replace) | |
2508 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2509 // 'Replace' button |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2510 #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
|
2511 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
|
2512 #else |
7 | 2513 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
|
2514 #endif |
7 | 2515 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
|
2516 gtk_widget_set_can_default(frdp->find, TRUE); |
7 | 2517 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
|
2518 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
|
2519 G_CALLBACK(find_replace_cb), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2520 GINT_TO_POINTER(FRD_REPLACE)); |
7 | 2521 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2522 // 'Replace All' button |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2523 #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
|
2524 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
|
2525 #else |
7 | 2526 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
|
2527 #endif |
7 | 2528 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
|
2529 gtk_widget_set_can_default(frdp->all, TRUE); |
7 | 2530 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
|
2531 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
|
2532 G_CALLBACK(find_replace_cb), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2533 GINT_TO_POINTER(FRD_REPLACEALL)); |
7 | 2534 } |
2535 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2536 // 'Cancel' button |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2537 #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
|
2538 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
|
2539 #else |
7 | 2540 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
|
2541 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2542 gtk_widget_set_can_default(tmp, TRUE); |
7 | 2543 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
|
2544 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
|
2545 "clicked", G_CALLBACK(gtk_widget_hide), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2546 G_OBJECT(frdp->dialog)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2547 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
|
2548 "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
|
2549 G_OBJECT(frdp->dialog)); |
7 | 2550 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2551 #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
|
2552 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
|
2553 #else |
7 | 2554 tmp = gtk_vseparator_new(); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2555 #endif |
7 | 2556 gtk_box_pack_end(GTK_BOX(hbox), tmp, FALSE, FALSE, 10); |
2557 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2558 // 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
|
2559 #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
|
2560 # 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
|
2561 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
|
2562 # endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2563 #else |
7 | 2564 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
|
2565 #endif |
7 | 2566 gtk_widget_show_all(hbox); |
2567 gtk_widget_show(frdp->dialog); | |
2568 | |
2569 vim_free(entry_text); | |
2570 vim_free(conv_buffer); | |
2571 #undef CONV | |
2572 } | |
2573 | |
2574 void | |
2575 gui_mch_find_dialog(exarg_T *eap) | |
2576 { | |
2577 if (gui.in_use) | |
2578 find_replace_dialog_create(eap->arg, FALSE); | |
2579 } | |
2580 | |
2581 void | |
2582 gui_mch_replace_dialog(exarg_T *eap) | |
2583 { | |
2584 if (gui.in_use) | |
2585 find_replace_dialog_create(eap->arg, TRUE); | |
2586 } | |
2587 | |
2588 /* | |
2589 * Callback for actions of the find and replace dialogs | |
2590 */ | |
2591 static void | |
1884 | 2592 find_replace_cb(GtkWidget *widget UNUSED, gpointer data) |
7 | 2593 { |
2594 int flags; | |
2595 char_u *find_text; | |
2596 char_u *repl_text; | |
2597 gboolean direction_down; | |
2598 SharedFindReplace *sfr; | |
2599 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2600 flags = (int)(long)data; // avoid a lint warning here |
7 | 2601 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2602 // Get the search/replace strings from the dialog |
7 | 2603 if (flags == FRD_FINDNEXT) |
2604 { | |
2605 repl_text = NULL; | |
2606 sfr = &find_widgets; | |
2607 } | |
2608 else | |
2609 { | |
2610 repl_text = (char_u *)gtk_entry_get_text(GTK_ENTRY(repl_widgets.with)); | |
2611 sfr = &repl_widgets; | |
2612 } | |
2613 | |
2614 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
|
2615 direction_down = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->down)); |
7 | 2616 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2617 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->wword))) |
7 | 2618 flags |= FRD_WHOLE_WORD; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2619 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->mcase))) |
7 | 2620 flags |= FRD_MATCH_CASE; |
2621 | |
2622 repl_text = CONVERT_FROM_UTF8(repl_text); | |
2623 find_text = CONVERT_FROM_UTF8(find_text); | |
2656 | 2624 gui_do_findrepl(flags, find_text, repl_text, direction_down); |
7 | 2625 CONVERT_FROM_UTF8_FREE(repl_text); |
2626 CONVERT_FROM_UTF8_FREE(find_text); | |
2627 } | |
2628 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2629 /* |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2630 * our usual callback function |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2631 */ |
7 | 2632 static void |
1884 | 2633 entry_activate_cb(GtkWidget *widget UNUSED, gpointer data) |
7 | 2634 { |
2635 gtk_widget_grab_focus(GTK_WIDGET(data)); | |
2636 } | |
2637 | |
2638 /* | |
2639 * Syncing the find/replace dialogs on the fly is utterly useless crack, | |
2640 * and causes nothing but problems. Please tell me a use case for which | |
2641 * you'd need both a find dialog and a find/replace one at the same time, | |
2642 * without being able to actually use them separately since they're syncing | |
2643 * all the time. I don't think it's worthwhile to fix this nonsense, | |
2644 * particularly evil incarnation of braindeadness, whatever; I'd much rather | |
2645 * see it extinguished from this planet. Thanks for listening. Sorry. | |
2646 */ | |
2647 static void | |
2648 entry_changed_cb(GtkWidget * entry, GtkWidget * dialog) | |
2649 { | |
2650 const gchar *entry_text; | |
2651 gboolean nonempty; | |
2652 | |
2653 entry_text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
2654 | |
2655 if (!entry_text) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2656 return; // shouldn't happen |
7 | 2657 |
2658 nonempty = (entry_text[0] != '\0'); | |
2659 | |
2660 if (dialog == find_widgets.dialog) | |
2661 gtk_widget_set_sensitive(find_widgets.find, nonempty); | |
2662 | |
2663 if (dialog == repl_widgets.dialog) | |
2664 { | |
2665 gtk_widget_set_sensitive(repl_widgets.find, nonempty); | |
2666 gtk_widget_set_sensitive(repl_widgets.replace, nonempty); | |
2667 gtk_widget_set_sensitive(repl_widgets.all, nonempty); | |
2668 } | |
2669 } | |
2670 | |
2671 /* | |
2672 * ":helpfind" | |
2673 */ | |
2674 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7380
diff
changeset
|
2675 ex_helpfind(exarg_T *eap UNUSED) |
7 | 2676 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2677 // 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
|
2678 // backwards compatibility anyway. |
7 | 2679 do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp"); |
2680 } | |
3484 | 2681 |
3564 | 2682 #if defined(FEAT_BROWSE) || defined(PROTO) |
3484 | 2683 static void |
2684 recent_func_log_func(const gchar *log_domain UNUSED, | |
2685 GLogLevelFlags log_level UNUSED, | |
2686 const gchar *message UNUSED, | |
2687 gpointer user_data UNUSED) | |
2688 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2689 // 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
|
2690 // http://bugzilla.gnome.org/show_bug.cgi?id=664587 |
3484 | 2691 } |
3564 | 2692 #endif |