Skip to content
Snippets Groups Projects
Commit a76638f4 authored by Bram Moolenaar's avatar Bram Moolenaar
Browse files

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)
parent 2c704a77
No related branches found
No related tags found
No related merge requests found
...@@ -1444,6 +1444,10 @@ selection_received_cb(GtkWidget *widget UNUSED, ...@@ -1444,6 +1444,10 @@ selection_received_cb(GtkWidget *widget UNUSED,
} }
#endif /* !HAVE_GTK2 */ #endif /* !HAVE_GTK2 */
/* Chop off any traiing NUL bytes. OpenOffice sends these. */
while (len > 0 && text[len - 1] == NUL)
--len;
clip_yank_selection(motion_type, text, (long)len, cbd); clip_yank_selection(motion_type, text, (long)len, cbd);
received_selection = RS_OK; received_selection = RS_OK;
vim_free(tmpbuf); vim_free(tmpbuf);
...@@ -3473,6 +3477,66 @@ gui_mch_set_curtab(nr) ...@@ -3473,6 +3477,66 @@ gui_mch_set_curtab(nr)
#endif /* FEAT_GUI_TABLINE */ #endif /* FEAT_GUI_TABLINE */
/*
* Add selection targets for PRIMARY and CLIPBOARD selections.
*/
void
gui_gtk_set_selection_targets(void)
{
int i, j = 0;
int n_targets = N_SELECTION_TARGETS;
GtkTargetEntry targets[N_SELECTION_TARGETS];
for (i = 0; i < (int)N_SELECTION_TARGETS; ++i)
{
#ifdef FEAT_MBYTE
/* OpenOffice tries to use TARGET_HTML and fails when it doesn't
* return something, instead of trying another target. Therefore only
* offer TARGET_HTML when it works. */
if (!clip_html && selection_targets[i].info == TARGET_HTML)
n_targets--;
else
#endif
targets[j++] = selection_targets[i];
}
gtk_selection_clear_targets(gui.drawarea, (GdkAtom)GDK_SELECTION_PRIMARY);
gtk_selection_clear_targets(gui.drawarea, (GdkAtom)clip_plus.gtk_sel_atom);
gtk_selection_add_targets(gui.drawarea,
(GdkAtom)GDK_SELECTION_PRIMARY,
targets, n_targets);
gtk_selection_add_targets(gui.drawarea,
(GdkAtom)clip_plus.gtk_sel_atom,
targets, n_targets);
}
/*
* Set up for receiving DND items.
*/
void
gui_gtk_set_dnd_targets(void)
{
int i, j = 0;
int n_targets = N_DND_TARGETS;
GtkTargetEntry targets[N_DND_TARGETS];
for (i = 0; i < (int)N_DND_TARGETS; ++i)
{
#ifdef FEAT_MBYTE
if (!clip_html && selection_targets[i].info == TARGET_HTML)
n_targets--;
else
#endif
targets[j++] = dnd_targets[i];
}
gtk_drag_dest_unset(gui.drawarea);
gtk_drag_dest_set(gui.drawarea,
GTK_DEST_DEFAULT_ALL,
targets, n_targets,
GDK_ACTION_COPY);
}
/* /*
* Initialize the GUI. Create all the windows, set up all the callbacks etc. * Initialize the GUI. Create all the windows, set up all the callbacks etc.
* Returns OK for success, FAIL when the GUI can't be started. * Returns OK for success, FAIL when the GUI can't be started.
...@@ -3936,15 +4000,7 @@ gui_mch_init(void) ...@@ -3936,15 +4000,7 @@ gui_mch_init(void)
gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_received", gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_received",
GTK_SIGNAL_FUNC(selection_received_cb), NULL); GTK_SIGNAL_FUNC(selection_received_cb), NULL);
/* gui_gtk_set_selection_targets();
* Add selection targets for PRIMARY and CLIPBOARD selections.
*/
gtk_selection_add_targets(gui.drawarea,
(GdkAtom)GDK_SELECTION_PRIMARY,
selection_targets, N_SELECTION_TARGETS);
gtk_selection_add_targets(gui.drawarea,
(GdkAtom)clip_plus.gtk_sel_atom,
selection_targets, N_SELECTION_TARGETS);
gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_get", gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_get",
GTK_SIGNAL_FUNC(selection_get_cb), NULL); GTK_SIGNAL_FUNC(selection_get_cb), NULL);
...@@ -4068,7 +4124,6 @@ check_startup_plug_hints(gpointer data UNUSED) ...@@ -4068,7 +4124,6 @@ check_startup_plug_hints(gpointer data UNUSED)
return TRUE; return TRUE;
} }
/* /*
* Open the GUI window which was created by a call to gui_mch_init(). * Open the GUI window which was created by a call to gui_mch_init().
*/ */
...@@ -4236,13 +4291,8 @@ gui_mch_open(void) ...@@ -4236,13 +4291,8 @@ gui_mch_open(void)
GTK_SIGNAL_FUNC(form_configure_event), NULL); GTK_SIGNAL_FUNC(form_configure_event), NULL);
#ifdef FEAT_DND #ifdef FEAT_DND
/* /* Set up for receiving DND items. */
* Set up for receiving DND items. gui_gtk_set_dnd_targets();
*/
gtk_drag_dest_set(gui.drawarea,
GTK_DEST_DEFAULT_ALL,
dnd_targets, N_DND_TARGETS,
GDK_ACTION_COPY);
gtk_signal_connect(GTK_OBJECT(gui.drawarea), "drag_data_received", gtk_signal_connect(GTK_OBJECT(gui.drawarea), "drag_data_received",
GTK_SIGNAL_FUNC(drag_data_received_cb), NULL); GTK_SIGNAL_FUNC(drag_data_received_cb), NULL);
......
...@@ -7149,6 +7149,13 @@ check_clipboard_option() ...@@ -7149,6 +7149,13 @@ check_clipboard_option()
clip_html = new_html; clip_html = new_html;
vim_free(clip_exclude_prog); vim_free(clip_exclude_prog);
clip_exclude_prog = new_exclude_prog; clip_exclude_prog = new_exclude_prog;
#ifdef FEAT_GUI_GTK
if (gui.in_use)
{
gui_gtk_set_selection_targets();
gui_gtk_set_dnd_targets();
}
#endif
} }
else else
vim_free(new_exclude_prog); vim_free(new_exclude_prog);
......
...@@ -9,6 +9,8 @@ void gui_mch_show_tabline __ARGS((int showit)); ...@@ -9,6 +9,8 @@ void gui_mch_show_tabline __ARGS((int showit));
int gui_mch_showing_tabline __ARGS((void)); int gui_mch_showing_tabline __ARGS((void));
void gui_mch_update_tabline __ARGS((void)); void gui_mch_update_tabline __ARGS((void));
void gui_mch_set_curtab __ARGS((int nr)); void gui_mch_set_curtab __ARGS((int nr));
void gui_gtk_set_selection_targets __ARGS((void));
void gui_gtk_set_dnd_targets __ARGS((void));
int gui_mch_init __ARGS((void)); int gui_mch_init __ARGS((void));
void gui_mch_forked __ARGS((void)); void gui_mch_forked __ARGS((void));
void gui_mch_new_colors __ARGS((void)); void gui_mch_new_colors __ARGS((void));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment