1 /* 2 * Copyright (C) 2007 Holger Hans Peter Freyther 3 * Copyright (C) 2007, 2008 Alp Toker <alp (at) 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 webkitwebview_h 23 #define webkitwebview_h 24 25 #include <gtk/gtk.h> 26 #include <libsoup/soup.h> 27 #include <JavaScriptCore/JSBase.h> 28 29 #include <webkit/webkitdefines.h> 30 #include <webkit/webkitdom.h> 31 #include <webkit/webkitwebbackforwardlist.h> 32 #include <webkit/webkitwebframe.h> 33 #include <webkit/webkitwebhistoryitem.h> 34 #include <webkit/webkitwebsettings.h> 35 36 G_BEGIN_DECLS 37 38 #define WEBKIT_TYPE_WEB_VIEW (webkit_web_view_get_type()) 39 #define WEBKIT_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebView)) 40 #define WEBKIT_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass)) 41 #define WEBKIT_IS_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_VIEW)) 42 #define WEBKIT_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_VIEW)) 43 #define WEBKIT_WEB_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass)) 44 45 typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate; 46 47 typedef enum { 48 WEBKIT_NAVIGATION_RESPONSE_ACCEPT, 49 WEBKIT_NAVIGATION_RESPONSE_IGNORE, 50 WEBKIT_NAVIGATION_RESPONSE_DOWNLOAD 51 } WebKitNavigationResponse; 52 53 typedef enum 54 { 55 WEBKIT_WEB_VIEW_TARGET_INFO_HTML, 56 WEBKIT_WEB_VIEW_TARGET_INFO_TEXT, 57 WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE, 58 WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST, 59 WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL 60 } WebKitWebViewTargetInfo; 61 62 typedef enum 63 { 64 WEBKIT_WEB_VIEW_VIEW_MODE_WINDOWED, 65 WEBKIT_WEB_VIEW_VIEW_MODE_FLOATING, 66 WEBKIT_WEB_VIEW_VIEW_MODE_FULLSCREEN, 67 WEBKIT_WEB_VIEW_VIEW_MODE_MAXIMIZED, 68 WEBKIT_WEB_VIEW_VIEW_MODE_MINIMIZED 69 } WebKitWebViewViewMode; 70 71 typedef enum 72 { 73 WEBKIT_SELECTION_AFFINITY_UPSTREAM, 74 WEBKIT_SELECTION_AFFINITY_DOWNSTREAM, 75 } WebKitSelectionAffinity; 76 77 typedef enum 78 { 79 WEBKIT_INSERT_ACTION_TYPED, 80 WEBKIT_INSERT_ACTION_PASTED, 81 WEBKIT_INSERT_ACTION_DROPPED, 82 } WebKitInsertAction; 83 84 struct _WebKitWebView { 85 GtkContainer parent_instance; 86 87 /*< private >*/ 88 WebKitWebViewPrivate *priv; 89 }; 90 91 struct _WebKitWebViewClass { 92 GtkContainerClass parent_class; 93 94 /*< public >*/ 95 /* 96 * default handler/virtual methods 97 */ 98 WebKitWebView * (* create_web_view) (WebKitWebView *web_view, 99 WebKitWebFrame *web_frame); 100 101 gboolean (* web_view_ready) (WebKitWebView* web_view); 102 103 gboolean (* close_web_view) (WebKitWebView* web_view); 104 105 WebKitNavigationResponse (* navigation_requested) (WebKitWebView *web_view, 106 WebKitWebFrame *frame, 107 WebKitNetworkRequest *request); 108 void (* window_object_cleared) (WebKitWebView *web_view, 109 WebKitWebFrame *frame, 110 JSGlobalContextRef context, 111 JSObjectRef window_object); 112 gchar * (* choose_file) (WebKitWebView *web_view, 113 WebKitWebFrame *frame, 114 const gchar *old_file); 115 gboolean (* script_alert) (WebKitWebView *web_view, 116 WebKitWebFrame *frame, 117 const gchar *alert_message); 118 gboolean (* script_confirm) (WebKitWebView *web_view, 119 WebKitWebFrame *frame, 120 const gchar *confirm_message, 121 gboolean *did_confirm); 122 gboolean (* script_prompt) (WebKitWebView *web_view, 123 WebKitWebFrame *frame, 124 const gchar *message, 125 const gchar *default_value, 126 gchar* *value); 127 gboolean (* console_message) (WebKitWebView *web_view, 128 const gchar *message, 129 guint line_number, 130 const gchar* source_id); 131 void (* select_all) (WebKitWebView *web_view); 132 void (* cut_clipboard) (WebKitWebView *web_view); 133 void (* copy_clipboard) (WebKitWebView *web_view); 134 void (* paste_clipboard) (WebKitWebView *web_view); 135 gboolean (* move_cursor) (WebKitWebView *web_view, 136 GtkMovementStep step, 137 gint count); 138 139 /* 140 * internal 141 */ 142 void (* set_scroll_adjustments) (WebKitWebView *web_view, 143 GtkAdjustment *hadjustment, 144 GtkAdjustment *vadjustment); 145 146 void (* undo) (WebKitWebView *web_view); 147 void (* redo) (WebKitWebView *web_view); 148 gboolean (* should_allow_editing_action) (WebKitWebView *web_view); 149 150 /* Padding for future expansion */ 151 void (*_webkit_reserved0) (void); 152 void (*_webkit_reserved1) (void); 153 void (*_webkit_reserved2) (void); 154 }; 155 156 WEBKIT_API GType 157 webkit_web_view_get_type (void); 158 159 WEBKIT_API GtkWidget * 160 webkit_web_view_new (void); 161 162 WEBKIT_API G_CONST_RETURN gchar * 163 webkit_web_view_get_title (WebKitWebView *webView); 164 165 WEBKIT_API G_CONST_RETURN gchar * 166 webkit_web_view_get_uri (WebKitWebView *webView); 167 168 WEBKIT_API void 169 webkit_web_view_set_maintains_back_forward_list (WebKitWebView *webView, 170 gboolean flag); 171 172 WEBKIT_API WebKitWebBackForwardList * 173 webkit_web_view_get_back_forward_list (WebKitWebView *webView); 174 175 WEBKIT_API gboolean 176 webkit_web_view_go_to_back_forward_item (WebKitWebView *webView, 177 WebKitWebHistoryItem *item); 178 179 WEBKIT_API gboolean 180 webkit_web_view_can_go_back (WebKitWebView *webView); 181 182 WEBKIT_API gboolean 183 webkit_web_view_can_go_back_or_forward (WebKitWebView *webView, 184 gint steps); 185 186 WEBKIT_API gboolean 187 webkit_web_view_can_go_forward (WebKitWebView *webView); 188 189 WEBKIT_API void 190 webkit_web_view_go_back (WebKitWebView *webView); 191 192 WEBKIT_API void 193 webkit_web_view_go_back_or_forward (WebKitWebView *webView, 194 gint steps); 195 196 WEBKIT_API void 197 webkit_web_view_go_forward (WebKitWebView *webView); 198 199 WEBKIT_API void 200 webkit_web_view_stop_loading (WebKitWebView *webView); 201 202 WEBKIT_API void 203 webkit_web_view_open (WebKitWebView *webView, 204 const gchar *uri); 205 206 WEBKIT_API void 207 webkit_web_view_reload (WebKitWebView *webView); 208 209 WEBKIT_API void 210 webkit_web_view_reload_bypass_cache (WebKitWebView *webView); 211 212 WEBKIT_API void 213 webkit_web_view_load_uri (WebKitWebView *webView, 214 const gchar *uri); 215 216 WEBKIT_API void 217 webkit_web_view_load_string (WebKitWebView *webView, 218 const gchar *content, 219 const gchar *mime_type, 220 const gchar *encoding, 221 const gchar *base_uri); 222 223 WEBKIT_API void 224 webkit_web_view_load_html_string (WebKitWebView *webView, 225 const gchar *content, 226 const gchar *base_uri); 227 228 WEBKIT_API void 229 webkit_web_view_load_request (WebKitWebView *webView, 230 WebKitNetworkRequest *request); 231 232 WEBKIT_API gboolean 233 webkit_web_view_search_text (WebKitWebView *webView, 234 const gchar *text, 235 gboolean case_sensitive, 236 gboolean forward, 237 gboolean wrap); 238 239 WEBKIT_API guint 240 webkit_web_view_mark_text_matches (WebKitWebView *webView, 241 const gchar *string, 242 gboolean case_sensitive, 243 guint limit); 244 245 WEBKIT_API void 246 webkit_web_view_set_highlight_text_matches (WebKitWebView *webView, 247 gboolean highlight); 248 249 WEBKIT_API void 250 webkit_web_view_unmark_text_matches (WebKitWebView *webView); 251 252 WEBKIT_API WebKitWebFrame * 253 webkit_web_view_get_main_frame (WebKitWebView *webView); 254 255 WEBKIT_API WebKitWebFrame * 256 webkit_web_view_get_focused_frame (WebKitWebView *webView); 257 258 WEBKIT_API void 259 webkit_web_view_execute_script (WebKitWebView *webView, 260 const gchar *script); 261 262 WEBKIT_API gboolean 263 webkit_web_view_can_cut_clipboard (WebKitWebView *webView); 264 265 WEBKIT_API gboolean 266 webkit_web_view_can_copy_clipboard (WebKitWebView *webView); 267 268 WEBKIT_API gboolean 269 webkit_web_view_can_paste_clipboard (WebKitWebView *webView); 270 271 WEBKIT_API void 272 webkit_web_view_cut_clipboard (WebKitWebView *webView); 273 274 WEBKIT_API void 275 webkit_web_view_copy_clipboard (WebKitWebView *webView); 276 277 WEBKIT_API void 278 webkit_web_view_paste_clipboard (WebKitWebView *webView); 279 280 WEBKIT_API void 281 webkit_web_view_delete_selection (WebKitWebView *webView); 282 283 WEBKIT_API gboolean 284 webkit_web_view_has_selection (WebKitWebView *webView); 285 286 WEBKIT_API void 287 webkit_web_view_select_all (WebKitWebView *webView); 288 289 WEBKIT_API gboolean 290 webkit_web_view_get_editable (WebKitWebView *webView); 291 292 WEBKIT_API void 293 webkit_web_view_set_editable (WebKitWebView *webView, 294 gboolean flag); 295 296 WEBKIT_API GtkTargetList * 297 webkit_web_view_get_copy_target_list (WebKitWebView *webView); 298 299 WEBKIT_API GtkTargetList * 300 webkit_web_view_get_paste_target_list (WebKitWebView *webView); 301 302 WEBKIT_API void 303 webkit_web_view_set_settings (WebKitWebView *webView, 304 WebKitWebSettings *settings); 305 306 WEBKIT_API WebKitWebSettings * 307 webkit_web_view_get_settings (WebKitWebView *webView); 308 309 WEBKIT_API WebKitWebInspector * 310 webkit_web_view_get_inspector (WebKitWebView *webView); 311 312 WEBKIT_API WebKitWebWindowFeatures* 313 webkit_web_view_get_window_features (WebKitWebView *webView); 314 315 WEBKIT_API gboolean 316 webkit_web_view_can_show_mime_type (WebKitWebView *webView, 317 const gchar *mime_type); 318 319 WEBKIT_API gboolean 320 webkit_web_view_get_transparent (WebKitWebView *webView); 321 322 WEBKIT_API void 323 webkit_web_view_set_transparent (WebKitWebView *webView, 324 gboolean flag); 325 326 WEBKIT_API gfloat 327 webkit_web_view_get_zoom_level (WebKitWebView *webView); 328 329 WEBKIT_API void 330 webkit_web_view_set_zoom_level (WebKitWebView *webView, 331 gfloat zoom_level); 332 333 WEBKIT_API void 334 webkit_web_view_zoom_in (WebKitWebView *webView); 335 336 WEBKIT_API void 337 webkit_web_view_zoom_out (WebKitWebView *webView); 338 339 WEBKIT_API gboolean 340 webkit_web_view_get_full_content_zoom (WebKitWebView *webView); 341 342 WEBKIT_API void 343 webkit_web_view_set_full_content_zoom (WebKitWebView *webView, 344 gboolean full_content_zoom); 345 346 WEBKIT_API const gchar* 347 webkit_web_view_get_encoding (WebKitWebView * webView); 348 349 WEBKIT_API void 350 webkit_web_view_set_custom_encoding (WebKitWebView * webView, 351 const gchar * encoding); 352 353 WEBKIT_API const char* 354 webkit_web_view_get_custom_encoding (WebKitWebView * webView); 355 356 WEBKIT_API void 357 webkit_web_view_set_view_mode (WebKitWebView *webView, 358 WebKitWebViewViewMode mode); 359 360 WEBKIT_API WebKitWebViewViewMode 361 webkit_web_view_get_view_mode (WebKitWebView *webView); 362 363 WEBKIT_API void 364 webkit_web_view_move_cursor (WebKitWebView * webView, 365 GtkMovementStep step, 366 gint count); 367 368 WEBKIT_API WebKitLoadStatus 369 webkit_web_view_get_load_status (WebKitWebView *webView); 370 371 WEBKIT_API gdouble 372 webkit_web_view_get_progress (WebKitWebView *webView); 373 374 WEBKIT_API void 375 webkit_web_view_undo (WebKitWebView *webView); 376 377 WEBKIT_API gboolean 378 webkit_web_view_can_undo (WebKitWebView *webView); 379 380 WEBKIT_API void 381 webkit_web_view_redo (WebKitWebView *webView); 382 383 WEBKIT_API gboolean 384 webkit_web_view_can_redo (WebKitWebView *webView); 385 386 WEBKIT_API void 387 webkit_web_view_set_view_source_mode (WebKitWebView *webView, 388 gboolean view_source_mode); 389 390 WEBKIT_API gboolean 391 webkit_web_view_get_view_source_mode (WebKitWebView *webView); 392 393 WEBKIT_API WebKitHitTestResult* 394 webkit_web_view_get_hit_test_result (WebKitWebView *webView, 395 GdkEventButton *event); 396 397 WEBKIT_API G_CONST_RETURN gchar * 398 webkit_web_view_get_icon_uri (WebKitWebView *webView); 399 400 WEBKIT_API GdkPixbuf * 401 webkit_web_view_get_icon_pixbuf (WebKitWebView *webView); 402 403 WEBKIT_API WebKitDOMDocument * 404 webkit_web_view_get_dom_document (WebKitWebView *webView); 405 406 WEBKIT_API WebKitViewportAttributes* 407 webkit_web_view_get_viewport_attributes (WebKitWebView *webView); 408 409 G_END_DECLS 410 411 #endif 412