* Customizable and extensible interface.
* Extensions written in C.
-Requirements: GTK+ 2.10, WebkitGTK+ 1.1.4, libXML2, libsoup 2.25.2, sqlite 3.0
+Requirements: GTK+ 2.10, WebkitGTK+ 1.1.14, libXML2, libsoup 2.25.2, sqlite 3.0
Optional: Unique 0.9, libidn, docutils, libnotify, Vala
gtk_label_set_markup (GTK_LABEL (label), markup);
g_free (markup);
katze_preferences_add_widget (preferences, label, "filled");
- #if WEBKIT_CHECK_VERSION (1, 1, 13)
button = katze_property_proxy (settings, "enable-offline-web-application-cache", NULL);
katze_preferences_add_widget (preferences, button, "indented");
- #endif
- #if WEBKIT_CHECK_VERSION (1, 1, 8)
button = katze_property_proxy (settings, "enable-html5-local-storage", NULL);
katze_preferences_add_widget (preferences, button, "spanned");
- #if !WEBKIT_CHECK_VERSION (1, 1, 14)
- button = katze_property_proxy (settings, "enable-html5-database", NULL);
- katze_preferences_add_widget (preferences, button, "indented");
- #endif
- #endif
#if HAVE_LIBSOUP_2_27_90
button = katze_property_proxy (settings, "strip-referer", NULL);
katze_preferences_add_widget (preferences, button, "indented");
midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));
/* Transfers */
- #if WEBKIT_CHECK_VERSION (1, 1, 3)
addon = g_object_new (MIDORI_TYPE_TRANSFERS, "app", app, NULL);
gtk_widget_show (addon);
midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));
- #endif
/* Extensions */
g_signal_connect (browser, "show-preferences",
midori_soup_session_set_proxy_uri (session, NULL);
}
-#if !WEBKIT_CHECK_VERSION (1, 1, 11)
-static void
-soup_session_settings_notify_ident_string_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- SoupSession* session)
-{
- gchar* ident_string = katze_object_get_string (settings, "user-agent");
- g_object_set (session, "user-agent", ident_string, NULL);
- g_free (ident_string);
-}
-#endif
-
static void
midori_soup_session_settings_accept_language_cb (SoupSession* session,
SoupMessage* msg,
g_signal_connect (settings, "notify::proxy-type",
G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
- #if !WEBKIT_CHECK_VERSION (1, 1, 11)
- soup_session_settings_notify_ident_string_cb (settings, NULL, session);
- g_signal_connect (settings, "notify::user-agent",
- G_CALLBACK (soup_session_settings_notify_ident_string_cb), session);
- #endif
-
g_signal_connect (session, "request-queued",
G_CALLBACK (midori_soup_session_settings_accept_language_cb), settings);
return 1;
}
-#if WEBKIT_CHECK_VERSION (1, 1, 6)
static void
snapshot_load_finished_cb (GtkWidget* web_view,
WebKitWebFrame* web_frame,
g_print (_("Snapshot saved to: %s\n"), filename);
gtk_main_quit ();
}
-#endif
static void
midori_web_app_browser_notify_load_status_cb (MidoriBrowser* browser,
g_free (path);
}
-#if WEBKIT_CHECK_VERSION (1, 1, 14)
static void
midori_clear_html5_databases_cb (void)
{
webkit_remove_all_web_databases ();
}
-#endif
#if WEBKIT_CHECK_VERSION (1, 3, 11)
static void
N_("Show a diagnostic dialog"), NULL },
{ "run", 'r', 0, G_OPTION_ARG_NONE, &run,
N_("Run the specified filename as javascript"), NULL },
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
{ "snapshot", 's', 0, G_OPTION_ARG_STRING, &snapshot,
N_("Take a snapshot of the specified URI"), NULL },
- #endif
{ "execute", 'e', 0, G_OPTION_ARG_NONE, &execute,
N_("Execute the specified command"), NULL },
{ "help-execute", 0, 0, G_OPTION_ARG_NONE, &help_execute,
return 0;
}
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
if (snapshot)
{
gchar* filename;
g_free (filename);
return 0;
}
- #endif
if (logfile)
{
{
g_object_set (settings,
"preferred-languages", "en",
- #if WEBKIT_CHECK_VERSION (1, 1, 2)
"enable-private-browsing", TRUE,
- #endif
- #if WEBKIT_CHECK_VERSION (1, 1, 8)
"enable-html5-database", FALSE,
"enable-html5-local-storage", FALSE,
"enable-offline-web-application-cache", FALSE,
- #endif
/* Arguably DNS prefetching is or isn't a privacy concern. For the
* lack of more fine-grained control we'll go the safe route. */
"enable-dns-prefetching", FALSE,
static void
_midori_browser_update_notebook (MidoriBrowser* browser);
-#if WEBKIT_CHECK_VERSION (1, 1, 3)
void
midori_transferbar_add_download_item (MidoriTransferbar* transferbar,
WebKitDownload* download);
-#endif
#define _action_by_name(brwsr, nme) \
gtk_action_group_get_action (brwsr->action_group, nme)
_action_set_sensitive (browser, "ZoomOut", midori_view_can_zoom_out (view));
_action_set_sensitive (browser, "ZoomNormal",
midori_view_get_zoom_level (view) != 1.0f);
- #if WEBKIT_CHECK_VERSION (1, 1, 2)
_action_set_sensitive (browser, "Encoding",
midori_view_can_view_source (view));
- #endif
_action_set_sensitive (browser, "SourceView",
midori_view_can_view_source (view));
_action_set_sensitive (browser, "Find",
midori_browser_set_title (MidoriBrowser* browser,
const gchar* title)
{
- #if WEBKIT_CHECK_VERSION (1, 1, 2)
if (katze_object_get_boolean (browser->settings, "enable-private-browsing"))
{
gchar* window_title = g_strdup_printf (_("%s (Private Browsing)"), title);
g_free (window_title);
}
else
- #endif
gtk_window_set_title (GTK_WINDOW (browser), title);
}
return return_status;
}
-#if WEBKIT_CHECK_VERSION (1, 1, 3)
static gboolean
midori_browser_prepare_download (MidoriBrowser* browser,
WebKitDownload* download,
midori_transferbar_add_download_item (MIDORI_TRANSFERBAR (browser->transferbar), download);
return TRUE;
}
-#else
-static void
-midori_browser_save_transfer_cb (KatzeNetRequest* request,
- gchar* filename)
-{
- FILE* fp;
- size_t ret;
-
- if (request->data)
- {
- if ((fp = fopen (filename, "wb")))
- {
- ret = fwrite (request->data, 1, request->length, fp);
- fclose (fp);
- if ((ret - request->length) != 0)
- {
- /* Once we have a download interface this should be
- indicated graphically. */
- g_warning ("Error writing to file %s "
- "in midori_browser_save_transfer_cb", filename);
- }
- }
- }
- g_free (filename);
-}
-#endif
static gchar*
midori_browser_save_source (const gchar* uri,
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
{
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
GtkWidget* view;
GtkWidget* web_view;
WebKitWebDataSource *data_source;
WebKitWebFrame *frame;
const GString *data;
- #else
- WebKitNetworkRequest* request;
- WebKitDownload* download;
- gchar* destination;
- #endif
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
view = midori_browser_get_current_tab (browser);
web_view = midori_view_get_web_view (MIDORI_VIEW (view));
frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
data_source = webkit_web_frame_get_data_source (frame);
data = webkit_web_data_source_get_data (data_source);
midori_browser_save_source (uri, data->str, data->len, filename);
- #else
- request = webkit_network_request_new (uri);
- download = webkit_download_new (request);
- g_object_unref (request);
- destination = g_filename_to_uri (filename, NULL, NULL);
- if (midori_browser_prepare_download (browser, download, destination))
- webkit_download_start (download);
- g_free (destination);
- #endif
g_free (last_dir);
last_dir = folder;
}
}
-#if WEBKIT_CHECK_VERSION (1, 1, 3)
-
static void
midori_view_download_save_as_response_cb (GtkWidget* dialog,
gint response,
}
return TRUE;
}
-#endif
static void
midori_view_search_text_cb (GtkWidget* view,
midori_view_new_window_cb, browser,
"signal::new-view",
midori_view_new_view_cb, browser,
- #if WEBKIT_CHECK_VERSION (1, 1, 3)
"signal::download-requested",
midori_view_download_requested_cb, browser,
- #endif
"signal::search-text",
midori_view_search_text_cb, browser,
"signal::save-as",
MidoriBrowser* browser)
{
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
gboolean can_undo = FALSE, can_redo = FALSE;
- #endif
gboolean can_cut = FALSE, can_copy = FALSE, can_paste = FALSE;
gboolean has_selection, can_select_all = FALSE;
if (WEBKIT_IS_WEB_VIEW (widget))
{
WebKitWebView* view = WEBKIT_WEB_VIEW (widget);
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
can_undo = webkit_web_view_can_undo (view);
can_redo = webkit_web_view_can_redo (view);
- #endif
can_cut = webkit_web_view_can_cut_clipboard (view);
can_copy = webkit_web_view_can_copy_clipboard (view);
can_paste = webkit_web_view_can_paste_clipboard (view);
can_select_all = TRUE;
}
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
_action_set_sensitive (browser, "Undo", can_undo);
_action_set_sensitive (browser, "Redo", can_redo);
- #endif
_action_set_sensitive (browser, "Cut", can_cut);
_action_set_sensitive (browser, "Copy", can_copy);
_action_set_sensitive (browser, "Paste", can_paste);
_action_set_sensitive (browser, "SelectAll", can_select_all);
}
-#if WEBKIT_CHECK_VERSION (1, 1, 14)
static void
_action_undo_activate (GtkAction* action,
MidoriBrowser* browser)
if (WEBKIT_IS_WEB_VIEW (widget))
webkit_web_view_redo (WEBKIT_WEB_VIEW (widget));
}
-#endif
static void
_action_cut_activate (GtkAction* action,
{
{ "ManageSearchEngines" },
{ "ClearPrivateData" },
- #if WEBKIT_CHECK_VERSION (1, 1, 17)
{ "InspectPage" },
- #endif
{ "-" },
{ NULL },
{ "p" },
{ "Find" },
#if !HAVE_HILDON
{ "Print" },
- #if WEBKIT_CHECK_VERSION (1, 1, 17)
{ "InspectPage" },
#endif
- #endif
{ NULL },
{ "PrivateBrowsing" },
#if !HAVE_HILDON
GtkAction* current,
MidoriBrowser* browser)
{
- #if WEBKIT_CHECK_VERSION (1, 1, 2)
GtkWidget* view = midori_browser_get_current_tab (browser);
if (view)
{
g_object_set (web_view, "custom-encoding", encoding, NULL);
}
}
- #endif
}
static gchar*
return unique_filename;
}
-#if !WEBKIT_CHECK_VERSION (1, 1, 14)
-static void
-midori_browser_source_transfer_cb (KatzeNetRequest* request,
- MidoriBrowser* browser)
-{
- gchar* text_editor;
- gchar* filename;
-
- filename = midori_browser_save_source (request->uri, request->data, request->length, NULL);
- if (filename)
- {
- g_object_get (browser->settings,
- "text-editor", &text_editor, NULL);
- if (text_editor && *text_editor)
- sokoke_spawn_program (text_editor, filename);
- else
- sokoke_show_uri (NULL, filename,
- gtk_get_current_event_time (), NULL);
- g_free (text_editor);
- }
- g_free (filename);
-}
-#endif
-
static void
_action_source_view_activate (GtkAction* action,
MidoriBrowser* browser)
if (!(text_editor && *text_editor))
{
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
GtkWidget* source;
GtkWidget* web_view;
midori_browser_add_tab (browser, source);
g_free (text_editor);
return;
- #else
- GError* error = NULL;
-
- if (g_str_has_prefix (uri, "file://"))
- {
- if (!sokoke_show_uri_with_mime_type (gtk_widget_get_screen (view),
- uri, "text/plain", gtk_get_current_event_time (), &error))
- sokoke_message_dialog (GTK_MESSAGE_ERROR,
- _("Could not run external program."),
- error ? error->message : "", FALSE);
- if (error)
- g_error_free (error);
- g_free (text_editor);
- return;
- }
- #endif
}
if (g_str_has_prefix (uri, "file://"))
filename = g_filename_from_uri (uri, NULL, NULL);
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
else
{
WebKitWebDataSource *data_source;
sokoke_spawn_program (text_editor, filename);
g_free (filename);
}
- #else
- katze_net_load_uri (NULL, uri, NULL,
- (KatzeNetTransferCb)midori_browser_source_transfer_cb, browser);
- #endif
g_free (text_editor);
}
-#if WEBKIT_CHECK_VERSION (1, 1, 6)
static void
_action_caret_browsing_activate (GtkAction* action,
MidoriBrowser* browser)
g_object_set (browser->settings, "enable-caret-browsing",
!katze_object_get_boolean (browser->settings, "enable-caret-browsing"), NULL);
}
-#endif
static void
_action_fullscreen_activate (GtkAction* action,
gtk_window_fullscreen (GTK_WINDOW (browser));
}
-#if WEBKIT_CHECK_VERSION (1, 1, 4)
static void
_action_scroll_somewhere_activate (GtkAction* action,
MidoriBrowser* browser)
else if (g_str_equal (name, "ScrollRight"))
webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_VISUAL_POSITIONS, 1);
}
-#endif
static gboolean
_action_navigation_activate (GtkAction* action,
gtk_window_present (GTK_WINDOW (dialog));
}
-#if WEBKIT_CHECK_VERSION (1, 1, 17)
static void
_action_inspect_page_activate (GtkAction* action,
MidoriBrowser* browser)
WebKitWebInspector* inspector = webkit_web_view_get_inspector (web_view);
webkit_web_inspector_show (inspector);
}
-#endif
static void
_action_tab_move_backward_activate (GtkAction* action,
N_("Close all open windows"), G_CALLBACK (_action_quit_activate) },
{ "Edit", NULL, N_("_Edit"), NULL, NULL, G_CALLBACK (_action_edit_activate) },
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
{ "Undo", GTK_STOCK_UNDO,
NULL, "<Ctrl>z",
N_("Undo the last modification"), G_CALLBACK (_action_undo_activate) },
{ "Redo", GTK_STOCK_REDO,
NULL, "<Ctrl><Shift>z",
N_("Redo the last modification"), G_CALLBACK (_action_redo_activate) },
- #endif
{ "Cut", GTK_STOCK_CUT,
NULL, "<Ctrl>x",
N_("Cut the selected text"), G_CALLBACK (_action_cut_activate) },
{ "SourceView", NULL,
N_("View So_urce"), "<Ctrl><Alt>U",
N_("View the source code of the page"), G_CALLBACK (_action_source_view_activate) },
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
{ "CaretBrowsing", NULL,
N_("Ca_ret Browsing"), "F7",
N_("Toggle text cursor navigation"), G_CALLBACK (_action_caret_browsing_activate) },
- #endif
{ "Fullscreen", GTK_STOCK_FULLSCREEN,
NULL, "F11",
N_("Toggle fullscreen view"), G_CALLBACK (_action_fullscreen_activate) },
- #if WEBKIT_CHECK_VERSION (1, 1, 4)
{ "ScrollLeft", NULL,
N_("Scroll _Left"), "h",
N_("Scroll to the left"), G_CALLBACK (_action_scroll_somewhere_activate) },
{ "ScrollRight", NULL,
N_("Scroll _Right"), "l",
N_("Scroll to the right"), G_CALLBACK (_action_scroll_somewhere_activate) },
- #endif
{ "Go", NULL, N_("_Go") },
{ "Back", GTK_STOCK_GO_BACK,
N_("_Clear Private Data"), "<Ctrl><Shift>Delete",
N_("Clear private data..."),
G_CALLBACK (_action_clear_private_data_activate) },
- #if WEBKIT_CHECK_VERSION (1, 1, 17)
{ "InspectPage", NULL,
N_("_Inspect Page"), "<Ctrl><Shift>i",
N_("Inspect page details and access developer tools..."),
G_CALLBACK (_action_inspect_page_activate) },
- #endif
{ "TabPrevious", GTK_STOCK_GO_BACK,
N_("_Previous Tab"), "<Ctrl>Page_Up",
"<menuitem action='Quit'/>"
"</menu>"
"<menu action='Edit'>"
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
"<menuitem action='Undo'/>"
"<menuitem action='Redo'/>"
"<separator/>"
- #endif
"<menuitem action='Cut'/>"
"<menuitem action='Copy'/>"
"<menuitem action='Paste'/>"
"<menuitem action='Preferences'/>"
"<menuitem action='InspectPage'/>"
"<menuitem action='ReloadUncached'/>"
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
"<menuitem action='CaretBrowsing'/>"
- #endif
"</menu>"
"</menubar>"
"<toolbar name='toolbar_navigation'>"
#if HAVE_HILDON
_action_set_visible (browser, "Menubar", FALSE);
#endif
- #if !WEBKIT_CHECK_VERSION (1, 1, 2)
- _action_set_sensitive (browser, "Encoding", FALSE);
- #endif
_action_set_sensitive (browser, "EncodingCustom", FALSE);
_action_set_visible (browser, "LastSession", FALSE);
#if !HAVE_HILDON && !defined (GDK_WINDOWING_X11)
#if !HAVE_HILDON
button = katze_property_proxy (settings, "auto-load-images", NULL);
INDENTED_ADD (button);
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
button = katze_property_proxy (settings, "enable-spell-checking", NULL);
- #else
- button = katze_property_proxy (settings, "enforce-96-dpi", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Enforce 96 dots per inch"));
- gtk_widget_set_tooltip_text (button, _("Enforce a video dot density of 96 DPI"));
- #endif
SPANNED_ADD (button);
button = katze_property_proxy (settings, "enable-scripts", NULL);
INDENTED_ADD (button);
#endif
button = katze_property_proxy (settings, "zoom-text-and-images", NULL);
INDENTED_ADD (button);
- #if WEBKIT_CHECK_VERSION (1, 1, 11)
button = katze_property_proxy (settings, "javascript-can-open-windows-automatically", NULL);
gtk_button_set_label (GTK_BUTTON (button), _("Allow scripts to open popups"));
gtk_widget_set_tooltip_text (button, _("Whether scripts are allowed to open popup windows automatically"));
SPANNED_ADD (button);
- #endif
button = NULL;
#if WEBKIT_CHECK_VERSION (1, 1, 15) || HAVE_HILDON
if (katze_widget_has_touchscreen_mode (parent ?
midori_view_apply_icon (view, icon, NULL);
}
-static void
-midori_view_icon_cb (GdkPixbuf* icon,
- MidoriView* view)
-{
- midori_view_update_icon (view, icon);
-}
-
-typedef void (*KatzeNetIconCb) (GdkPixbuf* icon,
- MidoriView* view);
-
-typedef struct
-{
- gchar* icon_file;
- gchar* icon_uri;
- MidoriView* view;
-} KatzeNetIconPriv;
-
-static void
-katze_net_icon_priv_free (KatzeNetIconPriv* priv)
-{
- g_free (priv->icon_file);
- g_free (priv->icon_uri);
- g_slice_free (KatzeNetIconPriv, priv);
-}
-
-static gboolean
-katze_net_icon_status_cb (KatzeNetRequest* request,
- KatzeNetIconPriv* priv)
-{
- switch (request->status)
- {
- case KATZE_NET_VERIFIED:
- if (request->mime_type && strncmp (request->mime_type, "image/", 6))
- {
- katze_net_icon_priv_free (priv);
- return FALSE;
- }
- break;
- case KATZE_NET_MOVED:
- break;
- default:
- katze_net_icon_priv_free (priv);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-katze_net_icon_transfer_cb (KatzeNetRequest* request,
- KatzeNetIconPriv* priv)
-{
- GdkPixbuf* pixbuf;
- FILE* fp;
- GdkPixbuf* pixbuf_scaled;
- gint icon_width, icon_height;
- size_t ret;
- GtkSettings* settings;
-
- if (request->status == KATZE_NET_MOVED)
- return;
-
- pixbuf = NULL;
- if (request->data)
- {
- if ((fp = fopen (priv->icon_file, "wb")))
- {
- ret = fwrite (request->data, 1, request->length, fp);
- fclose (fp);
- if ((ret - request->length) != 0)
- {
- g_warning ("Error writing to file %s "
- "in katze_net_icon_transfer_cb()", priv->icon_file);
- }
- pixbuf = gdk_pixbuf_new_from_file (priv->icon_file, NULL);
- }
- else
- pixbuf = katze_pixbuf_new_from_buffer ((guchar*)request->data,
- request->length, request->mime_type, NULL);
- if (pixbuf)
- g_object_ref (pixbuf);
- g_hash_table_insert (priv->view->memory,
- g_strdup (priv->icon_file), pixbuf);
- }
-
- if (!pixbuf)
- {
- midori_view_icon_cb (NULL, priv->view);
- katze_net_icon_priv_free (priv);
- return;
- }
-
- settings = gtk_widget_get_settings (priv->view->web_view);
- gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
- &icon_width, &icon_height);
- pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf, icon_width, icon_height,
- GDK_INTERP_BILINEAR);
- g_object_unref (pixbuf);
-
- katze_assign (priv->view->icon_uri, g_strdup (priv->icon_uri));
- midori_view_icon_cb (pixbuf_scaled, priv->view);
- katze_net_icon_priv_free (priv);
-}
-
static void
_midori_web_view_load_icon (MidoriView* view)
{
GdkPixbuf* pixbuf;
- KatzeNetIconPriv* priv;
gchar* icon_uri;
gchar* icon_file;
gint icon_width, icon_height;
g_free (icon_file);
katze_assign (view->icon_uri, icon_uri);
}
- else if (!view->special)
- {
- priv = g_slice_new (KatzeNetIconPriv);
- priv->icon_file = icon_file;
- priv->icon_uri = icon_uri;
- priv->view = view;
-
- katze_net_load_uri (NULL, icon_uri,
- (KatzeNetStatusCb)katze_net_icon_status_cb,
- (KatzeNetTransferCb)katze_net_icon_transfer_cb, priv);
- }
}
if (pixbuf)
g_object_notify (G_OBJECT (view), "progress");
}
-#if WEBKIT_CHECK_VERSION (1, 1, 14)
static void
midori_view_web_view_resource_request_cb (WebKitWebView* web_view,
WebKitWebFrame* web_frame,
}
}
}
-#endif
#define HAVE_GTK_INFO_BAR GTK_CHECK_VERSION (2, 18, 0)
return infobar;
}
-#if WEBKIT_CHECK_VERSION (1, 1, 14)
static void
midori_view_database_response_cb (GtkWidget* infobar,
gint response,
NULL);
g_free (message);
}
-#endif
#if WEBKIT_CHECK_VERSION (1, 1, 23)
static void
if (!web_frame)
web_frame = webkit_web_view_get_main_frame (web_view);
view->special = TRUE;
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
webkit_web_frame_load_alternate_string (
web_frame, data, uri, uri);
- #elif WEBKIT_CHECK_VERSION (1, 1, 6)
- webkit_web_frame_load_alternate_string (
- web_frame, data, res_root, uri);
- #else
- webkit_web_view_load_html_string (
- web_view, data, res_root);
- #endif
}
-#if WEBKIT_CHECK_VERSION (1, 1, 6)
static gboolean
midori_view_display_error (MidoriView* view,
const gchar* uri,
g_free (template_file);
if (g_file_get_contents (path, &template, NULL, NULL))
{
- #if !WEBKIT_CHECK_VERSION (1, 1, 14)
- SoupServer* res_server;
- guint port;
- #endif
gchar* res_root;
gchar* stock_root;
gchar* title_escaped;
gchar* result;
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
res_root = g_strdup ("res:/");
stock_root = g_strdup ("stock:/");
- #else
- res_server = sokoke_get_res_server ();
- port = soup_server_get_port (res_server);
- res_root = g_strdup_printf ("http://localhost:%d/res", port);
- stock_root = g_strdup_printf ("http://localhost:%d/stock", port);
- #endif
title_escaped = g_markup_escape_text (title, -1);
result = sokoke_replace_variables (template,
g_free (title);
return result;
}
-#else
-static void
-webkit_web_frame_load_done_cb (WebKitWebFrame* web_frame,
- gboolean success,
- MidoriView* view)
-{
- if (!success)
- {
- gchar* title;
- gchar* data;
- gchar* logo_path;
- gchar* logo_uri;
- /* i18n: The title of the 404 - Not found error page */
- title = g_strdup_printf (_("Not found - %s"), view->uri);
- katze_assign (view->title, title);
- logo_path = sokoke_find_data_filename ("midori/res/logo-shade.png");
- logo_uri = g_filename_to_uri (logo_path, NULL, NULL);
- g_free (logo_path);
- data = g_strdup_printf (
- "<html><head><title>%s</title></head>"
- "<body><h1>%s</h1>"
- "<img src=\"%s\" "
- "style=\"position: absolute; right: 15px; bottom: 15px; z-index: -9;\">"
- "<p />The page you were opening doesn't exist."
- "<p />Try to <a href=\"%s\">load the page again</a>, "
- "or move on to another page."
- "</body></html>",
- title, title, logo_uri, view->uri);
- webkit_web_view_load_html_string (
- WEBKIT_WEB_VIEW (view->web_view), data, view->uri);
- g_free (title);
- g_free (data);
- g_free (logo_uri);
- }
-
- midori_view_update_load_status (view, MIDORI_LOAD_FINISHED);
-}
-#endif
static void
midori_view_apply_scroll_position (MidoriView* view)
}
#endif
-#if WEBKIT_CHECK_VERSION (1, 1, 4)
static void
webkit_web_view_notify_uri_cb (WebKitWebView* web_view,
GParamSpec* pspec,
midori_view_set_title (view, title);
g_object_notify (G_OBJECT (view), "title");
}
-#else
-static void
-webkit_web_view_title_changed_cb (WebKitWebView* web_view,
- WebKitWebFrame* web_frame,
- const gchar* title,
- MidoriView* view)
-{
- g_object_set (view, "title", title, NULL);
-}
-#endif
static void
webkit_web_view_statusbar_text_changed_cb (WebKitWebView* web_view,
}
#endif
-#if !WEBKIT_CHECK_VERSION (1, 1, 3)
-static void
-midori_web_view_menu_save_as_activate_cb (GtkWidget* widget,
- MidoriView* view)
-{
- g_signal_emit (view, signals[SAVE_AS], 0, view->link_uri);
-}
-#endif
-
static void
midori_view_tab_label_menu_window_new_cb (GtkWidget* menuitem,
GtkWidget* view)
midori_view_get_display_uri (MIDORI_VIEW (view)));
}
-#if WEBKIT_CHECK_VERSION (1, 1, 17)
static void
midori_web_view_menu_inspect_element_activate_cb (GtkWidget* widget,
MidoriView* view)
webkit_web_inspector_inspect_coordinates (inspector, x, y);
webkit_web_inspector_show (inspector);
}
-#endif
static GtkWidget*
midori_view_insert_menu_item (GtkMenuShell* menu,
if (is_editable)
{
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_prepend (menu_shell, menuitem);
gtk_widget_show (menuitem);
gtk_widget_set_sensitive (menuitem,
webkit_web_view_can_undo (web_view));
gtk_menu_shell_prepend (menu_shell, menuitem);
- #endif
if (manual)
{
menuitem = sokoke_action_create_popup_menu_item (
gtk_action_group_get_action (actions, "SelectAll"));
gtk_menu_shell_append (menu_shell, menuitem);
/* FIXME: We are missing Font, Input Methods and Insert Character */
- #if WEBKIT_CHECK_VERSION (1, 1, 17)
if (katze_object_get_boolean (view->settings, "enable-developer-extras"))
{
menuitem = gtk_separator_menu_item_new ();
g_object_set_data (G_OBJECT (menuitem), "x", GINT_TO_POINTER (x));
g_object_set_data (G_OBJECT (menuitem), "y", GINT_TO_POINTER (y));
}
- #endif
}
return;
}
gtk_label_set_label (GTK_LABEL (label), _("Open Link in New _Window"));
menuitem = (GtkWidget*)g_list_nth_data (items, 3);
g_list_free (items);
- #if WEBKIT_CHECK_VERSION (1, 1, 3)
/* hack to localize menu item */
label = gtk_bin_get_child (GTK_BIN (menuitem));
GtkStockItem stock_item;
if (gtk_stock_lookup (GTK_STOCK_SAVE_AS, &stock_item))
gtk_label_set_label (GTK_LABEL (label), stock_item.label);
- #else
- /* hack to disable non-functional Download File */
- gtk_widget_hide (menuitem);
- gtk_widget_set_no_show_all (menuitem, TRUE);
- midori_view_insert_menu_item (menu_shell, 3,
- NULL, GTK_STOCK_SAVE_AS,
- G_CALLBACK (midori_web_view_menu_save_as_activate_cb), widget);
- #endif
}
#endif
}
}
- #if WEBKIT_CHECK_VERSION (1, 1, 17)
if ((!is_document || manual)
&& katze_object_get_boolean (view->settings, "enable-developer-extras"))
{
g_object_set_data (G_OBJECT (menuitem), "x", GINT_TO_POINTER (x));
g_object_set_data (G_OBJECT (menuitem), "y", GINT_TO_POINTER (y));
}
- #endif
gtk_widget_show_all (menu);
}
WebKitWebPolicyDecision* decision,
MidoriView* view)
{
- #if WEBKIT_CHECK_VERSION (1, 1, 3)
GtkWidget* dialog;
gchar* content_type;
gchar* description;
gchar* file_type;
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
WebKitWebDataSource* datasource;
WebKitNetworkRequest* original_request;
- #endif
const gchar* original_uri;
gchar** fingerprint;
#if GTK_CHECK_VERSION (2, 14, 0)
GdkScreen* screen;
GtkIconTheme* icon_theme;
gint response;
- #else
- gchar* uri;
- #endif
if (web_frame != webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view)))
return FALSE;
if (webkit_web_view_can_show_mime_type (WEBKIT_WEB_VIEW (web_view), mime_type))
{
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
gboolean view_source = FALSE;
/* Dedicated source code views are always pseudo-blank pages */
if (midori_view_is_blank (view))
|| !strcmp (mime_type, "text/xml")))
view_source = TRUE;
webkit_web_view_set_view_source_mode (WEBKIT_WEB_VIEW (web_view), view_source);
- #endif
katze_assign (view->mime_type, g_strdup (mime_type));
midori_view_update_icon (view, NULL);
return FALSE;
}
- #if WEBKIT_CHECK_VERSION (1, 1, 3)
dialog = gtk_message_dialog_new (
NULL, 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
_("Open or download file"));
g_free (description);
/* Link Fingerprint */
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
/* We look at the original URI because redirection would lose the fragment */
datasource = webkit_web_frame_get_provisional_data_source (web_frame);
original_request = webkit_web_data_source_get_initial_request (datasource);
original_uri = webkit_network_request_get_uri (original_request);
- #else
- original_uri = webkit_network_request_get_uri (request);
- #endif
fingerprint = g_strsplit (original_uri, "#!md5!", 2);
if (fingerprint && fingerprint[0] && fingerprint[1])
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
webkit_web_view_stop_loading (WEBKIT_WEB_VIEW (view->web_view));
return FALSE;
}
- #else
- katze_assign (view->mime_type, NULL);
- midori_view_update_icon (view, NULL);
- g_object_notify (G_OBJECT (view), "mime-type");
-
- uri = g_strdup_printf ("error:nodisplay %s",
- webkit_network_request_get_uri (request));
- midori_view_set_uri (view, uri);
- g_free (uri);
-
- return TRUE;
- #endif
}
-#if WEBKIT_CHECK_VERSION (1, 1, 3)
static gboolean
webkit_web_view_download_requested_cb (GtkWidget* web_view,
WebKitDownload* download,
MidoriView* view)
{
gboolean handled;
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
/* Propagate original URI to make it available when the download finishes */
WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
WebKitWebDataSource* datasource = webkit_web_frame_get_provisional_data_source (web_frame);
WebKitNetworkRequest* request = webkit_download_get_network_request (download);
g_object_set_data_full (G_OBJECT (request), "midori-original-uri",
g_strdup (original_uri), g_free);
- #endif
g_object_set_data (G_OBJECT (download), "open-download",
g_object_get_data (G_OBJECT (view), "open-download"));
g_object_set_data (G_OBJECT (download), "save-as-download",
g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled);
return handled;
}
-#endif
static gboolean
webkit_web_view_console_message_cb (GtkWidget* web_view,
return TRUE;
}
-#if WEBKIT_CHECK_VERSION (1, 1, 5)
static gboolean
midori_view_web_view_print_requested_cb (GtkWidget* web_view,
WebKitWebFrame* web_frame,
midori_view_print (view);
return TRUE;
}
-#endif
static void
webkit_web_view_window_object_cleared_cb (GtkWidget* web_view,
JSObjectRef js_window,
MidoriView* view)
{
- #if WEBKIT_CHECK_VERSION (1, 1, 2)
if (katze_object_get_boolean (view->settings, "enable-private-browsing"))
{
/* Mask language, architecture, no plugin list */
NULL);
g_free (result);
}
- #endif
g_signal_emit (view, signals[CONTEXT_READY], 0, js_context);
}
g_object_connect (view->web_view,
"signal::navigation-policy-decision-requested",
midori_view_web_view_navigation_decision_cb, view,
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
"signal::resource-request-starting",
midori_view_web_view_resource_request_cb, view,
- #endif
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
"signal::database-quota-exceeded",
midori_view_web_view_database_quota_exceeded_cb, view,
- #endif
#if WEBKIT_CHECK_VERSION (1, 1, 23)
"signal::geolocation-policy-decision-requested",
midori_view_web_view_geolocation_decision_cb, view,
"signal::notify::icon-uri",
midori_web_view_notify_icon_uri_cb, view,
#endif
- #if WEBKIT_CHECK_VERSION (1, 1, 4)
"signal::notify::uri",
webkit_web_view_notify_uri_cb, view,
"signal::notify::title",
webkit_web_view_notify_title_cb, view,
- #else
- "signal::title-changed",
- webkit_web_view_title_changed_cb, view,
- #endif
"signal::status-bar-text-changed",
webkit_web_view_statusbar_text_changed_cb, view,
"signal::leave-notify-event",
webkit_web_view_create_web_view_cb, view,
"signal-after::mime-type-policy-decision-requested",
webkit_web_view_mime_type_decision_cb, view,
- #if WEBKIT_CHECK_VERSION (1, 1, 3)
"signal::download-requested",
webkit_web_view_download_requested_cb, view,
- #endif
- #if WEBKIT_CHECK_VERSION (1, 1, 5)
"signal::print-requested",
midori_view_web_view_print_requested_cb, view,
- #endif
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
"signal-after::load-error",
webkit_web_view_load_error_cb, view,
- #endif
- NULL);
-
- #if !WEBKIT_CHECK_VERSION (1, 1, 6)
- g_object_connect (web_frame,
- "signal::load-done",
- webkit_web_frame_load_done_cb, view,
NULL);
- #endif
if (view->settings)
{
{
if (!strcmp (uri, ""))
{
- #if !WEBKIT_CHECK_VERSION (1, 1, 14)
- SoupServer* res_server;
- guint port;
- #endif
gchar* res_root;
gchar* speed_dial_head;
gchar* speed_dial_body;
if (G_UNLIKELY (!speed_dial_head))
speed_dial_head = g_strdup ("");
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
res_root = g_strdup ("res:/");
stock_root = g_strdup ("stock:/");
- #else
- res_server = sokoke_get_res_server ();
- port = soup_server_get_port (res_server);
- res_root = g_strdup_printf ("http://localhost:%d/res", port);
- stock_root = g_strdup_printf ("http://localhost:%d/stock", port);
- #endif
data = sokoke_replace_variables (speed_dial_head,
"{res}", res_root,
else if (g_str_has_prefix (uri, "error:") || g_str_has_prefix (uri, "about:"))
{
data = NULL;
- #if !WEBKIT_CHECK_VERSION (1, 1, 3)
- if (!strncmp (uri, "error:nodisplay ", 16))
- {
- gchar* title;
- gchar* logo_path;
- gchar* logo_uri;
-
- katze_assign (view->uri, g_strdup (&uri[16]));
- title = g_strdup_printf (_("Document cannot be displayed"));
- logo_path = sokoke_find_data_filename ("midori/res/logo-shade.png");
- logo_uri = g_filename_to_uri (logo_path, NULL, NULL);
- g_free (logo_path);
- data = g_strdup_printf (
- "<html><head><title>%s</title></head>"
- "<body><h1>%s</h1>"
- "<img src=\"%s\" "
- "style=\"position: absolute; right: 15px; bottom: 15px; z-index: -9;\">"
- "<p />The document %s of type '%s' cannot be displayed."
- "</body></html>",
- title, title, logo_uri, view->uri, view->mime_type);
- g_free (title);
- g_free (logo_uri);
- }
- #endif
if (!strncmp (uri, "error:nodocs ", 13))
{
gchar* title;
g_object_notify (G_OBJECT (view), "uri");
return;
}
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
else if (g_str_has_prefix (uri, "pause:"))
{
katze_assign (view->uri, g_strdup (&uri[6]));
katze_item_set_uri (view->item, uri);
g_object_notify (G_OBJECT (view), "uri");
}
- #endif
else if (g_str_has_prefix (uri, "javascript:"))
{
gboolean result;
midori_view_reload (MidoriView* view,
gboolean from_cache)
{
- gchar* title;
-
g_return_if_fail (MIDORI_IS_VIEW (view));
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
- title = NULL;
- #elif WEBKIT_CHECK_VERSION (1, 1, 6)
- /* WebKit 1.1.6 doesn't handle "alternate content" flawlessly,
- so reloading via Javascript works but not via API calls. */
- title = g_strdup_printf (_("Error - %s"), view->uri);
- #else
- /* Error pages are special, we want to try loading the destination
- again, not the error page which isn't even a proper page */
- title = g_strdup_printf (_("Error - %s"), view->uri);
- #endif
- if (view->title && title && strstr (title, view->title))
+ if (view->title)
webkit_web_view_open (WEBKIT_WEB_VIEW (view->web_view), view->uri);
else if (!(view->uri && *view->uri && strncmp (view->uri, "about:", 6)))
{
else
webkit_web_view_reload_bypass_cache (WEBKIT_WEB_VIEW (view->web_view));
katze_item_set_meta_integer (view->item, "delay", -1);
-
- g_free (title);
}
/**
return uri && uri[0] != '0' ? uri : NULL;
}
-#if WEBKIT_CHECK_VERSION (1, 1, 5)
static GtkWidget*
midori_view_print_create_custom_widget_cb (GtkPrintOperation* operation,
MidoriView* view)
return box;
}
-#endif
static void
midori_view_print_response_cb (GtkWidget* dialog,
midori_view_print (MidoriView* view)
{
WebKitWebFrame* frame;
- #if WEBKIT_CHECK_VERSION (1, 1, 5)
GtkPrintOperation* operation;
GError* error;
- #endif
g_return_if_fail (MIDORI_IS_VIEW (view));
frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
- #if WEBKIT_CHECK_VERSION (1, 1, 5)
operation = gtk_print_operation_new ();
gtk_print_operation_set_custom_tab_label (operation, _("Features"));
#if GTK_CHECK_VERSION (2, 18, 0)
G_CALLBACK (midori_view_print_response_cb), NULL);
gtk_widget_show (dialog);
}
- #else
- webkit_web_frame_print (frame);
- #endif
}
/**
{ MIDORI_STARTUP_BLANK_PAGE, "MIDORI_STARTUP_BLANK_PAGE", N_("Show Speed Dial") },
{ MIDORI_STARTUP_HOMEPAGE, "MIDORI_STARTUP_HOMEPAGE", N_("Show Homepage") },
{ MIDORI_STARTUP_LAST_OPEN_PAGES, "MIDORI_STARTUP_LAST_OPEN_PAGES", N_("Show last open tabs") },
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
{ MIDORI_STARTUP_DELAYED_PAGES, "MIDORI_STARTUP_DELAYED_PAGES", N_("Show last tabs without loading") },
- #endif
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MidoriStartup", values);
_("Save downloaded files to:"),
_("The folder downloaded files are saved to"),
midori_get_download_dir (),
- #if WEBKIT_CHECK_VERSION (1, 1, 3)
flags));
- #else
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- #endif
g_object_class_install_property (gobject_class,
PROP_TEXT_EDITOR,
"Enable special extensions for developers",
TRUE,
flags));
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
g_object_class_install_property (gobject_class,
PROP_ENABLE_SPELL_CHECKING,
g_param_spec_boolean ("enable-spell-checking",
_("Enable spell checking while typing"),
TRUE,
flags));
- #endif
- #if WEBKIT_CHECK_VERSION (1, 1, 8)
g_object_class_install_property (gobject_class,
PROP_ENABLE_HTML5_DATABASE,
g_param_spec_boolean ("enable-html5-database",
_("Whether to enable HTML5 local storage support"),
FALSE,
flags));
- #endif
#if WEBKIT_CHECK_VERSION (1, 1, 13)
g_object_class_install_property (gobject_class,
PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
g_object_set (web_settings, "WebKitWebSettings::enable-developer-extras",
g_value_get_boolean (value), NULL);
break;
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
case PROP_ENABLE_SPELL_CHECKING:
g_object_set (web_settings, "WebKitWebSettings::enable-spell-checking",
g_value_get_boolean (value), NULL);
break;
- #endif
- #if WEBKIT_CHECK_VERSION (1, 1, 8)
case PROP_ENABLE_HTML5_DATABASE:
g_object_set (web_settings, "WebKitWebSettings::enable-html5-database",
g_value_get_boolean (value), NULL);
g_object_set (web_settings, "WebKitWebSettings::enable-html5-local-storage",
g_value_get_boolean (value), NULL);
break;
- #endif
- #if WEBKIT_CHECK_VERSION (1, 1, 13)
case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
g_object_set (web_settings, "WebKitWebSettings::enable-offline-web-application-cache",
g_value_get_boolean (value), NULL);
break;
- #endif
#if WEBKIT_CHECK_VERSION (1, 1, 18)
case PROP_ENABLE_PAGE_CACHE:
g_object_set (web_settings, "WebKitWebSettings::enable-page-cache",
{
gchar* string = generate_ident_string (web_settings->identify_as);
katze_assign (web_settings->ident_string, string);
- #if WEBKIT_CHECK_VERSION (1, 1, 11)
g_object_set (web_settings, "user-agent", string, NULL);
- #else
- g_object_notify (object, "user-agent");
- #endif
}
break;
case PROP_USER_AGENT:
if (web_settings->identify_as == MIDORI_IDENT_CUSTOM)
katze_assign (web_settings->ident_string, g_value_dup_string (value));
- #if WEBKIT_CHECK_VERSION (1, 1, 11)
g_object_set (web_settings, "WebKitWebSettings::user-agent",
web_settings->ident_string, NULL);
- #endif
break;
case PROP_PREFERRED_LANGUAGES:
katze_assign (web_settings->http_accept_language, g_value_dup_string (value));
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
g_object_set (web_settings, "spell-checking-languages",
web_settings->http_accept_language, NULL);
- #endif
break;
case PROP_CLEAR_PRIVATE_DATA:
web_settings->clear_private_data = g_value_get_int (value);
g_value_set_boolean (value, katze_object_get_boolean (web_settings,
"WebKitWebSettings::enable-developer-extras"));
break;
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
case PROP_ENABLE_SPELL_CHECKING:
g_value_set_boolean (value, katze_object_get_boolean (web_settings,
"WebKitWebSettings::enable-spell-checking"));
break;
- #endif
- #if WEBKIT_CHECK_VERSION (1, 1, 8)
case PROP_ENABLE_HTML5_DATABASE:
g_value_set_boolean (value, katze_object_get_boolean (web_settings,
"WebKitWebSettings::enable-html5-database"));
g_value_set_boolean (value, katze_object_get_boolean (web_settings,
"WebKitWebSettings::enable-html5-local-storage"));
break;
- #endif
#if WEBKIT_CHECK_VERSION (1, 1, 13)
case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
g_value_set_boolean (value, katze_object_get_boolean (web_settings,
includes='/usr/X11R6/include', mandatory=False)
conf.check (lib='Xss', libpath='/usr/X11R6/lib', mandatory=False)
check_pkg ('gtk+-2.0', '2.10.0', var='GTK', args=args)
- check_pkg ('webkit-1.0', '1.1.4', args=args)
+ check_pkg ('webkit-1.0', '1.1.14', args=args)
check_pkg ('libsoup-2.4', '2.25.2')
conf.define ('HAVE_LIBSOUP_2_25_2', 1)
check_pkg ('libsoup-2.4', '2.27.90', False, var='LIBSOUP_2_27_90')