Mercurial > vim
annotate src/gui_gtk.c @ 14027:6d9783027174 v8.1.0031
patch 8.1.0031: terminal test aucmd_on_close if flaky
commit https://github.com/vim/vim/commit/c8523e2e6cd072d86a9412f465aa9eef53f5675e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 3 18:22:02 2018 +0200
patch 8.1.0031: terminal test aucmd_on_close if flaky
Problem: Terminal test aucmd_on_close if flaky.
Solution: Wait a bit longer.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 03 Jun 2018 18:30:05 +0200 |
parents | 8412df1479a3 |
children | 82e7ce311065 |
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 | |
40 /* GTK defines MAX and MIN, but some system header files as well. Undefine | |
41 * them and don't use them. */ | |
42 #ifdef MIN | |
43 # undef MIN | |
44 #endif | |
45 #ifdef MAX | |
46 # undef MAX | |
47 #endif | |
48 | |
49 #ifdef FEAT_GUI_GNOME | |
50 /* Gnome redefines _() and N_(). Grrr... */ | |
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) |
67 # define ENABLE_NLS /* so the texts in the dialog boxes are translated */ | |
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> |
79 # ifdef WIN3264 | |
80 # include <gdk/gdkwin32.h> | |
81 # else | |
82 # include <gdk/gdkx.h> | |
83 # endif | |
84 | |
85 # include <gtk/gtk.h> | |
86 #else | |
87 /* define these items to be able to generate prototypes without GTK */ | |
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 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
121 /* 00 */ "document-new", /* sub. GTK_STOCK_NEW */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
122 /* 01 */ "document-open", /* sub. GTK_STOCK_OPEN */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
123 /* 02 */ "document-save", /* sub. GTK_STOCK_SAVE */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
124 /* 03 */ "edit-undo", /* sub. GTK_STOCK_UNDO */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
125 /* 04 */ "edit-redo", /* sub. GTK_STOCK_REDO */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
126 /* 05 */ "edit-cut", /* sub. GTK_STOCK_CUT */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
127 /* 06 */ "edit-copy", /* sub. GTK_STOCK_COPY */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
128 /* 07 */ "edit-paste", /* sub. GTK_STOCK_PASTE */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
129 /* 08 */ "document-print", /* sub. GTK_STOCK_PRINT */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
130 /* 09 */ "help-browser", /* sub. GTK_STOCK_HELP */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
131 /* 10 */ "edit-find", /* sub. GTK_STOCK_FIND */ |
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) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
133 /* Use the file names in gui_gtk_res.xml, cutting off the extension. |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
134 * Similar changes follow. */ |
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 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
145 /* 15 */ "system-run", /* sub. GTK_STOCK_EXECUTE */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
146 /* 16 */ "edit-find-replace", /* sub. GTK_STOCK_FIND_AND_REPLACE */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
147 /* 17 */ "window-close", /* sub. GTK_STOCK_CLOSE, FIXME: fuzzy */ |
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 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
159 /* 22 */ "go-previous", /* sub. GTK_STOCK_GO_BACK */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
160 /* 23 */ "go-next", /* sub. GTK_STOCK_GO_FORWARD */ |
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 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
166 /* 25 */ "gtk-convert", /* sub. GTK_STOCK_CONVERT */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
167 /* 26 */ "go-jump", /* sub. GTK_STOCK_JUMP_TO */ |
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 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
179 /* 31 */ "application-exit", /* GTK_STOCK_QUIT */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
180 }; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
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, | |
201 /* 17 */ GTK_STOCK_CLOSE, /* FIXME: fuzzy */ | |
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 }; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
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 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
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: |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
319 /* FALLTHROUGH */ |
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; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
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; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
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 | |
370 /* First use a specified "icon=" argument. */ | |
371 if (menu->iconfile != NULL && lookup_menu_iconfile(menu->iconfile, buf)) | |
372 image = load_menu_iconfile(buf, icon_size); | |
373 | |
374 /* If not found and not builtin specified try using the menu name. */ | |
375 if (image == NULL && !menu->icon_builtin | |
376 && lookup_menu_iconfile(menu->name, buf)) | |
377 image = load_menu_iconfile(buf, icon_size); | |
378 | |
379 /* Still not found? Then use a builtin icon, a blank one as fallback. */ | |
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 { |
1884 | 413 /* When we're in a GtkPlug, we don't have window focus events, only widget |
414 * focus. To emulate stand-alone gvim, if a button gets focus (e.g., | |
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 } | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2103
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); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
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 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
481 /* An icon theme is supposed to provide fixed-size |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
482 * image files for each size, e.g., 16, 22, 24, ... |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
483 * Naturally, in contrast to GtkIconSet, GtkIconTheme |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
484 * won't prepare size variants for us out of a single |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
485 * fixed-size image. |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
486 * |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
487 * Currently, Vim provides 24x24 images only while the |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
488 * icon size on the menu and the toolbar is set to 16x16 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
489 * by default. |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
490 * |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
491 * Resize them by ourselves until we have our own fully |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
492 * fledged icon theme. */ |
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 } |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
506 # else /* !GTK_CHECK_VERSION(3,0.0) */ |
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); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
528 # endif /* !GTK_CHECK_VERSION(3,0,0) */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
529 # endif /* defined(USE_GRESOURCE) */ |
7 | 530 } |
531 | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2103
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 | |
562 buf = alloc((unsigned)(psrc - name + n_underscores + 1)); | |
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 | |
600 /* It would be neat to have image menu items, but that would require major | |
601 * changes to Vim's menu system. Not to mention that all the translations | |
602 * had to be updated. */ | |
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) |
7 | 656 /* since the tearoff should always appear first, increment idx */ |
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 | |
687 void | |
688 gui_mch_add_menu_item(vimmenu_T *menu, int idx) | |
689 { | |
690 vimmenu_T *parent; | |
691 | |
692 parent = menu->parent; | |
693 | |
694 # ifdef FEAT_TOOLBAR | |
695 if (menu_is_toolbar(parent->name)) | |
696 { | |
697 GtkToolbar *toolbar; | |
698 | |
699 toolbar = GTK_TOOLBAR(gui.toolbar); | |
700 menu->submenu_id = NULL; | |
701 | |
702 if (menu_is_separator(menu->name)) | |
703 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
704 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
705 GtkToolItem *item = gtk_separator_tool_item_new(); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
706 gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(item), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
707 TRUE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
708 gtk_tool_item_set_expand(GTK_TOOL_ITEM(item), FALSE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
709 gtk_widget_show(GTK_WIDGET(item)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
710 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
711 gtk_toolbar_insert(toolbar, item, idx); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
712 # else |
7 | 713 gtk_toolbar_insert_space(toolbar, idx); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
714 # endif |
7 | 715 menu->id = NULL; |
716 } | |
717 else | |
718 { | |
719 char_u *text; | |
720 char_u *tooltip; | |
721 | |
722 text = CONVERT_TO_UTF8(menu->dname); | |
723 tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); | |
26 | 724 if (tooltip != NULL && !utf_valid_string(tooltip, NULL)) |
725 /* Invalid text, can happen when 'encoding' is changed. Avoid | |
726 * a nasty GTK error message, skip the tooltip. */ | |
727 CONVERT_TO_UTF8_FREE(tooltip); | |
7 | 728 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
729 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
730 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
731 GtkWidget *icon; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
732 GtkToolItem *item; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
733 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
734 icon = create_menu_icon(menu, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
735 gtk_toolbar_get_icon_size(toolbar)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
736 item = gtk_tool_button_new(icon, (const gchar *)text); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
737 gtk_tool_item_set_tooltip_text(item, (const gchar *)tooltip); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
738 g_signal_connect(G_OBJECT(item), "clicked", |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
739 G_CALLBACK(&menu_item_activate), menu); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
740 gtk_widget_show_all(GTK_WIDGET(item)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
741 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
742 gtk_toolbar_insert(toolbar, item, idx); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
743 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
744 menu->id = GTK_WIDGET(item); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
745 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
746 # else |
7 | 747 menu->id = gtk_toolbar_insert_item( |
748 toolbar, | |
749 (const char *)text, | |
750 (const char *)tooltip, | |
751 NULL, | |
752 create_menu_icon(menu, gtk_toolbar_get_icon_size(toolbar)), | |
753 G_CALLBACK(&menu_item_activate), | |
754 menu, | |
755 idx); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
756 # endif |
7 | 757 |
856 | 758 if (gtk_socket_id != 0) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
759 # 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
|
760 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
|
761 G_CALLBACK(toolbar_button_focus_in_event), NULL); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
762 # else |
856 | 763 gtk_signal_connect(GTK_OBJECT(menu->id), "focus_in_event", |
764 GTK_SIGNAL_FUNC(toolbar_button_focus_in_event), NULL); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
765 # endif |
790 | 766 |
7 | 767 CONVERT_TO_UTF8_FREE(text); |
768 CONVERT_TO_UTF8_FREE(tooltip); | |
769 } | |
770 } | |
771 else | |
772 # endif /* FEAT_TOOLBAR */ | |
773 { | |
774 /* No parent, must be a non-menubar menu */ | |
840 | 775 if (parent == NULL || parent->submenu_id == NULL) |
7 | 776 return; |
777 | |
11508
9b1077d33c68
patch 8.0.0637: crash when using some version of GTK 3
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
778 # if !GTK_CHECK_VERSION(3,4,0) |
7 | 779 /* Make place for the possible tearoff handle item. Not in the popup |
780 * menu, it doesn't have a tearoff item. */ | |
840 | 781 if (!menu_is_popup(parent->name)) |
7 | 782 ++idx; |
11508
9b1077d33c68
patch 8.0.0637: crash when using some version of GTK 3
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
783 # endif |
7 | 784 |
785 if (menu_is_separator(menu->name)) | |
786 { | |
787 /* Separator: Just add it */ | |
9035
08854bb267b2
commit https://github.com/vim/vim/commit/0b6cf69c038b9af198542edc349ebe8e53a8f847
Christian Brabandt <cb@256bit.org>
parents:
8279
diff
changeset
|
788 # 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
|
789 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
|
790 # else |
7 | 791 menu->id = gtk_menu_item_new(); |
792 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
|
793 # endif |
7 | 794 gtk_widget_show(menu->id); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
795 # 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
|
796 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
|
797 menu->id, idx); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
798 # else |
7 | 799 gtk_menu_insert(GTK_MENU(parent->submenu_id), menu->id, idx); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
800 # endif |
7 | 801 |
802 return; | |
803 } | |
804 | |
805 /* Add textual menu item. */ | |
806 menu_item_new(menu, parent->submenu_id); | |
807 gtk_widget_show(menu->id); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
808 # 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
|
809 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
|
810 menu->id, idx); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
811 # else |
7 | 812 gtk_menu_insert(GTK_MENU(parent->submenu_id), menu->id, idx); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
813 # endif |
7 | 814 |
815 if (menu->id != NULL) | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
816 # 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
|
817 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
|
818 G_CALLBACK(menu_item_activate), menu); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
819 # else |
7 | 820 gtk_signal_connect(GTK_OBJECT(menu->id), "activate", |
821 GTK_SIGNAL_FUNC(menu_item_activate), menu); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
822 # endif |
7 | 823 } |
824 } | |
825 #endif /* FEAT_MENU */ | |
826 | |
827 | |
828 void | |
829 gui_mch_set_text_area_pos(int x, int y, int w, int h) | |
830 { | |
831 gtk_form_move_resize(GTK_FORM(gui.formwin), gui.drawarea, x, y, w, h); | |
832 } | |
833 | |
834 | |
835 #if defined(FEAT_MENU) || defined(PROTO) | |
836 /* | |
1215 | 837 * Enable or disable accelerators for the toplevel menus. |
7 | 838 */ |
839 void | |
840 gui_gtk_set_mnemonics(int enable) | |
841 { | |
842 vimmenu_T *menu; | |
843 char_u *name; | |
844 | |
845 for (menu = root_menu; menu != NULL; menu = menu->next) | |
846 { | |
847 if (menu->id == NULL) | |
848 continue; | |
849 | |
850 name = translate_mnemonic_tag(menu->name, enable); | |
851 gtk_label_set_text_with_mnemonic(GTK_LABEL(menu->label), | |
852 (const char *)name); | |
853 vim_free(name); | |
854 } | |
855 } | |
856 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
857 # if !GTK_CHECK_VERSION(3,4,0) |
7 | 858 static void |
859 recurse_tearoffs(vimmenu_T *menu, int val) | |
860 { | |
861 for (; menu != NULL; menu = menu->next) | |
862 { | |
863 if (menu->submenu_id != NULL && menu->tearoff_handle != NULL | |
864 && menu->name[0] != ']' && !menu_is_popup(menu->name)) | |
865 { | |
866 if (val) | |
867 gtk_widget_show(menu->tearoff_handle); | |
868 else | |
869 gtk_widget_hide(menu->tearoff_handle); | |
870 } | |
871 recurse_tearoffs(menu->children, val); | |
872 } | |
873 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
874 # endif |
7 | 875 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
876 # 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
|
877 void |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
878 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
|
879 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
880 /* Do nothing */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
881 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
882 # else |
7 | 883 void |
884 gui_mch_toggle_tearoffs(int enable) | |
885 { | |
886 recurse_tearoffs(root_menu, enable); | |
887 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
888 # endif |
7 | 889 #endif /* FEAT_MENU */ |
890 | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2103
diff
changeset
|
891 #if defined(FEAT_TOOLBAR) |
7 | 892 static int |
893 get_menu_position(vimmenu_T *menu) | |
894 { | |
895 vimmenu_T *node; | |
944 | 896 int idx = 0; |
7 | 897 |
898 for (node = menu->parent->children; node != menu; node = node->next) | |
899 { | |
900 g_return_val_if_fail(node != NULL, -1); | |
944 | 901 ++idx; |
7 | 902 } |
903 | |
944 | 904 return idx; |
7 | 905 } |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2103
diff
changeset
|
906 #endif /* FEAT_TOOLBAR */ |
7 | 907 |
908 | |
909 #if defined(FEAT_TOOLBAR) || defined(PROTO) | |
910 void | |
911 gui_mch_menu_set_tip(vimmenu_T *menu) | |
912 { | |
913 if (menu->id != NULL && menu->parent != NULL | |
914 && gui.toolbar != NULL && menu_is_toolbar(menu->parent->name)) | |
915 { | |
916 char_u *tooltip; | |
917 | |
918 tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
919 if (tooltip != NULL && utf_valid_string(tooltip, NULL)) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
920 # if GTK_CHECK_VERSION(3,0,0) |
26 | 921 /* Only set the tooltip when it's valid utf-8. */ |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
922 gtk_widget_set_tooltip_text(menu->id, (const gchar *)tooltip); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
923 # else |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
924 /* Only set the tooltip when it's valid utf-8. */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
925 gtk_tooltips_set_tip(GTK_TOOLBAR(gui.toolbar)->tooltips, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
926 menu->id, (const char *)tooltip, NULL); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
927 # endif |
7 | 928 CONVERT_TO_UTF8_FREE(tooltip); |
929 } | |
930 } | |
931 #endif /* FEAT_TOOLBAR */ | |
932 | |
933 | |
934 #if defined(FEAT_MENU) || defined(PROTO) | |
935 /* | |
936 * Destroy the machine specific menu widget. | |
937 */ | |
938 void | |
939 gui_mch_destroy_menu(vimmenu_T *menu) | |
940 { | |
5092
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
941 /* Don't let gtk_container_remove automatically destroy menu->id. */ |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
942 if (menu->id != NULL) |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
943 g_object_ref(menu->id); |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
944 |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
945 /* Workaround for a spurious gtk warning in Ubuntu: "Trying to remove |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
946 * a child that doesn't believe we're it's parent." |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
947 * Remove widget from gui.menubar before destroying it. */ |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
948 if (menu->id != NULL && gui.menubar != NULL |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
949 && gtk_widget_get_parent(menu->id) == gui.menubar) |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
950 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
|
951 |
7 | 952 # ifdef FEAT_TOOLBAR |
953 if (menu->parent != NULL && menu_is_toolbar(menu->parent->name)) | |
954 { | |
955 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
|
956 # 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
|
957 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
958 GtkToolItem *item = NULL; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
959 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
960 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
|
961 get_menu_position(menu)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
962 if (item != NULL) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
963 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
|
964 GTK_WIDGET(item)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
965 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
966 # else |
7 | 967 gtk_toolbar_remove_space(GTK_TOOLBAR(gui.toolbar), |
968 get_menu_position(menu)); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
969 # endif |
7 | 970 else if (menu->id != NULL) |
971 gtk_widget_destroy(menu->id); | |
972 } | |
973 else | |
974 # endif /* FEAT_TOOLBAR */ | |
975 { | |
976 if (menu->submenu_id != NULL) | |
977 gtk_widget_destroy(menu->submenu_id); | |
978 | |
979 if (menu->id != NULL) | |
980 gtk_widget_destroy(menu->id); | |
981 } | |
982 | |
5092
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
983 if (menu->id != NULL) |
1ed945570d47
updated for version 7.3.1289
Bram Moolenaar <bram@vim.org>
parents:
3871
diff
changeset
|
984 g_object_unref(menu->id); |
7 | 985 menu->submenu_id = NULL; |
986 menu->id = NULL; | |
987 } | |
988 #endif /* FEAT_MENU */ | |
989 | |
990 | |
991 /* | |
992 * Scrollbar stuff. | |
993 */ | |
994 void | |
995 gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max) | |
996 { | |
997 if (sb->id != NULL) | |
998 { | |
999 GtkAdjustment *adjustment; | |
1000 | |
1001 adjustment = gtk_range_get_adjustment(GTK_RANGE(sb->id)); | |
1002 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1003 #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
|
1004 gtk_adjustment_set_lower(adjustment, 0.0); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1005 gtk_adjustment_set_value(adjustment, val); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1006 gtk_adjustment_set_upper(adjustment, max + 1); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1007 gtk_adjustment_set_page_size(adjustment, size); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1008 gtk_adjustment_set_page_increment(adjustment, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1009 size < 3L ? 1L : size - 2L); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1010 gtk_adjustment_set_step_increment(adjustment, 1.0); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1011 #else |
7 | 1012 adjustment->lower = 0.0; |
1013 adjustment->value = val; | |
1014 adjustment->upper = max + 1; | |
1015 adjustment->page_size = size; | |
1016 adjustment->page_increment = size < 3L ? 1L : size - 2L; | |
1017 adjustment->step_increment = 1.0; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1018 #endif |
7 | 1019 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1020 #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
|
1021 g_signal_handler_block(G_OBJECT(adjustment), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1022 (gulong)sb->handler_id); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1023 #else |
7 | 1024 g_signal_handler_block(GTK_OBJECT(adjustment), |
1025 (gulong)sb->handler_id); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1026 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1027 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1028 #if !GTK_CHECK_VERSION(3,18,0) |
7 | 1029 gtk_adjustment_changed(adjustment); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1030 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1031 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1032 #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
|
1033 g_signal_handler_unblock(G_OBJECT(adjustment), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1034 (gulong)sb->handler_id); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1035 #else |
7 | 1036 g_signal_handler_unblock(GTK_OBJECT(adjustment), |
1037 (gulong)sb->handler_id); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1038 #endif |
7 | 1039 } |
1040 } | |
1041 | |
1042 void | |
1043 gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h) | |
1044 { | |
1045 if (sb->id != NULL) | |
1046 gtk_form_move_resize(GTK_FORM(gui.formwin), sb->id, x, y, w, h); | |
1047 } | |
1048 | |
1049 /* | |
1050 * Take action upon scrollbar dragging. | |
1051 */ | |
1052 static void | |
1053 adjustment_value_changed(GtkAdjustment *adjustment, gpointer data) | |
1054 { | |
1055 scrollbar_T *sb; | |
1056 long value; | |
1057 int dragging = FALSE; | |
1058 | |
1059 #ifdef FEAT_XIM | |
1060 /* cancel any preediting */ | |
1061 if (im_is_preediting()) | |
1062 xim_reset(); | |
1063 #endif | |
1064 | |
1065 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
|
1066 #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
|
1067 value = gtk_adjustment_get_value(adjustment); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1068 #else |
7 | 1069 value = (long)adjustment->value; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1070 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1071 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 1072 /* |
1073 * The dragging argument must be right for the scrollbar to work with | |
1074 * closed folds. This isn't documented, hopefully this will keep on | |
1075 * working in later GTK versions. | |
1076 * | |
1077 * FIXME: Well, it doesn't work in GTK2. :) | |
1078 * HACK: Get the mouse pointer position, if it appears to be on an arrow | |
1079 * button set "dragging" to FALSE. This assumes square buttons! | |
1080 */ | |
1081 if (sb != NULL) | |
1082 { | |
1083 dragging = TRUE; | |
1084 | |
1085 if (sb->wp != NULL) | |
1086 { | |
1087 int x; | |
1088 int y; | |
1089 GdkModifierType state; | |
1090 int width; | |
1091 int height; | |
1092 | |
1093 /* vertical scrollbar: need to set "dragging" properly in case | |
1094 * there are closed folds. */ | |
1095 gdk_window_get_pointer(sb->id->window, &x, &y, &state); | |
1096 gdk_window_get_size(sb->id->window, &width, &height); | |
1097 if (x >= 0 && x < width && y >= 0 && y < height) | |
1098 { | |
1099 if (y < width) | |
1100 { | |
1101 /* up arrow: move one (closed fold) line up */ | |
1102 dragging = FALSE; | |
1103 value = sb->wp->w_topline - 2; | |
1104 } | |
1105 else if (y > height - width) | |
1106 { | |
1107 /* down arrow: move one (closed fold) line down */ | |
1108 dragging = FALSE; | |
1109 value = sb->wp->w_topline; | |
1110 } | |
1111 } | |
1112 } | |
1113 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1114 #endif /* !GTK_CHECK_VERSION(3,0,0) */ |
7 | 1115 gui_drag_scrollbar(sb, value, dragging); |
1116 } | |
1117 | |
1118 /* SBAR_VERT or SBAR_HORIZ */ | |
1119 void | |
1120 gui_mch_create_scrollbar(scrollbar_T *sb, int orient) | |
1121 { | |
1122 if (orient == SBAR_HORIZ) | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1123 #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
|
1124 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
|
1125 #else |
7 | 1126 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
|
1127 #endif |
7 | 1128 else if (orient == SBAR_VERT) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1129 #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
|
1130 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
|
1131 #else |
7 | 1132 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
|
1133 #endif |
7 | 1134 |
1135 if (sb->id != NULL) | |
1136 { | |
1137 GtkAdjustment *adjustment; | |
1138 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1139 #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
|
1140 gtk_widget_set_can_focus(sb->id, FALSE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1141 #else |
7 | 1142 GTK_WIDGET_UNSET_FLAGS(sb->id, GTK_CAN_FOCUS); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1143 #endif |
7 | 1144 gtk_form_put(GTK_FORM(gui.formwin), sb->id, 0, 0); |
1145 | |
1146 adjustment = gtk_range_get_adjustment(GTK_RANGE(sb->id)); | |
1147 | |
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,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1149 sb->handler_id = g_signal_connect( |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1150 G_OBJECT(adjustment), "value-changed", |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1151 G_CALLBACK(adjustment_value_changed), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1152 GINT_TO_POINTER(sb->ident)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1153 #else |
7 | 1154 sb->handler_id = gtk_signal_connect( |
1155 GTK_OBJECT(adjustment), "value_changed", | |
1156 GTK_SIGNAL_FUNC(adjustment_value_changed), | |
1157 GINT_TO_POINTER(sb->ident)); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1158 #endif |
7 | 1159 gui_mch_update(); |
1160 } | |
1161 } | |
1162 | |
1163 void | |
1164 gui_mch_destroy_scrollbar(scrollbar_T *sb) | |
1165 { | |
1166 if (sb->id != NULL) | |
1167 { | |
1168 gtk_widget_destroy(sb->id); | |
1169 sb->id = NULL; | |
1170 } | |
1171 gui_mch_update(); | |
1172 } | |
1173 | |
1174 #if defined(FEAT_BROWSE) || defined(PROTO) | |
1175 /* | |
1176 * Implementation of the file selector related stuff | |
1177 */ | |
270 | 1178 |
1179 #ifndef USE_FILE_CHOOSER | |
7 | 1180 static void |
1884 | 1181 browse_ok_cb(GtkWidget *widget UNUSED, gpointer cbdata) |
7 | 1182 { |
1183 gui_T *vw = (gui_T *)cbdata; | |
1184 | |
1185 if (vw->browse_fname != NULL) | |
1186 g_free(vw->browse_fname); | |
1187 | |
1188 vw->browse_fname = (char_u *)g_strdup(gtk_file_selection_get_filename( | |
1189 GTK_FILE_SELECTION(vw->filedlg))); | |
1190 gtk_widget_hide(vw->filedlg); | |
1191 } | |
1192 | |
1193 static void | |
1884 | 1194 browse_cancel_cb(GtkWidget *widget UNUSED, gpointer cbdata) |
7 | 1195 { |
1196 gui_T *vw = (gui_T *)cbdata; | |
1197 | |
1198 if (vw->browse_fname != NULL) | |
1199 { | |
1200 g_free(vw->browse_fname); | |
1201 vw->browse_fname = NULL; | |
1202 } | |
1203 gtk_widget_hide(vw->filedlg); | |
1204 } | |
1205 | |
1206 static gboolean | |
1884 | 1207 browse_destroy_cb(GtkWidget *widget UNUSED) |
7 | 1208 { |
1209 if (gui.browse_fname != NULL) | |
1210 { | |
1211 g_free(gui.browse_fname); | |
1212 gui.browse_fname = NULL; | |
1213 } | |
1214 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
|
1215 gtk_main_quit(); |
7 | 1216 return FALSE; |
1217 } | |
270 | 1218 #endif |
7 | 1219 |
1220 /* | |
1221 * Put up a file requester. | |
1222 * Returns the selected name in allocated memory, or NULL for Cancel. | |
1223 * saving, select file to write | |
1224 * title title for the window | |
1225 * dflt default name | |
1226 * ext not used (extension added) | |
1227 * initdir initial directory, NULL for current dir | |
1228 * filter not used (file name filter) | |
1229 */ | |
1230 char_u * | |
1884 | 1231 gui_mch_browse(int saving UNUSED, |
7 | 1232 char_u *title, |
1233 char_u *dflt, | |
1884 | 1234 char_u *ext UNUSED, |
7 | 1235 char_u *initdir, |
3664 | 1236 char_u *filter) |
7 | 1237 { |
270 | 1238 #ifdef USE_FILE_CHOOSER |
1239 GtkWidget *fc; | |
1240 #endif | |
29 | 1241 char_u dirbuf[MAXPATHL]; |
3484 | 1242 guint log_handler; |
1243 const gchar *domain = "Gtk"; | |
7 | 1244 |
1245 title = CONVERT_TO_UTF8(title); | |
1246 | |
1003 | 1247 /* GTK has a bug, it only works with an absolute path. */ |
270 | 1248 if (initdir == NULL || *initdir == NUL) |
1249 mch_dirname(dirbuf, MAXPATHL); | |
1003 | 1250 else if (vim_FullName(initdir, dirbuf, MAXPATHL - 2, FALSE) == FAIL) |
270 | 1251 dirbuf[0] = NUL; |
1252 /* Always need a trailing slash for a directory. */ | |
1253 add_pathsep(dirbuf); | |
1254 | |
1255 /* If our pointer is currently hidden, then we should show it. */ | |
1256 gui_mch_mousehide(FALSE); | |
1257 | |
3484 | 1258 /* Hack: The GTK file dialog warns when it can't access a new file, this |
1259 * makes it shut up. http://bugzilla.gnome.org/show_bug.cgi?id=664587 */ | |
1260 log_handler = g_log_set_handler(domain, G_LOG_LEVEL_WARNING, | |
1261 recent_func_log_func, NULL); | |
1262 | |
270 | 1263 #ifdef USE_FILE_CHOOSER |
1264 /* We create the dialog each time, so that the button text can be "Open" | |
1265 * or "Save" according to the action. */ | |
1266 fc = gtk_file_chooser_dialog_new((const gchar *)title, | |
1267 GTK_WINDOW(gui.mainwin), | |
1268 saving ? GTK_FILE_CHOOSER_ACTION_SAVE | |
1269 : GTK_FILE_CHOOSER_ACTION_OPEN, | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1270 # 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
|
1271 _("_Cancel"), GTK_RESPONSE_CANCEL, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1272 saving ? _("_Save") : _("_Open"), GTK_RESPONSE_ACCEPT, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1273 # else |
1025 | 1274 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
270 | 1275 saving ? GTK_STOCK_SAVE : GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1276 # endif |
270 | 1277 NULL); |
1278 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc), | |
1279 (const gchar *)dirbuf); | |
3664 | 1280 |
1281 if (filter != NULL && *filter != NUL) | |
1282 { | |
1283 int i = 0; | |
1284 char_u *patt; | |
1285 char_u *p = filter; | |
3871 | 1286 GtkFileFilter *gfilter; |
3664 | 1287 |
1288 gfilter = gtk_file_filter_new(); | |
1289 patt = alloc(STRLEN(filter)); | |
1290 while (p != NULL && *p != NUL) | |
1291 { | |
1292 if (*p == '\n' || *p == ';' || *p == '\t') | |
1293 { | |
1294 STRNCPY(patt, filter, i); | |
1295 patt[i] = '\0'; | |
1296 if (*p == '\t') | |
1297 gtk_file_filter_set_name(gfilter, (gchar *)patt); | |
1298 else | |
1299 { | |
1300 gtk_file_filter_add_pattern(gfilter, (gchar *)patt); | |
1301 if (*p == '\n') | |
1302 { | |
1303 gtk_file_chooser_add_filter((GtkFileChooser *)fc, | |
1304 gfilter); | |
1305 if (*(p + 1) != NUL) | |
1306 gfilter = gtk_file_filter_new(); | |
1307 } | |
1308 } | |
1309 filter = ++p; | |
1310 i = 0; | |
1311 } | |
1312 else | |
1313 { | |
1314 p++; | |
1315 i++; | |
1316 } | |
1317 } | |
1318 vim_free(patt); | |
1319 } | |
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
|
1320 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
|
1321 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), (char *)dflt); |
270 | 1322 |
1323 gui.browse_fname = NULL; | |
1324 if (gtk_dialog_run(GTK_DIALOG(fc)) == GTK_RESPONSE_ACCEPT) | |
7 | 1325 { |
856 | 1326 char *filename; |
1327 | |
1328 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc)); | |
1329 gui.browse_fname = (char_u *)g_strdup(filename); | |
1330 g_free(filename); | |
270 | 1331 } |
1332 gtk_widget_destroy(GTK_WIDGET(fc)); | |
1333 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1334 #else /* !USE_FILE_CHOOSER */ |
270 | 1335 |
1336 if (gui.filedlg == NULL) | |
1337 { | |
1338 GtkFileSelection *fs; /* shortcut */ | |
1339 | |
7 | 1340 gui.filedlg = gtk_file_selection_new((const gchar *)title); |
1341 gtk_window_set_modal(GTK_WINDOW(gui.filedlg), TRUE); | |
1342 gtk_window_set_transient_for(GTK_WINDOW(gui.filedlg), | |
270 | 1343 GTK_WINDOW(gui.mainwin)); |
7 | 1344 fs = GTK_FILE_SELECTION(gui.filedlg); |
1345 | |
1346 gtk_container_border_width(GTK_CONTAINER(fs), 4); | |
1347 | |
1348 gtk_signal_connect(GTK_OBJECT(fs->ok_button), | |
1349 "clicked", GTK_SIGNAL_FUNC(browse_ok_cb), &gui); | |
1350 gtk_signal_connect(GTK_OBJECT(fs->cancel_button), | |
1351 "clicked", GTK_SIGNAL_FUNC(browse_cancel_cb), &gui); | |
1352 /* gtk_signal_connect() doesn't work for destroy, it causes a hang */ | |
1353 gtk_signal_connect_object(GTK_OBJECT(gui.filedlg), | |
1354 "destroy", GTK_SIGNAL_FUNC(browse_destroy_cb), | |
1355 GTK_OBJECT(gui.filedlg)); | |
1356 } | |
1357 else | |
1358 gtk_window_set_title(GTK_WINDOW(gui.filedlg), (const gchar *)title); | |
1359 | |
1003 | 1360 /* Concatenate "initdir" and "dflt". */ |
1361 if (dflt != NULL && *dflt != NUL | |
1362 && STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL) | |
1363 STRCAT(dirbuf, dflt); | |
1364 | |
7 | 1365 gtk_file_selection_set_filename(GTK_FILE_SELECTION(gui.filedlg), |
1366 (const gchar *)dirbuf); | |
1367 | |
1368 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
|
1369 gtk_main(); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1370 #endif /* !USE_FILE_CHOOSER */ |
3484 | 1371 g_log_remove_handler(domain, log_handler); |
270 | 1372 |
1373 CONVERT_TO_UTF8_FREE(title); | |
7 | 1374 if (gui.browse_fname == NULL) |
1375 return NULL; | |
1376 | |
1377 /* shorten the file name if possible */ | |
1411 | 1378 return vim_strsave(shorten_fname1(gui.browse_fname)); |
7 | 1379 } |
1380 | |
29 | 1381 /* |
1382 * Put up a directory selector | |
1383 * Returns the selected name in allocated memory, or NULL for Cancel. | |
1384 * title title for the window | |
1385 * dflt default name | |
1386 * initdir initial directory, NULL for current dir | |
1387 */ | |
1388 char_u * | |
1389 gui_mch_browsedir( | |
1390 char_u *title, | |
1391 char_u *initdir) | |
1392 { | |
1393 # if defined(GTK_FILE_CHOOSER) /* Only in GTK 2.4 and later. */ | |
1394 char_u dirbuf[MAXPATHL]; | |
1395 char_u *p; | |
1396 GtkWidget *dirdlg; /* file selection dialog */ | |
1397 char_u *dirname = NULL; | |
1398 | |
1399 title = CONVERT_TO_UTF8(title); | |
1400 | |
1401 dirdlg = gtk_file_chooser_dialog_new( | |
1402 (const gchar *)title, | |
1403 GTK_WINDOW(gui.mainwin), | |
1404 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
|
1405 # 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
|
1406 _("_Cancel"), GTK_RESPONSE_CANCEL, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1407 _("_OK"), GTK_RESPONSE_ACCEPT, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1408 # else |
29 | 1409 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
1410 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
|
1411 # endif |
29 | 1412 NULL); |
1413 | |
1414 CONVERT_TO_UTF8_FREE(title); | |
1415 | |
1416 /* if our pointer is currently hidden, then we should show it. */ | |
1417 gui_mch_mousehide(FALSE); | |
1418 | |
1419 /* GTK appears to insist on an absolute path. */ | |
1420 if (initdir == NULL || *initdir == NUL | |
1421 || vim_FullName(initdir, dirbuf, MAXPATHL - 10, FALSE) == FAIL) | |
1422 mch_dirname(dirbuf, MAXPATHL - 10); | |
1423 | |
1424 /* Always need a trailing slash for a directory. | |
1425 * Also add a dummy file name, so that we get to the directory. */ | |
1426 add_pathsep(dirbuf); | |
1427 STRCAT(dirbuf, "@zd(*&1|"); | |
1428 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dirdlg), | |
1429 (const gchar *)dirbuf); | |
1430 | |
1431 /* Run the dialog. */ | |
1432 if (gtk_dialog_run(GTK_DIALOG(dirdlg)) == GTK_RESPONSE_ACCEPT) | |
1433 dirname = (char_u *)gtk_file_chooser_get_filename( | |
1434 GTK_FILE_CHOOSER(dirdlg)); | |
1435 gtk_widget_destroy(dirdlg); | |
1436 if (dirname == NULL) | |
1437 return NULL; | |
1438 | |
1439 /* shorten the file name if possible */ | |
1411 | 1440 p = vim_strsave(shorten_fname1(dirname)); |
29 | 1441 g_free(dirname); |
1442 return p; | |
1443 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1444 # else /* !defined(GTK_FILE_CHOOSER) */ |
29 | 1445 /* For GTK 2.2 and earlier: fall back to ordinary file selector. */ |
1446 return gui_mch_browse(0, title, NULL, NULL, initdir, NULL); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1447 # endif /* !defined(GTK_FILE_CHOOSER) */ |
29 | 1448 } |
1449 | |
270 | 1450 |
7 | 1451 #endif /* FEAT_BROWSE */ |
1452 | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2103
diff
changeset
|
1453 #if defined(FEAT_GUI_DIALOG) || defined(PROTO) |
7 | 1454 |
1455 static GtkWidget * | |
1456 create_message_dialog(int type, char_u *title, char_u *message) | |
1457 { | |
1458 GtkWidget *dialog; | |
1459 GtkMessageType message_type; | |
1460 | |
1461 switch (type) | |
1462 { | |
1463 case VIM_ERROR: message_type = GTK_MESSAGE_ERROR; break; | |
1464 case VIM_WARNING: message_type = GTK_MESSAGE_WARNING; break; | |
1465 case VIM_QUESTION: message_type = GTK_MESSAGE_QUESTION; break; | |
1466 default: message_type = GTK_MESSAGE_INFO; break; | |
1467 } | |
1468 | |
1469 message = CONVERT_TO_UTF8(message); | |
1470 dialog = gtk_message_dialog_new(GTK_WINDOW(gui.mainwin), | |
1471 GTK_DIALOG_DESTROY_WITH_PARENT, | |
1472 message_type, | |
1473 GTK_BUTTONS_NONE, | |
1474 "%s", (const char *)message); | |
1475 CONVERT_TO_UTF8_FREE(message); | |
1476 | |
1477 if (title != NULL) | |
1478 { | |
1479 title = CONVERT_TO_UTF8(title); | |
1480 gtk_window_set_title(GTK_WINDOW(dialog), (const char *)title); | |
1481 CONVERT_TO_UTF8_FREE(title); | |
1482 } | |
1483 else if (type == VIM_GENERIC) | |
1484 { | |
1485 gtk_window_set_title(GTK_WINDOW(dialog), "VIM"); | |
1486 } | |
1487 | |
1488 return dialog; | |
1489 } | |
1490 | |
1491 /* | |
1492 * Split up button_string into individual button labels by inserting | |
1493 * NUL bytes. Also replace the Vim-style mnemonic accelerator prefix | |
1494 * '&' with '_'. button_string must point to allocated memory! | |
1495 * Return an allocated array of pointers into button_string. | |
1496 */ | |
1497 static char ** | |
1498 split_button_string(char_u *button_string, int *n_buttons) | |
1499 { | |
1500 char **array; | |
1501 char_u *p; | |
1502 unsigned int count = 1; | |
1503 | |
1504 for (p = button_string; *p != NUL; ++p) | |
1505 if (*p == DLG_BUTTON_SEP) | |
1506 ++count; | |
1507 | |
1508 array = (char **)alloc((count + 1) * sizeof(char *)); | |
1509 count = 0; | |
1510 | |
1511 if (array != NULL) | |
1512 { | |
1513 array[count++] = (char *)button_string; | |
40 | 1514 for (p = button_string; *p != NUL; ) |
7 | 1515 { |
1516 if (*p == DLG_BUTTON_SEP) | |
1517 { | |
40 | 1518 *p++ = NUL; |
1519 array[count++] = (char *)p; | |
7 | 1520 } |
1521 else if (*p == DLG_HOTKEY_CHAR) | |
40 | 1522 *p++ = '_'; |
1523 else | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10544
diff
changeset
|
1524 MB_PTR_ADV(p); |
7 | 1525 } |
1526 array[count] = NULL; /* currently not relied upon, but doesn't hurt */ | |
1527 } | |
1528 | |
1529 *n_buttons = count; | |
1530 return array; | |
1531 } | |
1532 | |
1533 static char ** | |
1534 split_button_translation(const char *message) | |
1535 { | |
1536 char **buttons = NULL; | |
1537 char_u *str; | |
1538 int n_buttons = 0; | |
1539 int n_expected = 1; | |
1540 | |
1541 for (str = (char_u *)message; *str != NUL; ++str) | |
1542 if (*str == DLG_BUTTON_SEP) | |
1543 ++n_expected; | |
1544 | |
1545 str = (char_u *)_(message); | |
1546 if (str != NULL) | |
1547 { | |
1548 if (output_conv.vc_type != CONV_NONE) | |
1549 str = string_convert(&output_conv, str, NULL); | |
1550 else | |
1551 str = vim_strsave(str); | |
1552 | |
1553 if (str != NULL) | |
1554 buttons = split_button_string(str, &n_buttons); | |
1555 } | |
1556 /* | |
1557 * Uh-oh... this should never ever happen. But we don't wanna crash | |
1558 * if the translation is broken, thus fall back to the untranslated | |
1559 * buttons string in case of emergency. | |
1560 */ | |
1561 if (buttons == NULL || n_buttons != n_expected) | |
1562 { | |
1563 vim_free(buttons); | |
1564 vim_free(str); | |
1565 buttons = NULL; | |
1566 str = vim_strsave((char_u *)message); | |
1567 | |
1568 if (str != NULL) | |
1569 buttons = split_button_string(str, &n_buttons); | |
1570 if (buttons == NULL) | |
1571 vim_free(str); | |
1572 } | |
1573 | |
1574 return buttons; | |
1575 } | |
1576 | |
1577 static int | |
1578 button_equal(const char *a, const char *b) | |
1579 { | |
1580 while (*a != '\0' && *b != '\0') | |
1581 { | |
1582 if (*a == '_' && *++a == '\0') | |
1583 break; | |
1584 if (*b == '_' && *++b == '\0') | |
1585 break; | |
1586 | |
1587 if (g_unichar_tolower(g_utf8_get_char(a)) | |
1588 != g_unichar_tolower(g_utf8_get_char(b))) | |
1589 return FALSE; | |
1590 | |
1591 a = g_utf8_next_char(a); | |
1592 b = g_utf8_next_char(b); | |
1593 } | |
1594 | |
1595 return (*a == '\0' && *b == '\0'); | |
1596 } | |
1597 | |
1598 static void | |
1599 dialog_add_buttons(GtkDialog *dialog, char_u *button_string) | |
1600 { | |
1601 char **ok; | |
1602 char **ync; /* "yes no cancel" */ | |
1603 char **buttons; | |
1604 int n_buttons = 0; | |
944 | 1605 int idx; |
7 | 1606 |
1607 button_string = vim_strsave(button_string); /* must be writable */ | |
1608 if (button_string == NULL) | |
1609 return; | |
1610 | |
1611 /* Check 'v' flag in 'guioptions': vertical button placement. */ | |
1612 if (vim_strchr(p_go, GO_VERTICAL) != NULL) | |
1613 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1614 # 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
|
1615 /* Add GTK+ 3 code if necessary. */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1616 /* N.B. GTK+ 3 doesn't allow you to access vbox and action_area via |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1617 * the C API. */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1618 # else |
7 | 1619 GtkWidget *vbutton_box; |
1620 | |
1621 vbutton_box = gtk_vbutton_box_new(); | |
1622 gtk_widget_show(vbutton_box); | |
1623 gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->vbox), | |
1624 vbutton_box, TRUE, FALSE, 0); | |
1625 /* Overrule the "action_area" value, hopefully this works... */ | |
1626 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
|
1627 # endif |
7 | 1628 } |
1629 | |
1630 /* | |
1631 * Yes this is ugly, I don't particularly like it either. But doing it | |
1632 * this way has the compelling advantage that translations need not to | |
1633 * be touched at all. See below what 'ok' and 'ync' are used for. | |
1634 */ | |
1635 ok = split_button_translation(N_("&Ok")); | |
1636 ync = split_button_translation(N_("&Yes\n&No\n&Cancel")); | |
1637 buttons = split_button_string(button_string, &n_buttons); | |
1638 | |
1639 /* | |
1640 * Yes, the buttons are in reversed order to match the GNOME 2 desktop | |
1641 * environment. Don't hit me -- it's all about consistency. | |
1642 * Well, apparently somebody changed his mind: with GTK 2.2.4 it works the | |
1643 * other way around... | |
1644 */ | |
944 | 1645 for (idx = 1; idx <= n_buttons; ++idx) |
7 | 1646 { |
1647 char *label; | |
1648 char_u *label8; | |
1649 | |
944 | 1650 label = buttons[idx - 1]; |
7 | 1651 /* |
1652 * Perform some guesswork to find appropriate stock items for the | |
1653 * buttons. We have to compare with a sample of the translated | |
1654 * button string to get things right. Yes, this is hackish :/ | |
1655 * | |
1656 * But even the common button labels aren't necessarily translated, | |
1657 * since anyone can create their own dialogs using Vim functions. | |
1658 * Thus we have to check for those too. | |
1659 */ | |
1660 if (ok != NULL && ync != NULL) /* almost impossible to fail */ | |
1661 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1662 # 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
|
1663 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
|
1664 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
|
1665 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
|
1666 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
|
1667 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
|
1668 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
|
1669 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
|
1670 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
|
1671 # else |
7 | 1672 if (button_equal(label, ok[0])) label = GTK_STOCK_OK; |
1673 else if (button_equal(label, ync[0])) label = GTK_STOCK_YES; | |
1674 else if (button_equal(label, ync[1])) label = GTK_STOCK_NO; | |
1675 else if (button_equal(label, ync[2])) label = GTK_STOCK_CANCEL; | |
1676 else if (button_equal(label, "Ok")) label = GTK_STOCK_OK; | |
1677 else if (button_equal(label, "Yes")) label = GTK_STOCK_YES; | |
1678 else if (button_equal(label, "No")) label = GTK_STOCK_NO; | |
1679 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
|
1680 # endif |
7 | 1681 } |
1682 label8 = CONVERT_TO_UTF8((char_u *)label); | |
944 | 1683 gtk_dialog_add_button(dialog, (const gchar *)label8, idx); |
7 | 1684 CONVERT_TO_UTF8_FREE(label8); |
1685 } | |
1686 | |
1687 if (ok != NULL) | |
1688 vim_free(*ok); | |
1689 if (ync != NULL) | |
1690 vim_free(*ync); | |
1691 vim_free(ok); | |
1692 vim_free(ync); | |
1693 vim_free(buttons); | |
1694 vim_free(button_string); | |
1695 } | |
1696 | |
1697 /* | |
1698 * Allow mnemonic accelerators to be activated without pressing <Alt>. | |
1699 * I'm not sure if it's a wise idea to do this. However, the old GTK+ 1.2 | |
1700 * GUI used to work this way, and I consider the impact on UI consistency | |
1701 * low enough to justify implementing this as a special Vim feature. | |
1702 */ | |
1703 typedef struct _DialogInfo | |
1704 { | |
1705 int ignore_enter; /* no default button, ignore "Enter" */ | |
1706 int noalt; /* accept accelerators without Alt */ | |
1707 GtkDialog *dialog; /* Widget of the dialog */ | |
1708 } DialogInfo; | |
1709 | |
1710 static gboolean | |
1711 dialog_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) | |
1712 { | |
1713 DialogInfo *di = (DialogInfo *)data; | |
1714 | |
1355 | 1715 /* Ignore hitting Enter (or Space) when there is no default button. */ |
1716 if (di->ignore_enter && (event->keyval == GDK_Return | |
1717 || event->keyval == ' ')) | |
1718 return TRUE; | |
1719 else /* A different key was pressed, return to normal behavior */ | |
1720 di->ignore_enter = FALSE; | |
1721 | |
7 | 1722 /* Close the dialog when hitting "Esc". */ |
1723 if (event->keyval == GDK_Escape) | |
1724 { | |
1725 gtk_dialog_response(di->dialog, GTK_RESPONSE_REJECT); | |
1726 return TRUE; | |
1727 } | |
1728 | |
1729 if (di->noalt | |
1730 && (event->state & gtk_accelerator_get_default_mod_mask()) == 0) | |
1731 { | |
1732 return gtk_window_mnemonic_activate( | |
1733 GTK_WINDOW(widget), event->keyval, | |
1734 gtk_window_get_mnemonic_modifier(GTK_WINDOW(widget))); | |
1735 } | |
1736 | |
1737 return FALSE; /* continue emission */ | |
1738 } | |
1739 | |
1740 int | |
1741 gui_mch_dialog(int type, /* type of dialog */ | |
1742 char_u *title, /* title of dialog */ | |
1743 char_u *message, /* message text */ | |
1744 char_u *buttons, /* names of buttons */ | |
1745 int def_but, /* default button */ | |
2684 | 1746 char_u *textfield, /* text for textfield or NULL */ |
1747 int ex_cmd UNUSED) | |
7 | 1748 { |
1749 GtkWidget *dialog; | |
1750 GtkWidget *entry = NULL; | |
1751 char_u *text; | |
1752 int response; | |
1753 DialogInfo dialoginfo; | |
1754 | |
1755 dialog = create_message_dialog(type, title, message); | |
1756 dialoginfo.dialog = GTK_DIALOG(dialog); | |
1757 dialog_add_buttons(GTK_DIALOG(dialog), buttons); | |
1758 | |
1759 if (textfield != NULL) | |
1760 { | |
1761 GtkWidget *alignment; | |
1762 | |
1763 entry = gtk_entry_new(); | |
1764 gtk_widget_show(entry); | |
1765 | |
2649 | 1766 /* Make Enter work like pressing OK. */ |
3664 | 1767 gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); |
2649 | 1768 |
7 | 1769 text = CONVERT_TO_UTF8(textfield); |
1770 gtk_entry_set_text(GTK_ENTRY(entry), (const char *)text); | |
1771 CONVERT_TO_UTF8_FREE(text); | |
1772 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1773 # 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
|
1774 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
|
1775 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
|
1776 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
|
1777 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
|
1778 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1779 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
|
1780 # else |
7 | 1781 alignment = gtk_alignment_new((float)0.5, (float)0.5, |
1782 (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
|
1783 # endif |
7 | 1784 gtk_container_add(GTK_CONTAINER(alignment), entry); |
1785 gtk_container_set_border_width(GTK_CONTAINER(alignment), 5); | |
1786 gtk_widget_show(alignment); | |
1787 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1788 # 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
|
1789 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1790 GtkWidget * const vbox |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1791 = 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
|
1792 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
|
1793 alignment, TRUE, FALSE, 0); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1794 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1795 # else |
7 | 1796 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
1797 alignment, TRUE, FALSE, 0); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1798 # endif |
7 | 1799 dialoginfo.noalt = FALSE; |
1800 } | |
1801 else | |
1802 dialoginfo.noalt = TRUE; | |
1803 | |
1804 /* Allow activation of mnemonic accelerators without pressing <Alt> when | |
864 | 1805 * there is no textfield. Handle pressing Esc. */ |
7 | 1806 g_signal_connect(G_OBJECT(dialog), "key_press_event", |
1807 G_CALLBACK(&dialog_key_press_event_cb), &dialoginfo); | |
1808 | |
1809 if (def_but > 0) | |
1810 { | |
1811 gtk_dialog_set_default_response(GTK_DIALOG(dialog), def_but); | |
1812 dialoginfo.ignore_enter = FALSE; | |
1813 } | |
1814 else | |
1815 /* No default button, ignore pressing Enter. */ | |
1816 dialoginfo.ignore_enter = TRUE; | |
1817 | |
1818 /* Show the mouse pointer if it's currently hidden. */ | |
1819 gui_mch_mousehide(FALSE); | |
1820 | |
1821 response = gtk_dialog_run(GTK_DIALOG(dialog)); | |
1822 | |
1823 /* GTK_RESPONSE_NONE means the dialog was programmatically destroyed. */ | |
1824 if (response != GTK_RESPONSE_NONE) | |
1825 { | |
314 | 1826 if (response == GTK_RESPONSE_ACCEPT) /* Enter pressed */ |
1827 response = def_but; | |
7 | 1828 if (textfield != NULL) |
1829 { | |
1830 text = (char_u *)gtk_entry_get_text(GTK_ENTRY(entry)); | |
1831 text = CONVERT_FROM_UTF8(text); | |
1832 | |
419 | 1833 vim_strncpy(textfield, text, IOSIZE - 1); |
7 | 1834 |
1835 CONVERT_FROM_UTF8_FREE(text); | |
1836 } | |
1837 gtk_widget_destroy(dialog); | |
1838 } | |
1839 | |
1840 return response > 0 ? response : 0; | |
1841 } | |
1842 | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2103
diff
changeset
|
1843 #endif /* FEAT_GUI_DIALOG */ |
7 | 1844 |
1845 | |
1846 #if defined(FEAT_MENU) || defined(PROTO) | |
1847 | |
1848 void | |
1849 gui_mch_show_popupmenu(vimmenu_T *menu) | |
1850 { | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2103
diff
changeset
|
1851 # if defined(FEAT_XIM) |
7 | 1852 /* |
1853 * Append a submenu for selecting an input method. This is | |
1854 * currently the only way to switch input methods at runtime. | |
1855 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1856 # if !GTK_CHECK_VERSION(3,10,0) |
7 | 1857 if (xic != NULL && g_object_get_data(G_OBJECT(menu->submenu_id), |
1858 "vim-has-im-menu") == NULL) | |
1859 { | |
1860 GtkWidget *menuitem; | |
1861 GtkWidget *submenu; | |
1862 char_u *name; | |
1863 | |
1864 menuitem = gtk_separator_menu_item_new(); | |
1865 gtk_widget_show(menuitem); | |
1866 gtk_menu_shell_append(GTK_MENU_SHELL(menu->submenu_id), menuitem); | |
1867 | |
1868 name = (char_u *)_("Input _Methods"); | |
1869 name = CONVERT_TO_UTF8(name); | |
1870 menuitem = gtk_menu_item_new_with_mnemonic((const char *)name); | |
1871 CONVERT_TO_UTF8_FREE(name); | |
1872 gtk_widget_show(menuitem); | |
1873 | |
1874 submenu = gtk_menu_new(); | |
1875 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
1876 gtk_menu_shell_append(GTK_MENU_SHELL(menu->submenu_id), menuitem); | |
1877 | |
1878 gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(xic), | |
1879 GTK_MENU_SHELL(submenu)); | |
1880 g_object_set_data(G_OBJECT(menu->submenu_id), | |
1881 "vim-has-im-menu", GINT_TO_POINTER(TRUE)); | |
1882 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1883 # endif |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2103
diff
changeset
|
1884 # endif /* FEAT_XIM */ |
7 | 1885 |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1886 # 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
|
1887 { |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1888 GdkEventButton trigger; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1889 |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1890 /* A pseudo event to have gtk_menu_popup_at_pointer() work. Since the |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1891 * function calculates the popup menu position on the basis of the |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1892 * actual pointer position when it is invoked, the fields x, y, x_root |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1893 * and y_root are set to zero for convenience. */ |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1894 trigger.type = GDK_BUTTON_PRESS; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1895 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
|
1896 trigger.send_event = FALSE; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1897 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
|
1898 trigger.x = 0.0; |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
13184
diff
changeset
|
1899 trigger.y = 0.0; |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1900 trigger.axes = NULL; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1901 trigger.state = 0; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1902 trigger.button = 3; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1903 trigger.device = NULL; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1904 trigger.x_root = 0.0; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1905 trigger.y_root = 0.0; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1906 |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1907 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
|
1908 (GdkEvent *)&trigger); |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1909 } |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1910 #else |
7 | 1911 gtk_menu_popup(GTK_MENU(menu->submenu_id), |
1912 NULL, NULL, | |
1913 (GtkMenuPositionFunc)NULL, NULL, | |
2923 | 1914 3U, gui.event_time); |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1915 #endif |
7 | 1916 } |
1917 | |
401 | 1918 /* Ugly global variable to pass "mouse_pos" flag from gui_make_popup() to |
1919 * popup_menu_position_func(). */ | |
1920 static int popup_mouse_pos; | |
1921 | |
7 | 1922 /* |
1923 * Menu position callback; used by gui_make_popup() to place the menu | |
1924 * at the current text cursor position. | |
1925 * | |
1926 * Note: The push_in output argument seems to affect scrolling of huge | |
1927 * menus that don't fit on the screen. Leave it at the default for now. | |
1928 */ | |
1929 static void | |
1884 | 1930 popup_menu_position_func(GtkMenu *menu UNUSED, |
7 | 1931 gint *x, gint *y, |
1884 | 1932 gboolean *push_in UNUSED, |
1933 gpointer user_data UNUSED) | |
7 | 1934 { |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1935 # 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
|
1936 gdk_window_get_origin(gtk_widget_get_window(gui.drawarea), x, y); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1937 # else |
401 | 1938 gdk_window_get_origin(gui.drawarea->window, x, y); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1939 # endif |
401 | 1940 |
1941 if (popup_mouse_pos) | |
7 | 1942 { |
401 | 1943 int mx, my; |
1944 | |
1945 gui_mch_getmouse(&mx, &my); | |
1946 *x += mx; | |
1947 *y += my; | |
1948 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1949 # 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
|
1950 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
|
1951 gtk_widget_get_window(gui.drawarea) != NULL) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1952 # else |
401 | 1953 else if (curwin != NULL && gui.drawarea != NULL && gui.drawarea->window != NULL) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1954 # endif |
401 | 1955 { |
7 | 1956 /* 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
|
1957 *x += FILL_X(curwin->w_wincol + curwin->w_wcol + 1) + 1; |
7 | 1958 *y += FILL_Y(W_WINROW(curwin) + curwin->w_wrow + 1) + 1; |
1959 } | |
1960 } | |
1961 | |
1962 void | |
401 | 1963 gui_make_popup(char_u *path_name, int mouse_pos) |
7 | 1964 { |
1965 vimmenu_T *menu; | |
1966 | |
401 | 1967 popup_mouse_pos = mouse_pos; |
1968 | |
7 | 1969 menu = gui_find_menu(path_name); |
1970 | |
1971 if (menu != NULL && menu->submenu_id != NULL) | |
1972 { | |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1973 # 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
|
1974 GdkWindow * const win = gtk_widget_get_window(gui.drawarea); |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1975 GdkEventButton trigger; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1976 |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1977 /* A pseudo event to have gtk_menu_popup_at_*() functions work. Since |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1978 * the position where the menu pops up is automatically adjusted by |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1979 * the functions, none of the fields x, y, x_root and y_root has to be |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1980 * set to a specific value here; therefore, they are set to zero for |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1981 * convenience.*/ |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1982 trigger.type = GDK_BUTTON_PRESS; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1983 trigger.window = win; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1984 trigger.send_event = FALSE; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1985 trigger.time = GDK_CURRENT_TIME; |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
13184
diff
changeset
|
1986 trigger.x = 0.0; |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
13184
diff
changeset
|
1987 trigger.y = 0.0; |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1988 trigger.axes = NULL; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1989 trigger.state = 0; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1990 trigger.button = 0; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1991 trigger.device = NULL; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1992 trigger.x_root = 0.0; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1993 trigger.y_root = 0.0; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1994 |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1995 if (mouse_pos) |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1996 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
|
1997 (GdkEvent *)&trigger); |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1998 else |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1999 { |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2000 gint origin_x, origin_y; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2001 GdkRectangle rect = { 0, 0, 0, 0 }; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2002 |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2003 gdk_window_get_origin(win, &origin_x, &origin_y); |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2004 popup_menu_position_func(NULL, &rect.x, &rect.y, NULL, NULL); |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2005 |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2006 rect.x -= origin_x; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2007 rect.y -= origin_y; |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2008 |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2009 gtk_menu_popup_at_rect(GTK_MENU(menu->submenu_id), |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2010 win, |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2011 &rect, |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2012 GDK_GRAVITY_SOUTH_EAST, |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2013 GDK_GRAVITY_NORTH_WEST, |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2014 (GdkEvent *)&trigger); |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2015 } |
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2016 # else |
7 | 2017 gtk_menu_popup(GTK_MENU(menu->submenu_id), |
2018 NULL, NULL, | |
2019 &popup_menu_position_func, NULL, | |
2020 0U, (guint32)GDK_CURRENT_TIME); | |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2021 # endif |
7 | 2022 } |
2023 } | |
2024 | |
2025 #endif /* FEAT_MENU */ | |
2026 | |
2027 | |
2028 /* | |
2029 * We don't create it twice. | |
2030 */ | |
2031 | |
2032 typedef struct _SharedFindReplace | |
2033 { | |
2034 GtkWidget *dialog; /* the main dialog widget */ | |
2035 GtkWidget *wword; /* 'Whole word only' check button */ | |
2036 GtkWidget *mcase; /* 'Match case' check button */ | |
2037 GtkWidget *up; /* search direction 'Up' radio button */ | |
2038 GtkWidget *down; /* search direction 'Down' radio button */ | |
2039 GtkWidget *what; /* 'Find what' entry text widget */ | |
2040 GtkWidget *with; /* 'Replace with' entry text widget */ | |
2041 GtkWidget *find; /* 'Find Next' action button */ | |
2042 GtkWidget *replace; /* 'Replace With' action button */ | |
2043 GtkWidget *all; /* 'Replace All' action button */ | |
2044 } SharedFindReplace; | |
2045 | |
1884 | 2046 static SharedFindReplace find_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; |
2047 static SharedFindReplace repl_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; | |
2048 | |
7 | 2049 static int |
2050 find_key_press_event( | |
1884 | 2051 GtkWidget *widget UNUSED, |
7 | 2052 GdkEventKey *event, |
2053 SharedFindReplace *frdp) | |
2054 { | |
2055 /* If the user is holding one of the key modifiers we will just bail out, | |
2056 * thus preserving the possibility of normal focus traversal. | |
2057 */ | |
2058 if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) | |
2059 return FALSE; | |
2060 | |
2061 /* the Escape key synthesizes a cancellation action */ | |
2062 if (event->keyval == GDK_Escape) | |
2063 { | |
2064 gtk_widget_hide(frdp->dialog); | |
2065 | |
2066 return TRUE; | |
2067 } | |
2068 | |
1215 | 2069 /* It would be delightful if it where possible to do search history |
7 | 2070 * operations on the K_UP and K_DOWN keys here. |
2071 */ | |
2072 | |
2073 return FALSE; | |
2074 } | |
2075 | |
2076 static GtkWidget * | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2077 #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
|
2078 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
|
2079 const char *label) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2080 #else |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2081 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
|
2082 const char *label) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2083 #endif |
7 | 2084 { |
2085 char_u *text; | |
2086 GtkWidget *box; | |
2087 GtkWidget *alignment; | |
2088 GtkWidget *button; | |
2089 | |
2090 text = CONVERT_TO_UTF8((char_u *)label); | |
2091 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2092 #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
|
2093 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
|
2094 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
|
2095 #else |
7 | 2096 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
|
2097 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2098 #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
|
2099 if (stock_id != NULL) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2100 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
|
2101 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
|
2102 FALSE, FALSE, 0); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2103 #endif |
7 | 2104 gtk_box_pack_start(GTK_BOX(box), |
2105 gtk_label_new((const char *)text), | |
2106 FALSE, FALSE, 0); | |
2107 | |
2108 CONVERT_TO_UTF8_FREE(text); | |
2109 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2110 #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
|
2111 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
|
2112 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
|
2113 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
|
2114 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
|
2115 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2116 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
|
2117 #else |
7 | 2118 alignment = gtk_alignment_new((float)0.5, (float)0.5, |
2119 (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
|
2120 #endif |
7 | 2121 gtk_container_add(GTK_CONTAINER(alignment), box); |
2122 gtk_widget_show_all(alignment); | |
2123 | |
2124 button = gtk_button_new(); | |
2125 gtk_container_add(GTK_CONTAINER(button), alignment); | |
2126 | |
2127 return button; | |
2128 } | |
2129 | |
2130 /* | |
2131 * This is currently only used by find_replace_dialog_create(), and | |
2132 * I'd really like to keep it at that. In other words: don't spread | |
2133 * this nasty hack all over the code. Think twice. | |
2134 */ | |
2135 static const char * | |
2136 convert_localized_message(char_u **buffer, const char *message) | |
2137 { | |
2138 if (output_conv.vc_type == CONV_NONE) | |
2139 return message; | |
2140 | |
2141 vim_free(*buffer); | |
2142 *buffer = string_convert(&output_conv, (char_u *)message, NULL); | |
2143 | |
2144 return (const char *)*buffer; | |
2145 } | |
2146 | |
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
|
2147 /* |
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
|
2148 * 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
|
2149 */ |
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
|
2150 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
|
2151 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
|
2152 { |
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
|
2153 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
|
2154 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
|
2155 |
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
|
2156 #if GTK_CHECK_VERSION(2,18,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
|
2157 /* 2.18 introduced a new object GtkEntryBuffer to handle text data for |
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
|
2158 * GtkEntry instead of letting each instance of the latter have its own |
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
|
2159 * storage for that. The code below is almost identical to the |
2ede8acf65dc
patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length()
Christian Brabandt <cb@256bit.org>
parents:
13119
diff
changeset
|
2160 * implementation of gtk_entry_get_text_length() for the versions >= 2.18. |
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
|
2161 */ |
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
|
2162 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
|
2163 #elif GTK_CHECK_VERSION(2,14,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
|
2164 /* 2.14 introduced a new function to avoid memory management bugs which can |
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
|
2165 * happen when gtk_entry_get_text() is used without due care and attention. |
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
|
2166 */ |
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
|
2167 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
|
2168 #else |
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
|
2169 /* gtk_entry_get_text() returns the pointer to the storage allocated |
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
|
2170 * internally by the widget. Accordingly, use the one with great care: |
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 * Don't free it nor modify the contents it points to; call the function |
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 * every time you need the pointer since its value may have been changed |
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 * by the widget. */ |
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 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
|
2175 #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
|
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 |
7 | 2178 static void |
2179 find_replace_dialog_create(char_u *arg, int do_replace) | |
2180 { | |
2181 GtkWidget *hbox; /* main top down box */ | |
2182 GtkWidget *actionarea; | |
2183 GtkWidget *table; | |
2184 GtkWidget *tmp; | |
2185 GtkWidget *vbox; | |
2186 gboolean sensitive; | |
2187 SharedFindReplace *frdp; | |
2188 char_u *entry_text; | |
2189 int wword = FALSE; | |
2190 int mcase = !p_ic; | |
2191 char_u *conv_buffer = NULL; | |
2192 # define CONV(message) convert_localized_message(&conv_buffer, (message)) | |
2193 | |
2194 frdp = (do_replace) ? (&repl_widgets) : (&find_widgets); | |
2195 | |
2196 /* Get the search string to use. */ | |
2197 entry_text = get_find_dialog_text(arg, &wword, &mcase); | |
2198 | |
2199 if (entry_text != NULL && output_conv.vc_type != CONV_NONE) | |
2200 { | |
2201 char_u *old_text = entry_text; | |
2202 entry_text = string_convert(&output_conv, entry_text, NULL); | |
2203 vim_free(old_text); | |
2204 } | |
2205 | |
2206 /* | |
2207 * If the dialog already exists, just raise it. | |
2208 */ | |
2209 if (frdp->dialog) | |
2210 { | |
2211 if (entry_text != NULL) | |
2212 { | |
2213 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
|
2214 #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
|
2215 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
|
2216 (gboolean)wword); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2217 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
|
2218 (gboolean)mcase); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2219 #else |
7 | 2220 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->wword), |
2221 (gboolean)wword); | |
2222 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->mcase), | |
2223 (gboolean)mcase); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2224 #endif |
7 | 2225 } |
2226 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
|
2227 |
729f279fda8d
patch 8.0.1434: GTK: :promtfind does not put focus on text input
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
2228 /* For :promptfind dialog, always give keyboard focus to 'what' entry. |
729f279fda8d
patch 8.0.1434: GTK: :promtfind does not put focus on text input
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
2229 * For :promptrepl dialog, give it to 'with' entry if 'what' has an |
729f279fda8d
patch 8.0.1434: GTK: :promtfind does not put focus on text input
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
2230 * non-empty entry; otherwise, to 'what' entry. */ |
729f279fda8d
patch 8.0.1434: GTK: :promtfind does not put focus on text input
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
2231 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
|
2232 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
|
2233 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
|
2234 |
7 | 2235 vim_free(entry_text); |
2236 return; | |
2237 } | |
2238 | |
2239 frdp->dialog = gtk_dialog_new(); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2240 #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
|
2241 /* Nothing equivalent to gtk_dialog_set_has_separator() in GTK+ 3. */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2242 #else |
7 | 2243 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
|
2244 #endif |
7 | 2245 gtk_window_set_transient_for(GTK_WINDOW(frdp->dialog), GTK_WINDOW(gui.mainwin)); |
2246 gtk_window_set_destroy_with_parent(GTK_WINDOW(frdp->dialog), TRUE); | |
2247 | |
2248 if (do_replace) | |
2249 { | |
2250 gtk_window_set_title(GTK_WINDOW(frdp->dialog), | |
2251 CONV(_("VIM - Search and Replace..."))); | |
2252 } | |
2253 else | |
2254 { | |
2255 gtk_window_set_title(GTK_WINDOW(frdp->dialog), | |
2256 CONV(_("VIM - Search..."))); | |
2257 } | |
2258 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2259 #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
|
2260 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
|
2261 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
|
2262 #else |
7 | 2263 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
|
2264 #endif |
7 | 2265 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
|
2266 #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
|
2267 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2268 GtkWidget * const dialog_vbox |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2269 = 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
|
2270 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
|
2271 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2272 #else |
7 | 2273 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
|
2274 #endif |
7 | 2275 |
2276 if (do_replace) | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2277 #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
|
2278 table = gtk_grid_new(); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2279 #else |
7 | 2280 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
|
2281 #endif |
7 | 2282 else |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2283 #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
|
2284 table = gtk_grid_new(); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2285 #else |
7 | 2286 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
|
2287 #endif |
7 | 2288 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
|
2289 #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
|
2290 gtk_container_set_border_width(GTK_CONTAINER(table), 4); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2291 #else |
7 | 2292 gtk_container_border_width(GTK_CONTAINER(table), 4); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2293 #endif |
7 | 2294 |
2295 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
|
2296 #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
|
2297 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
|
2298 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
|
2299 #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
|
2300 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2301 GValue align_val = G_VALUE_INIT; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2302 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2303 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
|
2304 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2305 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
|
2306 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
|
2307 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2308 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
|
2309 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
|
2310 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2311 g_value_unset(&align_val); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2312 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2313 #else |
7 | 2314 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
|
2315 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2316 #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
|
2317 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
|
2318 #else |
7 | 2319 gtk_table_attach(GTK_TABLE(table), tmp, 0, 1, 0, 1, |
2320 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
|
2321 #endif |
7 | 2322 frdp->what = gtk_entry_new(); |
2323 sensitive = (entry_text != NULL && entry_text[0] != NUL); | |
2324 if (entry_text != NULL) | |
2325 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
|
2326 #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
|
2327 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
|
2328 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
|
2329 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
|
2330 G_CALLBACK(find_key_press_event), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2331 (gpointer) frdp); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2332 #else |
7 | 2333 gtk_signal_connect(GTK_OBJECT(frdp->what), "changed", |
2334 GTK_SIGNAL_FUNC(entry_changed_cb), frdp->dialog); | |
2335 gtk_signal_connect_after(GTK_OBJECT(frdp->what), "key_press_event", | |
2336 GTK_SIGNAL_FUNC(find_key_press_event), | |
2337 (gpointer) frdp); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2338 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2339 #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
|
2340 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
|
2341 #else |
7 | 2342 gtk_table_attach(GTK_TABLE(table), frdp->what, 1, 1024, 0, 1, |
2343 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
|
2344 #endif |
7 | 2345 |
2346 if (do_replace) | |
2347 { | |
2348 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
|
2349 #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
|
2350 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
|
2351 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
|
2352 #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
|
2353 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2354 GValue align_val = G_VALUE_INIT; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2355 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2356 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
|
2357 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2358 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
|
2359 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
|
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.5); |
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), "yalign", &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_unset(&align_val); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2365 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2366 #else |
7 | 2367 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
|
2368 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2369 #if GTK_CHECK_VERSION(3,4,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2370 gtk_grid_attach(GTK_GRID(table), tmp, 0, 1, 2, 1); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2371 #else |
7 | 2372 gtk_table_attach(GTK_TABLE(table), tmp, 0, 1, 1, 2, |
2373 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
|
2374 #endif |
7 | 2375 frdp->with = gtk_entry_new(); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2376 #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
|
2377 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
|
2378 G_CALLBACK(find_replace_cb), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2379 GINT_TO_POINTER(FRD_R_FINDNEXT)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2380 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
|
2381 G_CALLBACK(find_key_press_event), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2382 (gpointer) frdp); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2383 #else |
7 | 2384 gtk_signal_connect(GTK_OBJECT(frdp->with), "activate", |
2385 GTK_SIGNAL_FUNC(find_replace_cb), | |
2386 GINT_TO_POINTER(FRD_R_FINDNEXT)); | |
2387 gtk_signal_connect_after(GTK_OBJECT(frdp->with), "key_press_event", | |
2388 GTK_SIGNAL_FUNC(find_key_press_event), | |
2389 (gpointer) frdp); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2390 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2391 #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
|
2392 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
|
2393 #else |
7 | 2394 gtk_table_attach(GTK_TABLE(table), frdp->with, 1, 1024, 1, 2, |
2395 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
|
2396 #endif |
7 | 2397 |
2398 /* | |
2399 * Make the entry activation only change the input focus onto the | |
2400 * with item. | |
2401 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2402 #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
|
2403 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
|
2404 G_CALLBACK(entry_activate_cb), frdp->with); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2405 #else |
7 | 2406 gtk_signal_connect(GTK_OBJECT(frdp->what), "activate", |
2407 GTK_SIGNAL_FUNC(entry_activate_cb), frdp->with); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2408 #endif |
7 | 2409 } |
2410 else | |
2411 { | |
2412 /* | |
2413 * Make the entry activation do the search. | |
2414 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2415 #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
|
2416 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
|
2417 G_CALLBACK(find_replace_cb), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2418 GINT_TO_POINTER(FRD_FINDNEXT)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2419 #else |
7 | 2420 gtk_signal_connect(GTK_OBJECT(frdp->what), "activate", |
2421 GTK_SIGNAL_FUNC(find_replace_cb), | |
2422 GINT_TO_POINTER(FRD_FINDNEXT)); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2423 #endif |
7 | 2424 } |
2425 | |
2426 /* whole word only button */ | |
2427 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
|
2428 #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
|
2429 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
|
2430 (gboolean)wword); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2431 #else |
7 | 2432 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->wword), |
2433 (gboolean)wword); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2434 #endif |
7 | 2435 if (do_replace) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2436 #if GTK_CHECK_VERSION(3,4,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2437 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
|
2438 #else |
7 | 2439 gtk_table_attach(GTK_TABLE(table), frdp->wword, 0, 1023, 2, 3, |
2440 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
|
2441 #endif |
7 | 2442 else |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2443 #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
|
2444 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
|
2445 #else |
7 | 2446 gtk_table_attach(GTK_TABLE(table), frdp->wword, 0, 1023, 1, 2, |
2447 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
|
2448 #endif |
7 | 2449 |
2450 /* match case button */ | |
2451 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
|
2452 #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
|
2453 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
|
2454 (gboolean)mcase); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2455 #else |
7 | 2456 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->mcase), |
2457 (gboolean)mcase); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2458 #endif |
7 | 2459 if (do_replace) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2460 #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
|
2461 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
|
2462 #else |
7 | 2463 gtk_table_attach(GTK_TABLE(table), frdp->mcase, 0, 1023, 3, 4, |
2464 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
|
2465 #endif |
7 | 2466 else |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2467 #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
|
2468 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
|
2469 #else |
7 | 2470 gtk_table_attach(GTK_TABLE(table), frdp->mcase, 0, 1023, 2, 3, |
2471 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
|
2472 #endif |
7 | 2473 |
2474 tmp = gtk_frame_new(CONV(_("Direction"))); | |
2475 if (do_replace) | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2476 #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
|
2477 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
|
2478 #else |
7 | 2479 gtk_table_attach(GTK_TABLE(table), tmp, 1023, 1024, 2, 4, |
2480 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
|
2481 #endif |
7 | 2482 else |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2483 #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
|
2484 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
|
2485 #else |
7 | 2486 gtk_table_attach(GTK_TABLE(table), tmp, 1023, 1024, 1, 3, |
2487 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
|
2488 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2489 #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
|
2490 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
|
2491 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
|
2492 #else |
7 | 2493 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
|
2494 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2495 #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
|
2496 gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2497 #else |
7 | 2498 gtk_container_border_width(GTK_CONTAINER(vbox), 0); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2499 #endif |
7 | 2500 gtk_container_add(GTK_CONTAINER(tmp), vbox); |
2501 | |
2502 /* 'Up' and 'Down' buttons */ | |
2503 frdp->up = gtk_radio_button_new_with_label(NULL, CONV(_("Up"))); | |
2504 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
|
2505 #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
|
2506 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
|
2507 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
|
2508 CONV(_("Down"))); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2509 #else |
7 | 2510 frdp->down = gtk_radio_button_new_with_label( |
2511 gtk_radio_button_group(GTK_RADIO_BUTTON(frdp->up)), | |
2512 CONV(_("Down"))); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2513 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2514 #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
|
2515 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->down), TRUE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2516 #else |
7 | 2517 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(frdp->down), TRUE); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2518 #endif |
7 | 2519 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2); |
2520 gtk_box_pack_start(GTK_BOX(vbox), frdp->down, TRUE, TRUE, 0); | |
2521 | |
2522 /* 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
|
2523 #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
|
2524 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
|
2525 #else |
7 | 2526 actionarea = gtk_vbutton_box_new(); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2527 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2528 #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
|
2529 gtk_container_set_border_width(GTK_CONTAINER(actionarea), 2); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2530 #else |
7 | 2531 gtk_container_border_width(GTK_CONTAINER(actionarea), 2); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2532 #endif |
7 | 2533 gtk_box_pack_end(GTK_BOX(hbox), actionarea, FALSE, FALSE, 0); |
2534 | |
2535 /* 'Find Next' button */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2536 #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
|
2537 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
|
2538 #else |
7 | 2539 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
|
2540 #endif |
7 | 2541 gtk_widget_set_sensitive(frdp->find, sensitive); |
2542 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2543 #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
|
2544 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
|
2545 G_CALLBACK(find_replace_cb), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2546 (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
|
2547 : GINT_TO_POINTER(FRD_FINDNEXT)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2548 #else |
7 | 2549 gtk_signal_connect(GTK_OBJECT(frdp->find), "clicked", |
2550 GTK_SIGNAL_FUNC(find_replace_cb), | |
2551 (do_replace) ? GINT_TO_POINTER(FRD_R_FINDNEXT) | |
2552 : GINT_TO_POINTER(FRD_FINDNEXT)); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2553 #endif |
7 | 2554 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2555 #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
|
2556 gtk_widget_set_can_default(frdp->find, TRUE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2557 #else |
7 | 2558 GTK_WIDGET_SET_FLAGS(frdp->find, GTK_CAN_DEFAULT); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2559 #endif |
7 | 2560 gtk_box_pack_start(GTK_BOX(actionarea), frdp->find, FALSE, FALSE, 0); |
2561 gtk_widget_grab_default(frdp->find); | |
2562 | |
2563 if (do_replace) | |
2564 { | |
2565 /* 'Replace' button */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2566 #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
|
2567 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
|
2568 #else |
7 | 2569 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
|
2570 #endif |
7 | 2571 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
|
2572 #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
|
2573 gtk_widget_set_can_default(frdp->find, TRUE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2574 #else |
7 | 2575 GTK_WIDGET_SET_FLAGS(frdp->replace, GTK_CAN_DEFAULT); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2576 #endif |
7 | 2577 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
|
2578 #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
|
2579 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
|
2580 G_CALLBACK(find_replace_cb), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2581 GINT_TO_POINTER(FRD_REPLACE)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2582 #else |
7 | 2583 gtk_signal_connect(GTK_OBJECT(frdp->replace), "clicked", |
2584 GTK_SIGNAL_FUNC(find_replace_cb), | |
2585 GINT_TO_POINTER(FRD_REPLACE)); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2586 #endif |
7 | 2587 |
2588 /* 'Replace All' button */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2589 #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
|
2590 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
|
2591 #else |
7 | 2592 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
|
2593 #endif |
7 | 2594 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
|
2595 #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
|
2596 gtk_widget_set_can_default(frdp->all, TRUE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2597 #else |
7 | 2598 GTK_WIDGET_SET_FLAGS(frdp->all, GTK_CAN_DEFAULT); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2599 #endif |
7 | 2600 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
|
2601 #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
|
2602 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
|
2603 G_CALLBACK(find_replace_cb), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2604 GINT_TO_POINTER(FRD_REPLACEALL)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2605 #else |
7 | 2606 gtk_signal_connect(GTK_OBJECT(frdp->all), "clicked", |
2607 GTK_SIGNAL_FUNC(find_replace_cb), | |
2608 GINT_TO_POINTER(FRD_REPLACEALL)); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2609 #endif |
7 | 2610 } |
2611 | |
2612 /* 'Cancel' button */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2613 #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
|
2614 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
|
2615 #else |
7 | 2616 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
|
2617 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2618 #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
|
2619 gtk_widget_set_can_default(tmp, TRUE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2620 #else |
7 | 2621 GTK_WIDGET_SET_FLAGS(tmp, GTK_CAN_DEFAULT); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2622 #endif |
7 | 2623 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
|
2624 #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
|
2625 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
|
2626 "clicked", G_CALLBACK(gtk_widget_hide), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2627 G_OBJECT(frdp->dialog)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2628 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
|
2629 "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
|
2630 G_OBJECT(frdp->dialog)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2631 #else |
7 | 2632 gtk_signal_connect_object(GTK_OBJECT(tmp), |
2633 "clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), | |
2634 GTK_OBJECT(frdp->dialog)); | |
2635 gtk_signal_connect_object(GTK_OBJECT(frdp->dialog), | |
2636 "delete_event", GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete), | |
2637 GTK_OBJECT(frdp->dialog)); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2638 #endif |
7 | 2639 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2640 #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
|
2641 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
|
2642 #else |
7 | 2643 tmp = gtk_vseparator_new(); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2644 #endif |
7 | 2645 gtk_box_pack_end(GTK_BOX(hbox), tmp, FALSE, FALSE, 10); |
2646 | |
2647 /* 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
|
2648 #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
|
2649 # 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
|
2650 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
|
2651 # endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2652 #else |
7 | 2653 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
|
2654 #endif |
7 | 2655 gtk_widget_show_all(hbox); |
2656 gtk_widget_show(frdp->dialog); | |
2657 | |
2658 vim_free(entry_text); | |
2659 vim_free(conv_buffer); | |
2660 #undef CONV | |
2661 } | |
2662 | |
2663 void | |
2664 gui_mch_find_dialog(exarg_T *eap) | |
2665 { | |
2666 if (gui.in_use) | |
2667 find_replace_dialog_create(eap->arg, FALSE); | |
2668 } | |
2669 | |
2670 void | |
2671 gui_mch_replace_dialog(exarg_T *eap) | |
2672 { | |
2673 if (gui.in_use) | |
2674 find_replace_dialog_create(eap->arg, TRUE); | |
2675 } | |
2676 | |
2677 /* | |
2678 * Callback for actions of the find and replace dialogs | |
2679 */ | |
2680 static void | |
1884 | 2681 find_replace_cb(GtkWidget *widget UNUSED, gpointer data) |
7 | 2682 { |
2683 int flags; | |
2684 char_u *find_text; | |
2685 char_u *repl_text; | |
2686 gboolean direction_down; | |
2687 SharedFindReplace *sfr; | |
2688 | |
2689 flags = (int)(long)data; /* avoid a lint warning here */ | |
2690 | |
2691 /* Get the search/replace strings from the dialog */ | |
2692 if (flags == FRD_FINDNEXT) | |
2693 { | |
2694 repl_text = NULL; | |
2695 sfr = &find_widgets; | |
2696 } | |
2697 else | |
2698 { | |
2699 repl_text = (char_u *)gtk_entry_get_text(GTK_ENTRY(repl_widgets.with)); | |
2700 sfr = &repl_widgets; | |
2701 } | |
2702 | |
2703 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
|
2704 #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
|
2705 direction_down = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->down)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2706 #else |
7 | 2707 direction_down = GTK_TOGGLE_BUTTON(sfr->down)->active; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2708 #endif |
7 | 2709 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2710 #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
|
2711 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->wword))) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2712 #else |
7 | 2713 if (GTK_TOGGLE_BUTTON(sfr->wword)->active) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2714 #endif |
7 | 2715 flags |= FRD_WHOLE_WORD; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2716 #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
|
2717 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sfr->mcase))) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2718 #else |
7 | 2719 if (GTK_TOGGLE_BUTTON(sfr->mcase)->active) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2720 #endif |
7 | 2721 flags |= FRD_MATCH_CASE; |
2722 | |
2723 repl_text = CONVERT_FROM_UTF8(repl_text); | |
2724 find_text = CONVERT_FROM_UTF8(find_text); | |
2656 | 2725 gui_do_findrepl(flags, find_text, repl_text, direction_down); |
7 | 2726 CONVERT_FROM_UTF8_FREE(repl_text); |
2727 CONVERT_FROM_UTF8_FREE(find_text); | |
2728 } | |
2729 | |
2730 /* our usual callback function */ | |
2731 static void | |
1884 | 2732 entry_activate_cb(GtkWidget *widget UNUSED, gpointer data) |
7 | 2733 { |
2734 gtk_widget_grab_focus(GTK_WIDGET(data)); | |
2735 } | |
2736 | |
2737 /* | |
2738 * Syncing the find/replace dialogs on the fly is utterly useless crack, | |
2739 * and causes nothing but problems. Please tell me a use case for which | |
2740 * you'd need both a find dialog and a find/replace one at the same time, | |
2741 * without being able to actually use them separately since they're syncing | |
2742 * all the time. I don't think it's worthwhile to fix this nonsense, | |
2743 * particularly evil incarnation of braindeadness, whatever; I'd much rather | |
2744 * see it extinguished from this planet. Thanks for listening. Sorry. | |
2745 */ | |
2746 static void | |
2747 entry_changed_cb(GtkWidget * entry, GtkWidget * dialog) | |
2748 { | |
2749 const gchar *entry_text; | |
2750 gboolean nonempty; | |
2751 | |
2752 entry_text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
2753 | |
2754 if (!entry_text) | |
2755 return; /* shouldn't happen */ | |
2756 | |
2757 nonempty = (entry_text[0] != '\0'); | |
2758 | |
2759 if (dialog == find_widgets.dialog) | |
2760 { | |
2761 gtk_widget_set_sensitive(find_widgets.find, nonempty); | |
2762 } | |
2763 | |
2764 if (dialog == repl_widgets.dialog) | |
2765 { | |
2766 gtk_widget_set_sensitive(repl_widgets.find, nonempty); | |
2767 gtk_widget_set_sensitive(repl_widgets.replace, nonempty); | |
2768 gtk_widget_set_sensitive(repl_widgets.all, nonempty); | |
2769 } | |
2770 } | |
2771 | |
2772 /* | |
2773 * ":helpfind" | |
2774 */ | |
2775 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7380
diff
changeset
|
2776 ex_helpfind(exarg_T *eap UNUSED) |
7 | 2777 { |
2778 /* This will fail when menus are not loaded. Well, it's only for | |
2779 * backwards compatibility anyway. */ | |
2780 do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp"); | |
2781 } | |
3484 | 2782 |
3564 | 2783 #if defined(FEAT_BROWSE) || defined(PROTO) |
3484 | 2784 static void |
2785 recent_func_log_func(const gchar *log_domain UNUSED, | |
2786 GLogLevelFlags log_level UNUSED, | |
2787 const gchar *message UNUSED, | |
2788 gpointer user_data UNUSED) | |
2789 { | |
2790 /* We just want to suppress the warnings. */ | |
2791 /* http://bugzilla.gnome.org/show_bug.cgi?id=664587 */ | |
2792 } | |
3564 | 2793 #endif |