860c0d0333673bef78391fc2512cdec5006d0307
[WebKit-https.git] / WebKit / gtk / webkit / webkitwebview.h
1 /*
2  * Copyright (C) 2007 Holger Hans Peter Freyther
3  * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
4  * Copyright (C) 2008 Collabora Ltd.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 #ifndef WEBKIT_WEB_VIEW_H
23 #define WEBKIT_WEB_VIEW_H
24
25 #include <gtk/gtk.h>
26 #include <JavaScriptCore/JSBase.h>
27
28 #include <webkit/webkitdefines.h>
29 #include <webkit/webkitwebbackforwardlist.h>
30 #include <webkit/webkitwebhistoryitem.h>
31 #include <webkit/webkitwebsettings.h>
32
33 G_BEGIN_DECLS
34
35 #define WEBKIT_TYPE_WEB_VIEW            (webkit_web_view_get_type())
36 #define WEBKIT_WEB_VIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebView))
37 #define WEBKIT_WEB_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass))
38 #define WEBKIT_IS_WEB_VIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_VIEW))
39 #define WEBKIT_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_WEB_VIEW))
40 #define WEBKIT_WEB_VIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass))
41
42 typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate;
43
44 typedef enum {
45     WEBKIT_NAVIGATION_RESPONSE_ACCEPT,
46     WEBKIT_NAVIGATION_RESPONSE_IGNORE,
47     WEBKIT_NAVIGATION_RESPONSE_DOWNLOAD
48 } WebKitNavigationResponse;
49
50 typedef enum
51 {
52     WEBKIT_WEB_VIEW_TARGET_INFO_HTML,
53     WEBKIT_WEB_VIEW_TARGET_INFO_TEXT
54 } WebKitWebViewTargetInfo;
55
56 struct _WebKitWebView {
57     GtkContainer parent_instance;
58
59     /*< private >*/
60     WebKitWebViewPrivate *priv;
61 };
62
63 struct _WebKitWebViewClass {
64     GtkContainerClass parent_class;
65
66     /*< public >*/
67     /*
68      * default handler/virtual methods
69      */
70     WebKitWebView            * (* create_web_view)        (WebKitWebView        *web_view,
71                                                            WebKitWebFrame       *web_frame);
72
73     gboolean                   (* web_view_ready)          (WebKitWebView* web_view);
74
75     WebKitNavigationResponse   (* navigation_requested)   (WebKitWebView        *web_view,
76                                                            WebKitWebFrame       *frame,
77                                                            WebKitNetworkRequest *request);
78     void                       (* window_object_cleared)  (WebKitWebView        *web_view,
79                                                            WebKitWebFrame       *frame,
80                                                            JSGlobalContextRef    context,
81                                                            JSObjectRef           window_object);
82     gchar                    * (* choose_file)            (WebKitWebView        *web_view,
83                                                            WebKitWebFrame       *frame,
84                                                            const gchar          *old_file);
85     gboolean                   (* script_alert)           (WebKitWebView        *web_view,
86                                                            WebKitWebFrame       *frame,
87                                                            const gchar          *alert_message);
88     gboolean                   (* script_confirm)         (WebKitWebView        *web_view,
89                                                            WebKitWebFrame       *frame,
90                                                            const gchar          *confirm_message,
91                                                            gboolean             *did_confirm);
92     gboolean                   (* script_prompt)          (WebKitWebView        *web_view,
93                                                            WebKitWebFrame       *frame,
94                                                            const gchar          *message,
95                                                            const gchar          *default_value,
96                                                            gchar*               *value);
97     gboolean                   (* console_message)        (WebKitWebView        *web_view,
98                                                            const gchar          *message,
99                                                            guint                 line_number,
100                                                            const gchar*          source_id);
101     void                       (* select_all)             (WebKitWebView        *web_view);
102     void                       (* cut_clipboard)          (WebKitWebView        *web_view);
103     void                       (* copy_clipboard)         (WebKitWebView        *web_view);
104     void                       (* paste_clipboard)        (WebKitWebView        *web_view);
105
106     /*
107      * internal
108      */
109     void                       (* set_scroll_adjustments) (WebKitWebView        *web_view,
110                                                            GtkAdjustment        *hadjustment,
111                                                            GtkAdjustment        *vadjustment);
112     /* Padding for future expansion */
113     void (*_webkit_reserved0) (void);
114     void (*_webkit_reserved1) (void);
115     void (*_webkit_reserved2) (void);
116     void (*_webkit_reserved3) (void);
117     void (*_webkit_reserved4) (void);
118     void (*_webkit_reserved5) (void);
119     void (*_webkit_reserved6) (void);
120     void (*_webkit_reserved7) (void);
121 };
122
123 WEBKIT_API GType
124 webkit_web_view_get_type (void);
125
126 WEBKIT_API GtkWidget *
127 webkit_web_view_new (void);
128
129 WEBKIT_API void
130 webkit_web_view_set_maintains_back_forward_list (WebKitWebView        *web_view,
131                                                  gboolean              flag);
132
133 WEBKIT_API WebKitWebBackForwardList *
134 webkit_web_view_get_back_forward_list           (WebKitWebView        *web_view);
135
136 WEBKIT_API gboolean
137 webkit_web_view_go_to_back_forward_item         (WebKitWebView        *web_view,
138                                                  WebKitWebHistoryItem *item);
139
140 WEBKIT_API gboolean
141 webkit_web_view_can_go_back                     (WebKitWebView        *web_view);
142
143 WEBKIT_API gboolean
144 webkit_web_view_can_go_back_or_forward          (WebKitWebView        *web_view,
145                                                  gint                  steps);
146
147 WEBKIT_API gboolean
148 webkit_web_view_can_go_forward                  (WebKitWebView        *web_view);
149
150 WEBKIT_API void
151 webkit_web_view_go_back                         (WebKitWebView        *web_view);
152
153 WEBKIT_API void
154 webkit_web_view_go_back_or_forward              (WebKitWebView        *web_view,
155                                                  gint                  steps);
156
157 WEBKIT_API void
158 webkit_web_view_go_forward                      (WebKitWebView        *web_view);
159
160 WEBKIT_API void
161 webkit_web_view_stop_loading                    (WebKitWebView        *web_view);
162
163 WEBKIT_API void
164 webkit_web_view_open                            (WebKitWebView        *web_view,
165                                                  const gchar          *uri);
166
167 WEBKIT_API void
168 webkit_web_view_reload                          (WebKitWebView        *web_view);
169
170 WEBKIT_API void
171 webkit_web_view_reload_bypass_cache             (WebKitWebView        *web_view);
172
173 WEBKIT_API void
174 webkit_web_view_load_uri                        (WebKitWebView        *web_view,
175                                                  const gchar          *uri);
176
177 WEBKIT_API void
178 webkit_web_view_load_string                     (WebKitWebView        *web_view,
179                                                  const gchar          *content,
180                                                  const gchar          *mime_type,
181                                                  const gchar          *encoding,
182                                                  const gchar          *base_uri);
183
184 WEBKIT_API void
185 webkit_web_view_load_html_string                (WebKitWebView        *web_view,
186                                                  const gchar          *content,
187                                                  const gchar          *base_uri);
188
189 WEBKIT_API void
190 webkit_web_view_load_request                    (WebKitWebView        *web_view,
191                                                  WebKitNetworkRequest *request);
192
193 WEBKIT_API gboolean
194 webkit_web_view_search_text                     (WebKitWebView        *web_view,
195                                                  const gchar          *text,
196                                                  gboolean              case_sensitive,
197                                                  gboolean              forward,
198                                                  gboolean              wrap);
199
200 WEBKIT_API guint
201 webkit_web_view_mark_text_matches               (WebKitWebView        *web_view,
202                                                  const gchar          *string,
203                                                  gboolean              case_sensitive,
204                                                  guint                 limit);
205
206 WEBKIT_API void
207 webkit_web_view_set_highlight_text_matches      (WebKitWebView        *web_view,
208                                                  gboolean              highlight);
209
210 WEBKIT_API void
211 webkit_web_view_unmark_text_matches             (WebKitWebView        *web_view);
212
213 WEBKIT_API WebKitWebFrame *
214 webkit_web_view_get_main_frame                  (WebKitWebView        *web_view);
215
216 WEBKIT_API WebKitWebFrame *
217 webkit_web_view_get_focused_frame               (WebKitWebView        *web_view);
218
219 WEBKIT_API void
220 webkit_web_view_execute_script                  (WebKitWebView        *web_view,
221                                                  const gchar          *script);
222
223 WEBKIT_API gboolean
224 webkit_web_view_can_cut_clipboard               (WebKitWebView        *web_view);
225
226 WEBKIT_API gboolean
227 webkit_web_view_can_copy_clipboard              (WebKitWebView        *web_view);
228
229 WEBKIT_API gboolean
230 webkit_web_view_can_paste_clipboard             (WebKitWebView        *web_view);
231
232 WEBKIT_API void
233 webkit_web_view_cut_clipboard                   (WebKitWebView        *web_view);
234
235 WEBKIT_API void
236 webkit_web_view_copy_clipboard                  (WebKitWebView        *web_view);
237
238 WEBKIT_API void
239 webkit_web_view_paste_clipboard                 (WebKitWebView        *web_view);
240
241 WEBKIT_API void
242 webkit_web_view_delete_selection                (WebKitWebView        *web_view);
243
244 WEBKIT_API gboolean
245 webkit_web_view_has_selection                   (WebKitWebView        *web_view);
246
247 WEBKIT_API void
248 webkit_web_view_select_all                      (WebKitWebView        *web_view);
249
250 WEBKIT_API gboolean
251 webkit_web_view_get_editable                    (WebKitWebView        *web_view);
252
253 WEBKIT_API void
254 webkit_web_view_set_editable                    (WebKitWebView        *web_view,
255                                                  gboolean              flag);
256
257 WEBKIT_API GtkTargetList *
258 webkit_web_view_get_copy_target_list            (WebKitWebView        *web_view);
259
260 WEBKIT_API GtkTargetList *
261 webkit_web_view_get_paste_target_list           (WebKitWebView        *web_view);
262
263 WEBKIT_API void
264 webkit_web_view_set_settings                    (WebKitWebView        *web_view,
265                                                  WebKitWebSettings    *settings);
266
267 WEBKIT_API WebKitWebSettings *
268 webkit_web_view_get_settings                    (WebKitWebView        *web_view);
269
270 WEBKIT_API WebKitWebInspector *
271 webkit_web_view_get_inspector                   (WebKitWebView        *web_view);
272
273 WEBKIT_API WebKitWebWindowFeatures*
274 webkit_web_view_get_window_features             (WebKitWebView        *web_view);
275
276 WEBKIT_API gboolean
277 webkit_web_view_can_show_mime_type              (WebKitWebView        *web_view,
278                                                  const gchar          *mime_type);
279
280 WEBKIT_API gboolean
281 webkit_web_view_get_transparent                 (WebKitWebView        *web_view);
282
283 WEBKIT_API void
284 webkit_web_view_set_transparent                 (WebKitWebView        *web_view,
285                                                  gboolean              flag);
286
287 WEBKIT_API gfloat
288 webkit_web_view_get_zoom_level                  (WebKitWebView        *web_view);
289
290 WEBKIT_API void
291 webkit_web_view_set_zoom_level                  (WebKitWebView        *web_view,
292                                                  gfloat                zoom_level);
293
294 WEBKIT_API void
295 webkit_web_view_zoom_in                         (WebKitWebView        *web_view);
296
297 WEBKIT_API void
298 webkit_web_view_zoom_out                        (WebKitWebView        *web_view);
299
300 WEBKIT_API gboolean
301 webkit_web_view_get_full_content_zoom           (WebKitWebView        *web_view);
302
303 WEBKIT_API void
304 webkit_web_view_set_full_content_zoom           (WebKitWebView        *web_view,
305                                                  gboolean              full_content_zoom);
306
307 G_END_DECLS
308
309 #endif