Merge branch 'upstream-unstable'

This commit is contained in:
Yves-Alexis Perez 2011-08-02 07:43:10 +02:00
commit 459dd9dffe
60 changed files with 20903 additions and 20191 deletions

View file

@ -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

4
README
View file

@ -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.

View file

@ -68,10 +68,12 @@ description {
<h1>{title}</h1>
<p id="message">{message}</p>
<p id="description">{description}</p>
<button onclick="location.reload()">
<img src="{stock}/gtk-refresh"/>
<span>{tryagain}</span>
</button>
<form method="GET" action="{uri}">
<button type="submit" onclick="location.reload(); return false;">
<img src="{stock}/gtk-refresh"/>
<span>{tryagain}</span>
</button>
</form>
</div>
<br style="clear: both;"/>
</div>

View file

@ -5,23 +5,23 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>midori:faq</title>
<meta name="generator" content="DokuWiki" />
<meta name="robots" content="index,follow" />
<meta name="date" content="2011-05-05T22:28:18+0200" />
<meta name="keywords" content="midori,faq" />
<link rel="search" type="application/opensearchdescription+xml" href="/lib/exe/opensearch.php" title="Xfce Wiki" />
<link rel="start" href="/" />
<link rel="contents" href="/midori/faq?do=index" title="Sitemap" />
<link rel="alternate" type="application/rss+xml" title="Recent Changes" href="/feed.php" />
<link rel="alternate" type="application/rss+xml" title="Current Namespace" href="/feed.php?mode=list&amp;ns=midori" />
<link rel="alternate" type="text/html" title="Plain HTML" href="/_export/xhtml/midori/faq" />
<link rel="alternate" type="text/plain" title="Wiki Markup" href="/_export/raw/midori/faq" />
<link rel="canonical" href="http://wiki.xfce.org/midori/faq" />
<meta name="generator" content="DokuWiki"/>
<meta name="robots" content="index,follow"/>
<meta name="date" content="2011-05-05T22:28:18+0200"/>
<meta name="keywords" content="midori,faq"/>
<link rel="search" type="application/opensearchdescription+xml" href="/lib/exe/opensearch.php" title="Xfce Wiki"/>
<link rel="start" href="/"/>
<link rel="contents" href="/midori/faq?do=index" title="Sitemap"/>
<link rel="alternate" type="application/rss+xml" title="Recent Changes" href="/feed.php"/>
<link rel="alternate" type="application/rss+xml" title="Current Namespace" href="/feed.php?mode=list&amp;ns=midori"/>
<link rel="alternate" type="text/html" title="Plain HTML" href="/_export/xhtml/midori/faq"/>
<link rel="alternate" type="text/plain" title="Wiki Markup" href="/_export/raw/midori/faq"/>
<link rel="canonical" href="http://wiki.xfce.org/midori/faq"/>
<link rel="stylesheet" type="text/css" href="faq.css" />
<script type="text/javascript" ><!--//--><![CDATA[//><!--
var NS='midori';var SIG=' --- //[[christian@twotoasts.de|Christian Dywan]] 2011/05/16 01:12//';var JSINFO = {"id":"midori:faq","namespace":"midori"};
<script type="text/javascript"><!--//--><![CDATA[//><!--
var NS='midori';var JSINFO = {"id":"midori:faq","namespace":"midori"};
//--><!]]></script>
<script type="text/javascript" charset="utf-8" src="/lib/exe/js.php?tseed=1305397590" ></script>
<script type="text/javascript" charset="utf-8" src="/lib/exe/js.php?tseed=1306663866"></script>
</head>
<body>
<div class="dokuwiki export">
@ -71,6 +71,9 @@ var NS='midori';var SIG=' --- //[[christian@twotoasts.de|Christian Dywan]] 2011/
<p>
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.
</p>
<p>
This is a snapshot of Frequently Asked Questions designated for offline viewing. The most recent version of this document can be found <a href="http://wiki.xfce.org/midori/faq">in the Xfce wiki</a>.
<p/>
</div>
<!-- EDIT1 SECTION "Midori - Frequently asked questions" [1-289] -->
@ -275,7 +278,7 @@ You need to have GStreamer plugins installed which implement the codecs.
</li>
<li class="level1"><div class="li"> With Arch Linux, you may need to install liboil explicitly if it is not installed already (see <a href="https://bugs.archlinux.org/task/20945" class="urlextern" title="https://bugs.archlinux.org/task/20945" rel="nofollow">this</a> bug report).</div>
</li>
<li class="level1"><div class="li"> You need plugins for Theora, gstreamer0.10-base and <acronym title="Motion Picture Experts Group">MPEG</acronym>-4 incluing aac (e.g. gst-plugins-faad), gstreamer0.10-bad. For WebM, you&#039;ll need plugins for vorbis (-base), matroska (-good), and vp8 (-bad). Have a look at <a href="http://www.gstreamer.net/documentation/plugins.html" class="urlextern" title="http://www.gstreamer.net/documentation/plugins.html" rel="nofollow">http://www.gstreamer.net/documentation/plugins.html</a> for details.</div>
<li class="level1"><div class="li"> You need plugins for Theora, gstreamer0.10-base and <acronym title="Moving Picture Experts Group">MPEG</acronym>-4 incluing aac (e.g. gst-plugins-faad), gstreamer0.10-bad. For WebM, you&#039;ll need plugins for vorbis (-base), matroska (-good), and vp8 (-bad). Have a look at <a href="http://www.gstreamer.net/documentation/plugins.html" class="urlextern" title="http://www.gstreamer.net/documentation/plugins.html" rel="nofollow">http://www.gstreamer.net/documentation/plugins.html</a> for details.</div>
</li>
<li class="level1"><div class="li"> For Youtube or Vimeo, you need WebKitGTK+ 1.1.20 or newer.</div>
</li>

View file

@ -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

View file

@ -20,8 +20,6 @@
#include <unistd.h>
#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, &regex))
while (g_hash_table_iter_next (&iter, &patt, &regex))
{
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 ());

View file

@ -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);

View file

@ -21,36 +21,36 @@
#include <unistd.h>
#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,
</html> */
#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;
}

View file

@ -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<GLib.PtrArray> ("history-list-tab-history");
unowned GLib.PtrArray list_new = this.browser.get_data<GLib.PtrArray> ("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<GLib.PtrArray> ("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<GLib.PtrArray> ("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<Midori.View?> ("history-list-last-change");
if (view != null) {
this.tab_list_resort (browser, view);
browser.set_data<Midori.View?> ("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<GLib.PtrArray> ("history-list-tab-history");
unowned GLib.PtrArray list_new = this.browser.get_data<GLib.PtrArray> ("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<GLib.PtrArray> ("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<GLib.PtrArray> ("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<GLib.PtrArray> ("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<Midori.View?> ("history-list-last-change");
if (view != null) {
this.tab_list_resort (browser, view);
browser.set_data<Midori.View?> ("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, "<Ctrl>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, "<Ctrl>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, "<Ctrl>1");
action.set_accel_group (acg);
action.connect_accelerator ();
browser.set_data<ulong> ("history-list-sid-tab-next", sidTabNext);
browser.set_data<ulong> ("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, "<Ctrl>2");
action.set_accel_group (acg);
action.connect_accelerator ();
browser.set_data<GLib.PtrArray*> ("history-list-tab-history",
new GLib.PtrArray ());
browser.set_data<GLib.PtrArray*> ("history-list-tab-history-new",
new GLib.PtrArray ());
browser.set_data<Midori.View?> ("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, "<Ctrl>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<ulong> ("history-list-sid-tab-next");
sidTabPrevious = browser.get_data<ulong> ("history-list-sid-tab-previous");
browser.set_data<ulong> ("history-list-sid-tab-next", sidTabNext);
browser.set_data<ulong> ("history-list-sid-tab-previous", sidTabPrevious);
Gtk.Action action;
Gtk.ActionGroup action_group;
action_group = browser.get_action_group ();
browser.set_data<GLib.PtrArray*> ("history-list-tab-history",
new GLib.PtrArray ());
browser.set_data<GLib.PtrArray*> ("history-list-tab-history-new",
new GLib.PtrArray ());
browser.set_data<Midori.View?> ("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<GLib.PtrArray> ("history-list-tab-history-new");
list.add (view);
}
void tab_removed (Midori.Browser browser, Midori.View view) {
unowned GLib.PtrArray list = browser.get_data<GLib.PtrArray> ("history-list-tab-history");
unowned GLib.PtrArray list_new = browser.get_data<GLib.PtrArray> ("history-list-tab-history-new");
list.remove (view);
list_new.remove (view);
browser.set_data<Midori.View?> ("history-list-last-change", null);
void browser_removed (Midori.Browser browser) {
string[] callbacks = { "HistoryListNextNewTab", "HistoryListPreviousNewTab",
"HistoryListSpecialFunction" };
ulong sidTabNext, sidTabPrevious;
sidTabNext = browser.get_data<ulong> ("history-list-sid-tab-next");
sidTabPrevious = browser.get_data<ulong> ("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<Midori.View?> ("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<GLib.PtrArray> ("history-list-tab-history-new");
list.add (view);
}
void tab_removed (Midori.Browser browser, Midori.View view) {
unowned GLib.PtrArray list = browser.get_data<GLib.PtrArray> ("history-list-tab-history");
unowned GLib.PtrArray list_new = browser.get_data<GLib.PtrArray> ("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<Midori.View?> ("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<Midori.View?> ("history-list-last-change");
if (last_view != null) {
this.tab_list_resort (browser, last_view);
}
browser.set_data<Midori.View?> ("history-list-last-change", view);
}
}
void tab_list_resort (Midori.Browser browser, Midori.View view) {
unowned GLib.PtrArray list = browser.get_data<GLib.PtrArray> ("history-list-tab-history");
unowned GLib.PtrArray list_new = browser.get_data<GLib.PtrArray> ("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 <andre@stoesel.de>");
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<Midori.View?> ("history-list-last-change", view);
}
void tab_list_resort (Midori.Browser browser, Midori.View view) {
unowned GLib.PtrArray list = browser.get_data<GLib.PtrArray> ("history-list-tab-history");
unowned GLib.PtrArray list_new = browser.get_data<GLib.PtrArray> ("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 <andre@stoesel.de>");
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 ();
}

View file

@ -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);

View file

@ -61,6 +61,12 @@
#include <gdk/gdkx.h>
#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 ("<span size=\"smaller\">%s</span>",
@ -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 (&timestamp)),
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);

View file

@ -36,6 +36,10 @@
#include <unistd.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifdef HAVE_HILDON_2_2
#include <dbus/dbus.h>
#include <mce/mode-names.h>
@ -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, "<Ctrl>t",
N_("Open a new tab"), G_CALLBACK (_action_tab_new_activate) },
{ "PrivateBrowsing", NULL,
N_("P_rivate Browsing"), "<Ctrl><Shift>n",
N_("New P_rivate Browsing Window"), "<Ctrl><Shift>n",
N_("Don't save any private data while browsing"),
G_CALLBACK (_action_private_browsing_activate), },
{ "Open", GTK_STOCK_OPEN,
NULL, "<Ctrl>o",
N_("Open a file"), G_CALLBACK (_action_open_activate) },
{ "SaveAs", GTK_STOCK_SAVE_AS,
NULL, "<Ctrl>s",
N_("_Save Page As..."), "<Ctrl>s",
N_("Save to a file"), G_CALLBACK (_action_save_as_activate) },
{ "AddSpeedDial", NULL,
N_("Add to Speed _dial"), "<Ctrl>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, "<Ctrl>z",
N_("Undo the last modification"), G_CALLBACK (_action_undo_activate) },
{ "Redo", GTK_STOCK_REDO,
NULL, "<Ctrl><Shift>z",
N_("Redo the last modification"), G_CALLBACK (_action_redo_activate) },
#endif
{ "Cut", GTK_STOCK_CUT,
NULL, "<Ctrl>x",
N_("Cut the selected text"), G_CALLBACK (_action_cut_activate) },
@ -5103,7 +5071,7 @@ static const GtkActionEntry entries[] =
NULL, "<Ctrl>a",
N_("Select all text"), G_CALLBACK (_action_select_all_activate) },
{ "Find", GTK_STOCK_FIND,
NULL, "<Ctrl>f",
N_("_Find..."), "<Ctrl>f",
N_("Find a word or phrase in the page"), G_CALLBACK (_action_find_activate) },
{ "FindNext", GTK_STOCK_GO_FORWARD,
N_("Find _Next"), "<Ctrl>g",
@ -5143,15 +5111,12 @@ static const GtkActionEntry entries[] =
{ "SourceView", NULL,
N_("View So_urce"), "<Ctrl><Alt>U",
N_("View the source code of the page"), G_CALLBACK (_action_source_view_activate) },
#if WEBKIT_CHECK_VERSION (1, 1, 6)
{ "CaretBrowsing", NULL,
N_("Ca_ret Browsing"), "F7",
N_("Toggle text cursor navigation"), G_CALLBACK (_action_caret_browsing_activate) },
#endif
{ "Fullscreen", GTK_STOCK_FULLSCREEN,
NULL, "F11",
N_("Toggle fullscreen view"), G_CALLBACK (_action_fullscreen_activate) },
#if WEBKIT_CHECK_VERSION (1, 1, 4)
{ "ScrollLeft", NULL,
N_("Scroll _Left"), "h",
N_("Scroll to the left"), G_CALLBACK (_action_scroll_somewhere_activate) },
@ -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"), "<Ctrl><Shift>Delete",
N_("Clear private data..."),
G_CALLBACK (_action_clear_private_data_activate) },
#if WEBKIT_CHECK_VERSION (1, 1, 17)
{ "InspectPage", NULL,
N_("_Inspect Page"), "<Ctrl><Shift>i",
N_("Inspect page details and access developer tools..."),
G_CALLBACK (_action_inspect_page_activate) },
#endif
{ "TabPrevious", GTK_STOCK_GO_BACK,
N_("_Previous Tab"), "<Ctrl>Page_Up",
@ -5449,11 +5411,9 @@ static const gchar* ui_markup =
"<menuitem action='Quit'/>"
"</menu>"
"<menu action='Edit'>"
#if WEBKIT_CHECK_VERSION (1, 1, 14)
"<menuitem action='Undo'/>"
"<menuitem action='Redo'/>"
"<separator/>"
#endif
"<menuitem action='Cut'/>"
"<menuitem action='Copy'/>"
"<menuitem action='Paste'/>"
@ -5543,9 +5503,7 @@ static const gchar* ui_markup =
"<menuitem action='Preferences'/>"
"<menuitem action='InspectPage'/>"
"<menuitem action='ReloadUncached'/>"
#if WEBKIT_CHECK_VERSION (1, 1, 6)
"<menuitem action='CaretBrowsing'/>"
#endif
"</menu>"
"</menubar>"
"<toolbar name='toolbar_navigation'>"
@ -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);
}

View file

@ -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

View file

@ -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);

View file

@ -0,0 +1,4 @@
public class Midori.ExtensionsCoumn : Gtk.TreeViewColumn {
public signal void row_clicked (Gtk.TreeView view, Gtk.TreePath path);
}

View file

@ -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 "

View file

@ -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*

View file

@ -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");

View file

@ -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)

File diff suppressed because it is too large Load diff

View file

@ -39,23 +39,18 @@ struct _MidoriWebSettings
gboolean show_navigationbar : 1;
gboolean show_bookmarkbar : 1;
gboolean show_panel : 1;
gboolean show_transferbar : 1;
gboolean show_statusbar : 1;
MidoriToolbarStyle toolbar_style : 3;
gboolean search_engines_in_completion : 1;
gboolean compact_sidepanel : 1;
gboolean show_panel_controls : 1;
gboolean right_align_sidepanel : 1;
gboolean open_panels_in_windows : 1;
MidoriStartup load_on_startup : 2;
gboolean show_crash_dialog : 1;
gboolean speed_dial_in_new_tabs : 1;
MidoriPreferredEncoding preferred_encoding : 3;
gboolean always_show_tabbar : 1;
gboolean close_buttons_on_tabs : 1;
gint close_buttons_left;
MidoriNewPage open_new_pages_in : 2;
MidoriNewPage open_external_pages_in : 2;
gboolean middle_click_opens_selection : 1;
gboolean open_tabs_in_the_background : 1;
gboolean open_tabs_next_to_current : 1;
@ -63,10 +58,8 @@ struct _MidoriWebSettings
gboolean zoom_text_and_images : 1;
gboolean find_while_typing : 1;
gboolean kinetic_scrolling : 1;
MidoriAcceptCookies accept_cookies : 2;
gboolean original_cookies_only : 1;
gboolean remember_last_visited_pages : 1;
gboolean remember_last_downloaded_files : 1;
MidoriProxy proxy_type : 2;
MidoriIdentity identify_as : 3;
@ -81,7 +74,6 @@ struct _MidoriWebSettings
gchar* toolbar_items;
gchar* homepage;
gchar* download_folder;
gchar* download_manager;
gchar* text_editor;
gchar* news_aggregator;
gchar* location_entry_search;
@ -123,23 +115,18 @@ enum
PROP_SHOW_NAVIGATIONBAR,
PROP_SHOW_BOOKMARKBAR,
PROP_SHOW_PANEL,
PROP_SHOW_TRANSFERBAR,
PROP_SHOW_STATUSBAR,
PROP_TOOLBAR_STYLE,
PROP_SEARCH_ENGINES_IN_COMPLETION,
PROP_TOOLBAR_ITEMS,
PROP_COMPACT_SIDEPANEL,
PROP_SHOW_PANEL_CONTROLS,
PROP_RIGHT_ALIGN_SIDEPANEL,
PROP_OPEN_PANELS_IN_WINDOWS,
PROP_LOAD_ON_STARTUP,
PROP_HOMEPAGE,
PROP_SHOW_CRASH_DIALOG,
PROP_SPEED_DIAL_IN_NEW_TABS,
PROP_DOWNLOAD_FOLDER,
PROP_DOWNLOAD_MANAGER,
PROP_TEXT_EDITOR,
PROP_NEWS_AGGREGATOR,
PROP_LOCATION_ENTRY_SEARCH,
@ -149,7 +136,6 @@ enum
PROP_CLOSE_BUTTONS_ON_TABS,
PROP_CLOSE_BUTTONS_LEFT,
PROP_OPEN_NEW_PAGES_IN,
PROP_OPEN_EXTERNAL_PAGES_IN,
PROP_MIDDLE_CLICK_OPENS_SELECTION,
PROP_OPEN_TABS_IN_THE_BACKGROUND,
PROP_OPEN_TABS_NEXT_TO_CURRENT,
@ -167,11 +153,9 @@ enum
PROP_ZOOM_TEXT_AND_IMAGES,
PROP_FIND_WHILE_TYPING,
PROP_KINETIC_SCROLLING,
PROP_ACCEPT_COOKIES,
PROP_MAXIMUM_COOKIE_AGE,
PROP_MAXIMUM_HISTORY_AGE,
PROP_REMEMBER_LAST_DOWNLOADED_FILES,
PROP_PROXY_TYPE,
PROP_HTTP_PROXY,
@ -214,9 +198,7 @@ midori_startup_get_type (void)
{ MIDORI_STARTUP_BLANK_PAGE, "MIDORI_STARTUP_BLANK_PAGE", N_("Show Speed Dial") },
{ MIDORI_STARTUP_HOMEPAGE, "MIDORI_STARTUP_HOMEPAGE", N_("Show Homepage") },
{ MIDORI_STARTUP_LAST_OPEN_PAGES, "MIDORI_STARTUP_LAST_OPEN_PAGES", N_("Show last open tabs") },
#if WEBKIT_CHECK_VERSION (1, 1, 6)
{ MIDORI_STARTUP_DELAYED_PAGES, "MIDORI_STARTUP_DELAYED_PAGES", N_("Show last tabs without loading") },
#endif
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MidoriStartup", values);
@ -299,23 +281,6 @@ midori_proxy_get_type (void)
return type;
}
GType
midori_accept_cookies_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GEnumValue values[] = {
{ MIDORI_ACCEPT_COOKIES_ALL, "MIDORI_ACCEPT_COOKIES_ALL", N_("All cookies") },
{ MIDORI_ACCEPT_COOKIES_SESSION, "MIDORI_ACCEPT_COOKIES_SESSION", N_("Session cookies") },
{ MIDORI_ACCEPT_COOKIES_NONE, "MIDORI_ACCEPT_COOKIES_NONE", N_("None") },
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MidoriAcceptCookies", values);
}
return type;
}
GType
midori_identity_get_type (void)
{
@ -485,24 +450,6 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
FALSE,
flags));
/**
* MidoriWebSettings:show-transferbar:
*
* Whether to show the transferbar.
*
* Since: 0.1.5
*
* Deprecated: 0.3.1
*/
g_object_class_install_property (gobject_class,
PROP_SHOW_TRANSFERBAR,
g_param_spec_boolean (
"show-transferbar",
_("Show Transferbar"),
_("Whether to show the transferbar"),
TRUE,
flags));
g_object_class_install_property (gobject_class,
PROP_SHOW_STATUSBAR,
g_param_spec_boolean (
@ -523,24 +470,6 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
MIDORI_TOOLBAR_DEFAULT,
flags));
/**
* MidoriWebSettings:search-engines-in-completion:
*
* Whether to show search engines in the location completion.
*
* Since: 0.1.6
*
* Deprecated: 0.3.1
*/
g_object_class_install_property (gobject_class,
PROP_SEARCH_ENGINES_IN_COMPLETION,
g_param_spec_boolean (
"search-engines-in-completion",
_("Search engines in location completion"),
_("Whether to show search engines in the location completion"),
TRUE,
flags));
g_object_class_install_property (gobject_class,
PROP_TOOLBAR_ITEMS,
g_param_spec_string (
@ -559,24 +488,6 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
FALSE,
flags));
/**
* MidoriWebSettings:show-panel-controls:
*
* Whether to show the operating controls of the panel.
*
* Since: 0.1.9
*
* Deprecated: 0.3.0
*/
g_object_class_install_property (gobject_class,
PROP_SHOW_PANEL_CONTROLS,
g_param_spec_boolean (
"show-panel-controls",
_("Show operating controls of the panel"),
_("Whether to show the operating controls of the panel"),
TRUE,
flags));
/**
* MidoriWebSettings:right-sidepanel:
*
@ -645,25 +556,6 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
TRUE,
flags));
/**
* MidoriWebSettings:speed-dial-in-new-tabs:
*
* Show spee dial in newly opened tabs.
*
* Since: 0.1.7
*
* Deprecated: 0.3.4
*/
g_object_class_install_property (gobject_class,
PROP_SPEED_DIAL_IN_NEW_TABS,
g_param_spec_boolean (
"speed-dial-in-new-tabs",
/* i18n: Speed dial, webpage shortcuts, named for the phone function */
_("Show speed dial in new tabs"),
_("Show speed dial in newly opened tabs"),
TRUE,
flags));
g_object_class_install_property (gobject_class,
PROP_DOWNLOAD_FOLDER,
g_param_spec_string (
@ -671,26 +563,6 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
_("Save downloaded files to:"),
_("The folder downloaded files are saved to"),
midori_get_download_dir (),
#if WEBKIT_CHECK_VERSION (1, 1, 3)
flags));
#else
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
#endif
/**
* MidoriWebSettings:download-manager:
*
* An external download manager that shows up in context menus.
*
* Deprecated: 0.3.4
*/
g_object_class_install_property (gobject_class,
PROP_DOWNLOAD_MANAGER,
g_param_spec_string (
"download-manager",
_("Download Manager"),
_("An external download manager"),
NULL,
flags));
g_object_class_install_property (gobject_class,
@ -783,23 +655,6 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
MIDORI_NEW_PAGE_TAB,
flags));
/**
* MidoriWebSettings:open-external-pages-in:
*
* Where to open externally opened pages.
*
* Deprecated: 0.3.4
*/
g_object_class_install_property (gobject_class,
PROP_OPEN_EXTERNAL_PAGES_IN,
g_param_spec_enum (
"open-external-pages-in",
_("Open external pages in:"),
_("Where to open externally opened pages"),
MIDORI_TYPE_NEW_PAGE,
MIDORI_NEW_PAGE_TAB,
flags));
g_object_class_install_property (gobject_class,
PROP_MIDDLE_CLICK_OPENS_SELECTION,
g_param_spec_boolean (
@ -871,7 +726,6 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
"Enable special extensions for developers",
TRUE,
flags));
#if WEBKIT_CHECK_VERSION (1, 1, 6)
g_object_class_install_property (gobject_class,
PROP_ENABLE_SPELL_CHECKING,
g_param_spec_boolean ("enable-spell-checking",
@ -879,8 +733,6 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
_("Enable spell checking while typing"),
TRUE,
flags));
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 8)
g_object_class_install_property (gobject_class,
PROP_ENABLE_HTML5_DATABASE,
g_param_spec_boolean ("enable-html5-database",
@ -895,8 +747,6 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
_("Whether to enable HTML5 local storage support"),
FALSE,
flags));
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 13)
g_object_class_install_property (gobject_class,
PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
g_param_spec_boolean ("enable-offline-web-application-cache",
@ -904,7 +754,6 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
_("Whether to enable offline web application cache"),
FALSE,
flags));
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 18)
g_object_class_install_property (gobject_class,
PROP_ENABLE_PAGE_CACHE,
@ -963,28 +812,11 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
TRUE,
flags));
/**
* MidoriWebSettings:accept-cookies:
*
* What type of cookies to accept.
*
* Deprecated: 0.3.4
**/
g_object_class_install_property (gobject_class,
PROP_ACCEPT_COOKIES,
g_param_spec_enum (
"accept-cookies",
_("Accept cookies"),
_("What type of cookies to accept"),
MIDORI_TYPE_ACCEPT_COOKIES,
MIDORI_ACCEPT_COOKIES_ALL,
flags));
g_object_class_install_property (gobject_class,
PROP_MAXIMUM_COOKIE_AGE,
g_param_spec_int (
"maximum-cookie-age",
_("Maximum cookie age"),
_("Delete old Cookies after:"),
_("The maximum number of days to save cookies for"),
0, G_MAXINT, 30,
flags));
@ -994,29 +826,11 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
PROP_MAXIMUM_HISTORY_AGE,
g_param_spec_int (
"maximum-history-age",
_("Maximum history age"),
_("Delete pages from history after:"),
_("The maximum number of days to save the history for"),
0, G_MAXINT, 30,
flags));
/**
* MidoriWebSettings:remember-last-downloaded-files:
*
* Whether the last downloaded files are saved.
*
* Deprecated: 0.2.9
**/
g_object_class_install_property (gobject_class,
PROP_REMEMBER_LAST_DOWNLOADED_FILES,
g_param_spec_boolean (
"remember-last-downloaded-files",
_("Remember last downloaded files"),
_("Whether the last downloaded files are saved"),
TRUE,
flags));
/**
* MidoriWebSettings:proxy-type:
*
@ -1216,9 +1030,7 @@ midori_web_settings_init (MidoriWebSettings* web_settings)
{
web_settings->download_folder = g_strdup (midori_get_download_dir ());
web_settings->http_proxy = NULL;
web_settings->show_panel_controls = TRUE;
web_settings->open_popups_in_tabs = TRUE;
web_settings->remember_last_downloaded_files = TRUE;
web_settings->kinetic_scrolling = TRUE;
g_signal_connect (web_settings, "notify::default-encoding",
@ -1235,7 +1047,6 @@ midori_web_settings_finalize (GObject* object)
katze_assign (web_settings->toolbar_items, NULL);
katze_assign (web_settings->homepage, NULL);
katze_assign (web_settings->download_folder, NULL);
katze_assign (web_settings->download_manager, NULL);
katze_assign (web_settings->text_editor, NULL);
katze_assign (web_settings->news_aggregator, NULL);
katze_assign (web_settings->location_entry_search, NULL);
@ -1375,9 +1186,6 @@ midori_web_settings_set_property (GObject* object,
case PROP_SHOW_PANEL:
web_settings->show_panel = g_value_get_boolean (value);
break;
case PROP_SHOW_TRANSFERBAR:
web_settings->show_transferbar = g_value_get_boolean (value);
break;
case PROP_SHOW_STATUSBAR:
web_settings->show_statusbar = g_value_get_boolean (value);
break;
@ -1385,18 +1193,12 @@ midori_web_settings_set_property (GObject* object,
case PROP_TOOLBAR_STYLE:
web_settings->toolbar_style = g_value_get_enum (value);
break;
case PROP_SEARCH_ENGINES_IN_COMPLETION:
web_settings->search_engines_in_completion = g_value_get_boolean (value);
break;
case PROP_TOOLBAR_ITEMS:
katze_assign (web_settings->toolbar_items, g_value_dup_string (value));
break;
case PROP_COMPACT_SIDEPANEL:
web_settings->compact_sidepanel = g_value_get_boolean (value);
break;
case PROP_SHOW_PANEL_CONTROLS:
web_settings->show_panel_controls = g_value_get_boolean (value);
break;
case PROP_RIGHT_ALIGN_SIDEPANEL:
web_settings->right_align_sidepanel = g_value_get_boolean (value);
break;
@ -1413,15 +1215,9 @@ midori_web_settings_set_property (GObject* object,
case PROP_SHOW_CRASH_DIALOG:
web_settings->show_crash_dialog = g_value_get_boolean (value);
break;
case PROP_SPEED_DIAL_IN_NEW_TABS:
web_settings->speed_dial_in_new_tabs = g_value_get_boolean (value);
break;
case PROP_DOWNLOAD_FOLDER:
katze_assign (web_settings->download_folder, g_value_dup_string (value));
break;
case PROP_DOWNLOAD_MANAGER:
katze_assign (web_settings->download_manager, g_value_dup_string (value));
break;
case PROP_TEXT_EDITOR:
katze_assign (web_settings->text_editor, g_value_dup_string (value));
break;
@ -1467,9 +1263,6 @@ midori_web_settings_set_property (GObject* object,
case PROP_OPEN_NEW_PAGES_IN:
web_settings->open_new_pages_in = g_value_get_enum (value);
break;
case PROP_OPEN_EXTERNAL_PAGES_IN:
web_settings->open_external_pages_in = g_value_get_enum (value);
break;
case PROP_MIDDLE_CLICK_OPENS_SELECTION:
web_settings->middle_click_opens_selection = g_value_get_boolean (value);
break;
@ -1503,13 +1296,10 @@ midori_web_settings_set_property (GObject* object,
g_object_set (web_settings, "WebKitWebSettings::enable-developer-extras",
g_value_get_boolean (value), NULL);
break;
#if WEBKIT_CHECK_VERSION (1, 1, 6)
case PROP_ENABLE_SPELL_CHECKING:
g_object_set (web_settings, "WebKitWebSettings::enable-spell-checking",
g_value_get_boolean (value), NULL);
break;
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 8)
case PROP_ENABLE_HTML5_DATABASE:
g_object_set (web_settings, "WebKitWebSettings::enable-html5-database",
g_value_get_boolean (value), NULL);
@ -1518,13 +1308,10 @@ midori_web_settings_set_property (GObject* object,
g_object_set (web_settings, "WebKitWebSettings::enable-html5-local-storage",
g_value_get_boolean (value), NULL);
break;
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 13)
case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
g_object_set (web_settings, "WebKitWebSettings::enable-offline-web-application-cache",
g_value_get_boolean (value), NULL);
break;
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 18)
case PROP_ENABLE_PAGE_CACHE:
g_object_set (web_settings, "WebKitWebSettings::enable-page-cache",
@ -1540,9 +1327,6 @@ midori_web_settings_set_property (GObject* object,
case PROP_KINETIC_SCROLLING:
web_settings->kinetic_scrolling = g_value_get_boolean (value);
break;
case PROP_ACCEPT_COOKIES:
web_settings->accept_cookies = g_value_get_enum (value);
break;
case PROP_MAXIMUM_COOKIE_AGE:
web_settings->maximum_cookie_age = g_value_get_int (value);
break;
@ -1550,9 +1334,6 @@ midori_web_settings_set_property (GObject* object,
case PROP_MAXIMUM_HISTORY_AGE:
web_settings->maximum_history_age = g_value_get_int (value);
break;
case PROP_REMEMBER_LAST_DOWNLOADED_FILES:
web_settings->remember_last_downloaded_files = g_value_get_boolean (value);
break;
case PROP_PROXY_TYPE:
web_settings->proxy_type = g_value_get_enum (value);
@ -1571,27 +1352,19 @@ midori_web_settings_set_property (GObject* object,
{
gchar* string = generate_ident_string (web_settings->identify_as);
katze_assign (web_settings->ident_string, string);
#if WEBKIT_CHECK_VERSION (1, 1, 11)
g_object_set (web_settings, "user-agent", string, NULL);
#else
g_object_notify (object, "user-agent");
#endif
}
break;
case PROP_USER_AGENT:
if (web_settings->identify_as == MIDORI_IDENT_CUSTOM)
katze_assign (web_settings->ident_string, g_value_dup_string (value));
#if WEBKIT_CHECK_VERSION (1, 1, 11)
g_object_set (web_settings, "WebKitWebSettings::user-agent",
web_settings->ident_string, NULL);
#endif
break;
case PROP_PREFERRED_LANGUAGES:
katze_assign (web_settings->http_accept_language, g_value_dup_string (value));
#if WEBKIT_CHECK_VERSION (1, 1, 6)
g_object_set (web_settings, "spell-checking-languages",
web_settings->http_accept_language, NULL);
#endif
break;
case PROP_CLEAR_PRIVATE_DATA:
web_settings->clear_private_data = g_value_get_int (value);
@ -1657,9 +1430,6 @@ midori_web_settings_get_property (GObject* object,
case PROP_SHOW_PANEL:
g_value_set_boolean (value, web_settings->show_panel);
break;
case PROP_SHOW_TRANSFERBAR:
g_value_set_boolean (value, web_settings->show_transferbar);
break;
case PROP_SHOW_STATUSBAR:
g_value_set_boolean (value, web_settings->show_statusbar);
break;
@ -1667,18 +1437,12 @@ midori_web_settings_get_property (GObject* object,
case PROP_TOOLBAR_STYLE:
g_value_set_enum (value, web_settings->toolbar_style);
break;
case PROP_SEARCH_ENGINES_IN_COMPLETION:
g_value_set_boolean (value, web_settings->search_engines_in_completion);
break;
case PROP_TOOLBAR_ITEMS:
g_value_set_string (value, web_settings->toolbar_items);
break;
case PROP_COMPACT_SIDEPANEL:
g_value_set_boolean (value, web_settings->compact_sidepanel);
break;
case PROP_SHOW_PANEL_CONTROLS:
g_value_set_boolean (value, web_settings->show_panel_controls);
break;
case PROP_RIGHT_ALIGN_SIDEPANEL:
g_value_set_boolean (value, web_settings->right_align_sidepanel);
break;
@ -1695,15 +1459,9 @@ midori_web_settings_get_property (GObject* object,
case PROP_SHOW_CRASH_DIALOG:
g_value_set_boolean (value, web_settings->show_crash_dialog);
break;
case PROP_SPEED_DIAL_IN_NEW_TABS:
g_value_set_boolean (value, web_settings->speed_dial_in_new_tabs);
break;
case PROP_DOWNLOAD_FOLDER:
g_value_set_string (value, web_settings->download_folder);
break;
case PROP_DOWNLOAD_MANAGER:
g_value_set_string (value, web_settings->download_manager);
break;
case PROP_TEXT_EDITOR:
g_value_set_string (value, web_settings->text_editor);
break;
@ -1764,9 +1522,6 @@ midori_web_settings_get_property (GObject* object,
case PROP_OPEN_NEW_PAGES_IN:
g_value_set_enum (value, web_settings->open_new_pages_in);
break;
case PROP_OPEN_EXTERNAL_PAGES_IN:
g_value_set_enum (value, web_settings->open_external_pages_in);
break;
case PROP_MIDDLE_CLICK_OPENS_SELECTION:
g_value_set_boolean (value, web_settings->middle_click_opens_selection);
break;
@ -1796,13 +1551,10 @@ midori_web_settings_get_property (GObject* object,
g_value_set_boolean (value, katze_object_get_boolean (web_settings,
"WebKitWebSettings::enable-developer-extras"));
break;
#if WEBKIT_CHECK_VERSION (1, 1, 6)
case PROP_ENABLE_SPELL_CHECKING:
g_value_set_boolean (value, katze_object_get_boolean (web_settings,
"WebKitWebSettings::enable-spell-checking"));
break;
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 8)
case PROP_ENABLE_HTML5_DATABASE:
g_value_set_boolean (value, katze_object_get_boolean (web_settings,
"WebKitWebSettings::enable-html5-database"));
@ -1811,13 +1563,10 @@ midori_web_settings_get_property (GObject* object,
g_value_set_boolean (value, katze_object_get_boolean (web_settings,
"WebKitWebSettings::enable-html5-local-storage"));
break;
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 13)
case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
g_value_set_boolean (value, katze_object_get_boolean (web_settings,
"WebKitWebSettings::enable-offline-web-application-cache"));
break;
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 18)
case PROP_ENABLE_PAGE_CACHE:
g_value_set_boolean (value, katze_object_get_boolean (web_settings,
@ -1833,9 +1582,6 @@ midori_web_settings_get_property (GObject* object,
case PROP_KINETIC_SCROLLING:
g_value_set_boolean (value, web_settings->kinetic_scrolling);
break;
case PROP_ACCEPT_COOKIES:
g_value_set_enum (value, web_settings->accept_cookies);
break;
case PROP_MAXIMUM_COOKIE_AGE:
g_value_set_int (value, web_settings->maximum_cookie_age);
break;
@ -1843,9 +1589,6 @@ midori_web_settings_get_property (GObject* object,
case PROP_MAXIMUM_HISTORY_AGE:
g_value_set_int (value, web_settings->maximum_history_age);
break;
case PROP_REMEMBER_LAST_DOWNLOADED_FILES:
g_value_set_boolean (value, web_settings->remember_last_downloaded_files);
break;
case PROP_PROXY_TYPE:
g_value_set_enum (value, web_settings->proxy_type);

View file

@ -44,6 +44,7 @@ enum
MIDORI_CLEAR_TRASH = 16,
MIDORI_CLEAR_ON_QUIT = 32,
MIDORI_CLEAR_WEB_CACHE = 64, /* deprecated */
MIDORI_CLEAR_SESSION = 128,
};
typedef enum
@ -66,9 +67,7 @@ typedef enum
MIDORI_STARTUP_BLANK_PAGE, /* One blank tab or speed dial is opened */
MIDORI_STARTUP_HOMEPAGE, /* One homepage tab is opened */
MIDORI_STARTUP_LAST_OPEN_PAGES, /* The session is loaded and saved */
#if WEBKIT_CHECK_VERSION (1, 1, 6)
MIDORI_STARTUP_DELAYED_PAGES /* The session is saved, loading pages is delayed */
#endif
} MidoriStartup;
GType
@ -136,19 +135,6 @@ midori_proxy_get_type (void) G_GNUC_CONST;
#define MIDORI_TYPE_PROXY \
(midori_proxy_get_type ())
typedef enum
{
MIDORI_ACCEPT_COOKIES_ALL,
MIDORI_ACCEPT_COOKIES_SESSION,
MIDORI_ACCEPT_COOKIES_NONE
} MidoriAcceptCookies;
GType
midori_accept_cookies_get_type (void) G_GNUC_CONST;
#define MIDORI_TYPE_ACCEPT_COOKIES \
(midori_accept_cookies_get_type ())
typedef enum
{
MIDORI_IDENT_MIDORI,

View file

@ -93,6 +93,18 @@ namespace Midori {
public Extension ();
public unowned Midori.App get_app ();
public void install_boolean (string name, bool default_value);
public void install_integer (string name, int default_value);
public void install_string (string name, string default_value);
public bool get_boolean (string name);
public int get_integer (string name);
public unowned string get_string (string name);
public void set_boolean (string name, bool value);
public void set_integer (string name, int value);
public void set_string (string name, string value);
[NoAccessorMethod]
public string name { get; set; }
[NoAccessorMethod]
@ -104,6 +116,7 @@ namespace Midori {
public signal void activate (Midori.App app);
public signal void deactivate ();
public signal void open_preferences ();
}
public class View : Gtk.VBox {

View file

@ -926,6 +926,8 @@ sokoke_uri_unescape_string (const gchar* uri)
{
/* Preserve %20 for pasting URLs into other windows */
gchar* unescaped = g_uri_unescape_string (uri, "+");
if (!unescaped)
return g_strdup (uri);
gchar* spaced = sokoke_replace_variables (unescaped, " ", "%20", NULL);
g_free (unescaped);
return spaced;
@ -1720,6 +1722,16 @@ sokoke_find_data_filename (const gchar* filename)
const gchar* data_dir;
gchar* path;
#ifdef G_OS_WIN32
gchar* install_path = g_win32_get_package_installation_directory_of_module (NULL);
path = g_build_filename (install_path, "share", filename, NULL);
g_free (install_path);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
#endif
path = g_build_filename (g_get_user_data_dir (), filename, NULL);
if (g_access (path, F_OK) == 0)
return path;
@ -1754,101 +1766,6 @@ sokoke_get_argv (gchar** argument_vector)
return stored_argv;
}
#if !WEBKIT_CHECK_VERSION (1, 1, 14)
static void
res_server_handler_cb (SoupServer* res_server,
SoupMessage* msg,
const gchar* path,
GHashTable* query,
SoupClientContext* client,
gpointer data)
{
if (g_str_has_prefix (path, "/res"))
{
gchar* filename = g_build_filename ("midori", path, NULL);
gchar* filepath = sokoke_find_data_filename (filename);
gchar* contents;
gsize length;
g_free (filename);
if (g_file_get_contents (filepath, &contents, &length, NULL))
{
gchar* content_type = g_content_type_guess (filepath, (guchar*)contents,
length, NULL);
gchar* mime_type = g_content_type_get_mime_type (content_type);
g_free (content_type);
soup_message_set_response (msg, mime_type, SOUP_MEMORY_TAKE,
contents, length);
g_free (mime_type);
soup_message_set_status (msg, 200);
}
else
soup_message_set_status (msg, 404);
g_free (filepath);
}
else if (g_str_has_prefix (path, "/stock/"))
{
GtkIconTheme* icon_theme = gtk_icon_theme_get_default ();
const gchar* icon_name = &path[7] ? &path[7] : "";
gint icon_size = 22;
GdkPixbuf* icon;
gchar* contents;
gsize length;
if (g_ascii_isalpha (icon_name[0]))
icon_size = strstr (icon_name, "dialog") ? 48 : 22;
else if (g_ascii_isdigit (icon_name[0]))
{
guint i = 0;
while (icon_name[i])
if (icon_name[i++] == '/')
{
gchar* size = g_strndup (icon_name, i - 1);
icon_size = atoi (size);
g_free (size);
icon_name = &icon_name[i];
}
}
icon = gtk_icon_theme_load_icon (icon_theme, icon_name,
icon_size, 0, NULL);
if (!icon)
icon = gtk_icon_theme_load_icon (icon_theme, "gtk-missing-image",
icon_size, 0, NULL);
gdk_pixbuf_save_to_buffer (icon, &contents, &length, "png", NULL, NULL);
g_object_unref (icon);
soup_message_set_response (msg, "image/png", SOUP_MEMORY_TAKE,
contents, length);
soup_message_set_status (msg, 200);
}
else
{
soup_message_set_status (msg, 404);
}
}
SoupServer*
sokoke_get_res_server (void)
{
static SoupServer* res_server = NULL;
SoupAddress* addr = NULL;
if (G_UNLIKELY (!res_server))
{
addr = soup_address_new ("localhost", SOUP_ADDRESS_ANY_PORT);
soup_address_resolve_sync (addr, NULL);
res_server = soup_server_new ("interface", addr, NULL);
g_object_unref (addr);
soup_server_add_handler (res_server, "/",
res_server_handler_cb, NULL, NULL);
soup_server_run_async (res_server);
}
return res_server;
}
#endif
gchar*
sokoke_replace_variables (const gchar* template,
const gchar* variable_first, ...)

View file

@ -231,11 +231,6 @@ sokoke_find_data_filename (const gchar* filename);
gchar**
sokoke_get_argv (gchar** argument_vector);
#if !WEBKIT_CHECK_VERSION (1, 1, 14)
SoupServer*
sokoke_get_res_server (void);
#endif
gchar*
sokoke_replace_variables (const gchar* template,
const gchar* variable_first, ...);

View file

@ -17,6 +17,7 @@ if progressive or Options.commands['check']:
obj.uselib = libs
obj.add_marshal_file ('marshal.list', 'midori_cclosure_marshal')
obj.install_path = None
obj.packages = 'glib-2.0 gio-2.0 gtk+-2.0 libsoup-2.4 webkit-1.0'
bld.add_group ()
if progressive:

View file

@ -133,6 +133,9 @@ midori_bookmarks_export_array_db (sqlite3* db,
KatzeItem* item;
GList* list;
if (!db)
return;
sqlcmd = g_strdup_printf ("SELECT * FROM bookmarks where folder='%s'", folder);
root_array = katze_array_from_sqlite (db, sqlcmd);
g_free (sqlcmd);
@ -160,6 +163,9 @@ midori_bookmarks_import_array_db (sqlite3* db,
GList* list;
KatzeItem* item;
if (!db)
return;
KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
{
if (KATZE_IS_ARRAY (item))
@ -181,6 +187,9 @@ midori_bookmarks_read_from_db (MidoriBookmarks* bookmarks,
db = g_object_get_data (G_OBJECT (bookmarks->array), "db");
if (!db)
return katze_array_new (KATZE_TYPE_ITEM);
if (keyword && *keyword)
{
gchar* filterstr;
@ -202,7 +211,7 @@ midori_bookmarks_read_from_db (MidoriBookmarks* bookmarks,
}
if (result != SQLITE_OK)
return NULL;
return katze_array_new (KATZE_TYPE_ITEM);
return katze_array_from_statement (statement);
}
@ -248,6 +257,9 @@ midori_bookmarks_insert_item_db (sqlite3* db,
/* Bookmarks must have a name, import may produce invalid items */
g_return_if_fail (katze_item_get_name (item));
if (!db)
return;
if (KATZE_ITEM_IS_BOOKMARK (item))
uri = g_strdup (katze_item_get_uri (item));
else

View file

@ -16,6 +16,8 @@
#include "midori-stock.h"
#include "midori-viewable.h"
#include "midori-extensions-column.c"
#include "sokoke.h"
#include <glib/gi18n.h>
@ -244,6 +246,24 @@ midori_extensions_treeview_render_icon_cb (GtkTreeViewColumn* column,
g_object_unref (extension);
}
static void
midori_extensions_treeview_render_preferences_cb (GtkTreeViewColumn* column,
GtkCellRenderer* renderer,
GtkTreeModel* model,
GtkTreeIter* iter,
GtkWidget* treeview)
{
MidoriExtension* extension;
gtk_tree_model_get (model, iter, 0, &extension, -1);
g_object_set (renderer, "stock-id", GTK_STOCK_PREFERENCES,
"stock-size", GTK_ICON_SIZE_BUTTON,
"visible", midori_extension_has_preferences (extension),
"sensitive", midori_extension_is_active (extension),
"xpad", 4, NULL);
g_object_unref (extension);
}
static void
midori_extensions_treeview_render_text_cb (GtkTreeViewColumn* column,
GtkCellRenderer* renderer,
@ -351,6 +371,57 @@ midori_extensions_tree_sort_func (GtkTreeModel* model,
return result;
}
static void
midori_extensions_treeview_column_preference_clicked_cb (GtkWidget* widget,
GtkTreeView* treeview,
GtkTreePath* path)
{
GtkTreeModel* model;
GtkTreeIter iter;
model = gtk_tree_view_get_model (treeview);
if (gtk_tree_model_get_iter (model, &iter, path))
{
MidoriExtension* extension;
gtk_tree_model_get (model, &iter, 0, &extension, -1);
if (midori_extension_is_active (extension))
g_signal_emit_by_name (extension, "open-preferences");
g_object_unref (extension);
}
}
static gboolean
midori_extensions_treeview_button_pressed_cb (GtkWidget* view,
GdkEventButton* bevent,
gpointer data)
{
gboolean ret = FALSE;
GtkTreePath* path;
GtkTreeViewColumn* column;
guint signal_id;
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (view),
bevent->x, bevent->y, &path, &column, NULL, NULL))
{
if (path != NULL)
{
if (MIDORI_IS_EXTENSIONS_COUMN (column))
{
signal_id = g_signal_lookup ("row-clicked", G_OBJECT_TYPE (column));
if (signal_id && g_signal_has_handler_pending (column, signal_id, 0, FALSE)) {
g_signal_emit (column, signal_id, 0, GTK_TREE_VIEW (view), path);
ret = TRUE;
}
}
gtk_tree_path_free (path);
}
}
return ret;
}
static void
midori_extensions_init (MidoriExtensions* extensions)
{
@ -359,8 +430,13 @@ midori_extensions_init (MidoriExtensions* extensions)
GtkCellRenderer* renderer_icon;
GtkCellRenderer* renderer_text;
GtkCellRenderer* renderer_toggle;
GtkCellRenderer* renderer_preferences;
GtkListStore* liststore = gtk_list_store_new (1, G_TYPE_OBJECT);
extensions->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (liststore));
g_object_connect (extensions->treeview,
"signal::button-press-event",
midori_extensions_treeview_button_pressed_cb, NULL,
NULL);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (liststore),
0, GTK_SORT_ASCENDING);
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (liststore),
@ -386,10 +462,24 @@ midori_extensions_init (MidoriExtensions* extensions)
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
renderer_text = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column, renderer_text, FALSE);
gtk_tree_view_column_set_expand (column, TRUE);
gtk_tree_view_column_set_cell_data_func (column, renderer_text,
(GtkTreeCellDataFunc)midori_extensions_treeview_render_text_cb,
extensions->treeview, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (extensions->treeview), column);
column = GTK_TREE_VIEW_COLUMN (midori_extensions_coumn_new ());
g_signal_connect (column,
"row-clicked",
G_CALLBACK (midori_extensions_treeview_column_preference_clicked_cb),
NULL);
renderer_preferences = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, renderer_preferences, FALSE);
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_fixed_width (column, 30);
gtk_tree_view_column_set_cell_data_func (column, renderer_preferences,
(GtkTreeCellDataFunc)midori_extensions_treeview_render_preferences_cb,
extensions->treeview, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (extensions->treeview), column);
g_object_unref (liststore);
g_object_connect (extensions->treeview,
"signal::row-activated",

View file

@ -174,6 +174,9 @@ midori_history_remove_item_from_db (MidoriHistory* history,
db = g_object_get_data (G_OBJECT (history->array), "db");
if (!db)
return;
if (KATZE_ITEM_IS_BOOKMARK (item))
sqlcmd = sqlite3_mprintf (
"DELETE FROM history WHERE uri = '%q' AND"
@ -217,6 +220,9 @@ midori_history_read_from_db (MidoriHistory* history,
db = g_object_get_data (G_OBJECT (history->array), "db");
if (!db)
return katze_array_new (KATZE_TYPE_ITEM);
if (filter && *filter)
{
gchar* filterstr;
@ -249,7 +255,7 @@ midori_history_read_from_db (MidoriHistory* history,
}
if (result != SQLITE_OK)
return NULL;
return katze_array_new (KATZE_TYPE_ITEM);
return katze_array_from_statement (statement);
}
@ -327,7 +333,7 @@ midori_history_bookmark_add_cb (GtkWidget* menuitem,
{
GtkTreeModel* model;
GtkTreeIter iter;
KatzeItem* item;
KatzeItem* item = NULL;
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (history));
if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (history->treeview),
@ -335,11 +341,12 @@ midori_history_bookmark_add_cb (GtkWidget* menuitem,
gtk_tree_model_get (model, &iter, 0, &item, -1);
if (KATZE_IS_ITEM (item) && katze_item_get_uri (item))
{
midori_browser_edit_bookmark_dialog_new (browser, item, TRUE, FALSE);
g_object_unref (item);
}
else
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
g_object_unref (item);
}
static GtkWidget*
@ -674,6 +681,10 @@ midori_history_open_in_tab_activate_cb (GtkWidget* menuitem,
KatzeArray* array;
db = g_object_get_data (G_OBJECT (history->array), "db");
if (!db)
return;
sqlcmd = g_strdup_printf ("SELECT uri, title, date, day "
"FROM history WHERE day = %d "
"GROUP BY uri ORDER BY date ASC",

View file

@ -103,7 +103,6 @@ midori_transfers_button_clear_clicked_cb (GtkToolItem* toolitem,
gint n = 0;
while ((gtk_tree_model_iter_nth_child (model, &iter, NULL, n++)))
{
#if WEBKIT_CHECK_VERSION (1, 1, 3)
WebKitDownload* download;
WebKitDownloadStatus status;
@ -117,7 +116,6 @@ midori_transfers_button_clear_clicked_cb (GtkToolItem* toolitem,
n--; /* Decrement n since we just removed it */
}
g_object_unref (download);
#endif
}
}
@ -161,7 +159,6 @@ midori_transfers_viewable_iface_init (MidoriViewableIface* iface)
iface->get_toolbar = midori_transfers_get_toolbar;
}
#if WEBKIT_CHECK_VERSION (1, 1, 3)
static void
midori_transfers_download_notify_progress_cb (WebKitDownload* download,
GParamSpec* pspec,
@ -198,7 +195,6 @@ midori_transfers_browser_add_download_cb (MidoriBrowser* browser,
g_signal_connect (download, "notify::status",
G_CALLBACK (midori_transfers_download_notify_status_cb), transfers);
}
#endif
static void
midori_transfers_set_property (GObject* object,
@ -257,7 +253,6 @@ midori_transfers_treeview_render_text_cb (GtkTreeViewColumn* column,
GtkTreeIter* iter,
GtkWidget* treeview)
{
#if WEBKIT_CHECK_VERSION (1, 1, 3)
WebKitDownload* download;
gchar* current;
gchar* total;
@ -286,7 +281,6 @@ midori_transfers_treeview_render_text_cb (GtkTreeViewColumn* column,
"xpad", 1, "ypad", 6, NULL);
g_free (text);
g_object_unref (download);
#endif
}
static void
@ -296,7 +290,6 @@ midori_transfers_treeview_render_button_cb (GtkTreeViewColumn* column,
GtkTreeIter* iter,
GtkWidget* treeview)
{
#if WEBKIT_CHECK_VERSION (1, 1, 3)
WebKitDownload* download;
const gchar* stock_id;
@ -317,7 +310,6 @@ midori_transfers_treeview_render_button_cb (GtkTreeViewColumn* column,
"stock-size", GTK_ICON_SIZE_MENU, NULL);
g_object_unref (download);
#endif
}
static void
@ -330,7 +322,6 @@ midori_transfers_treeview_row_activated_cb (GtkTreeView* treeview,
GtkTreeIter iter;
if (gtk_tree_model_get_iter (model, &iter, path))
{
#if WEBKIT_CHECK_VERSION (1, 1, 3)
WebKitDownload* download;
gtk_tree_model_get (model, &iter, 1, &download, -1);
@ -355,7 +346,6 @@ midori_transfers_treeview_row_activated_cb (GtkTreeView* treeview,
break;
}
g_object_unref (download);
#endif
}
}
@ -363,7 +353,6 @@ static void
midori_transfers_hierarchy_changed_cb (MidoriTransfers* transfers,
GtkWidget* old_parent)
{
#if WEBKIT_CHECK_VERSION (1, 1, 3)
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (transfers));
if (MIDORI_IS_BROWSER (browser))
g_signal_connect (browser, "add-download",
@ -371,10 +360,8 @@ midori_transfers_hierarchy_changed_cb (MidoriTransfers* transfers,
if (old_parent)
g_signal_handlers_disconnect_by_func (old_parent,
midori_transfers_browser_add_download_cb, transfers);
#endif
}
#if WEBKIT_CHECK_VERSION (1, 1, 3)
static GtkWidget*
midori_transfers_popup_menu_item (GtkMenu* menu,
const gchar* stock_id,
@ -486,7 +473,6 @@ midori_transfers_popup (GtkWidget* widget,
katze_widget_popup (widget, GTK_MENU (menu), event, KATZE_MENU_POSITION_CURSOR);
}
#endif
static gboolean
midori_transfers_popup_menu_cb (GtkWidget* widget,
@ -497,7 +483,6 @@ midori_transfers_popup_menu_cb (GtkWidget* widget,
if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
{
#if WEBKIT_CHECK_VERSION (1, 1, 3)
WebKitDownload* download;
gtk_tree_model_get (model, &iter, 1, &download, -1);
@ -505,7 +490,6 @@ midori_transfers_popup_menu_cb (GtkWidget* widget,
midori_transfers_popup (widget, NULL, download, transfers);
g_object_unref (download);
return TRUE;
#endif
}
return FALSE;
}
@ -523,7 +507,6 @@ midori_transfers_button_release_event_cb (GtkWidget* widget,
if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
{
#if WEBKIT_CHECK_VERSION (1, 1, 3)
WebKitDownload* download;
gtk_tree_model_get (model, &iter, 1, &download, -1);
@ -531,7 +514,6 @@ midori_transfers_button_release_event_cb (GtkWidget* widget,
midori_transfers_popup (widget, NULL, download, transfers);
g_object_unref (download);
return TRUE;
#endif
}
return FALSE;
}

2359
po/ar.po

File diff suppressed because it is too large Load diff

1493
po/cs.po

File diff suppressed because it is too large Load diff

1432
po/da.po

File diff suppressed because it is too large Load diff

1572
po/de.po

File diff suppressed because it is too large Load diff

2059
po/el.po

File diff suppressed because it is too large Load diff

2048
po/es.po

File diff suppressed because it is too large Load diff

1920
po/gl.po

File diff suppressed because it is too large Load diff

1425
po/hr.po

File diff suppressed because it is too large Load diff

1873
po/id.po

File diff suppressed because it is too large Load diff

1570
po/it.po

File diff suppressed because it is too large Load diff

1660
po/ja.po

File diff suppressed because it is too large Load diff

1436
po/ko.po

File diff suppressed because it is too large Load diff

2882
po/nl.po

File diff suppressed because it is too large Load diff

1492
po/pl.po

File diff suppressed because it is too large Load diff

1493
po/pt.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

2086
po/ro.po

File diff suppressed because it is too large Load diff

1982
po/sk.po

File diff suppressed because it is too large Load diff

2040
po/tr.po

File diff suppressed because it is too large Load diff

1434
po/uk.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -258,18 +258,18 @@ magic_uri_format (void)
static void
magic_uri_prefetch (void)
{
g_assert (!sokoke_prefetch_uri (NULL, NULL, NULL));
g_assert (sokoke_prefetch_uri ("http://google.com", NULL, NULL));
g_assert (sokoke_prefetch_uri ("http://google.com", NULL, NULL));
g_assert (sokoke_prefetch_uri ("http://googlecom", NULL, NULL));
g_assert (sokoke_prefetch_uri ("http://1kino.com", NULL, NULL));
g_assert (sokoke_prefetch_uri ("http://", NULL, NULL));
g_assert (!sokoke_prefetch_uri ("http:/", NULL, NULL));
g_assert (!sokoke_prefetch_uri ("http", NULL, NULL));
g_assert (!sokoke_prefetch_uri ("ftp://ftphost.org", NULL, NULL));
g_assert (!sokoke_prefetch_uri ("http://10.0.0.1", NULL, NULL));
g_assert (!sokoke_prefetch_uri ("about:blank", NULL, NULL));
g_assert (!sokoke_prefetch_uri ("javascript: alert()", NULL, NULL));
g_assert (!sokoke_prefetch_uri (NULL, NULL, NULL, NULL));
g_assert (sokoke_prefetch_uri (NULL, "http://google.com", NULL, NULL));
g_assert (sokoke_prefetch_uri (NULL, "http://google.com", NULL, NULL));
g_assert (sokoke_prefetch_uri (NULL, "http://googlecom", NULL, NULL));
g_assert (sokoke_prefetch_uri (NULL, "http://1kino.com", NULL, NULL));
g_assert (sokoke_prefetch_uri (NULL, "http://", NULL, NULL));
g_assert (!sokoke_prefetch_uri (NULL, "http:/", NULL, NULL));
g_assert (!sokoke_prefetch_uri (NULL, "http", NULL, NULL));
g_assert (!sokoke_prefetch_uri (NULL, "ftp://ftphost.org", NULL, NULL));
g_assert (!sokoke_prefetch_uri (NULL, "http://10.0.0.1", NULL, NULL));
g_assert (!sokoke_prefetch_uri (NULL, "about:blank", NULL, NULL));
g_assert (!sokoke_prefetch_uri (NULL, "javascript: alert()", NULL, NULL));
}
int

View file

@ -147,9 +147,8 @@ midori_findbar_invoke (MidoriFindbar* findbar)
if ((text = midori_view_get_selected_text (MIDORI_VIEW (view))))
gtk_entry_set_text (GTK_ENTRY (findbar->find_text), text);
gtk_widget_show (GTK_WIDGET (findbar));
gtk_widget_grab_focus (GTK_WIDGET (findbar->find_text));
}
gtk_widget_grab_focus (GTK_WIDGET (findbar->find_text));
}
static void

View file

@ -37,7 +37,6 @@ midori_transferbar_class_init (MidoriTransferbarClass* class)
/* Nothing to do */
}
#if WEBKIT_CHECK_VERSION (1, 1, 3)
typedef struct
{
WebKitDownload* download;
@ -112,9 +111,7 @@ midori_transferbar_download_notify_status_cb (WebKitDownload* download,
case WEBKIT_DOWNLOAD_STATUS_FINISHED:
{
MidoriBrowser* browser = midori_browser_get_for_widget (button);
#if WEBKIT_CHECK_VERSION (1, 1, 14)
WebKitNetworkRequest* request;
#endif
const gchar* original_uri;
gchar** fingerprint;
@ -137,11 +134,9 @@ midori_transferbar_download_notify_status_cb (WebKitDownload* download,
}
/* Link Fingerprint */
#if WEBKIT_CHECK_VERSION (1, 1, 14)
request = webkit_download_get_network_request (download);
original_uri = g_object_get_data (G_OBJECT (request), "midori-original-uri");
if (!original_uri)
#endif
original_uri = webkit_download_get_uri (download);
fingerprint = g_strsplit (original_uri, "#!md5!", 2);
if (fingerprint && fingerprint[0] && fingerprint[1])
@ -315,7 +310,6 @@ midori_transferbar_clear_clicked_cb (GtkWidget* button,
}
}
}
#endif
static void
midori_transferbar_init (MidoriTransferbar* transferbar)
@ -326,10 +320,8 @@ midori_transferbar_init (MidoriTransferbar* transferbar)
transferbar->clear = gtk_tool_button_new_from_stock (GTK_STOCK_CLEAR);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (transferbar->clear), _("Clear All"));
gtk_tool_item_set_is_important (transferbar->clear, TRUE);
#if WEBKIT_CHECK_VERSION (1, 1, 3)
g_signal_connect (transferbar->clear, "clicked",
G_CALLBACK (midori_transferbar_clear_clicked_cb), transferbar);
#endif
gtk_toolbar_insert (GTK_TOOLBAR (transferbar), transferbar->clear, -1);
transferbar->infos = NULL;
@ -340,7 +332,6 @@ midori_transferbar_confirm_delete (MidoriTransferbar* transferbar)
{
GtkWidget* dialog = NULL;
gboolean cancel = FALSE;
#if WEBKIT_CHECK_VERSION (1, 1, 3)
GList* list;
gboolean all_done = TRUE;
@ -359,9 +350,6 @@ midori_transferbar_confirm_delete (MidoriTransferbar* transferbar)
}
if (!all_done)
#else
if (transferbar->infos || g_list_nth_data (transferbar->infos, 0))
#endif
{
GtkWidget* widget = gtk_widget_get_toplevel (GTK_WIDGET (transferbar));
dialog = gtk_message_dialog_new (GTK_WINDOW (widget),

View file

@ -1,31 +0,0 @@
#! /bin/sh
# Copyright (C) 2010-2011 Peter de Ridder <peter@xfce.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file COPYING for the full license text.
temp_file_new=`mktemp`
temp_file_old=`mktemp`
while [ "$1" ]
do
echo $1 >> $temp_file_new
shift
done
while [ "x`sha1sum - < $temp_file_new`" != "x`sha1sum - < $temp_file_old`" ]
do
files=`cat $temp_file_new $temp_file_old | sort | uniq -u`
cp $temp_file_new $temp_file_old
strings $files 2> /dev/null | grep \\.dll | cat - $temp_file_old | sort | uniq > $temp_file_new
done
cat $temp_file_new
rm $temp_file_new $temp_file_old

59
win32/makedist/makedist.midori Normal file → Executable file
View file

@ -9,15 +9,60 @@
#
# See the file COPYING for the full license text.
# script: makedist.midori [version tag]
#
# This script creates an archive containing all required files for
# midori on windows. The midori version is inserted in the name of
# the archive and appended to the name of the root directory in the
# archive.
# The name of the archive is contructed as follows:
# midori<version tag>-<timestamp>.extension
# The archive contains a root directory named:
# midori<version tag>
# a bit of configuration
root_dir=$MINGW_PREFIX
script_dir=$PWD
# create temporary working directory
temp_dir=`mktemp -d`
# check if we can use 7zip
have_7zip=`which 7za`
# generate unique filename
ARCHIVE=midori$1-`date +%Y%m%d%H%M`.zip
if [ "$have_7zip" != "" ]; then
ARCHIVE=midori$1-`date +%Y%m%d%H%M`.7z
else
ARCHIVE=midori$1-`date +%Y%m%d%H%M`.zip
fi
# function: dll-recursive <list of exe and dll files ...>
#
# recursively search all dll dependencies of the input files.
# The resulting list of dll files including the input files is
# printed to stdout.
dll_recursive ()
{
temp_file_new=`mktemp`
temp_file_old=`mktemp`
while [ "$1" ]
do
echo $1 >> $temp_file_new
shift
done
while [ "x`sha1sum - < $temp_file_new`" != "x`sha1sum - < $temp_file_old`" ]
do
files=`cat $temp_file_new $temp_file_old | sort | uniq -u`
cp $temp_file_new $temp_file_old
strings $files 2> /dev/null | grep \\.dll | cat - $temp_file_old | sort | uniq > $temp_file_new
done
cat $temp_file_new
rm $temp_file_new $temp_file_old
}
echo -n "Creating $ARCHIVE ."
@ -28,7 +73,7 @@ echo -n .
# auto generate dll list, only of existing files
pushd $root_dir/bin > /dev/null
$script_dir/dll-recursive.sh midori*.exe gspawn-*-helper*.exe libhunspell*.dll > $temp_dir/midori.exe.lst
dll_recursive midori*.exe gspawn-*-helper*.exe libhunspell*.dll > $temp_dir/midori.exe.lst
files=`ls | cat - $temp_dir/midori.exe.lst | sort | uniq -d`
rm $temp_dir/midori.exe.lst
popd > /dev/null
@ -82,9 +127,13 @@ echo -n .
ARCHIVE=`pwd`/$ARCHIVE
# store as tar.bz2 file
# store as zip/7z file
pushd $temp_dir > /dev/null
zip -rq $ARCHIVE midori$1
if [ "$have_7zip" != "" ]; then
7za a -m0=lzma -mx=9 $ARCHIVE midori$1
else
zip -rq $ARCHIVE midori$1
fi
popd > /dev/null
echo -n .

0
win32/x86-mingw32-opensuse/crossconfig.sh Normal file → Executable file
View file

4
win32/x86-mingw32-opensuse/install.sh Normal file → Executable file
View file

@ -10,7 +10,7 @@
# See the file COPYING for the full license text.
# config variables
REPO_URL=http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_11.2
REPO_URL=http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_11.4
REPO_ARCH=noarch
DOWNLOAD_PATH=~/dev/mingw/packages/opensuse
BUILD_PATH=~/tmp/opensuse
@ -71,7 +71,7 @@ do
if [ -d $BUILD_PATH/usr/i686-w64-mingw32/sys-root/mingw ]
then
# convert pkgconfig files
if [ -d $BUILD_PATH/usr/i686-w64=mingw32/sys-root/mingw/lib/pkgconfig ]
if [ -d $BUILD_PATH/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig ]
then
sed -i -e 's@^prefix=.*@prefix='$INSTALL_PATH'@' -e 's@/usr/i686-w64-mingw32/sys-root/mingw@${prefix}@' $BUILD_PATH/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/*.pc
fi

View file

@ -14,12 +14,14 @@ mingw32-freetype
mingw32-freetype-devel
mingw32-gcc-c++
mingw32-gcc
mingw32-gdb
mingw32-gdk-pixbuf
mingw32-gdk-pixbuf-devel
mingw32-gettext-runtime
mingw32-gettext-tools
mingw32-glib2
mingw32-glib2-devel
mingw32-glib-networking
mingw32-gst-plugins-base-devel
mingw32-gstreamer-devel
mingw32-gtk2
@ -42,6 +44,8 @@ mingw32-libgstinterfaces
mingw32-libgstreamer
mingw32-libidn
mingw32-libidn-devel
mingw32-libintl
mingw32-libintl-devel
mingw32-libjasper
mingw32-libjasper-devel
mingw32-libjpeg
@ -59,8 +63,9 @@ mingw32-libtasn1
mingw32-libtasn1-devel
mingw32-libtiff
mingw32-libtiff-devel
mingw32-libwebkit
mingw32-libwebkit-devel
mingw32-libwebkitgtk
mingw32-libwebkitgtk-devel
mingw32-webkit-tools
mingw32-libxml2
mingw32-libxml2-devel
mingw32-libxslt
@ -71,6 +76,8 @@ mingw32-pixman
mingw32-pixman-devel
mingw32-pthreads
mingw32-pthreads-devel
mingw32-libproxy
mingw32-libmodman
mingw32-shared-mime-info
mingw32-shared-mime-info-devel
mingw32-win_iconv

21
wscript
View file

@ -28,8 +28,8 @@ import misc
from Configure import find_program_impl
major = 0
minor = 3
micro = 6
minor = 4
micro = 0
APPNAME = 'midori'
VERSION = str (major) + '.' + str (minor) + '.' + str (micro)
@ -88,14 +88,7 @@ def configure (conf):
return dirvalue
conf.check_tool ('compiler_cc')
if option_enabled ('vala'):
if find_program_impl (conf.env, 'valac'):
conf.check_tool ('vala')
else:
conf.check_message ('program', 'valac', False, False)
Utils.pprint ('RED', 'Vala is required for some extensions.')
Utils.pprint ('RED', 'Pass --disable-vala to not build with Vala.')
sys.exit (1)
conf.check_tool ('vala')
conf.check_tool ('glib2')
if option_enabled ('nls'):
@ -203,7 +196,7 @@ def configure (conf):
includes='/usr/X11R6/include', mandatory=False)
conf.check (lib='Xss', libpath='/usr/X11R6/lib', mandatory=False)
check_pkg ('gtk+-2.0', '2.10.0', var='GTK', args=args)
check_pkg ('webkit-1.0', '1.1.1', args=args)
check_pkg ('webkit-1.0', '1.1.17', args=args)
check_pkg ('libsoup-2.4', '2.25.2')
conf.define ('HAVE_LIBSOUP_2_25_2', 1)
check_pkg ('libsoup-2.4', '2.27.90', False, var='LIBSOUP_2_27_90')
@ -330,8 +323,9 @@ def set_options (opt):
if group == None:
group = opt
option_ = option.replace ('-', '_')
group.add_option ('--enable-' + option, action='store_true',
default=False, help='Enable ' + desc, dest='enable_' + option_)
group.add_option ('--enable-' + option, action='store_true', default=False,
help='Enable ' + desc + ' [Default: ' + str (not disable) + ']',
dest='enable_' + option_)
group.add_option ('--disable-' + option, action='store_true',
default=disable, help='Disable ' + desc, dest='disable_' + option_)
@ -359,7 +353,6 @@ def set_options (opt):
group = opt.add_option_group ('Optional features', '')
add_enable_option ('unique', 'single instance support', group)
add_enable_option ('vala', 'Vala support', group)
add_enable_option ('libidn', 'international domain name support', group)
add_enable_option ('libnotify', 'notification support', group)
add_enable_option ('addons', 'building of extensions', group)