pidgin: 3afba1bd: Set up the link description from the alr...
qulogic at pidgin.im
qulogic at pidgin.im
Mon Jun 4 04:25:45 EDT 2012
----------------------------------------------------------------------
Revision: 3afba1bd369579ccea4aa5c18b8d392f1d834fbd
Parent: 1b845412014fe4bd5b3db57ca9e76de601ffc8fb
Author: qulogic at pidgin.im
Date: 06/03/12 17:13:19
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/3afba1bd369579ccea4aa5c18b8d392f1d834fbd
Changelog:
Set up the link description from the already selected text.
Changes against parent 1b845412014fe4bd5b3db57ca9e76de601ffc8fb
patched pidgin/gtkwebview.c
patched pidgin/gtkwebview.h
patched pidgin/gtkwebviewtoolbar.c
-------------- next part --------------
============================================================
--- pidgin/gtkwebview.c dab75fd8ef1cb43f96d48679d1cfc180435ef973
+++ pidgin/gtkwebview.c 94d49d1dff266d671f0ec7c03a2dd6eeafb2a713
@@ -840,6 +840,22 @@ gtk_webview_get_body_text(GtkWebView *we
return text;
}
+gchar *
+gtk_webview_get_selected_text(GtkWebView *webview)
+{
+ WebKitDOMDocument *dom;
+ WebKitDOMDOMWindow *win;
+ WebKitDOMDOMSelection *sel;
+ WebKitDOMRange *range;
+
+ dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+ win = webkit_dom_document_get_default_view(dom);
+ sel = webkit_dom_dom_window_get_selection(win);
+ range = webkit_dom_dom_selection_get_range_at(sel, 0, NULL);
+
+ return webkit_dom_range_get_text(range);
+}
+
GtkWebViewButtons
gtk_webview_get_format_functions(GtkWebView *webview)
{
============================================================
--- pidgin/gtkwebview.h 0fb4ef9b8713d319772905c166969b4f1cae0b4c
+++ pidgin/gtkwebview.h f846c6555ec930a3ba87a1f15ab90b0737371c65
@@ -309,9 +309,18 @@ gchar *gtk_webview_get_body_text(GtkWebV
* @return The HTML-free text that is currently displayed.
*/
gchar *gtk_webview_get_body_text(GtkWebView *webview);
-gchar *gtk_webview_get_head_text(GtkWebView *webview);
/**
+ * Gets the selected text of a GtkWebView.
+ *
+ * @param webview The GtkWebView
+ *
+ * @return The HTML-free text that is currently selected, or NULL if nothing is
+ * currently selected.
+ */
+gchar *gtk_webview_get_selected_text(GtkWebView *webview);
+
+/**
* Clear all the formatting on a GtkWebView.
*
* @param webview The GtkWebView
============================================================
--- pidgin/gtkwebviewtoolbar.c d955c80c8cbb7e9816f2a1ee40d5e41b65c5732a
+++ pidgin/gtkwebviewtoolbar.c 3a7e33c71284d866a82625009ecdc7d957366682
@@ -509,9 +509,6 @@ insert_link_cb(GtkWidget *w, GtkWebViewT
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
-#if 0
- GtkTextIter start, end;
-#endif
char *msg;
char *desc = NULL;
@@ -525,11 +522,7 @@ insert_link_cb(GtkWidget *w, GtkWebViewT
purple_request_field_group_add_field(group, field);
if (gtk_webview_get_format_functions(GTK_WEBVIEW(toolbar->webview)) & GTK_WEBVIEW_LINKDESC) {
-#if 0
- if (gtk_text_buffer_get_selection_bounds(GTK_WEBVIEW(toolbar->webview)->text_buffer, &start, &end)) {
- desc = gtk_webview_get_text(GTK_WEBVIEW(toolbar->webview), &start, &end);
- }
-#endif
+ desc = gtk_webview_get_selected_text(GTK_WEBVIEW(toolbar->webview));
field = purple_request_field_string_new("description", _("_Description"),
desc, FALSE);
purple_request_field_group_add_field(group, field);
More information about the Commits
mailing list