import upstream version 2.7

Signed-off-by: Yves-Alexis Perez <corsac@debian.org>
This commit is contained in:
Yves-Alexis Perez 2010-08-17 08:19:18 +02:00
parent 45380ddfe3
commit a72caddd02
75 changed files with 24234 additions and 19580 deletions

View file

@ -1,5 +1,17 @@
This file is licensed under the terms of the expat license, see the file EXPAT.
v0.2.7
+ Multiple word completion in location
+ Database backed bookmarks
+ Search bookmark panel and drag bookmarks
+ Bookmarks in address completion
+ Removed bookmarks and history from menubar
+ Add 'Minimize New Tabs' and 'Copy Addresses of Tabs'
+ Refactorings and optimisations in the core
+ Adblock compatibility improvements and speedup
+ Changeable speed dial size
+ Delayed pages at startup, or after a crash
v0.2.6
+ Show a dialogue when quitting while downloading
+ Render icons in errors/ speed dial properly

View file

@ -61,6 +61,10 @@ If you are interested in (non-) touchscreen behaviour, try this:
'MIDORI_TOUCHSCREEN=0 _build_/default/midori/midori'
If you want to "dry run" without WebKitGTK+ rendering, try this:
'MIDORI_UNARMED=1 _build_/default/midori/midori'
For further information a tutorial for gdb and
reading up on how you can install debugging
symbols for libraries used by Midori are recommended.

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
Requirements: GTK+ 2.10, WebkitGTK+ 1.1.1, libXML2, libsoup 2.25.2, sqlite 3.0
Optional: Unique 0.9, libidn, sqlite 3.0, docutils, libnotify
Optional: Unique 0.9, libidn, docutils, libnotify, Vala
For installation instructions read INSTALL.

7
TODO
View file

@ -91,3 +91,10 @@ TODO:
. Draw rectangle with the mouse, x/y/x2/y2 in the statusbar (extension)
. Shared bookmarks and config
. Prevent dead tabs: download, aborted page
BOOKMARK ISSUES:
. Bookmark menu is not populated
. Bookmark toolbar is broken
. Import is broken
. Integration with locationbar search
. Remove separator from submenu before showing it

View file

@ -295,7 +295,9 @@ FormSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:
};
function initSuggestions () {
var inputs = document.getElementsByTagName("input");
var inputs = document.getElementsByTagName ("input");
if (inputs.length == 0)
return false;
for (i=0;i<inputs.length;i++)
{
@ -308,4 +310,5 @@ function initSuggestions () {
if (inputs[i].type == "text" && autocomplete != "off")
var smth = new AutoSuggestControl (inputs[i], new FormSuggestions (ename));
}
return true;
};

BIN
data/midori.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View file

@ -1,2 +1,2 @@
IDR_MAINFRAME ICON DISCARDABLE "../_build_/default/data/midori.ico"
IDR_MAINFRAME ICON DISCARDABLE "midori.ico"

View file

@ -1,4 +1,11 @@
[Yahoo]
name=Yahoo
text=Yahoo Web Search
uri=http://search.yahoo.com/search?p=
icon=
token=y
[Google]
name=Google
text=Web Search

View file

@ -30,7 +30,7 @@
}
#content {
margin-top: 10px;
margin-top: 40px;
}
div.shortcut {
@ -90,6 +90,11 @@
text-decoration: none;
}
div.shortcut a img {
width: 100%;
height: 100%;
}
.waiter img {
margin-top: 38px;
}
@ -142,23 +147,54 @@
}
div.config {
position: absolute;
top: 0px;
padding: 12px;
text-align: left;
}
div.config span {
color: #ccc;
margin-right: 10px;
margin-right: 10px;
}
div.config span:hover {
div.config span.config_option:hover {
color: #999;
cursor: pointer;
}
div.config span.config_label {
color: #ccc;
cursor: default;
margin-right: 0px;
}
div.config span.config_option {
margin-left: 0px;
margin-right: 0px;
}
div.osd {
top: 9px;
position: fixed;
width: 100%;
text-align: right;
}
div.osd span {
border: 1px solid #999;
background-color: #f5f5f5;
padding: 8px;
color: #999;
-webkit-border-bottom-left-radius: 10px;
visibility: hidden;
}
</style>
<script type="text/javascript">
sc = JSON.decode ({json_data});
var sc = JSON.decode ({json_data});
var encodeSafe = function (obj) {
var str = JSON.encode (obj);
@ -174,6 +210,8 @@
var url = prompt ("{enter_shortcut_address}", "http://");
if (!url) return false;
if (url.indexOf ("://") == -1)
url = "http://" + url;
var name = prompt ("{enter_shortcut_name}", "");
if (!name) name = "";
@ -227,10 +265,9 @@
var renameShortcut = function (id)
{
var name = prompt ("{enter_shortcut_name}", "");
if (!name) return;
var num = id.substr (1) - 1;
var name = prompt ("{enter_shortcut_name}", sc.shortcuts[num].title);
if (!name) return;
$(id).getLast ().set ('html', name);
sc.shortcuts[num].title = name;
@ -266,10 +303,18 @@
var buildSpeeddial = function ()
{
var width = 3;
var thumb = 160;
if (sc.thumb)
{
thumb = sc.thumb;
setThumbSize(thumb);
}
if (sc.width)
{
width = sc.width;
$('wrap').style.width = (width * 220) + 'px';
$('wrap').style.width = (width * (thumb + 60)) + 'px';
}
sc.shortcuts.each (function (item, index, sc)
@ -319,23 +364,39 @@
});
}
var setWidth = function ()
var setSize = function ()
{
var width = prompt ("{enter_dial_width}", "");
if (!width || isNaN (width)) return;
var rows = Math.ceil (sc.shortcuts.length / sc.width);
var size = prompt ("{enter_dial_size}", sc.width + 'x' + rows);
sc.width = width;
if (!size) return;
$('content').empty ();
buildSpeeddial ();
var pos = size.indexOf('x');
console.log ("speed_dial-save '" + encodeSafe (sc) + "'");
}
if (pos <= 0)
{
alert ("{invalid_dial_size}");
return;
}
var setCount = function ()
{
var count = prompt ("{enter_shortcut_count}", "");
if (!count || isNaN (count)) return;
var cols = size.substr(0, pos);
rows = size.substr(pos+1);
if (isNaN (cols) || isNaN (rows) || cols == 0 || rows == 0)
{
alert ("{invalid_dial_size}");
return;
}
if (size.indexOf('.') >= 0)
{
alert ("{invalid_dial_size}");
return;
}
sc.width = cols;
var count = cols * rows;
sc.shortcuts = sc.shortcuts.slice (0, count);
@ -352,30 +413,99 @@
console.log ("speed_dial-save '" + encodeSafe (sc) + "'");
}
var setThumbSize = function (size)
{
var i;
var rules = document.styleSheets[0].cssRules;
var width = 3;
if (sc.width)
width = sc.width;
var height = Math.round (size / 1.5);
$('wrap').style.width = (width * (size + 60)) + 'px';
for (i = 0; i < rules.length; i++)
{
switch (rules[i].selectorText)
{
case 'div.shortcut a':
rules[i].style.width = size + 'px';
rules[i].style.height = height + 'px';
break;
case 'div.shortcut':
rules[i].style.width = (size + 40) + 'px';
rules[i].style.height = (height + 43) + 'px';
break;
case '.cross':
rules[i].style.marginLeft = (size + 20) + 'px';
break;
case 'h1':
rules[i].style.fontSize = (size / 4 + 10) + 'px';
rules[i].style.height = (size / 4 - 10) + 'px';
break;
case 'h4 span::before':
rules[i].style.visibility = (size < 160) ? 'hidden' : 'visible';
break;
}
}
if (sc.thumb != size)
{
sc.thumb = size;
console.log ("speed_dial-save '" + encodeSafe (sc) + "'");
}
}
window.addEvent ('domready', function () {
buildSpeeddial ();
});
var key_id = 's';
var key_timeout;
document.onkeypress = function ()
{
var id = $('s' + String.fromCharCode (event.which));
key_id = key_id + String.fromCharCode (event.which);
if ($(id))
clearTimeout (key_timeout);
$('dialing').innerText = key_id.substr(1);
$('dialing').style.visibility = 'visible';
if ($(key_id))
{
if (getAction (id))
document.location = $(id).children[1];
return false;
if (key_id.substr(1) * 10 > sc.shortcuts.length)
{
if (getAction (key_id))
document.location = $(key_id).children[1];
key_id = 's';
}
else
key_timeout = setTimeout ('if (getAction (key_id)) document.location = $(key_id).children[1]; key_id = \'s\'', 3000);
}
else
key_id = 's';
return true
if (key_id.length <= 1)
$('dialing').style.visibility = 'hidden';
return false;
}
</script>
</head>
<body>
<div class="osd" >
<span id="dialing"></span>
</div>
<div class="config">
<span onclick="javascript:setWidth()">{set_dial_width}</span>
<span onclick="javascript:setCount()">{set_shortcut_count}</span>
<span onclick="javascript:setSize()" class="config_option">{set_dial_size}</span>
<span class="config_label">{set_thumb_size}</span>
<span onclick="javascript:setThumbSize(80)" class="config_option">{set_thumb_small}</span>
<span onclick="javascript:setThumbSize(160)" class="config_option">{set_thumb_normal}</span>
<span onclick="javascript:setThumbSize(240)" class="config_option">{set_thumb_big}</span>
</div>
<div id="wrap">
<div id="content">

View file

@ -591,7 +591,7 @@ adblock_browser_populate_tool_menu_cb (MidoriBrowser* browser,
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
}
static gboolean
static inline gboolean
adblock_check_filter_options (GRegex* regex,
const gchar* opts,
const gchar* req_uri,
@ -607,7 +607,7 @@ adblock_check_filter_options (GRegex* regex,
return FALSE;
}
static gboolean
static inline gboolean
adblock_is_matched_by_pattern (const gchar* req_uri,
const gchar* page_uri)
{
@ -634,7 +634,7 @@ adblock_is_matched_by_pattern (const gchar* req_uri,
return FALSE;
}
static gboolean
static inline gboolean
adblock_is_matched_by_key (const gchar* opts,
const gchar* req_uri,
const gchar* page_uri)
@ -1059,6 +1059,8 @@ adblock_fixup_regexp (gchar* src)
case '^':
g_string_append (str, "");
break;
case '+':
break;
default:
g_string_append_printf (str,"%c", *src);
break;
@ -1347,6 +1349,8 @@ adblock_deactivate_cb (MidoriExtension* extension,
extension, adblock_deactivate_cb, browser);
g_signal_handlers_disconnect_by_func (
app, adblock_app_add_browser_cb, extension);
g_signal_handlers_disconnect_by_func (
browser, adblock_add_tab_cb, extension);
midori_browser_foreach (browser, (GtkCallback)adblock_deactivate_tabs, browser);
katze_assign (blockcss, NULL);
@ -1407,6 +1411,7 @@ test_adblock_parse (void)
g_assert (!adblock_parse_line ("##"));
g_assert (!adblock_parse_line ("["));
g_assert_cmpstr (adblock_parse_line ("+advert/"), ==, "advert/");
g_assert_cmpstr (adblock_parse_line ("*foo"), ==, "foo");
g_assert_cmpstr (adblock_parse_line ("f*oo"), ==, "f.*oo");
g_assert_cmpstr (adblock_parse_line ("?foo"), ==, "\\?foo");

109
extensions/copy-tabs.c Normal file
View file

@ -0,0 +1,109 @@
/*
Copyright (C) 2008-2010 Christian Dywan <christian@twotoasts.de>
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.
*/
#include <midori/midori.h>
#include <midori/sokoke.h>
static void
copy_tabs_apply_cb (GtkWidget* menuitem,
MidoriBrowser* browser)
{
guint i = 0;
GtkWidget* view;
gchar* text = g_strdup ("");
GtkClipboard* clipboard = gtk_widget_get_clipboard (menuitem,
GDK_SELECTION_CLIPBOARD);
while ((view = midori_browser_get_nth_tab (browser, i++)))
{
gchar* new_text = g_strconcat (text,
midori_view_get_display_uri (MIDORI_VIEW (view)), "\n", NULL);
katze_assign (text, new_text);
}
gtk_clipboard_set_text (clipboard, text, -1);
}
static void
copy_tabs_browser_populate_tool_menu_cb (MidoriBrowser* browser,
GtkWidget* menu,
MidoriExtension* extension)
{
GtkWidget* menuitem = gtk_menu_item_new_with_mnemonic (_("Copy Tab _Addresses"));
g_signal_connect (menuitem, "activate",
G_CALLBACK (copy_tabs_apply_cb), browser);
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
}
static void
copy_tabs_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser,
MidoriExtension* extension);
static void
copy_tabs_deactivate_cb (MidoriExtension* extension,
MidoriBrowser* browser)
{
MidoriApp* app = midori_extension_get_app (extension);
g_signal_handlers_disconnect_by_func (
browser, copy_tabs_browser_populate_tool_menu_cb, extension);
g_signal_handlers_disconnect_by_func (
extension, copy_tabs_deactivate_cb, browser);
g_signal_handlers_disconnect_by_func (
app, copy_tabs_app_add_browser_cb, extension);
}
static void
copy_tabs_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser,
MidoriExtension* extension)
{
g_signal_connect (browser, "populate-tool-menu",
G_CALLBACK (copy_tabs_browser_populate_tool_menu_cb), extension);
g_signal_connect (extension, "deactivate",
G_CALLBACK (copy_tabs_deactivate_cb), browser);
}
static void
copy_tabs_activate_cb (MidoriExtension* extension,
MidoriApp* app)
{
KatzeArray* browsers;
MidoriBrowser* browser;
guint i;
browsers = katze_object_get_object (app, "browsers");
i = 0;
while ((browser = katze_array_get_nth_item (browsers, i++)))
copy_tabs_app_add_browser_cb (app, browser, extension);
g_object_unref (browsers);
g_signal_connect (app, "add-browser",
G_CALLBACK (copy_tabs_app_add_browser_cb), extension);
}
MidoriExtension*
extension_init (void)
{
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", _("Copy Addresses of Tabs"),
"description", _("Copy the addresses of all tabs to the clipboard"),
"version", "0.1",
"authors", "MonkeyOfDoom <pixelmonkey@ensellitis.com>",
NULL);
g_signal_connect (extension, "activate",
G_CALLBACK (copy_tabs_activate_cb), NULL);
return extension;
}

View file

@ -90,8 +90,8 @@ public class ExternalApplications : Midori.Extension {
}
}
internal ExternalApplications () {
GLib.Object (name: "External Applications",
description: "Associate URL schemes with external commands",
GLib.Object (name: _("External Applications"),
description: _("Associate URL schemes with external commands"),
version: "0.1",
authors: "Christian Dywan <christian@twotoasts.de>");
activate.connect (activated);

View file

@ -30,7 +30,6 @@ struct _FeedPanel
GtkWidget* webview;
GtkWidget* delete;
GdkPixbuf* pixbuf;
KatzeNet* net;
};
struct _FeedPanelClass
@ -750,7 +749,6 @@ feed_panel_finalize (GObject* object)
FeedPanel* panel = FEED_PANEL (object);
g_object_unref (panel->pixbuf);
g_object_unref (panel->net);
}
static void
@ -826,8 +824,6 @@ feed_panel_init (FeedPanel* panel)
gtk_icon_factory_add_default (factory);
g_object_unref (factory);
panel->net = katze_net_new ();
model = gtk_tree_store_new (1, KATZE_TYPE_ITEM);
treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
panel->treeview = treeview;

View file

@ -100,8 +100,11 @@ feed_get_element_date (FeedParser* fparser)
SoupDate* sdate;
sdate = soup_date_new_from_string (content);
date = soup_date_to_time_t (sdate);
soup_date_free (sdate);
if (sdate)
{
date = soup_date_to_time_t (sdate);
soup_date_free (sdate);
}
g_free (content);
}
return ((gint64)date);

View file

@ -76,7 +76,7 @@ rss_update (FeedParser* fparser)
fparser->node = child;
newdate = feed_get_element_date (fparser);
fparser->node = node;
return (date != newdate);
return (date != newdate || date == 0);
}
}
child = child->next;

View file

@ -40,7 +40,6 @@ typedef struct
MidoriExtension* extension;
GtkWidget* panel;
KatzeArray* feeds;
KatzeNet* net;
GSList* parsers;
guint source_id;
@ -96,8 +95,6 @@ feed_deactivate_cb (MidoriExtension* extension,
g_source_remove (priv->source_id);
g_slist_foreach (priv->parsers, (GFunc)g_free, NULL);
g_slist_free (priv->parsers);
if (priv->feeds)
g_object_unref (priv->net);
if (priv->feeds)
g_object_unref (priv->feeds);
gtk_widget_destroy (priv->panel);
@ -286,7 +283,7 @@ update_feed (FeedPrivate* priv,
netpriv->extension = priv->extension;
netpriv->feed = KATZE_ARRAY (feed);
katze_net_load_uri (priv->net,
katze_net_load_uri (NULL,
katze_item_get_uri (feed),
(KatzeNetStatusCb) feed_status_cb,
(KatzeNetTransferCb) feed_transfer_cb,
@ -437,7 +434,6 @@ feed_app_add_browser_cb (MidoriApp* app,
GtkWidget* addon;
GtkActionGroup* action_group;
GtkAction* action;
KatzeNet* net;
KatzeArray* feeds;
KatzeArray* feed;
FeedPrivate* priv;
@ -453,14 +449,12 @@ feed_app_add_browser_cb (MidoriApp* app,
midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));
g_object_unref (panel);
net = katze_net_new ();
feeds = katze_array_new (KATZE_TYPE_ARRAY);
feed_panel_add_feeds (FEED_PANEL (addon), KATZE_ITEM (feeds));
priv->extension = extension;
priv->browser = browser;
priv->panel = addon;
priv->net = net;
priv->feeds = feeds;
priv->parsers = g_slist_prepend (priv->parsers, atom_init_parser ());
priv->parsers = g_slist_prepend (priv->parsers, rss_init_parser ());

View file

@ -21,9 +21,7 @@
#include <unistd.h>
#endif
#if HAVE_SQLITE
#include <sqlite3.h>
#endif
#include <sqlite3.h>
static GHashTable* global_keys;
static gchar* jsforms;
@ -64,7 +62,8 @@ formhistory_prepare_js ()
"function () {"
" if (document.getElementById('formhistory'))"
" return;"
" initSuggestions ();"
" if (!initSuggestions ())"
" return;"
" var mystyle = document.createElement('style');"
" mystyle.setAttribute('type', 'text/css');"
" mystyle.setAttribute('id', 'formhistory');"
@ -129,7 +128,6 @@ formhistory_update_database (gpointer db,
const gchar* key,
const gchar* value)
{
#if HAVE_SQLITE
gchar* sqlcmd;
gchar* errmsg;
gint success;
@ -145,7 +143,6 @@ formhistory_update_database (gpointer db,
g_free (errmsg);
return;
}
#endif
}
static gboolean
@ -161,20 +158,24 @@ formhistory_update_main_hash (gchar* key,
if (length > MAXCHARS || length < MINCHARS)
return FALSE;
formhistory_fixup_value (key);
formhistory_fixup_value (value);
if ((tmp = g_hash_table_lookup (global_keys, (gpointer)key)))
{
gchar* rvalue = g_strdup_printf ("\"%s\"",value);
if (!g_regex_match_simple (rvalue, tmp,
gchar* patt = g_regex_escape_string (rvalue, -1);
if (!g_regex_match_simple (patt, tmp,
G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY))
{
gchar* new_value = g_strdup_printf ("%s%s,", tmp, rvalue);
g_hash_table_insert (global_keys, g_strdup (key), new_value);
g_free (rvalue);
g_free (patt);
}
else
{
g_free (rvalue);
g_free (patt);
return FALSE;
}
}
@ -201,6 +202,8 @@ formhistory_navigation_decision_cb (WebKitWebView* web_view,
const gchar* script = "function dumpForm (inputs) {"
" var out = '';"
" for (i=0;i<inputs.length;i++) {"
" if (inputs[i].getAttribute('autocomplete') == 'off')"
" continue;"
" if (inputs[i].value && (inputs[i].type == 'text' || inputs[i].type == 'password')) {"
" var ename = inputs[i].getAttribute('name');"
" var eid = inputs[i].getAttribute('id');"
@ -365,9 +368,7 @@ formhistory_deactivate_cb (MidoriExtension* extension,
MidoriBrowser* browser)
{
MidoriApp* app = midori_extension_get_app (extension);
#if HAVE_SQLITE
sqlite3* db;
#endif
g_signal_handlers_disconnect_by_func (
browser, formhistory_add_tab_cb, extension);
@ -382,13 +383,10 @@ formhistory_deactivate_cb (MidoriExtension* extension,
if (global_keys)
g_hash_table_destroy (global_keys);
#if HAVE_SQLITE
if ((db = g_object_get_data (G_OBJECT (extension), "formhistory-db")))
sqlite3_close (db);
#endif
}
#if HAVE_SQLITE
static int
formhistory_add_field (gpointer data,
int argc,
@ -416,18 +414,15 @@ formhistory_add_field (gpointer data,
}
return 0;
}
#endif
static void
formhistory_activate_cb (MidoriExtension* extension,
MidoriApp* app)
{
#if HAVE_SQLITE
const gchar* config_dir;
gchar* filename;
sqlite3* db;
char* errmsg = NULL, *errmsg2 = NULL;
#endif
KatzeArray* browsers;
MidoriBrowser* browser;
guint i;
@ -437,7 +432,6 @@ formhistory_activate_cb (MidoriExtension* extension,
(GDestroyNotify)g_free);
if(!jsforms)
formhistory_prepare_js ();
#if HAVE_SQLITE
config_dir = midori_extension_get_config_dir (extension);
katze_mkdir_with_parents (config_dir, 0700);
filename = g_build_filename (config_dir, "forms.db", NULL);
@ -468,7 +462,6 @@ formhistory_activate_cb (MidoriExtension* extension,
}
sqlite3_close (db);
}
#endif
browsers = katze_object_get_object (app, "browsers");
i = 0;

View file

@ -0,0 +1,257 @@
/*
Copyright (C) 2010 André Stösel <Midori-Plugin@PyIT.de>
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.
*/
using Gtk;
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);
}
public 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);
}
public abstract void make_update ();
}
private class TabWindow : HistoryWindow {
public TabWindow (Midori.Browser browser) {
base (browser);
var hbox = new Gtk.HBox (false, 1);
this.add (hbox);
var sw = new Gtk.ScrolledWindow (null, null);
sw.set_size_request (320, 20);
sw.set_policy (PolicyType.NEVER , PolicyType.AUTOMATIC);
sw.set_shadow_type (ShadowType.ETCHED_IN);
hbox.pack_start (sw, true, true, 0);
var store = new Gtk.ListStore (TabTreeCells.TREE_CELL_COUNT,
typeof (Gdk.Pixbuf), typeof (string), typeof (void*));
Gtk.TreeIter iter;
unowned GLib.PtrArray list = this.browser.get_data<GLib.PtrArray> ("history-list-tab-history");
for (var i = list.len; i > 0; i--) {
Midori.View view = list.index (i - 1) as Midori.View;
Gdk.Pixbuf? icon = null;
view.get ("icon", ref icon);
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);
}
this.set_default_size (320, list.len > 10 ? 232 : (int) list.len * 23 + 2);
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);
this.show_all ();
}
public override void make_update () {
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);
}
}
private class HistoryList : Midori.Extension {
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) {
browser.disconnect (this.tmp_sig_ids[0]);
browser.disconnect (this.tmp_sig_ids[1]);
this.history_window.make_update ();
this.history_window.destroy ();
this.history_window = null;
}
}
return false;
}
public void walk (Gtk.Action action, Browser browser, Type type, int step) {
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);
}
}
var hw = this.history_window as HistoryWindow;
hw.walk (step);
}
void browser_added (Midori.Browser browser) {
var acg = new Gtk.AccelGroup ();
browser.add_accel_group (acg);
var action_group = browser.get_action_group ();
Gtk.Action action;
action = new Gtk.Action ("HistoryListNextTab",
_("Next Tab (History List)"),
_("Next tab from history"), null);
action.activate.connect ((a) => {
this.walk (a, browser, typeof (TabWindow), 1);
});
action_group.add_action_with_accel (action, "<Ctrl>Tab");
action.set_accel_group (acg);
action.connect_accelerator ();
action = new Gtk.Action ("HistoryListPreviousTab",
_("Previous Tab (History List)"),
_("Previous tab from history"), null);
action.activate.connect ((a) => {
this.walk (a, browser, typeof (TabWindow), -1);
});
action_group.add_action_with_accel (action, "<Ctrl><Shift>Tab");
action.set_accel_group (acg);
action.connect_accelerator ();
browser.set_data<GLib.PtrArray*> ("history-list-tab-history",
new GLib.PtrArray ());
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 = { "HistoryListNextTab", "HistoryListPreviousTab" };
Gtk.ActionGroup action_group;
action_group = browser.get_action_group ();
for (int i = 0; i < callbacks.length; i++) {
Gtk.Action 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_added (Midori.Browser browser, Midori.View view) {
unowned GLib.PtrArray list = browser.get_data<GLib.PtrArray> ("history-list-tab-history");
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");
list.remove (view);
}
void tab_changed (GLib.Object window, GLib.ParamSpec pspec) {
Midori.Browser browser = window as Midori.Browser;
Midori.View view = null;
browser.get ("tab", ref view);
unowned GLib.PtrArray list = browser.get_data<GLib.PtrArray> ("history-list-tab-history");
list.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: _("Allows to switch tabs by choosing from a list sorted by last usage"),
version: "0.2",
authors: "André Stösel <Midori-Plugin@PyIT.de>");
activate.connect (activated);
deactivate.connect (deactivated);
}
}
public Midori.Extension extension_init () {
return new HistoryList ();
}

View file

@ -173,7 +173,7 @@ MidoriExtension*
extension_init (void)
{
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", _("Status clock"),
"name", _("Statusbar Clock"),
"description", _("Display date and time in the statusbar"),
"version", "0.1",
"authors", "Arno Renevier <arno@renevier.net>",

View file

@ -0,0 +1,90 @@
/*
Copyright (C) 2008-2010 Christian Dywan <christian@twotoasts.de>
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.
*/
#include <midori/midori.h>
#include <midori/sokoke.h>
static void
tabs_minimized_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser,
MidoriExtension* extension);
static void
tabs_minimized_add_tab_cb (MidoriBrowser* browser,
MidoriView* tab,
MidoriExtension* extension);
static void
tabs_minimized_deactivate_cb (MidoriExtension* extension,
MidoriBrowser* browser)
{
MidoriApp* app = midori_extension_get_app (extension);
g_signal_handlers_disconnect_by_func (
extension, tabs_minimized_deactivate_cb, browser);
g_signal_handlers_disconnect_by_func (
app, tabs_minimized_app_add_browser_cb, extension);
g_signal_handlers_disconnect_by_func (
browser, tabs_minimized_add_tab_cb, extension);
}
static void
tabs_minimized_add_tab_cb (MidoriBrowser* browser,
MidoriView* tab,
MidoriExtension* extension)
{
g_object_set (tab, "minimized", TRUE, NULL);
}
static void
tabs_minimized_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser,
MidoriExtension* extension)
{
g_signal_connect (browser, "add-tab",
G_CALLBACK (tabs_minimized_add_tab_cb), extension);
g_signal_connect (extension, "deactivate",
G_CALLBACK (tabs_minimized_deactivate_cb), browser);
}
static void
tabs_minimized_activate_cb (MidoriExtension* extension,
MidoriApp* app)
{
KatzeArray* browsers;
MidoriBrowser* browser;
guint i;
browsers = katze_object_get_object (app, "browsers");
i = 0;
while ((browser = katze_array_get_nth_item (browsers, i++)))
tabs_minimized_app_add_browser_cb (app, browser, extension);
g_object_unref (browsers);
g_signal_connect (app, "add-browser",
G_CALLBACK (tabs_minimized_app_add_browser_cb), extension);
}
MidoriExtension*
extension_init (void)
{
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", _("Minimize new Tabs"),
"description", _("New tabs open minimized"),
"version", "0.1",
"authors", "MonkeyOfDoom <pixelmonkey@ensellitis.com>",
NULL);
g_signal_connect (extension, "activate",
G_CALLBACK (tabs_minimized_activate_cb), NULL);
return extension;
}

View file

@ -36,6 +36,8 @@ def add_image (bld, category, name):
else:
Utils.pprint ('BLUE', "Optimized icons could not be created.")
break
bld.install_files ('${MDATADIR}/icons/hicolor/scalable/' + category,
srcdir + '/icons/scalable/' + name + '.svg')
add_image (bld, 'categories', 'extension')
add_image (bld, 'apps', 'midori')

View file

@ -595,6 +595,32 @@ katze_item_get_meta_integer (KatzeItem* item,
return -1;
}
/**
* katze_item_get_meta_boolean:
* @item: a #KatzeItem
* @key: the name of a boolean value
*
* The Value should be set with katze_item_set_meta_integer().
* If the value is set and not 0, %TRUE will be returned.
*
* Since: 0.2.7
**/
gboolean
katze_item_get_meta_boolean (KatzeItem* item,
const gchar* key)
{
const gchar* value;
g_return_val_if_fail (KATZE_IS_ITEM (item), FALSE);
g_return_val_if_fail (key != NULL, FALSE);
value = katze_item_get_meta_string (item, key);
if (value == NULL || value[0] == '0')
return FALSE;
else
return TRUE;
}
/**
* katze_item_set_meta_integer:
* @item: a #KatzeItem

View file

@ -28,6 +28,9 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_ITEM))
#define KATZE_ITEM_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_ITEM, KatzeItemClass))
#define KATZE_ITEM_IS_BOOKMARK(item) (item && katze_item_get_uri (item))
#define KATZE_ITEM_IS_FOLDER(item) (item && !katze_item_get_uri (item))
#define KATZE_ITEM_IS_SEPARATOR(item) (item == NULL)
typedef struct _KatzeItem KatzeItem;
typedef struct _KatzeItemClass KatzeItemClass;
@ -118,6 +121,10 @@ gint64
katze_item_get_meta_integer (KatzeItem* item,
const gchar* key);
gboolean
katze_item_get_meta_boolean (KatzeItem* item,
const gchar* key);
void
katze_item_set_meta_integer (KatzeItem* item,
const gchar* key,

View file

@ -77,6 +77,8 @@ katze_net_finalize (GObject* object)
* Instantiates a new #KatzeNet instance.
*
* Return value: a new #KatzeNet
*
* Deprecated: 0.2.7
**/
KatzeNet*
katze_net_new (void)
@ -102,14 +104,14 @@ katze_net_new (void)
*
* Return value: a session, or %NULL
*
* Since: 0.1.3
* Deprecated: 0.2.7: Use webkit_get_default_session ().
**/
gpointer
katze_net_get_session (KatzeNet* net)
{
g_return_val_if_fail (KATZE_IS_NET (net), NULL);
return net->session;
return webkit_get_default_session ();
}
typedef struct
@ -147,6 +149,9 @@ katze_net_get_cached_path (KatzeNet* net,
gchar* cached_filename;
gchar* cached_path;
if (!net)
net = katze_net_new ();
if (subfolder)
cache_path = g_build_filename (net->cache_path, subfolder, NULL);
else
@ -301,7 +306,7 @@ katze_net_default_cb (KatzeNetPriv* priv)
/**
* katze_net_load_uri:
* @net: a #KatzeNet
* @net: a #KatzeNet, or %NULL
* @uri: an URI string
* @status_cb: function to call for status information
* @transfer_cb: function to call upon transfer
@ -330,12 +335,14 @@ katze_net_load_uri (KatzeNet* net,
KatzeNetPriv* priv;
SoupMessage* msg;
g_return_if_fail (KATZE_IS_NET (net));
g_return_if_fail (uri != NULL);
if (!status_cb && !transfer_cb)
return;
if (net == NULL)
net = katze_net_new ();
request = g_new0 (KatzeNetRequest, 1);
request->uri = g_strdup (uri);
request->mime_type = NULL;

View file

@ -10,6 +10,7 @@
*/
#include "katze-utils.h"
#include "katze-array.h"
#include <glib/gstdio.h>
#include <glib/gi18n.h>
@ -1123,6 +1124,37 @@ katze_tree_view_get_selected_iter (GtkTreeView* treeview,
return FALSE;
}
void
katze_bookmark_populate_tree_view (KatzeArray* array,
GtkTreeStore* model,
GtkTreeIter* parent)
{
KatzeItem* child;
GtkTreeIter iter;
GtkTreeIter root_iter;
guint i = 0;
while ((child = katze_array_get_nth_item (KATZE_ARRAY (array), i)))
{
if (KATZE_ITEM_IS_BOOKMARK (child))
{
gchar* tooltip = g_markup_escape_text (katze_item_get_uri (child), -1);
gtk_tree_store_insert_with_values (model, NULL, parent,
0, 0, child, 1, tooltip, -1);
g_free (tooltip);
}
else
{
gtk_tree_store_insert_with_values (model, &root_iter, parent,
0, 0, child, -1);
/* That's an invisible dummy, so we always have an expander */
gtk_tree_store_insert_with_values (model, &iter, &root_iter,
0, 0, NULL, -1);
}
i++;
}
}
/**
* katze_strip_mnemonics:
* @original: a string with mnemonics

View file

@ -14,6 +14,7 @@
#define __KATZE_UTILS_H__
#include <gtk/gtk.h>
#include "katze-array.h"
G_BEGIN_DECLS
@ -105,9 +106,14 @@ katze_pixbuf_new_from_buffer (const guchar* buffer,
GError** error);
gboolean
katze_tree_view_get_selected_iter (GtkTreeView* treeview,
GtkTreeModel** model,
GtkTreeIter* iter);
katze_tree_view_get_selected_iter (GtkTreeView* treeview,
GtkTreeModel** model,
GtkTreeIter* iter);
void
katze_bookmark_populate_tree_view (KatzeArray* array,
GtkTreeStore* model,
GtkTreeIter* parent);
gchar*
katze_strip_mnemonics (const gchar* original);

View file

@ -33,10 +33,7 @@
#include <string.h>
#include <glib/gstdio.h>
#include <webkit/webkit.h>
#if HAVE_SQLITE
#include <sqlite3.h>
#endif
#include <sqlite3.h>
#if ENABLE_NLS
#include <libintl.h>
@ -351,16 +348,17 @@ search_engines_save_to_file (KatzeArray* search_engines,
return saved;
}
#if HAVE_SQLITE
static sqlite3*
midori_history_initialize (KatzeArray* array,
const gchar* filename,
const gchar* bookmarks_filename,
char** errmsg)
{
sqlite3* db;
gboolean has_day;
sqlite3_stmt* stmt;
gint result;
gchar* sql;
has_day = FALSE;
@ -377,11 +375,7 @@ midori_history_initialize (KatzeArray* array,
"CREATE TABLE IF NOT EXISTS "
"history (uri text, title text, date integer, day integer);"
"CREATE TABLE IF NOT EXISTS "
"search (keywords text, uri text, day integer);"
"CREATE TEMP VIEW history_view AS SELECT "
"1 AS type, uri, title, day FROM history;"
"CREATE TEMP VIEW search_view AS SELECT "
"2 AS type, uri, keywords AS title, day FROM search;",
"search (keywords text, uri text, day integer);",
NULL, NULL, errmsg) != SQLITE_OK)
return NULL;
@ -405,6 +399,11 @@ midori_history_initialize (KatzeArray* array,
"DROP TABLE backup;"
"COMMIT;",
NULL, NULL, errmsg);
sql = g_strdup_printf ("ATTACH DATABASE '%s' AS bookmarks", bookmarks_filename);
sqlite3_exec (db, sql, NULL, NULL, errmsg);
g_free (sql);
return db;
}
@ -428,7 +427,94 @@ midori_history_terminate (sqlite3* db,
g_free (sqlcmd);
sqlite3_close (db);
}
#endif
static void
midori_bookmarks_remove_item_cb (KatzeArray* array,
KatzeItem* item,
sqlite3* db)
{
gchar* sqlcmd;
char* errmsg = NULL;
if (KATZE_ITEM_IS_BOOKMARK (item))
sqlcmd = sqlite3_mprintf (
"DELETE FROM bookmarks WHERE uri = '%q' "
" AND folder = '%q'",
katze_item_get_uri (item),
katze_item_get_meta_string (item, "folder"));
else
sqlcmd = sqlite3_mprintf (
"DELETE FROM bookmarks WHERE title = '%q'"
" AND folder = '%q'",
katze_item_get_name (item),
katze_item_get_meta_string (item, "folder"));
if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK)
{
g_printerr (_("Failed to remove history item: %s\n"), errmsg);
sqlite3_free (errmsg);
}
sqlite3_free (sqlcmd);
}
static sqlite3*
midori_bookmarks_initialize (KatzeArray* array,
const gchar* filename,
char** errmsg)
{
sqlite3* db;
if (sqlite3_open (filename, &db) != SQLITE_OK)
{
if (errmsg)
*errmsg = g_strdup_printf (_("Failed to open database: %s\n"),
sqlite3_errmsg (db));
sqlite3_close (db);
return NULL;
}
if (sqlite3_exec (db,
"CREATE TABLE IF NOT EXISTS "
"bookmarks (uri text, title text, folder text, "
"desc text, app integer, toolbar integer);",
NULL, NULL, errmsg) != SQLITE_OK)
return NULL;
g_signal_connect (array, "remove-item",
G_CALLBACK (midori_bookmarks_remove_item_cb), db);
return db;
}
static void
midori_bookmarks_import (const gchar* filename,
sqlite3* db)
{
KatzeArray* bookmarks;
GError* error = NULL;
bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
if (!midori_array_from_file (bookmarks, filename, "xbel", &error))
{
g_warning (_("The bookmarks couldn't be saved. %s"), error->message);
g_error_free (error);
return;
}
midori_bookmarks_import_array_db (db, bookmarks, "");
}
static void
midori_session_add_delay (KatzeArray* session)
{
KatzeItem* item;
gint i = 0;
while ((item = katze_array_get_nth_item (session, i++)))
{
if (katze_item_get_meta_integer (item, "delay") < 0)
katze_item_set_meta_integer (item, "delay", 1);
}
}
static void
settings_notify_cb (MidoriWebSettings* settings,
@ -487,105 +573,6 @@ midori_search_engines_modify_cb (KatzeArray* array,
g_free (config_file);
}
static void
midori_bookmarks_notify_item_cb (KatzeArray* folder,
GParamSpec* pspec,
KatzeArray* bookmarks)
{
gchar* config_file;
GError* error;
config_file = build_config_filename (BOOKMARK_FILE);
error = NULL;
if (!midori_array_to_file (bookmarks, config_file, "xbel", &error))
{
g_warning (_("The bookmarks couldn't be saved. %s"), error->message);
g_error_free (error);
}
g_free (config_file);
}
static void
midori_bookmarks_add_item_cb (KatzeArray* folder,
KatzeItem* item,
KatzeArray* bookmarks);
static void
midori_bookmarks_remove_item_cb (KatzeArray* folder,
GObject* item,
KatzeArray* bookmarks);
static void
midori_bookmarks_connect_item (KatzeArray* folder,
KatzeItem* item,
KatzeArray* bookmarks)
{
if (KATZE_IS_ARRAY (item))
{
KatzeItem* child;
guint i = 0;
while ((child = katze_array_get_nth_item ((KatzeArray*)item, i++)))
midori_bookmarks_connect_item ((KatzeArray*)item, child, bookmarks);
g_signal_connect_after (item, "add-item",
G_CALLBACK (midori_bookmarks_add_item_cb), bookmarks);
g_signal_connect_after (item, "remove-item",
G_CALLBACK (midori_bookmarks_remove_item_cb), bookmarks);
}
g_signal_connect_after (item, "notify",
G_CALLBACK (midori_bookmarks_notify_item_cb), bookmarks);
}
static void
midori_bookmarks_add_item_cb (KatzeArray* folder,
KatzeItem* item,
KatzeArray* bookmarks)
{
gchar* config_file;
GError* error;
config_file = build_config_filename (BOOKMARK_FILE);
error = NULL;
if (!midori_array_to_file (bookmarks, config_file, "xbel", &error))
{
g_warning (_("The bookmarks couldn't be saved. %s"), error->message);
g_error_free (error);
}
g_free (config_file);
midori_bookmarks_connect_item (folder, item, bookmarks);
}
static void
midori_bookmarks_remove_item_cb (KatzeArray* folder,
GObject* item,
KatzeArray* bookmarks)
{
gchar* config_file;
GError* error;
config_file = build_config_filename (BOOKMARK_FILE);
error = NULL;
if (!midori_array_to_file (bookmarks, config_file, "xbel", &error))
{
g_warning (_("The bookmarks couldn't be saved. %s"), error->message);
g_error_free (error);
}
g_free (config_file);
if (KATZE_IS_ARRAY (item))
{
g_signal_handlers_disconnect_by_func (item,
midori_bookmarks_add_item_cb, bookmarks);
g_signal_handlers_disconnect_by_func (item,
midori_bookmarks_remove_item_cb, bookmarks);
}
g_signal_handlers_disconnect_by_func (item,
midori_bookmarks_notify_item_cb, bookmarks);
}
static void
midori_trash_add_item_cb (KatzeArray* trash,
GObject* item)
@ -872,7 +859,7 @@ midori_soup_session_prepare (SoupSession* session,
soup_session_settings_notify_http_proxy_cb (settings, NULL, session);
g_signal_connect (settings, "notify::http-proxy",
G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
g_signal_connect (settings, "notify::auto-detect-proxy",
g_signal_connect (settings, "notify::proxy-type",
G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
#if !WEBKIT_CHECK_VERSION (1, 1, 11)
@ -1153,13 +1140,17 @@ midori_load_extensions (gpointer data)
(gpointer) &extension_init))
{
extension = extension_init ();
/* Signal that we want the extension to load and save */
g_object_set_data_full (G_OBJECT (extension), "filename",
g_strdup (filename), g_free);
if (midori_extension_is_prepared (extension))
midori_extension_get_config_dir (extension);
if (extension != NULL)
{
/* Signal that we want the extension to load and save */
g_object_set_data_full (G_OBJECT (extension), "filename",
g_strdup (filename), g_free);
if (midori_extension_is_prepared (extension))
midori_extension_get_config_dir (extension);
}
}
else
if (!extension)
{
extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", filename,
@ -1188,7 +1179,8 @@ midori_load_extensions (gpointer data)
}
g_strfreev (active_extensions);
g_idle_add (midori_load_netscape_plugins, app);
if (g_getenv ("MIDORI_UNARMED") == NULL)
g_idle_add (midori_load_netscape_plugins, app);
#ifdef G_ENABLE_DEBUG
if (startup_timer)
@ -1230,11 +1222,13 @@ midori_load_session (gpointer data)
KatzeArray* _session = KATZE_ARRAY (data);
MidoriBrowser* browser;
MidoriApp* app = katze_item_get_parent (KATZE_ITEM (_session));
MidoriWebSettings* settings = katze_object_get_object (app, "settings");
gchar* config_file;
KatzeArray* session;
KatzeItem* item;
guint i;
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;
@ -1263,14 +1257,13 @@ 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);
if (katze_array_is_empty (_session))
{
MidoriWebSettings* settings = katze_object_get_object (app, "settings");
MidoriStartup load_on_startup;
gchar* homepage;
item = katze_item_new ();
g_object_get (settings, "load-on-startup", &load_on_startup, NULL);
if (load_on_startup == MIDORI_STARTUP_BLANK_PAGE)
katze_item_set_uri (item, "");
else
@ -1279,11 +1272,13 @@ midori_load_session (gpointer data)
katze_item_set_uri (item, homepage);
g_free (homepage);
}
g_object_unref (settings);
katze_array_add_item (_session, item);
g_object_unref (item);
}
if (load_on_startup == MIDORI_STARTUP_DELAYED_PAGES)
midori_session_add_delay (_session);
session = midori_browser_get_proxy_array (browser);
i = 0;
while ((item = katze_array_get_nth_item (_session, i++)))
@ -1297,13 +1292,13 @@ midori_load_session (gpointer data)
midori_browser_set_current_page (browser, current);
if (!(item = katze_array_get_nth_item (_session, current)))
item = katze_array_get_nth_item (_session, 0);
if (!strcmp (katze_item_get_uri (item), ""))
if (!g_strcmp0 (katze_item_get_uri (item), ""))
midori_browser_activate_action (browser, "Location");
g_object_unref (settings);
g_object_unref (_session);
katze_assign (config_file, build_config_filename ("session.xbel"));
g_signal_connect_after (browser, "notify::uri",
G_CALLBACK (midori_browser_session_cb), session);
g_signal_connect_after (browser, "add-tab",
G_CALLBACK (midori_browser_session_cb), session);
g_signal_connect_after (browser, "remove-tab",
@ -1541,6 +1536,7 @@ main (int argc,
gchar* webapp;
gchar* config;
gboolean diagnostic_dialog;
gboolean back_from_crash;
gboolean run;
gchar* snapshot;
gboolean execute;
@ -1586,6 +1582,7 @@ main (int argc,
gchar** extensions;
MidoriWebSettings* settings;
gchar* config_file;
gchar* bookmarks_file;
MidoriStartup load_on_startup;
KatzeArray* search_engines;
KatzeArray* bookmarks;
@ -1596,11 +1593,9 @@ main (int argc,
gchar* uri;
KatzeItem* item;
gchar* uri_ready;
#if HAVE_SQLITE
gchar* errmsg;
sqlite3* db;
gint max_history_age;
#endif
gint clear_prefs = MIDORI_CLEAR_NONE;
#ifdef G_ENABLE_DEBUG
gboolean startup_timer = g_getenv ("MIDORI_STARTTIME") != NULL;
@ -1649,6 +1644,7 @@ main (int argc,
/* Parse cli options */
webapp = NULL;
config = NULL;
back_from_crash = FALSE;
diagnostic_dialog = FALSE;
run = FALSE;
snapshot = NULL;
@ -1733,10 +1729,30 @@ main (int argc,
gchar* tmp_uri = midori_prepare_uri (webapp);
katze_assign (webapp, tmp_uri);
midori_startup_timer ("Browser: \t%f");
settings = katze_object_get_object (browser, "settings");
if (config)
{
SoupSession* session;
SoupCookieJar* jar;
config_file = g_build_filename (config, "config", NULL);
settings = settings_new_from_file (config_file, &extensions);
g_free (config_file);
g_strfreev (extensions);
session = webkit_get_default_session ();
config_file = g_build_filename (config, "cookies.txt", NULL);
jar = soup_cookie_jar_text_new (config_file, TRUE);
g_free (config_file);
soup_session_add_feature (session, SOUP_SESSION_FEATURE (jar));
g_object_unref (jar);
}
else
settings = katze_object_get_object (browser, "settings");
g_object_set (settings,
"show-menubar", FALSE,
"show-navigationbar", TRUE,
"show-panel", FALSE,
"toolbar-items", "Back,Forward,ReloadStop,Location",
"homepage", NULL,
"show-statusbar", TRUE,
@ -1904,29 +1920,31 @@ main (int argc,
midori_startup_timer ("Search read: \t%f");
bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
#if HAVE_LIBXML
katze_assign (config_file, build_config_filename (BOOKMARK_FILE));
error = NULL;
if (!midori_array_from_file (bookmarks, config_file, "xbel", &error))
bookmarks_file = build_config_filename ("bookmarks.db");
errmsg = NULL;
if ((db = midori_bookmarks_initialize (bookmarks, bookmarks_file, &errmsg)) == NULL)
{
if (error->code == G_FILE_ERROR_NOENT)
{
katze_assign (config_file,
sokoke_find_config_filename (NULL, "bookmarks.xbel"));
midori_array_from_file (bookmarks, config_file, "xbel", NULL);
}
else
g_string_append_printf (error_messages,
_("The bookmarks couldn't be loaded: %s\n"), error->message);
g_error_free (error);
g_string_append_printf (error_messages,
_("Bookmarks couldn't be loaded: %s\n"), errmsg);
g_free (errmsg);
}
#endif
midori_startup_timer ("Bkmarks read: \t%f");
else
{
gchar* old_bookmarks = build_config_filename (BOOKMARK_FILE);
if (g_access (old_bookmarks, F_OK) == 0)
{
midori_bookmarks_import (old_bookmarks, db);
g_unlink(old_bookmarks);
}
g_free (old_bookmarks);
g_object_set_data (G_OBJECT (bookmarks), "db", db);
}
midori_startup_timer ("Bookmarks read: \t%f");
_session = katze_array_new (KATZE_TYPE_ITEM);
#if HAVE_LIBXML
g_object_get (settings, "load-on-startup", &load_on_startup, NULL);
if (load_on_startup == MIDORI_STARTUP_LAST_OPEN_PAGES)
if (load_on_startup >= MIDORI_STARTUP_LAST_OPEN_PAGES)
{
katze_assign (config_file, build_config_filename ("session.xbel"));
error = NULL;
@ -1956,18 +1974,17 @@ main (int argc,
midori_startup_timer ("Trash read: \t%f");
history = katze_array_new (KATZE_TYPE_ARRAY);
#if HAVE_SQLITE
katze_assign (config_file, build_config_filename ("history.db"));
errmsg = NULL;
if ((db = midori_history_initialize (history, config_file, &errmsg)) == NULL)
if ((db = midori_history_initialize (history, config_file, bookmarks_file ,&errmsg)) == NULL)
{
g_string_append_printf (error_messages,
_("The history couldn't be loaded: %s\n"), errmsg);
g_free (errmsg);
}
g_free (bookmarks_file);
g_object_set_data (G_OBJECT (history), "db", db);
#endif
midori_startup_timer ("History read: \t%f");
/* In case of errors */
@ -2026,6 +2043,7 @@ main (int argc,
uri_ready = midori_prepare_uri (uri);
katze_item_set_uri (item, uri_ready);
g_free (uri_ready);
katze_item_set_meta_integer (item, "delay", 0);
katze_array_add_item (_session, item);
uri = strtok (NULL, "|");
}
@ -2034,7 +2052,6 @@ main (int argc,
}
}
katze_assign (config_file, build_config_filename ("search"));
if (1)
{
g_signal_connect_after (search_engines, "add-item",
@ -2049,24 +2066,10 @@ main (int argc,
G_CALLBACK (midori_search_engines_modify_cb), search_engines);
}
}
katze_assign (config_file, build_config_filename (BOOKMARK_FILE));
/* Don't save bookmarks if they are not our own */
if (!g_path_is_absolute (BOOKMARK_FILE))
{
midori_bookmarks_connect_item (NULL, (KatzeItem*)bookmarks, bookmarks);
g_signal_connect_after (bookmarks, "add-item",
G_CALLBACK (midori_bookmarks_add_item_cb), bookmarks);
g_signal_connect_after (bookmarks, "remove-item",
G_CALLBACK (midori_bookmarks_remove_item_cb), bookmarks);
}
katze_assign (config_file, build_config_filename ("tabtrash.xbel"));
g_signal_connect_after (trash, "add-item",
G_CALLBACK (midori_trash_add_item_cb), NULL);
g_signal_connect_after (trash, "remove-item",
G_CALLBACK (midori_trash_remove_item_cb), NULL);
#if HAVE_SQLITE
katze_assign (config_file, build_config_filename ("history.db"));
#endif
katze_item_set_parent (KATZE_ITEM (_session), app);
g_object_set_data (G_OBJECT (app), "extensions", extensions);
@ -2075,12 +2078,21 @@ main (int argc,
katze_assign (config_file, build_config_filename ("running"));
if (g_access (config_file, F_OK) == 0)
{
if (katze_object_get_boolean (settings, "show-crash-dialog"))
diagnostic_dialog = TRUE;
back_from_crash = TRUE;
}
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 (diagnostic_dialog)
{
GtkWidget* dialog = midori_create_diagnostic_dialog (settings, _session);
@ -2119,18 +2131,14 @@ main (int argc,
gtk_main ();
settings = katze_object_get_object (app, "settings");
#if HAVE_SQLITE
g_object_get (settings, "maximum-history-age", &max_history_age, NULL);
midori_history_terminate (db, max_history_age);
#endif
/* Clear data on quit, according to the Clear private data dialog */
g_object_get (settings, "clear-private-data", &clear_prefs, NULL);
if (clear_prefs & MIDORI_CLEAR_ON_QUIT)
{
#if HAVE_SQLITE
midori_remove_config_file (clear_prefs, MIDORI_CLEAR_HISTORY, "history.db");
#endif
midori_remove_config_file (clear_prefs, MIDORI_CLEAR_COOKIES, "cookies.txt");
if ((clear_prefs & MIDORI_CLEAR_FLASH_COOKIES) == MIDORI_CLEAR_FLASH_COOKIES)
{
@ -2156,8 +2164,8 @@ main (int argc,
}
}
if (katze_object_get_boolean (settings, "load-on-startup")
!= MIDORI_STARTUP_LAST_OPEN_PAGES)
if (katze_object_get_int (settings, "load-on-startup")
< MIDORI_STARTUP_LAST_OPEN_PAGES)
{
katze_assign (config_file, build_config_filename ("session.xbel"));
g_unlink (config_file);

View file

@ -17,6 +17,7 @@
#include <glib/gstdio.h>
#include <glib/gi18n.h>
#include <sqlite3.h>
#if HAVE_LIBXML
#include <libxml/parser.h>
@ -204,7 +205,7 @@ katze_array_from_xmlDocPtr (KatzeArray* array,
gchar* value;
value = (gchar*)xmlGetProp (cur, (xmlChar*)"version");
if (!katze_str_equal (value, "1.0"))
if (!value || !katze_str_equal (value, "1.0"))
g_warning ("XBEL version is not 1.0.");
g_free (value);
@ -752,3 +753,117 @@ midori_array_to_file (KatzeArray* array,
g_critical ("Cannot write KatzeArray to unknown format '%s'.", format);
return FALSE;
}
static void
katze_item_set_value_from_column (sqlite3_stmt* stmt,
gint column,
KatzeItem* item)
{
const gchar* name;
name = sqlite3_column_name (stmt, column);
g_return_if_fail (name != NULL);
if (g_str_equal (name, "uri"))
{
const unsigned char* uri;
uri = sqlite3_column_text (stmt, column);
if (uri && uri[0] && uri[0] != '(')
katze_item_set_uri (item, (gchar*)uri);
}
else if (g_str_equal (name, "title") || g_str_equal (name, "name"))
{
const unsigned char* title;
title = sqlite3_column_text (stmt, column);
katze_item_set_name (item, (gchar*)title);
}
else if (g_str_equal (name, "date"))
{
gint date;
date = sqlite3_column_int64 (stmt, column);
katze_item_set_added (item, date);
}
else if (g_str_equal (name, "day") || g_str_equal (name, "app")
|| g_str_equal (name, "toolbar"))
{
gint value;
value = sqlite3_column_int64 (stmt, column);
katze_item_set_meta_integer (item, name, value);
}
else if (g_str_equal (name, "folder"))
{
const unsigned char* folder;
folder = sqlite3_column_text (stmt, column);
katze_item_set_meta_string (item, name, (gchar*)folder);
}
else if (g_str_equal (name, "desc"))
{
const unsigned char* text;
text = sqlite3_column_text (stmt, column);
katze_item_set_text (item, (gchar*)text);
}
else
g_warn_if_reached ();
}
/**
* midori_array_from_statement:
* @stmt: prepared statement
*
* Stores the result in a #KatzeArray.
*
* Return value: a #KatzeArray on success, %NULL otherwise
*
* Since: 0.2.7
**/
KatzeArray*
katze_array_from_statement (sqlite3_stmt* stmt)
{
KatzeArray *array;
gint result;
gint cols;
array = katze_array_new (KATZE_TYPE_ITEM);
cols = sqlite3_column_count (stmt);
while ((result = sqlite3_step (stmt)) == SQLITE_ROW)
{
gint i;
KatzeItem* item;
item = katze_item_new ();
for (i = 0; i < cols; i++)
katze_item_set_value_from_column (stmt, i, item);
katze_array_add_item (array, item);
}
sqlite3_clear_bindings (stmt);
sqlite3_reset (stmt);
return array;
}
/**
* midori_array_from_sqlite:
* @db: opened database handler
* @sqlcmd: SQL query
*
* Stores the result in a #KatzeArray.
*
* Return value: a #KatzeArray on success, %NULL otherwise
*
* Since: 0.2.7
**/
KatzeArray*
katze_array_from_sqlite (sqlite3* db,
const gchar* sqlcmd)
{
sqlite3_stmt* stmt;
gint result;
result = sqlite3_prepare_v2 (db, sqlcmd, -1, &stmt, NULL);
if (result != SQLITE_OK)
return NULL;
return katze_array_from_statement (stmt);
}

View file

@ -12,6 +12,7 @@
#ifndef __MIDORI_ARRAY_H__
#define __MIDORI_ARRAY_H__ 1
#include <sqlite3.h>
#include <katze/katze.h>
gboolean
@ -26,4 +27,11 @@ midori_array_to_file (KatzeArray* array,
const gchar* format,
GError** error);
KatzeArray*
katze_array_from_statement (sqlite3_stmt* stmt);
KatzeArray*
katze_array_from_sqlite (sqlite3* db,
const gchar* sqlcmd);
#endif /* !__MIDORI_ARRAY_H__ */

File diff suppressed because it is too large Load diff

View file

@ -116,6 +116,9 @@ midori_browser_set_current_uri (MidoriBrowser* browser,
const gchar*
midori_browser_get_current_uri (MidoriBrowser* browser);
void
midori_browser_set_current_page_smartly (MidoriBrowser* browser,
gint n);
void
midori_browser_set_current_page (MidoriBrowser* browser,
gint n);

View file

@ -21,11 +21,9 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#if HAVE_SQLITE
#include <sqlite3.h>
#endif
#include <sqlite3.h>
#define COMPLETION_DELAY 150
#define COMPLETION_DELAY 200
#define MAX_ITEMS 25
struct _MidoriLocationAction
@ -274,7 +272,6 @@ midori_location_action_create_model (void)
return model;
}
#if HAVE_SQLITE
static void
midori_location_action_popup_position (GtkWidget* popup,
GtkWidget* widget)
@ -339,6 +336,8 @@ midori_location_action_popup_timeout_cb (gpointer data)
MidoriLocationAction* action = data;
GtkTreeViewColumn* column;
GtkListStore* store;
gchar* effective_key;
gint i;
gint result;
static sqlite3_stmt* stmt;
const gchar* sqlcmd;
@ -359,15 +358,29 @@ midori_location_action_popup_timeout_cb (gpointer data)
{
sqlite3* db;
db = g_object_get_data (G_OBJECT (action->history), "db");
sqlcmd = "SELECT type, uri, title, count() AS ct FROM history_view "
"WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri "
"UNION ALL "
"SELECT type, replace(uri, '%s', title) AS uri, title, count() AS ct FROM search_view "
"WHERE title LIKE ?1 GROUP BY uri "
"ORDER BY ct DESC LIMIT ?2";
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 "
" UNION ALL "
" SELECT 2 AS type, replace(uri, '%s', keywords) AS uri, "
" keywords AS title, count() AS ct FROM search "
" WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri "
" UNION ALL "
" SELECT 1 AS type, uri, title, 50 AS ct FROM bookmarks "
" WHERE title LIKE ?1 OR uri LIKE ?1 AND uri !='' "
") GROUP BY uri ORDER BY ct DESC LIMIT ?2";
sqlite3_prepare_v2 (db, sqlcmd, strlen (sqlcmd) + 1, &stmt, NULL);
}
sqlite3_bind_text (stmt, 1, g_strdup_printf ("%%%s%%", action->key), -1, g_free);
effective_key = g_strdup_printf ("%%%s%%", action->key);
i = 0;
do
{
if (effective_key[i] == ' ')
effective_key[i] = '%';
i++;
}
while (effective_key[i] != '\0');
sqlite3_bind_text (stmt, 1, effective_key, -1, g_free);
sqlite3_bind_int64 (stmt, 2, MAX_ITEMS);
result = sqlite3_step (stmt);
@ -444,6 +457,7 @@ midori_location_action_popup_timeout_cb (gpointer data)
style = gtk_widget_get_style (action->treeview);
while (result == SQLITE_ROW)
{
gchar* unescaped_uri;
sqlite3_int64 type = sqlite3_column_int64 (stmt, 0);
const unsigned char* uri = sqlite3_column_text (stmt, 1);
const unsigned char* title = sqlite3_column_text (stmt, 2);
@ -451,9 +465,14 @@ midori_location_action_popup_timeout_cb (gpointer data)
if (!icon)
icon = action->default_icon;
if (type == 1 /* history_view */)
{
unescaped_uri = sokoke_uri_unescape_string ((const char*)uri);
gtk_list_store_insert_with_values (store, NULL, matches,
URI_COL, uri, TITLE_COL, title, YALIGN_COL, 0.25,
URI_COL, unescaped_uri, TITLE_COL, title, YALIGN_COL, 0.25,
FAVICON_COL, icon, -1);
g_free (unescaped_uri);
}
else if (type == 2 /* search_view */)
{
gchar* search_title = g_strdup_printf (_("Search for %s"), title);
@ -516,7 +535,6 @@ midori_location_action_popup_timeout_cb (gpointer data)
return FALSE;
}
#endif
static void
midori_location_action_popup_completion (MidoriLocationAction* action,
@ -529,11 +547,9 @@ midori_location_action_popup_completion (MidoriLocationAction* action,
action->entry = entry;
g_signal_connect (entry, "destroy",
G_CALLBACK (gtk_widget_destroyed), &action->entry);
#if HAVE_SQLITE
action->completion_timeout = g_timeout_add (COMPLETION_DELAY,
midori_location_action_popup_timeout_cb, action);
/* TODO: Inline completion */
#endif
}
static void
@ -563,34 +579,6 @@ midori_location_action_entry_for_proxy (GtkWidget* proxy)
return entry;
}
/**
* midori_location_action_freeze:
* @location_action: a #MidoriLocationAction
*
* Freezing of the action doesn't do anything.
*
* Deprecated: 0.2.3
**/
void
midori_location_action_freeze (MidoriLocationAction* location_action)
{
/* Nothing to do */
}
/**
* midori_location_action_thaw:
* @location_action: a #MidoriLocationAction
*
* Thawing of the action doesn't do anything.
*
* Deprecated: 0.2.3
**/
void
midori_location_action_thaw (MidoriLocationAction* location_action)
{
/* Nothing to do */
}
static void
midori_location_action_init (MidoriLocationAction* location_action)
{
@ -633,17 +621,14 @@ midori_location_action_toggle_arrow_cb (GtkWidget* widget,
MidoriLocationAction* location_action)
{ gboolean show = FALSE;
#if HAVE_SQLITE
sqlite3* db;
const gchar* sqlcmd;
sqlite3_stmt* statement;
gint result;
#endif
if (!GTK_IS_BUTTON (widget))
return;
#if HAVE_SQLITE
db = g_object_get_data (G_OBJECT (location_action->history), "db");
sqlcmd = "SELECT uri FROM history LIMIT 1";
sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL);
@ -651,7 +636,6 @@ midori_location_action_toggle_arrow_cb (GtkWidget* widget,
if (result == SQLITE_ROW)
show = TRUE;
sqlite3_finalize (statement);
#endif
sokoke_widget_set_visible (widget, show);
gtk_widget_set_size_request (widget, show ? -1 : 1, show ? -1 : 1);
}
@ -1046,14 +1030,21 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
gboolean style;
gchar* desc;
gchar* desc_uri;
gchar* desc_iter;
gchar* temp_iter;
gchar* desc_title;
const gchar* str;
gchar* key;
gchar** keys;
gint key_idx;
gchar* start;
gchar* skey;
gchar* temp;
gchar* temp_concat;
gchar* temp_markup;
gchar** parts;
size_t len;
size_t offset;
gtk_tree_model_get (model, iter, URI_COL, &uri, TITLE_COL, &title,
BACKGROUND_COL, &background, STYLE_COL, &style, -1);
@ -1074,40 +1065,121 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
str = "";
key = g_utf8_strdown (str, -1);
len = strlen (key);
keys = g_strsplit_set (key, " %", -1);
g_free (key);
if (G_LIKELY (uri))
{
temp = g_utf8_strdown (uri, -1);
if ((start = strstr (temp, key)) && (start - temp))
temp_iter = temp = g_utf8_strdown (uri, -1);
desc_iter = uri;
key_idx = 0;
key = keys[key_idx];
len = strlen (key);
offset = 0;
while ((start = strstr (temp_iter, key)) && start)
{
skey = g_strndup (uri + (start - temp), len);
parts = g_strsplit (uri, skey, 2);
if (parts[0] && parts[1])
desc_uri = g_markup_printf_escaped ("%s<b>%s</b>%s",
parts[0], skey, parts[1]);
g_strfreev (parts);
g_free (skey);
if (len)
{
offset = (start - temp_iter);
skey = g_strndup (desc_iter + offset, len);
parts = g_strsplit (desc_iter, skey, 2);
if (parts[0] && parts[1])
{
if (desc_uri)
{
temp_markup = g_markup_printf_escaped ("%s<b>%s</b>",
parts[0], skey);
temp_concat = g_strconcat (desc_uri, temp_markup, NULL);
g_free (temp_markup);
katze_assign (desc_uri, temp_concat);
}
else
{
desc_uri = g_markup_printf_escaped ("%s<b>%s</b>",
parts[0], skey);
}
}
g_strfreev (parts);
g_free (skey);
offset += len;
temp_iter += offset;
desc_iter += offset;
}
key_idx++;
key = keys[key_idx];
if (key == NULL)
break;
len = strlen (key);
}
if (!desc_uri)
if (key)
katze_assign (desc_uri, NULL);
if (desc_uri)
{
temp_markup = g_markup_escape_text (desc_iter, -1);
temp_concat = g_strconcat (desc_uri, temp_markup, NULL);
g_free (temp_markup);
katze_assign (desc_uri, temp_concat);
}
else
desc_uri = g_markup_escape_text (uri, -1);
g_free (temp);
}
if (G_LIKELY (title))
{
temp = g_utf8_strdown (title, -1);
if ((start = strstr (temp, key)) && (start - temp))
temp_iter = temp = g_utf8_strdown (title, -1);
desc_iter = title;
key_idx = 0;
key = keys[key_idx];
len = strlen (key);
offset = 0;
while ((start = strstr (temp_iter, key)) && start)
{
skey = g_strndup (title + (start - temp), len);
parts = g_strsplit (title, skey, 2);
if (parts[0] && parts[1])
desc_title = g_markup_printf_escaped ("%s<b>%s</b>%s",
parts[0], skey, parts[1]);
g_strfreev (parts);
g_free (skey);
if (len)
{
offset = (start - temp_iter);
skey = g_strndup (desc_iter + offset, len);
parts = g_strsplit (desc_iter, skey, 2);
if (parts[0] && parts[1])
{
if (desc_title)
{
temp_markup = g_markup_printf_escaped ("%s<b>%s</b>",
parts[0], skey);
temp_concat = g_strconcat (desc_title, temp_markup, NULL);
g_free (temp_markup);
katze_assign (desc_title, temp_concat);
}
else
{
desc_title = g_markup_printf_escaped ("%s<b>%s</b>",
parts[0], skey);
}
}
g_strfreev (parts);
g_free (skey);
offset += len;
temp_iter += offset;
desc_iter += offset;
}
key_idx++;
key = keys[key_idx];
if (key == NULL)
break;
len = strlen (key);
}
if (!desc_title)
if (key)
katze_assign (desc_title, NULL);
if (desc_title)
{
temp_markup = g_markup_escape_text (desc_iter, -1);
temp_concat = g_strconcat (desc_title, temp_markup, NULL);
g_free (temp_markup);
katze_assign (desc_title, temp_concat);
}
else
desc_title = g_markup_escape_text (title, -1);
g_free (temp);
}
@ -1127,7 +1199,7 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
g_free (uri);
g_free (title);
g_free (key);
g_strfreev (keys);
g_free (desc);
}
@ -1171,7 +1243,6 @@ static void
midori_location_action_entry_popup_cb (GtkComboBox* combo_box,
MidoriLocationAction* location_action)
{
#if HAVE_SQLITE
GtkListStore* store;
gint result;
const gchar* sqlcmd;
@ -1217,7 +1288,6 @@ midori_location_action_entry_popup_cb (GtkComboBox* combo_box,
while (result == SQLITE_ROW);
sqlite3_reset (stmt);
sqlite3_clear_bindings (stmt);
#endif
}
static void
@ -1434,27 +1504,6 @@ midori_location_action_set_text (MidoriLocationAction* location_action,
g_object_unref (icon);
}
/**
* midori_location_action_set_uri:
* @location_action: a #MidoriLocationAction
* @uri: an URI string
*
* Sets the entry URI to @uri and, if applicable, updates the icon.
*
* Deprecated: 0.2.0
**/
void
midori_location_action_set_uri (MidoriLocationAction* location_action,
const gchar* uri)
{
g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
g_return_if_fail (uri != NULL);
katze_assign (location_action->uri, g_strdup (uri));
midori_location_action_set_text (location_action, uri);
}
/**
* midori_location_action_set_icon:
* @location_action: a #MidoriLocationAction

View file

@ -36,12 +36,6 @@ typedef struct _MidoriLocationActionClass MidoriLocationActionClass;
GType
midori_location_action_get_type (void) G_GNUC_CONST;
void
midori_location_action_freeze (MidoriLocationAction* location_action);
void
midori_location_action_thaw (MidoriLocationAction* location_action);
const gchar*
midori_location_action_get_text (MidoriLocationAction* location_action);
@ -52,10 +46,6 @@ midori_location_action_set_text (MidoriLocationAction* location_acti
const gchar*
midori_location_action_get_uri (MidoriLocationAction* location_action);
void
midori_location_action_set_uri (MidoriLocationAction* location_action,
const gchar* uri);
void
midori_location_action_set_icon (MidoriLocationAction* location_action,
GdkPixbuf* icon);

View file

@ -38,7 +38,6 @@ struct _MidoriPanel
GtkWidget* toolbook;
GtkWidget* notebook;
GtkActionGroup* action_group;
GtkMenu* menu;
gboolean show_titles;
gboolean show_controls;
@ -63,7 +62,6 @@ enum
PROP_SHADOW_TYPE,
PROP_ACTION_GROUP,
PROP_MENU,
PROP_PAGE,
PROP_SHOW_TITLES,
PROP_SHOW_CONTROLS,
@ -165,24 +163,6 @@ midori_panel_class_init (MidoriPanelClass* class)
GTK_TYPE_ACTION_GROUP,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* MidoriWebSettings:menu:
*
* This is the menu that holds the panel menu items.
*
* You shouldn't use this menu or add items.
*
* Deprecated: 0.1.9
*/
g_object_class_install_property (gobject_class,
PROP_MENU,
g_param_spec_object (
"menu",
"Menu",
"Menu to hold panel items",
GTK_TYPE_MENU,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
PROP_PAGE,
g_param_spec_int (
@ -508,9 +488,6 @@ midori_panel_set_property (GObject* object,
case PROP_ACTION_GROUP:
katze_object_assign (panel->action_group, g_value_dup_object (value));
break;
case PROP_MENU:
katze_object_assign (panel->menu, g_value_dup_object (value));
break;
case PROP_PAGE:
midori_panel_set_current_page (panel, g_value_get_int (value));
break;
@ -556,9 +533,6 @@ midori_panel_get_property (GObject* object,
case PROP_ACTION_GROUP:
g_value_set_object (value, panel->action_group);
break;
case PROP_MENU:
g_value_set_object (value, panel->menu);
break;
case PROP_PAGE:
g_value_set_int (value, midori_panel_get_current_page (panel));
break;
@ -1150,3 +1124,14 @@ midori_panel_append_widget (MidoriPanel* panel,
G_CALLBACK (midori_panel_widget_destroy_cb), viewable);
return midori_panel_append_page (panel, MIDORI_VIEWABLE (viewable));
}
/* Private function, used by MidoriBrowser */
void
midori_panel_set_toolbar_style (MidoriPanel* panel,
GtkToolbarStyle style)
{
g_return_if_fail (MIDORI_IS_PANEL (panel));
gtk_toolbar_set_style (GTK_TOOLBAR (panel->toolbar), style);
}

View file

@ -176,7 +176,10 @@ midori_preferences_homepage_current_clicked_cb (GtkWidget* button,
if (GTK_IS_WINDOW (browser))
{
gchar* uri = katze_object_get_string (browser, "uri");
g_object_set (settings, "homepage", uri, NULL);
if (uri && *uri)
g_object_set (settings, "homepage", uri, NULL);
else
g_object_set (settings, "homepage", "about:blank", NULL);
g_free (uri);
}
}

View file

@ -97,7 +97,6 @@ struct _MidoriView
GtkWidget* menu_item;
GtkWidget* tab_label;
/* GtkWidget* tooltip_image; */
GtkWidget* tab_icon;
GtkWidget* tab_title;
GtkWidget* tab_close;
@ -397,6 +396,15 @@ midori_view_class_init (MidoriViewClass* class)
G_TYPE_BOOLEAN,
G_TYPE_STRING);
/**
* MidoriView::add-bookmark:
* @view: the object on which the signal is emitted
* @uri: the bookmark URI
*
* Emitted when a bookmark is added.
*
* Deprecated: 0.2.7
*/
signals[ADD_BOOKMARK] = g_signal_new (
"add-bookmark",
G_TYPE_FROM_CLASS (class),
@ -641,15 +649,13 @@ midori_view_update_title (MidoriView* view)
soup_uri_free (uri);
}
gtk_label_set_text (GTK_LABEL (view->tab_title), title);
#if 1
gtk_widget_set_tooltip_text (view->tab_icon, title);
gtk_widget_set_tooltip_text (view->tab_title, title);
#endif
}
if (view->menu_item)
gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (
view->menu_item))), title);
if (view->item)
katze_item_set_name (view->item, title);
katze_item_set_name (view->item, title);
#undef title
}
@ -658,8 +664,7 @@ midori_view_apply_icon (MidoriView* view,
GdkPixbuf* icon,
const gchar* icon_name)
{
if (view->item)
katze_item_set_icon (view->item, icon_name);
katze_item_set_icon (view->item, icon_name);
katze_object_assign (view->icon, icon);
g_object_notify (G_OBJECT (view), "icon");
@ -887,7 +892,7 @@ _midori_web_view_load_icon (MidoriView* view)
icon_uri = g_strdup_printf ("%s/favicon.ico", view->uri);
}
icon_file = katze_net_get_cached_path (view->net, icon_uri, "icons");
icon_file = katze_net_get_cached_path (NULL, icon_uri, "icons");
if (g_hash_table_lookup_extended (view->memory,
icon_file, NULL, (gpointer)&pixbuf))
{
@ -910,7 +915,7 @@ _midori_web_view_load_icon (MidoriView* view)
priv->icon_uri = icon_uri;
priv->view = view;
katze_net_load_uri (view->net, icon_uri,
katze_net_load_uri (NULL, icon_uri,
(KatzeNetStatusCb)katze_net_icon_status_cb,
(KatzeNetTransferCb)katze_net_icon_transfer_cb, priv);
}
@ -995,56 +1000,17 @@ webkit_web_view_load_committed_cb (WebKitWebView* web_view,
uri = webkit_web_frame_get_uri (web_frame);
g_return_if_fail (uri != NULL);
katze_assign (view->uri, sokoke_format_uri_for_display (uri));
katze_assign (view->icon_uri, NULL);
if (view->item)
if (g_strcmp0 (uri, katze_item_get_uri (view->item)))
{
#if 0
/* Load back forward history from meta data. WebKit does not seem to
respect the order of items, so the feature is unusable. */
if (!view->back_forward_set)
{
WebKitWebBackForwardList* list;
gchar* key;
guint i;
const gchar* data;
WebKitWebHistoryItem* item;
list = webkit_web_view_get_back_forward_list (web_view);
key = g_strdup ("back4");
for (i = 4; i > 0; i--)
{
key[4] = 48 + i;
if ((data = katze_item_get_meta_string (view->item, key)))
{
item = webkit_web_history_item_new_with_data (data, NULL);
webkit_web_back_forward_list_add_item (list, item);
g_object_unref (item);
}
}
#if 0
key[0] = 'f';
key[1] = 'o';
key[2] = 'r';
key[3] = 'e';
for (i = 4; i > 0; i--)
{
key[4] = 48 + i;
item = webkit_web_history_item_new_with_data (data, NULL);
webkit_web_back_forward_list_add_item (list, item);
g_object_unref (item);
}
#endif
g_free (key);
view->back_forward_set = TRUE;
}
#endif
katze_assign (view->uri, sokoke_format_uri_for_display (uri));
katze_item_set_uri (view->item, uri);
katze_item_set_added (view->item, time (NULL));
}
katze_item_set_added (view->item, time (NULL));
katze_item_set_meta_integer (view->item, "history-step", -1);
g_object_notify (G_OBJECT (view), "uri");
g_object_set (view, "title", NULL, NULL);
@ -1414,59 +1380,6 @@ midori_web_view_notify_icon_uri_cb (WebKitWebView* web_view,
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 4)
static void
webkit_web_view_notify_uri_cb (WebKitWebView* web_view,
GParamSpec* pspec,
MidoriView* view)
{
#if 0
if (view->item)
{
/* Save back forward history as meta data. This is disabled
because we can't reliably restore these atm. */
WebKitWebView* web_view;
WebKitWebBackForwardList* list;
GList* back;
GList* forward;
web_view = WEBKIT_WEB_VIEW (view->web_view);
list = webkit_web_view_get_back_forward_list (web_view);
back = webkit_web_back_forward_list_get_back_list_with_limit (list, 5);
forward = webkit_web_back_forward_list_get_forward_list_with_limit (list, 5);
guint i;
WebKitWebHistoryItem* item;
gchar* key = g_strdup ("back0");
i = 0;
while ((item = g_list_nth_data (back, i++)))
{
katze_item_set_meta_string (view->item, key,
webkit_web_history_item_get_uri (item));
key[4] = 48 + i;
}
#if 0
key[0] = 'f';
key[1] = 'o';
key[2] = 'r';
key[3] = 'e';
key[4] = 48;
i = 0;
while ((item = g_list_nth_data (forward, i++)))
{
katze_item_set_meta_string (view->item, key,
webkit_web_history_item_get_uri (item));
key[4] = 48 + i;
}
#endif
g_free (key);
}
#endif
g_object_get (web_view, "uri", &view->uri, NULL);
g_object_notify (G_OBJECT (view), "uri");
}
static void
webkit_web_view_notify_title_cb (WebKitWebView* web_view,
GParamSpec* pspec,
@ -1540,7 +1453,7 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
gboolean background;
event->state = event->state & MIDORI_KEYS_MODIFIER_MASK;
link_uri = midori_view_get_link_uri (MIDORI_VIEW (view));
link_uri = midori_view_get_link_uri (view);
switch (event->button)
{
@ -1939,6 +1852,14 @@ midori_web_view_menu_download_activate_cb (GtkWidget* widget,
sokoke_spawn_program (view->download_manager, view->link_uri, FALSE);
}
static void
midori_view_tab_label_menu_window_new_cb (GtkWidget* menuitem,
GtkWidget* view)
{
g_signal_emit (view, signals[NEW_WINDOW], 0,
midori_view_get_display_uri (MIDORI_VIEW (view)));
}
#if WEBKIT_CHECK_VERSION (1, 1, 17)
static void
midori_web_view_menu_inspect_element_activate_cb (GtkWidget* widget,
@ -1951,6 +1872,7 @@ midori_web_view_menu_inspect_element_activate_cb (GtkWidget* widget,
x = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "x"));
y = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "y"));
webkit_web_inspector_inspect_coordinates (inspector, x, y);
webkit_web_inspector_show (inspector);
}
#endif
@ -2410,8 +2332,13 @@ midori_view_populate_popup (MidoriView* view,
gtk_menu_shell_append (menu_shell, gtk_separator_menu_item_new ());
menuitem = sokoke_action_create_popup_menu_item (
gtk_action_group_get_action (actions, "UndoTabClose"));
gtk_action_group_get_action (actions, "UndoTabClose"));
gtk_menu_shell_append (menu_shell, menuitem);
menuitem = gtk_image_menu_item_new_from_stock (STOCK_WINDOW_NEW, NULL);
gtk_menu_item_set_label (GTK_MENU_ITEM (menuitem), _("Open in New _Window"));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (midori_view_tab_label_menu_window_new_cb), view);
#if WEBKIT_CHECK_VERSION (1, 1, 15)
/* if (webkit_web_view_get_main_frame (web_view) != frame_under_mouse)
@ -2600,7 +2527,6 @@ webkit_web_view_create_web_view_cb (GtkWidget* web_view,
else
{
new_view = g_object_new (MIDORI_TYPE_VIEW,
"net", view->net,
"settings", view->settings,
NULL);
midori_view_construct_web_view (new_view);
@ -2640,7 +2566,10 @@ webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,
if (webkit_web_view_can_show_mime_type (WEBKIT_WEB_VIEW (web_view), mime_type))
{
#if WEBKIT_CHECK_VERSION (1, 1, 14)
gboolean view_source = webkit_web_view_get_view_source_mode (WEBKIT_WEB_VIEW (web_view));
gboolean view_source = FALSE;
/* Dedicated source code views are always pseudo-blank pages */
if (midori_view_is_blank (view))
view_source = webkit_web_view_get_view_source_mode (WEBKIT_WEB_VIEW (web_view));
/* Render raw XML, including news feeds, as source */
if (!view_source && (!strcmp (mime_type, "application/xml")
@ -2804,8 +2733,7 @@ midori_view_hadjustment_notify_value_cb (GtkAdjustment* hadjustment,
MidoriView* view)
{
gint value = (gint)gtk_adjustment_get_value (hadjustment);
if (view->item)
katze_item_set_meta_integer (view->item, "scrollh", value);
katze_item_set_meta_integer (view->item, "scrollh", value);
}
static void
@ -2825,8 +2753,7 @@ midori_view_vadjustment_notify_value_cb (GtkAdjustment* vadjustment,
MidoriView* view)
{
gint value = (gint)gtk_adjustment_get_value (vadjustment);
if (view->item)
katze_item_set_meta_integer (view->item, "scrollv", value);
katze_item_set_meta_integer (view->item, "scrollv", value);
}
static void
@ -2869,7 +2796,8 @@ midori_view_init (MidoriView* view)
view->selected_text = NULL;
view->news_feeds = katze_array_new (KATZE_TYPE_ITEM);
view->item = NULL;
view->item = katze_item_new ();
view->scrollh = view->scrollv = -2;
view->back_forward_set = FALSE;
@ -2879,9 +2807,11 @@ midori_view_init (MidoriView* view)
/* Adjustments are not created initially, but overwritten later */
view->scrolled_window = katze_scrolled_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view->scrolled_window),
GTK_SHADOW_ETCHED_OUT);
GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER (view), view->scrolled_window);
g_signal_connect (view->item, "meta-data-changed",
G_CALLBACK (midori_view_item_meta_data_changed), view);
g_signal_connect (view->scrolled_window, "notify::hadjustment",
G_CALLBACK (midori_view_notify_hadjustment_cb), view);
g_signal_connect (view->scrolled_window, "notify::vadjustment",
@ -2898,9 +2828,8 @@ midori_view_finalize (GObject* object)
if (view->settings)
g_signal_handlers_disconnect_by_func (view->settings,
midori_view_settings_notify_cb, view);
if (view->item)
g_signal_handlers_disconnect_by_func (view->item,
midori_view_item_meta_data_changed, view);
g_signal_handlers_disconnect_by_func (view->item,
midori_view_item_meta_data_changed, view);
if (view->thumb_view)
gtk_widget_destroy (view->thumb_view);
@ -2944,15 +2873,12 @@ midori_view_set_property (GObject* object,
break;
case PROP_MINIMIZED:
view->minimized = g_value_get_boolean (value);
if (view->item)
{
g_signal_handlers_block_by_func (view->item,
midori_view_item_meta_data_changed, view);
katze_item_set_meta_integer (view->item, "minimized",
view->minimized ? 1 : -1);
g_signal_handlers_unblock_by_func (view->item,
midori_view_item_meta_data_changed, view);
}
g_signal_handlers_block_by_func (view->item,
midori_view_item_meta_data_changed, view);
katze_item_set_meta_integer (view->item, "minimized",
view->minimized ? 1 : -1);
g_signal_handlers_unblock_by_func (view->item,
midori_view_item_meta_data_changed, view);
if (view->tab_label)
sokoke_widget_set_visible (view->tab_title, !view->minimized);
break;
@ -2967,8 +2893,6 @@ midori_view_set_property (GObject* object,
break;
case PROP_NET:
katze_object_assign (view->net, g_value_dup_object (value));
if (!view->net)
view->net = katze_net_new ();
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -3047,7 +2971,7 @@ midori_view_focus_in_event (GtkWidget* widget,
/**
* midori_view_new:
* @net: a #KatzeNet
* @net: a #KatzeNet, or %NULL
*
* Creates a new view.
*
@ -3056,9 +2980,7 @@ midori_view_focus_in_event (GtkWidget* widget,
GtkWidget*
midori_view_new (KatzeNet* net)
{
g_return_val_if_fail (!net || KATZE_IS_NET (net), NULL);
return g_object_new (MIDORI_TYPE_VIEW, "net", net, NULL);
return g_object_new (MIDORI_TYPE_VIEW, NULL);
}
static void
@ -3287,6 +3209,21 @@ midori_view_web_inspector_inspect_web_view_cb (gpointer inspector,
return WEBKIT_WEB_VIEW (inspector_view);
}
static gboolean
midori_view_web_inspector_show_window_cb (gpointer inspector,
MidoriView* view)
{
GtkWidget* inspector_view;
GtkWidget* window;
g_object_get (inspector, "web-view", &inspector_view, NULL);
window = gtk_widget_get_toplevel (inspector_view);
if (!window)
return FALSE;
gtk_window_present (GTK_WINDOW (window));
return TRUE;
}
static gboolean
midori_view_web_inspector_attach_window_cb (gpointer inspector,
MidoriView* view)
@ -3353,8 +3290,6 @@ midori_view_construct_web_view (MidoriView* view)
midori_web_view_notify_icon_uri_cb, view,
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 4)
"signal::notify::uri",
webkit_web_view_notify_uri_cb, view,
"signal::notify::title",
webkit_web_view_notify_title_cb, view,
#else
@ -3381,7 +3316,7 @@ midori_view_construct_web_view (MidoriView* view)
webkit_web_view_window_object_cleared_cb, view,
"signal::create-web-view",
webkit_web_view_create_web_view_cb, view,
"signal::mime-type-policy-decision-requested",
"signal-after::mime-type-policy-decision-requested",
webkit_web_view_mime_type_decision_cb, view,
#if WEBKIT_CHECK_VERSION (1, 1, 3)
"signal::download-requested",
@ -3418,6 +3353,8 @@ midori_view_construct_web_view (MidoriView* view)
g_object_connect (inspector,
"signal::inspect-web-view",
midori_view_web_inspector_inspect_web_view_cb, view,
"signal::show-window",
midori_view_web_inspector_show_window_cb, view,
"signal::attach-window",
midori_view_web_inspector_attach_window_cb, view,
"signal::detach-window",
@ -3443,7 +3380,7 @@ midori_view_set_uri (MidoriView* view,
/* Treat "about:blank" and "" equally, see midori_view_is_blank(). */
if (!uri || !strcmp (uri, "about:blank")) uri = "";
if (1)
if (g_getenv ("MIDORI_UNARMED") == NULL)
{
if (!view->web_view)
midori_view_construct_web_view (view);
@ -3462,6 +3399,7 @@ midori_view_set_uri (MidoriView* view,
gchar* filepath;
katze_assign (view->uri, g_strdup (""));
katze_item_set_uri (view->item, "");
filepath = sokoke_find_data_filename ("midori/res/speeddial-head.html");
g_file_get_contents (filepath, &speed_dial_head, NULL, NULL);
@ -3503,10 +3441,13 @@ midori_view_set_uri (MidoriView* view,
"{enter_shortcut_address}", _("Enter shortcut address"),
"{enter_shortcut_name}", _("Enter shortcut title"),
"{are_you_sure}", _("Are you sure you want to delete this shortcut?"),
"{set_dial_width}", _("Set number of columns"),
"{enter_dial_width}", _("Enter number of columns:"),
"{set_shortcut_count}", _("Set number of shortcuts"),
"{enter_shortcut_count}", _("Enter number of shortcuts:"), NULL);
"{set_dial_size}", _("Set number of columns and rows"),
"{enter_dial_size}", _("Enter number of columns and rows:"),
"{invalid_dial_size}", _("Invalid input for the size of the speed dial"),
"{set_thumb_size}", _("Thumb size:"),
"{set_thumb_small}", _("Small"),
"{set_thumb_normal}", _("Medium"),
"{set_thumb_big}", _("Big"), NULL);
midori_view_load_alternate_string (view,
@ -3618,7 +3559,6 @@ midori_view_set_uri (MidoriView* view,
"<tr><td>GTK+</td><td>%d.%d.%d (%d.%d.%d)</td></tr>"
"<tr><td>Glib</td><td>%d.%d.%d (%d.%d.%d)</td></tr>"
"<tr><td>libsoup</td><td>%s</td></tr>"
"<tr><td>sqlite3</td><td>%s</td></tr>"
"<tr><td>libnotify</td><td>%s</td></tr>"
"<tr><td>libidn</td><td>%s</td></tr>"
"<tr><td>libunique</td><td>%s</td></tr>"
@ -3640,7 +3580,6 @@ midori_view_set_uri (MidoriView* view,
GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION,
glib_major_version, glib_minor_version, glib_micro_version,
LIBSOUP_VERSION,
HAVE_SQLITE ? "Yes" : "No",
HAVE_LIBNOTIFY ? "Yes" : "No",
HAVE_LIBIDN ? "Yes" : "No",
HAVE_UNIQUE ? "Yes" : "No",
@ -3663,11 +3602,26 @@ midori_view_set_uri (MidoriView* view,
webkit_web_view_load_html_string (
WEBKIT_WEB_VIEW (view->web_view), data, view->uri);
g_free (data);
katze_item_set_uri (view->item, uri);
g_object_notify (G_OBJECT (view), "uri");
if (view->item)
katze_item_set_uri (view->item, uri);
return;
}
else if (g_str_has_prefix (uri, "pause:"))
{
gchar* title;
title = g_strdup_printf ("%s", view->title);
katze_assign (view->uri, g_strdup (&uri[6]));
midori_view_display_error (
view, view->uri, title,
_("Page loading delayed"),
_("Loading delayed either due to a recent crash or startup preferences."),
_("Load Page"),
NULL);
g_free (title);
katze_item_set_uri (view->item, uri);
g_object_notify (G_OBJECT (view), "uri");
}
else if (g_str_has_prefix (uri, "javascript:"))
{
gboolean result;
@ -3689,9 +3643,8 @@ midori_view_set_uri (MidoriView* view,
else
{
katze_assign (view->uri, sokoke_format_uri_for_display (uri));
katze_item_set_uri (view->item, uri);
g_object_notify (G_OBJECT (view), "uri");
if (view->item)
katze_item_set_uri (view->item, uri);
webkit_web_view_open (WEBKIT_WEB_VIEW (view->web_view), uri);
}
}
@ -3972,13 +3925,6 @@ midori_view_tab_label_menu_open_cb (GtkWidget* menuitem,
midori_browser_set_current_tab (browser, view);
}
static void
midori_view_tab_label_menu_window_new_cb (GtkWidget* menuitem,
GtkWidget* view)
{
g_signal_emit (view, signals[NEW_WINDOW], 0,
midori_view_get_display_uri (MIDORI_VIEW (view)));
}
static void
midori_view_tab_label_menu_duplicate_tab_cb (GtkWidget* menuitem,
@ -3986,7 +3932,7 @@ midori_view_tab_label_menu_duplicate_tab_cb (GtkWidget* menuitem,
{
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
GtkWidget* new_view = g_object_new (MIDORI_TYPE_VIEW,
"net", view->net, "settings", view->settings, NULL);
"settings", view->settings, NULL);
midori_view_set_uri (MIDORI_VIEW (new_view),
midori_view_get_display_uri (view));
gtk_widget_show (new_view);
@ -4062,6 +4008,7 @@ midori_view_get_tab_menu (MidoriView* view)
g_signal_connect (menuitem, "activate",
G_CALLBACK (midori_view_tab_label_menu_open_cb), view);
menuitem = gtk_image_menu_item_new_from_stock (STOCK_WINDOW_NEW, NULL);
gtk_menu_item_set_label (GTK_MENU_ITEM (menuitem), _("Open in New _Window"));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (midori_view_tab_label_menu_window_new_cb), view);
@ -4231,23 +4178,6 @@ midori_view_tab_label_parent_set (GtkWidget* tab_label,
}
}
#if 0
static gboolean
midori_view_tab_label_query_tooltip_cb (GtkWidget* tab_label,
gint x,
gint y,
gboolean keyboard,
GtkTooltip* tooltip,
MidoriView* view)
{
if (view->speed_dial_in_new_tabs)
gtk_tooltip_set_icon (tooltip, midori_view_get_snapshot (view, -160, -107));
else
gtk_tooltip_set_text (tooltip, midori_view_get_display_title (view));
return TRUE;
}
#endif
/**
* midori_view_get_label_ellipsize:
* @view: a #MidoriView
@ -4348,11 +4278,6 @@ midori_view_get_proxy_tab_label (MidoriView* view)
G_CALLBACK (midori_view_tab_close_clicked), view);
view->tab_label = event_box;
#if 0
gtk_widget_set_has_tooltip (view->tab_label, TRUE);
g_signal_connect (view->tab_label, "query-tooltip",
G_CALLBACK (midori_view_tab_label_query_tooltip_cb), view);
#endif
g_signal_connect (view->tab_icon, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&view->tab_icon);
@ -4394,29 +4319,15 @@ midori_view_item_meta_data_changed (KatzeItem* item,
* Retrieves a proxy item that can be used for bookmark storage as
* well as session management.
*
* The item is created on the first call and will be updated to reflect
* changes to the title and uri automatically.
* The item reflects changes to the title and uri automatically.
*
* Return value: the proxy #KatzeItem
**/
KatzeItem*
midori_view_get_proxy_item (MidoriView* view)
{
const gchar* uri;
const gchar* title;
g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
if (!view->item)
{
view->item = katze_item_new ();
uri = midori_view_get_display_uri (view);
katze_item_set_uri (view->item, uri);
title = midori_view_get_display_title (view);
katze_item_set_name (view->item, title);
g_signal_connect (view->item, "meta-data-changed",
G_CALLBACK (midori_view_item_meta_data_changed), view);
}
return view->item;
}
@ -4642,15 +4553,48 @@ midori_view_get_previous_page (MidoriView* view)
g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
if (!view->web_view)
return NULL;
web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
js_context = webkit_web_frame_get_global_context (web_frame);
katze_assign (uri, sokoke_js_script_eval (js_context,
"(function (l) { for (i in l) "
"if ((l[i].rel && l[i].rel == 'prev') "
" || (l[i].innerHTML"
" && l[i].innerHTML.toLowerCase ().indexOf ('prev') != -1)) "
"{ return l[i].href; } return 0; })("
"document.getElementsByTagName ('a'));", NULL));
"(function (g) {"
"var ind = ['prev','←','«','&lt;'];"
"var nind = ['next','→','»','&gt;'];"
"for (h in g) {"
"l = g[h];"
"for (i in l)"
"if (l[i].rel && (l[i].rel == ind[0]))"
"return l[i].href;"
"for (j in ind)"
"for (i in l)"
"if (l[i].innerHTML"
"&& (l[i].innerHTML.toLowerCase ().indexOf (ind[j]) != -1)"
"&& (l[i].innerHTML.toLowerCase ().indexOf (nind[j]) == -1))"
"return l[i].href;"
"var wa = window.location.href.split (/\\d+/);"
"var wn = window.location.href.split (/[^\\d]+/);"
"wn = wn.slice (1,wn.length - 1);"
"var cand = [];"
"for (i in wn)"
"{"
"cand[i] = '';"
"for (j = 0; j <= i; j++)"
"{"
"cand[i] += wa[j];"
"if (wn[j])"
"cand[i] += parseInt (wn[j]) - ((i == j) ? 1 : 0);"
"}"
"}"
"for (j in cand)"
"for (i in l)"
"if (cand[j].length && l[i].href && (l[i].href.indexOf (cand[j]) == 0))"
"return l[i].href;"
"}"
"return 0;"
"}) ([document.getElementsByTagName ('link'),"
"document.getElementsByTagName ('a')]);", NULL));
return uri && uri[0] != '0' ? uri : NULL;
}
@ -4673,18 +4617,50 @@ midori_view_get_next_page (MidoriView* view)
g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
if (!view->web_view)
return NULL;
web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
js_context = webkit_web_frame_get_global_context (web_frame);
katze_assign (uri, sokoke_js_script_eval (js_context,
"(function (l) { for (i in l) "
"if ((l[i].rel && l[i].rel == 'next') "
" || (l[i].innerHTML"
" && l[i].innerHTML.toLowerCase ().indexOf ('next') != -1)) "
"{ return l[i].href; } return 0; })("
"document.getElementsByTagName ('a'));", NULL));
"(function (g) {"
"var ind = ['next','→','»','&gt;'];"
"var nind = ['prev','←','«','&lt;'];"
"for (h in g) {"
"l = g[h];"
"for (i in l)"
"if (l[i].rel && (l[i].rel == ind[0]))"
"return l[i].href;"
"for (j in ind)"
"for (i in l)"
"if (l[i].innerHTML"
"&& (l[i].innerHTML.toLowerCase ().indexOf (ind[j]) != -1)"
"&& (l[i].innerHTML.toLowerCase ().indexOf (nind[j]) == -1))"
"return l[i].href;"
"var wa = window.location.href.split (/\\d+/);"
"var wn = window.location.href.split (/[^\\d]+/);"
"wn = wn.slice (1,wn.length - 1);"
"var cand = [];"
"for (i in wn)"
"{"
"cand[i] = '';"
"for (j = 0; j <= i; j++)"
"{"
"cand[i] += wa[j];"
"if (wn[j])"
"cand[i] += parseInt (wn[j]) + ((i == j) ? 1 : 0);"
"}"
"}"
"for (j in cand)"
"for (i in l)"
"if (cand[j].length && l[i].href && (l[i].href.indexOf (cand[j]) == 0))"
"return l[i].href;"
"}"
"return 0;"
"}) ([document.getElementsByTagName ('link'),"
"document.getElementsByTagName ('a')]);", NULL));
return uri && uri[0] != '0' ? uri : NULL;
}
#if WEBKIT_CHECK_VERSION (1, 1, 5)
static GtkWidget*
midori_view_print_create_custom_widget_cb (GtkPrintOperation* operation,
@ -5032,7 +5008,8 @@ thumb_view_load_status_cb (MidoriView* thumb_view,
if (katze_object_get_enum (thumb_view, "load-status") != MIDORI_LOAD_FINISHED)
return;
img = midori_view_get_snapshot (MIDORI_VIEW (thumb_view), 160, 107);
gtk_widget_realize (midori_view_get_web_view (MIDORI_VIEW (thumb_view)));
img = midori_view_get_snapshot (MIDORI_VIEW (thumb_view), 240, 160);
gdk_pixbuf_save_to_buffer (img, &file_content, &sz, "png", NULL, "compression", "7", NULL);
encoded = g_base64_encode ((guchar *)file_content, sz );

View file

@ -65,7 +65,6 @@ struct _MidoriWebSettings
gboolean remember_last_visited_pages : 1;
gboolean remember_last_downloaded_files : 1;
MidoriProxy proxy_type : 2;
gboolean auto_detect_proxy : 1;
MidoriIdentity identify_as : 3;
gint last_window_width;
@ -159,16 +158,13 @@ enum
PROP_FIND_WHILE_TYPING,
PROP_KINETIC_SCROLLING,
PROP_ACCEPT_COOKIES,
PROP_ORIGINAL_COOKIES_ONLY,
PROP_MAXIMUM_COOKIE_AGE,
PROP_REMEMBER_LAST_VISITED_PAGES,
PROP_MAXIMUM_HISTORY_AGE,
PROP_REMEMBER_LAST_DOWNLOADED_FILES,
PROP_PROXY_TYPE,
PROP_HTTP_PROXY,
PROP_AUTO_DETECT_PROXY,
PROP_IDENTIFY_AS,
PROP_USER_AGENT,
PROP_PREFERRED_LANGUAGES,
@ -204,6 +200,7 @@ midori_startup_get_type (void)
{ MIDORI_STARTUP_BLANK_PAGE, "MIDORI_STARTUP_BLANK_PAGE", N_("Show Blank page") },
{ MIDORI_STARTUP_HOMEPAGE, "MIDORI_STARTUP_HOMEPAGE", N_("Show Homepage") },
{ MIDORI_STARTUP_LAST_OPEN_PAGES, "MIDORI_STARTUP_LAST_OPEN_PAGES", N_("Show last open tabs") },
{ MIDORI_STARTUP_DELAYED_PAGES, "MIDORI_STARTUP_DELAYED_PAGES", N_("Show last tabs without loading") },
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MidoriStartup", values);
@ -970,22 +967,6 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
MIDORI_ACCEPT_COOKIES_ALL,
flags));
/**
* MidoriWebSettings:original-cookies-only:
*
* Accept cookies from the original website only.
*
* Deprecated: 0.2.3: This value is not used.
*/
g_object_class_install_property (gobject_class,
PROP_ORIGINAL_COOKIES_ONLY,
g_param_spec_boolean (
"original-cookies-only",
_("Original cookies only"),
_("Accept cookies from the original website only"),
FALSE,
flags));
g_object_class_install_property (gobject_class,
PROP_MAXIMUM_COOKIE_AGE,
g_param_spec_int (
@ -996,23 +977,6 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
flags));
/**
* MidoriWebSettings:remember-last-visited-pages:
*
* Whether the last visited pages are saved.
*
* Deprecated: 0.2.2
*/
g_object_class_install_property (gobject_class,
PROP_REMEMBER_LAST_VISITED_PAGES,
g_param_spec_boolean (
"remember-last-visited-pages",
_("Remember last visited pages"),
_("Whether the last visited pages are saved"),
TRUE,
flags));
g_object_class_install_property (gobject_class,
PROP_MAXIMUM_HISTORY_AGE,
g_param_spec_int (
@ -1059,22 +1023,6 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
NULL,
flags));
/**
* MidoriWebSettings:auto-detect-proxy:
*
* Whether to detect the proxy server automatically from the environment
*
* Deprecated: 0.2.5
*/
g_object_class_install_property (gobject_class,
PROP_AUTO_DETECT_PROXY,
g_param_spec_boolean (
"auto-detect-proxy",
_("Detect proxy server automatically"),
_("Whether to detect the proxy server automatically from the environment"),
TRUE,
flags));
/**
* MidoriWebSettings:identify-as:
*
@ -1183,7 +1131,6 @@ midori_web_settings_init (MidoriWebSettings* web_settings)
web_settings->open_popups_in_tabs = TRUE;
web_settings->remember_last_downloaded_files = TRUE;
web_settings->kinetic_scrolling = TRUE;
web_settings->auto_detect_proxy = TRUE;
g_signal_connect (web_settings, "notify::default-encoding",
G_CALLBACK (notify_default_encoding_cb), NULL);
@ -1505,16 +1452,10 @@ midori_web_settings_set_property (GObject* object,
case PROP_ACCEPT_COOKIES:
web_settings->accept_cookies = g_value_get_enum (value);
break;
case PROP_ORIGINAL_COOKIES_ONLY:
web_settings->original_cookies_only = g_value_get_boolean (value);
break;
case PROP_MAXIMUM_COOKIE_AGE:
web_settings->maximum_cookie_age = g_value_get_int (value);
break;
case PROP_REMEMBER_LAST_VISITED_PAGES:
web_settings->remember_last_visited_pages = g_value_get_boolean (value);
break;
case PROP_MAXIMUM_HISTORY_AGE:
web_settings->maximum_history_age = g_value_get_int (value);
break;
@ -1524,17 +1465,10 @@ midori_web_settings_set_property (GObject* object,
case PROP_PROXY_TYPE:
web_settings->proxy_type = g_value_get_enum (value);
web_settings->auto_detect_proxy =
web_settings->proxy_type == MIDORI_PROXY_AUTOMATIC
? TRUE : FALSE;
g_object_notify (object, "auto-detect-proxy");
break;
case PROP_HTTP_PROXY:
katze_assign (web_settings->http_proxy, g_value_dup_string (value));
break;
case PROP_AUTO_DETECT_PROXY:
web_settings->auto_detect_proxy = g_value_get_boolean (value);
break;
case PROP_IDENTIFY_AS:
web_settings->identify_as = g_value_get_enum (value);
if (web_settings->identify_as != MIDORI_IDENT_CUSTOM)
@ -1756,16 +1690,10 @@ midori_web_settings_get_property (GObject* object,
case PROP_ACCEPT_COOKIES:
g_value_set_enum (value, web_settings->accept_cookies);
break;
case PROP_ORIGINAL_COOKIES_ONLY:
g_value_set_boolean (value, web_settings->original_cookies_only);
break;
case PROP_MAXIMUM_COOKIE_AGE:
g_value_set_int (value, web_settings->maximum_cookie_age);
break;
case PROP_REMEMBER_LAST_VISITED_PAGES:
g_value_set_boolean (value, web_settings->remember_last_visited_pages);
break;
case PROP_MAXIMUM_HISTORY_AGE:
g_value_set_int (value, web_settings->maximum_history_age);
break;
@ -1779,9 +1707,6 @@ midori_web_settings_get_property (GObject* object,
case PROP_HTTP_PROXY:
g_value_set_string (value, web_settings->http_proxy);
break;
case PROP_AUTO_DETECT_PROXY:
g_value_set_boolean (value, web_settings->auto_detect_proxy);
break;
case PROP_IDENTIFY_AS:
g_value_set_enum (value, web_settings->identify_as);
break;

View file

@ -60,11 +60,13 @@ midori_window_state_get_type (void) G_GNUC_CONST;
#define MIDORI_TYPE_WINDOW_STATE \
(midori_window_state_get_type ())
/* values >= MIDORI_STARTUP_LAST_OPEN_PAGES mean session is saved */
typedef enum
{
MIDORI_STARTUP_BLANK_PAGE,
MIDORI_STARTUP_HOMEPAGE,
MIDORI_STARTUP_LAST_OPEN_PAGES
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 */
MIDORI_STARTUP_DELAYED_PAGES /* The session is saved, loading pages is delayed */
} MidoriStartup;
GType

View file

@ -26,7 +26,7 @@
#include "midori-websettings.h"
/* For convenience, include localization header */
#include <glib/gi18n.h>
#include <glib/gi18n-lib.h>
#define MIDORI_CHECK_VERSION(major, minor, micro) \
(MIDORI_MAJOR_VERSION > (major) || \

View file

@ -109,10 +109,10 @@ namespace Midori {
public View (GLib.Object net);
public void set_uri (string uri);
public bool is_blank ();
public string get_display_uri ();
public string get_display_title ();
public string get_icon_uri ();
public string get_link_uri ();
public unowned string get_display_uri ();
public unowned string get_display_title ();
public unowned string get_icon_uri ();
public unowned string get_link_uri ();
public bool has_selection ();
public string get_selected_text ();
public Gtk.MenuItem get_proxy_menu_item ();
@ -149,5 +149,10 @@ namespace Midori {
public class WebSettings : WebKit.WebSettings {
public WebSettings ();
}
[CCode (cheader_filename = "midori/sokoke.h", lower_case_cprefix = "sokoke_")]
namespace Sokoke {
public static uint gtk_action_count_modifiers (Gtk.Action action);
}
}

View file

@ -626,7 +626,7 @@ gchar* sokoke_search_uri (const gchar* uri,
if (!uri)
return g_strdup (keywords);
escaped = g_uri_escape_string (keywords, " :/", TRUE);
escaped = g_uri_escape_string (keywords, ":/", TRUE);
if (strstr (uri, "%s"))
search = g_strdup_printf (uri, escaped);
else
@ -737,6 +737,22 @@ sokoke_magic_uri (const gchar* uri)
return NULL;
}
/**
* sokoke_uri_unescape_string:
* @uri: an URI string
*
* Unescape @uri if needed, and pass through '+'.
*
* Return value: a newly allocated URI
**/
gchar*
sokoke_uri_unescape_string (const gchar* uri)
{
if (strchr (uri,'%'))
return g_uri_unescape_string (uri, "+");
return g_strdup (uri);
}
/**
* sokoke_format_uri_for_display:
* @uri: an URI string
@ -751,7 +767,7 @@ sokoke_format_uri_for_display (const gchar* uri)
{
if (uri && g_str_has_prefix (uri, "http://"))
{
gchar* unescaped = g_uri_unescape_string (uri, " +");
gchar* unescaped = sokoke_uri_unescape_string (uri);
#ifdef HAVE_LIBSOUP_2_27_90
gchar* path = NULL;
gchar* hostname;
@ -1103,22 +1119,15 @@ sokoke_key_file_save_to_file (GKeyFile* key_file,
GError** error)
{
gchar* data;
FILE* fp;
gboolean success = FALSE;
data = g_key_file_to_data (key_file, NULL, error);
if (!data)
return FALSE;
if (!(fp = fopen (filename, "w")))
{
*error = g_error_new (G_FILE_ERROR, G_FILE_ERROR_ACCES,
_("Writing failed."));
return FALSE;
}
fputs (data, fp);
fclose (fp);
success = g_file_set_contents (filename, data, -1, error);
g_free (data);
return TRUE;
return success;
}
void
@ -1296,11 +1305,11 @@ sokoke_register_stock_items (void)
{ STOCK_BOOKMARK_ADD, N_("Add Boo_kmark"), 0, 0, GTK_STOCK_ADD },
{ STOCK_CONSOLE, N_("_Console"), 0, 0, GTK_STOCK_DIALOG_WARNING },
{ STOCK_EXTENSIONS, N_("_Extensions"), 0, 0, GTK_STOCK_CONVERT },
{ STOCK_HISTORY, N_("_History"), 0, 0, GTK_STOCK_SORT_ASCENDING },
{ STOCK_HISTORY, N_("_History"), 0, GDK_H, GTK_STOCK_SORT_ASCENDING },
{ STOCK_HOMEPAGE, N_("_Homepage"), 0, 0, GTK_STOCK_HOME },
{ STOCK_SCRIPTS, N_("_Userscripts"), 0, 0, GTK_STOCK_EXECUTE },
{ STOCK_TAB_NEW, N_("New _Tab"), 0, 0, GTK_STOCK_ADD },
{ STOCK_TRANSFERS, N_("_Transfers"), 0, 0, GTK_STOCK_SAVE },
{ STOCK_TRANSFERS, N_("_Transfers"), 0, GDK_J, GTK_STOCK_SAVE },
{ STOCK_PLUGINS, N_("Netscape p_lugins"), 0, 0, GTK_STOCK_CONVERT },
{ STOCK_USER_TRASH, N_("_Closed Tabs"), 0, 0, "gtk-undo-ltr" },
{ STOCK_WINDOW_NEW, N_("New _Window"), 0, 0, GTK_STOCK_ADD },
@ -1462,17 +1471,27 @@ sokoke_find_config_filename (const gchar* folder,
const gchar* const* config_dirs = g_get_system_config_dirs ();
guint i = 0;
const gchar* config_dir;
gchar* path;
if (!folder)
folder = "";
while ((config_dir = config_dirs[i++]))
{
gchar* path = g_build_filename (config_dir, PACKAGE_NAME, folder, filename, NULL);
path = g_build_filename (config_dir, PACKAGE_NAME, folder, filename, NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
}
#ifdef G_OS_WIN32
config_dir = g_win32_get_package_installation_directory_of_module (NULL);
path = g_build_filename (config_dir, "etc", "xdg", PACKAGE_NAME, folder, filename, NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
#endif
return g_build_filename (SYSCONFDIR, "xdg", PACKAGE_NAME, folder, filename, NULL);
}
@ -1689,6 +1708,39 @@ sokoke_window_activate_key (GtkWindow* window,
return FALSE;
}
/**
* sokoke_gtk_action_count_modifiers:
* @action: a #GtkAction
*
* Counts the number of modifiers in the accelerator
* belonging to the action.
*
* Return value: the number of modifiers
**/
guint
sokoke_gtk_action_count_modifiers (GtkAction* action)
{
GtkAccelKey key;
gint mods, cmods = 0;
const gchar* accel_path;
g_return_val_if_fail (GTK_IS_ACTION (action), 0);
accel_path = gtk_action_get_accel_path (action);
if (accel_path)
if (gtk_accel_map_lookup_entry (accel_path, &key))
{
mods = key.accel_mods;
while (mods)
{
if (1 & mods >> 0)
cmods++;
mods = mods >> 1;
}
}
return cmods;
}
/**
* sokoke_file_chooser_dialog_new:
* @title: a window title, or %NULL

View file

@ -40,6 +40,9 @@
#if !GTK_CHECK_VERSION (2, 16, 0)
#define GTK_ACTIVATABLE GTK_WIDGET
#define gtk_activatable_get_related_action gtk_widget_get_action
#define gtk_menu_item_set_label(menuitem, label) \
gtk_label_set_label (GTK_LABEL (GTK_BIN (menuitem)->child), \
label ? label : "");
#endif
#if !GTK_CHECK_VERSION (2, 18, 0)
@ -110,6 +113,9 @@ sokoke_uri_to_ascii (const gchar* uri);
gchar*
sokoke_magic_uri (const gchar* uri);
gchar*
sokoke_uri_unescape_string (const gchar* uri);
gchar*
sokoke_format_uri_for_display (const gchar* uri);
@ -227,6 +233,8 @@ sokoke_replace_variables (const gchar* template,
gboolean
sokoke_window_activate_key (GtkWindow* window,
GdkEventKey* event);
guint
sokoke_gtk_action_count_modifiers (GtkAction* action);
GtkWidget*
sokoke_file_chooser_dialog_new (const gchar* title,

View file

@ -11,8 +11,8 @@ libs = 'M UNIQUE LIBSOUP GMODULE GTHREAD LIBIDN GIO GTK SQLITE ' \
if progressive or Options.commands['check']:
obj = bld.new_task_gen ('cc', 'staticlib')
obj.target = 'midori-core'
obj.includes = '.. ../katze .'
obj.find_sources_in_dirs ('../katze . ../panels', excludes=['main.c'])
obj.includes = '.. ../katze . ../toolbars'
obj.find_sources_in_dirs ('../katze . ../panels ../toolbars', excludes=['main.c'])
obj.uselib = libs
obj.add_marshal_file ('marshal.list', 'midori_cclosure_marshal')
obj.install_path = None

View file

@ -11,22 +11,24 @@
#include "midori-bookmarks.h"
#include "midori-array.h"
#include "midori-app.h"
#include "midori-browser.h"
#include "midori-stock.h"
#include "midori-view.h"
#include "midori-viewable.h"
#include "midori-bookmark-store.h"
#include "sokoke.h"
#include "gtkiconentry.h"
#include <glib/gi18n.h>
#include <string.h>
#include <katze/katze.h>
#include <gdk/gdkkeysyms.h>
void
#define COMPLETION_DELAY 200
gboolean
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
KatzeItem* bookmark,
gboolean new_bookmark,
@ -46,6 +48,9 @@ struct _MidoriBookmarks
GtkWidget* treeview;
MidoriApp* app;
KatzeArray* array;
gint filter_timeout;
gchar* filter;
};
struct _MidoriBookmarksClass
@ -117,12 +122,220 @@ midori_bookmarks_get_stock_id (MidoriViewable* viewable)
return STOCK_BOOKMARKS;
}
void
midori_bookmarks_export_array_db (sqlite3* db,
KatzeArray* array,
const gchar* folder)
{
gchar* sqlcmd;
KatzeArray* root_array;
KatzeArray* subarray;
KatzeItem* item;
int i = 0;
sqlcmd = g_strdup_printf ("SELECT * FROM bookmarks where folder='%s'", folder);
root_array = katze_array_from_sqlite (db, sqlcmd);
g_free (sqlcmd);
while ((item = katze_array_get_nth_item (KATZE_ARRAY (root_array), i++)))
{
if (KATZE_ITEM_IS_FOLDER (item))
{
subarray = katze_array_new (KATZE_TYPE_ARRAY);
katze_item_set_name (KATZE_ITEM (subarray), katze_item_get_name (item));
midori_bookmarks_export_array_db (db, subarray, katze_item_get_name (item));
katze_array_add_item (array, subarray);
}
else
katze_array_add_item (array, item);
}
}
void
midori_bookmarks_import_array_db (sqlite3* db,
KatzeArray* array,
const gchar* folder)
{
GList* list = NULL;
GList* bookmarks;
bookmarks = katze_array_get_items ((KatzeArray*)array);
for (list = bookmarks; list != NULL; list = g_list_next (list))
{
KatzeItem* item;
if (KATZE_IS_ARRAY (list->data))
midori_bookmarks_import_array_db (db, list->data, folder);
item = (KatzeItem*) list->data;
midori_bookmarks_insert_item_db (db, item, folder);
}
}
static KatzeArray*
midori_bookmarks_read_from_db (MidoriBookmarks* bookmarks,
const gchar* folder,
const gchar* keyword)
{
sqlite3* db;
sqlite3_stmt* statement;
gint result;
const gchar* sqlcmd;
db = g_object_get_data (G_OBJECT (bookmarks->array), "db");
if (keyword && *keyword)
{
gchar* filterstr;
sqlcmd = "SELECT uri, title, desc, app, toolbar, folder from bookmarks where "
" title like ? ORDER BY uri DESC";
result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL);
filterstr = g_strdup_printf ("%%%s%%", keyword);
sqlite3_bind_text (statement, 1, g_strdup (filterstr), -1, g_free);
g_free (filterstr);
}
else
{
if (!folder)
folder = "";
sqlcmd = "SELECT uri, title, desc, app, toolbar, folder from bookmarks where "
" folder = ? ORDER BY uri DESC";
result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL);
sqlite3_bind_text (statement, 1, g_strdup (folder), -1, g_free);
}
if (result != SQLITE_OK)
return NULL;
return katze_array_from_statement (statement);
}
static void
midori_bookmarks_read_from_db_to_model (MidoriBookmarks* bookmarks,
GtkTreeStore* model,
GtkTreeIter* parent,
const gchar* folder,
const gchar* keyword)
{
KatzeArray* array;
gint last;
KatzeItem* item;
GtkTreeIter child;
array = midori_bookmarks_read_from_db (bookmarks, folder, keyword);
katze_bookmark_populate_tree_view (array, model, parent);
/* Remove invisible dummy row */
last = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), parent);
if (!last)
return;
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (model), &child, parent, last - 1);
gtk_tree_model_get (GTK_TREE_MODEL (model), &child, 0, &item, -1);
if (KATZE_ITEM_IS_SEPARATOR (item))
gtk_tree_store_remove (model, &child);
else
g_object_unref (item);
}
void
midori_bookmarks_insert_item_db (sqlite3* db,
KatzeItem* item,
const gchar* folder)
{
gchar* sqlcmd;
char* errmsg = NULL;
KatzeItem* old_parent;
gchar* parent;
gchar* uri;
if (KATZE_ITEM_IS_BOOKMARK (item))
uri = g_strdup (katze_item_get_uri (item));
else
uri = g_strdup ("");
/* Use folder, otherwise fallback to parent folder */
old_parent = katze_item_get_parent (item);
if (folder && *folder)
parent = g_strdup (folder);
else if (old_parent && katze_item_get_name (old_parent))
parent = g_strdup (katze_item_get_name (old_parent));
else
parent = g_strdup ("");
sqlcmd = sqlite3_mprintf (
"INSERT into bookmarks (uri, title, desc, folder, toolbar, app) values"
" ('%q', '%q', '%q', '%q', %d, %d)",
uri,
katze_item_get_name (item),
katze_item_get_text (item),
parent,
katze_item_get_meta_boolean (item, "toolbar"),
katze_item_get_meta_boolean (item, "app"));
if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK)
{
g_printerr (_("Failed to add bookmark item: %s\n"), errmsg);
sqlite3_free (errmsg);
}
g_free (uri);
g_free (parent);
sqlite3_free (sqlcmd);
}
static void
midori_bookmarks_remove_item_cb (KatzeArray* array,
KatzeItem* item,
MidoriBookmarks* bookmarks)
{
GtkTreeModel* model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
gtk_tree_store_clear (GTK_TREE_STORE (model));
midori_bookmarks_read_from_db_to_model (bookmarks,
GTK_TREE_STORE (model), NULL, NULL, bookmarks->filter);
}
static void
midori_bookmarks_row_changed_cb (GtkTreeModel* model,
GtkTreePath* path,
GtkTreeIter* iter,
MidoriBookmarks* bookmarks)
{
KatzeItem* item;
GtkTreeIter parent;
sqlite3* db;
gchar* parent_name;
db = g_object_get_data (G_OBJECT (bookmarks->array), "db");
gtk_tree_model_get (model, iter, 0, &item, -1);
if (gtk_tree_model_iter_parent (model, &parent, iter))
{
KatzeItem* new_parent;
gtk_tree_model_get (model, &parent, 0, &new_parent, -1);
/* Bookmarks must not be moved into non-folder items */
if (!KATZE_ITEM_IS_FOLDER (new_parent))
parent_name = g_strdup ("");
else
parent_name = g_strdup (katze_item_get_name (new_parent));
g_object_unref (new_parent);
}
else
parent_name = g_strdup ("");
katze_array_remove_item (bookmarks->array, item);
midori_bookmarks_insert_item_db (db, item, parent_name);
}
static void
midori_bookmarks_add_clicked_cb (GtkWidget* toolitem)
{
MidoriBrowser* browser = midori_browser_get_for_widget (toolitem);
/* FIXME: Take selected folder into account */
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
if (g_str_equal (gtk_widget_get_name (toolitem), "BookmarkFolderAdd"))
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, TRUE);
else
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
}
static void
@ -136,17 +349,15 @@ midori_bookmarks_edit_clicked_cb (GtkWidget* toolitem,
&model, &iter))
{
KatzeItem* item;
gboolean is_separator;
MidoriBrowser* browser;
gtk_tree_model_get (model, &iter, 0, &item, -1);
is_separator = !KATZE_IS_ARRAY (item) && !katze_item_get_uri (item);
if (!is_separator)
{
MidoriBrowser* browser = midori_browser_get_for_widget (toolitem);
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE);
}
g_assert (!KATZE_ITEM_IS_SEPARATOR (item));
browser = midori_browser_get_for_widget (bookmarks->treeview);
midori_browser_edit_bookmark_dialog_new (
browser, item, FALSE, KATZE_ITEM_IS_FOLDER (item));
g_object_unref (item);
}
}
@ -162,59 +373,20 @@ midori_bookmarks_delete_clicked_cb (GtkWidget* toolitem,
&model, &iter))
{
KatzeItem* item;
KatzeArray* parent;
gtk_tree_model_get (model, &iter, 0, &item, -1);
/* FIXME: Even toplevel items should technically have a parent */
g_return_if_fail (katze_item_get_parent (item));
parent = katze_item_get_parent (item);
katze_array_remove_item (parent, item);
/* Manually remove the iter and block clearing the treeview */
gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
g_signal_handlers_block_by_func (bookmarks->array,
midori_bookmarks_remove_item_cb, bookmarks);
katze_array_remove_item (bookmarks->array, item);
g_signal_handlers_unblock_by_func (bookmarks->array,
midori_bookmarks_remove_item_cb, bookmarks);
g_object_unref (item);
}
}
static void
midori_bookmarks_folder_clicked_cb (GtkWidget* toolitem)
{
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (toolitem));
/* FIXME: Take selected folder into account */
midori_browser_edit_bookmark_dialog_new (browser,
NULL, TRUE, TRUE);
}
static void
midori_bookmarks_cursor_or_row_changed_cb (GtkTreeView* treeview,
MidoriBookmarks* bookmarks)
{
GtkTreeModel* model;
GtkTreeIter iter;
KatzeItem* item;
if (!bookmarks->edit)
return;
if (katze_tree_view_get_selected_iter (treeview, &model, &iter))
{
gboolean is_separator;
gtk_tree_model_get (model, &iter, 0, &item, -1);
is_separator = !KATZE_IS_ARRAY (item) && !katze_item_get_uri (item);
gtk_widget_set_sensitive (bookmarks->edit, !is_separator);
gtk_widget_set_sensitive (bookmarks->delete, TRUE);
g_object_unref (item);
}
else
{
gtk_widget_set_sensitive (bookmarks->edit, FALSE);
gtk_widget_set_sensitive (bookmarks->delete, FALSE);
}
}
static GtkWidget*
midori_bookmarks_get_toolbar (MidoriViewable* viewable)
{
@ -229,6 +401,7 @@ midori_bookmarks_get_toolbar (MidoriViewable* viewable)
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
bookmarks->toolbar = toolbar;
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_ADD);
gtk_widget_set_name (GTK_WIDGET (toolitem), "BookmarkAdd");
gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
_("Add a new bookmark"));
gtk_tool_item_set_is_important (toolitem, TRUE);
@ -258,15 +431,14 @@ midori_bookmarks_get_toolbar (MidoriViewable* viewable)
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
gtk_widget_show (GTK_WIDGET (toolitem));
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DIRECTORY);
gtk_widget_set_name (GTK_WIDGET (toolitem), "BookmarkFolderAdd");
gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
_("Add a new folder"));
g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_bookmarks_folder_clicked_cb), bookmarks);
G_CALLBACK (midori_bookmarks_add_clicked_cb), bookmarks);
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
gtk_widget_show (GTK_WIDGET (toolitem));
midori_bookmarks_cursor_or_row_changed_cb (
GTK_TREE_VIEW (bookmarks->treeview), bookmarks);
g_signal_connect (bookmarks->edit, "destroy",
G_CALLBACK (gtk_widget_destroyed), &bookmarks->edit);
g_signal_connect (bookmarks->delete, "destroy",
@ -284,214 +456,16 @@ midori_bookmarks_viewable_iface_init (MidoriViewableIface* iface)
iface->get_toolbar = midori_bookmarks_get_toolbar;
}
static void
midori_bookmarks_add_item_cb (KatzeArray* array,
KatzeItem* added_item,
MidoriBookmarks* bookmarks);
static void
midori_bookmarks_remove_item_cb (KatzeArray* array,
KatzeItem* removed_item,
MidoriBookmarks* bookmarks);
static void
midori_bookmarks_clear_cb (KatzeArray* array,
MidoriBookmarks* bookmarks);
static void
midori_bookmarks_disconnect_folder (MidoriBookmarks* bookmarks,
KatzeArray* array)
{
KatzeItem* item;
guint i;
g_return_if_fail (KATZE_IS_ARRAY (array));
g_signal_handlers_disconnect_by_func (array,
midori_bookmarks_add_item_cb, bookmarks);
g_signal_handlers_disconnect_by_func (array,
midori_bookmarks_remove_item_cb, bookmarks);
g_signal_handlers_disconnect_by_func (array,
midori_bookmarks_clear_cb, bookmarks);
i = 0;
while ((item = katze_array_get_nth_item (array, i++)))
{
if (KATZE_IS_ARRAY (item))
midori_bookmarks_disconnect_folder (bookmarks, KATZE_ARRAY (item));
g_object_unref (item);
}
}
static void
midori_bookmarks_add_item_cb (KatzeArray* array,
KatzeItem* added_item,
MidoriBookmarks* bookmarks)
{
GtkTreeModel* model;
GtkTreeIter iter;
guint i;
g_return_if_fail (KATZE_IS_ARRAY (array));
g_return_if_fail (KATZE_IS_ITEM (added_item));
if (KATZE_IS_ARRAY (added_item))
{
g_signal_connect (added_item, "add-item",
G_CALLBACK (midori_bookmarks_add_item_cb), bookmarks);
g_signal_connect (added_item, "remove-item",
G_CALLBACK (midori_bookmarks_remove_item_cb), bookmarks);
g_signal_connect (added_item, "clear",
G_CALLBACK (midori_bookmarks_clear_cb), bookmarks);
}
g_object_ref (added_item);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
if (array == bookmarks->array)
{
gtk_tree_store_insert_with_values (GTK_TREE_STORE (model),
&iter, NULL, G_MAXINT, 0, added_item, -1);
return;
}
i = 0;
/* FIXME: Recurse over children of folders, too */
while (gtk_tree_model_iter_nth_child (model, &iter, NULL, i))
{
KatzeItem* item;
gtk_tree_model_get (model, &iter, 0, &item, -1);
if (item == (KatzeItem*)array)
{
GtkTreeIter child_iter;
gtk_tree_store_insert_with_values (GTK_TREE_STORE (model),
&child_iter, &iter, G_MAXINT, 0, added_item, -1);
break;
}
g_object_unref (item);
i++;
}
}
static void
midori_bookmarks_remove_iter (GtkTreeModel* model,
GtkTreeIter* parent,
KatzeItem* removed_item)
{
guint i;
GtkTreeIter iter;
i = 0;
while (gtk_tree_model_iter_nth_child (model, &iter, parent, i))
{
KatzeItem* item;
gtk_tree_model_get (model, &iter, 0, &item, -1);
if (item == removed_item)
{
gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
g_object_unref (item);
break;
}
if (KATZE_IS_ARRAY (item))
midori_bookmarks_remove_iter (model, &iter, removed_item);
g_object_unref (item);
i++;
}
}
static void
midori_bookmarks_remove_item_cb (KatzeArray* array,
KatzeItem* removed_item,
MidoriBookmarks* bookmarks)
{
GtkTreeModel* model;
g_return_if_fail (KATZE_IS_ARRAY (array));
g_return_if_fail (KATZE_IS_ITEM (removed_item));
if (KATZE_IS_ARRAY (removed_item))
midori_bookmarks_disconnect_folder (bookmarks, KATZE_ARRAY (removed_item));
model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
midori_bookmarks_remove_iter (model, NULL, removed_item);
g_object_unref (removed_item);
}
static void
midori_bookmarks_clear_cb (KatzeArray* array,
MidoriBookmarks* bookmarks)
{
GtkTreeView* treeview;
GtkTreeStore* store;
g_return_if_fail (KATZE_IS_ARRAY (array));
if (array == bookmarks->array)
{
treeview = GTK_TREE_VIEW (bookmarks->treeview);
store = GTK_TREE_STORE (gtk_tree_view_get_model (treeview));
gtk_tree_store_clear (store);
}
else
{
KatzeItem* item;
guint i;
i = 0;
while ((item = katze_array_get_nth_item (array, i++)))
midori_bookmarks_remove_item_cb (array, item, bookmarks);
}
}
static void
midori_bookmarks_insert_folder (MidoriBookmarks* bookmarks,
GtkTreeStore* treestore,
GtkTreeIter* parent,
KatzeArray* array)
{
KatzeItem* item;
guint i;
GtkTreeIter iter;
g_return_if_fail (KATZE_IS_ARRAY (array));
g_signal_connect (array, "add-item",
G_CALLBACK (midori_bookmarks_add_item_cb), bookmarks);
g_signal_connect (array, "remove-item",
G_CALLBACK (midori_bookmarks_remove_item_cb), bookmarks);
g_signal_connect (array, "clear",
G_CALLBACK (midori_bookmarks_clear_cb), bookmarks);
i = 0;
while ((item = katze_array_get_nth_item (array, i++)))
{
g_object_ref (item);
gtk_tree_store_insert_with_values (treestore, &iter, parent, i,
0, item, -1);
if (KATZE_IS_ARRAY (item))
midori_bookmarks_insert_folder (bookmarks, treestore,
&iter, KATZE_ARRAY (item));
}
}
static void
midori_bookmarks_set_app (MidoriBookmarks* bookmarks,
MidoriApp* app)
{
GtkTreeModel* model;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
if (bookmarks->array)
{
midori_bookmarks_disconnect_folder (bookmarks, bookmarks->array);
g_object_unref (bookmarks->array);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
gtk_tree_store_clear (GTK_TREE_STORE (model));
}
katze_assign (bookmarks->app, app);
@ -500,13 +474,14 @@ midori_bookmarks_set_app (MidoriBookmarks* bookmarks,
g_object_ref (app);
bookmarks->array = katze_object_get_object (app, "bookmarks");
if (bookmarks->array)
{
/* FIXME: Dereference the app on finalization */
model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
midori_bookmarks_insert_folder (bookmarks, GTK_TREE_STORE (model),
NULL, g_object_ref (bookmarks->array));
}
g_object_set_data (G_OBJECT (bookmarks->array), "treeview", bookmarks->treeview);
g_signal_connect (bookmarks->array, "remove-item",
G_CALLBACK (midori_bookmarks_remove_item_cb), bookmarks);
midori_bookmarks_read_from_db_to_model (bookmarks, GTK_TREE_STORE (model), NULL, "", NULL);
g_signal_connect_after (model, "row-changed",
G_CALLBACK (midori_bookmarks_row_changed_cb),
bookmarks);
}
static void
@ -561,17 +536,18 @@ midori_bookmarks_treeview_render_icon_cb (GtkTreeViewColumn* column,
/* TODO: Would it be better to not do this on every redraw? */
pixbuf = NULL;
if (KATZE_IS_ARRAY (item))
if (KATZE_ITEM_IS_FOLDER (item))
pixbuf = gtk_widget_render_icon (treeview, GTK_STOCK_DIRECTORY,
GTK_ICON_SIZE_MENU, NULL);
else if (katze_item_get_uri (item))
else if (KATZE_ITEM_IS_BOOKMARK (item))
pixbuf = katze_load_cached_icon (katze_item_get_uri (item), treeview);
g_object_set (renderer, "pixbuf", pixbuf, NULL);
if (pixbuf)
g_object_unref (pixbuf);
g_object_unref (item);
if (item)
g_object_unref (item);
}
static void
@ -585,13 +561,14 @@ midori_bookmarks_treeview_render_text_cb (GtkTreeViewColumn* column,
gtk_tree_model_get (model, iter, 0, &item, -1);
if (KATZE_IS_ARRAY (item) || katze_item_get_uri (item))
if (item && katze_item_get_name (item))
g_object_set (renderer, "markup", NULL,
"text", katze_item_get_name (item), NULL);
else
g_object_set (renderer, "markup", _("<i>Separator</i>"), NULL);
g_object_unref (item);
if (item)
g_object_unref (item);
}
static void
@ -608,13 +585,20 @@ midori_bookmarks_row_activated_cb (GtkTreeView* treeview,
if (gtk_tree_model_get_iter (model, &iter, path))
{
MidoriBrowser* browser;
gtk_tree_model_get (model, &iter, 0, &item, -1);
if (KATZE_ITEM_IS_BOOKMARK (item))
{
MidoriBrowser* browser;
browser = midori_browser_get_for_widget (GTK_WIDGET (bookmarks));
midori_browser_open_bookmark (browser, item);
browser = midori_browser_get_for_widget (GTK_WIDGET (bookmarks));
midori_browser_open_bookmark (browser, item);
g_object_unref (item);
return;
}
if (gtk_tree_view_row_expanded (treeview, path))
gtk_tree_view_collapse_row (treeview, path);
else
gtk_tree_view_expand_row (treeview, path, FALSE);
g_object_unref (item);
}
}
@ -630,7 +614,7 @@ midori_bookmarks_popup_item (GtkWidget* menu,
const gchar* uri;
GtkWidget* menuitem;
uri = katze_item_get_uri (item);
uri = KATZE_ITEM_IS_BOOKMARK (item) ? katze_item_get_uri (item) : NULL;
menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
if (label)
@ -638,8 +622,8 @@ midori_bookmarks_popup_item (GtkWidget* menu,
GTK_BIN (menuitem))), label);
if (!strcmp (stock_id, GTK_STOCK_EDIT))
gtk_widget_set_sensitive (menuitem,
KATZE_IS_ARRAY (item) || uri != NULL);
else if (!KATZE_IS_ARRAY (item) && strcmp (stock_id, GTK_STOCK_DELETE))
!KATZE_ITEM_IS_SEPARATOR (item));
else if (!KATZE_ITEM_IS_FOLDER (item) && strcmp (stock_id, GTK_STOCK_DELETE))
gtk_widget_set_sensitive (menuitem, uri != NULL);
g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
g_signal_connect (menuitem, "activate", G_CALLBACK (callback), bookmarks);
@ -655,9 +639,8 @@ midori_bookmarks_open_activate_cb (GtkWidget* menuitem,
const gchar* uri;
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
uri = katze_item_get_uri (item);
if (uri && *uri)
if ((uri = katze_item_get_uri (item)) && *uri)
{
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (bookmarks));
midori_browser_set_current_uri (browser, uri);
@ -673,42 +656,34 @@ midori_bookmarks_open_in_tab_activate_cb (GtkWidget* menuitem,
guint n;
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
if (KATZE_IS_ARRAY (item))
if (KATZE_ITEM_IS_FOLDER (item))
{
KatzeItem* child;
KatzeArray* array;
guint i = 0;
while ((child = katze_array_get_nth_item (KATZE_ARRAY (item), i)))
array = midori_bookmarks_read_from_db (bookmarks, katze_item_get_name (item), NULL);
g_return_if_fail (KATZE_IS_ARRAY (array));
while ((child = katze_array_get_nth_item (KATZE_ARRAY (array), i)))
{
if ((uri = katze_item_get_uri (child)) && *uri)
{
MidoriBrowser* browser;
MidoriWebSettings* settings;
browser = midori_browser_get_for_widget (GTK_WIDGET (bookmarks));
n = midori_browser_add_item (browser, child);
settings = katze_object_get_object (browser, "settings");
if (!katze_object_get_boolean (settings, "open-tabs-in-the-background"))
midori_browser_set_current_page (browser, n);
g_object_unref (settings);
midori_browser_set_current_page_smartly (browser, n);
}
i++;
}
}
else
else if ((uri = katze_item_get_uri (item)) && *uri)
{
if ((uri = katze_item_get_uri (item)) && *uri)
{
MidoriBrowser* browser;
MidoriWebSettings* settings;
MidoriBrowser* browser;
browser = midori_browser_get_for_widget (GTK_WIDGET (bookmarks));
n = midori_browser_add_item (browser, item);
settings = katze_object_get_object (browser, "settings");
if (!katze_object_get_boolean (settings, "open-tabs-in-the-background"))
midori_browser_set_current_page (browser, n);
g_object_unref (settings);
}
browser = midori_browser_get_for_widget (GTK_WIDGET (bookmarks));
n = midori_browser_add_item (browser, item);
midori_browser_set_current_page_smartly (browser, n);
}
}
@ -731,39 +706,6 @@ midori_bookmarks_open_in_window_activate_cb (GtkWidget* menuitem,
}
}
static void
midori_bookmarks_edit_activate_cb (GtkWidget* menuitem,
MidoriBookmarks* bookmarks)
{
KatzeItem* item;
gboolean is_separator;
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
is_separator = !KATZE_IS_ARRAY (item) && !katze_item_get_uri (item);
if (!is_separator)
{
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (bookmarks));
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE);
}
}
static void
midori_bookmarks_delete_activate_cb (GtkWidget* menuitem,
MidoriBookmarks* bookmarks)
{
KatzeItem* item;
KatzeArray* parent;
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
/* FIXME: Even toplevel items should technically have a parent */
g_return_if_fail (katze_item_get_parent (item));
parent = katze_item_get_parent (item);
katze_array_remove_item (parent, item);
}
static void
midori_bookmarks_popup (GtkWidget* widget,
GdkEventButton* event,
@ -774,7 +716,7 @@ midori_bookmarks_popup (GtkWidget* widget,
GtkWidget* menuitem;
menu = gtk_menu_new ();
if (KATZE_IS_ARRAY (item))
if (KATZE_ITEM_IS_FOLDER (item))
midori_bookmarks_popup_item (menu,
STOCK_TAB_NEW, _("Open all in _Tabs"),
item, midori_bookmarks_open_in_tab_activate_cb, bookmarks);
@ -791,9 +733,9 @@ midori_bookmarks_popup (GtkWidget* widget,
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
midori_bookmarks_popup_item (menu, GTK_STOCK_EDIT, NULL,
item, midori_bookmarks_edit_activate_cb, bookmarks);
item, midori_bookmarks_edit_clicked_cb, bookmarks);
midori_bookmarks_popup_item (menu, GTK_STOCK_DELETE, NULL,
item, midori_bookmarks_delete_activate_cb, bookmarks);
item, midori_bookmarks_delete_clicked_cb, bookmarks);
katze_widget_popup (widget, GTK_MENU (menu), event, KATZE_MENU_POSITION_CURSOR);
}
@ -817,9 +759,8 @@ midori_bookmarks_button_release_event_cb (GtkWidget* widget,
if (event->button == 2)
{
const gchar* uri = katze_item_get_uri (item);
if (uri && *uri)
const gchar* uri;
if (KATZE_ITEM_IS_BOOKMARK (item) && (uri = katze_item_get_uri (item)) && *uri)
{
MidoriBrowser* browser;
gint n;
@ -832,7 +773,8 @@ midori_bookmarks_button_release_event_cb (GtkWidget* widget,
else
midori_bookmarks_popup (widget, event, item, bookmarks);
g_object_unref (item);
if (item != NULL)
g_object_unref (item);
return TRUE;
}
return FALSE;
@ -880,19 +822,114 @@ midori_bookmarks_popup_menu_cb (GtkWidget* widget,
}
}
static void
midori_bookmarks_row_expanded_cb (GtkTreeView* treeview,
GtkTreeIter* iter,
GtkTreePath* path,
MidoriBookmarks* bookmarks)
{
GtkTreeModel* model;
KatzeItem* item;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
gtk_tree_model_get (model, iter, 0, &item, -1);
midori_bookmarks_read_from_db_to_model (bookmarks, GTK_TREE_STORE (model),
iter, katze_item_get_name (item), NULL);
g_object_unref (item);
}
static void
midori_bookmarks_row_collapsed_cb (GtkTreeView *treeview,
GtkTreeIter *parent,
GtkTreePath *path,
gpointer user_data)
{
GtkTreeModel* model;
GtkTreeStore* treestore;
GtkTreeIter child;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
treestore = GTK_TREE_STORE (model);
while (gtk_tree_model_iter_nth_child (model, &child, parent, 0))
gtk_tree_store_remove (treestore, &child);
/* That's an invisible dummy, so we always have an expander */
gtk_tree_store_insert_with_values (treestore, &child, parent,
0, 0, NULL, -1);
}
static gboolean
midori_bookmarks_filter_timeout_cb (gpointer data)
{
MidoriBookmarks* bookmarks = data;
GtkTreeModel* model;
GtkTreeStore* treestore;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
treestore = GTK_TREE_STORE (model);
gtk_tree_store_clear (treestore);
midori_bookmarks_read_from_db_to_model (bookmarks,
treestore, NULL, NULL, bookmarks->filter);
return FALSE;
}
static void
midori_bookmarks_filter_entry_changed_cb (GtkEntry* entry,
MidoriBookmarks* bookmarks)
{
if (bookmarks->filter_timeout)
g_source_remove (bookmarks->filter_timeout);
katze_assign (bookmarks->filter, g_strdup (gtk_entry_get_text (entry)));
bookmarks->filter_timeout = g_timeout_add (COMPLETION_DELAY,
midori_bookmarks_filter_timeout_cb, bookmarks);
}
static void
midori_bookmarks_filter_entry_clear_cb (GtkEntry* entry,
gint icon_pos,
gint button,
MidoriBookmarks* bookmarks)
{
if (icon_pos == GTK_ICON_ENTRY_SECONDARY)
gtk_entry_set_text (entry, "");
}
static void
midori_bookmarks_init (MidoriBookmarks* bookmarks)
{
GtkWidget* entry;
GtkWidget* box;
GtkTreeStore* model;
GtkWidget* treeview;
GtkTreeViewColumn* column;
GtkCellRenderer* renderer_pixbuf;
GtkCellRenderer* renderer_text;
/* Create the filter entry */
entry = gtk_icon_entry_new ();
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_PRIMARY,
GTK_STOCK_FIND);
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_SECONDARY,
GTK_STOCK_CLEAR);
gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_SECONDARY, TRUE);
g_signal_connect (entry, "icon-release",
G_CALLBACK (midori_bookmarks_filter_entry_clear_cb), bookmarks);
g_signal_connect (entry, "changed",
G_CALLBACK (midori_bookmarks_filter_entry_changed_cb), bookmarks);
box = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 3);
gtk_widget_show_all (box);
gtk_box_pack_start (GTK_BOX (bookmarks), box, FALSE, FALSE, 5);
/* Create the treeview */
model = midori_bookmark_store_new (1, KATZE_TYPE_ITEM);
model = gtk_tree_store_new (2, KATZE_TYPE_ITEM, G_TYPE_STRING);
treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (treeview), 1);
column = gtk_tree_view_column_new ();
renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
@ -905,20 +942,21 @@ midori_bookmarks_init (MidoriBookmarks* bookmarks)
(GtkTreeCellDataFunc)midori_bookmarks_treeview_render_text_cb,
treeview, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
gtk_tree_view_set_reorderable (GTK_TREE_VIEW (treeview), TRUE);
g_object_unref (model);
g_object_connect (treeview,
"signal::row-activated",
midori_bookmarks_row_activated_cb, bookmarks,
"signal::cursor-changed",
midori_bookmarks_cursor_or_row_changed_cb, bookmarks,
"signal::columns-changed",
midori_bookmarks_cursor_or_row_changed_cb, bookmarks,
"signal::button-release-event",
midori_bookmarks_button_release_event_cb, bookmarks,
"signal::key-release-event",
midori_bookmarks_key_release_event_cb, bookmarks,
"signal::popup-menu",
midori_bookmarks_popup_menu_cb, bookmarks,
"signal::row-expanded",
midori_bookmarks_row_expanded_cb, bookmarks,
"signal::row-collapsed",
midori_bookmarks_row_collapsed_cb, bookmarks,
NULL);
gtk_widget_show (treeview);
gtk_box_pack_start (GTK_BOX (bookmarks), treeview, TRUE, TRUE, 0);
@ -930,7 +968,6 @@ midori_bookmarks_finalize (GObject* object)
{
MidoriBookmarks* bookmarks = MIDORI_BOOKMARKS (object);
midori_bookmarks_disconnect_folder (bookmarks, bookmarks->array);
if (bookmarks->app)
g_object_unref (bookmarks->app);
}

View file

@ -12,7 +12,11 @@
#ifndef __MIDORI_BOOKMARKS_H__
#define __MIDORI_BOOKMARKS_H__
#include "config.h"
#include <sqlite3.h>
#include <gtk/gtk.h>
#include <katze/katze.h>
G_BEGIN_DECLS
@ -38,6 +42,16 @@ midori_bookmarks_get_type (void);
GtkWidget*
midori_bookmarks_new (void);
void
midori_bookmarks_insert_item_db (sqlite3* db,
KatzeItem* item,
const gchar* folder);
void
midori_bookmarks_import_array_db (sqlite3* db,
KatzeArray* array,
const gchar* folder);
G_END_DECLS
#endif /* __MIDORI_BOOKMARKS_H__ */

View file

@ -12,6 +12,7 @@
#include "midori-history.h"
#include "midori-app.h"
#include "midori-array.h"
#include "midori-browser.h"
#include "midori-stock.h"
#include "midori-view.h"
@ -23,22 +24,16 @@
#include <glib/gi18n.h>
#include <string.h>
#include <katze/katze.h>
#include <gdk/gdkkeysyms.h>
#define COMPLETION_DELAY 200
void
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
KatzeItem* bookmark,
gboolean new_bookmark,
gboolean is_folder);
#include "config.h"
#if HAVE_SQLITE
#include <sqlite3.h>
#endif
#define COMPLETION_DELAY 150
struct _MidoriHistory
{
@ -125,7 +120,40 @@ midori_history_get_stock_id (MidoriViewable* viewable)
return STOCK_HISTORY;
}
#if HAVE_SQLITE
static gchar*
midori_history_format_date (KatzeItem *item)
{
gint age;
gint64 day;
gchar token[50];
gchar* sdate;
time_t current_time;
current_time = time (NULL);
day = katze_item_get_added (item);
age = sokoke_days_between ((time_t*)&day, &current_time);
/* A negative age is a date in the future, the clock is probably off */
if (age < -1)
;
else if (age > 7 || age < 0)
{
strftime (token, sizeof (token), "%x", localtime ((time_t*)&day));
sdate = g_strdup (token);
}
else if (age > 6)
sdate = _("A week ago");
else if (age > 1)
sdate = g_strdup_printf (ngettext ("%d day ago",
"%d days ago", (gint)age), (gint)age);
else if (age == 0)
sdate = _("Today");
else
sdate = _("Yesterday");
return sdate;
}
static void
midori_history_clear_db (MidoriHistory* history)
{
@ -155,7 +183,7 @@ midori_history_remove_item_from_db (MidoriHistory* history,
db = g_object_get_data (G_OBJECT (history->array), "db");
if (katze_item_get_uri (item))
if (KATZE_ITEM_IS_BOOKMARK (item))
sqlcmd = sqlite3_mprintf (
"DELETE FROM history WHERE uri = '%q' AND"
" title = '%q' AND date = %llu",
@ -163,8 +191,8 @@ midori_history_remove_item_from_db (MidoriHistory* history,
katze_item_get_name (item),
katze_item_get_added (item));
else
sqlcmd = sqlite3_mprintf (
"DELETE FROM history WHERE day = %d", katze_item_get_added (item));
sqlcmd = sqlite3_mprintf ("DELETE FROM history WHERE day = %d",
katze_item_get_meta_integer (item, "day"));
if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK)
{
@ -178,8 +206,6 @@ midori_history_remove_item_from_db (MidoriHistory* history,
/**
* midori_history_read_from_db:
* @history: a #MidoriHistory
* @model: a #GtkTreeStore
* @parent: a #GtkTreeIter, or %NULL
* @req_day: the timestamp of one day, or 0
* @filter: a filter string to search for
*
@ -188,10 +214,8 @@ midori_history_remove_item_from_db (MidoriHistory* history,
* 2. If @req_day is given, all pages for that day are added.
* 3. If @filter is given, all pages matching the filter are added.
**/
static gboolean
static KatzeArray*
midori_history_read_from_db (MidoriHistory* history,
GtkTreeStore* model,
GtkTreeIter* parent,
int req_day,
const gchar* filter)
{
@ -199,10 +223,6 @@ midori_history_read_from_db (MidoriHistory* history,
sqlite3_stmt* statement;
gint result;
const gchar* sqlcmd;
time_t current_time;
GtkTreeIter iter;
GtkTreeIter root_iter;
db = g_object_get_data (G_OBJECT (history->array), "db");
@ -210,16 +230,17 @@ midori_history_read_from_db (MidoriHistory* history,
{
gchar* filterstr;
sqlcmd = "SELECT uri, title, day FROM history_view "
"WHERE uri LIKE ? or title LIKE ? GROUP BY uri "
sqlcmd = "SELECT * FROM ("
" SELECT uri, title, day FROM history"
" WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri "
"UNION ALL "
"SELECT replace(uri, '%s', title) AS uri, title, day "
"FROM search_view WHERE title LIKE ?1 GROUP BY uri "
"ORDER BY day ASC";
" SELECT replace (uri, '%s', keywords) AS uri, "
" keywords AS title, day FROM search "
" WHERE uri LIKE ?1 OR keywords LIKE ?1 GROUP BY uri "
") ORDER BY day ASC";
result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL);
filterstr = g_strdup_printf ("%%%s%%", filter);
sqlite3_bind_text (statement, 1, filterstr, -1, g_free);
sqlite3_bind_text (statement, 2, g_strdup (filterstr), -1, g_free);
req_day = -1;
}
else if (req_day == 0)
@ -237,111 +258,36 @@ midori_history_read_from_db (MidoriHistory* history,
}
if (result != SQLITE_OK)
return FALSE;
return NULL;
if (req_day == 0)
current_time = time (NULL);
while ((result = sqlite3_step (statement)) == SQLITE_ROW)
{
KatzeItem* item;
const unsigned char* uri;
const unsigned char* title;
sqlite3_int64 date;
sqlite3_int64 day;
if (req_day == 0)
{
gint age;
gchar token[50];
gchar* sdate;
day = sqlite3_column_int64 (statement, 0);
date = sqlite3_column_int64 (statement, 1);
item = katze_item_new ();
katze_item_set_added (item, day);
age = sokoke_days_between ((time_t*)&date, &current_time);
/* A negative age is a date in the future, the clock is probably off */
if (age < -1)
{
static gboolean clock_warning = FALSE;
if (!clock_warning)
{
midori_app_send_notification (history->app,
_("Erroneous clock time"),
_("The clock time lies in the past. "
"Please check the current date and time."));
clock_warning = TRUE;
}
}
if (age > 7 || age < 0)
{
strftime (token, sizeof (token), "%x", localtime ((time_t*)&date));
sdate = token;
}
else if (age > 6)
sdate = _("A week ago");
else if (age > 1)
sdate = g_strdup_printf (ngettext ("%d day ago",
"%d days ago", (gint)age), (gint)age);
else if (age == 0)
sdate = _("Today");
else
sdate = _("Yesterday");
gtk_tree_store_insert_with_values (model, &root_iter, NULL,
0, 0, item, 1, sdate, -1);
/* That's an invisible dummy, so we always have an expander */
gtk_tree_store_insert_with_values (model, &iter, &root_iter,
0, 0, NULL, 1, NULL, -1);
if (age > 1 && age < 7)
g_free (sdate);
}
else
{
uri = sqlite3_column_text (statement, 0);
title = sqlite3_column_text (statement, 1);
date = sqlite3_column_int64 (statement, 2);
day = sqlite3_column_int64 (statement, 3);
if (!uri)
continue;
item = katze_item_new ();
katze_item_set_added (item, date);
katze_item_set_uri (item, (gchar*)uri);
katze_item_set_name (item, (gchar*)title);
gtk_tree_store_insert_with_values (model, NULL, parent,
0, 0, item, 1, katze_item_get_name (item), -1);
}
}
if (req_day != 0 && !(filter && *filter))
{
/* Remove invisible dummy row */
GtkTreeIter child;
gint last = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), parent);
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (model), &child, parent, last - 1);
gtk_tree_store_remove (model, &child);
}
if (result != SQLITE_DONE)
g_print (_("Failed to execute database statement: %s\n"),
sqlite3_errmsg (db));
sqlite3_finalize (statement);
return FALSE;
return katze_array_from_statement (statement);
}
static void
midori_history_add_clicked_cb (GtkWidget* toolitem)
midori_history_read_from_db_to_model (MidoriHistory* history,
GtkTreeStore* model,
GtkTreeIter* parent,
int req_day,
const gchar* filter)
{
MidoriBrowser* browser = midori_browser_get_for_widget (toolitem);
/* FIXME: Take selected folder into account */
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
KatzeArray* array;
gint last;
KatzeItem* item;
GtkTreeIter child;
array = midori_history_read_from_db (history, req_day, filter);
katze_bookmark_populate_tree_view (array, model, parent);
/* Remove invisible dummy row */
last = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), parent);
if (!last)
return;
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (model), &child, parent, last - 1);
gtk_tree_model_get (GTK_TREE_MODEL (model), &child, 0, &item, -1);
if (KATZE_ITEM_IS_SEPARATOR (item))
gtk_tree_store_remove (model, &child);
else
g_object_unref (item);
}
static void
@ -385,36 +331,25 @@ midori_history_clear_clicked_cb (GtkWidget* toolitem,
}
static void
midori_history_cursor_or_row_changed_cb (GtkTreeView* treeview,
MidoriHistory* history)
midori_history_bookmark_add_cb (GtkWidget* menuitem,
MidoriHistory* history)
{
GtkTreeModel* model;
GtkTreeIter iter;
KatzeItem* item;
if (!history->bookmark)
return;
if (katze_tree_view_get_selected_iter (treeview, &model, &iter))
{
gboolean is_page;
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (history));
if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (history->treeview),
&model, &iter))
gtk_tree_model_get (model, &iter, 0, &item, -1);
is_page = item && katze_item_get_uri (item);
gtk_widget_set_sensitive (history->bookmark, is_page);
gtk_widget_set_sensitive (history->delete, TRUE);
if (item)
g_object_unref (item);
}
if (KATZE_IS_ITEM (item) && katze_item_get_uri (item))
midori_browser_edit_bookmark_dialog_new (browser, item, TRUE, FALSE);
else
{
gtk_widget_set_sensitive (history->bookmark, FALSE);
gtk_widget_set_sensitive (history->delete, FALSE);
}
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
g_object_unref (item);
}
#endif
static GtkWidget*
midori_history_get_toolbar (MidoriViewable* viewable)
@ -424,20 +359,17 @@ midori_history_get_toolbar (MidoriViewable* viewable)
if (!history->toolbar)
{
GtkWidget* toolbar;
#if HAVE_SQLITE
GtkToolItem* toolitem;
#endif
toolbar = gtk_toolbar_new ();
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
history->toolbar = toolbar;
#if HAVE_SQLITE
toolitem = gtk_tool_button_new_from_stock (STOCK_BOOKMARK_ADD);
gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
_("Bookmark the selected history item"));
gtk_tool_item_set_is_important (toolitem, TRUE);
g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_history_add_clicked_cb), history);
G_CALLBACK (midori_history_bookmark_add_cb), history);
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
gtk_widget_show (GTK_WIDGET (toolitem));
history->bookmark = GTK_WIDGET (toolitem);
@ -457,15 +389,12 @@ midori_history_get_toolbar (MidoriViewable* viewable)
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
gtk_widget_show (GTK_WIDGET (toolitem));
history->clear = GTK_WIDGET (toolitem);
midori_history_cursor_or_row_changed_cb (
GTK_TREE_VIEW (history->treeview), history);
g_signal_connect (history->bookmark, "destroy",
G_CALLBACK (gtk_widget_destroyed), &history->bookmark);
g_signal_connect (history->delete, "destroy",
G_CALLBACK (gtk_widget_destroyed), &history->delete);
g_signal_connect (history->clear, "destroy",
G_CALLBACK (gtk_widget_destroyed), &history->clear);
#endif
}
return history->toolbar;
@ -479,6 +408,51 @@ midori_history_viewable_iface_init (MidoriViewableIface* iface)
iface->get_toolbar = midori_history_get_toolbar;
}
static void
midori_history_add_item_cb (KatzeArray* array,
KatzeItem* item,
MidoriHistory* history)
{
GtkTreeView* treeview = GTK_TREE_VIEW (history->treeview);
GtkTreeModel* model = gtk_tree_view_get_model (treeview);
GtkTreeIter iter;
KatzeItem* today;
time_t current_time;
current_time = time (NULL);
if (gtk_tree_model_iter_children (model, &iter, NULL))
{
gint64 day;
gboolean has_today;
gtk_tree_model_get (model, &iter, 0, &today, -1);
day = katze_item_get_added (today);
has_today = sokoke_days_between ((time_t*)&day, &current_time) == 0;
g_object_unref (today);
if (has_today)
{
gchar* tooltip = g_markup_escape_text (katze_item_get_uri (item), -1);
KatzeItem* copy = katze_item_copy (item);
gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), NULL, &iter,
0, 0, copy, 1, tooltip, -1);
g_object_unref (copy);
g_free (tooltip);
return;
}
}
today = (KatzeItem*)katze_array_new (KATZE_TYPE_ITEM);
katze_item_set_added (today, current_time);
katze_item_set_meta_integer (today, "day",
sokoke_time_t_to_julian (&current_time));
gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &iter, NULL,
0, 0, today, -1);
/* That's an invisible dummy, so we always have an expander */
gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), NULL, &iter,
0, 0, NULL, -1);
}
static void
midori_history_set_app (MidoriHistory* history,
MidoriApp* app)
@ -487,7 +461,9 @@ midori_history_set_app (MidoriHistory* history,
if (history->array)
{
g_object_unref (history->array);
g_signal_handlers_disconnect_by_func (history->array,
midori_history_add_item_cb, history);
katze_object_assign (history->array, NULL);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (history->treeview));
gtk_tree_store_clear (GTK_TREE_STORE (model));
}
@ -498,11 +474,11 @@ midori_history_set_app (MidoriHistory* history,
g_object_ref (app);
history->array = katze_object_get_object (app, "history");
g_signal_connect (history->array, "add-item",
G_CALLBACK (midori_history_add_item_cb), history);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (history->treeview));
#if HAVE_SQLITE
if (history->array)
midori_history_read_from_db (history, GTK_TREE_STORE (model), NULL, 0, NULL);
#endif
midori_history_read_from_db_to_model (history, GTK_TREE_STORE (model), NULL, 0, NULL);
}
static void
@ -572,36 +548,60 @@ midori_history_treeview_render_icon_cb (GtkTreeViewColumn* column,
}
}
#if HAVE_SQLITE
static void
midori_history_treeview_render_text_cb (GtkTreeViewColumn* column,
GtkCellRenderer* renderer,
GtkTreeModel* model,
GtkTreeIter* iter,
GtkWidget* treeview)
{
KatzeItem* item;
gtk_tree_model_get (model, iter, 0, &item, -1);
if (KATZE_ITEM_IS_BOOKMARK (item))
g_object_set (renderer, "markup", NULL,
"text", katze_item_get_name (item), NULL);
else if (KATZE_ITEM_IS_FOLDER (item))
g_object_set (renderer, "markup", NULL,
"text", midori_history_format_date (item), NULL);
else
g_object_set (renderer, "markup", _("<i>Separator</i>"), NULL);
if (item)
g_object_unref (item);
}
static void
midori_history_row_activated_cb (GtkTreeView* treeview,
GtkTreePath* path,
GtkTreeViewColumn* column,
MidoriHistory* history)
GtkTreePath* path,
GtkTreeViewColumn* column,
MidoriHistory* history)
{
GtkTreeModel* model;
GtkTreeIter iter;
KatzeItem* item;
const gchar* uri;
model = gtk_tree_view_get_model (treeview);
if (gtk_tree_model_get_iter (model, &iter, path))
{
gtk_tree_model_get (model, &iter, 0, &item, -1);
if (!item)
return;
uri = katze_item_get_uri (item);
if (uri && *uri)
if (KATZE_ITEM_IS_BOOKMARK (item))
{
MidoriBrowser* browser;
const gchar* uri;
uri = katze_item_get_uri (item);
browser = midori_browser_get_for_widget (GTK_WIDGET (history));
midori_browser_set_current_uri (browser, uri);
g_object_unref (item);
return;
}
if (gtk_tree_view_row_expanded (treeview, path))
gtk_tree_view_collapse_row (treeview, path);
else
gtk_tree_view_expand_row (treeview, path, FALSE);
g_object_unref (item);
}
}
@ -624,9 +624,8 @@ midori_history_popup_item (GtkWidget* menu,
gtk_label_set_text_with_mnemonic (GTK_LABEL (gtk_bin_get_child (
GTK_BIN (menuitem))), label);
if (!strcmp (stock_id, GTK_STOCK_EDIT))
gtk_widget_set_sensitive (menuitem,
KATZE_IS_ARRAY (item) || uri != NULL);
else if (!KATZE_IS_ARRAY (item) && strcmp (stock_id, GTK_STOCK_DELETE))
gtk_widget_set_sensitive (menuitem, uri != NULL);
else if (katze_item_get_uri (item) && strcmp (stock_id, GTK_STOCK_DELETE))
gtk_widget_set_sensitive (menuitem, uri != NULL);
g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
g_signal_connect (menuitem, "activate", G_CALLBACK (callback), history);
@ -660,26 +659,31 @@ midori_history_open_in_tab_activate_cb (GtkWidget* menuitem,
guint n;
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
if (KATZE_IS_ARRAY (item))
if (KATZE_ITEM_IS_FOLDER (item))
{
sqlite3* db;
gchar* sqlcmd;
KatzeItem* child;
KatzeArray* array;
guint i = 0;
while ((child = katze_array_get_nth_item (KATZE_ARRAY (item), i)))
db = g_object_get_data (G_OBJECT (history->array), "db");
sqlcmd = g_strdup_printf ("SELECT uri, title, date, day "
"FROM history WHERE day = %d "
"GROUP BY uri ORDER BY date ASC",
(int)katze_item_get_added (item));
array = katze_array_from_sqlite (db, sqlcmd);
g_free (sqlcmd);
while ((child = katze_array_get_nth_item (KATZE_ARRAY (array), i++)))
{
if ((uri = katze_item_get_uri (child)) && *uri)
{
MidoriBrowser* browser;
MidoriWebSettings* settings;
browser = midori_browser_get_for_widget (GTK_WIDGET (history));
n = midori_browser_add_item (browser, child);
settings = katze_object_get_object (browser, "settings");
if (!katze_object_get_boolean (settings, "open-tabs-in-the-background"))
midori_browser_set_current_page (browser, n);
g_object_unref (settings);
midori_browser_set_current_page_smartly (browser, n);
}
i++;
}
}
else
@ -687,14 +691,10 @@ midori_history_open_in_tab_activate_cb (GtkWidget* menuitem,
if ((uri = katze_item_get_uri (item)) && *uri)
{
MidoriBrowser* browser;
MidoriWebSettings* settings;
browser = midori_browser_get_for_widget (GTK_WIDGET (history));
n = midori_browser_add_item (browser, item);
settings = katze_object_get_object (browser, "settings");
if (!katze_object_get_boolean (settings, "open-tabs-in-the-background"))
midori_browser_set_current_page (browser, n);
g_object_unref (settings);
midori_browser_set_current_page_smartly (browser, n);
}
}
}
@ -718,22 +718,6 @@ midori_history_open_in_window_activate_cb (GtkWidget* menuitem,
}
}
static void
midori_history_bookmark_activate_cb (GtkWidget* menuitem,
MidoriHistory* history)
{
KatzeItem* item;
const gchar* uri;
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
uri = katze_item_get_uri (item);
if (uri && *uri)
{
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (history));
midori_browser_edit_bookmark_dialog_new (browser, item, TRUE, FALSE);
}
}
static void
midori_history_popup (GtkWidget* widget,
@ -745,7 +729,7 @@ midori_history_popup (GtkWidget* widget,
GtkWidget* menuitem;
menu = gtk_menu_new ();
if (KATZE_IS_ARRAY (item))
if (!katze_item_get_uri (item))
midori_history_popup_item (menu,
STOCK_TAB_NEW, _("Open all in _Tabs"),
item, midori_history_open_in_tab_activate_cb, history);
@ -758,7 +742,7 @@ midori_history_popup (GtkWidget* widget,
midori_history_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"),
item, midori_history_open_in_window_activate_cb, history);
midori_history_popup_item (menu, STOCK_BOOKMARK_ADD, NULL,
item, midori_history_bookmark_activate_cb, history);
item, midori_history_bookmark_add_cb, history);
}
menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
@ -863,8 +847,8 @@ midori_history_row_expanded_cb (GtkTreeView* treeview,
model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
gtk_tree_model_get (model, iter, 0, &item, -1);
midori_history_read_from_db (history, GTK_TREE_STORE (model),
iter, katze_item_get_added (item), NULL);
midori_history_read_from_db_to_model (history, GTK_TREE_STORE (model),
iter, katze_item_get_meta_integer (item, "day"), NULL);
g_object_unref (item);
}
@ -884,7 +868,7 @@ midori_history_row_collapsed_cb (GtkTreeView *treeview,
gtk_tree_store_remove (treestore, &child);
/* That's an invisible dummy, so we always have an expander */
gtk_tree_store_insert_with_values (treestore, &child, parent,
0, 0, NULL, 1, NULL, -1);
0, 0, NULL, -1);
}
static gboolean
@ -898,7 +882,7 @@ midori_history_filter_timeout_cb (gpointer data)
treestore = GTK_TREE_STORE (model);
gtk_tree_store_clear (treestore);
midori_history_read_from_db (history, treestore, NULL, 0, history->filter);
midori_history_read_from_db_to_model (history, treestore, NULL, 0, history->filter);
return FALSE;
}
@ -913,7 +897,7 @@ midori_history_filter_entry_changed_cb (GtkEntry* entry,
midori_history_filter_timeout_cb, history);
katze_assign (history->filter, g_strdup (gtk_entry_get_text (entry)));
}
#endif
static void
midori_history_filter_entry_clear_cb (GtkEntry* entry,
gint icon_pos,
@ -939,17 +923,19 @@ midori_history_init (MidoriHistory* history)
/* Create the filter entry */
entry = gtk_icon_entry_new ();
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_SECONDARY, GTK_STOCK_CLEAR);
GTK_ICON_ENTRY_PRIMARY,
GTK_STOCK_FIND);
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_SECONDARY,
GTK_STOCK_CLEAR);
gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_SECONDARY, TRUE);
GTK_ICON_ENTRY_SECONDARY,
TRUE);
g_signal_connect (entry, "icon-release",
G_CALLBACK (midori_history_filter_entry_clear_cb), history);
#if HAVE_SQLITE
g_signal_connect (entry, "changed",
G_CALLBACK (midori_history_filter_entry_changed_cb), history);
#endif
box = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (box), gtk_label_new (_("Filter:")), FALSE, FALSE, 3);
gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 3);
gtk_widget_show_all (box);
gtk_box_pack_start (GTK_BOX (history), box, FALSE, FALSE, 5);
@ -958,6 +944,7 @@ midori_history_init (MidoriHistory* history)
model = gtk_tree_store_new (2, KATZE_TYPE_ITEM, G_TYPE_STRING);
treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (treeview), 1);
column = gtk_tree_view_column_new ();
renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
@ -966,18 +953,14 @@ midori_history_init (MidoriHistory* history)
treeview, NULL);
renderer_text = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column, renderer_text, FALSE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_text,
"text", 1, NULL);
gtk_tree_view_column_set_cell_data_func (column, renderer_text,
(GtkTreeCellDataFunc)midori_history_treeview_render_text_cb,
treeview, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
g_object_unref (model);
#if HAVE_SQLITE
g_object_connect (treeview,
"signal::row-activated",
midori_history_row_activated_cb, history,
"signal::cursor-changed",
midori_history_cursor_or_row_changed_cb, history,
"signal::columns-changed",
midori_history_cursor_or_row_changed_cb, history,
"signal::button-release-event",
midori_history_button_release_event_cb, history,
"signal::key-release-event",
@ -989,7 +972,6 @@ midori_history_init (MidoriHistory* history)
"signal::popup-menu",
midori_history_popup_menu_cb, history,
NULL);
#endif
gtk_widget_show (treeview);
gtk_box_pack_start (GTK_BOX (history), treeview, TRUE, TRUE, 0);
history->treeview = treeview;
@ -1006,8 +988,8 @@ midori_history_finalize (GObject* object)
if (history->app)
g_object_unref (history->app);
/* FIXME: We don't unref items (last argument is FALSE) because
our reference counting is incorrect. */
g_signal_handlers_disconnect_by_func (history->array,
midori_history_add_item_cb, history);
g_object_unref (history->array);
katze_assign (history->filter, NULL);
}

View file

@ -112,7 +112,10 @@ midori_transfers_button_clear_clicked_cb (GtkToolItem* toolitem,
status = webkit_download_get_status (download);
if (status == WEBKIT_DOWNLOAD_STATUS_FINISHED
|| status == WEBKIT_DOWNLOAD_STATUS_CANCELLED)
{
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
n--; /* Decrement n since we just removed it */
}
g_object_unref (download);
#endif
}

View file

@ -12,6 +12,8 @@ midori/midori-view.c
midori/midori-preferences.c
midori/midori-searchaction.c
midori/sokoke.c
toolbars/midori-findbar.c
toolbars/midori-transferbar.c
panels/midori-bookmarks.c
panels/midori-console.c
panels/midori-extensions.c
@ -30,17 +32,21 @@ extensions/colorful-tabs.c
extensions/cookie-manager/cookie-manager.c
extensions/cookie-manager/cookie-manager-page.c
extensions/cookie-manager/main.c
extensions/copy-tabs.c
extensions/external-applications.vala
extensions/feed-panel/feed-atom.c
extensions/feed-panel/feed-panel.c
extensions/feed-panel/feed-parse.c
extensions/feed-panel/feed-rss.c
extensions/feed-panel/main.c
extensions/formhistory.c
extensions/history-list.vala
extensions/mouse-gestures.c
extensions/page-holder.c
extensions/shortcuts.c
extensions/status-clock.c
extensions/statusbar-features.c
extensions/tab-panel.c
extensions/tab-switcher.c
extensions/tabs-minimized.c
extensions/toolbar-editor.c
extensions/web-cache.c

1417
po/ca.po

File diff suppressed because it is too large Load diff

1404
po/cs.po

File diff suppressed because it is too large Load diff

1410
po/da.po

File diff suppressed because it is too large Load diff

1323
po/de.po

File diff suppressed because it is too large Load diff

1603
po/el.po

File diff suppressed because it is too large Load diff

1280
po/es.po

File diff suppressed because it is too large Load diff

1205
po/fr.po

File diff suppressed because it is too large Load diff

1170
po/gl.po

File diff suppressed because it is too large Load diff

1442
po/hr.po

File diff suppressed because it is too large Load diff

3227
po/hu.po

File diff suppressed because it is too large Load diff

1440
po/ja.po

File diff suppressed because it is too large Load diff

2221
po/nl.po

File diff suppressed because it is too large Load diff

530
po/pl.po

File diff suppressed because it is too large Load diff

1408
po/pt.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

1764
po/ro.po

File diff suppressed because it is too large Load diff

1321
po/ru.po

File diff suppressed because it is too large Load diff

1459
po/sk.po

File diff suppressed because it is too large Load diff

958
po/tr.po

File diff suppressed because it is too large Load diff

2316
po/ug.po

File diff suppressed because it is too large Load diff

1406
po/uk.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

327
toolbars/midori-findbar.c Normal file
View file

@ -0,0 +1,327 @@
/*
Copyright (C) 2008-2010 Christian Dywan <christian@twotoasts.de>
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.
*/
#include "midori-findbar.h"
#include "midori-browser.h"
#include "gtkiconentry.h"
#include "sokoke.h"
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#if HAVE_CONFIG_H
#include "config.h"
#endif
struct _MidoriFindbar
{
GtkToolbar parent_instance;
GtkWidget* find_text;
GtkToolItem* previous;
GtkToolItem* next;
GtkToolItem* find_case;
GtkToolItem* find_highlight;
GtkToolItem* find_close;
gboolean find_typing;
};
struct _MidoriFindbarClass
{
GtkToolbarClass parent_class;
};
G_DEFINE_TYPE (MidoriFindbar, midori_findbar, GTK_TYPE_TOOLBAR);
static void
midori_findbar_class_init (MidoriFindbarClass* class)
{
/* Nothing to do */
}
static void
midori_findbar_done (MidoriFindbar* findbar)
{
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (findbar));
GtkWidget* view = midori_browser_get_current_tab (browser);
midori_view_unmark_text_matches (MIDORI_VIEW (view));
gtk_widget_hide (GTK_WIDGET (findbar));
findbar->find_typing = FALSE;
gtk_window_set_focus (GTK_WINDOW (browser), view);
}
static gboolean
midori_findbar_find_key_press_event_cb (MidoriFindbar* findbar,
GdkEventKey* event)
{
if (event->keyval == GDK_Escape)
{
midori_findbar_done (findbar);
return TRUE;
}
return FALSE;
}
static void
midori_findbar_entry_clear_icon_released_cb (GtkIconEntry* entry,
gint icon_pos,
gint button,
gpointer user_data)
{
if (icon_pos == GTK_ICON_ENTRY_SECONDARY)
gtk_entry_set_text (GTK_ENTRY (entry), "");
}
void
midori_findbar_find (MidoriFindbar* findbar,
gboolean forward)
{
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (findbar));
const gchar* text;
gboolean case_sensitive;
GtkWidget* view;
if (!(view = midori_browser_get_current_tab (browser)))
return;
text = gtk_entry_get_text (GTK_ENTRY (findbar->find_text));
case_sensitive = gtk_toggle_tool_button_get_active (
GTK_TOGGLE_TOOL_BUTTON (findbar->find_case));
midori_view_search_text (MIDORI_VIEW (view), text, case_sensitive, forward);
}
void
midori_findbar_invoke (MidoriFindbar* findbar)
{
if (gtk_widget_get_visible (GTK_WIDGET (findbar)))
midori_findbar_done (findbar);
else
{
MidoriBrowser* browser = midori_browser_get_for_widget (findbar->find_text);
GtkWidget* view = midori_browser_get_current_tab (browser);
const gchar* text;
#if !HAVE_HILDON
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (findbar->find_text),
GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_FIND);
gtk_widget_show (GTK_WIDGET (findbar->find_case));
#endif
gtk_widget_show (GTK_WIDGET (findbar->find_highlight));
gtk_widget_show (GTK_WIDGET (findbar->find_close));
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));
}
static void
midori_findbar_next_activate_cb (GtkWidget* entry,
MidoriFindbar* findbar)
{
midori_findbar_find (findbar, TRUE);
}
static void
midori_findbar_previous_clicked_cb (GtkWidget* entry,
MidoriFindbar* findbar)
{
midori_findbar_find (findbar, FALSE);
}
static void
midori_findbar_button_close_clicked_cb (GtkWidget* widget,
MidoriFindbar* findbar)
{
midori_findbar_done (findbar);
}
static void
midori_findbar_text_changed_cb (GtkWidget* entry,
MidoriFindbar* findbar)
{
if (findbar->find_typing)
{
MidoriBrowser* browser = midori_browser_get_for_widget (entry);
GtkWidget* view = midori_browser_get_current_tab (browser);
const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
midori_view_unmark_text_matches (MIDORI_VIEW (view));
if (g_utf8_strlen (text, -1) > 2)
midori_findbar_find (findbar, TRUE);
}
}
static gboolean
midori_findbar_text_focus_out_event_cb (GtkWidget* entry,
GdkEventFocus* event,
MidoriFindbar* findbar)
{
if (findbar->find_typing)
midori_findbar_done (findbar);
return FALSE;
}
static void
midori_findbar_highlight_toggled_cb (GtkToggleToolButton* toolitem,
MidoriFindbar* findbar)
{
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (findbar));
GtkWidget* view = midori_browser_get_current_tab (browser);
gboolean highlight = gtk_toggle_tool_button_get_active (toolitem);
midori_view_set_highlight_text_matches (MIDORI_VIEW (view), highlight);
}
static void
midori_findbar_init (MidoriFindbar* findbar)
{
GtkToolItem* toolitem;
gtk_widget_set_name (GTK_WIDGET (findbar), "MidoriFindbar");
gtk_toolbar_set_icon_size (GTK_TOOLBAR (findbar), GTK_ICON_SIZE_MENU);
gtk_toolbar_set_style (GTK_TOOLBAR (findbar), GTK_TOOLBAR_BOTH_HORIZ);
g_signal_connect (findbar, "key-press-event",
G_CALLBACK (midori_findbar_find_key_press_event_cb), NULL);
toolitem = gtk_tool_item_new ();
gtk_container_set_border_width (GTK_CONTAINER (toolitem), 6);
gtk_container_add (GTK_CONTAINER (toolitem),
/* i18n: A panel at the bottom, to search text in pages */
gtk_label_new_with_mnemonic (_("_Inline Find:")));
gtk_toolbar_insert (GTK_TOOLBAR (findbar), toolitem, -1);
findbar->find_text = gtk_icon_entry_new ();
#if !HAVE_HILDON
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (findbar->find_text),
GTK_ICON_ENTRY_PRIMARY,
GTK_STOCK_FIND);
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (findbar->find_text),
GTK_ICON_ENTRY_SECONDARY,
GTK_STOCK_CLEAR);
gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (findbar->find_text),
GTK_ICON_ENTRY_SECONDARY, TRUE);
#endif
g_signal_connect (findbar->find_text, "icon-release",
G_CALLBACK (midori_findbar_entry_clear_icon_released_cb), NULL);
g_signal_connect (findbar->find_text, "activate",
G_CALLBACK (midori_findbar_next_activate_cb), findbar);
g_signal_connect (findbar->find_text, "changed",
G_CALLBACK (midori_findbar_text_changed_cb), findbar);
g_signal_connect (findbar->find_text, "focus-out-event",
G_CALLBACK (midori_findbar_text_focus_out_event_cb), findbar);
toolitem = gtk_tool_item_new ();
gtk_container_add (GTK_CONTAINER (toolitem), findbar->find_text);
gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolitem), TRUE);
gtk_toolbar_insert (GTK_TOOLBAR (findbar), toolitem, -1);
#if HAVE_HILDON
findbar->find_case = gtk_toggle_tool_button_new ();
findbar->find_highlight = gtk_toggle_tool_button_new ();
#else
findbar->previous = gtk_tool_button_new_from_stock (GTK_STOCK_GO_BACK);
g_signal_connect (findbar->previous, "clicked",
G_CALLBACK (midori_findbar_previous_clicked_cb), findbar);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (findbar->previous), _("Previous"));
gtk_tool_item_set_is_important (findbar->previous, TRUE);
gtk_toolbar_insert (GTK_TOOLBAR (findbar), findbar->previous, -1);
findbar->next = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
g_signal_connect (findbar->next, "clicked",
G_CALLBACK (midori_findbar_next_activate_cb), findbar);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (findbar->next), _("Next"));
gtk_tool_item_set_is_important (findbar->next, TRUE);
gtk_toolbar_insert (GTK_TOOLBAR (findbar), findbar->next, -1);
findbar->find_case = gtk_toggle_tool_button_new_from_stock (GTK_STOCK_SPELL_CHECK);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (findbar->find_case), _("Match Case"));
gtk_tool_item_set_is_important (GTK_TOOL_ITEM (findbar->find_case), TRUE);
gtk_toolbar_insert (GTK_TOOLBAR (findbar), findbar->find_case, -1);
findbar->find_highlight = gtk_toggle_tool_button_new_from_stock (
GTK_STOCK_SELECT_ALL);
#endif
g_signal_connect (findbar->find_highlight, "toggled",
G_CALLBACK (midori_findbar_highlight_toggled_cb), findbar);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (findbar->find_highlight),
_("Highlight Matches"));
gtk_tool_item_set_is_important (GTK_TOOL_ITEM (findbar->find_highlight), TRUE);
gtk_toolbar_insert (GTK_TOOLBAR (findbar), findbar->find_highlight, -1);
toolitem = gtk_separator_tool_item_new ();
gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (toolitem), FALSE);
#if !HAVE_HILDON
gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolitem), TRUE);
#endif
gtk_toolbar_insert (GTK_TOOLBAR (findbar), toolitem, -1);
findbar->find_close = gtk_tool_button_new_from_stock (GTK_STOCK_CLOSE);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (findbar->find_close),
_("Close Findbar"));
g_signal_connect (findbar->find_close, "clicked",
G_CALLBACK (midori_findbar_button_close_clicked_cb), findbar);
#if HAVE_OSX
gtk_toolbar_insert (GTK_TOOLBAR (findbar), findbar->find_close, 0);
#else
gtk_toolbar_insert (GTK_TOOLBAR (findbar), findbar->find_close, -1);
#endif
sokoke_container_show_children (GTK_CONTAINER (findbar));
}
void
midori_findbar_set_can_find (MidoriFindbar* findbar,
gboolean can_find)
{
gtk_widget_set_sensitive (GTK_WIDGET (findbar->next), can_find);
gtk_widget_set_sensitive (GTK_WIDGET (findbar->previous), can_find);
}
void
midori_findbar_search_text (MidoriFindbar* findbar,
GtkWidget* view,
gboolean found,
gchar* typing)
{
const gchar* text;
gboolean case_sensitive;
gboolean highlight;
if (typing)
{
MidoriBrowser* browser = midori_browser_get_for_widget (view);
gint position = -1;
findbar->find_typing = TRUE;
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
findbar->find_highlight), TRUE);
gtk_widget_hide (GTK_WIDGET (findbar->find_case));
gtk_widget_hide (GTK_WIDGET (findbar->find_highlight));
gtk_widget_hide (GTK_WIDGET (findbar->find_close));
if (!gtk_widget_get_visible (GTK_WIDGET (findbar)))
gtk_entry_set_text (GTK_ENTRY (findbar->find_text), "");
gtk_widget_show (GTK_WIDGET (findbar));
gtk_window_set_focus (GTK_WINDOW (browser), findbar->find_text);
gtk_editable_insert_text (GTK_EDITABLE (findbar->find_text),
typing, -1, &position);
gtk_editable_set_position (GTK_EDITABLE (findbar->find_text), -1);
}
if (gtk_widget_get_visible (GTK_WIDGET (findbar)) && !typing)
{
#if !HAVE_HILDON
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (findbar->find_text),
GTK_ICON_ENTRY_PRIMARY, (found) ? GTK_STOCK_FIND : GTK_STOCK_STOP);
#endif
text = gtk_entry_get_text (GTK_ENTRY (findbar->find_text));
case_sensitive = gtk_toggle_tool_button_get_active (
GTK_TOGGLE_TOOL_BUTTON (findbar->find_case));
midori_view_mark_text_matches (MIDORI_VIEW (view), text, case_sensitive);
highlight = gtk_toggle_tool_button_get_active (
GTK_TOGGLE_TOOL_BUTTON (findbar->find_highlight));
midori_view_set_highlight_text_matches (MIDORI_VIEW (view), highlight);
}
}

57
toolbars/midori-findbar.h Normal file
View file

@ -0,0 +1,57 @@
/*
Copyright (C) 2010 Christian Dywan <christian@twotoasts.de>
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.
*/
#ifndef __MIDORI_FINDBAR_H__
#define __MIDORI_FINDBAR_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define MIDORI_TYPE_FINDBAR \
(midori_findbar_get_type ())
#define MIDORI_FINDBAR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_FINDBAR, MidoriFindbar))
#define MIDORI_FINDBAR_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_FINDBAR, MidoriFindbarClass))
#define MIDORI_IS_FINDBAR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_FINDBAR))
#define MIDORI_IS_FINDBAR_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_FINDBAR))
#define MIDORI_FINDBAR_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_FINDBAR, MidoriFindbarClass))
typedef struct _MidoriFindbar MidoriFindbar;
typedef struct _MidoriFindbarClass MidoriFindbarClass;
GType
midori_findbar_get_type (void);
void
midori_findbar_invoke (MidoriFindbar* findbar);
void
midori_findbar_find (MidoriFindbar* findbar,
gboolean forward);
void
midori_findbar_set_can_find (MidoriFindbar* findbar,
gboolean can_find);
void
midori_findbar_search_text (MidoriFindbar* findbar,
GtkWidget* view,
gboolean found,
gchar* typing);
G_END_DECLS
#endif /* __MIDORI_FINDBAR_H__ */

View file

@ -0,0 +1,319 @@
/*
Copyright (C) 2010 Christian Dywan <christian@twotoasts.de>
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.
*/
#include "midori-transferbar.h"
#include "midori-browser.h"
#include "sokoke.h"
#include <glib/gi18n.h>
struct _MidoriTransferbar
{
GtkToolbar parent_instance;
GList* infos;
GtkToolItem* clear;
};
struct _MidoriTransferbarClass
{
GtkToolbarClass parent_class;
};
G_DEFINE_TYPE (MidoriTransferbar, midori_transferbar, GTK_TYPE_TOOLBAR);
static void
midori_transferbar_class_init (MidoriTransferbarClass* class)
{
/* Nothing to do */
}
#if WEBKIT_CHECK_VERSION (1, 1, 3)
typedef struct
{
WebKitDownload* download;
GtkWidget* button;
GtkWidget* toolitem;
MidoriTransferbar* transferbar;
} TransferInfo;
static gboolean
midori_transferbar_info_free (gpointer data)
{
TransferInfo* info = data;
MidoriTransferbar* transferbar = info->transferbar;
transferbar->infos = g_list_remove (transferbar->infos, info);
g_object_unref (info->download);
gtk_widget_destroy (info->toolitem);
g_free (info);
if (!transferbar->infos || !g_list_nth_data (transferbar->infos, 0))
gtk_widget_hide (GTK_WIDGET (transferbar->clear));
return FALSE;
}
static void
midori_transferbar_button_destroy_cb (GtkWidget* button,
TransferInfo* info)
{
g_idle_add (midori_transferbar_info_free, info);
}
static void
midori_transferbar_download_notify_progress_cb (WebKitDownload* download,
GParamSpec* pspec,
GtkWidget* progress)
{
gchar* current;
gchar* total;
gchar* size_text;
gchar* text;
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress),
webkit_download_get_progress (download));
current = g_format_size_for_display (webkit_download_get_current_size (download));
total = g_format_size_for_display (webkit_download_get_total_size (download));
size_text = g_strdup_printf (_("%s of %s"), current, total);
g_free (current);
g_free (total);
text = g_strdup_printf ("%s (%s)",
gtk_progress_bar_get_text (GTK_PROGRESS_BAR (progress)),
size_text);
gtk_widget_set_tooltip_text (progress, text);
}
static void
midori_transferbar_download_notify_status_cb (WebKitDownload* download,
GParamSpec* pspec,
TransferInfo* info)
{
GtkWidget* button = info->button;
GtkWidget* icon;
switch (webkit_download_get_status (download))
{
case WEBKIT_DOWNLOAD_STATUS_FINISHED:
{
MidoriBrowser* browser = midori_browser_get_for_widget (button);
MidoriWebSettings* settings = midori_browser_get_settings (browser);
icon = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
gtk_button_set_image (GTK_BUTTON (button), icon);
if (g_object_get_data (G_OBJECT (download), "open-download"))
gtk_button_clicked (GTK_BUTTON (button));
if (katze_object_get_boolean (settings, "notify-transfer-completed"))
{
const gchar* uri = webkit_download_get_destination_uri (download);
gchar* path = soup_uri_decode (uri);
gchar* filename = g_strrstr (path, "/") + 1;
gchar* msg = g_strdup_printf (
_("The file '<b>%s</b>' has been downloaded."), filename);
g_free (path);
g_signal_emit_by_name (browser, "send-notification",
_("Transfer completed"), msg);
g_free (msg);
}
break;
}
case WEBKIT_DOWNLOAD_STATUS_CANCELLED:
case WEBKIT_DOWNLOAD_STATUS_ERROR:
icon = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU);
gtk_button_set_image (GTK_BUTTON (button), icon);
break;
default:
break;
}
}
static void
midori_transferbar_download_button_clicked_cb (GtkWidget* button,
TransferInfo* info)
{
WebKitDownload* download = info->download;
switch (webkit_download_get_status (download))
{
case WEBKIT_DOWNLOAD_STATUS_STARTED:
webkit_download_cancel (download);
break;
case WEBKIT_DOWNLOAD_STATUS_FINISHED:
{
const gchar* uri = webkit_download_get_destination_uri (download);
if (sokoke_show_uri (gtk_widget_get_screen (button),
uri, gtk_get_current_event_time (), NULL))
gtk_widget_destroy (button);
break;
}
case WEBKIT_DOWNLOAD_STATUS_CANCELLED:
gtk_widget_destroy (button);
default:
break;
}
}
void
midori_transferbar_add_download_item (MidoriTransferbar* transferbar,
WebKitDownload* download)
{
GtkWidget* box;
GtkWidget* icon;
GtkToolItem* toolitem;
GtkWidget* button;
GtkWidget* progress;
const gchar* uri;
gint width;
TransferInfo* info;
box = gtk_hbox_new (FALSE, 0);
progress = gtk_progress_bar_new ();
gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (progress),
PANGO_ELLIPSIZE_MIDDLE);
if ((uri = webkit_download_get_destination_uri (download)))
{
gchar* path = soup_uri_decode (uri);
gchar* filename = g_strrstr (path, "/") + 1;
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), filename);
g_free (path);
}
else
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress),
webkit_download_get_suggested_filename (download));
sokoke_widget_get_text_size (progress, "M", &width, NULL);
gtk_widget_set_size_request (progress, width * 10, 1);
/* Avoid a bug in WebKit */
if (webkit_download_get_status (download) != WEBKIT_DOWNLOAD_STATUS_CREATED)
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress),
webkit_download_get_progress (download));
gtk_box_pack_start (GTK_BOX (box), progress, FALSE, FALSE, 0);
icon = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU);
button = gtk_button_new ();
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
gtk_container_add (GTK_CONTAINER (button), icon);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
toolitem = gtk_tool_item_new ();
gtk_container_add (GTK_CONTAINER (toolitem), box);
gtk_widget_show_all (GTK_WIDGET (toolitem));
gtk_toolbar_insert (GTK_TOOLBAR (transferbar), toolitem, 0);
gtk_widget_show (GTK_WIDGET (transferbar->clear));
info = g_new (TransferInfo, 1);
info->download = g_object_ref (download);
info->button = button;
info->toolitem = GTK_WIDGET (toolitem);
info->transferbar = transferbar;
g_signal_connect (button, "destroy",
G_CALLBACK (midori_transferbar_button_destroy_cb), info);
transferbar->infos = g_list_prepend (transferbar->infos, info);
g_signal_connect (download, "notify::progress",
G_CALLBACK (midori_transferbar_download_notify_progress_cb), progress);
g_signal_connect (download, "notify::status",
G_CALLBACK (midori_transferbar_download_notify_status_cb), info);
g_signal_connect (button, "clicked",
G_CALLBACK (midori_transferbar_download_button_clicked_cb), info);
}
static void
midori_transferbar_clear_clicked_cb (GtkWidget* button,
MidoriTransferbar* transferbar)
{
GList* list;
for (list = transferbar->infos; list != NULL; list = g_list_next (list))
{
TransferInfo* info = list->data;
WebKitDownloadStatus status = webkit_download_get_status (info->download);
if (status == WEBKIT_DOWNLOAD_STATUS_ERROR
|| status == WEBKIT_DOWNLOAD_STATUS_CANCELLED
|| status == WEBKIT_DOWNLOAD_STATUS_FINISHED)
{
gtk_widget_destroy (info->button);
}
}
}
#endif
static void
midori_transferbar_init (MidoriTransferbar* transferbar)
{
gtk_toolbar_set_style (GTK_TOOLBAR (transferbar), GTK_TOOLBAR_BOTH_HORIZ);
gtk_toolbar_set_icon_size (GTK_TOOLBAR (transferbar), GTK_ICON_SIZE_MENU);
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;
}
gboolean
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;
for (list = transferbar->infos; list != NULL; list = g_list_next (list))
{
TransferInfo* info = list->data;
WebKitDownloadStatus status = webkit_download_get_status (info->download);
if (status != WEBKIT_DOWNLOAD_STATUS_FINISHED
&& status != WEBKIT_DOWNLOAD_STATUS_CANCELLED
&& status != WEBKIT_DOWNLOAD_STATUS_ERROR)
{
all_done = FALSE;
break;
}
}
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),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
_("Some files are being downloaded"));
gtk_window_set_title (GTK_WINDOW (dialog),
_("Some files are being downloaded"));
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gtk_dialog_add_button (GTK_DIALOG (dialog),
_("_Quit Midori"), GTK_RESPONSE_ACCEPT);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
_("The transfers will be cancelled if Midori quits."));
}
if (dialog != NULL)
{
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_CANCEL)
cancel = TRUE;
gtk_widget_destroy (dialog);
}
return cancel;
}

View file

@ -0,0 +1,40 @@
/*
Copyright (C) 2010 Christian Dywan <christian@twotoasts.de>
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.
*/
#ifndef __MIDORI_TRANSFERBAR_H__
#define __MIDORI_TRANSFERBAR_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define MIDORI_TYPE_TRANSFERBAR \
(midori_transferbar_get_type ())
#define MIDORI_TRANSFERBAR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_TRANSFERBAR, MidoriTransferbar))
#define MIDORI_TRANSFERBAR_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_TRANSFERBAR, MidoriTransferbarClass))
#define MIDORI_IS_TRANSFERBAR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_TRANSFERBAR))
#define MIDORI_IS_TRANSFERBAR_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_TRANSFERBAR))
#define MIDORI_TRANSFERBAR_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_TRANSFERBAR, MidoriTransferbarClass))
typedef struct _MidoriTransferbar MidoriTransferbar;
typedef struct _MidoriTransferbarClass MidoriTransferbarClass;
GType
midori_transferbar_get_type (void);
G_END_DECLS
#endif /* __MIDORI_TRANSFERBAR_H__ */

74
wscript
View file

@ -29,15 +29,15 @@ from Configure import find_program_impl
major = 0
minor = 2
micro = 6
micro = 7
APPNAME = 'midori'
VERSION = str (major) + '.' + str (minor) + '.' + str (micro)
try:
git = Utils.cmd_output (['git', 'rev-parse', '--short', 'HEAD'], silent=True)
git = Utils.cmd_output (['git', 'describe'], silent=True)
if git:
VERSION = (VERSION + '-' + git).strip ()
VERSION = git.strip ()
except:
pass
@ -87,11 +87,14 @@ def configure (conf):
return dirvalue
conf.check_tool ('compiler_cc')
# Circumvent mandatory check for valac
if find_program_impl (conf.env, 'valac'):
conf.check_tool ('vala')
else:
conf.check_message ('program', 'valac', False, False)
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 ('glib2')
if option_enabled ('userdocs'):
@ -124,8 +127,6 @@ def configure (conf):
icons = 'no '
if is_mingw (conf.env) or Options.platform == 'win32':
if not conf.find_program ('convert', var='CONVERT'):
Utils.pprint ('YELLOW', 'midori.ico won\'t be created')
conf.find_program ('windres', var='WINRC')
conf.env['platform'] = 'win32'
@ -147,9 +148,6 @@ def configure (conf):
Utils.pprint ('BLUE', 'Mingw recognized, assuming cross compile.')
if conf.env['CONVERT'] and not conf.env['WINRC']:
Utils.pprint ('YELLOW', 'midori.ico won\'t be created')
dirname_default ('LIBDIR', os.path.join (conf.env['PREFIX'], 'lib'))
if conf.env['PREFIX'] == '/usr':
dirname_default ('SYSCONFDIR', '/etc')
@ -191,15 +189,6 @@ def configure (conf):
unique = 'no '
conf.define ('HAVE_UNIQUE', [0,1][unique == 'yes'])
if option_enabled ('sqlite'):
check_pkg ('sqlite3', '3.0', False, var='SQLITE')
sqlite = ['N/A','yes'][conf.env['HAVE_SQLITE'] == 1]
if sqlite != 'yes':
option_checkfatal ('sqlite', 'history database')
else:
sqlite = 'no '
conf.define ('HAVE_SQLITE', [0,1][sqlite == 'yes'])
if option_enabled ('libnotify'):
check_pkg ('libnotify', mandatory=False)
libnotify = ['N/A','yes'][conf.env['HAVE_LIBNOTIFY'] == 1]
@ -230,6 +219,7 @@ def configure (conf):
check_pkg ('libsoup-2.4', '2.29.3', False, var='LIBSOUP_2_29_3')
check_pkg ('libsoup-2.4', '2.29.91', False, var='LIBSOUP_2_29_91')
check_pkg ('libxml-2.0', '2.6')
check_pkg ('sqlite3', '3.0', True, var='SQLITE')
if conf.env['HAVE_LIBSOUP_2_27_90']:
idn = 'yes'
@ -291,7 +281,7 @@ def configure (conf):
conf.define ('MIDORI_MICRO_VERSION', micro)
conf.write_config_header ('config.h')
conf.env.append_value ('CCFLAGS', '-DHAVE_CONFIG_H')
conf.env.append_value ('CCFLAGS', '-DHAVE_CONFIG_H -include config.h'.split ())
debug_level = Options.options.debug_level
compiler = conf.env['CC_NAME']
if debug_level != '' and compiler != 'gcc':
@ -332,7 +322,6 @@ def configure (conf):
print '''
Localization: %(nls)s (intltool)
Icon optimizations: %(icons)s (rsvg-convert)
History: %(sqlite)s (sqlite3)
Notifications: %(libnotify)s (libnotify)
IDN support: %(idn)s (libidn or libsoup 2.27.90)
@ -380,8 +369,8 @@ 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 ('sqlite', 'history database support', group)
add_enable_option ('libnotify', 'notification support', group)
add_enable_option ('addons', 'building of extensions', group)
add_enable_option ('tests', 'building of tests', group, disable=True)
@ -415,31 +404,6 @@ def write_linguas_file (self):
write_linguas_file = feature ('intltool_po')(write_linguas_file)
def build (bld):
def image_to_win32ico (task):
'Converts an image to a Win32 ico'
if not os.path.exists (bld.env['CONVERT']):
return 1
infile = task.inputs[0].abspath (task.env)
outfile = task.outputs[0].abspath (task.env)
command = bld.env['CONVERT'] + ' -background transparent \
-geometry 16x16 -extent 16x16 ' + \
infile + ' ' + outfile
if Utils.exec_command (command):
return 1
if task.chmod:
os.chmod (outfile, task.chmod)
return 0
if bld.env['WINRC']:
obj = bld.new_task_gen ('copy',
fun = image_to_win32ico,
source = 'icons/16x16/midori.png',
target = 'data/midori.ico',
before = 'cc')
bld.add_group ()
bld.add_subdirs ('midori icons')
@ -533,7 +497,15 @@ def build (bld):
bld.install_files ('${MDATADIR}/' + APPNAME + '/res', 'data/autosuggestcontrol.css')
# FIXME: Determine the library naming for other platforms
if Options.platform == 'linux':
if bld.env['platform'] == 'win32':
extensions = os.listdir ('data/extensions')
for extension in extensions:
folder = 'lib' + extension + '.dll'
source = 'data/extensions/' + extension + '/config'
if os.path.exists (source):
bld.install_files ('${SYSCONFDIR}/xdg/' + APPNAME + \
'/extensions/' + folder, source)
elif Options.platform == 'linux':
extensions = os.listdir ('data/extensions')
for extension in extensions:
folder = 'lib' + extension + '.so'