qulogic/pidgin

Restore "Insert Link" functionality.

2012-06-03, Elliott Sales de Andrade
f62232fb738a
Parents 3a742f00a0f4
Children 2f8a83007ab9
Restore "Insert Link" functionality.
--- a/pidgin/gtkwebview.c Sun Jun 03 20:50:42 2012 +0000
+++ b/pidgin/gtkwebview.c Sun Jun 03 21:00:43 2012 +0000
@@ -1020,3 +1020,19 @@
priv->edit.block_changed = FALSE;
}
+void
+gtk_webview_insert_link(GtkWebView *webview, const char *url, const char *desc)
+{
+ GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+ WebKitDOMDocument *dom;
+ char *link;
+
+ dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+ link = g_strdup_printf("<a href=%s>%s</a>", url, desc ? desc : url);
+
+ priv->edit.block_changed = TRUE;
+ webkit_dom_document_exec_command(dom, "insertHTML", FALSE, link);
+ priv->edit.block_changed = FALSE;
+ g_free(link);
+}
+
--- a/pidgin/gtkwebview.h Sun Jun 03 20:50:42 2012 +0000
+++ b/pidgin/gtkwebview.h Sun Jun 03 21:00:43 2012 +0000
@@ -410,6 +410,16 @@
*/
void gtk_webview_insert_hr(GtkWebView *webview);
+/**
+ * Inserts a link at the current location or selection in a GtkWebView.
+ *
+ * @param webview The GtkWebView
+ * @param url The URL of the link
+ * @param desc The text description of the link. If not supplied, the URL is
+ * used instead.
+ */
+void gtk_webview_insert_link(GtkWebView *webview, const char *url, const char *desc);
+
G_END_DECLS
#endif /* _PIDGIN_WEBVIEW_H_ */
--- a/pidgin/gtkwebviewtoolbar.c Sun Jun 03 20:50:42 2012 +0000
+++ b/pidgin/gtkwebviewtoolbar.c Sun Jun 03 21:00:43 2012 +0000
@@ -494,14 +494,7 @@
else
description = NULL;
- if (description == NULL)
- description = url;
-
-#if 0
- gtk_webview_insert_link(GTK_WEBVIEW(toolbar->webview),
- gtk_text_buffer_get_insert(GTK_WEBVIEW(toolbar->webview)->text_buffer),
- url, description);
-#endif
+ gtk_webview_insert_link(GTK_WEBVIEW(toolbar->webview), url, description);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->link), FALSE);