1 /* 2 * e-web-view.h 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, but 9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public License 14 * along with this program; if not, see <http://www.gnu.org/licenses/>. 15 * 16 */ 17 18 /* This is intended to serve as a common base class for all HTML viewing 19 * needs in Evolution. 20 * 21 * This class handles basic tasks like mouse hovers over links, clicked 22 * links, and servicing URI requests asynchronously via GIO. */ 23 24 #if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION) 25 #error "Only <e-util/e-util.h> should be included directly." 26 #endif 27 28 #ifndef E_WEB_VIEW_H 29 #define E_WEB_VIEW_H 30 31 #include <webkit2/webkit2.h> 32 #include <e-util/e-activity.h> 33 #include <e-util/e-content-request.h> 34 35 /* Standard GObject macros */ 36 #define E_TYPE_WEB_VIEW \ 37 (e_web_view_get_type ()) 38 #define E_WEB_VIEW(obj) \ 39 (G_TYPE_CHECK_INSTANCE_CAST \ 40 ((obj), E_TYPE_WEB_VIEW, EWebView)) 41 #define E_WEB_VIEW_CLASS(cls) \ 42 (G_TYPE_CHECK_CLASS_CAST \ 43 ((cls), E_TYPE_WEB_VIEW, EWebViewClass)) 44 #define E_IS_WEB_VIEW(obj) \ 45 (G_TYPE_CHECK_INSTANCE_TYPE \ 46 ((obj), E_TYPE_WEB_VIEW)) 47 #define E_IS_WEB_VIEW_CLASS(cls) \ 48 (G_TYPE_CHECK_CLASS_TYPE \ 49 ((cls), E_TYPE_WEB_VIEW)) 50 #define E_WEB_VIEW_GET_CLASS(obj) \ 51 (G_TYPE_INSTANCE_GET_CLASS \ 52 ((obj), E_TYPE_WEB_VIEW, EWebViewClass)) 53 54 G_BEGIN_DECLS 55 56 typedef struct _EWebView EWebView; 57 typedef struct _EWebViewClass EWebViewClass; 58 typedef struct _EWebViewPrivate EWebViewPrivate; 59 60 typedef enum { 61 CID_URI_SCHEME, 62 FILE_URI_SCHEME, 63 MAIL_URI_SCHEME, 64 EVO_HTTP_URI_SCHEME, 65 EVO_HTTPS_URI_SCHEME, 66 GTK_STOCK_URI_SCHEME 67 } EURIScheme; 68 69 typedef void (*EWebViewElementClickedFunc) (EWebView *web_view, 70 const gchar *iframe_id, 71 const gchar *element_id, 72 const gchar *element_class, 73 const gchar *element_value, 74 const GtkAllocation *element_position, 75 gpointer user_data); 76 77 struct _EWebView { 78 WebKitWebView parent; 79 EWebViewPrivate *priv; 80 }; 81 82 struct _EWebViewClass { 83 WebKitWebViewClass parent_class; 84 85 /* Methods */ 86 void (*hovering_over_link) (EWebView *web_view, 87 const gchar *title, 88 const gchar *uri); 89 void (*link_clicked) (EWebView *web_view, 90 const gchar *uri); 91 void (*load_string) (EWebView *web_view, 92 const gchar *load_string); 93 void (*load_uri) (EWebView *web_view, 94 const gchar *load_uri); 95 gchar * (*suggest_filename) (EWebView *web_view, 96 const gchar *uri); 97 void (*set_fonts) (EWebView *web_view, 98 PangoFontDescription **monospace, 99 PangoFontDescription **variable_width); 100 101 /* Signals */ 102 void (*new_activity) (EWebView *web_view, 103 EActivity *activity); 104 gboolean (*popup_event) (EWebView *web_view, 105 const gchar *uri, 106 GdkEvent *event); 107 void (*status_message) (EWebView *web_view, 108 const gchar *status_message); 109 void (*stop_loading) (EWebView *web_view); 110 void (*update_actions) (EWebView *web_view); 111 gboolean (*process_mailto) (EWebView *web_view, 112 const gchar *mailto_uri); 113 void (*uri_requested) (EWebView *web_view, 114 const gchar *uri, 115 gchar **redirect_to_uri); 116 void (*content_loaded) (EWebView *web_view, 117 const gchar *frame_id); 118 void (*before_popup_event) (EWebView *web_view, 119 const gchar *uri); 120 121 /* Padding for future expansion */ 122 gpointer reserved[15]; 123 }; 124 125 GType e_web_view_get_type (void) G_GNUC_CONST; 126 GtkWidget * e_web_view_new (void); 127 WebKitSettings * 128 e_web_view_get_default_webkit_settings 129 (void); 130 void e_web_view_utils_apply_minimum_font_size 131 (WebKitSettings *wk_settings); 132 gint e_web_view_get_minimum_font_size(EWebView *web_view); 133 void e_web_view_set_minimum_font_size(EWebView *web_view, 134 gint pixels); 135 GCancellable * e_web_view_get_cancellable (EWebView *web_view); 136 void e_web_view_register_content_request_for_scheme 137 (EWebView *web_view, 138 const gchar *scheme, 139 EContentRequest *content_request); 140 void e_web_view_update_fonts_settings 141 (GSettings *font_settings, 142 PangoFontDescription *ms_font, 143 PangoFontDescription *vw_font, 144 GtkWidget *view_widget); 145 void e_web_view_clear (EWebView *web_view); 146 void e_web_view_load_string (EWebView *web_view, 147 const gchar *string); 148 void e_web_view_load_uri (EWebView *web_view, 149 const gchar *uri); 150 gchar * e_web_view_suggest_filename (EWebView *web_view, 151 const gchar *uri); 152 void e_web_view_reload (EWebView *web_view); 153 gboolean e_web_view_get_caret_mode (EWebView *web_view); 154 void e_web_view_set_caret_mode (EWebView *web_view, 155 gboolean caret_mode); 156 GtkTargetList * e_web_view_get_copy_target_list (EWebView *web_view); 157 gboolean e_web_view_get_disable_printing (EWebView *web_view); 158 void e_web_view_set_disable_printing (EWebView *web_view, 159 gboolean disable_printing); 160 gboolean e_web_view_get_disable_save_to_disk 161 (EWebView *web_view); 162 void e_web_view_set_disable_save_to_disk 163 (EWebView *web_view, 164 gboolean disable_save_to_disk); 165 gboolean e_web_view_get_editable (EWebView *web_view); 166 void e_web_view_set_editable (EWebView *web_view, 167 gboolean editable); 168 gboolean e_web_view_get_need_input (EWebView *web_view); 169 gboolean e_web_view_get_inline_spelling (EWebView *web_view); 170 void e_web_view_set_inline_spelling (EWebView *web_view, 171 gboolean inline_spelling); 172 gboolean e_web_view_get_magic_links (EWebView *web_view); 173 void e_web_view_set_magic_links (EWebView *web_view, 174 gboolean magic_links); 175 gboolean e_web_view_get_magic_smileys (EWebView *web_view); 176 void e_web_view_set_magic_smileys (EWebView *web_view, 177 gboolean magic_smileys); 178 const gchar * e_web_view_get_selected_uri (EWebView *web_view); 179 void e_web_view_set_selected_uri (EWebView *web_view, 180 const gchar *selected_uri); 181 const gchar * e_web_view_get_cursor_image_src (EWebView *web_view); 182 void e_web_view_set_cursor_image_src (EWebView *web_view, 183 const gchar *src_uri); 184 GtkAction * e_web_view_get_open_proxy (EWebView *web_view); 185 void e_web_view_set_open_proxy (EWebView *web_view, 186 GtkAction *open_proxy); 187 GtkTargetList * e_web_view_get_paste_target_list 188 (EWebView *web_view); 189 GtkAction * e_web_view_get_print_proxy (EWebView *web_view); 190 void e_web_view_set_print_proxy (EWebView *web_view, 191 GtkAction *print_proxy); 192 GtkAction * e_web_view_get_save_as_proxy (EWebView *web_view); 193 void e_web_view_set_save_as_proxy (EWebView *web_view, 194 GtkAction *save_as_proxy); 195 void e_web_view_get_last_popup_place (EWebView *web_view, 196 gchar **out_iframe_src, 197 gchar **out_iframe_id, 198 gchar **out_element_id, 199 gchar **out_link_uri); 200 void e_web_view_add_highlight (EWebView *web_view, 201 const gchar *highlight); 202 void e_web_view_clear_highlights (EWebView *web_view); 203 void e_web_view_update_highlights (EWebView *web_view); 204 void e_web_view_disable_highlights (EWebView *web_view); 205 GtkAction * e_web_view_get_action (EWebView *web_view, 206 const gchar *action_name); 207 GtkActionGroup *e_web_view_get_action_group (EWebView *web_view, 208 const gchar *group_name); 209 void e_web_view_copy_clipboard (EWebView *web_view); 210 void e_web_view_cut_clipboard (EWebView *web_view); 211 gboolean e_web_view_has_selection (EWebView *web_view); 212 void e_web_view_paste_clipboard (EWebView *web_view); 213 gboolean e_web_view_scroll_forward (EWebView *web_view); 214 gboolean e_web_view_scroll_backward (EWebView *web_view); 215 void e_web_view_select_all (EWebView *web_view); 216 void e_web_view_unselect_all (EWebView *web_view); 217 void e_web_view_zoom_100 (EWebView *web_view); 218 void e_web_view_zoom_in (EWebView *web_view); 219 void e_web_view_zoom_out (EWebView *web_view); 220 GtkUIManager * e_web_view_get_ui_manager (EWebView *web_view); 221 GtkWidget * e_web_view_get_popup_menu (EWebView *web_view); 222 void e_web_view_show_popup_menu (EWebView *web_view, 223 GdkEvent *event); 224 EActivity * e_web_view_new_activity (EWebView *web_view); 225 void e_web_view_status_message (EWebView *web_view, 226 const gchar *status_message); 227 void e_web_view_stop_loading (EWebView *web_view); 228 void e_web_view_update_actions (EWebView *web_view); 229 void e_web_view_update_fonts (EWebView *web_view); 230 void e_web_view_cursor_image_copy (EWebView *web_view); 231 void e_web_view_cursor_image_save (EWebView *web_view); 232 void e_web_view_request (EWebView *web_view, 233 const gchar *uri, 234 GCancellable *cancellable, 235 GAsyncReadyCallback callback, 236 gpointer user_data); 237 GInputStream * e_web_view_request_finish (EWebView *web_view, 238 GAsyncResult *result, 239 GError **error); 240 void e_web_view_install_request_handler 241 (EWebView *web_view, 242 GType handler_type); 243 const gchar * e_web_view_get_citation_color_for_level 244 (gint level); 245 void e_web_view_set_iframe_src (EWebView *web_view, 246 const gchar *iframe_id, 247 const gchar *new_src); 248 void e_web_view_register_element_clicked 249 (EWebView *web_view, 250 const gchar *element_class, 251 EWebViewElementClickedFunc callback, 252 gpointer user_data); 253 void e_web_view_unregister_element_clicked 254 (EWebView *web_view, 255 const gchar *element_class, 256 EWebViewElementClickedFunc callback, 257 gpointer user_data); 258 void e_web_view_set_element_hidden (EWebView *web_view, 259 const gchar *element_id, 260 gboolean hidden); 261 void e_web_view_set_element_style_property 262 (EWebView *web_view, 263 const gchar *element_id, 264 const gchar *property_name, 265 const gchar *value); 266 void e_web_view_set_element_attribute 267 (EWebView *web_view, 268 const gchar *element_id, 269 const gchar *namespace_uri, 270 const gchar *qualified_name, 271 const gchar *value); 272 G_END_DECLS 273 274 #endif /* E_WEB_VIEW_H */ 275