Work around copying bug in WebKitGTK+
Fixes: https://bugs.launchpad.net/midori/+bug/707888
This commit is contained in:
parent
de0ede905f
commit
fb9629c1aa
4 changed files with 31 additions and 18 deletions
|
@ -2443,6 +2443,15 @@ _action_copy_activate (GtkAction* action,
|
|||
MidoriBrowser* browser)
|
||||
{
|
||||
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
|
||||
/* Work around broken clipboard handling for the sake of the user */
|
||||
if (WEBKIT_IS_WEB_VIEW (widget))
|
||||
{
|
||||
GtkWidget* scrolled = gtk_widget_get_parent (widget);
|
||||
GtkWidget* view = gtk_widget_get_parent (scrolled);
|
||||
const gchar* selected = midori_view_get_selected_text (MIDORI_VIEW (view));
|
||||
sokoke_widget_copy_clipboard (widget, selected);
|
||||
return;
|
||||
}
|
||||
if (G_LIKELY (widget) && g_signal_lookup ("copy-clipboard", G_OBJECT_TYPE (widget)))
|
||||
g_signal_emit_by_name (widget, "copy-clipboard");
|
||||
}
|
||||
|
|
|
@ -1973,19 +1973,6 @@ gtk_widget_scroll_event_cb (WebKitWebView* web_view,
|
|||
}
|
||||
|
||||
#if WEBKIT_CHECK_VERSION (1, 1, 15)
|
||||
static void
|
||||
midori_web_view_set_clipboard (GtkWidget* widget,
|
||||
const gchar* text)
|
||||
{
|
||||
GdkDisplay* display = gtk_widget_get_display (widget);
|
||||
GtkClipboard* clipboard;
|
||||
|
||||
clipboard = gtk_clipboard_get_for_display (display, GDK_SELECTION_CLIPBOARD);
|
||||
gtk_clipboard_set_text (clipboard, text, -1);
|
||||
clipboard = gtk_clipboard_get_for_display (display, GDK_SELECTION_PRIMARY);
|
||||
gtk_clipboard_set_text (clipboard, text, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
midori_web_view_menu_new_window_activate_cb (GtkWidget* widget,
|
||||
MidoriView* view)
|
||||
|
@ -2005,9 +1992,9 @@ midori_web_view_menu_link_copy_activate_cb (GtkWidget* widget,
|
|||
MidoriView* view)
|
||||
{
|
||||
if (g_str_has_prefix (view->link_uri, "mailto:"))
|
||||
midori_web_view_set_clipboard (widget, view->link_uri + 7);
|
||||
sokoke_widget_copy_clipboard (widget, view->link_uri + 7);
|
||||
else
|
||||
midori_web_view_set_clipboard (widget, view->link_uri);
|
||||
sokoke_widget_copy_clipboard (widget, view->link_uri);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2037,7 +2024,7 @@ midori_web_view_menu_image_copy_activate_cb (GtkWidget* widget,
|
|||
MidoriView* view)
|
||||
{
|
||||
gchar* uri = katze_object_get_string (view->hit_test, "image-uri");
|
||||
midori_web_view_set_clipboard (widget, uri);
|
||||
sokoke_widget_copy_clipboard (widget, uri);
|
||||
g_free (uri);
|
||||
}
|
||||
|
||||
|
@ -2060,7 +2047,7 @@ midori_web_view_menu_video_copy_activate_cb (GtkWidget* widget,
|
|||
MidoriView* view)
|
||||
{
|
||||
gchar* uri = katze_object_get_string (view->hit_test, "media-uri");
|
||||
midori_web_view_set_clipboard (widget, uri);
|
||||
sokoke_widget_copy_clipboard (widget, uri);
|
||||
g_free (uri);
|
||||
}
|
||||
|
||||
|
@ -2153,7 +2140,7 @@ static void
|
|||
midori_web_view_menu_copy_activate_cb (GtkWidget* widget,
|
||||
MidoriView* view)
|
||||
{
|
||||
midori_web_view_set_clipboard (widget, view->selected_text);
|
||||
sokoke_widget_copy_clipboard (widget, view->selected_text);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2171,3 +2171,16 @@ sokoke_register_privacy_item (const gchar* name,
|
|||
items = g_list_append (items, item);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
sokoke_widget_copy_clipboard (GtkWidget* widget,
|
||||
const gchar* text)
|
||||
{
|
||||
GdkDisplay* display = gtk_widget_get_display (widget);
|
||||
GtkClipboard* clipboard;
|
||||
|
||||
clipboard = gtk_clipboard_get_for_display (display, GDK_SELECTION_CLIPBOARD);
|
||||
gtk_clipboard_set_text (clipboard, text, -1);
|
||||
clipboard = gtk_clipboard_get_for_display (display, GDK_SELECTION_PRIMARY);
|
||||
gtk_clipboard_set_text (clipboard, text, -1);
|
||||
}
|
||||
|
|
|
@ -280,4 +280,8 @@ sokoke_register_privacy_item (const gchar* name,
|
|||
const gchar* label,
|
||||
GCallback clear);
|
||||
|
||||
void
|
||||
sokoke_widget_copy_clipboard (GtkWidget* widget,
|
||||
const gchar* text);
|
||||
|
||||
#endif /* !__SOKOKE_H__ */
|
||||
|
|
Loading…
Reference in a new issue