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 <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 { 54 WEBKIT_WEB_VIEW_TARGET_INFO_HTML, 55 WEBKIT_WEB_VIEW_TARGET_INFO_TEXT 56 } WebKitWebViewTargetInfo; 57 58 struct _WebKitWebView { 59 GtkContainer parent_instance; 60 61 /*< private >*/ 62 WebKitWebViewPrivate *priv; 63 }; 64 65 struct _WebKitWebViewClass { 66 GtkContainerClass parent_class; 67 68 /*< public >*/ 69 /* 70 * default handler/virtual methods 71 */ 72 WebKitWebView * (* create_web_view) (WebKitWebView *web_view, 73 WebKitWebFrame *web_frame); 74 75 gboolean (* web_view_ready) (WebKitWebView* web_view); 76 77 gboolean (* close_web_view) (WebKitWebView* web_view); 78 79 WebKitNavigationResponse (* navigation_requested) (WebKitWebView *web_view, 80 WebKitWebFrame *frame, 81 WebKitNetworkRequest *request); 82 void (* window_object_cleared) (WebKitWebView *web_view, 83 WebKitWebFrame *frame, 84 JSGlobalContextRef context, 85 JSObjectRef window_object); 86 gchar * (* choose_file) (WebKitWebView *web_view, 87 WebKitWebFrame *frame, 88 const gchar *old_file); 89 gboolean (* script_alert) (WebKitWebView *web_view, 90 WebKitWebFrame *frame, 91 const gchar *alert_message); 92 gboolean (* script_confirm) (WebKitWebView *web_view, 93 WebKitWebFrame *frame, 94 const gchar *confirm_message, 95 gboolean *did_confirm); 96 gboolean (* script_prompt) (WebKitWebView *web_view, 97 WebKitWebFrame *frame, 98 const gchar *message, 99 const gchar *default_value, 100 gchar* *value); 101 gboolean (* console_message) (WebKitWebView *web_view, 102 const gchar *message, 103 guint line_number, 104 const gchar* source_id); 105 void (* select_all) (WebKitWebView *web_view); 106 void (* cut_clipboard) (WebKitWebView *web_view); 107 void (* copy_clipboard) (WebKitWebView *web_view); 108 void (* paste_clipboard) (WebKitWebView *web_view); 109 gboolean (* move_cursor) (WebKitWebView *web_view, 110 GtkMovementStep step, 111 gint count); 112 113 /* 114 * internal 115 */ 116 void (* set_scroll_adjustments) (WebKitWebView *web_view, 117 GtkAdjustment *hadjustment, 118 GtkAdjustment *vadjustment); 119 /* Padding for future expansion */ 120 void (*_webkit_reserved0) (void); 121 void (*_webkit_reserved1) (void); 122 void (*_webkit_reserved2) (void); 123 void (*_webkit_reserved3) (void); 124 void (*_webkit_reserved4) (void); 125 void (*_webkit_reserved5) (void); 126 }; 127 128 WEBKIT_API GType 129 webkit_web_view_get_type (void); 130 131 WEBKIT_API GtkWidget * 132 webkit_web_view_new (void); 133 134 WEBKIT_API G_CONST_RETURN gchar * 135 webkit_web_view_get_title (WebKitWebView *web_view); 136 137 WEBKIT_API G_CONST_RETURN gchar * 138 webkit_web_view_get_uri (WebKitWebView *web_view); 139 140 WEBKIT_API void 141 webkit_web_view_set_maintains_back_forward_list (WebKitWebView *web_view, 142 gboolean flag); 143 144 WEBKIT_API WebKitWebBackForwardList * 145 webkit_web_view_get_back_forward_list (WebKitWebView *web_view); 146 147 WEBKIT_API gboolean 148 webkit_web_view_go_to_back_forward_item (WebKitWebView *web_view, 149 WebKitWebHistoryItem *item); 150 151 WEBKIT_API gboolean 152 webkit_web_view_can_go_back (WebKitWebView *web_view); 153 154 WEBKIT_API gboolean 155 webkit_web_view_can_go_back_or_forward (WebKitWebView *web_view, 156 gint steps); 157 158 WEBKIT_API gboolean 159 webkit_web_view_can_go_forward (WebKitWebView *web_view); 160 161 WEBKIT_API void 162 webkit_web_view_go_back (WebKitWebView *web_view); 163 164 WEBKIT_API void 165 webkit_web_view_go_back_or_forward (WebKitWebView *web_view, 166 gint steps); 167 168 WEBKIT_API void 169 webkit_web_view_go_forward (WebKitWebView *web_view); 170 171 WEBKIT_API void 172 webkit_web_view_stop_loading (WebKitWebView *web_view); 173 174 WEBKIT_API void 175 webkit_web_view_open (WebKitWebView *web_view, 176 const gchar *uri); 177 178 WEBKIT_API void 179 webkit_web_view_reload (WebKitWebView *web_view); 180 181 WEBKIT_API void 182 webkit_web_view_reload_bypass_cache (WebKitWebView *web_view); 183 184 WEBKIT_API void 185 webkit_web_view_load_uri (WebKitWebView *web_view, 186 const gchar *uri); 187 188 WEBKIT_API void 189 webkit_web_view_load_string (WebKitWebView *web_view, 190 const gchar *content, 191 const gchar *mime_type, 192 const gchar *encoding, 193 const gchar *base_uri); 194 195 WEBKIT_API void 196 webkit_web_view_load_html_string (WebKitWebView *web_view, 197 const gchar *content, 198 const gchar *base_uri); 199 200 WEBKIT_API void 201 webkit_web_view_load_request (WebKitWebView *web_view, 202 WebKitNetworkRequest *request); 203 204 WEBKIT_API gboolean 205 webkit_web_view_search_text (WebKitWebView *web_view, 206 const gchar *text, 207 gboolean case_sensitive, 208 gboolean forward, 209 gboolean wrap); 210 211 WEBKIT_API guint 212 webkit_web_view_mark_text_matches (WebKitWebView *web_view, 213 const gchar *string, 214 gboolean case_sensitive, 215 guint limit); 216 217 WEBKIT_API void 218 webkit_web_view_set_highlight_text_matches (WebKitWebView *web_view, 219 gboolean highlight); 220 221 WEBKIT_API void 222 webkit_web_view_unmark_text_matches (WebKitWebView *web_view); 223 224 WEBKIT_API WebKitWebFrame * 225 webkit_web_view_get_main_frame (WebKitWebView *web_view); 226 227 WEBKIT_API WebKitWebFrame * 228 webkit_web_view_get_focused_frame (WebKitWebView *web_view); 229 230 WEBKIT_API void 231 webkit_web_view_execute_script (WebKitWebView *web_view, 232 const gchar *script); 233 234 WEBKIT_API gboolean 235 webkit_web_view_can_cut_clipboard (WebKitWebView *web_view); 236 237 WEBKIT_API gboolean 238 webkit_web_view_can_copy_clipboard (WebKitWebView *web_view); 239 240 WEBKIT_API gboolean 241 webkit_web_view_can_paste_clipboard (WebKitWebView *web_view); 242 243 WEBKIT_API void 244 webkit_web_view_cut_clipboard (WebKitWebView *web_view); 245 246 WEBKIT_API void 247 webkit_web_view_copy_clipboard (WebKitWebView *web_view); 248 249 WEBKIT_API void 250 webkit_web_view_paste_clipboard (WebKitWebView *web_view); 251 252 WEBKIT_API void 253 webkit_web_view_delete_selection (WebKitWebView *web_view); 254 255 WEBKIT_API gboolean 256 webkit_web_view_has_selection (WebKitWebView *web_view); 257 258 WEBKIT_API void 259 webkit_web_view_select_all (WebKitWebView *web_view); 260 261 WEBKIT_API gboolean 262 webkit_web_view_get_editable (WebKitWebView *web_view); 263 264 WEBKIT_API void 265 webkit_web_view_set_editable (WebKitWebView *web_view, 266 gboolean flag); 267 268 WEBKIT_API GtkTargetList * 269 webkit_web_view_get_copy_target_list (WebKitWebView *web_view); 270 271 WEBKIT_API GtkTargetList * 272 webkit_web_view_get_paste_target_list (WebKitWebView *web_view); 273 274 WEBKIT_API void 275 webkit_web_view_set_settings (WebKitWebView *web_view, 276 WebKitWebSettings *settings); 277 278 WEBKIT_API WebKitWebSettings * 279 webkit_web_view_get_settings (WebKitWebView *web_view); 280 281 WEBKIT_API WebKitWebInspector * 282 webkit_web_view_get_inspector (WebKitWebView *web_view); 283 284 WEBKIT_API WebKitWebWindowFeatures* 285 webkit_web_view_get_window_features (WebKitWebView *web_view); 286 287 WEBKIT_API gboolean 288 webkit_web_view_can_show_mime_type (WebKitWebView *web_view, 289 const gchar *mime_type); 290 291 WEBKIT_API gboolean 292 webkit_web_view_get_transparent (WebKitWebView *web_view); 293 294 WEBKIT_API void 295 webkit_web_view_set_transparent (WebKitWebView *web_view, 296 gboolean flag); 297 298 WEBKIT_API gfloat 299 webkit_web_view_get_zoom_level (WebKitWebView *web_view); 300 301 WEBKIT_API void 302 webkit_web_view_set_zoom_level (WebKitWebView *web_view, 303 gfloat zoom_level); 304 305 WEBKIT_API void 306 webkit_web_view_zoom_in (WebKitWebView *web_view); 307 308 WEBKIT_API void 309 webkit_web_view_zoom_out (WebKitWebView *web_view); 310 311 WEBKIT_API gboolean 312 webkit_web_view_get_full_content_zoom (WebKitWebView *web_view); 313 314 WEBKIT_API void 315 webkit_web_view_set_full_content_zoom (WebKitWebView *web_view, 316 gboolean full_content_zoom); 317 318 WEBKIT_API SoupSession* 319 webkit_get_default_session (void); 320 321 WEBKIT_API const gchar* 322 webkit_web_view_get_encoding (WebKitWebView * webView); 323 324 WEBKIT_API void 325 webkit_web_view_set_custom_encoding (WebKitWebView * webView, 326 const gchar * encoding); 327 328 WEBKIT_API const char* 329 webkit_web_view_get_custom_encoding (WebKitWebView * webView); 330 331 WEBKIT_API void 332 webkit_web_view_move_cursor (WebKitWebView * webView, 333 GtkMovementStep step, 334 gint count); 335 336 WEBKIT_API WebKitLoadStatus 337 webkit_web_view_get_load_status (WebKitWebView *web_view); 338 339 WEBKIT_API gdouble 340 webkit_web_view_get_progress (WebKitWebView *web_view); 341 342 G_END_DECLS 343 344 #endif 345