Mercurial > vim
comparison src/gui_gtk_x11.c @ 2183:b0ebf9d121ff v7.2.442
updated for version 7.2.442
Problem: Copy/paste with OpenOffice doesn't work.
Solution: Do not offer the HTML target when it is not supported. (James
Vega)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 05 Jun 2010 12:49:46 +0200 |
parents | 733f0dc510c3 |
children | dc8ee74574f8 |
comparison
equal
deleted
inserted
replaced
2181:f838615313cd | 2183:b0ebf9d121ff |
---|---|
1431 if (list != NULL) | 1431 if (list != NULL) |
1432 gdk_free_text_list(list); | 1432 gdk_free_text_list(list); |
1433 } | 1433 } |
1434 #endif /* !HAVE_GTK2 */ | 1434 #endif /* !HAVE_GTK2 */ |
1435 | 1435 |
1436 /* Chop off any traiing NUL bytes. OpenOffice sends these. */ | |
1437 while (len > 0 && text[len - 1] == NUL) | |
1438 --len; | |
1439 | |
1436 clip_yank_selection(motion_type, text, (long)len, cbd); | 1440 clip_yank_selection(motion_type, text, (long)len, cbd); |
1437 received_selection = RS_OK; | 1441 received_selection = RS_OK; |
1438 vim_free(tmpbuf); | 1442 vim_free(tmpbuf); |
1439 #ifdef HAVE_GTK2 | 1443 #ifdef HAVE_GTK2 |
1440 g_free(tmpbuf_utf8); | 1444 g_free(tmpbuf_utf8); |
3461 } | 3465 } |
3462 | 3466 |
3463 #endif /* FEAT_GUI_TABLINE */ | 3467 #endif /* FEAT_GUI_TABLINE */ |
3464 | 3468 |
3465 /* | 3469 /* |
3470 * Add selection targets for PRIMARY and CLIPBOARD selections. | |
3471 */ | |
3472 void | |
3473 gui_gtk_set_selection_targets(void) | |
3474 { | |
3475 int i, j = 0; | |
3476 int n_targets = N_SELECTION_TARGETS; | |
3477 GtkTargetEntry targets[N_SELECTION_TARGETS]; | |
3478 | |
3479 for (i = 0; i < (int)N_SELECTION_TARGETS; ++i) | |
3480 { | |
3481 #ifdef FEAT_MBYTE | |
3482 /* OpenOffice tries to use TARGET_HTML and fails when it doesn't | |
3483 * return something, instead of trying another target. Therefore only | |
3484 * offer TARGET_HTML when it works. */ | |
3485 if (!clip_html && selection_targets[i].info == TARGET_HTML) | |
3486 n_targets--; | |
3487 else | |
3488 #endif | |
3489 targets[j++] = selection_targets[i]; | |
3490 } | |
3491 | |
3492 gtk_selection_clear_targets(gui.drawarea, (GdkAtom)GDK_SELECTION_PRIMARY); | |
3493 gtk_selection_clear_targets(gui.drawarea, (GdkAtom)clip_plus.gtk_sel_atom); | |
3494 gtk_selection_add_targets(gui.drawarea, | |
3495 (GdkAtom)GDK_SELECTION_PRIMARY, | |
3496 targets, n_targets); | |
3497 gtk_selection_add_targets(gui.drawarea, | |
3498 (GdkAtom)clip_plus.gtk_sel_atom, | |
3499 targets, n_targets); | |
3500 } | |
3501 | |
3502 /* | |
3503 * Set up for receiving DND items. | |
3504 */ | |
3505 void | |
3506 gui_gtk_set_dnd_targets(void) | |
3507 { | |
3508 int i, j = 0; | |
3509 int n_targets = N_DND_TARGETS; | |
3510 GtkTargetEntry targets[N_DND_TARGETS]; | |
3511 | |
3512 for (i = 0; i < (int)N_DND_TARGETS; ++i) | |
3513 { | |
3514 #ifdef FEAT_MBYTE | |
3515 if (!clip_html && selection_targets[i].info == TARGET_HTML) | |
3516 n_targets--; | |
3517 else | |
3518 #endif | |
3519 targets[j++] = dnd_targets[i]; | |
3520 } | |
3521 | |
3522 gtk_drag_dest_unset(gui.drawarea); | |
3523 gtk_drag_dest_set(gui.drawarea, | |
3524 GTK_DEST_DEFAULT_ALL, | |
3525 targets, n_targets, | |
3526 GDK_ACTION_COPY); | |
3527 } | |
3528 | |
3529 /* | |
3466 * Initialize the GUI. Create all the windows, set up all the callbacks etc. | 3530 * Initialize the GUI. Create all the windows, set up all the callbacks etc. |
3467 * Returns OK for success, FAIL when the GUI can't be started. | 3531 * Returns OK for success, FAIL when the GUI can't be started. |
3468 */ | 3532 */ |
3469 int | 3533 int |
3470 gui_mch_init(void) | 3534 gui_mch_init(void) |
3923 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_clear_event", | 3987 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_clear_event", |
3924 GTK_SIGNAL_FUNC(selection_clear_event), NULL); | 3988 GTK_SIGNAL_FUNC(selection_clear_event), NULL); |
3925 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_received", | 3989 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_received", |
3926 GTK_SIGNAL_FUNC(selection_received_cb), NULL); | 3990 GTK_SIGNAL_FUNC(selection_received_cb), NULL); |
3927 | 3991 |
3928 /* | 3992 gui_gtk_set_selection_targets(); |
3929 * Add selection targets for PRIMARY and CLIPBOARD selections. | |
3930 */ | |
3931 gtk_selection_add_targets(gui.drawarea, | |
3932 (GdkAtom)GDK_SELECTION_PRIMARY, | |
3933 selection_targets, N_SELECTION_TARGETS); | |
3934 gtk_selection_add_targets(gui.drawarea, | |
3935 (GdkAtom)clip_plus.gtk_sel_atom, | |
3936 selection_targets, N_SELECTION_TARGETS); | |
3937 | 3993 |
3938 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_get", | 3994 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_get", |
3939 GTK_SIGNAL_FUNC(selection_get_cb), NULL); | 3995 GTK_SIGNAL_FUNC(selection_get_cb), NULL); |
3940 | 3996 |
3941 /* Pretend we don't have input focus, we will get an event if we do. */ | 3997 /* Pretend we don't have input focus, we will get an event if we do. */ |
4054 | 4110 |
4055 /* Keep on trying */ | 4111 /* Keep on trying */ |
4056 init_window_hints_state = 1; | 4112 init_window_hints_state = 1; |
4057 return TRUE; | 4113 return TRUE; |
4058 } | 4114 } |
4059 | |
4060 | 4115 |
4061 /* | 4116 /* |
4062 * Open the GUI window which was created by a call to gui_mch_init(). | 4117 * Open the GUI window which was created by a call to gui_mch_init(). |
4063 */ | 4118 */ |
4064 int | 4119 int |
4223 */ | 4278 */ |
4224 gtk_signal_connect(GTK_OBJECT(gui.formwin), "configure_event", | 4279 gtk_signal_connect(GTK_OBJECT(gui.formwin), "configure_event", |
4225 GTK_SIGNAL_FUNC(form_configure_event), NULL); | 4280 GTK_SIGNAL_FUNC(form_configure_event), NULL); |
4226 | 4281 |
4227 #ifdef FEAT_DND | 4282 #ifdef FEAT_DND |
4228 /* | 4283 /* Set up for receiving DND items. */ |
4229 * Set up for receiving DND items. | 4284 gui_gtk_set_dnd_targets(); |
4230 */ | |
4231 gtk_drag_dest_set(gui.drawarea, | |
4232 GTK_DEST_DEFAULT_ALL, | |
4233 dnd_targets, N_DND_TARGETS, | |
4234 GDK_ACTION_COPY); | |
4235 | 4285 |
4236 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "drag_data_received", | 4286 gtk_signal_connect(GTK_OBJECT(gui.drawarea), "drag_data_received", |
4237 GTK_SIGNAL_FUNC(drag_data_received_cb), NULL); | 4287 GTK_SIGNAL_FUNC(drag_data_received_cb), NULL); |
4238 #endif | 4288 #endif |
4239 | 4289 |
4426 | 4476 |
4427 #ifndef HAVE_GTK2 | 4477 #ifndef HAVE_GTK2 |
4428 /* this will cause the proper resizement to happen too */ | 4478 /* this will cause the proper resizement to happen too */ |
4429 update_window_manager_hints(0, 0); | 4479 update_window_manager_hints(0, 0); |
4430 | 4480 |
4431 #else /* HAVE_GTK2 */ | 4481 #else |
4432 /* this will cause the proper resizement to happen too */ | 4482 /* this will cause the proper resizement to happen too */ |
4433 if (gtk_socket_id == 0) | 4483 if (gtk_socket_id == 0) |
4434 update_window_manager_hints(0, 0); | 4484 update_window_manager_hints(0, 0); |
4435 | 4485 |
4436 /* With GTK+ 2, changing the size of the form widget doesn't resize | 4486 /* With GTK+ 2, changing the size of the form widget doesn't resize |
4442 if (gtk_socket_id == 0) | 4492 if (gtk_socket_id == 0) |
4443 gtk_window_resize(GTK_WINDOW(gui.mainwin), width, height); | 4493 gtk_window_resize(GTK_WINDOW(gui.mainwin), width, height); |
4444 else | 4494 else |
4445 update_window_manager_hints(width, height); | 4495 update_window_manager_hints(width, height); |
4446 | 4496 |
4447 #if 0 | 4497 # if 0 |
4448 if (!resize_idle_installed) | 4498 if (!resize_idle_installed) |
4449 { | 4499 { |
4450 g_idle_add_full(GDK_PRIORITY_EVENTS + 10, | 4500 g_idle_add_full(GDK_PRIORITY_EVENTS + 10, |
4451 &force_shell_resize_idle, NULL, NULL); | 4501 &force_shell_resize_idle, NULL, NULL); |
4452 resize_idle_installed = TRUE; | 4502 resize_idle_installed = TRUE; |
4453 } | 4503 } |
4454 #endif | 4504 # endif |
4455 /* | 4505 /* |
4456 * Wait until all events are processed to prevent a crash because the | 4506 * Wait until all events are processed to prevent a crash because the |
4457 * real size of the drawing area doesn't reflect Vim's internal ideas. | 4507 * real size of the drawing area doesn't reflect Vim's internal ideas. |
4458 * | 4508 * |
4459 * This is a bit of a hack, since Vim is a terminal application with a GUI | 4509 * This is a bit of a hack, since Vim is a terminal application with a GUI |