comparison pidgin/gtkwebview.h @ 32541:b89351c7580b

safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
author tdrhq@soc.pidgin.im
date Mon, 10 Aug 2009 07:33:21 +0000
parents ac42a0dfda48
children 25d99f3621bb
comparison
equal deleted inserted replaced
32540:7b92a2b852db 32541:b89351c7580b
33 33
34 #define GTK_TYPE_WEBVIEW (gtk_webview_get_type()) 34 #define GTK_TYPE_WEBVIEW (gtk_webview_get_type())
35 #define GTK_WEBVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_WEBVIEW, GtkWebView)) 35 #define GTK_WEBVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_WEBVIEW, GtkWebView))
36 #define GTK_WEBVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_WEBVIEW, GtkWebViewClass)) 36 #define GTK_WEBVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_WEBVIEW, GtkWebViewClass))
37 #define GTK_IS_WEBVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_WEBVIEW)) 37 #define GTK_IS_WEBVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_WEBVIEW))
38 #define GTK_IS_IMHTML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_WEBVIEW)) 38 #define GTK_IS_WEBVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_WEBVIEW))
39 39
40
41 struct GtkWebViewPriv;
40 42
41 struct _GtkWebView 43 struct _GtkWebView
42 { 44 {
43 WebKitWebView webkit_web_view; 45 WebKitWebView webkit_web_view;
44 46
45 /*< private >*/ 47 /*< private >*/
46 GHashTable *images; /**< a map from id to temporary file for the image */ 48 struct GtkWebViewPriv* priv;
47 gboolean empty; /**< whether anything has been appended **/
48 char *script_return; /**< the last value returned from a script **/
49 }; 49 };
50 50
51 typedef struct _GtkWebView GtkWebView; 51 typedef struct _GtkWebView GtkWebView;
52 52
53 struct _GtkWebViewClass 53 struct _GtkWebViewClass
104 104
105 /** 105 /**
106 * Executes javascript and returns the answer of the script 106 * Executes javascript and returns the answer of the script
107 * formatted as string. The return value needs to be freed using 107 * formatted as string. The return value needs to be freed using
108 * g_free. If the return values is not required you may instead 108 * g_free. If the return values is not required you may instead
109 * use webkit_web_view_execute_script. 109 * use webkit_web_view_execute_script, or even better
110 * gtk_webview_safe_execute_script.
110 * 111 *
111 * @param webview The GtkWebView object 112 * @param webview The GtkWebView object
112 * @param script The JavaScript to execute 113 * @param script The JavaScript to execute
113 * 114 *
114 * @return the return value of the script. 115 * @return the return value of the script.
115 */ 116 */
116 char* gtk_webview_execute_script (GtkWebView *webview, const char *script); 117 char* gtk_webview_execute_script (GtkWebView *webview, const char *script);
118
119 /**
120 * Execute the JavaScript only after the webkit_webview_load_string
121 * loads completely. We also guarantee that the scripts are executed
122 * in the order they are called here.This is useful to avoid race
123 * conditions when calls JS functions immediately after opening the
124 * page.
125 *
126 * @param webview the GtkWebView object
127 * @param script the script to execute
128 */
129 void gtk_webview_safe_execute_script (GtkWebView *webview, const char* script);
117 130
118 /** 131 /**
119 * Get the current contents of the GtkWebView object. 132 * Get the current contents of the GtkWebView object.
120 * 133 *
121 * @param webview The GtkWebView object 134 * @param webview The GtkWebView object