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