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