pidgin: 1b845412: Restore "Insert Link" functionality.
qulogic at pidgin.im
qulogic at pidgin.im
Mon Jun 4 04:25:42 EDT 2012
----------------------------------------------------------------------
Revision: 1b845412014fe4bd5b3db57ca9e76de601ffc8fb
Parent: 4f8cd119f4719b7a0ba0ec9414225ce56170c787
Author: qulogic at pidgin.im
Date: 06/03/12 17:00:43
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/1b845412014fe4bd5b3db57ca9e76de601ffc8fb
Changelog:
Restore "Insert Link" functionality.
Changes against parent 4f8cd119f4719b7a0ba0ec9414225ce56170c787
patched pidgin/gtkwebview.c
patched pidgin/gtkwebview.h
patched pidgin/gtkwebviewtoolbar.c
-------------- next part --------------
============================================================
--- pidgin/gtkwebview.c e33a119702a287c67d4ca33f0dbb3861a2d4585e
+++ pidgin/gtkwebview.c dab75fd8ef1cb43f96d48679d1cfc180435ef973
@@ -1020,3 +1020,19 @@ gtk_webview_insert_hr(GtkWebView *webvie
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);
+}
+
============================================================
--- pidgin/gtkwebview.h 7e7765d2a9fecea9e107429b9773a8ef21d63a6a
+++ pidgin/gtkwebview.h 0fb4ef9b8713d319772905c166969b4f1cae0b4c
@@ -410,6 +410,16 @@ void gtk_webview_insert_hr(GtkWebView *w
*/
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_ */
============================================================
--- pidgin/gtkwebviewtoolbar.c 28cc128a0ea27545b7a75282e6a6c4baf39b2bf5
+++ pidgin/gtkwebviewtoolbar.c d955c80c8cbb7e9816f2a1ee40d5e41b65c5732a
@@ -494,15 +494,8 @@ do_insert_link_cb(GtkWebViewToolbar *too
else
description = NULL;
- if (description == NULL)
- description = url;
+ gtk_webview_insert_link(GTK_WEBVIEW(toolbar->webview), url, description);
-#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_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->link), FALSE);
priv->link_dialog = NULL;
More information about the Commits
mailing list