]>
Commit | Line | Data |
---|---|---|
71da7c9d AF |
1 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/Make_container.mak vim/src/Make_container.mak |
2 | --- vimcopy/src/Make_container.mak Wed Dec 31 18:00:00 1969 | |
3 | +++ vim/src/Make_container.mak Fri Mar 21 23:22:33 2003 | |
4 | @@ -0,0 +1,11 @@ | |
5 | +gnomeccFlags = `pkg-config --cflags libgnomeui-2.0 libgnome-2.0` | |
6 | +ccFlags = -g -c ${gnomeccFlags} | |
7 | +ldFlags = `pkg-config --libs libgnomeui-2.0 libgnome-2.0` | |
8 | + | |
9 | +all: container | |
10 | + | |
11 | +container: container.o | |
12 | + gcc -o container ${ldFlags} container.o | |
13 | + | |
14 | +%.o: %.c | |
15 | + gcc ${ccFlags} $< -o $@ | |
16 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/Makefile vim/src/Makefile | |
17 | --- vimcopy/src/Makefile Fri Mar 21 23:08:10 2003 | |
18 | +++ vim/src/Makefile Sat Mar 22 11:07:26 2003 | |
19 | @@ -1268,6 +1268,9 @@ | |
20 | objects/term.o \ | |
21 | objects/ui.o \ | |
22 | objects/undo.o \ | |
23 | + objects/vim_bonobo_main.o \ | |
24 | + objects/vim_bonobo_factory.o \ | |
25 | + objects/vim_bonobo_control.o \ | |
26 | objects/window.o \ | |
27 | $(GUI_OBJ) \ | |
28 | $(PERL_OBJ) \ | |
29 | @@ -1277,7 +1280,7 @@ | |
30 | $(OS_EXTRA_OBJ) \ | |
31 | $(WORKSHOP_OBJ) \ | |
32 | $(NETBEANS_OBJ) \ | |
33 | - $(WSDEBUG_OBJ) | |
34 | + $(WSDEBUG_OBJ) | |
35 | ||
36 | PRO_AUTO = \ | |
37 | buffer.pro \ | |
38 | @@ -2194,6 +2197,15 @@ | |
39 | ||
40 | objects/undo.o: undo.c | |
41 | $(CCC) -o $@ undo.c | |
42 | + | |
43 | +objects/vim_bonobo_control.o: vim_bonobo_control.c | |
44 | + $(CCC) -o $@ vim_bonobo_control.c | |
45 | + | |
46 | +objects/vim_bonobo_factory.o: vim_bonobo_factory.c | |
47 | + $(CCC) -o $@ vim_bonobo_factory.c | |
48 | + | |
49 | +objects/vim_bonobo_main.o: vim_bonobo_main.c | |
50 | + $(CCC) -o $@ vim_bonobo_main.c | |
51 | ||
52 | objects/window.o: window.c | |
53 | $(CCC) -o $@ window.c | |
54 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/Vim_Control.server vim/src/Vim_Control.server | |
55 | --- vimcopy/src/Vim_Control.server Wed Dec 31 18:00:00 1969 | |
56 | +++ vim/src/Vim_Control.server Fri Mar 21 23:22:33 2003 | |
57 | @@ -0,0 +1,34 @@ | |
58 | +<oaf_info> | |
59 | + | |
60 | +<oaf_server iid="OAFIID:Vim_Control_Factory" type="exe" location="/home/jdhildeb/projects/gnome-vim/vim/src/vim"> | |
61 | + <oaf_attribute name="repo_ids" type="stringv"> | |
62 | + <item value="IDL:Bonobo/GenericFactory:1.0"/> | |
63 | + </oaf_attribute> | |
64 | + <oaf_attribute name="name" type="string" value="Vim Control factory"/> | |
65 | + <oaf_attribute name="description" type="string" value="Vim Control factory"/> | |
66 | +</oaf_server> | |
67 | + | |
68 | +<oaf_server iid="OAFIID:Vim_Control" type="factory" | |
69 | + location="OAFIID:Vim_Control_Factory"> | |
70 | + <oaf_attribute name="repo_ids" type="stringv"> | |
71 | + <item value="IDL:Bonobo/Unknown:1.0"/> | |
72 | + <item value="IDL:Bonobo/Control:1.0"/> | |
73 | + <item value="IDL:Bonobo/ItemContainer:1.0"/> | |
74 | + <item value="IDL:Bonobo/PersistStream:1.0"/> | |
75 | + <item value="IDL:Bonobo/PersistFile:1.0"/> | |
76 | + <item value="IDL:Bonobo/Persist:1.0"/> | |
77 | + <item value="IDL:Nautilus/View:1.0"/> | |
78 | + </oaf_attribute> | |
79 | + <oaf_attribute name="name" type="string" value="Vim Control"/> | |
80 | + <oaf_attribute name="description" type="string" value="Vim Control"/> | |
81 | + <oaf_attribute name="bonobo:editable" type="boolean" value="false"/> | |
82 | + <oaf_attribute name="bonobo:supported_mime_types" type="stringv"> | |
83 | + <item value="text/plain"/> | |
84 | + <item value="text/*"/> | |
85 | + </oaf_attribute> | |
86 | + <oaf_attribute name="nautilus:view_as_name" type="string" value="Text"/> | |
87 | + <oaf_attribute name="nautilus:view_as_label" type="string" value="View/Edit in Vim"/> | |
88 | + <oaf_attribute name="nautilus:viewer_label" type="string" value="Vim"/> | |
89 | +</oaf_server> | |
90 | + | |
91 | +</oaf_info> | |
92 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/config.h.in vim/src/config.h.in | |
93 | --- vimcopy/src/config.h.in Fri Mar 21 23:15:56 2003 | |
94 | +++ vim/src/config.h.in Fri Mar 21 23:22:33 2003 | |
95 | @@ -314,6 +314,9 @@ | |
96 | /* Define if GTK+ multihead support is available (requires GTK+ >= 2.1.1). */ | |
97 | #undef HAVE_GTK_MULTIHEAD | |
98 | ||
99 | +/* Define if you want component (i.e. Bonobo) support. */ | |
100 | +#undef FEAT_GUI_COMPONENT | |
101 | + | |
102 | /* Define if your X has own locale library */ | |
103 | #undef X_LOCALE | |
104 | ||
105 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/configure.in vim/src/configure.in | |
106 | --- vimcopy/src/configure.in Fri Mar 21 23:15:56 2003 | |
107 | +++ vim/src/configure.in Fri Mar 21 23:22:33 2003 | |
108 | @@ -1091,9 +1091,9 @@ | |
109 | AC_MSG_CHECKING(for libgnomeui-2.0) | |
110 | if $PKG_CONFIG --exists libgnomeui-2.0; then | |
111 | AC_MSG_RESULT(yes) | |
112 | - GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0` | |
113 | - GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0` | |
114 | - GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0` | |
115 | + GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0 libnautilus` | |
116 | + GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0 libnautilus` | |
117 | + GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0 libnautilus` | |
118 | $1 | |
119 | else | |
120 | AC_MSG_RESULT(not found) | |
121 | @@ -1241,6 +1241,20 @@ | |
122 | AC_DEFINE(FEAT_GUI_GNOME) | |
123 | GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR" | |
124 | GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS" | |
125 | + AC_MSG_CHECKING(whether or not to include bonobo support) | |
126 | + AC_ARG_ENABLE(bonobo, | |
127 | + [ --enable-bonobo If using GNOME, enable bonobo support [default=no]], | |
128 | + , enable_bonobo="no") | |
129 | + if test "x$enable_bonobo" = "xno"; then | |
130 | + AC_MSG_RESULT($enable_bonobo); | |
131 | + else | |
132 | + if test "x$SKIP_BONOBO" != "xYES" -a $gtk_major_version -ge 2; then | |
133 | + AC_MSG_RESULT(yes); | |
134 | + AC_DEFINE(FEAT_GUI_COMPONENT) | |
135 | + else | |
136 | + AC_MSG_RESULT(no (bonobo requires Gnome 2)); | |
137 | + fi | |
138 | + fi | |
139 | fi | |
140 | } | |
141 | fi | |
142 | Binary files vimcopy/src/container and vim/src/container differ | |
143 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/container.c vim/src/container.c | |
144 | --- vimcopy/src/container.c Wed Dec 31 18:00:00 1969 | |
145 | +++ vim/src/container.c Sat Mar 22 15:33:04 2003 | |
146 | @@ -0,0 +1,176 @@ | |
147 | + | |
148 | +#include <bonobo.h> | |
149 | +#include <glib.h> | |
150 | + | |
151 | +BonoboControlFrame *ctrl_frame; | |
152 | +BonoboUIComponent *ui_comp; | |
153 | + | |
154 | +/* vbox */ | |
155 | +GtkWidget *box; | |
156 | +GtkWidget *ctrl_widget; | |
157 | + | |
158 | +char * filename; | |
159 | + | |
160 | +static Bonobo_Control | |
161 | +instantiate_control() | |
162 | +{ | |
163 | + Bonobo_Control control; | |
164 | + Bonobo_PersistFile pfile; | |
165 | + CORBA_Environment ev; | |
166 | + | |
167 | + CORBA_exception_init (&ev); | |
168 | + | |
169 | + /* get control component */ | |
170 | + control = bonobo_get_object ("OAFIID:Vim_Control", | |
171 | + "Bonobo/Control", &ev); | |
172 | + if (BONOBO_EX (&ev) || (control == CORBA_OBJECT_NIL)) | |
173 | + exit(1); | |
174 | + | |
175 | +#if 0 | |
176 | + /* get PersistFile interface */ | |
177 | + pfile = Bonobo_Unknown_queryInterface (control, "IDL:Bonobo/PersistFile:1.0", &ev); | |
178 | + if (BONOBO_EX (&ev) || (pfile == CORBA_OBJECT_NIL)) | |
179 | + exit(1); | |
180 | + | |
181 | + /* load the file */ | |
182 | + Bonobo_PersistFile_load (pfile, filename, &ev); | |
183 | + bonobo_object_release_unref (pfile, NULL); | |
184 | +#endif | |
185 | + return control; | |
186 | +} | |
187 | + | |
188 | +static void | |
189 | +verb_FileNewWindow (BonoboUIComponent *uic, gpointer user_data, const char *cname) | |
190 | +{ | |
191 | + printf("Got New Window!\n"); | |
192 | +} | |
193 | + | |
194 | +static void | |
195 | +verb_DoNothing (BonoboUIComponent *uic, gpointer user_data, const char *cname) | |
196 | +{ | |
197 | +} | |
198 | + | |
199 | +static BonoboUIVerb app_verbs[] = { | |
200 | + BONOBO_UI_VERB ("FileNewWindow", verb_FileNewWindow), | |
201 | + BONOBO_UI_VERB ("FileOpen", verb_DoNothing), | |
202 | + BONOBO_UI_VERB ("FileCloseWindow", verb_DoNothing), | |
203 | + BONOBO_UI_VERB ("FileExit", verb_DoNothing), | |
204 | + BONOBO_UI_VERB ("Preferences", verb_DoNothing), | |
205 | + BONOBO_UI_VERB ("HelpAbout", verb_DoNothing), | |
206 | + BONOBO_UI_VERB ("Help", verb_DoNothing), | |
207 | + BONOBO_UI_VERB ("DnDNewWindow", verb_DoNothing), | |
208 | + BONOBO_UI_VERB ("DnDSameWindow", verb_DoNothing), | |
209 | + BONOBO_UI_VERB ("DnDCancel", verb_DoNothing), | |
210 | + BONOBO_UI_VERB_END | |
211 | +}; | |
212 | + | |
213 | +static void | |
214 | +add_control_to_ui (BonoboWindow *window, Bonobo_Control control) | |
215 | +{ | |
216 | + CORBA_Environment ev; | |
217 | + Bonobo_PropertyControl prop_control; | |
218 | + BonoboUIContainer *ui_container; | |
219 | + char *curdir; | |
220 | + | |
221 | + g_return_if_fail (window != NULL); | |
222 | + g_return_if_fail (BONOBO_IS_WINDOW (window)); | |
223 | + | |
224 | + CORBA_exception_init (&ev); | |
225 | + | |
226 | + ui_container = bonobo_window_get_ui_container (BONOBO_WINDOW (window)); | |
227 | + ctrl_frame = bonobo_control_frame_new (BONOBO_OBJREF (ui_container)); | |
228 | + | |
229 | + /* bind and view new control widget */ | |
230 | + bonobo_control_frame_bind_to_control (ctrl_frame, control, &ev); | |
231 | + bonobo_control_frame_control_activate (ctrl_frame); | |
232 | + if (control != CORBA_OBJECT_NIL && ctrl_widget == NULL) { | |
233 | + ctrl_widget = bonobo_control_frame_get_widget (ctrl_frame); | |
234 | + if (!ctrl_widget) | |
235 | + g_assert_not_reached (); | |
236 | + | |
237 | + bonobo_window_set_contents (BONOBO_WINDOW(window), GTK_WIDGET(ctrl_widget)); | |
238 | + gtk_widget_show (ctrl_widget); | |
239 | + } | |
240 | + | |
241 | + ui_comp = bonobo_ui_component_new ("vim-container"); | |
242 | + bonobo_ui_component_set_container (ui_comp, BONOBO_OBJREF (ui_container), NULL); | |
243 | + | |
244 | + curdir = (char *)getcwd(NULL, 0); | |
245 | + bonobo_ui_util_set_ui (ui_comp, curdir, "vim-container.xml", "Vim", NULL); | |
246 | + free( curdir ); | |
247 | + bonobo_ui_component_add_verb_list_with_data (ui_comp, app_verbs, window); | |
248 | + | |
249 | + /* update sensitivity of the properties menu item */ | |
250 | + prop_control = Bonobo_Unknown_queryInterface (control, | |
251 | + "IDL:Bonobo/PropertyControl:1.0", &ev); | |
252 | + bonobo_ui_component_set_prop (ui_comp, | |
253 | + "/commands/Preferences", | |
254 | + "sensitive", | |
255 | + prop_control == CORBA_OBJECT_NIL ? "0" : "1", | |
256 | + &ev); | |
257 | + | |
258 | + bonobo_object_release_unref (prop_control, &ev); | |
259 | + | |
260 | + /* enable view menu */ | |
261 | + /* FIXME: We should check if the component adds anything to | |
262 | + * the menu, so that we don't view an empty menu. | |
263 | + */ | |
264 | + /*bonobo_ui_component_set_prop (ui_comp, "/menu/View", "hidden", "0", &ev);*/ | |
265 | + | |
266 | + CORBA_exception_free (&ev); | |
267 | + | |
268 | + /* retrieve control properties and install listeners */ | |
269 | + //check_for_control_properties (window); | |
270 | +} | |
271 | + | |
272 | +static void | |
273 | +window_destroyed (GtkWindow *window, char * data) | |
274 | +{ | |
275 | + Bonobo_Control control; | |
276 | + bonobo_control_frame_control_deactivate(ctrl_frame); | |
277 | + control = bonobo_control_frame_get_control(ctrl_frame); | |
278 | + bonobo_object_release_unref( control, NULL ); | |
279 | + bonobo_main_quit(); | |
280 | +} | |
281 | + | |
282 | +int main(int argc, char * argv[] ) | |
283 | +{ | |
284 | + BonoboWidget * bw; | |
285 | + BonoboWindow *window; | |
286 | + BonoboUIEngine *engine; | |
287 | + BonoboUIContainer *container; | |
288 | + Bonobo_Control control; | |
289 | + | |
290 | +#if 0 | |
291 | + if( argc <= 1 ) { | |
292 | + fprintf(stderr, "%s: not enough args\n", argv[0] ); | |
293 | + fprintf(stderr, "Usage: %s <image file>\n", argv[0]); | |
294 | + exit(1); | |
295 | + } | |
296 | + image_file = argv[1]; | |
297 | +#endif | |
298 | + | |
299 | + bonobo_ui_init ("container", "1.0", &argc, argv); | |
300 | + | |
301 | + if(gnome_vfs_init () == FALSE) | |
302 | + g_error (_("Could not initialize GnomeVFS!\n")); | |
303 | + | |
304 | + window = BONOBO_WINDOW ( bonobo_window_new ("Window", "Vim Test Container")); | |
305 | + | |
306 | + // instantiate a control | |
307 | + control = instantiate_control(); | |
308 | + | |
309 | + // put it into our window | |
310 | + add_control_to_ui (window, control); | |
311 | + | |
312 | + g_signal_connect (window, "destroy", | |
313 | + G_CALLBACK (window_destroyed), | |
314 | + &window); | |
315 | + | |
316 | + | |
317 | + gtk_widget_show_all( GTK_WIDGET( window )); | |
318 | + | |
319 | + bonobo_main(); | |
320 | + | |
321 | + return 0; | |
322 | +} | |
323 | Binary files vimcopy/src/container.o and vim/src/container.o differ | |
324 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/ex_docmd.c vim/src/ex_docmd.c | |
325 | --- vimcopy/src/ex_docmd.c Fri Mar 21 23:05:42 2003 | |
326 | +++ vim/src/ex_docmd.c Fri Mar 21 23:22:33 2003 | |
327 | @@ -4974,8 +4974,13 @@ | |
328 | } | |
329 | else | |
330 | { | |
331 | +#ifdef FEAT_GUI_COMPONENT | |
332 | + EMSG(_("E462: Quit not allowed from embedded component")); | |
333 | + not_exiting(); | |
334 | + return; | |
335 | +#endif | |
336 | #ifdef FEAT_WINDOWS | |
337 | - if (only_one_window()) /* quit last window */ | |
338 | + if (only_one_window()) /* quit last window */ | |
339 | #endif | |
340 | getout(0); | |
341 | #ifdef FEAT_WINDOWS | |
342 | @@ -4996,8 +5001,12 @@ | |
343 | ex_cquit(eap) | |
344 | exarg_T *eap; | |
345 | { | |
346 | +#ifdef FEAT_GUI_COMPONENT | |
347 | + EMSG(_("E462: Quit not allowed from embedded component")); | |
348 | + return; | |
349 | +#endif | |
350 | getout(1); /* this does not always pass on the exit code to the Manx | |
351 | - compiler. why? */ | |
352 | + compiler. why? */ | |
353 | } | |
354 | ||
355 | /* | |
356 | @@ -5017,6 +5026,10 @@ | |
357 | return; | |
358 | } | |
359 | # endif | |
360 | +#ifdef FEAT_GUI_COMPONENT | |
361 | + EMSG(_("E462: Quit not allowed from embedded component")); | |
362 | + return; | |
363 | +#endif | |
364 | exiting = TRUE; | |
365 | if (eap->forceit || !check_changed_any(FALSE)) | |
366 | getout(0); | |
367 | @@ -5211,8 +5224,13 @@ | |
368 | } | |
369 | else | |
370 | { | |
371 | +#ifdef FEAT_GUI_COMPONENT | |
372 | + EMSG(_("E462: Quit not allowed from embedded component")); | |
373 | + not_exiting(); | |
374 | + return; | |
375 | +#endif | |
376 | #ifdef FEAT_WINDOWS | |
377 | - if (only_one_window()) /* quit last window, exit Vim */ | |
378 | + if ( only_one_window()) /* quit last window, exit Vim */ | |
379 | #endif | |
380 | getout(0); | |
381 | #ifdef FEAT_WINDOWS | |
382 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/gui.c vim/src/gui.c | |
383 | --- vimcopy/src/gui.c Fri Mar 21 23:15:57 2003 | |
384 | +++ vim/src/gui.c Fri Mar 21 23:22:33 2003 | |
385 | @@ -433,8 +433,12 @@ | |
386 | * Create the GUI shell. | |
387 | */ | |
388 | gui.in_use = TRUE; /* Must be set after menus have been set up */ | |
389 | +#ifdef FEAT_GUI_COMPONENT | |
390 | + vim_bonobo_wait_for_instantiation(); | |
391 | +#else | |
392 | if (gui_mch_init() == FAIL) | |
393 | goto error; | |
394 | +#endif | |
395 | ||
396 | /* Avoid a delay for an error message that was printed in the terminal | |
397 | * where Vim was started. */ | |
398 | @@ -4022,8 +4026,8 @@ | |
399 | ||
400 | #ifdef FEAT_GUI_GTK | |
401 | /* Need to wake up the main loop */ | |
402 | - if (gtk_main_level() > 0) | |
403 | - gtk_main_quit(); | |
404 | + if (MAIN_LEVEL() > 0) | |
405 | + MAIN_QUIT(); | |
406 | #endif | |
407 | } | |
408 | } | |
409 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/gui.h vim/src/gui.h | |
410 | --- vimcopy/src/gui.h Fri Mar 21 23:15:57 2003 | |
411 | +++ vim/src/gui.h Fri Mar 21 23:30:43 2003 | |
412 | @@ -35,6 +35,21 @@ | |
413 | # include <gtk/gtk.h> | |
414 | #endif | |
415 | ||
416 | +# if defined(FEAT_GUI_GNOME) && defined(FEAT_GUI_COMPONENT) | |
417 | + #include "libbonoboui.h" | |
418 | + #include "vim_bonobo_main.h" | |
419 | + #include "vim_bonobo_factory.h" | |
420 | + #define MAIN vim_bonobo_main | |
421 | + #define MAIN_LEVEL vim_bonobo_main_level | |
422 | + #define MAIN_QUIT vim_bonobo_main_quit | |
423 | + #define MAIN_ITERATION_DO vim_bonobo_main_iteration_do | |
424 | +# else | |
425 | + #define MAIN gtk_main | |
426 | + #define MAIN_LEVEL gtk_main_level | |
427 | + #define MAIN_QUIT gtk_main_quit | |
428 | + #define MAIN_ITERATION_DO gtk_main_iteration_do | |
429 | +#endif | |
430 | + | |
431 | #ifdef FEAT_GUI_BEOS | |
432 | # include "gui_beos.h" | |
433 | #endif | |
434 | @@ -391,6 +406,10 @@ | |
435 | GtkWidget *toolbar; /* toolbar */ | |
436 | # endif | |
437 | # ifdef FEAT_GUI_GNOME | |
438 | +# ifdef FEAT_GUI_COMPONENT | |
439 | + GtkVBox *vbox; | |
440 | + BonoboControl *control; | |
441 | +# endif | |
442 | GtkWidget *menubar_h; /* menubar handle */ | |
443 | GtkWidget *toolbar_h; /* toolbar handle */ | |
444 | # endif | |
445 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/gui_gtk.c vim/src/gui_gtk.c | |
446 | --- vimcopy/src/gui_gtk.c Fri Mar 21 23:15:57 2003 | |
447 | +++ vim/src/gui_gtk.c Fri Mar 21 23:22:33 2003 | |
448 | @@ -37,7 +37,7 @@ | |
449 | ||
450 | #include "vim.h" | |
451 | ||
452 | -#ifdef FEAT_GUI_GNOME | |
453 | +#if 0 | |
454 | /* Gnome redefines _() and N_(). Grrr... */ | |
455 | # ifdef _ | |
456 | # undef _ | |
457 | @@ -414,6 +414,7 @@ | |
458 | char_u *actext; | |
459 | int use_mnemonic; | |
460 | ||
461 | + | |
462 | /* It would be neat to have image menu items, but that requires major | |
463 | * changes to Vim's menu system. Not to mention that all the translations | |
464 | * had to be updated. */ | |
465 | @@ -570,12 +571,307 @@ | |
466 | ||
467 | # endif /* !HAVE_GTK2 */ | |
468 | ||
469 | +#ifdef FEAT_GUI_COMPONENT | |
470 | + | |
471 | + | |
472 | +static void | |
473 | +verb_activate( BonoboUIComponent *uic, gpointer data, const char *cname ) | |
474 | +{ | |
475 | + gui_menu_cb((vimmenu_T *) data); | |
476 | + | |
477 | + /* make sure the menu action is taken immediately */ | |
478 | + if (MAIN_LEVEL() > 0) | |
479 | + MAIN_QUIT(); | |
480 | +} | |
481 | + | |
482 | +static void g_string_append_normalized_name( GString * dest, char_u * name ) | |
483 | +{ | |
484 | + gchar * cur; | |
485 | + | |
486 | + if( name == NULL ) | |
487 | + { | |
488 | + return; | |
489 | + } | |
490 | + cur = name; | |
491 | + while( *cur != '\0' ) { | |
492 | + gunichar wc; | |
493 | + wc = g_utf8_get_char(cur); | |
494 | + if( g_unichar_isalnum( wc ) ) { | |
495 | + g_string_append_unichar( dest, wc ); | |
496 | + } | |
497 | + cur = g_utf8_next_char(cur); | |
498 | + } | |
499 | +} | |
500 | + | |
501 | +static | |
502 | +char * menu_xml_path( vimmenu_T * menu, int only_parent ) | |
503 | +{ | |
504 | + GString * normname; | |
505 | + GString * path; | |
506 | + char * retpath; | |
507 | + | |
508 | + normname = g_string_sized_new( 64 ); | |
509 | + path = g_string_sized_new( 128 ); | |
510 | + while( 1 ) { | |
511 | + if( menu_is_toolbar(menu->name) ) { | |
512 | + /* "Toolbar" is a standard Bonobo UI element, but Vim uses "ToolBar", so we | |
513 | + * have to check for this. */ | |
514 | + g_string_prepend( path, "/Toolbar"); | |
515 | + } else { | |
516 | + g_string_assign( normname, "" ); | |
517 | + g_string_append_normalized_name( normname, menu->dname ); | |
518 | + g_string_prepend( path, normname->str ); | |
519 | + g_string_prepend( path, "/" ); | |
520 | + } | |
521 | + if( menu->parent == NULL ) { | |
522 | + if( menu && menu_is_menubar( menu->name ) ) { | |
523 | + g_string_prepend( path, "/menu" ); | |
524 | + } | |
525 | + break; | |
526 | + } | |
527 | + menu = menu->parent; | |
528 | + } | |
529 | + g_string_free( normname, TRUE ); | |
530 | + retpath = path->str; | |
531 | + g_string_free( path, FALSE ); | |
532 | + | |
533 | + if( only_parent ) { | |
534 | + gchar * slash; | |
535 | + slash = g_strrstr(retpath, "/"); | |
536 | + if( slash == retpath ) | |
537 | + slash[1] = '\0'; | |
538 | + else if( slash ) | |
539 | + *slash = '\0'; | |
540 | + } | |
541 | + return( retpath ); | |
542 | +} | |
543 | + | |
544 | +static char * | |
545 | +gtk_image_to_xml_attrs( GtkImage * image) | |
546 | +{ | |
547 | + GString * xml = g_string_sized_new(32); | |
548 | + GtkImageType type = gtk_image_get_storage_type(image); | |
549 | + char * attrs; | |
550 | + char * imagexml; | |
551 | + | |
552 | + if( type == GTK_IMAGE_STOCK ) { | |
553 | + GtkIconSize size; | |
554 | + GtkIconSet * iconset; | |
555 | + gchar * stockname; | |
556 | + GdkPixbuf * pixbuf; | |
557 | + | |
558 | + gtk_image_get_stock(image, &stockname, &size); | |
559 | + pixbuf = gtk_widget_render_icon(gui.drawarea, stockname, size, NULL); | |
560 | + imagexml = bonobo_ui_util_pixbuf_to_xml(pixbuf); | |
561 | + g_string_append_printf(xml, " pixtype=\"pixbuf\" pixname=\"%s\"", imagexml); | |
562 | + g_object_unref(pixbuf); | |
563 | + g_free(imagexml); | |
564 | + } else if( type == GTK_IMAGE_PIXBUF ) { | |
565 | + imagexml = bonobo_ui_util_pixbuf_to_xml(gtk_image_get_pixbuf(image)); | |
566 | + g_string_append_printf(xml, " pixtype=\"pixbuf\" pixname=\"%s\"", imagexml); | |
567 | + g_free(imagexml); | |
568 | + } | |
569 | + attrs = xml->str; | |
570 | + g_string_free(xml, FALSE); | |
571 | + return( attrs ); | |
572 | +} | |
573 | + | |
574 | +static | |
575 | +void generate_gui_xml_recurse( vimmenu_T * menu, GString * xml, GSList ** commands, int do_siblings) | |
576 | +{ | |
577 | + GString * normname = g_string_sized_new(16); | |
578 | + GString * verbname = g_string_sized_new(32); | |
579 | + char_u * label; | |
580 | + int use_mnemonic; | |
581 | + BonoboUIComponent *uic; | |
582 | + gchar * command; | |
583 | + | |
584 | + uic = bonobo_control_get_ui_component (BONOBO_CONTROL (gui.control)); | |
585 | + | |
586 | + while( menu ) | |
587 | + { | |
588 | + use_mnemonic = (p_wak[0] != 'n' ); | |
589 | + label = translate_mnemonic_tag( menu->name, use_mnemonic ); | |
590 | + g_string_assign( normname, "" ); | |
591 | + g_string_append_normalized_name( normname, menu->dname ); | |
592 | + if( menu->children ) { | |
593 | + if( menu_is_toolbar( menu->name )) { | |
594 | + g_string_append( xml, "<dockitem name=\"Toolbar\" look=\"icon\" tips=\"1\">"); | |
595 | + generate_gui_xml_recurse( menu->children, xml, commands, TRUE ); | |
596 | + g_string_append( xml, "</dockitem>"); | |
597 | + } else { | |
598 | + g_string_append_printf( xml, "<submenu name=\"%s\" label=\"%s\">\n", normname->str, label); | |
599 | + | |
600 | + generate_gui_xml_recurse( menu->children, xml, commands, TRUE ); | |
601 | + g_string_append( xml, "</submenu>\n"); | |
602 | + } | |
603 | + } else if( menu_is_separator(menu->name)) { | |
604 | + g_string_append( xml, "<separator />\n" ); | |
605 | + } else if( menu->parent && menu_is_toolbar(menu->parent->name)) { | |
606 | + char * menupath = menu_xml_path(menu, FALSE); | |
607 | + GtkImage *image = NULL; | |
608 | + char * imagexml; | |
609 | + char_u *tooltip; | |
610 | + | |
611 | + g_string_assign(verbname, ""); | |
612 | + g_string_append_normalized_name(verbname, menupath); | |
613 | + vim_free(menupath); | |
614 | + image = GTK_IMAGE(create_menu_icon(menu, GTK_ICON_SIZE_SMALL_TOOLBAR)); | |
615 | + imagexml = gtk_image_to_xml_attrs(image); | |
616 | + tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); | |
617 | + g_string_append_printf( xml, "<toolitem name=\"%s\" label=\"%s\" verb=\"%s\" tip=\"%s\" %s />\n", normname->str, label, verbname->str, tooltip, imagexml); | |
618 | + gtk_object_sink(GTK_OBJECT(image)); | |
619 | + g_free(imagexml); | |
620 | + CONVERT_TO_UTF8_FREE(tooltip); | |
621 | + | |
622 | + command = g_strdup_printf( "<cmd name=\"%s\" sensitive=\"%c\" />\n", verbname->str, menu->sensitive ? '1' : '0'); | |
623 | + *commands = g_slist_prepend( *commands, command ); | |
624 | + bonobo_ui_component_add_verb(uic, verbname->str, verb_activate, menu); | |
625 | + } else if( menu_is_menubar(menu->name)) { | |
626 | + char * menupath = menu_xml_path(menu, FALSE); | |
627 | + | |
628 | + g_string_assign(verbname, ""); | |
629 | + g_string_append_normalized_name(verbname, menupath); | |
630 | + vim_free(menupath); | |
631 | + | |
632 | + g_string_append_printf( xml, "<menuitem name=\"%s\" label=\"%s\" verb=\"%s\" />\n", normname->str, label, verbname->str); | |
633 | + | |
634 | + command = g_strdup_printf( "<cmd name=\"%s\" sensitive=\"%c\" />\n", verbname->str, menu->sensitive ? '1' : '0'); | |
635 | + *commands = g_slist_prepend( *commands, command ); | |
636 | + bonobo_ui_component_add_verb(uic, verbname->str, verb_activate, menu); | |
637 | + } | |
638 | + if( label ) { | |
639 | + vim_free( label ); | |
640 | + } | |
641 | + if( do_siblings ) { | |
642 | + menu = menu->next; | |
643 | + } else { | |
644 | + menu = NULL; | |
645 | + } | |
646 | + } | |
647 | + g_string_free( normname, TRUE ); | |
648 | +} | |
649 | + | |
650 | +static | |
651 | +void set_gui_xml(vimmenu_T * menu) | |
652 | +{ | |
653 | + GSList * commands = NULL; | |
654 | + GSList * command; | |
655 | + BonoboUIComponent *uic; | |
656 | + GString * xml = g_string_sized_new(1024); | |
657 | + int path_exists; | |
658 | + uic = bonobo_control_get_ui_component (BONOBO_CONTROL (gui.control)); | |
659 | + | |
660 | + if( bonobo_ui_component_get_container(uic) == CORBA_OBJECT_NIL ) { | |
661 | + return; | |
662 | + } | |
663 | + | |
664 | + while( menu ) { | |
665 | + if( menu->dirty ) { | |
666 | + if (menu_is_popup(menu->name)) { | |
667 | + /* do nothing */ | |
668 | + } else if( menu_is_menubar(menu->name)) { | |
669 | + char * menupath = menu_xml_path(menu, TRUE); | |
670 | + path_exists = bonobo_ui_component_path_exists(uic, menupath, NULL); | |
671 | + g_string_assign(xml, ""); | |
672 | + generate_gui_xml_recurse (menu, xml, &commands, FALSE); | |
673 | + /*fprintf(stdout, "set %s\n", menupath);*/ | |
674 | + /*fprintf(stdout, "set %s\n%s", menupath, xml->str);*/ | |
675 | + /*fflush(stdout);*/ | |
676 | + bonobo_ui_component_set(uic, menupath, xml->str, NULL); | |
677 | + g_free(menupath); | |
678 | + } else if( menu_is_toolbar(menu->name)) { | |
679 | + char * menupath = menu_xml_path(menu, TRUE); | |
680 | + path_exists = bonobo_ui_component_path_exists(uic, menupath, NULL); | |
681 | + g_string_assign(xml, ""); | |
682 | + generate_gui_xml_recurse (menu, xml, &commands, FALSE); | |
683 | + /*fprintf(stdout, "set %s\n", menupath);*/ | |
684 | + /*fprintf(stdout, "set %s\n%s", menupath, xml->str);*/ | |
685 | + /*fflush(stdout);*/ | |
686 | + bonobo_ui_component_set(uic, menupath, xml->str, NULL); | |
687 | + g_free(menupath); | |
688 | + } | |
689 | + menu->dirty = FALSE; | |
690 | + } | |
691 | + menu = menu->next; | |
692 | + } | |
693 | + /* the commands are inserted separately into a list, and set one by one, | |
694 | + * otherwise it's not possible to update a subtree of the UI | |
695 | + */ | |
696 | + command = commands; | |
697 | + while( command ) { | |
698 | + /*fprintf(stdout, "set %s\n%s", "/commands", command->data); | |
699 | + fflush(stdout);*/ | |
700 | + bonobo_ui_component_set(uic, "/commands", command->data, NULL); | |
701 | + g_free(command->data); | |
702 | + command = command->next; | |
703 | + } | |
704 | + g_slist_free( commands ); | |
705 | +} | |
706 | + | |
707 | +static gboolean update_gui_idle_installed = FALSE; | |
708 | + | |
709 | +static gboolean | |
710 | +update_gui_idle(gpointer data) | |
711 | +{ | |
712 | + BonoboUIComponent *uic; | |
713 | + | |
714 | + uic = bonobo_control_get_ui_component (BONOBO_CONTROL (gui.control)); | |
715 | + if( bonobo_ui_component_get_container(uic) == CORBA_OBJECT_NIL ) { | |
716 | + /* we aren't in a container yet; try again later... */ | |
717 | + g_timeout_add(100, &update_gui_idle, NULL); | |
718 | + return FALSE; | |
719 | + } | |
720 | + bonobo_ui_component_freeze(uic, NULL); | |
721 | + set_gui_xml( (vimmenu_T *)root_menu ); | |
722 | + update_gui_idle_installed = FALSE; | |
723 | + bonobo_ui_component_thaw(uic, NULL); | |
724 | + return FALSE; /* don't call me again */ | |
725 | +} | |
726 | + | |
727 | +void | |
728 | +update_menu_later(vimmenu_T *menu) | |
729 | +{ | |
730 | + if (!update_gui_idle_installed) | |
731 | + { | |
732 | + update_gui_idle_installed = TRUE; | |
733 | + g_idle_add_full(GDK_PRIORITY_EVENTS + 10, | |
734 | + &update_gui_idle, NULL, NULL); | |
735 | + } | |
736 | + while( menu->parent ) | |
737 | + menu = menu->parent; | |
738 | + menu->dirty = TRUE; | |
739 | +} | |
740 | + | |
741 | +void update_ui_later() | |
742 | +{ | |
743 | + vimmenu_T *menu = root_menu; | |
744 | + | |
745 | + if (!update_gui_idle_installed) | |
746 | + { | |
747 | + update_gui_idle_installed = TRUE; | |
748 | + g_idle_add_full(GDK_PRIORITY_EVENTS + 10, | |
749 | + &update_gui_idle, NULL, NULL); | |
750 | + } | |
751 | + while( menu ) { | |
752 | + menu->dirty = TRUE; | |
753 | + menu = menu->next; | |
754 | + } | |
755 | +} | |
756 | +#endif | |
757 | + | |
758 | + | |
759 | /*ARGSUSED*/ | |
760 | void | |
761 | gui_mch_add_menu(vimmenu_T *menu, int idx) | |
762 | { | |
763 | +#ifdef FEAT_GUI_COMPONENT | |
764 | + update_menu_later(menu); | |
765 | + return; | |
766 | +#else | |
767 | vimmenu_T *parent = menu->parent; | |
768 | ||
769 | + | |
770 | if (menu_is_popup(menu->name)) | |
771 | { | |
772 | menu->submenu_id = gtk_menu_new(); | |
773 | @@ -626,6 +922,7 @@ | |
774 | if (vim_strchr(p_go, GO_TEAROFF) != NULL) | |
775 | gtk_widget_show(menu->tearoff_handle); | |
776 | gtk_menu_prepend(GTK_MENU(menu->submenu_id), menu->tearoff_handle); | |
777 | +#endif | |
778 | } | |
779 | ||
780 | /*ARGSUSED*/ | |
781 | @@ -635,8 +932,8 @@ | |
782 | gui_menu_cb((vimmenu_T *) data); | |
783 | ||
784 | /* make sure the menu action is taken immediately */ | |
785 | - if (gtk_main_level() > 0) | |
786 | - gtk_main_quit(); | |
787 | + if (MAIN_LEVEL() > 0) | |
788 | + MAIN_QUIT(); | |
789 | } | |
790 | ||
791 | # if defined(FEAT_TOOLBAR) && !defined(HAVE_GTK2) | |
792 | @@ -742,6 +1039,10 @@ | |
793 | void | |
794 | gui_mch_add_menu_item(vimmenu_T *menu, int idx) | |
795 | { | |
796 | +#ifdef FEAT_GUI_COMPONENT | |
797 | + update_menu_later(menu); | |
798 | + return; | |
799 | +#else | |
800 | vimmenu_T *parent; | |
801 | ||
802 | parent = menu->parent; | |
803 | @@ -844,6 +1145,7 @@ | |
804 | gtk_signal_connect(GTK_OBJECT(menu->id), "activate", | |
805 | GTK_SIGNAL_FUNC(menu_item_activate), menu); | |
806 | } | |
807 | +#endif | |
808 | } | |
809 | #endif /* FEAT_MENU */ | |
810 | ||
811 | @@ -867,6 +1169,10 @@ | |
812 | vimmenu_T *menu; | |
813 | char_u *name; | |
814 | ||
815 | +#ifdef FEAT_GUI_COMPONENT | |
816 | + return; | |
817 | +#endif | |
818 | + | |
819 | for (menu = root_menu; menu != NULL; menu = menu->next) | |
820 | { | |
821 | if (menu->id == NULL) | |
822 | @@ -981,6 +1287,9 @@ | |
823 | void | |
824 | gui_mch_toggle_tearoffs(int enable) | |
825 | { | |
826 | +#ifdef FEAT_GUI_COMPONENT | |
827 | + return; | |
828 | +#endif | |
829 | recurse_tearoffs(root_menu, enable); | |
830 | } | |
831 | #endif /* FEAT_MENU */ | |
832 | @@ -1055,6 +1364,9 @@ | |
833 | void | |
834 | gui_mch_menu_set_tip(vimmenu_T *menu) | |
835 | { | |
836 | +#ifdef FEAT_GUI_COMPONENT | |
837 | + return; | |
838 | +#endif | |
839 | if (menu->id != NULL && menu->parent != NULL && | |
840 | gui.toolbar != NULL && menu_is_toolbar(menu->parent->name)) | |
841 | { | |
842 | @@ -1082,6 +1394,9 @@ | |
843 | void | |
844 | gui_mch_destroy_menu(vimmenu_T *menu) | |
845 | { | |
846 | +#ifdef FEAT_GUI_COMPONENT | |
847 | + return; | |
848 | +#endif | |
849 | # ifdef FEAT_TOOLBAR | |
850 | if (menu->parent != NULL && menu_is_toolbar(menu->parent->name)) | |
851 | { | |
852 | @@ -1184,8 +1499,8 @@ | |
853 | ||
854 | gui_drag_scrollbar(sb, value, dragging); | |
855 | ||
856 | - if (gtk_main_level() > 0) | |
857 | - gtk_main_quit(); | |
858 | + if (MAIN_LEVEL() > 0) | |
859 | + MAIN_QUIT(); | |
860 | } | |
861 | ||
862 | /* SBAR_VERT or SBAR_HORIZ */ | |
863 | @@ -1244,8 +1559,8 @@ | |
864 | vw->browse_fname = (char_u *)g_strdup(gtk_file_selection_get_filename( | |
865 | GTK_FILE_SELECTION(vw->filedlg))); | |
866 | gtk_widget_hide(vw->filedlg); | |
867 | - if (gtk_main_level() > 0) | |
868 | - gtk_main_quit(); | |
869 | + if (MAIN_LEVEL() > 0) | |
870 | + MAIN_QUIT(); | |
871 | } | |
872 | ||
873 | /*ARGSUSED*/ | |
874 | @@ -1260,8 +1575,8 @@ | |
875 | vw->browse_fname = NULL; | |
876 | } | |
877 | gtk_widget_hide(vw->filedlg); | |
878 | - if (gtk_main_level() > 0) | |
879 | - gtk_main_quit(); | |
880 | + if (MAIN_LEVEL() > 0) | |
881 | + MAIN_QUIT(); | |
882 | } | |
883 | ||
884 | /*ARGSUSED*/ | |
885 | @@ -1275,8 +1590,8 @@ | |
886 | } | |
887 | gui.filedlg = NULL; | |
888 | ||
889 | - if (gtk_main_level() > 0) | |
890 | - gtk_main_quit(); | |
891 | + if (MAIN_LEVEL() > 0) | |
892 | + MAIN_QUIT(); | |
893 | ||
894 | return FALSE; | |
895 | } | |
896 | @@ -1359,7 +1674,7 @@ | |
897 | ||
898 | gtk_widget_show(gui.filedlg); | |
899 | while (gui.filedlg && GTK_WIDGET_DRAWABLE(gui.filedlg)) | |
900 | - gtk_main_iteration_do(TRUE); | |
901 | + MAIN_ITERATION_DO(TRUE); | |
902 | ||
903 | if (gui.browse_fname == NULL) | |
904 | return NULL; | |
905 | @@ -1579,8 +1894,8 @@ | |
906 | dlg_destroy_cb(int *p) | |
907 | { | |
908 | *p = TRUE; /* set dialog_destroyed to break out of the loop */ | |
909 | - if (gtk_main_level() > 0) | |
910 | - gtk_main_quit(); | |
911 | + if (MAIN_LEVEL() > 0) | |
912 | + MAIN_QUIT(); | |
913 | } | |
914 | ||
915 | /* ARGSUSED */ | |
916 | @@ -1880,7 +2195,7 @@ | |
917 | /* loop here until the dialog goes away */ | |
918 | while (dialog_status == -1 && !dialog_destroyed | |
919 | && GTK_WIDGET_DRAWABLE(dialog)) | |
920 | - gtk_main_iteration_do(TRUE); | |
921 | + MAIN_ITERATION_DO(TRUE); | |
922 | ||
923 | if (dialog_status < 0) | |
924 | dialog_status = 0; | |
925 | @@ -2810,8 +3125,8 @@ | |
926 | CONVERT_FROM_UTF8_FREE(find_text); | |
927 | #endif | |
928 | ||
929 | - if (rc && gtk_main_level() > 0) | |
930 | - gtk_main_quit(); /* make sure cmd will be handled immediately */ | |
931 | + if (rc && MAIN_LEVEL() > 0) | |
932 | + MAIN_QUIT(); /* make sure cmd will be handled immediately */ | |
933 | } | |
934 | ||
935 | /* our usual callback function */ | |
936 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/gui_gtk_x11.c vim/src/gui_gtk_x11.c | |
937 | --- vimcopy/src/gui_gtk_x11.c Fri Mar 21 23:15:57 2003 | |
938 | +++ vim/src/gui_gtk_x11.c Sat Mar 22 11:33:04 2003 | |
939 | @@ -23,6 +23,7 @@ | |
940 | ||
941 | #include "vim.h" | |
942 | #ifdef FEAT_GUI_GNOME | |
943 | + #if 0 | |
944 | /* Gnome redefines _() and N_(). Grrr... */ | |
945 | # ifdef _ | |
946 | # undef _ | |
947 | @@ -36,6 +37,7 @@ | |
948 | # ifdef bindtextdomain | |
949 | # undef bindtextdomain | |
950 | # endif | |
951 | + #endif | |
952 | # if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS) | |
953 | # define ENABLE_NLS /* so the texts in the dialog boxes are translated */ | |
954 | # endif | |
955 | @@ -646,8 +648,8 @@ | |
956 | xev.xproperty.state = PropertyNewValue; | |
957 | serverEventProc(GDK_WINDOW_XDISPLAY(event->window), &xev); | |
958 | ||
959 | - if (gtk_main_level() > 0) | |
960 | - gtk_main_quit(); | |
961 | + if (MAIN_LEVEL() > 0) | |
962 | + MAIN_QUIT(); | |
963 | } | |
964 | return FALSE; | |
965 | } | |
966 | @@ -748,6 +750,10 @@ | |
967 | if (blink_state == BLINK_NONE) | |
968 | gui_mch_start_blink(); | |
969 | ||
970 | +#ifdef FEAT_GUI_COMPONENT | |
971 | + gtk_widget_grab_focus(gui.drawarea); | |
972 | + gtk_grab_add(gui.drawarea); | |
973 | +#endif | |
974 | /* make sure keyboard input goes there */ | |
975 | if (gtk_socket_id == 0 || !GTK_WIDGET_HAS_FOCUS(gui.drawarea)) | |
976 | gtk_widget_grab_focus(gui.drawarea); | |
977 | @@ -759,6 +765,9 @@ | |
978 | static gint | |
979 | leave_notify_event(GtkWidget *widget, GdkEventCrossing *event, gpointer data) | |
980 | { | |
981 | +#ifdef FEAT_GUI_COMPONENT | |
982 | + gtk_grab_remove(gui.drawarea); | |
983 | +#endif | |
984 | if (blink_state != BLINK_NONE) | |
985 | gui_mch_stop_blink(); | |
986 | ||
987 | @@ -1106,8 +1115,8 @@ | |
988 | if (p_mh) | |
989 | gui_mch_mousehide(TRUE); | |
990 | ||
991 | - if (gtk_main_level() > 0) | |
992 | - gtk_main_quit(); | |
993 | + if (MAIN_LEVEL() > 0) | |
994 | + MAIN_QUIT(); | |
995 | ||
996 | return TRUE; | |
997 | } | |
998 | @@ -1137,8 +1146,8 @@ | |
999 | else | |
1000 | clip_lose_selection(&clip_star); | |
1001 | ||
1002 | - if (gtk_main_level() > 0) | |
1003 | - gtk_main_quit(); | |
1004 | + if (MAIN_LEVEL() > 0) | |
1005 | + MAIN_QUIT(); | |
1006 | ||
1007 | return TRUE; | |
1008 | } | |
1009 | @@ -1312,7 +1321,7 @@ | |
1010 | int | |
1011 | gui_mch_init_check(void) | |
1012 | { | |
1013 | - int init_failed; | |
1014 | + int init_failed = 0; | |
1015 | ||
1016 | #ifndef HAVE_GTK2 | |
1017 | /* This is needed to make the locale handling consistant between the GUI | |
1018 | @@ -1328,13 +1337,18 @@ | |
1019 | * For GNOME 2, always use gtk_init_check() since gnome_program_init() | |
1020 | * exits on failure. So let's call it later in gui_mch_init(). | |
1021 | */ | |
1022 | -#if defined(FEAT_GUI_GNOME) && !defined(HAVE_GTK2) | |
1023 | +#ifdef FEAT_GUI_COMPONENT | |
1024 | + init_failed = 0; | |
1025 | + vim_bonobo_init(&gui_argc, gui_argv); | |
1026 | +#else | |
1027 | +# if defined(FEAT_GUI_GNOME) && !defined(HAVE_GTK2) | |
1028 | if (using_gnome) | |
1029 | init_failed = gnome_init("vim", VIM_VERSION_SHORT, gui_argc, gui_argv); | |
1030 | else | |
1031 | -#else | |
1032 | +# else | |
1033 | /* Don't use gtk_init(), it exits on failure. */ | |
1034 | init_failed = !gtk_init_check(&gui_argc, &gui_argv); | |
1035 | +# endif | |
1036 | #endif | |
1037 | ||
1038 | if (init_failed) | |
1039 | @@ -1347,6 +1361,22 @@ | |
1040 | return OK; | |
1041 | } | |
1042 | ||
1043 | +static gint | |
1044 | +control_activate_event(BonoboControl *control, gboolean activated) | |
1045 | +{ | |
1046 | + if (activated) | |
1047 | + { | |
1048 | + gui_focus_change (TRUE); | |
1049 | + if (blink_state == BLINK_NONE) | |
1050 | + gui_mch_start_blink(); | |
1051 | + } else { | |
1052 | + gui_focus_change (FALSE); | |
1053 | + if (blink_state != BLINK_NONE) | |
1054 | + gui_mch_stop_blink(); | |
1055 | + } | |
1056 | + return TRUE; | |
1057 | +} | |
1058 | + | |
1059 | ||
1060 | /**************************************************************************** | |
1061 | * Mouse handling callbacks | |
1062 | @@ -1407,8 +1437,8 @@ | |
1063 | /* inform the editor engine about the occurence of this event */ | |
1064 | gui_send_mouse_event(button, x, y, FALSE, vim_modifiers); | |
1065 | ||
1066 | - if (gtk_main_level() > 0) | |
1067 | - gtk_main_quit(); | |
1068 | + if (MAIN_LEVEL() > 0) | |
1069 | + MAIN_QUIT(); | |
1070 | ||
1071 | /* | |
1072 | * Auto repeat timer handling. | |
1073 | @@ -1539,6 +1569,9 @@ | |
1074 | int_u vim_modifiers; | |
1075 | ||
1076 | /* Make sure we have focus now we've been selected */ | |
1077 | +#ifdef FEAT_GUI_COMPONENT | |
1078 | + gtk_widget_grab_focus(gui.drawarea); | |
1079 | +#endif | |
1080 | if (gtk_socket_id != 0 && !GTK_WIDGET_HAS_FOCUS(gui.drawarea)) | |
1081 | gtk_widget_grab_focus(gui.drawarea); | |
1082 | ||
1083 | @@ -1603,8 +1636,8 @@ | |
1084 | vim_modifiers |= MOUSE_ALT; | |
1085 | ||
1086 | gui_send_mouse_event(button, x, y, repeated_click, vim_modifiers); | |
1087 | - if (gtk_main_level() > 0) | |
1088 | - gtk_main_quit(); /* make sure the above will be handled immediately */ | |
1089 | + if (MAIN_LEVEL() > 0) | |
1090 | + MAIN_QUIT(); /* make sure the above will be handled immediately */ | |
1091 | ||
1092 | return TRUE; | |
1093 | } | |
1094 | @@ -1651,8 +1684,8 @@ | |
1095 | ||
1096 | gui_send_mouse_event(button, event->x, event->y, FALSE, vim_modifiers); | |
1097 | ||
1098 | - if (gtk_main_level() > 0) | |
1099 | - gtk_main_quit(); /* make sure the above will be handled immediately */ | |
1100 | + if (MAIN_LEVEL() > 0) | |
1101 | + MAIN_QUIT(); /* make sure the above will be handled immediately */ | |
1102 | ||
1103 | return TRUE; | |
1104 | } | |
1105 | @@ -1687,8 +1720,8 @@ | |
1106 | vim_modifiers |= MOUSE_ALT; | |
1107 | ||
1108 | gui_send_mouse_event(MOUSE_RELEASE, x, y, FALSE, vim_modifiers); | |
1109 | - if (gtk_main_level() > 0) | |
1110 | - gtk_main_quit(); /* make sure it will be handled immediately */ | |
1111 | + if (MAIN_LEVEL() > 0) | |
1112 | + MAIN_QUIT(); /* make sure the above will be handled immediately */ | |
1113 | ||
1114 | return TRUE; | |
1115 | } | |
1116 | @@ -2246,6 +2279,7 @@ | |
1117 | static void | |
1118 | mainwin_realize(GtkWidget *widget, gpointer data) | |
1119 | { | |
1120 | +#ifndef FEAT_GUI_COMPONENT | |
1121 | /* If you get an error message here, you still need to unpack the runtime | |
1122 | * archive! */ | |
1123 | #ifdef magick | |
1124 | @@ -2332,6 +2366,7 @@ | |
1125 | ||
1126 | #endif /* !HAVE_GTK2 */ | |
1127 | } | |
1128 | +#endif /* FEAT_GUI_COMPONENT */ | |
1129 | ||
1130 | #ifndef USE_GNOME_SESSION | |
1131 | /* Register a handler for WM_SAVE_YOURSELF with GDK's low-level X I/F */ | |
1132 | @@ -2350,7 +2385,7 @@ | |
1133 | #endif | |
1134 | setup_save_yourself(); | |
1135 | ||
1136 | -#ifdef FEAT_CLIENTSERVER | |
1137 | +#if defined(FEAT_CLIENTSERVER) &&!defined(FEAT_GUI_COMPONENT) | |
1138 | if (serverName == NULL && serverDelayedStartName != NULL) | |
1139 | { | |
1140 | /* This is a :gui command in a plain vim with no previous server */ | |
1141 | @@ -2374,7 +2409,7 @@ | |
1142 | #endif | |
1143 | } | |
1144 | ||
1145 | -#ifdef HAVE_GTK_MULTIHEAD | |
1146 | +#if defined(GTK2_MULTIHEAD) && !defined(FEAT_GUI_COMPONENT) | |
1147 | /*ARGSUSED1*/ | |
1148 | static void | |
1149 | mainwin_screen_changed_cb(GtkWidget *widget, | |
1150 | @@ -2704,23 +2739,38 @@ | |
1151 | { | |
1152 | #ifdef FEAT_GUI_GNOME | |
1153 | if (using_gnome) | |
1154 | - gui.mainwin = gnome_app_new("Vim", NULL); | |
1155 | + { | |
1156 | +# if defined(FEAT_GUI_COMPONENT) | |
1157 | + gui.mainwin = NULL; | |
1158 | +# else | |
1159 | + gui.mainwin = gnome_app_new("vim", "vim"); | |
1160 | +# endif | |
1161 | + } | |
1162 | else | |
1163 | #endif | |
1164 | gui.mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1165 | } | |
1166 | ||
1167 | +#ifndef FEAT_GUI_COMPONENT | |
1168 | gtk_widget_set_name(gui.mainwin, "vim-main-window"); | |
1169 | +#endif | |
1170 | + vbox = gtk_vbox_new(FALSE, 0); | |
1171 | + gui.vbox = vbox; | |
1172 | ||
1173 | #ifdef HAVE_GTK2 | |
1174 | /* Create the PangoContext used for drawing all text. */ | |
1175 | +#ifdef FEAT_GUI_COMPONENT | |
1176 | + gui.text_context = gtk_widget_create_pango_context(GTK_WIDGET(gui.vbox)); | |
1177 | +#else | |
1178 | gui.text_context = gtk_widget_create_pango_context(gui.mainwin); | |
1179 | +#endif | |
1180 | pango_context_set_base_dir(gui.text_context, PANGO_DIRECTION_LTR); | |
1181 | #endif | |
1182 | ||
1183 | #ifndef HAVE_GTK2 | |
1184 | gtk_window_set_policy(GTK_WINDOW(gui.mainwin), TRUE, TRUE, TRUE); | |
1185 | #endif | |
1186 | +#ifndef FEAT_GUI_COMPONENT | |
1187 | gtk_container_border_width(GTK_CONTAINER(gui.mainwin), 0); | |
1188 | gtk_widget_add_events(gui.mainwin, GDK_VISIBILITY_NOTIFY_MASK); | |
1189 | ||
1190 | @@ -2740,8 +2790,6 @@ | |
1191 | gui.accel_group = gtk_accel_group_get_default(); | |
1192 | #endif | |
1193 | ||
1194 | - vbox = gtk_vbox_new(FALSE, 0); | |
1195 | - | |
1196 | #ifdef FEAT_GUI_GNOME | |
1197 | if (using_gnome) | |
1198 | { | |
1199 | @@ -2757,6 +2805,11 @@ | |
1200 | gtk_container_add(GTK_CONTAINER(gui.mainwin), vbox); | |
1201 | gtk_widget_show(vbox); | |
1202 | } | |
1203 | +#else | |
1204 | + gtk_widget_show(vbox); | |
1205 | +#endif | |
1206 | + | |
1207 | +#ifndef FEAT_GUI_COMPONENT | |
1208 | ||
1209 | #ifdef FEAT_MENU | |
1210 | /* | |
1211 | @@ -2862,6 +2915,7 @@ | |
1212 | gtk_box_pack_start(GTK_BOX(vbox), gui.toolbar, FALSE, FALSE, 0); | |
1213 | } | |
1214 | #endif /* FEAT_TOOLBAR */ | |
1215 | +#endif /* FEAT_GUI_COMPONENT */ | |
1216 | ||
1217 | gui.formwin = gtk_form_new(); | |
1218 | gtk_container_border_width(GTK_CONTAINER(gui.formwin), 0); | |
1219 | @@ -2889,6 +2943,11 @@ | |
1220 | gtk_widget_show(gui.formwin); | |
1221 | gtk_box_pack_start(GTK_BOX(vbox), gui.formwin, TRUE, TRUE, 0); | |
1222 | ||
1223 | +#ifdef FEAT_GUI_COMPONENT | |
1224 | + GTK_WIDGET_SET_FLAGS (gui.drawarea, GTK_CAN_FOCUS); | |
1225 | + g_signal_connect(G_OBJECT(gui.drawarea), "key_press_event", | |
1226 | + G_CALLBACK(key_press_event), NULL); | |
1227 | +#else | |
1228 | /* For GtkSockets, key-presses must go to the focus widget (drawarea) | |
1229 | * and not the window. */ | |
1230 | gtk_signal_connect((gtk_socket_id == 0) ? GTK_OBJECT(gui.mainwin) | |
1231 | @@ -2903,6 +2962,7 @@ | |
1232 | "key_release_event", | |
1233 | G_CALLBACK(&key_release_event), NULL); | |
1234 | #endif | |
1235 | +#endif /* FEAT_GUI_COMPONENT */ | |
1236 | gtk_signal_connect(GTK_OBJECT(gui.drawarea), "realize", | |
1237 | GTK_SIGNAL_FUNC(drawarea_realize_cb), NULL); | |
1238 | gtk_signal_connect(GTK_OBJECT(gui.drawarea), "unrealize", | |
1239 | @@ -2938,16 +2998,27 @@ | |
1240 | */ | |
1241 | gui.border_offset = gui.border_width; | |
1242 | ||
1243 | +#ifdef FEAT_GUI_COMPONENT | |
1244 | + gtk_signal_connect(GTK_OBJECT(gui.vbox), "visibility_notify_event", | |
1245 | + GTK_SIGNAL_FUNC(visibility_event), NULL); | |
1246 | +#else | |
1247 | gtk_signal_connect(GTK_OBJECT(gui.mainwin), "visibility_notify_event", | |
1248 | GTK_SIGNAL_FUNC(visibility_event), NULL); | |
1249 | +#endif | |
1250 | gtk_signal_connect(GTK_OBJECT(gui.drawarea), "expose_event", | |
1251 | GTK_SIGNAL_FUNC(expose_event), NULL); | |
1252 | ||
1253 | /* | |
1254 | * Only install these enter/leave callbacks when 'p' in 'guioptions'. | |
1255 | * Only needed for some window managers. | |
1256 | + * | |
1257 | + * Force this on for bonobo, otherwise the toolbar gets the focus | |
1258 | + * after you click a button, and you can't get the focus back to the | |
1259 | + * drawarea. | |
1260 | */ | |
1261 | +#ifndef FEAT_GUI_COMPONENT | |
1262 | if (vim_strchr(p_go, GO_POINTER) != NULL) | |
1263 | +#endif | |
1264 | { | |
1265 | gtk_signal_connect(GTK_OBJECT(gui.drawarea), "leave_notify_event", | |
1266 | GTK_SIGNAL_FUNC(leave_notify_event), NULL); | |
1267 | @@ -2955,10 +3026,15 @@ | |
1268 | GTK_SIGNAL_FUNC(enter_notify_event), NULL); | |
1269 | } | |
1270 | ||
1271 | +#ifdef FEAT_GUI_COMPONENT | |
1272 | + g_signal_connect(G_OBJECT(gui.control), "activate", | |
1273 | + G_CALLBACK (control_activate_event), NULL); | |
1274 | +#else | |
1275 | gtk_signal_connect(GTK_OBJECT(gui.mainwin), "focus_out_event", | |
1276 | GTK_SIGNAL_FUNC(focus_out_event), NULL); | |
1277 | gtk_signal_connect(GTK_OBJECT(gui.mainwin), "focus_in_event", | |
1278 | GTK_SIGNAL_FUNC(focus_in_event), NULL); | |
1279 | +#endif | |
1280 | ||
1281 | gtk_signal_connect(GTK_OBJECT(gui.drawarea), "motion_notify_event", | |
1282 | GTK_SIGNAL_FUNC(motion_notify_event), NULL); | |
1283 | @@ -3155,6 +3231,7 @@ | |
1284 | geometry.min_height = height + MIN_LINES * gui.char_height; | |
1285 | geometry_mask = GDK_HINT_BASE_SIZE|GDK_HINT_RESIZE_INC | |
1286 | |GDK_HINT_MIN_SIZE; | |
1287 | +#ifndef FEAT_GUI_COMPONENT | |
1288 | # ifdef HAVE_GTK2 | |
1289 | /* Using gui.formwin as geometry widget doesn't work as expected | |
1290 | * with GTK+ 2 -- dunno why. Presumably all the resizing hacks | |
1291 | @@ -3165,6 +3242,7 @@ | |
1292 | gtk_window_set_geometry_hints(GTK_WINDOW(gui.mainwin), gui.formwin, | |
1293 | &geometry, geometry_mask); | |
1294 | # endif | |
1295 | +#endif | |
1296 | old_width = width; | |
1297 | old_height = height; | |
1298 | old_char_width = gui.char_width; | |
1299 | @@ -3341,8 +3419,10 @@ | |
1300 | * changed them). */ | |
1301 | highlight_gui_started(); /* re-init colors and fonts */ | |
1302 | ||
1303 | +#ifndef FEAT_GUI_COMPONENT | |
1304 | gtk_signal_connect(GTK_OBJECT(gui.mainwin), "destroy", | |
1305 | GTK_SIGNAL_FUNC(mainwin_destroy_cb), NULL); | |
1306 | +#endif | |
1307 | ||
1308 | #ifndef HAVE_GTK2 | |
1309 | /* Make this run after any internal handling of the client event happened | |
1310 | @@ -3418,7 +3498,9 @@ | |
1311 | NULL); | |
1312 | # endif | |
1313 | #endif | |
1314 | - gtk_widget_show(gui.mainwin); | |
1315 | +#ifndef FEAT_GUI_COMPONENT | |
1316 | + gtk_widget_show(gui.mainwin); | |
1317 | +#endif | |
1318 | ||
1319 | #if defined(FEAT_GUI_GNOME) && defined(HAVE_GTK2) && defined(FEAT_MENU) | |
1320 | if (menu_handler != 0) | |
1321 | @@ -3448,8 +3530,8 @@ | |
1322 | if (gui.mainwin != NULL) | |
1323 | gtk_widget_destroy(gui.mainwin); | |
1324 | ||
1325 | - if (gtk_main_level() > 0) | |
1326 | - gtk_main_quit(); | |
1327 | + if (MAIN_LEVEL() > 0) | |
1328 | + MAIN_QUIT(); /* make sure the above will be handled immediately */ | |
1329 | } | |
1330 | ||
1331 | /* | |
1332 | @@ -3543,7 +3625,7 @@ | |
1333 | /* this will cause the proper resizement to happen too */ | |
1334 | update_window_manager_hints(); | |
1335 | ||
1336 | -#ifdef HAVE_GTK2 | |
1337 | +#if defined( HAVE_GTK2 ) && !defined( FEAT_GUI_COMPONENT ) | |
1338 | /* With GTK+ 2, changing the size of the form widget doesn't resize | |
1339 | * the window. So lets do it the other way around and resize the | |
1340 | * main window instead. */ | |
1341 | @@ -3621,6 +3703,7 @@ | |
1342 | { | |
1343 | GtkWidget *widget; | |
1344 | ||
1345 | +#ifndef FEAT_GUI_COMPONENT | |
1346 | # ifdef FEAT_GUI_GNOME | |
1347 | if (using_gnome) | |
1348 | widget = gui.menubar_h; | |
1349 | @@ -3637,6 +3720,7 @@ | |
1350 | ||
1351 | update_window_manager_hints(); | |
1352 | } | |
1353 | +#endif | |
1354 | } | |
1355 | #endif /* FEAT_MENU */ | |
1356 | ||
1357 | @@ -3691,8 +3775,8 @@ | |
1358 | vw->fontname = vim_strsave((char_u *)gtk_font_selection_dialog_get_font_name(fs)); | |
1359 | gtk_widget_hide(vw->fontdlg); | |
1360 | ||
1361 | - if (gtk_main_level() > 0) | |
1362 | - gtk_main_quit(); | |
1363 | + if (MAIN_LEVEL() > 0) | |
1364 | + MAIN_QUIT(); | |
1365 | } | |
1366 | ||
1367 | /*ARGSUSED*/ | |
1368 | @@ -3702,8 +3786,8 @@ | |
1369 | gui_T *vw = (gui_T *)cbdata; | |
1370 | ||
1371 | gtk_widget_hide(vw->fontdlg); | |
1372 | - if (gtk_main_level() > 0) | |
1373 | - gtk_main_quit(); | |
1374 | + if (MAIN_LEVEL() > 0) | |
1375 | + MAIN_QUIT(); | |
1376 | } | |
1377 | ||
1378 | /*ARGSUSED*/ | |
1379 | @@ -3713,8 +3797,8 @@ | |
1380 | gui_T *vw = (gui_T *)cbdata; | |
1381 | ||
1382 | vw->fontdlg = NULL; | |
1383 | - if (gtk_main_level() > 0) | |
1384 | - gtk_main_quit(); | |
1385 | + if (MAIN_LEVEL() > 0) | |
1386 | + MAIN_QUIT(); | |
1387 | } | |
1388 | #endif /* !HAVE_GTK2 */ | |
1389 | ||
1390 | @@ -3874,7 +3958,7 @@ | |
1391 | ||
1392 | /* Wait for the font dialog to be closed. */ | |
1393 | while (gui.fontdlg && GTK_WIDGET_DRAWABLE(gui.fontdlg)) | |
1394 | - gtk_main_iteration_do(TRUE); | |
1395 | + MAIN_ITERATION_DO(TRUE); | |
1396 | ||
1397 | if (gui.fontname == NULL) | |
1398 | return NULL; | |
1399 | @@ -5371,7 +5455,7 @@ | |
1400 | gui_mch_update(void) | |
1401 | { | |
1402 | while (gtk_events_pending() && !vim_is_input_buf_full()) | |
1403 | - gtk_main_iteration_do(FALSE); | |
1404 | + MAIN_ITERATION_DO(FALSE); | |
1405 | } | |
1406 | ||
1407 | static gint | |
1408 | @@ -5382,8 +5466,8 @@ | |
1409 | /* Just inform the caller about the occurence of it */ | |
1410 | *timed_out = TRUE; | |
1411 | ||
1412 | - if (gtk_main_level() > 0) | |
1413 | - gtk_main_quit(); | |
1414 | + if (MAIN_LEVEL() > 0) | |
1415 | + MAIN_QUIT(); | |
1416 | ||
1417 | return FALSE; /* don't happen again */ | |
1418 | } | |
1419 | @@ -5403,8 +5487,8 @@ | |
1420 | ||
1421 | add_to_input_buf(bytes, 3); | |
1422 | ||
1423 | - if (gtk_main_level() > 0) | |
1424 | - gtk_main_quit(); | |
1425 | + if (MAIN_LEVEL() > 0) | |
1426 | + MAIN_QUIT(); | |
1427 | } | |
1428 | #endif | |
1429 | ||
1430 | @@ -5471,7 +5555,7 @@ | |
1431 | /* | |
1432 | * Loop in GTK+ processing until a timeout or input occurs. | |
1433 | */ | |
1434 | - gtk_main(); | |
1435 | + MAIN(); | |
1436 | ||
1437 | /* Got char, return immediately */ | |
1438 | if (!vim_is_input_buf_empty()) | |
1439 | @@ -5548,6 +5632,7 @@ | |
1440 | gdk_window_clear(gui.drawarea->window); | |
1441 | } | |
1442 | ||
1443 | + | |
1444 | /* | |
1445 | * Redraw any text revealed by scrolling up/down. | |
1446 | */ | |
1447 | @@ -5649,7 +5734,7 @@ | |
1448 | cbd->gtk_sel_atom, vim_atom, | |
1449 | (guint32)GDK_CURRENT_TIME); | |
1450 | while (received_selection == RS_NONE) | |
1451 | - gtk_main(); /* wait for selection_received_cb */ | |
1452 | + MAIN(); /* wait for selection_received_cb */ | |
1453 | ||
1454 | if (received_selection == RS_FAIL) | |
1455 | { | |
1456 | @@ -5659,7 +5744,7 @@ | |
1457 | gdk_atom_intern("COMPOUND_TEXT", FALSE), | |
1458 | (guint32)GDK_CURRENT_TIME); | |
1459 | while (received_selection == RS_NONE) | |
1460 | - gtk_main(); /* wait for selection_received_cb */ | |
1461 | + MAIN(); /* wait for selection_received_cb */ | |
1462 | } | |
1463 | if (received_selection == RS_FAIL) | |
1464 | { | |
1465 | @@ -5669,7 +5754,7 @@ | |
1466 | gdk_atom_intern("TEXT", FALSE), | |
1467 | (guint32)GDK_CURRENT_TIME); | |
1468 | while (received_selection == RS_NONE) | |
1469 | - gtk_main(); /* wait for selection_received_cb */ | |
1470 | + MAIN(); /* wait for selection_received_cb */ | |
1471 | } | |
1472 | if (received_selection == RS_FAIL) | |
1473 | { | |
1474 | @@ -5679,7 +5764,7 @@ | |
1475 | (GdkAtom)GDK_TARGET_STRING, | |
1476 | (guint32)GDK_CURRENT_TIME); | |
1477 | while (received_selection == RS_NONE) | |
1478 | - gtk_main(); /* wait for selection_received_cb */ | |
1479 | + MAIN(); /* wait for selection_received_cb */ | |
1480 | } | |
1481 | if (received_selection == RS_FAIL) | |
1482 | { | |
1483 | @@ -5748,6 +5833,13 @@ | |
1484 | void | |
1485 | gui_mch_menu_grey(vimmenu_T *menu, int grey) | |
1486 | { | |
1487 | +#ifdef FEAT_GUI_COMPONENT | |
1488 | + if( menu->sensitive != !grey ) { | |
1489 | + menu->sensitive = !grey; | |
1490 | + update_menu_later(menu); | |
1491 | + } | |
1492 | + return; | |
1493 | +#endif | |
1494 | if (menu->id == NULL) | |
1495 | return; | |
1496 | ||
1497 | @@ -5888,6 +5980,40 @@ | |
1498 | /* The last set mouse pointer shape is remembered, to be used when it goes | |
1499 | * from hidden to not hidden. */ | |
1500 | static int last_shape = 0; | |
1501 | +#endif | |
1502 | + | |
1503 | +#if 0 | |
1504 | +static BonoboWindow * | |
1505 | +bonobo_create_window(void) | |
1506 | +{ | |
1507 | + BonoboWindow *win; | |
1508 | + BonoboUIContainer *ui_container; | |
1509 | + BonoboUIComponent *ui_component; | |
1510 | + | |
1511 | + win = BONOBO_WINDOW (bonobo_window_new ("vim", "vim")); | |
1512 | + ui_container = bonobo_window_get_ui_container (win); | |
1513 | + bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (win), | |
1514 | + "/gnome-vim/UIConfig/kvps"); | |
1515 | + | |
1516 | + /* Create a UI component with which to communicate with the window */ | |
1517 | + ui_component = bonobo_ui_component_new_default (); | |
1518 | + | |
1519 | + gui.component = ui_component; | |
1520 | + | |
1521 | + /* Associate the BonoboUIComponent with the container */ | |
1522 | + bonobo_ui_component_set_container ( | |
1523 | + ui_component, BONOBO_OBJREF (ui_container), NULL); | |
1524 | + | |
1525 | + //bonobo_ui_util_set_ui (ui_component, "", | |
1526 | + //HELLO_SRCDIR HELLO_UI_XML, | |
1527 | + //"bonobo-hello", NULL); | |
1528 | + | |
1529 | + /* Associate our verb -> callback mapping with the BonoboWindow */ | |
1530 | + /* All the callback's user_data pointers will be set to 'win' */ | |
1531 | + //bonobo_ui_component_add_verb_list_with_data (ui_component, hello_verbs, win); | |
1532 | + | |
1533 | + return win; | |
1534 | +} | |
1535 | #endif | |
1536 | ||
1537 | /* | |
1538 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/main.c vim/src/main.c | |
1539 | --- vimcopy/src/main.c Fri Mar 21 23:15:57 2003 | |
1540 | +++ vim/src/main.c Fri Mar 21 23:22:34 2003 | |
1541 | @@ -79,7 +79,7 @@ | |
1542 | # ifdef VIMDLL | |
1543 | _export | |
1544 | # endif | |
1545 | -# ifdef FEAT_GUI_MSWIN | |
1546 | +# if defined(FEAT_GUI_MSWIN) | |
1547 | # ifdef __BORLANDC__ | |
1548 | _cdecl | |
1549 | # endif | |
1550 | @@ -239,8 +239,12 @@ | |
1551 | TIME_MSG("locale set"); | |
1552 | #endif | |
1553 | ||
1554 | -#ifdef FEAT_GUI | |
1555 | +#if defined(FEAT_GUI_COMPONENT) | |
1556 | + gui.dofork = FALSE; /* don't use fork when running as component */ | |
1557 | +#else | |
1558 | +# if defined(FEAT_GUI) && !defined(FEAT_GUI_COMPONENT) | |
1559 | gui.dofork = TRUE; /* default is to use fork() */ | |
1560 | +# endif | |
1561 | #endif | |
1562 | ||
1563 | #if defined(FEAT_XCLIPBOARD) || defined(FEAT_CLIENTSERVER) | |
1564 | @@ -441,6 +445,10 @@ | |
1565 | evim_mode = TRUE; | |
1566 | ++initstr; | |
1567 | } | |
1568 | + | |
1569 | +#ifdef FEAT_GUI_COMPONENT | |
1570 | + main_start_gui(); | |
1571 | +#endif | |
1572 | ||
1573 | if (TOLOWER_ASC(initstr[0]) == 'g') | |
1574 | { | |
1575 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/mbyte.c vim/src/mbyte.c | |
1576 | --- vimcopy/src/mbyte.c Fri Mar 21 23:15:57 2003 | |
1577 | +++ vim/src/mbyte.c Fri Mar 21 23:22:34 2003 | |
1578 | @@ -2839,8 +2839,8 @@ | |
1579 | ||
1580 | im_add_to_input((char_u *)str, strlen(str)); | |
1581 | ||
1582 | - if (gtk_main_level() > 0) | |
1583 | - gtk_main_quit(); | |
1584 | + if (MAIN_LEVEL() > 0) | |
1585 | + MAIN_QUIT(); | |
1586 | } | |
1587 | ||
1588 | /* | |
1589 | @@ -3782,7 +3782,11 @@ | |
1590 | if (gui.fontset != NOFONTSET | |
1591 | && gui.fontset->type == GDK_FONT_FONTSET) | |
1592 | { | |
1593 | +#ifdef FEAT_GUI_COMPONENT | |
1594 | + widget = gui.drawarea; | |
1595 | +#else | |
1596 | widget = gui.mainwin; | |
1597 | +#endif | |
1598 | gdk_window_get_size(widget->window, &width, &height); | |
1599 | ||
1600 | attrmask |= (int)GDK_IC_STATUS_AREA; | |
1601 | @@ -4359,9 +4363,15 @@ | |
1602 | while (event_queue != NULL && processing_queued_event) | |
1603 | { | |
1604 | GdkEvent *ev = event_queue->data; | |
1605 | - | |
1606 | + GtkWidget *output; | |
1607 | + | |
1608 | gboolean *ret; | |
1609 | - gtk_signal_emit_by_name((GtkObject*)gui.mainwin, "key_press_event", | |
1610 | +#ifdef FEAT_GUI_COMPONENT | |
1611 | + output = gui.drawarea; | |
1612 | +#else | |
1613 | + output = gui.mainwin; | |
1614 | +#endif | |
1615 | + gtk_signal_emit_by_name((GtkObject*)output, "key_press_event", | |
1616 | ev, &ret); | |
1617 | gdk_event_free(ev); | |
1618 | event_queue = event_queue->next; | |
1619 | @@ -4373,8 +4383,8 @@ | |
1620 | key_press_event_queue = NULL; | |
1621 | } | |
1622 | } | |
1623 | - if (gtk_main_level() > 0) | |
1624 | - gtk_main_quit(); | |
1625 | + if (MAIN_LEVEL() > 0) | |
1626 | + MAIN_QUIT(); | |
1627 | } | |
1628 | ||
1629 | /* | |
1630 | @@ -4509,7 +4519,11 @@ | |
1631 | GtkWidget *widget = gui.drawarea; | |
1632 | ||
1633 | attr->style = (GdkIMStyle)xim_input_style; | |
1634 | +#ifdef FEAT_GUI_COMPONENT | |
1635 | + attr->client_window = gui.drawarea->window; | |
1636 | +#else | |
1637 | attr->client_window = gui.mainwin->window; | |
1638 | +#endif | |
1639 | ||
1640 | if ((colormap = gtk_widget_get_colormap(widget)) != | |
1641 | gtk_widget_get_default_colormap()) | |
1642 | @@ -4556,7 +4570,11 @@ | |
1643 | } | |
1644 | else | |
1645 | { | |
1646 | +#ifdef FEAT_GUI_COMPONENT | |
1647 | + gdk_window_get_size(gui.drawarea->window, &width, &height); | |
1648 | +#else | |
1649 | gdk_window_get_size(gui.mainwin->window, &width, &height); | |
1650 | +#endif | |
1651 | attrmask |= (int)GDK_IC_STATUS_AREA_REQ; | |
1652 | attr->status_area.x = 0; | |
1653 | attr->status_area.y = height - gui.char_height - 1; | |
1654 | Binary files vimcopy/src/objects/buffer.o and vim/src/objects/buffer.o differ | |
1655 | Binary files vimcopy/src/objects/charset.o and vim/src/objects/charset.o differ | |
1656 | Binary files vimcopy/src/objects/diff.o and vim/src/objects/diff.o differ | |
1657 | Binary files vimcopy/src/objects/digraph.o and vim/src/objects/digraph.o differ | |
1658 | Binary files vimcopy/src/objects/edit.o and vim/src/objects/edit.o differ | |
1659 | Binary files vimcopy/src/objects/eval.o and vim/src/objects/eval.o differ | |
1660 | Binary files vimcopy/src/objects/ex_cmds.o and vim/src/objects/ex_cmds.o differ | |
1661 | Binary files vimcopy/src/objects/ex_cmds2.o and vim/src/objects/ex_cmds2.o differ | |
1662 | Binary files vimcopy/src/objects/ex_docmd.o and vim/src/objects/ex_docmd.o differ | |
1663 | Binary files vimcopy/src/objects/ex_getln.o and vim/src/objects/ex_getln.o differ | |
1664 | Binary files vimcopy/src/objects/fileio.o and vim/src/objects/fileio.o differ | |
1665 | Binary files vimcopy/src/objects/fold.o and vim/src/objects/fold.o differ | |
1666 | Binary files vimcopy/src/objects/getchar.o and vim/src/objects/getchar.o differ | |
1667 | Binary files vimcopy/src/objects/gui.o and vim/src/objects/gui.o differ | |
1668 | Binary files vimcopy/src/objects/gui_beval.o and vim/src/objects/gui_beval.o differ | |
1669 | Binary files vimcopy/src/objects/gui_gtk.o and vim/src/objects/gui_gtk.o differ | |
1670 | Binary files vimcopy/src/objects/gui_gtk_f.o and vim/src/objects/gui_gtk_f.o differ | |
1671 | Binary files vimcopy/src/objects/gui_gtk_x11.o and vim/src/objects/gui_gtk_x11.o differ | |
1672 | Binary files vimcopy/src/objects/if_cscope.o and vim/src/objects/if_cscope.o differ | |
1673 | Binary files vimcopy/src/objects/if_xcmdsrv.o and vim/src/objects/if_xcmdsrv.o differ | |
1674 | Binary files vimcopy/src/objects/main.o and vim/src/objects/main.o differ | |
1675 | Binary files vimcopy/src/objects/mark.o and vim/src/objects/mark.o differ | |
1676 | Binary files vimcopy/src/objects/mbyte.o and vim/src/objects/mbyte.o differ | |
1677 | Binary files vimcopy/src/objects/memfile.o and vim/src/objects/memfile.o differ | |
1678 | Binary files vimcopy/src/objects/memline.o and vim/src/objects/memline.o differ | |
1679 | Binary files vimcopy/src/objects/menu.o and vim/src/objects/menu.o differ | |
1680 | Binary files vimcopy/src/objects/message.o and vim/src/objects/message.o differ | |
1681 | Binary files vimcopy/src/objects/misc1.o and vim/src/objects/misc1.o differ | |
1682 | Binary files vimcopy/src/objects/misc2.o and vim/src/objects/misc2.o differ | |
1683 | Binary files vimcopy/src/objects/move.o and vim/src/objects/move.o differ | |
1684 | Binary files vimcopy/src/objects/normal.o and vim/src/objects/normal.o differ | |
1685 | Binary files vimcopy/src/objects/ops.o and vim/src/objects/ops.o differ | |
1686 | Binary files vimcopy/src/objects/option.o and vim/src/objects/option.o differ | |
1687 | Binary files vimcopy/src/objects/os_unix.o and vim/src/objects/os_unix.o differ | |
1688 | Binary files vimcopy/src/objects/pathdef.o and vim/src/objects/pathdef.o differ | |
1689 | Binary files vimcopy/src/objects/pty.o and vim/src/objects/pty.o differ | |
1690 | Binary files vimcopy/src/objects/quickfix.o and vim/src/objects/quickfix.o differ | |
1691 | Binary files vimcopy/src/objects/regexp.o and vim/src/objects/regexp.o differ | |
1692 | Binary files vimcopy/src/objects/screen.o and vim/src/objects/screen.o differ | |
1693 | Binary files vimcopy/src/objects/search.o and vim/src/objects/search.o differ | |
1694 | Binary files vimcopy/src/objects/syntax.o and vim/src/objects/syntax.o differ | |
1695 | Binary files vimcopy/src/objects/tag.o and vim/src/objects/tag.o differ | |
1696 | Binary files vimcopy/src/objects/term.o and vim/src/objects/term.o differ | |
1697 | Binary files vimcopy/src/objects/ui.o and vim/src/objects/ui.o differ | |
1698 | Binary files vimcopy/src/objects/undo.o and vim/src/objects/undo.o differ | |
1699 | Binary files vimcopy/src/objects/version.o and vim/src/objects/version.o differ | |
1700 | Binary files vimcopy/src/objects/vim_bonobo_control.o and vim/src/objects/vim_bonobo_control.o differ | |
1701 | Binary files vimcopy/src/objects/vim_bonobo_factory.o and vim/src/objects/vim_bonobo_factory.o differ | |
1702 | Binary files vimcopy/src/objects/vim_bonobo_main.o and vim/src/objects/vim_bonobo_main.o differ | |
1703 | Binary files vimcopy/src/objects/window.o and vim/src/objects/window.o differ | |
1704 | Binary files vimcopy/src/po/af.mo and vim/src/po/af.mo differ | |
1705 | Binary files vimcopy/src/po/cs.cp1250.mo and vim/src/po/cs.cp1250.mo differ | |
1706 | Binary files vimcopy/src/po/cs.mo and vim/src/po/cs.mo differ | |
1707 | Binary files vimcopy/src/po/de.mo and vim/src/po/de.mo differ | |
1708 | Binary files vimcopy/src/po/es.mo and vim/src/po/es.mo differ | |
1709 | Binary files vimcopy/src/po/fr.mo and vim/src/po/fr.mo differ | |
1710 | Binary files vimcopy/src/po/it.mo and vim/src/po/it.mo differ | |
1711 | Binary files vimcopy/src/po/ja.mo and vim/src/po/ja.mo differ | |
1712 | Binary files vimcopy/src/po/ja.sjis.mo and vim/src/po/ja.sjis.mo differ | |
1713 | Binary files vimcopy/src/po/ko.mo and vim/src/po/ko.mo differ | |
1714 | Binary files vimcopy/src/po/pl.mo and vim/src/po/pl.mo differ | |
1715 | Binary files vimcopy/src/po/sk.cp1250.mo and vim/src/po/sk.cp1250.mo differ | |
1716 | Binary files vimcopy/src/po/sk.mo and vim/src/po/sk.mo differ | |
1717 | Binary files vimcopy/src/po/uk.mo and vim/src/po/uk.mo differ | |
1718 | Binary files vimcopy/src/po/zh_CN.UTF-8.mo and vim/src/po/zh_CN.UTF-8.mo differ | |
1719 | Binary files vimcopy/src/po/zh_CN.cp936.mo and vim/src/po/zh_CN.cp936.mo differ | |
1720 | Binary files vimcopy/src/po/zh_CN.mo and vim/src/po/zh_CN.mo differ | |
1721 | Binary files vimcopy/src/po/zh_TW.mo and vim/src/po/zh_TW.mo differ | |
1722 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/structs.h vim/src/structs.h | |
1723 | --- vimcopy/src/structs.h Fri Mar 21 23:05:49 2003 | |
1724 | +++ vim/src/structs.h Fri Mar 21 23:22:34 2003 | |
1725 | @@ -1607,8 +1607,11 @@ | |
1726 | GtkWidget *tearoff_handle; | |
1727 | GtkWidget *label; /* Used by "set wak=" code. */ | |
1728 | #endif | |
1729 | -#ifdef FEAT_GUI_MOTIF | |
1730 | +#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_COMPONENT) | |
1731 | int sensitive; /* turn button on/off */ | |
1732 | +#if defined(FEAT_GUI_COMPONENT) | |
1733 | + int dirty; /* menu item has been updated; container needs to know */ | |
1734 | +#endif | |
1735 | #endif | |
1736 | #if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MOTIF) | |
1737 | Pixmap image; /* Toolbar image */ | |
1738 | Binary files vimcopy/src/vim and vim/src/vim differ | |
1739 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/vim-container.xml vim/src/vim-container.xml | |
1740 | --- vimcopy/src/vim-container.xml Wed Dec 31 18:00:00 1969 | |
1741 | +++ vim/src/vim-container.xml Fri Mar 21 23:22:34 2003 | |
1742 | @@ -0,0 +1,83 @@ | |
1743 | +<Root> | |
1744 | + | |
1745 | +<commands> | |
1746 | + <cmd name="FileNewWindow" _label="_New Window" _tip="Open a new window" | |
1747 | + pixtype="stock" pixname="gtk-new" accel="*Control*n"/> | |
1748 | + | |
1749 | + <cmd name="FileOpen" _label="_Open..." _tip="Open a file" | |
1750 | + pixtype="stock" pixname="gtk-open" accel="*Control*o"/> | |
1751 | + | |
1752 | + <cmd name="FileCloseWindow" _label="_Close" _tip="Close window" | |
1753 | + pixtype="stock" pixname="gtk-close" accel="*Control*w"/> | |
1754 | + | |
1755 | + <cmd name="FileExit" _label="_Quit" _tip="Quit the program" | |
1756 | + pixtype="stock" pixname="gtk-quit" accel="*Control*q"/> | |
1757 | + | |
1758 | + <cmd name="Preferences" _label="_Preferences..." _tip="Change preferences" sensitive="0" | |
1759 | + pixtype="stock" pixname="gtk-preferences"/> | |
1760 | + | |
1761 | + <cmd name="HelpAbout" _label="_About" _tip="About this application" | |
1762 | + pixtype="stock" pixname="About"/> | |
1763 | + <cmd name="Help" _label="Contents" _tip="Help On this application" | |
1764 | + pixtype="stock" pixname="Help" accel="F1"/> | |
1765 | + | |
1766 | + | |
1767 | + <cmd name="DnDNewWindow" _label="Open in new window"/> | |
1768 | + <cmd name="DnDSameWindow" _label="Open in this window"/> | |
1769 | + <cmd name="DnDCancel" _label="Cancel" | |
1770 | + pixtype="stock" pixname="Cancel"/> | |
1771 | +</commands> | |
1772 | + | |
1773 | +<menu> | |
1774 | + <submenu name="File" _label="_File"> | |
1775 | + | |
1776 | + <menuitem name="FileNewWindow" verb=""/> | |
1777 | + | |
1778 | + <placeholder name="Open Placeholder" delimit="top"> | |
1779 | + <menuitem name="FileOpen" verb=""/> | |
1780 | + </placeholder> | |
1781 | + | |
1782 | + <placeholder name="File Items Placeholder" delimit="top"/> | |
1783 | + | |
1784 | + <separator/> | |
1785 | + | |
1786 | + <menuitem name="FileCloseWindow" verb=""/> | |
1787 | + | |
1788 | + <menuitem name="FileExit" verb=""/> | |
1789 | + | |
1790 | + </submenu> | |
1791 | + | |
1792 | + <submenu name="Edit" _label="_Edit"> | |
1793 | + <menuitem name="Preferences" verb=""/> | |
1794 | + </submenu> | |
1795 | + | |
1796 | + <submenu name="View" _label="_View" hidden="1"> | |
1797 | + <placeholder name="View Preferences Placeholder"/> | |
1798 | + <placeholder name="View Items Placeholder" delimit="top"/> | |
1799 | + </submenu> | |
1800 | + | |
1801 | + <submenu name="Help" _label="_Help"> | |
1802 | + <menuitem name="Help" verb=""/> | |
1803 | + <menuitem name="HelpAbout" verb=""/> | |
1804 | + </submenu> | |
1805 | +</menu> | |
1806 | + | |
1807 | +<dockitem name="Toolbar" relief="none" homogeneous="1" behavior="exclusive"> | |
1808 | + | |
1809 | + <toolitem name="TBOpen" _label="Open" pixtype="stock" | |
1810 | + pixname="Open" verb="FileOpen"/> | |
1811 | + | |
1812 | + <toolitem name="TBCloseWindow" _label="Close" pixtype="stock" | |
1813 | + pixname="Close" verb="FileCloseWindow"/> | |
1814 | +</dockitem> | |
1815 | + | |
1816 | +<popups> | |
1817 | + <popup name="dragndrop"> | |
1818 | + <menuitem name="DnDNewWindow" verb=""/> | |
1819 | + <menuitem name="DnDSameWindow" verb=""/> | |
1820 | + <separator/> | |
1821 | + <menuitem name="DnDCancel" verb=""/> | |
1822 | + </popup> | |
1823 | +</popups> | |
1824 | + | |
1825 | +</Root> | |
1826 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/vim_bonobo_control.c vim/src/vim_bonobo_control.c | |
1827 | --- vimcopy/src/vim_bonobo_control.c Wed Dec 31 18:00:00 1969 | |
1828 | +++ vim/src/vim_bonobo_control.c Fri Mar 21 23:22:34 2003 | |
1829 | @@ -0,0 +1,262 @@ | |
1830 | +/** | |
1831 | + * vim_bonobo_control.c | |
1832 | + * | |
1833 | + * Author: | |
1834 | + * Jason Hildebrand <jason@peaceworks.ca> | |
1835 | + * | |
1836 | + */ | |
1837 | +#include <stdio.h> | |
1838 | + | |
1839 | +#include "vim.h" | |
1840 | +#include "vim_bonobo_control.h" | |
1841 | + | |
1842 | +#include <gnome.h> | |
1843 | +#include <libbonoboui.h> | |
1844 | +#include <libbonobo.h> | |
1845 | +#include <libnautilus/nautilus-view.h> | |
1846 | + | |
1847 | + | |
1848 | +struct _VimControlPrivate { | |
1849 | + BonoboUIComponent *component; | |
1850 | +}; | |
1851 | + | |
1852 | +static GObjectClass *vim_control_parent_class; | |
1853 | + | |
1854 | +static gboolean | |
1855 | +quit_vim(gpointer data) | |
1856 | +{ | |
1857 | + MAIN_QUIT(); | |
1858 | + exit(0); | |
1859 | +} | |
1860 | + | |
1861 | +static void | |
1862 | +vim_control_destroy (BonoboObject *control) | |
1863 | +{ | |
1864 | + BonoboUIComponent *uic; | |
1865 | + | |
1866 | + g_return_if_fail (control != NULL); | |
1867 | + g_return_if_fail (VIM_IS_CONTROL (control)); | |
1868 | + | |
1869 | + g_message ("Destroying VimControl..."); | |
1870 | + | |
1871 | + uic = bonobo_control_get_ui_component (BONOBO_CONTROL (control)); | |
1872 | + if( uic != CORBA_OBJECT_NIL ) | |
1873 | + bonobo_ui_component_unset_container (uic, NULL); | |
1874 | + | |
1875 | + BONOBO_OBJECT_CLASS (vim_control_parent_class)->destroy (control); | |
1876 | + | |
1877 | + /* we only support creating one vim control per process, so when this one | |
1878 | + * is finished, we're done. */ | |
1879 | + /* BONOBO_FIXME: shut down vim cleanly! */ | |
1880 | + g_timeout_add(100, &quit_vim, NULL); | |
1881 | +} | |
1882 | + | |
1883 | +static void | |
1884 | +vim_control_finalize (GObject *object) | |
1885 | +{ | |
1886 | + VimControl *control; | |
1887 | + | |
1888 | + g_return_if_fail (object != NULL); | |
1889 | + g_return_if_fail (VIM_IS_CONTROL (object)); | |
1890 | + | |
1891 | + control = VIM_CONTROL (object); | |
1892 | + | |
1893 | + g_free (control->priv); | |
1894 | + | |
1895 | + G_OBJECT_CLASS (vim_control_parent_class)->finalize (object); | |
1896 | +} | |
1897 | + | |
1898 | +static void | |
1899 | +vim_control_set_ui_container (VimControl *control, | |
1900 | + Bonobo_UIContainer ui_container) | |
1901 | +{ | |
1902 | + BonoboUIComponent *uic; | |
1903 | + | |
1904 | + g_return_if_fail (control != NULL); | |
1905 | + g_return_if_fail (VIM_IS_CONTROL (control)); | |
1906 | + g_return_if_fail (ui_container != CORBA_OBJECT_NIL); | |
1907 | + | |
1908 | + uic = bonobo_control_get_ui_component (BONOBO_CONTROL (control)); | |
1909 | + bonobo_ui_component_set_container (uic, ui_container, NULL); | |
1910 | + | |
1911 | + /* update vim's UI now */ | |
1912 | + update_ui_later(); | |
1913 | +} | |
1914 | + | |
1915 | +static void | |
1916 | +vim_control_unset_ui_container (VimControl *control) | |
1917 | +{ | |
1918 | + BonoboUIComponent *uic; | |
1919 | + | |
1920 | + g_return_if_fail (control != NULL); | |
1921 | + g_return_if_fail (VIM_IS_CONTROL (control)); | |
1922 | + | |
1923 | + uic = bonobo_control_get_ui_component (BONOBO_CONTROL (control)); | |
1924 | + bonobo_ui_component_unset_container (uic, NULL); | |
1925 | +} | |
1926 | + | |
1927 | +static void | |
1928 | +vim_control_activate (BonoboControl *object, gboolean state) | |
1929 | +{ | |
1930 | + VimControl *control; | |
1931 | + | |
1932 | + g_return_if_fail (object != NULL); | |
1933 | + g_return_if_fail (VIM_IS_CONTROL (object)); | |
1934 | + | |
1935 | + control = VIM_CONTROL (object); | |
1936 | + | |
1937 | + if (state) { | |
1938 | + Bonobo_UIContainer ui_container; | |
1939 | + | |
1940 | + ui_container = bonobo_control_get_remote_ui_container (BONOBO_CONTROL (control), NULL); | |
1941 | + if (ui_container != CORBA_OBJECT_NIL) { | |
1942 | + vim_control_set_ui_container (control, ui_container); | |
1943 | + bonobo_object_release_unref (ui_container, NULL); | |
1944 | + } | |
1945 | + } else | |
1946 | + vim_control_unset_ui_container (control); | |
1947 | + | |
1948 | + if (BONOBO_CONTROL_CLASS (vim_control_parent_class)->activate) | |
1949 | + BONOBO_CONTROL_CLASS (vim_control_parent_class)->activate (object, state); | |
1950 | +} | |
1951 | + | |
1952 | +static void | |
1953 | +vim_control_class_init (VimControl *klass) | |
1954 | +{ | |
1955 | + GObjectClass *gobject_class = (GObjectClass *)klass; | |
1956 | + BonoboObjectClass *bonobo_object_class = (BonoboObjectClass *)klass; | |
1957 | + BonoboControlClass *control_class = (BonoboControlClass *)klass; | |
1958 | + | |
1959 | + vim_control_parent_class= g_type_class_peek_parent (klass); | |
1960 | + | |
1961 | + bonobo_object_class->destroy = vim_control_destroy; | |
1962 | + gobject_class->finalize = vim_control_finalize; | |
1963 | + control_class->activate = vim_control_activate; | |
1964 | +} | |
1965 | + | |
1966 | + | |
1967 | +static gint | |
1968 | +load_vim_from_file (BonoboPersistFile *pf, const CORBA_char *text_uri, | |
1969 | + CORBA_Environment *ev, void *closure) | |
1970 | +{ | |
1971 | + return 0; | |
1972 | +} | |
1973 | + | |
1974 | +static void | |
1975 | +nv_load_location_cb (NautilusView *view, const char *location, gpointer user_data) | |
1976 | +{ | |
1977 | + g_return_if_fail (NAUTILUS_IS_VIEW (view)); | |
1978 | + g_return_if_fail (location != NULL); | |
1979 | + | |
1980 | + nautilus_view_report_load_underway (NAUTILUS_VIEW (view)); | |
1981 | + | |
1982 | + /* FIXME: load the file here (using gnome-vfs)! */ | |
1983 | + nautilus_view_report_load_complete (NAUTILUS_VIEW (view)); | |
1984 | +} | |
1985 | + | |
1986 | +static void | |
1987 | +vim_control_init (VimControl *control) | |
1988 | +{ | |
1989 | + control->priv = g_new0 (VimControlPrivate, 1); | |
1990 | +} | |
1991 | + | |
1992 | +BONOBO_TYPE_FUNC (VimControl, BONOBO_TYPE_CONTROL, vim_control); | |
1993 | + | |
1994 | +BonoboObject * | |
1995 | +vim_control_add_interfaces (VimControl *control, | |
1996 | + BonoboObject *to_aggregate) | |
1997 | +{ | |
1998 | + BonoboPersistFile *file; | |
1999 | + NautilusView *nv; | |
2000 | + //BonoboPersistStream *stream; | |
2001 | + //BonoboItemContainer *item_container; | |
2002 | + | |
2003 | + g_return_val_if_fail (VIM_IS_CONTROL (control), NULL); | |
2004 | + g_return_val_if_fail (BONOBO_IS_OBJECT (to_aggregate), NULL); | |
2005 | + | |
2006 | + /* Interface Bonobo::PersistFile */ | |
2007 | + file = bonobo_persist_file_new (load_vim_from_file, | |
2008 | + NULL, "OAFIID:GNOME_Vim_Control", control); | |
2009 | + if (!file) { | |
2010 | + bonobo_object_unref (BONOBO_OBJECT (to_aggregate)); | |
2011 | + return NULL; | |
2012 | + } | |
2013 | + | |
2014 | + bonobo_object_add_interface (BONOBO_OBJECT (to_aggregate), | |
2015 | + BONOBO_OBJECT (file)); | |
2016 | + | |
2017 | + nv = nautilus_view_new_from_bonobo_control(BONOBO_CONTROL(control)); | |
2018 | + if( !nv ) { | |
2019 | + bonobo_object_unref (BONOBO_OBJECT(to_aggregate)); | |
2020 | + return NULL; | |
2021 | + } | |
2022 | + bonobo_object_add_interface (BONOBO_OBJECT (to_aggregate), | |
2023 | + BONOBO_OBJECT (nv)); | |
2024 | + | |
2025 | + g_signal_connect (G_OBJECT (nv), "load_location", | |
2026 | + G_CALLBACK (nv_load_location_cb), NULL); | |
2027 | + | |
2028 | + return to_aggregate; | |
2029 | +} | |
2030 | + | |
2031 | +static gint | |
2032 | +key_press_event(GtkAccelGroup * group, GObject * acceleratable, guint keyval, GdkModifierType mod) | |
2033 | +{ | |
2034 | + printf("accel key pressed: %d %d!\n", keyval, mod); | |
2035 | + return FALSE; | |
2036 | +} | |
2037 | + | |
2038 | + | |
2039 | +VimControl * | |
2040 | +vim_control_construct (VimControl *control) | |
2041 | +{ | |
2042 | + GtkWidget *button; | |
2043 | + GtkWidget *label; | |
2044 | + BonoboPlug *plug; | |
2045 | + GtkAccelGroup *group; | |
2046 | + GClosure *closure; | |
2047 | + //VimControlPrivate *priv; | |
2048 | + | |
2049 | + g_return_val_if_fail (control != NULL, NULL); | |
2050 | + g_return_val_if_fail (VIM_IS_CONTROL (control), NULL); | |
2051 | + | |
2052 | + | |
2053 | + if (!vim_control_add_interfaces (control, BONOBO_OBJECT (control))) | |
2054 | + return NULL; | |
2055 | + | |
2056 | + gui.control = BONOBO_CONTROL(control); | |
2057 | + gui_mch_init(); | |
2058 | + | |
2059 | + /* Create the vim-view */ | |
2060 | + //priv->image_view = vim_image_view_new (vim, FALSE); | |
2061 | + //if (!priv->image_view) { | |
2062 | + //bonobo_object_unref (BONOBO_OBJECT (control)); | |
2063 | + //return NULL; | |
2064 | + //} | |
2065 | + | |
2066 | + | |
2067 | + bonobo_control_construct (BONOBO_CONTROL (control), GTK_WIDGET(gui.vbox)); | |
2068 | + | |
2069 | + group = gtk_accel_group_new(); | |
2070 | + plug = (BonoboPlug *)bonobo_control_get_plug(control); | |
2071 | + gtk_window_add_accel_group(GTK_WINDOW(plug), group); | |
2072 | + closure = g_cclosure_new (G_CALLBACK (key_press_event), NULL, (GClosureNotify)g_free); | |
2073 | + gtk_accel_group_connect(group, GDK_Escape, 0, 0, closure); | |
2074 | + closure = g_cclosure_new (G_CALLBACK (key_press_event), NULL, (GClosureNotify)g_free); | |
2075 | + gtk_accel_group_connect(group, GDK_n, GDK_CONTROL_MASK, 0, closure); | |
2076 | + | |
2077 | + return control; | |
2078 | +} | |
2079 | + | |
2080 | +VimControl * | |
2081 | +vim_control_new (void) | |
2082 | +{ | |
2083 | + VimControl *control; | |
2084 | + | |
2085 | + g_message ("Creating VimControl..."); | |
2086 | + | |
2087 | + control = g_object_new (VIM_CONTROL_TYPE, NULL); | |
2088 | + | |
2089 | + return vim_control_construct (control); | |
2090 | +} | |
2091 | + | |
2092 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/vim_bonobo_control.h vim/src/vim_bonobo_control.h | |
2093 | --- vimcopy/src/vim_bonobo_control.h Wed Dec 31 18:00:00 1969 | |
2094 | +++ vim/src/vim_bonobo_control.h Fri Mar 21 23:22:34 2003 | |
2095 | @@ -0,0 +1,44 @@ | |
2096 | +/* | |
2097 | + * vim_bonobo_control.h | |
2098 | + * | |
2099 | + * Author: | |
2100 | + * Jason Hildebrand (jason@peaceworks.ca) | |
2101 | + * | |
2102 | + */ | |
2103 | + | |
2104 | +#ifndef _VIM_CONTROL_H_ | |
2105 | +#define _VIM_CONTROL_H_ | |
2106 | + | |
2107 | +#include <bonobo/bonobo-control.h> | |
2108 | + | |
2109 | +G_BEGIN_DECLS | |
2110 | + | |
2111 | +#define VIM_CONTROL_TYPE (vim_control_get_type ()) | |
2112 | +#define VIM_CONTROL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), VIM_CONTROL_TYPE, VimControl)) | |
2113 | +#define VIM_CONTROL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), VIM_CONTROL_TYPE, VimControlClass)) | |
2114 | + | |
2115 | +#define VIM_IS_CONTROL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), VIM_CONTROL_TYPE)) | |
2116 | +#define VIM_IS_CONTROL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), VIM_CONTROL_TYPE)) | |
2117 | +#define VIM_CONTROL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), VIM_CONTROL_TYPE, VimControlClass)) | |
2118 | + | |
2119 | +typedef struct _VimControl VimControl; | |
2120 | +typedef struct _VimControlClass VimControlClass; | |
2121 | +typedef struct _VimControlPrivate VimControlPrivate; | |
2122 | + | |
2123 | +struct _VimControl { | |
2124 | + BonoboControl control; | |
2125 | + | |
2126 | + VimControlPrivate *priv; | |
2127 | +}; | |
2128 | + | |
2129 | +struct _VimControlClass { | |
2130 | + BonoboControlClass parent_class; | |
2131 | +}; | |
2132 | + | |
2133 | +GType vim_control_get_type (void); | |
2134 | +VimControl *vim_control_new (void); | |
2135 | +VimControl *vim_control_construct (VimControl *control); | |
2136 | + | |
2137 | +G_END_DECLS | |
2138 | + | |
2139 | +#endif /* _VIM_CONTROL_H_*/ | |
2140 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/vim_bonobo_factory.c vim/src/vim_bonobo_factory.c | |
2141 | --- vimcopy/src/vim_bonobo_factory.c Wed Dec 31 18:00:00 1969 | |
2142 | +++ vim/src/vim_bonobo_factory.c Fri Mar 21 23:22:34 2003 | |
2143 | @@ -0,0 +1,75 @@ | |
2144 | +/* | |
2145 | + * vim_bonobo_factory.c | |
2146 | + * | |
2147 | + * Author: | |
2148 | + * Jason Hildebrand (jason@peaceworks.ca) | |
2149 | + * | |
2150 | + */ | |
2151 | + | |
2152 | +#include "vim.h" | |
2153 | +#include "version.h" | |
2154 | +#include <bonobo/bonobo-generic-factory.h> | |
2155 | +#include "vim_bonobo_control.h" | |
2156 | + | |
2157 | +static BonoboGenericFactory *factory = NULL; | |
2158 | +static int vim_instantiated = 0; | |
2159 | + | |
2160 | +static BonoboObject * | |
2161 | +vim_bonobo_factory(BonoboGenericFactory *this, | |
2162 | + const char *oaf_iid, | |
2163 | + void *data) | |
2164 | +{ | |
2165 | + VimControl *vim; | |
2166 | + BonoboObject *retval; | |
2167 | + | |
2168 | + g_return_val_if_fail (this != NULL, NULL); | |
2169 | + g_return_val_if_fail (oaf_iid != NULL, NULL); | |
2170 | + | |
2171 | + if( vim_instantiated ) { | |
2172 | + /* we cannot instantiate more than one control from this process, | |
2173 | + * because of all of vim's global variables */ | |
2174 | + return NULL; | |
2175 | + } | |
2176 | + | |
2177 | + g_message ("Trying to produce a '%s'...", oaf_iid); | |
2178 | + | |
2179 | + if (strcmp (oaf_iid, "OAFIID:Vim_Control") == 0) { | |
2180 | + vim = vim_control_new (); | |
2181 | + if (vim == NULL) | |
2182 | + return NULL; | |
2183 | + retval = BONOBO_OBJECT (vim); | |
2184 | + } else { | |
2185 | + g_warning ("Unknown IID `%s' requested", oaf_iid); | |
2186 | + return NULL; | |
2187 | + } | |
2188 | + vim_instantiated = 1; | |
2189 | + | |
2190 | + return retval; | |
2191 | +} | |
2192 | + | |
2193 | +/* wait until this component is instantiated */ | |
2194 | +int vim_bonobo_wait_for_instantiation() | |
2195 | +{ | |
2196 | + while( !vim_instantiated) { | |
2197 | + MAIN_ITERATION_DO(TRUE); | |
2198 | + } | |
2199 | +} | |
2200 | + | |
2201 | + | |
2202 | +void vim_bonobo_init(int *argc, char *argv[]) | |
2203 | +{ | |
2204 | + if (!bonobo_ui_init ("gnome-vim", VIM_VERSION_SHORT, argc, argv)) | |
2205 | + g_error (_("Could not initialize Bonobo")); | |
2206 | + | |
2207 | + factory = bonobo_generic_factory_new ( | |
2208 | + "OAFIID:Vim_Control_Factory", vim_bonobo_factory, NULL); | |
2209 | + | |
2210 | + if (factory == NULL) { | |
2211 | + g_error ("Couldn't create factory.\n"); | |
2212 | + | |
2213 | + /* in component mode, we don't care about trying to continue without | |
2214 | + * a gui; if we can't create the factory, we might as well quit. */ | |
2215 | + mch_exit(2); | |
2216 | + } | |
2217 | +} | |
2218 | + | |
2219 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/vim_bonobo_factory.h vim/src/vim_bonobo_factory.h | |
2220 | --- vimcopy/src/vim_bonobo_factory.h Wed Dec 31 18:00:00 1969 | |
2221 | +++ vim/src/vim_bonobo_factory.h Fri Mar 21 23:22:34 2003 | |
2222 | @@ -0,0 +1,15 @@ | |
2223 | +/* | |
2224 | + * vim_bonobo_factory.h | |
2225 | + * | |
2226 | + * Author: | |
2227 | + * Jason Hildebrand (jason@peaceworks.ca) | |
2228 | + * | |
2229 | + */ | |
2230 | + | |
2231 | +#if !defined( _VIM_BONOBO_FACTORY_H) | |
2232 | +#define _VIM_BONOBO_FACTORY_H | |
2233 | + | |
2234 | +void gui_component_init(int *argc, char *argv []); | |
2235 | +int gui_component_wait_for_instantiation(void); | |
2236 | + | |
2237 | +#endif | |
2238 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/vim_bonobo_main.c vim/src/vim_bonobo_main.c | |
2239 | --- vimcopy/src/vim_bonobo_main.c Wed Dec 31 18:00:00 1969 | |
2240 | +++ vim/src/vim_bonobo_main.c Fri Mar 21 23:22:34 2003 | |
2241 | @@ -0,0 +1,60 @@ | |
2242 | +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ | |
2243 | + | |
2244 | +#include <glib/gmain.h> | |
2245 | +#include <glib-object.h> | |
2246 | + | |
2247 | +static guint bonobo_main_loop_level = 0; | |
2248 | +static GSList * bonobo_main_loops = NULL; | |
2249 | + | |
2250 | + | |
2251 | +/** | |
2252 | + * bonobo_main: | |
2253 | + * | |
2254 | + * Activates the Bonobo POA Manager and enters the main event loop. | |
2255 | + */ | |
2256 | +void | |
2257 | +vim_bonobo_main (void) | |
2258 | +{ | |
2259 | + GMainLoop *loop; | |
2260 | + | |
2261 | + bonobo_activate (); | |
2262 | + | |
2263 | + bonobo_main_loop_level++; | |
2264 | + | |
2265 | + loop = g_main_loop_new (NULL, TRUE); | |
2266 | + bonobo_main_loops = g_slist_prepend (bonobo_main_loops, loop); | |
2267 | + | |
2268 | + if (g_main_loop_is_running (bonobo_main_loops->data)) | |
2269 | + g_main_loop_run (loop); | |
2270 | + | |
2271 | + bonobo_main_loops = g_slist_remove (bonobo_main_loops, loop); | |
2272 | + | |
2273 | + g_main_loop_unref (loop); | |
2274 | + | |
2275 | + bonobo_main_loop_level--; | |
2276 | +} | |
2277 | + | |
2278 | +/** | |
2279 | + * bonobo_main_quit: | |
2280 | + * | |
2281 | + * Quits the main event loop. | |
2282 | + */ | |
2283 | +void | |
2284 | +vim_bonobo_main_quit (void) | |
2285 | +{ | |
2286 | + g_return_if_fail (bonobo_main_loops != NULL); | |
2287 | + | |
2288 | + g_main_loop_quit (bonobo_main_loops->data); | |
2289 | +} | |
2290 | + | |
2291 | +int | |
2292 | +vim_bonobo_main_level(void) | |
2293 | +{ | |
2294 | + return bonobo_main_loop_level; | |
2295 | +} | |
2296 | + | |
2297 | +gboolean | |
2298 | +vim_bonobo_main_iteration_do(may_block) | |
2299 | +{ | |
2300 | + g_main_context_iteration(NULL, may_block); | |
2301 | +} | |
2302 | diff --new-file -u -r --exclude-from=excludelist vimcopy/src/vim_bonobo_main.h vim/src/vim_bonobo_main.h | |
2303 | --- vimcopy/src/vim_bonobo_main.h Wed Dec 31 18:00:00 1969 | |
2304 | +++ vim/src/vim_bonobo_main.h Sat Mar 22 11:10:00 2003 | |
2305 | @@ -0,0 +1,14 @@ | |
2306 | +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ | |
2307 | + | |
2308 | +#ifndef __VIM_BONOBO_MAIN_H__ | |
2309 | +#define __VIM_BONOBO_MAIN_H__ | |
2310 | + | |
2311 | +#include <glib-object.h> | |
2312 | +#include <bonobo/Bonobo.h> | |
2313 | + | |
2314 | +void vim_bonobo_main (void); | |
2315 | +void vim_bonobo_main_quit (void); | |
2316 | +int vim_bonobo_level(void); | |
2317 | +gboolean vim_bonobo_main_iteration_do(int may_block); | |
2318 | + | |
2319 | +#endif /* __VIM_BONOBO_MAIN_H__ */ | |
2320 | Binary files vimcopy/src/xxd/xxd and vim/src/xxd/xxd differ | |
2321 | diff --new-file -u -r --exclude-from=excludelist vimcopy/vim/src/Make_container.mak vim/vim/src/Make_container.mak | |
2322 | --- vimcopy/vim/src/Make_container.mak Wed Dec 31 18:00:00 1969 | |
2323 | +++ vim/vim/src/Make_container.mak Fri Mar 21 23:22:34 2003 | |
2324 | @@ -0,0 +1,11 @@ | |
2325 | +gnomeccFlags = `pkg-config --cflags libgnomeui-2.0 libgnome-2.0` | |
2326 | +ccFlags = -g -c ${gnomeccFlags} | |
2327 | +ldFlags = `pkg-config --libs libgnomeui-2.0 libgnome-2.0` | |
2328 | + | |
2329 | +all: container | |
2330 | + | |
2331 | +container: container.o | |
2332 | + gcc -o container ${ldFlags} container.o | |
2333 | + | |
2334 | +%.o: %.c | |
2335 | + gcc ${ccFlags} $< -o $@ |