diff --git a/ChangeLog b/ChangeLog
index bca2b718..c836c397 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
This file is licensed under the terms of the expat license, see the file EXPAT.
+v0.4.0:
+ + Provide buttons to choose how to startup after crash
+ + Fix crash on corrupted datbase
+ + Never delay URIs given as command line arguments
+ + Space at the bottom of the page: Go to next page
+ + Initialize session in app/ private before adding URIs
+ + Add 'Last open tabs' option to Clear Private Data
+ + Show kinetic scrolling option regardless of Hildon
+ + Interpret Shift+Backspace as going forward
+ + Advertise SVG images as a supported MIME type
+ + Zoom in steps of 10% and support Ctr+=
+ + Fix a crasher on invalid geo: links
+ + Integrate Adblock and History List options in list
+ + Skip empty lines, ignore subdocument rules in Adblock
+ + Respect VALAC at configuration time
+ + URL cache, faster JS generator, inline parsing in Adblock
+ + Reuse source of webview instead of redownloading
+ + Remove the description field from bookmark dialog
+ + Add --log-file/ -l switch to log to a file
+ + Pass through javascript: URIS from the command line
+ + Tab and Window items in Unity Quicklist
+ + Adjust the preferences dialog
+ + Require WebKitGTK+ 1.1.17 and Vala 0.10
+
v0.3.6:
+ Track selected search engine per window
+ Improve preference dialogue size and alignments
diff --git a/README b/README
index 36f5ac63..ee55e9ba 100644
--- a/README
+++ b/README
@@ -11,9 +11,9 @@ Midori is a lightweight web browser.
* Customizable and extensible interface.
* Extensions written in C.
-Requirements: GTK+ 2.10, WebkitGTK+ 1.1.1, libXML2, libsoup 2.25.2, sqlite 3.0
+Requirements: GTK+ 2.10, WebkitGTK+ 1.1.17, libXML2, libsoup 2.25.2, sqlite 3.0, Vala 0.10
-Optional: Unique 0.9, libidn, docutils, libnotify, Vala
+Optional: Unique 0.9, libidn, libnotify
For installation instructions read INSTALL.
diff --git a/data/error.html b/data/error.html
index fd63f2b6..56ca6032 100644
--- a/data/error.html
+++ b/data/error.html
@@ -68,10 +68,12 @@ description {
{title}
{message}
{description}
-
-
- {tryagain}
-
+
diff --git a/data/faq.html b/data/faq.html
index a8b2a17f..fde49783 100644
--- a/data/faq.html
+++ b/data/faq.html
@@ -5,23 +5,23 @@
midori:faq
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
@@ -71,6 +71,9 @@ var NS='midori';var SIG=' --- //[[christian@twotoasts.de|Christian Dywan]] 2011/
This is a list of frequently asked questions about the Midori Web Browser. Anyone feel free to improve and/ or extend this page, but keep it clean and easy to read for other Xfce users.
+
+This is a snapshot of Frequently Asked Questions designated for offline viewing. The most recent version of this document can be found in the Xfce wiki .
+
@@ -275,7 +278,7 @@ You need to have GStreamer plugins installed which implement the codecs.
With Arch Linux, you may need to install liboil explicitly if it is not installed already (see
this bug report).
- You need plugins for Theora, gstreamer0.10-base and
MPEG -4 incluing aac (e.g. gst-plugins-faad), gstreamer0.10-bad. For WebM, you'll need plugins for vorbis (-base), matroska (-good), and vp8 (-bad). Have a look at
http://www.gstreamer.net/documentation/plugins.html for details.
+ You need plugins for Theora, gstreamer0.10-base and
MPEG -4 incluing aac (e.g. gst-plugins-faad), gstreamer0.10-bad. For WebM, you'll need plugins for vorbis (-base), matroska (-good), and vp8 (-bad). Have a look at
http://www.gstreamer.net/documentation/plugins.html for details.
For Youtube or Vimeo, you need WebKitGTK+ 1.1.20 or newer.
diff --git a/data/midori.desktop.in b/data/midori.desktop.in
index cc847fd4..f0598b4d 100644
--- a/data/midori.desktop.in
+++ b/data/midori.desktop.in
@@ -5,17 +5,27 @@ _Name=Midori
_GenericName=Web Browser
_Comment=Lightweight web browser
Categories=GTK;Network;WebBrowser;
-MimeType=text/html;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/geo;
-Exec=midori %u
+MimeType=text/html;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/geo;image/svg+xml;
+Exec=midori %U
Icon=midori
Terminal=false
StartupNotify=true
X-Osso-Type=application/x-executable
X-Osso-Service=midori
-X-Ayatana-Desktop-Shortcuts=Private
+X-Ayatana-Desktop-Shortcuts=TabNew;WindowNew;Private
+
+[TabNew Shortcut Group]
+Name=New _Tab
+Exec=midori -e TabNew
+TargetEnvironment=Unity
+
+[WindowNew Shortcut Group]
+Name=New _Window
+Exec=midori -e WindowNew
+TargetEnvironment=Unity
[Private Shortcut Group]
-Name=P_rivate Browsing
+Name=New P_rivate Browsing Window
Exec=midori --private
TargetEnvironment=Unity
diff --git a/extensions/adblock.c b/extensions/adblock.c
index 062a77eb..dcde78de 100644
--- a/extensions/adblock.c
+++ b/extensions/adblock.c
@@ -20,8 +20,6 @@
#include
#endif
-#define HAVE_WEBKIT_RESOURCE_REQUEST WEBKIT_CHECK_VERSION (1, 1, 14)
-
#define SIGNATURE_SIZE 8
#define USE_PATTERN_MATCHING 1
#define CUSTOM_LIST_NAME "custom.list"
@@ -41,8 +39,10 @@
static GHashTable* pattern;
static GHashTable* keys;
-static gchar* blockcss = NULL;
-static gchar* blockcssprivate = NULL;
+static GHashTable* optslist;
+static GHashTable* urlcache;
+static GString* blockcss;
+static GString* blockcssprivate;
static gchar* blockscript = NULL;
#ifdef G_ENABLE_DEBUG
static guint debug;
@@ -81,7 +81,8 @@ adblock_build_js (const gchar* style,
}
static gchar *
-adblock_fixup_regexp (gchar* src);
+adblock_fixup_regexp (const gchar* prefix,
+ gchar* src);
static void
adblock_init_db ()
@@ -92,8 +93,18 @@ adblock_init_db ()
keys = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free,
(GDestroyNotify)g_regex_unref);
- katze_assign (blockcss, g_strdup ("z-non-exist"));
- katze_assign (blockcssprivate, g_strdup (""));
+ optslist = g_hash_table_new_full (g_str_hash, g_str_equal,
+ NULL,
+ (GDestroyNotify)g_free);
+ urlcache = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify)g_free,
+ (GDestroyNotify)g_free);
+ if (blockcss && blockcss->len > 0)
+ g_string_free (blockcss, TRUE);
+ if (blockcssprivate && blockcssprivate->len > 0)
+ g_string_free (blockcssprivate, TRUE);
+ blockcss = g_string_new ("z-non-exist");
+ blockcssprivate = g_string_new ("");
}
#if WEBKIT_CHECK_VERSION (1, 1, 2)
@@ -106,7 +117,7 @@ adblock_download_notify_status_cb (WebKitDownload* download,
return;
adblock_parse_file (path);
- katze_assign (blockscript, adblock_build_js (blockcss, blockcssprivate));
+ katze_assign (blockscript, adblock_build_js (blockcss->str, blockcssprivate->str));
g_free (path);
/* g_object_unref (download); */
}
@@ -189,13 +200,9 @@ adblock_reload_rules (MidoriExtension* extension,
}
g_strfreev (filters);
- katze_assign (blockscript, adblock_build_js (blockcss, blockcssprivate));
+ katze_assign (blockscript, adblock_build_js (blockcss->str, blockcssprivate->str));
}
-static void
-adblock_browser_populate_tool_menu_cb (MidoriBrowser* browser,
- GtkWidget* menu,
- MidoriExtension* extension);
static void
adblock_preferences_render_tick_cb (GtkTreeViewColumn* column,
GtkCellRenderer* renderer,
@@ -561,8 +568,7 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
}
static void
-adblock_menu_configure_filters_activate_cb (GtkWidget* menuitem,
- MidoriExtension* extension)
+adblock_open_preferences_cb (MidoriExtension* extension)
{
static GtkWidget* dialog = NULL;
@@ -577,20 +583,6 @@ adblock_menu_configure_filters_activate_cb (GtkWidget* menuitem,
gtk_window_present (GTK_WINDOW (dialog));
}
-static void
-adblock_browser_populate_tool_menu_cb (MidoriBrowser* browser,
- GtkWidget* menu,
- MidoriExtension* extension)
-{
- GtkWidget* menuitem;
-
- menuitem = gtk_menu_item_new_with_mnemonic (_("Configure _Advertisement filters..."));
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (adblock_menu_configure_filters_activate_cb), extension);
- gtk_widget_show (menuitem);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-}
-
static inline gboolean
adblock_check_filter_options (GRegex* regex,
const gchar* opts,
@@ -612,16 +604,18 @@ adblock_is_matched_by_pattern (const gchar* req_uri,
const gchar* page_uri)
{
GHashTableIter iter;
- gpointer opts, regex;
+ gpointer patt, regex;
+ gchar* opts;
if (USE_PATTERN_MATCHING == 0)
return FALSE;
g_hash_table_iter_init (&iter, pattern);
- while (g_hash_table_iter_next (&iter, &opts, ®ex))
+ while (g_hash_table_iter_next (&iter, &patt, ®ex))
{
if (g_regex_match_full (regex, req_uri, -1, 0, 0, NULL, NULL))
{
+ opts = g_hash_table_lookup (optslist, patt);
if (opts && adblock_check_filter_options (regex, opts, req_uri, page_uri) == TRUE)
return FALSE;
else
@@ -635,8 +629,7 @@ adblock_is_matched_by_pattern (const gchar* req_uri,
}
static inline gboolean
-adblock_is_matched_by_key (const gchar* opts,
- const gchar* req_uri,
+adblock_is_matched_by_key (const gchar* req_uri,
const gchar* page_uri)
{
gchar* uri;
@@ -644,16 +637,19 @@ adblock_is_matched_by_key (const gchar* opts,
int pos = 0;
GList* regex_bl = NULL;
- uri = adblock_fixup_regexp ((gchar*)req_uri);
+ uri = adblock_fixup_regexp ("", (gchar*)req_uri);
len = strlen (uri);
for (pos = len - SIGNATURE_SIZE; pos >= 0; pos--)
{
gchar* sig = g_strndup (uri + pos, SIGNATURE_SIZE);
GRegex* regex = g_hash_table_lookup (keys, sig);
+ gchar* opts;
+
if (regex && !g_list_find (regex_bl, regex))
{
if (g_regex_match_full (regex, req_uri, -1, 0, 0, NULL, NULL))
{
+ opts = g_hash_table_lookup (optslist, sig);
g_free (sig);
if (opts && adblock_check_filter_options (regex, opts, req_uri, page_uri))
{
@@ -679,26 +675,39 @@ adblock_is_matched_by_key (const gchar* opts,
}
static gboolean
-adblock_is_matched (const gchar* opts,
- const gchar* req_uri,
+adblock_is_matched (const gchar* req_uri,
const gchar* page_uri)
{
+ gchar* value;
- if (adblock_is_matched_by_key (opts, req_uri, page_uri) == TRUE)
+ if ((value = g_hash_table_lookup (urlcache, req_uri)))
+ {
+ if (value[0] == '0')
+ return FALSE;
+ else
+ return TRUE;
+ }
+
+ if (adblock_is_matched_by_key (req_uri, page_uri))
+ {
+ g_hash_table_insert (urlcache, g_strdup (req_uri), g_strdup("1"));
return TRUE;
- else
- return adblock_is_matched_by_pattern (req_uri, page_uri);
+ }
+
+ if (adblock_is_matched_by_pattern (req_uri, page_uri))
+ {
+ g_hash_table_insert (urlcache, g_strdup (req_uri), g_strdup("1"));
+ return TRUE;
+ }
+ g_hash_table_insert (urlcache, g_strdup (req_uri), g_strdup("0"));
+ return FALSE;
}
-#if HAVE_WEBKIT_RESOURCE_REQUEST
static gchar*
adblock_prepare_urihider_js (GList* uris)
{
GList* li = NULL;
- gchar* out;
- gchar* cmd = g_strdup ("");
- gchar* tmp;
- const char *js =
+ GString* js = g_string_new (
"(function() {"
"function getElementsByAttribute (strTagName, strAttributeName, arrAttributeValue) {"
" var arrElements = document.getElementsByTagName (strTagName);"
@@ -724,20 +733,14 @@ adblock_prepare_urihider_js (GList* uris)
" oElements[i].style.height = '0';"
" }"
"};"
- "var uris=new Array ();"
- "%s"
- "hideElementBySrc (uris);"
- "})();";
+ "var uris=new Array ();");
for (li = uris; li != NULL; li = g_list_next (li))
- {
- tmp = g_strdup_printf ("uris.push ('%s');%s", (gchar*)li->data, cmd);
- katze_assign (cmd, tmp);
- }
- out = g_strdup_printf (js, cmd);
- g_free (cmd);
+ g_string_append_printf (js, "uris.push ('%s');", (gchar*)li->data);
- return out;
+ g_string_append (js, "hideElementBySrc (uris);})();");
+
+ return g_string_free (js, FALSE);
}
static void
@@ -779,8 +782,7 @@ adblock_resource_request_starting_cb (WebKitWebView* web_view,
if (debug == 2)
g_test_timer_start ();
#endif
- /* TODO: opts should be defined */
- if (adblock_is_matched (NULL, req_uri, page_uri))
+ if (adblock_is_matched (req_uri, page_uri))
{
blocked_uris = g_object_get_data (G_OBJECT (web_view), "blocked-uris");
blocked_uris = g_list_prepend (blocked_uris, g_strdup (req_uri));
@@ -793,39 +795,7 @@ adblock_resource_request_starting_cb (WebKitWebView* web_view,
#endif
}
-#else
-static void
-adblock_session_request_queued_cb (SoupSession* session,
- SoupMessage* msg)
-{
- SoupURI* soup_uri;
- gchar* req_uri;
- gchar* page_uri;
- if (msg->method && !strncmp (msg->method, "POST", 4))
- return;
-
- soup_uri = soup_message_get_uri (msg);
- req_uri = soup_uri_to_string (soup_uri, FALSE);
-
- page_uri = NULL; /* FIXME */
-
- if (!page_uri || !strcmp (page_uri, "about:blank"))
- page_uri = req_uri;
-
- if (adblock_is_matched (NULL, req_uri, page_uri))
- {
- soup_uri = soup_uri_new ("http://.invalid");
- soup_message_set_uri (msg, soup_uri);
- soup_uri_free (soup_uri);
- g_free (req_uri);
- return;
- }
- g_free (req_uri);
-}
-#endif
-
-#if WEBKIT_CHECK_VERSION (1, 1, 15)
static void
adblock_custom_block_image_cb (GtkWidget* widget,
MidoriExtension* extension)
@@ -926,15 +896,12 @@ adblock_populate_popup_cb (WebKitWebView* web_view,
g_signal_connect (menuitem, "activate",
G_CALLBACK (adblock_custom_block_image_cb), extension);
}
-#endif
-#if HAVE_WEBKIT_RESOURCE_REQUEST
static void
adblock_load_finished_cb (WebKitWebView *web_view,
WebKitWebFrame *web_frame,
gpointer user_data)
{
- JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
GList* uris = g_object_get_data (G_OBJECT (web_view), "blocked-uris");
gchar* script;
GList* li;
@@ -944,14 +911,12 @@ adblock_load_finished_cb (WebKitWebView *web_view,
script = adblock_prepare_urihider_js (uris);
webkit_web_view_execute_script (web_view, script);
- sokoke_js_script_eval (js_context, script, NULL);
li = NULL;
for (li = uris; li != NULL; li = g_list_next (li))
uris = g_list_remove (uris, li->data);
g_free (script);
g_object_set_data (G_OBJECT (web_view), "blocked-uris", uris);
}
-#endif
static void
adblock_window_object_cleared_cb (WebKitWebView* web_view,
@@ -959,7 +924,7 @@ adblock_window_object_cleared_cb (WebKitWebView* web_view,
JSContextRef js_context,
JSObjectRef js_window)
{
- webkit_web_view_execute_script (web_view, blockscript);
+ g_free (sokoke_js_script_eval (js_context, blockscript, NULL));
}
static void
@@ -968,22 +933,17 @@ adblock_add_tab_cb (MidoriBrowser* browser,
MidoriExtension* extension)
{
GtkWidget* web_view = midori_view_get_web_view (view);
- #if HAVE_WEBKIT_RESOURCE_REQUEST
GtkWidget* image = g_object_get_data (G_OBJECT (browser), "status-image");
- #endif
g_signal_connect (web_view, "window-object-cleared",
G_CALLBACK (adblock_window_object_cleared_cb), 0);
- #if WEBKIT_CHECK_VERSION (1, 1, 15)
+
g_signal_connect_after (web_view, "populate-popup",
G_CALLBACK (adblock_populate_popup_cb), extension);
- #endif
- #if HAVE_WEBKIT_RESOURCE_REQUEST
g_signal_connect (web_view, "resource-request-starting",
G_CALLBACK (adblock_resource_request_starting_cb), image);
g_signal_connect (web_view, "load-finished",
G_CALLBACK (adblock_load_finished_cb), image);
- #endif
}
static void
@@ -1018,24 +978,25 @@ adblock_app_add_browser_cb (MidoriApp* app,
(GtkCallback)adblock_add_tab_foreach_cb, extension);
g_signal_connect (browser, "add-tab",
G_CALLBACK (adblock_add_tab_cb), extension);
- g_signal_connect (browser, "populate-tool-menu",
- G_CALLBACK (adblock_browser_populate_tool_menu_cb), extension);
+ g_signal_connect (extension, "open-preferences",
+ G_CALLBACK (adblock_open_preferences_cb), extension);
g_signal_connect (extension, "deactivate",
G_CALLBACK (adblock_deactivate_cb), browser);
g_object_unref (statusbar);
}
static gchar *
-adblock_fixup_regexp (gchar* src)
+adblock_fixup_regexp (const gchar* prefix,
+ gchar* src)
{
gchar* dst;
GString* str;
- int len;
+ int len = 0;
if (!src)
return NULL;
- str = g_string_new ("");
+ str = g_string_new (prefix);
/* lets strip first .* */
if (src[0] == '*')
@@ -1049,54 +1010,50 @@ adblock_fixup_regexp (gchar* src)
{
case '*':
g_string_append (str, ".*");
+ len += 2;
break;
/*case '.':
g_string_append (str, "\\.");
break;*/
case '?':
g_string_append (str, "\\?");
+ len += 2;
break;
case '|':
- g_string_append (str, "");
- break;
/* FIXME: We actually need to match :[0-9]+ or '/'. Sign means
"here could be port number or nothing". So bla.com^ will match
bla.com/ or bla.com:8080/ but not bla.com.au/ */
case '^':
- g_string_append (str, "");
- break;
case '+':
break;
default:
g_string_append_printf (str,"%c", *src);
+ len++;
break;
}
src++;
}
while (*src);
- dst = g_strdup (str->str);
- g_string_free (str, TRUE);
+ dst = g_string_free (str, FALSE);
/* We dont need .* in the end of url. Thats stupid */
- len = strlen (dst);
if (dst && dst[len-1] == '*' && dst[len-2] == '.')
- {
dst[len-2] = '\0';
- }
return dst;
}
static void
-adblock_compile_regexp (GHashTable* tbl,
- GHashTable* keystbl,
- gchar* patt,
- gchar* opts)
+adblock_compile_regexp (gchar* patt,
+ gchar* opts)
{
GRegex* regex;
GError* error = NULL;
int pos = 0;
gchar *sig;
+ if (!patt)
+ return;
+
/* TODO: Play with optimization flags */
regex = g_regex_new (patt, G_REGEX_OPTIMIZE,
G_REGEX_MATCH_NOTEMPTY, &error);
@@ -1111,81 +1068,95 @@ adblock_compile_regexp (GHashTable* tbl,
{
int len = strlen (patt);
int signature_count = 0;
+
for (pos = len - SIGNATURE_SIZE; pos >= 0; pos--) {
sig = g_strndup (patt + pos, SIGNATURE_SIZE);
if (!g_regex_match_simple ("[\\*]", sig, G_REGEX_UNGREEDY, G_REGEX_MATCH_NOTEMPTY) &&
- !g_hash_table_lookup (keystbl, sig))
+ !g_hash_table_lookup (keys, sig))
{
adblock_debug ("sig: %s %s", sig, patt);
- g_hash_table_insert (keystbl, sig, regex);
+ g_hash_table_insert (keys, sig, regex);
+ g_hash_table_insert (optslist, sig, g_strdup (opts));
signature_count++;
}
else
{
if (g_regex_match_simple ("^\\*", sig, G_REGEX_UNGREEDY, G_REGEX_MATCH_NOTEMPTY) &&
- !g_hash_table_lookup (tbl, opts))
+ !g_hash_table_lookup (pattern, patt))
{
adblock_debug ("patt2: %s %s", sig, patt);
- g_hash_table_insert (tbl, opts, regex);
+ g_hash_table_insert (pattern, patt, regex);
+ g_hash_table_insert (optslist, patt, g_strdup (opts));
}
g_free (sig);
}
}
- if (signature_count > 1 && g_hash_table_lookup (tbl, opts))
- g_hash_table_steal (tbl, opts);
+ if (signature_count > 1 && g_hash_table_lookup (pattern, patt))
+ g_hash_table_steal (pattern, patt);
}
else
{
adblock_debug ("patt: %s%s", patt, "");
/* Pattern is a regexp chars */
- g_hash_table_insert (tbl, opts, regex);
+ g_hash_table_insert (pattern, patt, regex);
+ g_hash_table_insert (optslist, patt, g_strdup (opts));
}
}
-static gchar*
-adblock_add_url_pattern (gchar* format,
+static inline gchar*
+adblock_add_url_pattern (gchar* prefix,
gchar* type,
gchar* line)
{
gchar** data;
gchar* patt;
- gchar* fixed_patt;
gchar* format_patt;
gchar* opts;
data = g_strsplit (line, "$", -1);
- if (data && data[0] && data[1] && data[2])
+ if (!data || !data[0])
+ return NULL;
+
+ if (data[1] && data[2])
{
- patt = g_strdup_printf ("%s%s", data[0], data[1]);
- opts = g_strdup_printf ("type=%s,regexp=%s,%s", type, patt, data[2]);
+ patt = g_strconcat (data[0], data[1], NULL);
+ opts = g_strconcat (type, ",", data[2], NULL);
+ g_strfreev (data);
}
- else if (data && data[0] && data[1])
+ else if (data[1])
{
- patt = g_strdup (data[0]);
- opts = g_strdup_printf ("type=%s,regexp=%s,%s", type, patt, data[1]);
+ patt = data[0];
+ opts = g_strconcat (type, ",", data[1], NULL);
+ g_free (data[1]);
}
else
{
- patt = g_strdup (data[0]);
- opts = g_strdup_printf ("type=%s,regexp=%s", type, patt);
+ patt = data[0];
+ opts = g_strdup (type);
}
- fixed_patt = adblock_fixup_regexp (patt);
- format_patt = g_strdup_printf (format, fixed_patt);
+ if (g_regex_match_simple ("subdocument", opts,
+ G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY))
+ {
+ g_free (patt);
+ g_free (opts);
+ return NULL;
+ }
+
+ format_patt = adblock_fixup_regexp (prefix, patt);
adblock_debug ("got: %s opts %s", format_patt, opts);
- adblock_compile_regexp (pattern, keys, format_patt, opts);
+ adblock_compile_regexp (format_patt, opts);
- g_strfreev (data);
+ g_free (opts);
g_free (patt);
- g_free (fixed_patt);
return format_patt;
}
-static void
+static inline void
adblock_frame_add (gchar* line)
{
- gchar* new_blockcss;
+ const gchar* separator = " , ";
(void)*line++;
(void)*line++;
@@ -1196,15 +1167,14 @@ adblock_frame_add (gchar* line)
{
return;
}
- new_blockcss = g_strdup_printf ("%s, %s", blockcss, line);
- katze_assign (blockcss, new_blockcss);
+ g_string_append (blockcss, separator);
+ g_string_append (blockcss, line);
}
-static void
+static inline void
adblock_frame_add_private (const gchar* line,
const gchar* sep)
{
- gchar* new_blockcss;
gchar** data;
data = g_strsplit (line, sep, 2);
@@ -1226,17 +1196,15 @@ adblock_frame_add_private (const gchar* line,
domains = g_strsplit (data[0], ",", -1);
for (i = 0; domains[i]; i++)
{
- new_blockcss = g_strdup_printf ("%s;\nsites['%s']+=',%s'",
- blockcssprivate, g_strstrip (domains[i]), data[1]);
- katze_assign (blockcssprivate, new_blockcss);
+ g_string_append_printf (blockcssprivate, ";sites['%s']+=',%s'",
+ g_strstrip (domains[i]), data[1]);
}
g_strfreev (domains);
}
else
{
- new_blockcss = g_strdup_printf ("%s;\nsites['%s']+=',%s'",
- blockcssprivate, data[0], data[1]);
- katze_assign (blockcssprivate, new_blockcss);
+ g_string_append_printf (blockcssprivate, ";sites['%s']+=',%s'",
+ data[0], data[1]);
}
g_strfreev (data);
}
@@ -1257,6 +1225,10 @@ adblock_parse_line (gchar* line)
if (line[0] == '[')
return NULL;
+ /* Skip garbage */
+ if (line[0] == ' ' || !line[0])
+ return NULL;
+
/* Got CSS block hider */
if (line[0] == '#' && line[1] == '#' )
{
@@ -1285,14 +1257,14 @@ adblock_parse_line (gchar* line)
{
(void)*line++;
(void)*line++;
- return adblock_add_url_pattern ("%s", "fulluri", line);
+ return adblock_add_url_pattern ("", "fulluri", line);
}
if (line[0] == '|')
{
(void)*line++;
- return adblock_add_url_pattern ("^%s", "fulluri", line);
+ return adblock_add_url_pattern ("^", "fulluri", line);
}
- return adblock_add_url_pattern ("%s", "uri", line);
+ return adblock_add_url_pattern ("", "uri", line);
}
static gboolean
@@ -1304,7 +1276,7 @@ adblock_parse_file (gchar* path)
if ((file = g_fopen (path, "r")))
{
while (fgets (line, 2000, file))
- g_free (adblock_parse_line (line));
+ adblock_parse_line (line);
fclose (file);
return TRUE;
}
@@ -1317,24 +1289,18 @@ adblock_deactivate_tabs (MidoriView* view,
MidoriExtension* extension)
{
GtkWidget* web_view = midori_view_get_web_view (view);
- #if HAVE_WEBKIT_RESOURCE_REQUEST
GtkWidget* image = g_object_get_data (G_OBJECT (browser), "status-image");
- #endif
g_signal_handlers_disconnect_by_func (
browser, adblock_add_tab_cb, extension);
g_signal_handlers_disconnect_by_func (
web_view, adblock_window_object_cleared_cb, 0);
- #if WEBKIT_CHECK_VERSION (1, 1, 15)
g_signal_handlers_disconnect_by_func (
web_view, adblock_populate_popup_cb, extension);
- #endif
- #if HAVE_WEBKIT_RESOURCE_REQUEST
g_signal_handlers_disconnect_by_func (
web_view, adblock_resource_request_starting_cb, image);
g_signal_handlers_disconnect_by_func (
web_view, adblock_load_finished_cb, image);
- #endif
}
static void
@@ -1343,14 +1309,8 @@ adblock_deactivate_cb (MidoriExtension* extension,
{
MidoriApp* app = midori_extension_get_app (extension);
- #if !HAVE_WEBKIT_RESOURCE_REQUEST
- g_signal_handlers_disconnect_matched (webkit_get_default_session (),
- G_SIGNAL_MATCH_FUNC,
- g_signal_lookup ("request-queued", SOUP_TYPE_SESSION), 0,
- NULL, adblock_session_request_queued_cb, NULL);
- #endif
g_signal_handlers_disconnect_by_func (
- browser, adblock_browser_populate_tool_menu_cb, extension);
+ browser, adblock_open_preferences_cb, extension);
g_signal_handlers_disconnect_by_func (
extension, adblock_deactivate_cb, browser);
g_signal_handlers_disconnect_by_func (
@@ -1359,9 +1319,14 @@ adblock_deactivate_cb (MidoriExtension* extension,
browser, adblock_add_tab_cb, extension);
midori_browser_foreach (browser, (GtkCallback)adblock_deactivate_tabs, browser);
- katze_assign (blockcss, NULL);
- katze_assign (blockcssprivate, NULL);
+ if (blockcss)
+ g_string_free (blockcss, TRUE);
+ if (blockcssprivate)
+ g_string_free (blockcssprivate, TRUE);
+ blockcssprivate = blockcss = NULL;
g_hash_table_destroy (pattern);
+ g_hash_table_destroy (optslist);
+ g_hash_table_destroy (urlcache);
}
static void
@@ -1373,12 +1338,6 @@ adblock_activate_cb (MidoriExtension* extension,
#endif
KatzeArray* browsers;
MidoriBrowser* browser;
- #if !HAVE_WEBKIT_RESOURCE_REQUEST
- SoupSession* session = webkit_get_default_session ();
-
- g_signal_connect (session, "request-queued",
- G_CALLBACK (adblock_session_request_queued_cb), NULL);
- #endif
#ifdef G_ENABLE_DEBUG
debug_mode = g_getenv ("MIDORI_ADBLOCK");
@@ -1452,28 +1411,28 @@ test_adblock_pattern (void)
adblock_parse_file (filename);
g_test_timer_start ();
- g_assert (adblock_is_matched (NULL, "http://www.engadget.com/_uac/adpage.html", ""));
- g_assert (adblock_is_matched (NULL, "http://test.dom/test?var=1", ""));
- g_assert (adblock_is_matched (NULL, "http://ads.foo.bar/teddy", ""));
- g_assert (!adblock_is_matched (NULL, "http://ads.fuu.bar/teddy", ""));
- g_assert (adblock_is_matched (NULL, "https://ads.bogus.name/blub", ""));
- g_assert (adblock_is_matched (NULL, "http://ads.bla.blub/kitty", ""));
- g_assert (adblock_is_matched (NULL, "http://ads.blub.boing/soda", ""));
- g_assert (!adblock_is_matched (NULL, "http://ads.foo.boing/beer", ""));
- g_assert (adblock_is_matched (NULL, "https://testsub.engine.adct.ru/test?id=1", ""));
+ g_assert (adblock_is_matched ("http://www.engadget.com/_uac/adpage.html", ""));
+ g_assert (adblock_is_matched ("http://test.dom/test?var=1", ""));
+ g_assert (adblock_is_matched ("http://ads.foo.bar/teddy", ""));
+ g_assert (!adblock_is_matched ("http://ads.fuu.bar/teddy", ""));
+ g_assert (adblock_is_matched ("https://ads.bogus.name/blub", ""));
+ g_assert (adblock_is_matched ("http://ads.bla.blub/kitty", ""));
+ g_assert (adblock_is_matched ("http://ads.blub.boing/soda", ""));
+ g_assert (!adblock_is_matched ("http://ads.foo.boing/beer", ""));
+ g_assert (adblock_is_matched ("https://testsub.engine.adct.ru/test?id=1", ""));
if (USE_PATTERN_MATCHING)
- g_assert (adblock_is_matched (NULL, "http://test.ltd/addyn/test/test?var=adtech;&var2=1", ""));
- g_assert (adblock_is_matched (NULL, "http://add.doubleclick.net/pfadx/aaaa.mtvi", ""));
- g_assert (!adblock_is_matched (NULL, "http://add.doubleclick.net/pfadx/aaaa.mtv", ""));
- g_assert (adblock_is_matched (NULL, "http://objects.tremormedia.com/embed/xml/list.xml?r=", ""));
- g_assert (!adblock_is_matched (NULL, "http://qq.videostrip.c/sub/admatcherclient.php", ""));
- g_assert (adblock_is_matched (NULL, "http://qq.videostrip.com/sub/admatcherclient.php", ""));
- g_assert (adblock_is_matched (NULL, "http://qq.videostrip.com/sub/admatcherclient.php", ""));
- g_assert (adblock_is_matched (NULL, "http://br.gcl.ru/cgi-bin/br/test", ""));
- g_assert (!adblock_is_matched (NULL, "https://bugs.webkit.org/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=substring&email1=&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&query_based_on=gtkport&field0-0-0=keywords&type0-0-0=anywordssubstr&value0-0-0=Gtk%20Cairo%20soup&field0-0-1=short_desc&type0-0-1=anywordssubstr&value0-0-1=Gtk%20Cairo%20soup%20autoconf%20automake%20autotool&field0-0-2=component&type0-0-2=equals&value0-0-2=WebKit%20Gtk", ""));
- g_assert (!adblock_is_matched (NULL, "http://www.engadget.com/2009/09/24/google-hits-android-rom-modder-with-a-cease-and-desist-letter/", ""));
- g_assert (!adblock_is_matched (NULL, "http://karibik-invest.com/es/bienes_raices/search.php?sqT=19&sqN=&sqMp=&sqL=0&qR=1&sqMb=&searchMode=1&action=B%FAsqueda", ""));
- g_assert (!adblock_is_matched (NULL, "http://google.com", ""));
+ g_assert (adblock_is_matched ("http://test.ltd/addyn/test/test?var=adtech;&var2=1", ""));
+ g_assert (adblock_is_matched ("http://add.doubleclick.net/pfadx/aaaa.mtvi", ""));
+ g_assert (!adblock_is_matched ("http://add.doubleclick.net/pfadx/aaaa.mtv", ""));
+ g_assert (adblock_is_matched ("http://objects.tremormedia.com/embed/xml/list.xml?r=", ""));
+ g_assert (!adblock_is_matched ("http://qq.videostrip.c/sub/admatcherclient.php", ""));
+ g_assert (adblock_is_matched ("http://qq.videostrip.com/sub/admatcherclient.php", ""));
+ g_assert (adblock_is_matched ("http://qq.videostrip.com/sub/admatcherclient.php", ""));
+ g_assert (adblock_is_matched ("http://br.gcl.ru/cgi-bin/br/test", ""));
+ g_assert (!adblock_is_matched ("https://bugs.webkit.org/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=substring&email1=&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&query_based_on=gtkport&field0-0-0=keywords&type0-0-0=anywordssubstr&value0-0-0=Gtk%20Cairo%20soup&field0-0-1=short_desc&type0-0-1=anywordssubstr&value0-0-1=Gtk%20Cairo%20soup%20autoconf%20automake%20autotool&field0-0-2=component&type0-0-2=equals&value0-0-2=WebKit%20Gtk", ""));
+ g_assert (!adblock_is_matched ("http://www.engadget.com/2009/09/24/google-hits-android-rom-modder-with-a-cease-and-desist-letter/", ""));
+ g_assert (!adblock_is_matched ("http://karibik-invest.com/es/bienes_raices/search.php?sqT=19&sqN=&sqMp=&sqL=0&qR=1&sqMb=&searchMode=1&action=B%FAsqueda", ""));
+ g_assert (!adblock_is_matched ("http://google.com", ""));
g_print ("Search took %f seconds\n", g_test_timer_elapsed ());
diff --git a/extensions/addons.c b/extensions/addons.c
index aeb948bd..08eb2abc 100644
--- a/extensions/addons.c
+++ b/extensions/addons.c
@@ -843,7 +843,7 @@ addons_get_directories (AddonsKind kind)
{
path = g_build_path (G_DIR_SEPARATOR_S, *datadirs,
PACKAGE_NAME, folder_name, NULL);
- if (g_access (path, X_OK) == 0)
+ if (g_slist_find (directories, path) == NULL && g_access (path, X_OK) == 0)
directories = g_slist_prepend (directories, path);
else
g_free (path);
@@ -888,7 +888,8 @@ addons_get_files (AddonsKind kind)
if (g_str_has_suffix (filename, file_extension))
{
fullname = g_build_filename (dirname, filename, NULL);
- files = g_slist_prepend (files, fullname);
+ if (g_slist_find (files, fullname) == NULL)
+ files = g_slist_prepend (files, fullname);
}
}
g_dir_close (addon_dir);
diff --git a/extensions/formhistory.c b/extensions/formhistory.c
index cc4c07cf..9fbc19a9 100644
--- a/extensions/formhistory.c
+++ b/extensions/formhistory.c
@@ -21,36 +21,36 @@
#include
#endif
-#ifdef G_OS_WIN32
- #define LIBPREFIX ""
-#else
- #define LIBPREFIX "lib"
-#endif
-
static GHashTable* global_keys;
static gchar* jsforms;
static gboolean
formhistory_prepare_js ()
{
- gchar* data_name;
gchar* data_path;
gchar* autosuggest;
gchar* style;
guint i;
gchar* file;
- data_name = g_build_filename (PACKAGE_NAME, "res", NULL);
- data_path = sokoke_find_data_filename (data_name);
- g_free (data_name);
- file = g_build_filename (data_path, G_DIR_SEPARATOR_S, "autosuggestcontrol.js",NULL);
+ data_path = g_build_filename (PACKAGE_NAME, "res", "autosuggestcontrol.js", NULL);
+ file = sokoke_find_data_filename (data_path);
if (!g_file_get_contents (file, &autosuggest, NULL, NULL))
+ {
+ g_free (data_path);
+ g_free (file);
return FALSE;
+ }
g_strchomp (autosuggest);
- file = g_build_filename (data_path, G_DIR_SEPARATOR_S, "autosuggestcontrol.css",NULL);
- if(!g_file_get_contents (file, &style, NULL, NULL))
+ katze_assign (data_path, g_build_filename (PACKAGE_NAME, "res", "autosuggestcontrol.css", NULL));
+ katze_assign (file, sokoke_find_data_filename (data_path));
+ if (!g_file_get_contents (file, &style, NULL, NULL))
+ {
+ g_free (data_path);
+ g_free (file);
return FALSE;
+ }
g_strchomp (style);
i = 0;
while (style[i])
@@ -191,7 +191,6 @@ formhistory_update_main_hash (gchar* key,
return TRUE;
}
-#if WEBKIT_CHECK_VERSION (1, 1, 4)
static gboolean
formhistory_navigation_decision_cb (WebKitWebView* web_view,
WebKitWebFrame* web_frame,
@@ -251,50 +250,6 @@ formhistory_navigation_decision_cb (WebKitWebView* web_view,
}
return FALSE;
}
-#else
-static void
-formhistory_feed_keys (GHashTable* keys,
- gpointer db)
-{
- GHashTableIter iter;
- gchar* key;
- gchar* value;
-
- g_hash_table_iter_init (&iter, keys);
- while (g_hash_table_iter_next (&iter, (gpointer)&key, (gpointer)&value))
- {
- if (formhistory_update_main_hash (key, value))
- formhistory_update_database (db, key, value);
- }
-}
-
-static void
-formhistory_session_request_queued_cb (SoupSession* session,
- SoupMessage* msg,
- MidoriExtension* extension)
-{
- gchar* method = katze_object_get_string (msg, "method");
- if (method && !strncmp (method, "POST", 4))
- {
- SoupMessageBody* body = msg->request_body;
- if (soup_message_body_get_accumulate (body))
- {
- SoupBuffer* buffer;
- GHashTable* keys;
- gpointer db;
-
- buffer = soup_message_body_flatten (body);
- keys = soup_form_decode (body->data);
-
- db = g_object_get_data (G_OBJECT (extension), "formhistory-db");
- formhistory_feed_keys (keys, db);
- soup_buffer_free (buffer);
- g_hash_table_destroy (keys);
- }
- }
- g_free (method);
-}
-#endif
static void
formhistory_window_object_cleared_cb (WebKitWebView* web_view,
@@ -316,13 +271,8 @@ formhistory_add_tab_cb (MidoriBrowser* browser,
GtkWidget* web_view = midori_view_get_web_view (view);
g_signal_connect (web_view, "window-object-cleared",
G_CALLBACK (formhistory_window_object_cleared_cb), NULL);
- #if WEBKIT_CHECK_VERSION (1, 1, 4)
g_signal_connect (web_view, "navigation-policy-decision-requested",
G_CALLBACK (formhistory_navigation_decision_cb), extension);
- #else
- g_signal_connect (webkit_get_default_session (), "request-queued",
- G_CALLBACK (formhistory_session_request_queued_cb), extension);
- #endif
}
static void
@@ -358,13 +308,8 @@ formhistory_deactivate_tabs (MidoriView* view,
GtkWidget* web_view = midori_view_get_web_view (view);
g_signal_handlers_disconnect_by_func (
web_view, formhistory_window_object_cleared_cb, NULL);
- #if WEBKIT_CHECK_VERSION (1, 1, 4)
g_signal_handlers_disconnect_by_func (
web_view, formhistory_navigation_decision_cb, extension);
- #else
- g_signal_handlers_disconnect_by_func (
- webkit_get_default_session (), formhistory_session_request_queued_cb, extension);
- #endif
}
static void
@@ -491,21 +436,6 @@ formhistory_activate_cb (MidoriExtension* extension,
*/
#endif
-static void
-formhistory_clear_database_cb (void)
-{
- gchar* filename = g_build_filename (sokoke_set_config_dir (NULL),
- "extensions", LIBPREFIX "formhistory." G_MODULE_SUFFIX, "forms.db", NULL);
- sqlite3* db;
- if (sqlite3_open (filename, &db) == SQLITE_OK)
- {
- sqlite3_exec (db, "DELETE FROM forms", NULL, NULL, NULL);
- sqlite3_close (db);
- }
- g_free (filename);
-
-}
-
MidoriExtension*
extension_init (void)
{
@@ -539,9 +469,5 @@ extension_init (void)
g_signal_connect (extension, "activate",
G_CALLBACK (formhistory_activate_cb), NULL);
- /* i18n: Data entered into web forms by the user */
- sokoke_register_privacy_item ("formhistory", _("_Form History"),
- G_CALLBACK (formhistory_clear_database_cb));
-
return extension;
}
diff --git a/extensions/history-list.vala b/extensions/history-list.vala
index acacae11..8014b125 100644
--- a/extensions/history-list.vala
+++ b/extensions/history-list.vala
@@ -14,361 +14,565 @@ using Gdk;
using WebKit;
using Midori;
-enum TabTreeCells {
- TREE_CELL_PIXBUF,
- TREE_CELL_STRING,
- TREE_CELL_POINTER,
- TREE_CELL_COUNT
-}
-
-private abstract class HistoryWindow : Gtk.Window {
- public Midori.Browser browser { get; construct set; }
- protected Gtk.TreeView? treeview = null;
- public HistoryWindow (Midori.Browser browser) {
- GLib.Object (type: Gtk.WindowType.POPUP,
- window_position: Gtk.WindowPosition.CENTER,
- browser: browser);
+namespace HistoryList {
+ enum TabTreeCells {
+ TREE_CELL_PIXBUF,
+ TREE_CELL_STRING,
+ TREE_CELL_POINTER,
+ TREE_CELL_COUNT
}
- public virtual void walk (int step) {
- Gtk.TreePath? path;
- Gtk.TreeViewColumn? column;
- this.treeview.get_cursor (out path, out column);
-
- unowned int[] indices = path.get_indices ();
- int new_index = indices[0] + step;
-
- var model = this.treeview.get_model () as Gtk.ListStore;
-
- while (new_index < 0 || new_index >= model.length)
- new_index = new_index < 0 ? model.length + new_index : new_index - model.length;
-
- path = new Gtk.TreePath.from_indices (new_index);
- this.treeview.set_cursor (path, column, false);
+ enum TabClosingBehavior {
+ NONE,
+ LAST,
+ NEW
}
- public abstract void make_update ();
-}
-private class TabWindow : HistoryWindow {
- protected Gtk.HBox? hbox;
- protected Gtk.VBox? vbox;
- protected void store_append_row (GLib.PtrArray list, Gtk.ListStore store, out Gtk.TreeIter iter) {
- for (var i = list.len; i > 0; i--) {
- Midori.View view = list.index (i - 1) as Midori.View;
+ enum TabClosingBehaviorModel {
+ TEXT,
+ VALUE
+ }
- Gdk.Pixbuf? icon = null;
- view.get ("icon", ref icon);
+ private abstract class HistoryWindow : Gtk.Window {
+ public Midori.Browser browser { get; construct set; }
+ protected Gtk.TreeView? treeview = null;
- unowned string title = view.get_display_title ();
-
- store.append (out iter);
- store.set (iter, TabTreeCells.TREE_CELL_PIXBUF, icon,
- TabTreeCells.TREE_CELL_STRING, title,
- TabTreeCells.TREE_CELL_POINTER, view);
+ public HistoryWindow (Midori.Browser browser) {
+ GLib.Object (type: Gtk.WindowType.POPUP,
+ window_position: Gtk.WindowPosition.CENTER,
+ browser: browser);
}
- }
- protected virtual void insert_rows (Gtk.ListStore store) {
- Gtk.TreeIter iter;
- unowned GLib.PtrArray list = this.browser.get_data ("history-list-tab-history");
- unowned GLib.PtrArray list_new = this.browser.get_data ("history-list-tab-history-new");
- store_append_row (list, store, out iter);
- store_append_row (list_new, store, out iter);
- }
- public TabWindow (Midori.Browser browser) {
- base (browser);
- this.vbox = new Gtk.VBox (false, 1);
- this.add (this.vbox);
+ public virtual void walk (int step) {
+ Gtk.TreePath? path;
+ Gtk.TreeViewColumn? column;
- this.hbox = new Gtk.HBox (false, 1);
+ this.treeview.get_cursor (out path, out column);
- var sw = new Gtk.ScrolledWindow (null, null);
- sw.set_policy (PolicyType.NEVER , PolicyType.AUTOMATIC);
- sw.set_shadow_type (ShadowType.ETCHED_IN);
- this.hbox.pack_start (sw, true, true, 0);
+ unowned int[] indices = path.get_indices ();
+ int new_index = indices[0] + step;
- var store = new Gtk.ListStore (TabTreeCells.TREE_CELL_COUNT,
- typeof (Gdk.Pixbuf), typeof (string), typeof (void*));
+ var model = this.treeview.get_model () as Gtk.ListStore;
- this.insert_rows (store);
+ while (new_index < 0 || new_index >= model.length)
+ new_index = new_index < 0 ? model.length + new_index : new_index - model.length;
- this.vbox.pack_start (this.hbox, true, true, 0);
-
- this.treeview = new Gtk.TreeView.with_model (store);
- this.treeview.set_fixed_height_mode (true);
- sw.add (treeview);
-
- this.treeview.set_model (store);
- this.treeview.set ("headers-visible", false);
-
- this.treeview.insert_column_with_attributes (
- TabTreeCells.TREE_CELL_PIXBUF, "Icon",
- new CellRendererPixbuf (), "pixbuf", 0);
- this.treeview.insert_column_with_attributes (
- TabTreeCells.TREE_CELL_STRING, "Title",
- new CellRendererText (), "text", 1);
-
- Requisition requisition;
- int height;
- int max_lines = 10;
- this.treeview.size_request (out requisition);
- if (store.length > max_lines) {
- height = requisition.height / store.length * max_lines + 2;
- } else {
- height = requisition.height + 2;
+ path = new Gtk.TreePath.from_indices (new_index);
+ this.treeview.set_cursor (path, column, false);
}
- sw.set_size_request (320, height);
- this.show_all ();
+ public abstract void make_update ();
+ public abstract void clean_up ();
}
- public override void make_update () {
- Gtk.TreePath? path;
- Gtk.TreeViewColumn? column;
- this.treeview.get_cursor (out path, out column);
+ private class TabWindow : HistoryWindow {
+ protected Gtk.HBox? hbox;
+ protected Gtk.VBox? vbox;
+ protected bool is_dirty = false;
- var model = this.treeview.get_model () as Gtk.ListStore;
+ protected void store_append_row (GLib.PtrArray list, Gtk.ListStore store, out Gtk.TreeIter iter) {
+ for (var i = list.len; i > 0; i--) {
+ Midori.View view = list.index (i - 1) as Midori.View;
- Gtk.TreeIter iter;
- unowned Midori.View? view = null;
+ Gdk.Pixbuf? icon = null;
+ view.get ("icon", ref icon);
- model.get_iter (out iter, path);
- model.get (iter, TabTreeCells.TREE_CELL_POINTER, out view);
- this.browser.set ("tab", view);
- }
-}
+ unowned string title = view.get_display_title ();
-private class NewTabWindow : TabWindow {
- protected bool first_step = true;
- protected override void insert_rows (Gtk.ListStore store) {
- Gtk.TreeIter iter;
- unowned GLib.PtrArray list = this.browser.get_data ("history-list-tab-history-new");
- store_append_row (list, store, out iter);
-
- if ((int)list.len == 0) {
- var label = new Gtk.Label (_("There are no unvisited tabs"));
- this.vbox.pack_start (label, true, true, 0);
- unowned GLib.PtrArray list_old = this.browser.get_data ("history-list-tab-history");
- store_append_row (list_old, store, out iter);
- }
- }
- public override void walk (int step) {
- if (this.first_step == false || step != 1) {
- base.walk (step);
- }
- this.first_step = false;
- }
- public NewTabWindow (Midori.Browser browser) {
- base (browser);
- }
-}
-
-private class HistoryList : Midori.Extension {
- protected uint escKeyval;
- protected uint modifier_count;
- protected HistoryWindow? history_window;
- protected ulong[] tmp_sig_ids = new ulong[2];
- public bool key_press (Gdk.EventKey event_key) {
- if (event_key.is_modifier > 0) {
- this.modifier_count++;
- }
- return false;
- }
- public bool key_release (Gdk.EventKey event_key, Browser browser) {
- if (event_key.is_modifier > 0) {
- this.modifier_count--;
- }
- if (this.modifier_count == 0 || event_key.keyval == this.escKeyval) {
- browser.disconnect (this.tmp_sig_ids[0]);
- browser.disconnect (this.tmp_sig_ids[1]);
- if (this.modifier_count == 0) {
- this.history_window.make_update ();
- } else {
- this.modifier_count = 0;
+ store.append (out iter);
+ store.set (iter, TabTreeCells.TREE_CELL_PIXBUF, icon,
+ TabTreeCells.TREE_CELL_STRING, title,
+ TabTreeCells.TREE_CELL_POINTER, view);
}
- this.history_window.destroy ();
- this.history_window = null;
- }
- return false;
- }
- public void walk (Gtk.Action action, Browser browser, Type type, int step) {
- Midori.View? view = null;
- view = browser.get_data ("history-list-last-change");
- if (view != null) {
- this.tab_list_resort (browser, view);
- browser.set_data ("history-list-last-change", null);
}
- if (this.history_window == null || this.history_window.get_type () != type) {
- if (this.history_window == null) {
- this.modifier_count = Midori.Sokoke.gtk_action_count_modifiers (action);
- this.tmp_sig_ids[0] = browser.key_press_event.connect ((ek) => {
- return this.key_press (ek);
- });
- this.tmp_sig_ids[1] = browser.key_release_event.connect ((ek) => {
- return this.key_release (ek, browser);
- });
+ protected virtual void insert_rows (Gtk.ListStore store) {
+ Gtk.TreeIter iter;
+ unowned GLib.PtrArray list = this.browser.get_data ("history-list-tab-history");
+ unowned GLib.PtrArray list_new = this.browser.get_data ("history-list-tab-history-new");
+ store_append_row (list, store, out iter);
+ store_append_row (list_new, store, out iter);
+ }
+
+ public TabWindow (Midori.Browser browser) {
+ base (browser);
+
+ this.vbox = new Gtk.VBox (false, 1);
+ this.add (this.vbox);
+
+ this.hbox = new Gtk.HBox (false, 1);
+
+ var sw = new Gtk.ScrolledWindow (null, null);
+ sw.set_policy (PolicyType.NEVER , PolicyType.AUTOMATIC);
+ sw.set_shadow_type (ShadowType.ETCHED_IN);
+ this.hbox.pack_start (sw, true, true, 0);
+
+ var store = new Gtk.ListStore (TabTreeCells.TREE_CELL_COUNT,
+ typeof (Gdk.Pixbuf), typeof (string), typeof (void*));
+
+ this.insert_rows (store);
+
+ this.vbox.pack_start (this.hbox, true, true, 0);
+
+ this.treeview = new Gtk.TreeView.with_model (store);
+ this.treeview.set_fixed_height_mode (true);
+ sw.add (treeview);
+
+ this.treeview.set_model (store);
+ this.treeview.set ("headers-visible", false);
+
+ this.treeview.insert_column_with_attributes (
+ TabTreeCells.TREE_CELL_PIXBUF, "Icon",
+ new CellRendererPixbuf (), "pixbuf", 0);
+ this.treeview.insert_column_with_attributes (
+ TabTreeCells.TREE_CELL_STRING, "Title",
+ new CellRendererText (), "text", 1);
+
+ Requisition requisition;
+ int height;
+ int max_lines = 10;
+ this.treeview.size_request (out requisition);
+ if (store.length > max_lines) {
+ height = requisition.height / store.length * max_lines + 2;
} else {
+ height = requisition.height + 2;
+ }
+ sw.set_size_request (320, height);
+
+ this.show_all ();
+ }
+
+ public override void make_update () {
+ this.is_dirty = true;
+
+ Gtk.TreePath? path;
+ Gtk.TreeViewColumn? column;
+
+ this.treeview.get_cursor (out path, out column);
+
+ var model = this.treeview.get_model () as Gtk.ListStore;
+
+ Gtk.TreeIter iter;
+ unowned Midori.View? view = null;
+
+ model.get_iter (out iter, path);
+ model.get (iter, TabTreeCells.TREE_CELL_POINTER, out view);
+ this.browser.set ("tab", view);
+ }
+
+ public override void clean_up () {
+ if(this.is_dirty) {
+ Gtk.TreePath? path;
+ Gtk.TreeViewColumn? column;
+
+ this.treeview.get_cursor (out path, out column);
+
+ path = new Gtk.TreePath.from_indices (0);
+ this.treeview.set_cursor (path, column, false);
+
+ this.make_update ();
+ this.is_dirty = false;
+ }
+ }
+ }
+
+ private class NewTabWindow : TabWindow {
+ protected bool old_tabs = false;
+ protected bool first_step = true;
+
+ protected override void insert_rows (Gtk.ListStore store) {
+ Gtk.TreeIter iter;
+ unowned GLib.PtrArray list = this.browser.get_data ("history-list-tab-history-new");
+ store_append_row (list, store, out iter);
+
+ if ((int)list.len == 0) {
+ this.old_tabs = true;
+ var label = new Gtk.Label (_("There are no unvisited tabs"));
+ this.vbox.pack_start (label, true, true, 0);
+ unowned GLib.PtrArray list_old = this.browser.get_data ("history-list-tab-history");
+ store_append_row (list_old, store, out iter);
+ }
+ }
+
+ public override void walk (int step) {
+ if (this.first_step == false || step != 1) {
+ base.walk (step);
+ }
+ this.first_step = false;
+ }
+
+ public override void clean_up () {
+ if(this.is_dirty) {
+ if(this.old_tabs) {
+ base.clean_up ();
+ } else {
+ unowned GLib.PtrArray list = this.browser.get_data ("history-list-tab-history");
+ Midori.View view = list.index (list.len - 1) as Midori.View;
+ this.browser.set ("tab", view);
+ }
+ }
+ }
+
+ public NewTabWindow (Midori.Browser browser) {
+ base (browser);
+ }
+ }
+
+ private class PreferencesDialog : Dialog {
+ protected Manager hl_manager;
+ protected ComboBox closing_behavior;
+
+ public PreferencesDialog (Manager manager) {
+ this.hl_manager = manager;
+
+ this.title = _("Preferences for %s").printf( _("History-List"));
+ this.has_separator = false;
+ this.border_width = 5;
+ this.set_modal (true);
+ this.set_default_size (350, 100);
+ this.create_widgets ();
+
+ this.response.connect (response_cb);
+ }
+
+ private void response_cb (Dialog source, int response_id) {
+ switch (response_id) {
+ case ResponseType.APPLY:
+ int value;
+ TreeIter iter;
+
+ this.closing_behavior.get_active_iter (out iter);
+ var model = this.closing_behavior.get_model ();
+ model.get (iter, TabClosingBehaviorModel.VALUE, out value);
+
+ this.hl_manager.set_integer ("TabClosingBehavior", value);
+ this.hl_manager.preferences_changed ();
+
+ this.destroy ();
+ break;
+ case ResponseType.CANCEL:
+ this.destroy ();
+ break;
+ }
+ }
+
+ private void create_widgets () {
+ ListStore model;
+ TreeIter iter;
+ TreeIter? active_iter = null;
+
+ var table = new Table (1, 2, true);
+ var renderer = new CellRendererText ();
+
+ var label = new Label ( _("Tab closing behavior"));
+ table.attach_defaults (label, 0, 1, 0, 1);
+
+ var tab_closing_behavior = this.hl_manager.get_integer ("TabClosingBehavior");
+
+ model = new ListStore (2, typeof (string), typeof (int));
+
+ model.append (out iter);
+ model.set (iter, TabClosingBehaviorModel.TEXT, _("Do nothing"),
+ TabClosingBehaviorModel.VALUE, TabClosingBehavior.NONE);
+ if (TabClosingBehavior.NONE == tab_closing_behavior)
+ active_iter = iter;
+
+ model.append (out iter);
+ model.set (iter, TabClosingBehaviorModel.TEXT, _("Switch to last view tab"),
+ TabClosingBehaviorModel.VALUE, TabClosingBehavior.LAST);
+ if (TabClosingBehavior.LAST == tab_closing_behavior)
+ active_iter = iter;
+
+ model.append (out iter);
+ model.set (iter, TabClosingBehaviorModel.TEXT, _("Switch to newest tab"),
+ TabClosingBehaviorModel.VALUE, TabClosingBehavior.NEW);
+ if (TabClosingBehavior.NEW == tab_closing_behavior)
+ active_iter = iter;
+
+ this.closing_behavior = new ComboBox.with_model (model);
+ this.closing_behavior.set_active_iter (active_iter);
+ this.closing_behavior.pack_start (renderer, true);
+ this.closing_behavior.set_attributes (renderer, "text", 0);
+
+ table.attach_defaults (this.closing_behavior, 1, 2, 0, 1);
+
+ this.vbox.pack_start (table, false, true, 0);
+
+ this.add_button (Gtk.STOCK_CANCEL, ResponseType.CANCEL);
+ this.add_button (Gtk.STOCK_APPLY, ResponseType.APPLY);
+
+ this.show_all ();
+ }
+ }
+
+ private class Manager : Midori.Extension {
+ public signal void preferences_changed ();
+
+ protected uint escKeyval;
+ protected uint modifier_count;
+ protected int closing_behavior;
+ protected HistoryWindow? history_window;
+ protected ulong[] tmp_sig_ids = new ulong[2];
+ protected bool ignoreNextChange = false;
+
+ public void preferences_changed_cb () {
+ this.closing_behavior = this.get_integer ("TabClosingBehavior");
+ }
+
+ public bool key_press (Gdk.EventKey event_key) {
+ if (event_key.is_modifier > 0) {
+ this.modifier_count++;
+ }
+ return false;
+ }
+
+ public bool key_release (Gdk.EventKey event_key, Browser browser) {
+ if (event_key.is_modifier > 0) {
+ this.modifier_count--;
+ }
+ if (this.modifier_count == 0 || event_key.keyval == this.escKeyval) {
+ browser.disconnect (this.tmp_sig_ids[0]);
+ browser.disconnect (this.tmp_sig_ids[1]);
+ if (this.modifier_count == 0) {
+ this.history_window.make_update ();
+ } else {
+ this.modifier_count = 0;
+ this.history_window.clean_up ();
+ }
this.history_window.destroy ();
this.history_window = null;
}
- /*
- Bug: https://bugzilla.gnome.org/show_bug.cgi?id=618750
- Code: this.history_window = (Gtk.Window) GLib.Object.new (type);
- */
- if (type == typeof (TabWindow)) {
- this.history_window = new TabWindow (browser);
- } else if (type == typeof (NewTabWindow)) {
- this.history_window = new NewTabWindow (browser);
+ return false;
+ }
+
+ public void walk (Gtk.Action action, Browser browser, Type type, int step) {
+ Midori.View? view = null;
+ view = browser.get_data ("history-list-last-change");
+ if (view != null) {
+ this.tab_list_resort (browser, view);
+ browser.set_data ("history-list-last-change", null);
+ }
+
+ if (this.history_window == null || this.history_window.get_type () != type) {
+ if (this.history_window == null) {
+ this.modifier_count = Midori.Sokoke.gtk_action_count_modifiers (action);
+ this.tmp_sig_ids[0] = browser.key_press_event.connect ((ek) => {
+ return this.key_press (ek);
+ });
+ this.tmp_sig_ids[1] = browser.key_release_event.connect ((ek) => {
+ return this.key_release (ek, browser);
+ });
+ } else {
+ this.history_window.destroy ();
+ this.history_window = null;
+ }
+ /*
+ Bug: https://bugzilla.gnome.org/show_bug.cgi?id=618750
+ Code: this.history_window = (Gtk.Window) GLib.Object.new (type);
+ */
+ if (type == typeof (TabWindow)) {
+ this.history_window = new TabWindow (browser);
+ } else if (type == typeof (NewTabWindow)) {
+ this.history_window = new NewTabWindow (browser);
+ }
+ }
+ var hw = this.history_window as HistoryWindow;
+ hw.walk (step);
+ }
+
+ public void special_function (Gtk.Action action, Browser browser) {
+ if (this.history_window != null) {
+ this.ignoreNextChange = true;
+ this.history_window.make_update ();
}
}
- var hw = this.history_window as HistoryWindow;
- hw.walk (step);
- }
- void browser_added (Midori.Browser browser) {
- ulong sidTabNext, sidTabPrevious;
- var acg = new Gtk.AccelGroup ();
- browser.add_accel_group (acg);
- var action_group = browser.get_action_group ();
- Gtk.Action action;
+ void browser_added (Midori.Browser browser) {
+ ulong sidTabNext, sidTabPrevious;
+ var acg = new Gtk.AccelGroup ();
+ browser.add_accel_group (acg);
+ var action_group = browser.get_action_group ();
- action = action_group.get_action ("TabNext");
- browser.block_action (action);
- sidTabNext = action.activate.connect ((a) => {
- this.walk (a, browser, typeof (TabWindow), 1);
- });
+ Gtk.Action action;
- action = action_group.get_action ("TabPrevious");
- browser.block_action (action);
- sidTabPrevious = action.activate.connect ((a) => {
- this.walk (a, browser, typeof (TabWindow), -1);
- });
+ action = action_group.get_action ("TabNext");
+ browser.block_action (action);
+ sidTabNext = action.activate.connect ((a) => {
+ this.walk (a, browser, typeof (TabWindow), 1);
+ });
- action = new Gtk.Action ("HistoryListNextNewTab",
- _("Next new Tab (History List)"),
- _("Next new tab from history"), null);
- action.activate.connect ((a) => {
- this.walk (a, browser, typeof (NewTabWindow), 1);
- });
- action_group.add_action_with_accel (action, "1");
- action.set_accel_group (acg);
- action.connect_accelerator ();
+ action = action_group.get_action ("TabPrevious");
+ browser.block_action (action);
+ sidTabPrevious = action.activate.connect ((a) => {
+ this.walk (a, browser, typeof (TabWindow), -1);
+ });
- action = new Gtk.Action ("HistoryListPreviousNewTab",
- _("Previous new Tab (History List)"),
- _("Previous new tab from history"), null);
- action.activate.connect ((a) => {
- this.walk (a, browser, typeof (NewTabWindow), -1);
- });
- action_group.add_action_with_accel (action, "2");
- action.set_accel_group (acg);
- action.connect_accelerator ();
+ action = new Gtk.Action ("HistoryListNextNewTab",
+ _("Next new Tab (History List)"),
+ _("Next new tab from history"), null);
+ action.activate.connect ((a) => {
+ this.walk (a, browser, typeof (NewTabWindow), 1);
+ });
+ action_group.add_action_with_accel (action, "1");
+ action.set_accel_group (acg);
+ action.connect_accelerator ();
- browser.set_data ("history-list-sid-tab-next", sidTabNext);
- browser.set_data ("history-list-sid-tab-previous", sidTabPrevious);
+ action = new Gtk.Action ("HistoryListPreviousNewTab",
+ _("Previous new Tab (History List)"),
+ _("Previous new tab from history"), null);
+ action.activate.connect ((a) => {
+ this.walk (a, browser, typeof (NewTabWindow), -1);
+ });
+ action_group.add_action_with_accel (action, "2");
+ action.set_accel_group (acg);
+ action.connect_accelerator ();
- browser.set_data ("history-list-tab-history",
- new GLib.PtrArray ());
- browser.set_data ("history-list-tab-history-new",
- new GLib.PtrArray ());
- browser.set_data ("history-list-last-change", null);
+ action = new Gtk.Action ("HistoryListSpecialFunction",
+ _("Display tab in background (History List)"),
+ _("Display the current selected tab in background"), null);
+ action.activate.connect ((a) => {
+ this.special_function (a, browser);
+ });
+ action_group.add_action_with_accel (action, "3");
+ action.set_accel_group (acg);
+ action.connect_accelerator ();
- foreach (var tab in browser.get_tabs ())
- tab_added (browser, tab);
- browser.add_tab.connect (tab_added);
- browser.remove_tab.connect (tab_removed);
- browser.notify["tab"].connect (this.tab_changed);
- }
- void browser_removed (Midori.Browser browser) {
- string[] callbacks = { "HistoryListNextNewTab", "HistoryListPreviousNewTab" };
- ulong sidTabNext, sidTabPrevious;
- sidTabNext = browser.get_data ("history-list-sid-tab-next");
- sidTabPrevious = browser.get_data ("history-list-sid-tab-previous");
+ browser.set_data ("history-list-sid-tab-next", sidTabNext);
+ browser.set_data ("history-list-sid-tab-previous", sidTabPrevious);
- Gtk.Action action;
- Gtk.ActionGroup action_group;
- action_group = browser.get_action_group ();
+ browser.set_data ("history-list-tab-history",
+ new GLib.PtrArray ());
+ browser.set_data ("history-list-tab-history-new",
+ new GLib.PtrArray ());
+ browser.set_data ("history-list-last-change", null);
- action = action_group.get_action ("TabNext");
- action.disconnect (sidTabNext);
- browser.unblock_action (action);
- action = action_group.get_action ("TabPrevious");
- action.disconnect (sidTabPrevious);
- browser.unblock_action (action);
-
- for (int i = 0; i < callbacks.length; i++) {
- action = action_group.get_action (callbacks[i]);
- if (action != null)
- action_group.remove_action (action);
+ foreach (var tab in browser.get_tabs ())
+ tab_added (browser, tab);
+ browser.add_tab.connect (tab_added);
+ browser.remove_tab.connect (tab_removed);
+ browser.notify["tab"].connect (this.tab_changed);
}
- browser.add_tab.disconnect (tab_added);
- browser.remove_tab.disconnect (tab_removed);
- browser.notify["tab"].disconnect (this.tab_changed);
- }
- void tab_added (Midori.Browser browser, Midori.View view) {
- unowned GLib.PtrArray list = browser.get_data ("history-list-tab-history-new");
- list.add (view);
- }
- void tab_removed (Midori.Browser browser, Midori.View view) {
- unowned GLib.PtrArray list = browser.get_data ("history-list-tab-history");
- unowned GLib.PtrArray list_new = browser.get_data ("history-list-tab-history-new");
- list.remove (view);
- list_new.remove (view);
- browser.set_data ("history-list-last-change", null);
+ void browser_removed (Midori.Browser browser) {
+ string[] callbacks = { "HistoryListNextNewTab", "HistoryListPreviousNewTab",
+ "HistoryListSpecialFunction" };
+ ulong sidTabNext, sidTabPrevious;
+ sidTabNext = browser.get_data ("history-list-sid-tab-next");
+ sidTabPrevious = browser.get_data ("history-list-sid-tab-previous");
- if ((int) list.len > 0 || (int) list_new.len > 0) {
- var hw = new TabWindow (browser);
- hw.make_update ();
- hw.destroy ();
+ Gtk.Action action;
+ Gtk.ActionGroup action_group;
+ action_group = browser.get_action_group ();
+
+ action = action_group.get_action ("TabNext");
+ action.disconnect (sidTabNext);
+ browser.unblock_action (action);
+ action = action_group.get_action ("TabPrevious");
+ action.disconnect (sidTabPrevious);
+ browser.unblock_action (action);
+
+ for (int i = 0; i < callbacks.length; i++) {
+ action = action_group.get_action (callbacks[i]);
+ if (action != null)
+ action_group.remove_action (action);
+ }
+
+ browser.add_tab.disconnect (tab_added);
+ browser.remove_tab.disconnect (tab_removed);
+ browser.notify["tab"].disconnect (this.tab_changed);
}
- }
- void tab_changed (GLib.Object window, GLib.ParamSpec pspec) {
- Midori.Browser browser = window as Midori.Browser;
- Midori.View view = null;
- Midori.View last_view = null;
- browser.get ("tab", ref view);
- last_view = browser.get_data ("history-list-last-change");
-
- if (last_view != null) {
- this.tab_list_resort (browser, last_view);
+ void tab_added (Midori.Browser browser, Midori.View view) {
+ unowned GLib.PtrArray list = browser.get_data ("history-list-tab-history-new");
+ list.add (view);
+ }
+
+ void tab_removed (Midori.Browser browser, Midori.View view) {
+ unowned GLib.PtrArray list = browser.get_data ("history-list-tab-history");
+ unowned GLib.PtrArray list_new = browser.get_data ("history-list-tab-history-new");
+ list.remove (view);
+ list_new.remove (view);
+
+ if (this.closing_behavior == TabClosingBehavior.LAST || this.closing_behavior == TabClosingBehavior.NEW) {
+ browser.set_data ("history-list-last-change", null);
+
+ if ((int) list.len > 0 || (int) list_new.len > 0) {
+ TabWindow hw;
+ if (this.closing_behavior == TabClosingBehavior.LAST)
+ hw = new TabWindow (browser);
+ else
+ hw = new NewTabWindow (browser);
+ hw.make_update ();
+ hw.destroy ();
+ }
+ }
+ }
+
+ void tab_changed (GLib.Object window, GLib.ParamSpec pspec) {
+ if(this.ignoreNextChange) {
+ this.ignoreNextChange = false;
+ } else {
+ Midori.Browser browser = window as Midori.Browser;
+ Midori.View view = null;
+ Midori.View last_view = null;
+ browser.get ("tab", ref view);
+
+ last_view = browser.get_data ("history-list-last-change");
+
+ if (last_view != null) {
+ this.tab_list_resort (browser, last_view);
+ }
+ browser.set_data ("history-list-last-change", view);
+ }
+ }
+
+ void tab_list_resort (Midori.Browser browser, Midori.View view) {
+ unowned GLib.PtrArray list = browser.get_data ("history-list-tab-history");
+ unowned GLib.PtrArray list_new = browser.get_data ("history-list-tab-history-new");
+ list.remove (view);
+ list_new.remove (view);
+ list.add (view);
+ }
+
+ void activated (Midori.App app) {
+ this.preferences_changed ();
+ foreach (var browser in app.get_browsers ())
+ browser_added (browser);
+ app.add_browser.connect (browser_added);
+ }
+
+ void deactivated () {
+ var app = get_app ();
+ foreach (var browser in app.get_browsers ())
+ browser_removed (browser);
+ app.add_browser.disconnect (browser_added);
+ }
+
+ void show_preferences () {
+ var dialog = new PreferencesDialog (this);
+ dialog.show ();
+ }
+
+ internal Manager () {
+ GLib.Object (name: _("History List"),
+ description: _("Move to the last used tab when switching or closing tabs"),
+ version: "0.4",
+ authors: "André Stösel ");
+
+ this.install_integer ("TabClosingBehavior", TabClosingBehavior.LAST);
+
+ this.activate.connect (activated);
+ this.deactivate.connect (deactivated);
+ this.open_preferences.connect (show_preferences);
+ this.preferences_changed.connect (preferences_changed_cb);
+ }
+ construct {
+ this.escKeyval = Gdk.keyval_from_name ("Escape");
}
- browser.set_data ("history-list-last-change", view);
- }
- void tab_list_resort (Midori.Browser browser, Midori.View view) {
- unowned GLib.PtrArray list = browser.get_data ("history-list-tab-history");
- unowned GLib.PtrArray list_new = browser.get_data ("history-list-tab-history-new");
- list.remove (view);
- list_new.remove (view);
- list.add (view);
- }
- void activated (Midori.App app) {
- foreach (var browser in app.get_browsers ())
- browser_added (browser);
- app.add_browser.connect (browser_added);
- }
- void deactivated () {
- var app = get_app ();
- foreach (var browser in app.get_browsers ())
- browser_removed (browser);
- app.add_browser.disconnect (browser_added);
- }
- internal HistoryList () {
- GLib.Object (name: _("History List"),
- description: _("Switch tabs with Ctrl+Tab sorted by last usage"),
- version: "0.3",
- authors: "André Stösel ");
- activate.connect (activated);
- deactivate.connect (deactivated);
- }
- construct {
- this.escKeyval = Gdk.keyval_from_name ("Escape");
}
}
public Midori.Extension extension_init () {
- return new HistoryList ();
+ return new HistoryList.Manager ();
}
diff --git a/katze/katze-utils.c b/katze/katze-utils.c
index 9cbd72fd..767d814e 100644
--- a/katze/katze-utils.c
+++ b/katze/katze-utils.c
@@ -189,6 +189,26 @@ proxy_entry_focus_out_event_cb (GtkEntry* entry,
return FALSE;
}
+static void
+proxy_days_changed_cb (GtkComboBox* combo,
+ GObject* object)
+{
+ gint active = gtk_combo_box_get_active (combo);
+ const gchar* property = g_object_get_data (G_OBJECT (combo), "property");
+ gint max_age;
+ switch (active)
+ {
+ case 0: max_age = 0; break;
+ case 1: max_age = 1; break;
+ case 2: max_age = 7; break;
+ case 3: max_age = 30; break;
+ case 4: max_age = 365; break;
+ default:
+ max_age = 30;
+ }
+ g_object_set (object, property, max_age, NULL);
+}
+
static void
proxy_spin_button_changed_cb (GtkSpinButton* button,
GObject* object)
@@ -480,6 +500,9 @@ g_icon_to_string (GIcon *icon)
* Since 0.3.6 the following hints are also supported:
* "address": the widget will be particularly suitable for typing
* a valid URI or IP address and highlight errors.
+ * Since 0.4.0 the following hints are also supported:
+ * "days": the widget will be particularly suitable for choosing
+ * a period of time in days.
*
* Any other values for @hint are silently ignored.
*
@@ -788,6 +811,30 @@ katze_property_proxy (gpointer object,
g_signal_connect (widget, "value-changed",
G_CALLBACK (proxy_spin_button_changed_cb), object);
}
+ else if (type == G_TYPE_PARAM_INT && _hint == I_("days"))
+ {
+ gint value = katze_object_get_int (object, property);
+ gint active;
+ widget = gtk_combo_box_new_text ();
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("1 hour"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("1 day"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("1 week"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("1 month"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("1 year"));
+ switch (value)
+ {
+ case 0: active = 0; break;
+ case 1: active = 1; break;
+ case 7: active = 2; break;
+ case 30: active = 3; break;
+ case 365: active = 4; break;
+ default:
+ active = 3;
+ }
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), active);
+ g_signal_connect (widget, "changed",
+ G_CALLBACK (proxy_days_changed_cb), object);
+ }
else if (type == G_TYPE_PARAM_INT)
{
gint value = katze_object_get_int (object, property);
diff --git a/midori/main.c b/midori/main.c
index feadcfb2..b7dd32e0 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -61,6 +61,12 @@
#include
#endif
+#ifdef G_OS_WIN32
+ #define LIBPREFIX ""
+#else
+ #define LIBPREFIX "lib"
+#endif
+
static gchar*
build_config_filename (const gchar* filename)
{
@@ -420,13 +426,11 @@ midori_history_initialize (KatzeArray* array,
char** errmsg)
{
sqlite3* db;
- gboolean has_day;
+ gboolean has_day = FALSE;
sqlite3_stmt* stmt;
gint result;
gchar* sql;
- has_day = FALSE;
-
if (sqlite3_open (filename, &db) != SQLITE_OK)
{
if (errmsg)
@@ -593,7 +597,10 @@ midori_session_add_delay (KatzeArray* session)
{
KatzeItem* item;
KATZE_ARRAY_FOREACH_ITEM (item, session)
- katze_item_set_meta_integer (item, "delay", 1);
+ {
+ if (katze_item_get_meta_integer (item, "delay") == -1)
+ katze_item_set_meta_integer (item, "delay", 1);
+ }
}
static void
@@ -717,25 +724,6 @@ midori_browser_show_preferences_cb (MidoriBrowser* browser,
gtk_box_pack_start (GTK_BOX (page), scrolled, TRUE, TRUE, 4);
}
-static void
-midori_preferences_delete_cookies_changed_cb (GtkComboBox* combo,
- MidoriWebSettings* settings)
-{
- gint active = gtk_combo_box_get_active (combo);
- gint max_age;
- switch (active)
- {
- case 0: max_age = 0; break;
- case 1: max_age = 1; break;
- case 2: max_age = 7; break;
- case 3: max_age = 30; break;
- case 4: max_age = 365; break;
- default:
- max_age = 30;
- }
- g_object_set (settings, "maximum-cookie-age", max_age, NULL);
-}
-
static void
midori_browser_privacy_preferences_cb (MidoriBrowser* browser,
KatzePreferences* preferences,
@@ -744,34 +732,13 @@ midori_browser_privacy_preferences_cb (MidoriBrowser* browser,
MidoriWebSettings* settings = midori_browser_get_settings (browser);
GtkWidget* button;
GtkWidget* label;
- gint max_age = katze_object_get_int (settings, "maximum-cookie-age");
- guint active;
gchar* markup;
katze_preferences_add_category (preferences, _("Privacy"), GTK_STOCK_INDEX);
katze_preferences_add_group (preferences, NULL);
button = katze_property_label (settings, "maximum-cookie-age");
katze_preferences_add_widget (preferences, button, "indented");
- button = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (button), _("Delete old cookies after 1 hour"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (button), _("Delete old cookies after 1 day"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (button), _("Delete old cookies after 1 week"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (button), _("Delete old cookies after 1 month"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (button), _("Delete old cookies after 1 year"));
-
- switch (max_age)
- {
- case 0: active = 0; break;
- case 1: active = 1; break;
- case 7: active = 2; break;
- case 30: active = 3; break;
- case 365: active = 4; break;
- default:
- active = 3;
- }
- gtk_combo_box_set_active (GTK_COMBO_BOX (button), active);
- g_signal_connect (button, "changed",
- G_CALLBACK (midori_preferences_delete_cookies_changed_cb), settings);
+ button = katze_property_proxy (settings, "maximum-cookie-age", "days");
katze_preferences_add_widget (preferences, button, "spanned");
markup = g_strdup_printf ("%s ",
@@ -781,29 +748,19 @@ midori_browser_privacy_preferences_cb (MidoriBrowser* browser,
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");
#endif
- katze_preferences_add_group (preferences, NULL);
+ katze_preferences_add_widget (preferences, gtk_label_new (NULL), "indented");
button = katze_property_label (settings, "maximum-history-age");
katze_preferences_add_widget (preferences, button, "indented");
- button = katze_property_proxy (settings, "maximum-history-age", NULL);
+ button = katze_property_proxy (settings, "maximum-history-age", "days");
katze_preferences_add_widget (preferences, button, "spanned");
- label = gtk_label_new (_("days"));
- katze_preferences_add_widget (preferences, label, "spanned");
}
static void
@@ -827,11 +784,9 @@ midori_app_add_browser_cb (MidoriApp* app,
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",
@@ -954,18 +909,6 @@ soup_session_settings_notify_http_proxy_cb (MidoriWebSettings* settings,
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,
@@ -1036,7 +979,7 @@ midori_load_soup_session (gpointer settings)
{
SoupSession* session = webkit_get_default_session ();
- #if WEBKIT_CHECK_VERSION (1, 1, 14) && defined (HAVE_LIBSOUP_2_29_91)
+ #if defined (HAVE_LIBSOUP_2_29_91)
const gchar* certificate_files[] =
{
"/etc/pki/tls/certs/ca-bundle.crt",
@@ -1074,17 +1017,13 @@ midori_load_soup_session (gpointer settings)
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);
midori_soup_session_debug (session);
+ g_object_set_data (G_OBJECT (session), "midori-session-initialized", (void*)1);
+
return FALSE;
}
@@ -1098,22 +1037,6 @@ button_modify_preferences_clicked_cb (GtkWidget* button,
gtk_widget_destroy (dialog);
}
-static void
-button_reset_session_clicked_cb (GtkWidget* button,
- KatzeArray* session)
-{
- gchar* config_file = build_config_filename ("session.old.xbel");
- GError* error = NULL;
- if (!midori_array_to_file (session, config_file, "xbel", &error))
- {
- g_warning (_("The session couldn't be saved. %s"), error->message);
- g_error_free (error);
- }
- g_free (config_file);
- katze_array_clear (session);
- gtk_widget_set_sensitive (button, FALSE);
-}
-
static void
button_disable_extensions_clicked_cb (GtkWidget* button,
MidoriApp* app)
@@ -1122,25 +1045,23 @@ button_disable_extensions_clicked_cb (GtkWidget* button,
gtk_widget_set_sensitive (button, FALSE);
}
-static GtkWidget*
-midori_create_diagnostic_dialog (MidoriWebSettings* settings,
- KatzeArray* _session)
+static MidoriStartup
+midori_show_diagnostic_dialog (MidoriWebSettings* settings,
+ KatzeArray* _session)
{
GtkWidget* dialog;
GtkWidget* content_area;
GdkScreen* screen;
GtkIconTheme* icon_theme;
+ GtkWidget* align;
GtkWidget* box;
GtkWidget* button;
MidoriApp* app = katze_item_get_parent (KATZE_ITEM (_session));
+ MidoriStartup load_on_startup = katze_object_get_enum (settings, "load-on-startup");
+ gint response;
dialog = gtk_message_dialog_new (
- NULL, 0, GTK_MESSAGE_WARNING,
- #ifdef HAVE_HILDON_2_2
- GTK_BUTTONS_NONE,
- #else
- GTK_BUTTONS_OK,
- #endif
+ NULL, 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
_("Midori seems to have crashed the last time it was opened. "
"If this happened repeatedly, try one of the following options "
"to solve the problem."));
@@ -1156,16 +1077,14 @@ midori_create_diagnostic_dialog (MidoriWebSettings* settings,
else
gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
}
+ align = gtk_alignment_new (0.5, 0.5, 0.5, 0.5);
+ gtk_container_add (GTK_CONTAINER (content_area), align);
box = gtk_hbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (align), box);
button = gtk_button_new_with_mnemonic (_("Modify _preferences"));
g_signal_connect (button, "clicked",
G_CALLBACK (button_modify_preferences_clicked_cb), settings);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 4);
- button = gtk_button_new_with_mnemonic (_("Reset the last _session"));
- g_signal_connect (button, "clicked",
- G_CALLBACK (button_reset_session_clicked_cb), _session);
- gtk_widget_set_sensitive (button, !katze_array_is_empty (_session));
- gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 4);
button = gtk_button_new_with_mnemonic (_("Disable all _extensions"));
if (g_object_get_data (G_OBJECT (app), "extensions"))
g_signal_connect (button, "clicked",
@@ -1173,22 +1092,19 @@ midori_create_diagnostic_dialog (MidoriWebSettings* settings,
else
gtk_widget_set_sensitive (button, FALSE);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 4);
- gtk_widget_show_all (box);
- gtk_container_add (GTK_CONTAINER (content_area), box);
+ gtk_widget_show_all (align);
button = katze_property_proxy (settings, "show-crash-dialog", NULL);
gtk_widget_show (button);
gtk_container_add (GTK_CONTAINER (content_area), button);
- #ifdef HAVE_HILDON_2_2
- box = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), box, TRUE, FALSE, 4);
- button = hildon_gtk_button_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_HALFSCREEN_WIDTH);
- gtk_button_set_label (GTK_BUTTON (button), GTK_STOCK_OK);
- gtk_button_set_use_stock (GTK_BUTTON (button), TRUE);
- g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy), dialog);
- gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 4);
- gtk_widget_show_all (box);
- #endif
+ gtk_container_set_focus_child (GTK_CONTAINER (dialog), gtk_dialog_get_action_area (GTK_DIALOG (dialog)));
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("Discard old tabs"), MIDORI_STARTUP_BLANK_PAGE,
+ _("Show last tabs without loading"), MIDORI_STARTUP_DELAYED_PAGES,
+ _("Show last open tabs"), MIDORI_STARTUP_LAST_OPEN_PAGES,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ load_on_startup == MIDORI_STARTUP_HOMEPAGE
+ ? MIDORI_STARTUP_BLANK_PAGE : load_on_startup);
if (1)
{
/* GtkLabel can't wrap the text properly. Until some day
@@ -1211,7 +1127,14 @@ midori_create_diagnostic_dialog (MidoriWebSettings* settings,
gtk_widget_size_request (content_area, &req);
gtk_widget_set_size_request (label, req.width * 0.9, -1);
}
- return dialog;
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ if (response == GTK_RESPONSE_DELETE_EVENT)
+ response = G_MAXINT;
+ else if (response == MIDORI_STARTUP_BLANK_PAGE)
+ katze_array_clear (_session);
+ return response;
}
static gboolean
@@ -1403,11 +1326,11 @@ midori_load_session (gpointer data)
MidoriBrowser* browser;
MidoriApp* app = katze_item_get_parent (KATZE_ITEM (_session));
MidoriWebSettings* settings = katze_object_get_object (app, "settings");
+ MidoriStartup load_on_startup;
gchar* config_file;
KatzeArray* session;
KatzeItem* item;
gint64 current;
- MidoriStartup load_on_startup;
gchar** command = g_object_get_data (G_OBJECT (app), "execute-command");
#ifdef G_ENABLE_DEBUG
gboolean startup_timer = g_getenv ("MIDORI_STARTTIME") != NULL;
@@ -1436,8 +1359,7 @@ midori_load_session (gpointer data)
g_signal_connect_after (gtk_accel_map_get (), "changed",
G_CALLBACK (accel_map_changed_cb), NULL);
- g_object_get (settings, "load-on-startup", &load_on_startup, NULL);
-
+ load_on_startup = (MidoriStartup)g_object_get_data (G_OBJECT (settings), "load-on-startup");
if (katze_array_is_empty (_session))
{
gchar* homepage;
@@ -1536,7 +1458,6 @@ midori_run_script (const gchar* filename)
return 1;
}
-#if WEBKIT_CHECK_VERSION (1, 1, 6)
static void
snapshot_load_finished_cb (GtkWidget* web_view,
WebKitWebFrame* web_frame,
@@ -1560,7 +1481,6 @@ snapshot_load_finished_cb (GtkWidget* web_view,
g_print (_("Snapshot saved to: %s\n"), filename);
gtk_main_quit ();
}
-#endif
static void
midori_web_app_browser_notify_load_status_cb (MidoriBrowser* browser,
@@ -1597,6 +1517,8 @@ midori_prepare_uri (const gchar *uri)
if (g_path_is_absolute (uri))
return g_filename_to_uri (uri, NULL, NULL);
+ else if (g_str_has_prefix(uri, "javascript:"))
+ return g_strdup (uri);
else if (g_file_test (uri, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
{
gchar* current_dir = g_get_current_dir ();
@@ -1647,7 +1569,12 @@ speeddial_new_from_file (const gchar* config,
}
katze_assign (config_file, g_build_filename (config, "speeddial.json", NULL));
- g_file_get_contents (config_file, &json_content, &json_length, NULL);
+ if (!g_file_get_contents (config_file, &json_content, &json_length, NULL))
+ {
+ katze_assign (json_content, g_strdup ("'{}'"));
+ json_length = strlen ("'{}'");
+ }
+
script = g_string_sized_new (json_length);
g_string_append (script, "var json = JSON.parse (");
g_string_append_len (script, json_content, json_length);
@@ -1661,7 +1588,7 @@ speeddial_new_from_file (const gchar* config,
" + 'title=' + tile['title'] + '\\n\\n';"
"} "
"var columns = json['width'] ? json['width'] : 3;"
- "var rows = json['shortcuts'].length / columns;"
+ "var rows = json['shortcuts'] ? json['shortcuts'].length / columns : 0;"
"keyfile += '[settings]\\n'"
" + 'columns=' + columns + '\\n'"
" + 'rows=' + (rows > 3 ? rows : 3) + '\\n\\n';"
@@ -1848,13 +1775,28 @@ midori_clear_flash_cookies_cb (void)
}
#endif
-#if WEBKIT_CHECK_VERSION (1, 1, 14)
+static void
+midori_clear_saved_logins_cb (void)
+{
+ sqlite3* db;
+ gchar* path = g_build_filename (sokoke_set_config_dir (NULL), "logins", NULL);
+ g_unlink (path);
+ /* Form History database, written by the extension */
+ katze_assign (path, g_build_filename (sokoke_set_config_dir (NULL),
+ "extensions", LIBPREFIX "formhistory." G_MODULE_SUFFIX, "forms.db", NULL));
+ if (sqlite3_open (path, &db) == SQLITE_OK)
+ {
+ sqlite3_exec (db, "DELETE FROM forms", NULL, NULL, NULL);
+ sqlite3_close (db);
+ }
+ g_free (path);
+}
+
static void
midori_clear_html5_databases_cb (void)
{
webkit_remove_all_web_databases ();
}
-#endif
#if WEBKIT_CHECK_VERSION (1, 3, 11)
static void
@@ -1880,6 +1822,48 @@ midori_clear_offline_appcache_cb (void)
}
#endif
+static void
+midori_log_to_file (const gchar* log_domain,
+ GLogLevelFlags log_level,
+ const gchar* message,
+ gpointer user_data)
+{
+ FILE* logfile = fopen ((const char*)user_data, "a");
+ gchar* level_name = "";
+ time_t timestamp = time (NULL);
+
+ switch (log_level)
+ {
+ /* skip irrelevant flags */
+ case G_LOG_LEVEL_MASK:
+ case G_LOG_FLAG_FATAL:
+ case G_LOG_FLAG_RECURSION:
+
+ case G_LOG_LEVEL_ERROR:
+ level_name = "ERROR";
+ break;
+ case G_LOG_LEVEL_CRITICAL:
+ level_name = "CRITICAL";
+ break;
+ case G_LOG_LEVEL_WARNING:
+ level_name = "WARNING";
+ break;
+ case G_LOG_LEVEL_MESSAGE:
+ level_name = "MESSAGE";
+ break;
+ case G_LOG_LEVEL_INFO:
+ level_name = "INFO";
+ break;
+ case G_LOG_LEVEL_DEBUG:
+ level_name = "DEBUG";
+ break;
+ }
+
+ fprintf (logfile, "%s%s-%s **: %s\n", asctime (localtime (×tamp)),
+ log_domain ? log_domain : "Midori", level_name, message);
+ fclose (logfile);
+}
+
int
main (int argc,
char** argv)
@@ -1891,6 +1875,7 @@ main (int argc,
gboolean back_from_crash;
gboolean run;
gchar* snapshot;
+ gchar* logfile;
gboolean execute;
gboolean help_execute;
gboolean version;
@@ -1914,10 +1899,8 @@ main (int argc,
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,
@@ -1933,6 +1916,8 @@ main (int argc,
/* i18n: CLI: Close tabs, clear private data, open starting page */
N_("Reset Midori after SECONDS seconds of inactivity"), N_("SECONDS") },
#endif
+ { "log-file", 'l', 0, G_OPTION_ARG_FILENAME, &logfile,
+ N_("Redirects console warnings to the specified FILENAME"), N_("FILENAME")},
{ NULL }
};
GString* error_messages;
@@ -2008,6 +1993,7 @@ main (int argc,
diagnostic_dialog = FALSE;
run = FALSE;
snapshot = NULL;
+ logfile = NULL;
execute = FALSE;
help_execute = FALSE;
version = FALSE;
@@ -2036,7 +2022,6 @@ main (int argc,
/* Private browsing, window title, default config folder */
if (private)
{
- g_set_application_name (_("Midori (Private Browsing)"));
if (!config && !webapp)
config = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL);
/* Mask the timezone, which can be read by Javascript */
@@ -2093,7 +2078,6 @@ main (int argc,
return 0;
}
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
if (snapshot)
{
gchar* filename;
@@ -2124,20 +2108,25 @@ main (int argc,
g_free (filename);
return 0;
}
- #endif
+
+ if (logfile)
+ {
+ g_log_set_default_handler (midori_log_to_file, (gpointer)logfile);
+ }
sokoke_register_privacy_item ("page-icons", _("Website icons"),
G_CALLBACK (midori_clear_page_icons_cb));
+ /* i18n: Logins and passwords in websites and web forms */
+ sokoke_register_privacy_item ("formhistory", _("Saved logins and _passwords"),
+ G_CALLBACK (midori_clear_saved_logins_cb));
sokoke_register_privacy_item ("web-cookies", _("Cookies"),
G_CALLBACK (midori_clear_web_cookies_cb));
#ifdef GDK_WINDOWING_X11
sokoke_register_privacy_item ("flash-cookies", _("'Flash' Cookies"),
G_CALLBACK (midori_clear_flash_cookies_cb));
#endif
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
sokoke_register_privacy_item ("html5-databases", _("HTML5 _Databases"),
G_CALLBACK (midori_clear_html5_databases_cb));
- #endif
#if WEBKIT_CHECK_VERSION (1, 3, 11)
sokoke_register_privacy_item ("web-cache", _("Web Cache"),
G_CALLBACK (midori_clear_web_cache_cb));
@@ -2167,6 +2156,34 @@ main (int argc,
else
settings = g_object_ref (midori_browser_get_settings (browser));
+ if (private)
+ {
+ g_object_set (settings,
+ "preferred-languages", "en",
+ "enable-private-browsing", TRUE,
+ "enable-html5-database", FALSE,
+ "enable-html5-local-storage", FALSE,
+ "enable-offline-web-application-cache", FALSE,
+ /* 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,
+ "strip-referer", TRUE, NULL);
+ midori_browser_set_action_visible (browser, "Tools", FALSE);
+ midori_browser_set_action_visible (browser, "ClearPrivateData", FALSE);
+ }
+
+ if (private || !config)
+ {
+ /* Disable saving by setting an unwritable folder */
+ sokoke_set_config_dir ("/");
+ }
+
+ midori_load_soup_session (settings);
+ if (block_uris)
+ g_signal_connect (session, "request-queued",
+ G_CALLBACK (midori_soup_session_block_uris_cb),
+ g_strdup (block_uris));
+
if (webapp)
{
gchar* tmp_uri = midori_prepare_uri (webapp);
@@ -2186,33 +2203,7 @@ main (int argc,
G_CALLBACK (midori_web_app_browser_notify_load_status_cb), NULL);
}
- if (private)
- {
- 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,
- "strip-referer", TRUE, NULL);
- midori_browser_set_action_visible (browser, "Tools", FALSE);
- midori_browser_set_action_visible (browser, "ClearPrivateData", FALSE);
- }
-
- if (private || !config)
- {
- /* Disable saving by setting an unwritable folder */
- sokoke_set_config_dir ("/");
- }
-
- g_object_set (settings, "show-panel", FALSE,
+ g_object_set (settings, "show-panel", FALSE,
"last-window-state", MIDORI_WINDOW_NORMAL,
NULL);
midori_browser_set_action_visible (browser, "Panel", FALSE);
@@ -2243,12 +2234,7 @@ main (int argc,
if (midori_browser_get_current_uri (browser) == NULL)
midori_browser_add_uri (browser, "about:blank");
- if (block_uris)
- g_signal_connect (session, "request-queued",
- G_CALLBACK (midori_soup_session_block_uris_cb),
- g_strdup (block_uris));
midori_setup_inactivity_reset (browser, inactivity_reset, webapp);
- midori_load_soup_session (settings);
midori_startup_timer ("App created: \t%f");
gtk_main ();
return 0;
@@ -2319,9 +2305,7 @@ main (int argc,
error = NULL;
settings = settings_and_accels_new (config, &extensions);
g_object_set (settings, "enable-developer-extras", TRUE, NULL);
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
g_object_set (settings, "enable-html5-database", TRUE, NULL);
- #endif
midori_startup_timer ("Config and accels read: \t%f");
/* Load search engines */
@@ -2345,7 +2329,7 @@ main (int argc,
{
g_string_append_printf (error_messages,
_("Bookmarks couldn't be loaded: %s\n"), errmsg);
- g_free (errmsg);
+ errmsg = NULL;
}
else if (!bookmarks_exist)
{
@@ -2367,8 +2351,8 @@ main (int argc,
config_file = NULL;
_session = katze_array_new (KATZE_TYPE_ITEM);
+ load_on_startup = katze_object_get_enum (settings, "load-on-startup");
#if HAVE_LIBXML
- g_object_get (settings, "load-on-startup", &load_on_startup, NULL);
if (load_on_startup >= MIDORI_STARTUP_LAST_OPEN_PAGES)
{
katze_assign (config_file, build_config_filename ("session.xbel"));
@@ -2406,11 +2390,12 @@ main (int argc,
{
g_string_append_printf (error_messages,
_("The history couldn't be loaded: %s\n"), errmsg);
- g_free (errmsg);
+ errmsg = NULL;
}
g_free (bookmarks_file);
midori_startup_timer ("History read: \t%f");
+ error = NULL;
speeddial = speeddial_new_from_file (config, &error);
/* In case of errors */
@@ -2469,6 +2454,8 @@ main (int argc,
uri_ready = midori_prepare_uri (uri);
katze_item_set_uri (item, uri_ready);
g_free (uri_ready);
+ /* Never delay command line arguments */
+ katze_item_set_meta_integer (item, "delay", 0);
katze_array_add_item (_session, item);
uri = strtok (NULL, "|");
}
@@ -2507,24 +2494,16 @@ main (int argc,
else
g_file_set_contents (config_file, "RUNNING", -1, NULL);
- if (back_from_crash)
- {
- if (katze_object_get_int (settings, "load-on-startup")
- >= MIDORI_STARTUP_LAST_OPEN_PAGES)
- midori_session_add_delay (_session);
-
- if (katze_object_get_boolean (settings, "show-crash-dialog"))
- diagnostic_dialog = TRUE;
- }
+ if (back_from_crash && katze_object_get_boolean (settings, "show-crash-dialog"))
+ diagnostic_dialog = TRUE;
if (diagnostic_dialog)
{
- GtkWidget* dialog = midori_create_diagnostic_dialog (settings, _session);
- gint response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- if (response == GTK_RESPONSE_DELETE_EVENT)
+ load_on_startup = midori_show_diagnostic_dialog (settings, _session);
+ if (load_on_startup == G_MAXINT)
return 0;
}
+ g_object_set_data (G_OBJECT (settings), "load-on-startup", GINT_TO_POINTER (load_on_startup));
midori_startup_timer ("Signal setup: \t%f");
g_object_set (app, "settings", settings,
@@ -2573,6 +2552,7 @@ main (int argc,
GList* data_items = sokoke_register_privacy_item (NULL, NULL, NULL);
gchar* clear_data = katze_object_get_string (settings, "clear-data");
+ midori_remove_config_file (clear_prefs, MIDORI_CLEAR_SESSION, "session.xbel");
midori_remove_config_file (clear_prefs, MIDORI_CLEAR_HISTORY, "history.db");
midori_remove_config_file (clear_prefs, MIDORI_CLEAR_TRASH, "tabtrash.xbel");
@@ -2585,8 +2565,8 @@ main (int argc,
g_free (clear_data);
}
- if (katze_object_get_int (settings, "load-on-startup")
- < MIDORI_STARTUP_LAST_OPEN_PAGES)
+ load_on_startup = katze_object_get_int (settings, "load-on-startup");
+ if (load_on_startup < MIDORI_STARTUP_LAST_OPEN_PAGES)
{
katze_assign (config_file, g_build_filename (config, "session.xbel", NULL));
g_unlink (config_file);
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 74b08703..108f14cd 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -36,6 +36,10 @@
#include
#endif
+#include
+#include
+#include
+
#ifdef HAVE_HILDON_2_2
#include
#include
@@ -225,11 +229,9 @@ midori_transferbar_confirm_delete (MidoriTransferbar* transferbar);
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)
@@ -306,10 +308,8 @@ _midori_browser_update_interface (MidoriBrowser* browser)
_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",
@@ -576,16 +576,13 @@ static void
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_strconcat (title, " - ",
- g_get_application_name (), NULL);
+ gchar* window_title = g_strdup_printf (_("%s (Private Browsing)"), title);
gtk_window_set_title (GTK_WINDOW (browser), window_title);
g_free (window_title);
}
else
- #endif
gtk_window_set_title (GTK_WINDOW (browser), title);
}
@@ -705,7 +702,6 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
GtkWidget* label;
const gchar* value;
GtkWidget* entry_title;
- GtkWidget* entry_desc;
GtkWidget* entry_uri;
GtkWidget* combo_folder;
GtkWidget* check_toolbar;
@@ -718,6 +714,9 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
db = g_object_get_data (G_OBJECT (browser->bookmarks), "db");
+ if (!db)
+ return FALSE;
+
if (is_folder)
title = new_bookmark ? _("New folder") : _("Edit folder");
else
@@ -767,22 +766,6 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
gtk_container_add (GTK_CONTAINER (content_area), hbox);
gtk_widget_show_all (hbox);
- hbox = gtk_hbox_new (FALSE, 8);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
- label = gtk_label_new_with_mnemonic (_("_Description:"));
- gtk_size_group_add_widget (sizegroup, label);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- entry_desc = gtk_entry_new ();
- gtk_entry_set_activates_default (GTK_ENTRY (entry_desc), TRUE);
- if (bookmark)
- {
- value = katze_item_get_text (bookmark);
- gtk_entry_set_text (GTK_ENTRY (entry_desc), value ? value : "");
- }
- gtk_box_pack_start (GTK_BOX (hbox), entry_desc, TRUE, TRUE, 0);
- gtk_container_add (GTK_CONTAINER (content_area), hbox);
- gtk_widget_show_all (hbox);
-
entry_uri = NULL;
if (!is_folder)
{
@@ -908,8 +891,6 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
katze_item_set_name (bookmark,
gtk_entry_get_text (GTK_ENTRY (entry_title)));
- katze_item_set_text (bookmark,
- gtk_entry_get_text (GTK_ENTRY (entry_desc)));
katze_item_set_meta_integer (bookmark, "toolbar",
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_toolbar)));
if (!is_folder)
@@ -938,7 +919,6 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
return return_status;
}
-#if WEBKIT_CHECK_VERSION (1, 1, 3)
static gboolean
midori_browser_prepare_download (MidoriBrowser* browser,
WebKitDownload* download,
@@ -998,32 +978,12 @@ midori_browser_prepare_download (MidoriBrowser* browser,
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,
+ const gchar* data,
+ const size_t len,
+ const gchar* outfile);
static void
midori_browser_save_uri (MidoriBrowser* browser,
@@ -1080,26 +1040,21 @@ midori_browser_save_uri (MidoriBrowser* browser,
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
{
- #if WEBKIT_CHECK_VERSION (1, 1, 3)
- WebKitNetworkRequest* request;
- WebKitDownload* download;
- gchar* destination;
- #endif
+ GtkWidget* view;
+ GtkWidget* web_view;
+ WebKitWebDataSource *data_source;
+ WebKitWebFrame *frame;
+ const GString *data;
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, 3)
- 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);
- #else
- katze_net_load_uri (NULL, uri, NULL,
- (KatzeNetTransferCb)midori_browser_save_transfer_cb, filename);
- #endif
+ 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);
+ if (data)
+ midori_browser_save_source (uri, data->str, data->len, filename);
g_free (last_dir);
last_dir = folder;
@@ -1351,8 +1306,6 @@ midori_view_new_view_cb (GtkWidget* view,
}
}
-#if WEBKIT_CHECK_VERSION (1, 1, 3)
-
static void
midori_view_download_save_as_response_cb (GtkWidget* dialog,
gint response,
@@ -1461,7 +1414,6 @@ midori_view_download_requested_cb (GtkWidget* view,
}
return TRUE;
}
-#endif
static void
midori_view_search_text_cb (GtkWidget* view,
@@ -1579,10 +1531,8 @@ _midori_browser_add_tab (MidoriBrowser* browser,
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",
@@ -1662,6 +1612,7 @@ midori_browser_key_press_event (GtkWidget* widget,
MidoriBrowser* browser = MIDORI_BROWSER (widget);
GtkWidgetClass* widget_class;
guint clean_state;
+ GtkWidget* focus;
/* Interpret Ctrl(+Shift)+Tab as tab switching for compatibility */
if (midori_browser_get_nth_tab (browser, 1) != NULL
@@ -1678,6 +1629,13 @@ midori_browser_key_press_event (GtkWidget* widget,
gtk_action_activate (_action_by_name (browser, "TabPrevious"));
return TRUE;
}
+ /* Interpret Ctrl+= as Zoom In for compatibility */
+ else if ((event->keyval == GDK_KP_Equal || event->keyval == GDK_equal)
+ && (event->state & GDK_CONTROL_MASK))
+ {
+ midori_browser_activate_action (browser, "ZoomIn");
+ return TRUE;
+ }
/* Interpret F5 as reloading for compatibility */
else if (event->keyval == GDK_F5)
{
@@ -1685,8 +1643,31 @@ midori_browser_key_press_event (GtkWidget* widget,
return TRUE;
}
- if (gtk_window_get_focus (GTK_WINDOW (widget)) == NULL)
+ focus = gtk_window_get_focus (GTK_WINDOW (widget));
+ if (focus == NULL)
gtk_widget_grab_focus (midori_browser_get_current_tab (MIDORI_BROWSER (widget)));
+ else if (G_OBJECT_TYPE (focus) == WEBKIT_TYPE_WEB_VIEW
+ && event->keyval == GDK_space
+ && !webkit_web_view_can_cut_clipboard (WEBKIT_WEB_VIEW (focus))
+ && !webkit_web_view_can_paste_clipboard (WEBKIT_WEB_VIEW (focus)))
+ {
+ /* Space at the bottom of the page: Go to next page */
+ GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (focus));
+ MidoriView* view = MIDORI_VIEW (gtk_widget_get_parent (GTK_WIDGET (scrolled)));
+ GtkAdjustment* vadjust = gtk_scrolled_window_get_vadjustment (scrolled);
+ if (gtk_adjustment_get_value (vadjust)
+ == (gtk_adjustment_get_upper (vadjust) - gtk_adjustment_get_page_size (vadjust)))
+ {
+ /* Duplicate here because the URI pointer might change */
+ gchar* uri = g_strdup (midori_view_get_next_page (view));
+ if (uri != NULL)
+ {
+ midori_view_set_uri (view, uri);
+ g_free (uri);
+ return TRUE;
+ }
+ }
+ }
if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
if (sokoke_window_activate_key (window, event))
@@ -1703,8 +1684,14 @@ midori_browser_key_press_event (GtkWidget* widget,
if (event->state && gtk_window_propagate_key_event (window, event))
return TRUE;
- /* Interpret Backspace as going back for compatibility */
- if (event->keyval == GDK_BackSpace)
+ /* Interpret (Shift+)Backspace as going back (forward) for compatibility */
+ if ((event->keyval == GDK_BackSpace)
+ && (event->state & GDK_SHIFT_MASK))
+ {
+ gtk_action_activate (_action_by_name (browser, "Forward"));
+ return TRUE;
+ }
+ else if (event->keyval == GDK_BackSpace)
{
gtk_action_activate (_action_by_name (browser, "Back"));
return TRUE;
@@ -2431,6 +2418,11 @@ _action_tab_close_activate (GtkAction* action,
MidoriBrowser* browser)
{
GtkWidget* widget = midori_browser_get_current_tab (browser);
+ if (gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), 1) == NULL &&
+ midori_view_is_blank (MIDORI_VIEW (widget)))
+ {
+ return;
+ }
gtk_widget_destroy (widget);
}
@@ -2466,19 +2458,15 @@ _action_edit_activate (GtkAction* action,
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);
@@ -2504,10 +2492,8 @@ _action_edit_activate (GtkAction* action,
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);
@@ -2515,7 +2501,6 @@ _action_edit_activate (GtkAction* action,
_action_set_sensitive (browser, "SelectAll", can_select_all);
}
-#if WEBKIT_CHECK_VERSION (1, 1, 14)
static void
_action_undo_activate (GtkAction* action,
MidoriBrowser* browser)
@@ -2533,7 +2518,6 @@ _action_redo_activate (GtkAction* action,
if (WEBKIT_IS_WEB_VIEW (widget))
webkit_web_view_redo (WEBKIT_WEB_VIEW (widget));
}
-#endif
static void
_action_cut_activate (GtkAction* action,
@@ -2881,9 +2865,7 @@ _action_tools_populate_popup (GtkAction* action,
{
{ "ManageSearchEngines" },
{ "ClearPrivateData" },
- #if WEBKIT_CHECK_VERSION (1, 1, 17)
{ "InspectPage" },
- #endif
{ "-" },
{ NULL },
{ "p" },
@@ -3048,10 +3030,8 @@ _action_compact_menu_populate_popup (GtkAction* action,
{ "Find" },
#if !HAVE_HILDON
{ "Print" },
- #if WEBKIT_CHECK_VERSION (1, 1, 17)
{ "InspectPage" },
#endif
- #endif
{ NULL },
{ "PrivateBrowsing" },
#if !HAVE_HILDON
@@ -3282,10 +3262,10 @@ _action_zoom_activate (GtkAction* action,
if (g_str_equal (gtk_action_get_name (action), "ZoomIn"))
midori_view_set_zoom_level (MIDORI_VIEW (view),
- midori_view_get_zoom_level (MIDORI_VIEW (view)) + 0.25f);
+ midori_view_get_zoom_level (MIDORI_VIEW (view)) + 0.10f);
else if (g_str_equal (gtk_action_get_name (action), "ZoomOut"))
midori_view_set_zoom_level (MIDORI_VIEW (view),
- midori_view_get_zoom_level (MIDORI_VIEW (view)) - 0.25f);
+ midori_view_get_zoom_level (MIDORI_VIEW (view)) - 0.10f);
else
midori_view_set_zoom_level (MIDORI_VIEW (view), 1.0f);
}
@@ -3295,7 +3275,6 @@ _action_view_encoding_activate (GtkAction* action,
GtkAction* current,
MidoriBrowser* browser)
{
- #if WEBKIT_CHECK_VERSION (1, 1, 2)
GtkWidget* view = midori_browser_get_current_tab (browser);
if (view)
{
@@ -3326,7 +3305,6 @@ _action_view_encoding_activate (GtkAction* action,
g_object_set (web_view, "custom-encoding", encoding, NULL);
}
}
- #endif
}
static gchar*
@@ -3362,58 +3340,67 @@ midori_browser_get_uri_extension (const gchar* uri)
return g_strdup (period);
}
-static void
-midori_browser_source_transfer_cb (KatzeNetRequest* request,
- MidoriBrowser* browser)
+static gchar*
+midori_browser_save_source (const gchar* uri,
+ const gchar* data,
+ const size_t len,
+ const gchar* outfile)
{
- gchar* filename;
- gchar* extension;
gchar* unique_filename;
- gchar* text_editor;
gint fd;
FILE* fp;
size_t ret;
- if (request->data)
- {
- extension = midori_browser_get_uri_extension (request->uri);
- filename = g_strdup_printf ("%uXXXXXX%s",
- g_str_hash (request->uri), extension);
- g_free (extension);
- if (((fd = g_file_open_tmp (filename, &unique_filename, NULL)) != -1))
- {
- if ((fp = fdopen (fd, "w")))
- {
- ret = fwrite (request->data, 1, request->length, fp);
- fclose (fp);
- if ((ret - request->length) != 0)
- {
- g_warning ("Error writing to file %s "
- "in midori_browser_source_transfer_cb()", filename);
- }
- g_object_get (browser->settings,
- "text-editor", &text_editor, NULL);
- if (text_editor && *text_editor)
- sokoke_spawn_program (text_editor, unique_filename);
- else
- sokoke_show_uri (NULL, unique_filename,
- gtk_get_current_event_time (), NULL);
+ if (!data)
+ return NULL;
- g_free (unique_filename);
- g_free (text_editor);
- }
- close (fd);
- }
+ if (!outfile)
+ {
+ gchar* filename;
+ gchar* extension;
+
+ extension = midori_browser_get_uri_extension (uri);
+ filename = g_strdup_printf ("%uXXXXXX%s",
+ g_str_hash (uri), extension);
+ g_free (extension);
+ fd = g_file_open_tmp (filename, &unique_filename, NULL);
g_free (filename);
}
+ else
+ {
+ unique_filename = g_strdup (outfile);
+ fd = g_open (unique_filename, O_WRONLY|O_CREAT, 0644);
+ }
+
+ if (fd != -1)
+ {
+ if ((fp = fdopen (fd, "w")))
+ {
+ ret = fwrite (data, 1, len, fp);
+ fclose (fp);
+ if ((ret - len) != 0)
+ {
+ g_warning ("Error writing to file %s "
+ "in midori_browser_source_transfer_cb()", unique_filename);
+ katze_assign (unique_filename, NULL);
+ }
+ }
+ close (fd);
+ }
+ return unique_filename;
}
static void
_action_source_view_activate (GtkAction* action,
MidoriBrowser* browser)
{
+ WebKitWebDataSource *data_source;
+ WebKitWebFrame *frame;
+ const GString *data;
GtkWidget* view;
+ GtkWidget* web_view;
gchar* text_editor;
+ gchar* filename = NULL;
const gchar* uri;
if (!(view = midori_browser_get_current_tab (browser)))
@@ -3421,54 +3408,41 @@ _action_source_view_activate (GtkAction* action,
g_object_get (browser->settings, "text-editor", &text_editor, NULL);
uri = midori_view_get_display_uri (MIDORI_VIEW (view));
+ 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);
+ if (data)
+ filename = midori_browser_save_source (uri, data->str, data->len, NULL);
+
+ if (!filename)
+ return;
if (!(text_editor && *text_editor))
{
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
GtkWidget* source;
- GtkWidget* web_view;
+ GtkWidget* source_view;
+ gchar* source_uri;
+
+ source_uri = g_filename_to_uri (filename, NULL, NULL);
+ g_free (filename);
source = midori_view_new (NULL);
midori_view_set_settings (MIDORI_VIEW (source), browser->settings);
- web_view = midori_view_get_web_view (MIDORI_VIEW (source));
- webkit_web_view_set_view_source_mode (WEBKIT_WEB_VIEW (web_view), TRUE);
- webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), uri);
+ source_view = midori_view_get_web_view (MIDORI_VIEW (source));
+ webkit_web_view_set_view_source_mode (WEBKIT_WEB_VIEW (source_view), TRUE);
+ webkit_web_view_load_uri (WEBKIT_WEB_VIEW (source_view), source_uri);
gtk_widget_show (source);
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://"))
+ else
{
- gchar* filename = g_filename_from_uri (uri, NULL, NULL);
sokoke_spawn_program (text_editor, filename);
g_free (filename);
- g_free (text_editor);
- return;
}
- katze_net_load_uri (NULL, uri, NULL,
- (KatzeNetTransferCb)midori_browser_source_transfer_cb, browser);
g_free (text_editor);
}
-#if WEBKIT_CHECK_VERSION (1, 1, 6)
static void
_action_caret_browsing_activate (GtkAction* action,
MidoriBrowser* browser)
@@ -3476,7 +3450,6 @@ _action_caret_browsing_activate (GtkAction* action,
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,
@@ -3494,7 +3467,6 @@ _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)
@@ -3518,7 +3490,6 @@ _action_scroll_somewhere_activate (GtkAction* action,
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,
@@ -4349,6 +4320,15 @@ midori_browser_clear_private_data_response_cb (GtkWidget* dialog,
GString* clear_data = g_string_new (NULL);
g_object_get (browser->settings, "clear-private-data", &saved_prefs, NULL);
+ button = g_object_get_data (G_OBJECT (dialog), "session");
+ if (gtk_toggle_button_get_active (button))
+ {
+ GList* tabs = gtk_container_get_children (GTK_CONTAINER (browser->notebook));
+ for (; tabs != NULL; tabs = g_list_next (tabs))
+ gtk_widget_destroy (tabs->data);
+ g_list_free (tabs);
+ clear_prefs |= MIDORI_CLEAR_SESSION;
+ }
button = g_object_get_data (G_OBJECT (dialog), "history");
if (gtk_toggle_button_get_active (button))
{
@@ -4450,6 +4430,11 @@ _action_clear_private_data_activate (GtkAction* action,
vbox = gtk_vbox_new (TRUE, 4);
alignment = gtk_alignment_new (0, 0, 1, 1);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 6, 12, 0);
+ button = gtk_check_button_new_with_mnemonic (_("Last open _tabs"));
+ if ((clear_prefs & MIDORI_CLEAR_SESSION) == MIDORI_CLEAR_SESSION)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+ g_object_set_data (G_OBJECT (dialog), "session", button);
+ gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
/* i18n: Browsing history, visited web pages */
button = gtk_check_button_new_with_mnemonic (_("_History"));
if ((clear_prefs & MIDORI_CLEAR_HISTORY) == MIDORI_CLEAR_HISTORY)
@@ -4498,7 +4483,6 @@ _action_clear_private_data_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)
@@ -4508,7 +4492,6 @@ _action_inspect_page_activate (GtkAction* action,
WebKitWebInspector* inspector = webkit_web_view_get_inspector (web_view);
webkit_web_inspector_show (inspector);
}
-#endif
static void
_action_tab_move_backward_activate (GtkAction* action,
@@ -4806,19 +4789,6 @@ midori_panel_notify_show_titles_cb (MidoriPanel* panel,
midori_browser_settings_notify, browser);
}
-static void
-midori_panel_notify_show_controls_cb (MidoriPanel* panel,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- gboolean show_controls = katze_object_get_boolean (panel, "show-controls");
- g_signal_handlers_block_by_func (browser->settings,
- midori_browser_settings_notify, browser);
- g_object_set (browser->settings, "show-panel-controls", show_controls, NULL);
- g_signal_handlers_unblock_by_func (browser->settings,
- midori_browser_settings_notify, browser);
-}
-
static void
midori_panel_notify_right_aligned_cb (MidoriPanel* panel,
GParamSpec* pspec,
@@ -5039,14 +5009,14 @@ static const GtkActionEntry entries[] =
NULL, "t",
N_("Open a new tab"), G_CALLBACK (_action_tab_new_activate) },
{ "PrivateBrowsing", NULL,
- N_("P_rivate Browsing"), "n",
+ N_("New P_rivate Browsing Window"), "n",
N_("Don't save any private data while browsing"),
G_CALLBACK (_action_private_browsing_activate), },
{ "Open", GTK_STOCK_OPEN,
NULL, "o",
N_("Open a file"), G_CALLBACK (_action_open_activate) },
{ "SaveAs", GTK_STOCK_SAVE_AS,
- NULL, "s",
+ N_("_Save Page As..."), "s",
N_("Save to a file"), G_CALLBACK (_action_save_as_activate) },
{ "AddSpeedDial", NULL,
N_("Add to Speed _dial"), "h",
@@ -5079,14 +5049,12 @@ static const GtkActionEntry entries[] =
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, "z",
N_("Undo the last modification"), G_CALLBACK (_action_undo_activate) },
{ "Redo", GTK_STOCK_REDO,
NULL, "z",
N_("Redo the last modification"), G_CALLBACK (_action_redo_activate) },
- #endif
{ "Cut", GTK_STOCK_CUT,
NULL, "x",
N_("Cut the selected text"), G_CALLBACK (_action_cut_activate) },
@@ -5103,7 +5071,7 @@ static const GtkActionEntry entries[] =
NULL, "a",
N_("Select all text"), G_CALLBACK (_action_select_all_activate) },
{ "Find", GTK_STOCK_FIND,
- NULL, "f",
+ N_("_Find..."), "f",
N_("Find a word or phrase in the page"), G_CALLBACK (_action_find_activate) },
{ "FindNext", GTK_STOCK_GO_FORWARD,
N_("Find _Next"), "g",
@@ -5143,15 +5111,12 @@ static const GtkActionEntry entries[] =
{ "SourceView", NULL,
N_("View So_urce"), "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) },
@@ -5164,7 +5129,6 @@ static const GtkActionEntry entries[] =
{ "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,
@@ -5211,12 +5175,10 @@ static const GtkActionEntry entries[] =
N_("_Clear Private Data"), "Delete",
N_("Clear private data..."),
G_CALLBACK (_action_clear_private_data_activate) },
- #if WEBKIT_CHECK_VERSION (1, 1, 17)
{ "InspectPage", NULL,
N_("_Inspect Page"), "i",
N_("Inspect page details and access developer tools..."),
G_CALLBACK (_action_inspect_page_activate) },
- #endif
{ "TabPrevious", GTK_STOCK_GO_BACK,
N_("_Previous Tab"), "Page_Up",
@@ -5449,11 +5411,9 @@ static const gchar* ui_markup =
" "
""
""
- #if WEBKIT_CHECK_VERSION (1, 1, 14)
" "
" "
" "
- #endif
" "
" "
" "
@@ -5543,9 +5503,7 @@ static const gchar* ui_markup =
" "
" "
" "
- #if WEBKIT_CHECK_VERSION (1, 1, 6)
" "
- #endif
" "
""
""
@@ -5798,7 +5756,6 @@ midori_browser_init (MidoriBrowser* browser)
G_CALLBACK (midori_browser_destroy_cb), NULL);
gtk_window_set_role (GTK_WINDOW (browser), "browser");
gtk_window_set_icon_name (GTK_WINDOW (browser), "web-browser");
- gtk_window_set_title (GTK_WINDOW (browser), g_get_application_name ());
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (browser), vbox);
gtk_widget_show (vbox);
@@ -6027,9 +5984,6 @@ midori_browser_init (MidoriBrowser* browser)
#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)
@@ -6110,8 +6064,6 @@ midori_browser_init (MidoriBrowser* browser)
midori_panel_notify_page_cb, browser,
"signal::notify::show-titles",
midori_panel_notify_show_titles_cb, browser,
- "signal::notify::show-controls",
- midori_panel_notify_show_controls_cb, browser,
"signal::notify::right-aligned",
midori_panel_notify_right_aligned_cb, browser,
"signal::close",
@@ -6351,7 +6303,7 @@ _midori_browser_update_settings (MidoriBrowser* browser)
{
gboolean remember_last_window_size;
MidoriWindowState last_window_state;
- gboolean compact_sidepanel, show_panel_controls;
+ gboolean compact_sidepanel;
gboolean right_align_sidepanel, open_panels_in_windows;
gint last_panel_position, last_panel_page;
gboolean show_menubar, show_bookmarkbar;
@@ -6370,7 +6322,6 @@ _midori_browser_update_settings (MidoriBrowser* browser)
"last-window-height", &browser->last_window_height,
"last-window-state", &last_window_state,
"compact-sidepanel", &compact_sidepanel,
- "show-panel-controls", &show_panel_controls,
"right-align-sidepanel", &right_align_sidepanel,
"open-panels-in-windows", &open_panels_in_windows,
"last-panel-position", &last_panel_position,
@@ -6444,7 +6395,6 @@ _midori_browser_update_settings (MidoriBrowser* browser)
}
g_object_set (browser->panel, "show-titles", !compact_sidepanel,
- "show-controls", show_panel_controls,
"right-aligned", right_align_sidepanel,
"open-panels-in-windows", open_panels_in_windows, NULL);
gtk_paned_set_position (GTK_PANED (gtk_widget_get_parent (browser->panel)),
@@ -6492,15 +6442,6 @@ midori_browser_settings_notify (MidoriWebSettings* web_settings,
g_signal_handlers_unblock_by_func (browser->panel,
midori_panel_notify_show_titles_cb, browser);
}
- else if (name == g_intern_string ("show-panel-controls"))
- {
- g_signal_handlers_block_by_func (browser->panel,
- midori_panel_notify_show_controls_cb, browser);
- g_object_set (browser->panel, "show-controls",
- g_value_get_boolean (&value), NULL);
- g_signal_handlers_unblock_by_func (browser->panel,
- midori_panel_notify_show_controls_cb, browser);
- }
else if (name == g_intern_string ("open-panels-in-windows"))
g_object_set (browser->panel, "open-panels-in-windows",
g_value_get_boolean (&value), NULL);
@@ -6512,21 +6453,12 @@ midori_browser_settings_notify (MidoriWebSettings* web_settings,
browser->show_navigationbar = g_value_get_boolean (&value);
else if (name == g_intern_string ("show-statusbar"))
browser->show_statusbar = g_value_get_boolean (&value);
- else if (name == g_intern_string ("search-engines-in-completion"))
- {
- if (g_value_get_boolean (&value))
- midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
- _action_by_name (browser, "Location")), browser->search_engines);
- else
- midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
- _action_by_name (browser, "Location")), NULL);
- }
else if (name == g_intern_string ("location-entry-search"))
{
katze_assign (browser->location_entry_search, g_value_dup_string (&value));
}
else if (name == g_intern_string ("maximum-history-age"))
- browser->maximum_history_age = g_value_get_boolean (&value);
+ browser->maximum_history_age = g_value_get_int (&value);
else if (name == g_intern_string ("news-aggregator"))
{
katze_assign (browser->news_aggregator, g_value_dup_string (&value));
@@ -6762,13 +6694,8 @@ midori_browser_set_property (GObject* object,
{
/* FIXME: Disconnect handlers */
katze_object_assign (browser->search_engines, g_value_dup_object (value));
- if (katze_object_get_boolean (browser->settings,
- "search-engines-in-completion"))
- midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
- _action_by_name (browser, "Location")), browser->search_engines);
- else
- midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
- _action_by_name (browser, "Location")), NULL);
+ midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
+ _action_by_name (browser, "Location")), browser->search_engines);
midori_search_action_set_search_engines (MIDORI_SEARCH_ACTION (
_action_by_name (browser, "Search")), browser->search_engines);
/* FIXME: Connect to updates */
@@ -6919,6 +6846,10 @@ midori_browser_add_tab (MidoriBrowser* browser,
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
g_return_val_if_fail (GTK_IS_WIDGET (view), -1);
+ if (!g_object_get_data (G_OBJECT (webkit_get_default_session ()),
+ "midori-session-initialized"))
+ g_critical ("midori_load_soup_session was not called!");
+
g_signal_emit (browser, signals[ADD_TAB], 0, view);
return gtk_notebook_page_num (GTK_NOTEBOOK (browser->notebook), view);
}
diff --git a/midori/midori-extension.c b/midori/midori-extension.c
index cd96ec1c..4eb83ef7 100644
--- a/midori/midori-extension.c
+++ b/midori/midori-extension.c
@@ -137,6 +137,7 @@ enum
enum {
ACTIVATE,
DEACTIVATE,
+ OPEN_PREFERENCES,
LAST_SIGNAL
};
@@ -186,6 +187,24 @@ midori_extension_class_init (MidoriExtensionClass* class)
G_TYPE_NONE, 0,
G_TYPE_NONE);
+ /**
+ * MidoriExtension::open-preferences:
+ *
+ * The preferences of the extension should be opened.
+ *
+ * Since: 0.4.0
+ */
+ signals[OPEN_PREFERENCES] = g_signal_new (
+ "open-preferences",
+ G_TYPE_FROM_CLASS (class),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ 0,
+ 0,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0,
+ G_TYPE_NONE);
+
gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = midori_extension_finalize;
gobject_class->set_property = midori_extension_set_property;
@@ -468,6 +487,22 @@ midori_extension_is_prepared (MidoriExtension* extension)
return FALSE;
}
+/**
+ * midori_extension_has_preferences:
+ * @extension: a #MidoriExtension
+ *
+ * Determines if @extension has preferences.
+ *
+ * Return value: %TRUE if @extension has preferences
+ **/
+gboolean
+midori_extension_has_preferences (MidoriExtension* extension)
+{
+ g_return_val_if_fail (MIDORI_IS_EXTENSION (extension), FALSE);
+
+ return g_signal_has_handler_pending (extension, signals[OPEN_PREFERENCES], 0, FALSE);
+}
+
/**
* midori_extension_is_active:
* @extension: a #MidoriExtension
diff --git a/midori/midori-extension.h b/midori/midori-extension.h
index 9fceb982..fe74d00f 100644
--- a/midori/midori-extension.h
+++ b/midori/midori-extension.h
@@ -51,6 +51,9 @@ midori_extension_get_type (void) G_GNUC_CONST;
gboolean
midori_extension_is_prepared (MidoriExtension* extension);
+gboolean
+midori_extension_has_preferences (MidoriExtension* extension);
+
gboolean
midori_extension_is_active (MidoriExtension* extension);
diff --git a/midori/midori-extensions-column.vala b/midori/midori-extensions-column.vala
new file mode 100644
index 00000000..76b4ff9a
--- /dev/null
+++ b/midori/midori-extensions-column.vala
@@ -0,0 +1,4 @@
+
+public class Midori.ExtensionsCoumn : Gtk.TreeViewColumn {
+ public signal void row_clicked (Gtk.TreeView view, Gtk.TreePath path);
+}
diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c
index 968af2f8..e7225cef 100644
--- a/midori/midori-locationaction.c
+++ b/midori/midori-locationaction.c
@@ -364,6 +364,10 @@ midori_location_action_popup_timeout_cb (gpointer data)
{
sqlite3* db;
db = g_object_get_data (G_OBJECT (action->history), "db");
+
+ if (!db)
+ return FALSE;
+
sqlcmd = "SELECT type, uri, title FROM ("
" SELECT 1 AS type, uri, title, count() AS ct FROM history "
" WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri "
diff --git a/midori/midori-panel.c b/midori/midori-panel.c
index 1e73c07a..a7abc81a 100644
--- a/midori/midori-panel.c
+++ b/midori/midori-panel.c
@@ -588,12 +588,29 @@ static void
midori_panel_viewable_destroy_cb (GtkWidget* viewable,
MidoriPanel* panel)
{
- gint i = gtk_notebook_page_num (GTK_NOTEBOOK (panel->notebook),
+ gint n_pages;
+ gchar* action_name;
+ GtkAction* action;
+ gint i;
+
+ i = gtk_notebook_page_num (GTK_NOTEBOOK (panel->notebook),
g_object_get_data (G_OBJECT (viewable), "parent"));
if (i > -1)
gtk_notebook_remove_page (GTK_NOTEBOOK (panel->notebook), i);
g_signal_handlers_disconnect_by_func (
viewable, midori_panel_viewable_destroy_cb, panel);
+
+ n_pages = midori_panel_get_n_pages (panel);
+ if (n_pages > 0)
+ midori_panel_set_current_page (panel, (n_pages-1 > i) ? i : n_pages - 1);
+
+ action_name = g_strconcat ("PanelPage",
+ midori_viewable_get_stock_id (MIDORI_VIEWABLE (viewable)), NULL);
+ action = gtk_action_group_get_action (panel->action_group, action_name);
+ g_free (action_name);
+
+ gtk_action_group_remove_action (panel->action_group, action);
+ g_object_unref (G_OBJECT (action));
}
static GtkToolItem*
diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c
index 01f9d985..5cba2c9c 100644
--- a/midori/midori-preferences.c
+++ b/midori/midori-preferences.c
@@ -316,10 +316,10 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
}
/* Page "Appearance" */
- PAGE_NEW (GTK_STOCK_SELECT_FONT, _("Appearance"));
+ PAGE_NEW (GTK_STOCK_SELECT_FONT, _("Fonts"));
FRAME_NEW (NULL);
#if !HAVE_HILDON
- label = gtk_label_new (_("Default Font Family"));
+ label = gtk_label_new (_("Proportional Font Family"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
INDENTED_ADD (label);
button = katze_property_proxy (settings, "default-font-family", "font");
@@ -355,13 +355,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
#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);
@@ -370,22 +364,16 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
#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 ?
GTK_WIDGET (parent) : GTK_WIDGET (preferences)))
button = katze_property_proxy (settings, "kinetic-scrolling", NULL);
- #else
- button = katze_property_proxy (settings, "middle-click-opens-selection", NULL);
- #endif
- if (button != NULL)
- INDENTED_ADD (button);
+ else
+ button = katze_property_proxy (settings, "middle-click-opens-selection", NULL);
+ INDENTED_ADD (button);
FRAME_NEW (NULL);
button = katze_property_label (settings, "preferred-languages");
INDENTED_ADD (button);
@@ -425,7 +413,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
button = katze_property_proxy (settings, "open-tabs-in-the-background", NULL);
SPANNED_ADD (button);
#if !HAVE_HILDON
- FRAME_NEW (NULL);
+ INDENTED_ADD (gtk_label_new (NULL));
label = katze_property_label (settings, "text-editor");
INDENTED_ADD (label);
entry = katze_property_proxy (settings, "text-editor", "application-text/plain");
diff --git a/midori/midori-searchaction.c b/midori/midori-searchaction.c
index 4aa1bb7a..1641afdc 100644
--- a/midori/midori-searchaction.c
+++ b/midori/midori-searchaction.c
@@ -967,7 +967,12 @@ midori_search_action_get_editor (MidoriSearchAction* search_action,
label = gtk_label_new_with_mnemonic (_("_Address:"));
gtk_size_group_add_widget (sizegroup, label);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- entry_uri = gtk_entry_new ();
+ entry_uri = katze_uri_entry_new (
+ #if GTK_CHECK_VERSION (2, 20, 0)
+ gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT));
+ #else
+ NULL);
+ #endif
gtk_entry_set_activates_default (GTK_ENTRY (entry_uri), TRUE);
if (!new_engine)
gtk_entry_set_text (GTK_ENTRY (entry_uri)
diff --git a/midori/midori-view.c b/midori/midori-view.c
index a77f2fda..b0b163ae 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -41,11 +41,6 @@
/* This is unstable API, so we need to declare it */
gchar*
webkit_web_view_get_selected_text (WebKitWebView* web_view);
-/* This is public API since WebKitGTK+ 1.1.6 */
-#if !WEBKIT_CHECK_VERSION (1, 1, 6)
-void
-webkit_web_frame_print (WebKitWebFrame* web_frame);
-#endif
static void
midori_view_construct_web_view (MidoriView* view);
@@ -775,16 +770,6 @@ midori_view_update_icon (MidoriView* view,
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;
@@ -806,20 +791,19 @@ katze_net_icon_status_cb (KatzeNetRequest* request,
{
switch (request->status)
{
- case KATZE_NET_VERIFIED:
- if (request->mime_type && strncmp (request->mime_type, "image/", 6))
- {
+ 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;
- }
- break;
- case KATZE_NET_MOVED:
- break;
- default:
- katze_net_icon_priv_free (priv);
- return FALSE;
}
-
return TRUE;
}
@@ -842,40 +826,41 @@ katze_net_icon_transfer_cb (KatzeNetRequest* request,
{
if ((fp = fopen (priv->icon_file, "wb")))
{
- ret = fwrite (request->data, 1, request->length, fp);
+ ret = fwrite (request->data, 1, request->length, fp);
fclose (fp);
- if ((ret - request->length) != 0)
+ if ((ret - request->length != 0))
{
g_warning ("Error writing to file %s "
- "in katze_net_icon_transfer_cb()", priv->icon_file);
+ "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);
+ 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);
+ g_strdup (priv->icon_file), pixbuf);
}
if (!pixbuf)
{
- midori_view_icon_cb (NULL, priv->view);
+ midori_view_update_icon (priv->view, NULL);
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);
+ 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);
+ midori_view_update_icon (priv->view, pixbuf_scaled);
katze_net_icon_priv_free (priv);
}
@@ -883,7 +868,6 @@ static void
_midori_web_view_load_icon (MidoriView* view)
{
GdkPixbuf* pixbuf;
- KatzeNetIconPriv* priv;
gchar* icon_uri;
gchar* icon_file;
gint icon_width, icon_height;
@@ -929,6 +913,8 @@ _midori_web_view_load_icon (MidoriView* view)
}
else if (!view->special)
{
+ KatzeNetIconPriv* priv;
+
priv = g_slice_new (KatzeNetIconPriv);
priv->icon_file = icon_file;
priv->icon_uri = icon_uri;
@@ -983,7 +969,7 @@ midori_view_web_view_navigation_decision_cb (WebKitWebView* web_view
JSContextRef js_context;
gchar* result;
const gchar* uri = webkit_network_request_get_uri (request);
- if (g_str_has_prefix (uri, "geo:"))
+ if (g_str_has_prefix (uri, "geo:") && strstr (uri, ","))
{
gchar* new_uri = sokoke_magic_uri (uri);
midori_view_set_uri (view, new_uri);
@@ -1076,7 +1062,7 @@ webkit_web_view_load_committed_cb (WebKitWebView* web_view,
if (!strncmp (uri, "https", 5))
{
- #if WEBKIT_CHECK_VERSION (1, 1, 14) && defined (HAVE_LIBSOUP_2_29_91)
+ #if defined (HAVE_LIBSOUP_2_29_91)
WebKitWebDataSource *source;
WebKitNetworkRequest *request;
SoupMessage *message;
@@ -1112,7 +1098,6 @@ webkit_web_view_progress_changed_cb (WebKitWebView* web_view,
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,
@@ -1139,15 +1124,6 @@ midori_view_web_view_resource_request_cb (WebKitWebView* web_view,
webkit_network_request_set_uri (request, file_uri);
g_free (file_uri);
}
- else if (g_str_has_prefix (uri, "thumb://"))
- {
- gchar* file_path = g_build_filename (g_get_user_cache_dir (), "midori", "thumbnails",
- g_strdup (uri + 8), NULL);
- gchar* file_uri = g_filename_to_uri (file_path, NULL, NULL);
- webkit_network_request_set_uri (request, file_uri);
- g_free (file_uri);
- g_free (file_path);
- }
else if (g_str_has_prefix (uri, "stock://"))
{
GdkPixbuf* pixbuf;
@@ -1229,7 +1205,6 @@ midori_view_web_view_resource_request_cb (WebKitWebView* web_view,
}
}
}
-#endif
#define HAVE_GTK_INFO_BAR GTK_CHECK_VERSION (2, 18, 0)
@@ -1339,6 +1314,7 @@ midori_view_add_info_bar (MidoriView* view,
va_end (args);
label = gtk_label_new (message);
+ gtk_label_set_selectable (GTK_LABEL (label), TRUE);
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_container_add (GTK_CONTAINER (content_area), label);
gtk_widget_show_all (infobar);
@@ -1348,7 +1324,6 @@ midori_view_add_info_bar (MidoriView* view,
return infobar;
}
-#if WEBKIT_CHECK_VERSION (1, 1, 14)
static void
midori_view_database_response_cb (GtkWidget* infobar,
gint response,
@@ -1379,7 +1354,6 @@ midori_view_web_view_database_quota_exceeded_cb (WebKitWebView* web_view,
NULL);
g_free (message);
}
-#endif
#if WEBKIT_CHECK_VERSION (1, 1, 23)
static void
@@ -1423,19 +1397,10 @@ midori_view_load_alternate_string (MidoriView* view,
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,
@@ -1452,24 +1417,13 @@ midori_view_display_error (MidoriView* view,
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,
@@ -1479,6 +1433,7 @@ midori_view_display_error (MidoriView* view,
"{tryagain}", try_again,
"{res}", res_root,
"{stock}", stock_root,
+ "{uri}", uri,
NULL);
g_free (title_escaped);
g_free (template);
@@ -1527,44 +1482,6 @@ webkit_web_view_load_error_cb (WebKitWebView* web_view,
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 (
- "%s "
- "%s "
- " "
- "
The page you were opening doesn't exist."
- "
Try to load the page again , "
- "or move on to another page."
- "",
- 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)
@@ -1670,7 +1587,6 @@ midori_web_view_notify_icon_uri_cb (WebKitWebView* web_view,
}
#endif
-#if WEBKIT_CHECK_VERSION (1, 1, 4)
static void
webkit_web_view_notify_uri_cb (WebKitWebView* web_view,
GParamSpec* pspec,
@@ -1689,16 +1605,6 @@ webkit_web_view_notify_title_cb (WebKitWebView* web_view,
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,
@@ -1746,7 +1652,6 @@ midori_view_ensure_link_uri (MidoriView* view,
{
g_return_if_fail (MIDORI_IS_VIEW (view));
- #if WEBKIT_CHECK_VERSION (1, 1, 15)
if (view->web_view && gtk_widget_get_window (view->web_view))
{
GdkEventButton ev;
@@ -1771,7 +1676,6 @@ midori_view_ensure_link_uri (MidoriView* view,
katze_assign (view->link_uri,
katze_object_get_string (view->hit_test, "link-uri"));
}
- #endif
}
#define MIDORI_KEYS_MODIFIER_MASK (GDK_SHIFT_MASK | GDK_CONTROL_MASK \
@@ -1831,7 +1735,6 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
else if (view->middle_click_opens_selection)
{
gboolean is_editable;
- #if WEBKIT_CHECK_VERSION (1, 1, 15)
WebKitHitTestResult* result;
WebKitHitTestResultContext context;
@@ -1839,9 +1742,6 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
context = katze_object_get_int (result, "context");
is_editable = context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
g_object_unref (result);
- #else
- is_editable = webkit_web_view_can_paste_clipboard (WEBKIT_WEB_VIEW (view->web_view));
- #endif
if (is_editable)
return FALSE;
@@ -1892,7 +1792,6 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
}
}
break;
- #if WEBKIT_CHECK_VERSION (1, 1, 15)
case 3:
if (event->state & GDK_CONTROL_MASK)
{
@@ -1904,7 +1803,6 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
return TRUE;
}
break;
- #endif
case 8:
midori_view_go_back (view);
return TRUE;
@@ -2085,17 +1983,16 @@ gtk_widget_scroll_event_cb (WebKitWebView* web_view,
{
if (event->direction == GDK_SCROLL_DOWN)
midori_view_set_zoom_level (view,
- midori_view_get_zoom_level (view) - 0.25f);
+ midori_view_get_zoom_level (view) - 0.10f);
else if(event->direction == GDK_SCROLL_UP)
midori_view_set_zoom_level (view,
- midori_view_get_zoom_level (view) + 0.25f);
+ midori_view_get_zoom_level (view) + 0.10f);
return TRUE;
}
else
return FALSE;
}
-#if WEBKIT_CHECK_VERSION (1, 1, 15)
static void
midori_web_view_menu_new_window_activate_cb (GtkWidget* widget,
MidoriView* view)
@@ -2187,7 +2084,6 @@ midori_web_view_menu_video_save_activate_cb (GtkWidget* widget,
g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled);
g_free (uri);
}
-#endif
static void
midori_web_view_menu_new_tab_activate_cb (GtkWidget* widget,
@@ -2218,7 +2114,6 @@ midori_web_view_menu_new_tab_activate_cb (GtkWidget* widget,
}
}
-#if WEBKIT_CHECK_VERSION (1, 1, 15)
static void
midori_web_view_menu_background_tab_activate_cb (GtkWidget* widget,
MidoriView* view)
@@ -2226,7 +2121,6 @@ midori_web_view_menu_background_tab_activate_cb (GtkWidget* widget,
g_signal_emit (view, signals[NEW_TAB], 0, view->link_uri,
!view->open_tabs_in_the_background);
}
-#endif
static void
midori_web_view_menu_search_web_activate_cb (GtkWidget* widget,
@@ -2249,23 +2143,12 @@ midori_web_view_menu_search_web_activate_cb (GtkWidget* widget,
g_free (uri);
}
-#if WEBKIT_CHECK_VERSION (1, 1, 15)
static void
midori_web_view_menu_copy_activate_cb (GtkWidget* widget,
MidoriView* view)
{
sokoke_widget_copy_clipboard (widget, view->selected_text);
}
-#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,
@@ -2275,7 +2158,6 @@ midori_view_tab_label_menu_window_new_cb (GtkWidget* menuitem,
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)
@@ -2289,7 +2171,6 @@ midori_web_view_menu_inspect_element_activate_cb (GtkWidget* widget,
webkit_web_inspector_inspect_coordinates (inspector, x, y);
webkit_web_inspector_show (inspector);
}
-#endif
static GtkWidget*
midori_view_insert_menu_item (GtkMenuShell* menu,
@@ -2364,7 +2245,6 @@ midori_view_populate_popup (MidoriView* view,
GtkWidget* label;
guint i;
- #if WEBKIT_CHECK_VERSION (1, 1, 15)
gint x, y;
WebKitHitTestResultContext context;
gboolean is_image;
@@ -2379,42 +2259,9 @@ midori_view_populate_popup (MidoriView* view,
is_image = context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE;
is_media = context & WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA;
is_document = !view->link_uri && !has_selection && !is_image && !is_media;
- #else
- /* There is no guarantee view->link_uri is correct in case
- gtk-touchscreen-mode is enabled, nothing we can do. */
- has_selection = midori_view_has_selection (view);
- is_document = !view->link_uri && !has_selection;
-
- /* Unfortunately inspecting the menu is the only way to
- determine that the mouse is over a text area or selection. */
- items = gtk_container_get_children (GTK_CONTAINER (menu));
- menuitem = (GtkWidget*)g_list_nth_data (items, 0);
- if (GTK_IS_IMAGE_MENU_ITEM (menuitem))
- {
- icon = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (menuitem));
- gtk_image_get_stock (GTK_IMAGE (icon), &stock_id, NULL);
- if (!strcmp (stock_id, GTK_STOCK_FIND))
- {
- gtk_widget_hide (menuitem);
- gtk_widget_set_no_show_all (menuitem, TRUE);
- menuitem = (GtkWidget*)g_list_nth_data (items, 1);
- gtk_widget_hide (menuitem);
- menuitem = (GtkWidget*)g_list_nth_data (items, 2);
- icon = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (menuitem));
- gtk_image_get_stock (GTK_IMAGE (icon), &stock_id, NULL);
- }
- is_editable = !strcmp (stock_id, GTK_STOCK_CUT);
- if (is_document && !strcmp (stock_id, GTK_STOCK_OPEN))
- is_document = FALSE;
- }
- else
- is_editable = FALSE;
- g_list_free (items);
- #endif
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);
@@ -2428,7 +2275,6 @@ midori_view_populate_popup (MidoriView* view,
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 (
@@ -2458,7 +2304,6 @@ midori_view_populate_popup (MidoriView* view,
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 ();
@@ -2472,7 +2317,6 @@ midori_view_populate_popup (MidoriView* view,
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;
}
@@ -2505,7 +2349,6 @@ midori_view_populate_popup (MidoriView* view,
}
}
- #if WEBKIT_CHECK_VERSION (1, 1, 15)
if (!is_document)
{
items = gtk_container_get_children (GTK_CONTAINER (menu));
@@ -2569,40 +2412,6 @@ midori_view_populate_popup (MidoriView* view,
midori_view_insert_menu_item (menu_shell, -1, NULL, GTK_STOCK_COPY,
G_CALLBACK (midori_web_view_menu_copy_activate_cb), widget);
}
- #else
- if (view->link_uri)
- {
- items = gtk_container_get_children (GTK_CONTAINER (menu));
- menuitem = (GtkWidget*)g_list_nth_data (items, 0);
- /* hack to hide menu item */
- gtk_widget_hide (menuitem);
- midori_view_insert_menu_item (menu_shell, 1,
- _("Open Link in New _Tab"), STOCK_TAB_NEW,
- G_CALLBACK (midori_web_view_menu_new_tab_activate_cb), widget);
- g_list_free (items);
- items = gtk_container_get_children (GTK_CONTAINER (menu));
- menuitem = (GtkWidget*)g_list_nth_data (items, 2);
- /* hack to localize menu item */
- label = gtk_bin_get_child (GTK_BIN (menuitem));
- 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 (!view->link_uri && has_selection)
{
@@ -2652,21 +2461,9 @@ midori_view_populate_popup (MidoriView* view,
}
g_object_unref (search_engines);
}
- #if WEBKIT_CHECK_VERSION (1, 1, 15)
midori_view_insert_menu_item (menu_shell, 0,
_("_Search the Web"), GTK_STOCK_FIND,
G_CALLBACK (midori_web_view_menu_search_web_activate_cb), widget);
- #else
- items = gtk_container_get_children (GTK_CONTAINER (menu));
- menuitem = (GtkWidget*)g_list_nth_data (items, 0);
- /* hack to localize menu item */
- label = gtk_bin_get_child (GTK_BIN (menuitem));
- gtk_label_set_label (GTK_LABEL (label), _("_Search the Web"));
- /* hack to implement Search the Web */
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (midori_web_view_menu_search_web_activate_cb), view);
- g_list_free (items);
- #endif
g_strstrip (view->selected_text);
if (view->selected_text && !strchr (view->selected_text, ' ')
@@ -2738,18 +2535,6 @@ midori_view_populate_popup (MidoriView* view,
g_signal_connect (menuitem, "activate",
G_CALLBACK (midori_view_tab_label_menu_window_new_cb), view);
- #if WEBKIT_CHECK_VERSION (1, 1, 15)
- /* if (webkit_web_view_get_main_frame (web_view) != frame_under_mouse)
- {
- midori_view_insert_menu_item (menu_shell, -1,
- _("Open _Frame in New Tab"), NULL,
- G_CALLBACK (midori_web_view_menu_frame_new_tab_activate_cb), widget);
- midori_view_insert_menu_item (menu_shell, -1,
- _("Open _Frame in New Window"), NULL,
- G_CALLBACK (midori_web_view_menu_frame_new_window_activate_cb), widget);
- } */
- #endif
-
#if !HAVE_HILDON
menuitem = sokoke_action_create_popup_menu_item (
gtk_action_group_get_action (actions, "ZoomIn"));
@@ -2835,7 +2620,6 @@ midori_view_populate_popup (MidoriView* view,
}
}
- #if WEBKIT_CHECK_VERSION (1, 1, 17)
if ((!is_document || manual)
&& katze_object_get_boolean (view->settings, "enable-developer-extras"))
{
@@ -2846,7 +2630,6 @@ midori_view_populate_popup (MidoriView* view,
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);
}
@@ -2939,15 +2722,12 @@ webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,
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)
@@ -2958,16 +2738,12 @@ webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,
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))
@@ -2978,7 +2754,6 @@ webkit_web_view_mime_type_decision_cb (GtkWidget* web_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);
@@ -2987,7 +2762,6 @@ webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,
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"));
@@ -3015,14 +2789,10 @@ webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,
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),
@@ -3087,28 +2857,14 @@ webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,
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);
@@ -3117,7 +2873,6 @@ webkit_web_view_download_requested_cb (GtkWidget* web_view,
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",
@@ -3127,7 +2882,6 @@ webkit_web_view_download_requested_cb (GtkWidget* web_view,
g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled);
return handled;
}
-#endif
static gboolean
webkit_web_view_console_message_cb (GtkWidget* web_view,
@@ -3173,7 +2927,6 @@ midori_view_web_view_script_alert_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,
@@ -3182,7 +2935,6 @@ midori_view_web_view_print_requested_cb (GtkWidget* web_view,
midori_view_print (view);
return TRUE;
}
-#endif
static void
webkit_web_view_window_object_cleared_cb (GtkWidget* web_view,
@@ -3191,7 +2943,6 @@ 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 */
@@ -3207,7 +2958,6 @@ webkit_web_view_window_object_cleared_cb (GtkWidget* web_view,
NULL);
g_free (result);
}
- #endif
g_signal_emit (view, signals[CONTEXT_READY], 0, js_context);
}
@@ -3283,9 +3033,7 @@ midori_view_init (MidoriView* view)
view->load_status = MIDORI_LOAD_FINISHED;
view->minimized = FALSE;
view->statusbar_text = NULL;
- #if WEBKIT_CHECK_VERSION (1, 1, 15)
view->hit_test = NULL;
- #endif
view->link_uri = NULL;
view->selected_text = NULL;
view->news_feeds = katze_array_new (KATZE_TYPE_ITEM);
@@ -3753,7 +3501,6 @@ midori_view_web_inspector_close_window_cb (gpointer inspector,
static void
midori_view_construct_web_view (MidoriView* view)
{
- WebKitWebFrame* web_frame;
gpointer inspector;
g_return_if_fail (!view->web_view);
@@ -3762,7 +3509,6 @@ midori_view_construct_web_view (MidoriView* view)
/* Load something to avoid a bug where WebKit might not set a main frame */
webkit_web_view_open (WEBKIT_WEB_VIEW (view->web_view), "");
- web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
#if HAVE_HILDON
gtk_widget_tap_and_hold_setup (view->web_view, NULL, NULL, 0);
@@ -3773,14 +3519,10 @@ midori_view_construct_web_view (MidoriView* view)
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,
@@ -3797,15 +3539,10 @@ midori_view_construct_web_view (MidoriView* 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",
@@ -3830,27 +3567,14 @@ midori_view_construct_web_view (MidoriView* view)
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)
{
g_object_set (view->web_view, "settings", view->settings,
@@ -3939,14 +3663,53 @@ prepare_speed_dial_html (MidoriView* view)
{
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));
GKeyFile* key_file;
- GString* markup = g_string_new (NULL);
+ GString* markup = NULL;
guint rows, cols, slot = 1;
gchar* thumb_size_type;
+ gchar* speed_dial_head;
+ gchar* file_path;
+ gchar* file_name;
guint thumb_size = 160;
g_object_get (browser, "speed-dial", &key_file, NULL);
if (!key_file)
- return g_string_free (markup, FALSE);
+ return g_strdup ("");
+
+ file_name = g_build_filename ("midori", "res", "speeddial-head.html", NULL);
+ file_path = sokoke_find_data_filename (file_name);
+ g_free (file_name);
+
+ if (g_access (file_path, F_OK) == 0
+ && g_file_get_contents (file_path, &speed_dial_head, NULL, NULL))
+ {
+ gchar* header = sokoke_replace_variables (speed_dial_head,
+ "{res}", "res:/",
+ "{stock}", "stock:/",
+ "{title}", _("Speed Dial"),
+ "{click_to_add}", _("Click to add a shortcut"),
+ "{enter_shortcut_address}", _("Enter shortcut address"),
+ "{enter_shortcut_name}", _("Enter shortcut title"),
+ "{are_you_sure}", _("Are you sure you want to delete this shortcut?"),
+ "{set_dial_size}", _("Set number of columns and rows"),
+ "{enter_dial_size}", _("Enter number of columns and rows:"),
+ "{invalid_dial_size}", _("Invalid input for the size of the speed dial"),
+ "{set_thumb_size}", _("Thumb size:"),
+ "{set_thumb_small}", _("Small"),
+ "{set_thumb_normal}", _("Medium"),
+ "{set_thumb_big}", _("Big"), NULL);
+
+ markup = g_string_new (header);
+
+ g_free (speed_dial_head);
+ g_free (file_path);
+ g_free (header);
+ }
+ else
+ {
+ g_free (file_path);
+ return g_strdup ("");
+ }
+
rows = g_key_file_get_integer (key_file, "settings", "rows", NULL);
cols = g_key_file_get_integer (key_file, "settings", "columns", NULL);
thumb_size_type = g_key_file_get_string (key_file, "settings", "size", NULL);
@@ -4091,16 +3854,6 @@ midori_view_set_uri (MidoriView* view,
{
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;
- gchar* speed_dial_markup;
- gchar* stock_root;
- gchar* filepath;
#ifdef G_ENABLE_DEBUG
GTimer* timer = NULL;
@@ -4111,37 +3864,7 @@ midori_view_set_uri (MidoriView* view,
katze_assign (view->uri, g_strdup (""));
katze_item_set_uri (view->item, "");
- filepath = sokoke_find_data_filename ("midori/res/speeddial-head.html");
- g_file_get_contents (filepath, &speed_dial_head, NULL, NULL);
- g_free (filepath);
- 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,
- "{stock}", stock_root,
- "{title}", _("Speed Dial"),
- "{click_to_add}", _("Click to add a shortcut"),
- "{enter_shortcut_address}", _("Enter shortcut address"),
- "{enter_shortcut_name}", _("Enter shortcut title"),
- "{are_you_sure}", _("Are you sure you want to delete this shortcut?"),
- "{set_dial_size}", _("Set number of columns and rows"),
- "{enter_dial_size}", _("Enter number of columns and rows:"),
- "{invalid_dial_size}", _("Invalid input for the size of the speed dial"),
- "{set_thumb_size}", _("Thumb size:"),
- "{set_thumb_small}", _("Small"),
- "{set_thumb_normal}", _("Medium"),
- "{set_thumb_big}", _("Big"), NULL);
+ data = prepare_speed_dial_html (view);
#ifdef G_ENABLE_DEBUG
if (g_getenv ("MIDORI_STARTTIME") != NULL)
@@ -4150,49 +3873,15 @@ midori_view_set_uri (MidoriView* view,
g_timer_destroy (timer);
}
#endif
-
- speed_dial_body = prepare_speed_dial_html (view);
- speed_dial_markup = g_strdup_printf ("%s\n%s", data, speed_dial_body);
-
midori_view_load_alternate_string (view,
- speed_dial_markup, res_root, "about:blank", NULL);
-
- g_free (res_root);
- g_free (stock_root);
+ data, "res:/", "about:blank", NULL);
g_free (data);
- g_free (speed_dial_head);
- g_free (speed_dial_body);
- g_free (speed_dial_markup);
}
/* This is not prefectly elegant, but creating
special pages inline is the simplest solution. */
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 (
- "%s "
- "%s "
- " "
- "
The document %s of type '%s' cannot be displayed."
- "",
- 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;
@@ -4209,10 +3898,11 @@ midori_view_set_uri (MidoriView* view,
"%s "
" "
- "
There is no documentation installed at %s."
+ "
There is no documentation installed at %s. "
"You may want to ask your distribution or "
"package maintainer for it or if this a custom build "
- "verify that the build is setup properly."
+ "verify that the build is setup properly. "
+ "View the FAQ online "
"