annotate pidgin/gtkwebview.h @ 32120:24c8a98a6acc

webkit: Scroll to end when appending html. Most of the code was taken from imhtml.
author masca@cpw.pidgin.im
date Sat, 06 Feb 2010 22:18:05 +0000
parents 1cebf9aa291a
children 8e1ec44ede75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32061
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
1 /**
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
2 * @file gtkwebview.h Wrapper over the Gtk WebKitWebView component
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
3 * @ingroup pidgin
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
4 */
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
5
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
6 /* Pidgin is the legal property of its developers, whose names are too numerous
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
8 * source distribution.
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
9 *
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
11 * under the terms of the GNU General Public License as published by
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
13 * (at your option) any later version.
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
14 *
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
18 * GNU General Public License for more details.
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
19 *
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
23 */
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
24
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
25 #ifndef _PIDGIN_WEBVIEW_H_
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
26 #define _PIDGIN_WEBVIEW_H_
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
27
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
28 #include <glib.h>
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
29 #include <gtk/gtk.h>
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
30 #include <webkit/webkit.h>
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
31
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
32 #include "notify.h"
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
33
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
34 #define GTK_TYPE_WEBVIEW (gtk_webview_get_type())
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
35 #define GTK_WEBVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_WEBVIEW, GtkWebView))
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
36 #define GTK_WEBVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_WEBVIEW, GtkWebViewClass))
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
37 #define GTK_IS_WEBVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_WEBVIEW))
32080
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
38 #define GTK_IS_WEBVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_WEBVIEW))
32061
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
39
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
40
32080
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
41 struct GtkWebViewPriv;
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
42
32061
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
43 struct _GtkWebView
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
44 {
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
45 WebKitWebView webkit_web_view;
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
46
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
47 /*< private >*/
32080
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
48 struct GtkWebViewPriv* priv;
32061
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
49 };
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
50
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
51 typedef struct _GtkWebView GtkWebView;
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
52
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
53 struct _GtkWebViewClass
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
54 {
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
55 WebKitWebViewClass parent;
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
56 };
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
57
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
58 typedef struct _GtkWebViewClass GtkWebViewClass;
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
59
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
60
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
61 /**
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
62 * Returns the GType for a GtkWebView widget
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
63 *
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
64 * @return the GType for GtkWebView widget
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
65 */
32109
1cebf9aa291a Use (void) in prototypes. (thanks Elliott)
tdrhq@soc.pidgin.im
parents: 32082
diff changeset
66 GType gtk_webview_get_type (void);
32061
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
67
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
68 /**
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
69 * Create a new GtkWebView object
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
70 *
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
71 * @return a GtkWidget corresponding to the GtkWebView object
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
72 */
32109
1cebf9aa291a Use (void) in prototypes. (thanks Elliott)
tdrhq@soc.pidgin.im
parents: 32082
diff changeset
73 GtkWidget* gtk_webview_new (void);
32061
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
74
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
75 /**
32120
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
76 * Set the vertical adjustment for the GtkWebView.
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
77 *
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
78 * @param webview The GtkWebView.
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
79 * @param vadj The GtkAdjustment that control the webview.
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
80 */
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
81 void gtk_webview_set_vadjustment(GtkWebView *webview, GtkAdjustment *vadj);
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
82
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
83 /**
32061
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
84 * A very basic routine to append html, which can be considered
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
85 * equivalent to a "document.write" using JavaScript.
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
86 *
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
87 * @param webview The GtkWebView object
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
88 * @param markup The html markup to append
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
89 */
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
90 void gtk_webview_append_html (GtkWebView *webview, const char* markup);
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
91
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
92 /**
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
93 * Rather than use webkit_webview_load_string, this routine
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
94 * parses and displays the <img id=?> tags that make use of the
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
95 * Pidgin imgstore.
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
96 *
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
97 * @param webview The GtkWebView object
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
98 * @param html The HTML content to load
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
99 */
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
100 void gtk_webview_load_html_string_with_imgstore (GtkWebView* webview, const char* html);
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
101
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
102 /**
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
103 * (To be changed, right now it just tests whether an append has been
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
104 * called since the last clear or since the Widget was created. So it
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
105 * does not test for load_string's called in between.
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
106 *
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
107 * @param webview The GtkWebView object
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
108 *
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
109 * @return gboolean indicating whether the webview is empty.
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
110 */
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
111 gboolean gtk_webview_is_empty (GtkWebView *webview);
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
112
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
113 /**
32080
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
114 * Execute the JavaScript only after the webkit_webview_load_string
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
115 * loads completely. We also guarantee that the scripts are executed
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
116 * in the order they are called here.This is useful to avoid race
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
117 * conditions when calls JS functions immediately after opening the
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
118 * page.
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
119 *
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
120 * @param webview the GtkWebView object
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
121 * @param script the script to execute
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
122 */
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
123 void gtk_webview_safe_execute_script (GtkWebView *webview, const char* script);
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
124
b89351c7580b safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents: 32061
diff changeset
125 /**
32061
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
126 * A convenience routine to quote a string for use as a JavaScript
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
127 * string. For instance, "hello 'world'" becomes "'hello \\'world\\''"
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
128 *
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
129 * @param str The string to escape and quote
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
130 *
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
131 * @return the quoted string.
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
132 */
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
133 char* gtk_webview_quote_js_string (const char* str);
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
134
32120
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
135 /**
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
136 * Scrolls the Webview to the end of its contents.
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
137 *
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
138 * @param webview The GtkWebView.
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
139 * @param smoth A boolean indicating if smooth scrolling should be used.
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
140 */
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
141 void gtk_webview_scroll_to_end(GtkWebView *webview, gboolean smooth);
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32109
diff changeset
142
32061
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
143 #endif /* _PIDGIN_WEBVIEW_H_ */