Merge branch 'upstream-unstable'

This commit is contained in:
Yves-Alexis Perez 2011-01-31 08:08:02 +01:00
commit e51eca351f
68 changed files with 22313 additions and 16428 deletions

View file

@ -1,5 +1,22 @@
This file is licensed under the terms of the expat license, see the file EXPAT.
v0.3.0
+ Support libnotify 0.7
+ Copy-friendly URIs with %20
+ No blocking of typed URLs with adblock
+ Import from Netscape HTML
+ Bookmark im- and export fixes
+ Unit tests cleaned up and updated
+ Correct bookmark and search icon names
+ Better link menu handling
+ Certificate location on FreeBSD
+ Fix Russian keyboard issues
+ Stylesheet parsing improvements
+ Simplify language and panel options
+ Default to DuckDuckGo search
+ No Netscape plugins in extension panel
+ Easy user addon install infobar
v0.2.9
+ Add 'Identify As' to Statusbar Features
+ Don't restrict length of HTTP login passwords

View file

@ -13,7 +13,7 @@ There are several ways to contribute to the project:
For translating, have a look at the file TRANSLATE.
For helping with testing and triaging bug reports, you should registers with the bug tracker at http://www.twotoasts.de/bugs and join #midori on irc.freenode.net where a lot of problems are discussed. You can start right away by trying to reproduce bug reports and comment with your findings.
For helping with testing and triaging bug reports, you should register with the bug tracker at https://bugs.launchpad.net/midori and join #midori on irc.freenode.net where a lot of problems are discussed. You can start right away by trying to reproduce bug reports and comment with your findings.
If you are interested in contributing code, there are a few options. You can join #midori to discuss a particular problem you would like to look into, or a feature you would want to implement. Opening a bug report or feature request if there isn't already one is the next step. To attract some attention, if you attached a patch or have questions, ask in #midori.

2
README
View file

@ -18,7 +18,7 @@ Optional: Unique 0.9, libidn, docutils, libnotify, Vala
For installation instructions read INSTALL.
Please report comments, suggestions and bugs to:
http://www.twotoasts.de/bugs
https://bugs.launchpad.net/midori
And join the IRC channel #midori on irc.freenode.net

View file

@ -1,30 +1,31 @@
[Duck Duck Go]
name=Duck Duck Go
text=Privacy-aware Web Search
uri=https://duckduckgo.com/?q=%s
token=dd
[Yahoo]
name=Yahoo
text=Yahoo Web Search
uri=http://search.yahoo.com/search?p=
icon=
token=y
[Google]
name=Google
text=Web Search
uri=http://www.google.com/search?q=%s
icon=
token=g
[Wikipedia]
name=Wikipedia
text=The free encyclopedia
uri=http://en.wikipedia.org/wiki/Special:Search/%s
icon=
token=wp
[TheFreeDictionary]
name=The Free Dictionary
text=Dictionary, Encyclopedia and Thesaurus
uri=http://www.thefreedictionary.com/%s
icon=
token=fd
[Debian Packages]

View file

@ -366,6 +366,8 @@
var setSize = function ()
{
if (typeof sc.width == 'undefined')
sc.width = 3;
var rows = Math.ceil (sc.shortcuts.length / sc.width);
var size = prompt ("{enter_dial_size}", sc.width + 'x' + rows);

View file

@ -752,6 +752,10 @@ adblock_resource_request_starting_cb (WebKitWebView* web_view,
const gchar* req_uri;
const char *page_uri;
/* Never filter the main page itself */
if (web_frame == webkit_web_view_get_main_frame (web_view))
return;
req_uri = webkit_network_request_get_uri (request);
if (!req_uri)

View file

@ -1,6 +1,7 @@
/*
Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
Copyright (C) 2008-2010 Arno Renevier <arno@renevier.net>
Copyright (C) 2010 Paweł Forysiuk <tuxator@o2.pl>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -92,6 +93,199 @@ struct AddonsList
GSList* elements;
};
static void
addons_install_response (GtkWidget* infobar,
gint response_id,
MidoriView* view)
{
if (response_id == GTK_RESPONSE_ACCEPT)
{
MidoriBrowser* browser;
const gchar* uri;
browser = midori_browser_get_for_widget (GTK_WIDGET (infobar));
uri = midori_view_get_display_uri (view);
if (uri && *uri)
{
gchar** split_uri;
gchar* path, *filename, *hostname, *dest_path, *temp_uri;
const gchar* folder;
WebKitNetworkRequest* request;
WebKitDownload* download;
split_uri = g_strsplit (uri, "/", -1);
hostname = split_uri[2];
temp_uri = NULL;
filename = NULL;
folder = NULL;
if (!g_strcmp0 (hostname, "userscripts.org"))
{
gchar* script_id;
const gchar* js_script;
WebKitWebView* web_view;
WebKitWebFrame* web_frame;
web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view));
web_frame = webkit_web_view_get_main_frame (web_view);
js_script = "document.getElementById('heading').childNodes[3].childNodes[1].innerHTML";
if (WEBKIT_IS_WEB_FRAME (web_frame))
{
JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
gchar* value = sokoke_js_script_eval (js_context, js_script, NULL);
if (value && *value)
filename = g_strdup_printf ("%s.user.js", value);
g_free (value);
}
folder = "scripts";
script_id = split_uri[5];
/* rewrite uri to get source js */
temp_uri = g_strdup_printf ("http://%s/scripts/source/%s.user.js",
hostname, script_id);
uri = temp_uri;
}
else if (!g_strcmp0 (hostname, "userstyles.org"))
{
gchar* subpage;
folder = "styles";
if (g_str_has_suffix (uri, "/"))
subpage = split_uri[6];
else
subpage = split_uri[5];
if (!subpage)
{
gchar* style_id;
const gchar* js_script;
WebKitWebView* web_view;
WebKitWebFrame* web_frame;
web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view));
web_frame = webkit_web_view_get_main_frame (web_view);
js_script = "document.getElementById('stylish-description').innerHTML;";
if (WEBKIT_IS_WEB_FRAME (web_frame))
{
JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
gchar* value = sokoke_js_script_eval (js_context, js_script, NULL);
if (value && *value)
filename = g_strdup_printf ("%s.css", value);
g_free (value);
}
/* rewrite uri to get css */
style_id = split_uri[4];
temp_uri = g_strdup_printf ("http://%s/styles/%s.css", hostname, style_id);
uri = temp_uri;
}
}
if (g_str_has_suffix (uri, ".user.js"))
folder = "scripts";
else if (g_str_has_suffix (uri, ".user.css"))
folder = "styles";
if (!filename)
filename = g_path_get_basename (uri);
path = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
PACKAGE_NAME, folder, filename, NULL);
request = webkit_network_request_new (uri);
download = webkit_download_new (request);
g_object_unref (request);
dest_path = g_filename_to_uri (path, NULL, NULL);
webkit_download_set_destination_uri (download, dest_path);
webkit_download_start (download);
g_free (filename);
g_free (path);
g_free (temp_uri);
g_free (dest_path);
g_strfreev (split_uri);
}
}
gtk_widget_destroy (GTK_WIDGET (infobar));
}
static void
addons_uri_install (MidoriBrowser* browser,
MidoriView* view,
AddonsKind kind)
{
const gchar* message;
const gchar* button_text;
if (kind == ADDONS_USER_SCRIPTS)
{
/* i18n: An infobar shows up when viewing a script on userscripts.org */
message = _("This page appears to contain a user script. Do you wish to install it?");
button_text = _("_Install user script");
}
else if (kind == ADDONS_USER_STYLES)
{
/* i18n: An infobar shows up when viewing a style on userstyles.org */
message = _("This page appears to contain a user style. Do you wish to install it?");
button_text = _("_Install user style");
}
else
g_assert_not_reached ();
midori_view_add_info_bar (view, GTK_MESSAGE_QUESTION, message,
G_CALLBACK (addons_install_response), view,
button_text, GTK_RESPONSE_ACCEPT,
_("Don't install"), GTK_RESPONSE_CANCEL, NULL);
}
static void
addons_notify_load_status_cb (MidoriBrowser* browser,
GParamSpec* pspec,
MidoriExtension* extension)
{
const gchar* uri = midori_browser_get_current_uri (browser);
if (uri && *uri)
{
/* FIXME: addons_notify_load_status_cb should pass MidoriView* pointer */
GtkWidget* view = midori_browser_get_current_tab (browser);
if (midori_view_get_load_status (MIDORI_VIEW (view)) == MIDORI_LOAD_FINISHED)
{
/* casual sites goes by uri suffix */
if (g_str_has_suffix (uri, ".user.js"))
addons_uri_install (browser, MIDORI_VIEW (view), ADDONS_USER_SCRIPTS);
else if (g_str_has_suffix (uri, ".user.css"))
addons_uri_install (browser, MIDORI_VIEW (view), ADDONS_USER_STYLES);
else if (g_str_has_prefix (uri, "http://userscripts.org/scripts/"))
{
gchar** split_uri = g_strsplit (uri, "/", -1);
gchar* subpage = split_uri[4];
/* userscripts.org script main (with desc) and "source view" pages */
if (!g_strcmp0 (subpage, "show") /* || !g_strcmp0 (subpage, "review") */)
addons_uri_install (browser, MIDORI_VIEW (view), ADDONS_USER_SCRIPTS);
g_strfreev (split_uri);
}
else if (g_str_has_prefix (uri, "http://userstyles.org/styles/"))
{
gchar** split_uri = g_strsplit (uri, "/", -1);
gchar* subpage;
if (g_str_has_suffix (uri, "/"))
subpage = split_uri[6];
else
subpage = split_uri[5];
/* userstyles.org style main page with style description */
if (!subpage)
addons_uri_install (browser, MIDORI_VIEW (view), ADDONS_USER_STYLES);
g_strfreev (split_uri);
}
}
}
}
static void
midori_addons_button_add_clicked_cb (GtkToolItem* toolitem,
Addons* addons)
@ -293,7 +487,7 @@ midori_addons_open_in_editor_clicked_cb (GtkWidget* toolitem,
gchar* text_editor;
browser = midori_browser_get_for_widget (GTK_WIDGET (addons->treeview));
settings = katze_object_get_object (browser, "settings");
settings = midori_browser_get_settings (browser);
gtk_tree_model_get (model, &iter, 0, &element, -1);
@ -794,6 +988,7 @@ css_metadata_from_file (const gchar* filename,
GIOChannel* channel;
gchar* line;
gchar* rest_of_line;
gboolean line_has_meta;
if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
return FALSE;
@ -802,60 +997,61 @@ css_metadata_from_file (const gchar* filename,
if (!channel)
return FALSE;
line_has_meta = FALSE;
while (g_io_channel_read_line (channel, &line, NULL, NULL, NULL)
== G_IO_STATUS_NORMAL)
{
if (g_str_has_prefix (line, "@-moz-document"))
if (g_str_has_prefix (line, "@-moz-document") || line_has_meta)
{ /* FIXME: We merely look for includes. We should honor blocks. */
if (includes)
{
gchar** parts;
guint i;
rest_of_line = g_strdup (line + strlen ("@-moz-document"));
if (g_str_has_prefix (line, "@-moz-document"))
rest_of_line = g_strdup (line + strlen ("@-moz-document"));
else
rest_of_line = g_strdup (line);
rest_of_line = g_strstrip (rest_of_line);
parts = g_strsplit (rest_of_line, " ", 0);
i = 0;
while (parts[i])
while (parts[i] && (*parts[i] != '\0' && *parts[i] != '{'))
{
gchar* value = NULL;
if (g_str_has_prefix (parts[i], "url-prefix("))
value = g_strdup (parts[i] + strlen ("url-prefix("));
else if (g_str_has_prefix (parts[i], "domain("))
value = g_strdup (parts[i] + strlen ("domain("));
else if (g_str_has_prefix (parts[i], "url("))
value = g_strdup (parts[i] + strlen ("url("));
if (value)
{
guint j;
guint begin, end;
gchar* domain;
if (value[0] != '\'' && value[0] != '"')
line_has_meta = TRUE;
begin = value[0] == '"' || value[0] == '\'' ? 1 : 0;
end = 1;
while (value[end] != '\0' && value[end] != ')')
++end;
domain = g_strndup (value + begin, end - begin * 2);
if (!strncmp ("http", domain, 4))
*includes = g_slist_prepend (*includes, domain);
else
{
/* Wrong syntax, abort */
g_free (value);
g_strfreev (parts);
g_free (line);
g_io_channel_shutdown (channel, false, 0);
g_slist_free (*includes);
g_slist_free (*excludes);
*includes = NULL;
*excludes = NULL;
return FALSE;
*includes = g_slist_prepend (*includes,
g_strdup_printf ("http://*%s/*", domain));
g_free (domain);
}
j = 1;
while (value[j] != '\0')
{
if (value[j] == value[0])
break;
j++;
}
*includes = g_slist_prepend (*includes, g_strndup (value + 1, j - 1));
g_free (value);
}
/* FIXME: Recognize "domain" */
i++;
}
g_strfreev (parts);
}
line_has_meta = g_str_has_suffix (rest_of_line, "{") ? FALSE : TRUE;
}
g_free (line);
}
@ -871,7 +1067,8 @@ addons_get_element_content (gchar* file_path,
gchar** content)
{
gchar* file_content;
guint meta;
GString* content_chunks;
guint meta, comment;
guint i, n;
g_assert (kind == ADDONS_USER_SCRIPTS || kind == ADDONS_USER_STYLES);
@ -887,7 +1084,9 @@ addons_get_element_content (gchar* file_path,
else if (kind == ADDONS_USER_STYLES)
{
meta = 0;
comment = 0;
n = strlen (file_content);
content_chunks = g_string_new_len (NULL, n);
for (i = 0; i < n; i++)
{
/* Replace line breaks with spaces */
@ -896,23 +1095,19 @@ addons_get_element_content (gchar* file_path,
/* Change all single quotes to double quotes */
if (file_content[i] == '\'')
file_content[i] = '\"';
/* Turn metadata we inspected earlier into comments */
if (!meta && file_content[i] == '@')
{
file_content[i] = '/';
meta++;
}
else if (meta == 1
&& (file_content[i] == '-' || file_content[i] == 'n'))
{
file_content[i] = '*';
meta++;
}
else if (meta == 2 && file_content[i] == '{')
{
file_content[i - 1] = '*';
file_content[i] = '/';
meta++;
continue;
}
else if (meta == 3 && file_content[i] == '{')
meta++;
@ -920,9 +1115,33 @@ addons_get_element_content (gchar* file_path,
meta--;
else if (meta == 3 && file_content[i] == '}')
{
file_content[i] = ' ';
meta = 0;
continue;
}
if (file_content[i] == '/' && file_content[i+1] == '*')
comment++;
/* Check whether we have comment ending, merely '*' or '/' */
else if (comment == 2
&& file_content[i] == '*' && file_content[i+1] == '/')
{
comment--;
}
else if (comment == 1
&& file_content[i-1] == '*' && file_content[i] == '/')
{
comment--;
continue;
}
/* Skip consecutive spaces */
if (file_content[i] == ' '
&& i > 0 && file_content[i - 1] == ' ')
continue;
/* Append actual data to string */
if ((meta == 0 || meta >= 3) && !comment)
g_string_append_c (content_chunks, file_content[i]);
}
*content = g_strdup_printf (
@ -936,8 +1155,8 @@ addons_get_element_content (gchar* file_path,
"else document.documentElement.insertBefore"
"(mystyle, document.documentElement.firstChild);"
"}, true);",
file_content);
content_chunks->str);
g_string_free (content_chunks, TRUE);
}
g_free (file_content);
if (*content)
@ -1356,6 +1575,8 @@ addons_app_add_browser_cb (MidoriApp* app,
(GtkCallback)addons_add_tab_foreach_cb, extension);
g_signal_connect (browser, "add-tab",
G_CALLBACK (addons_add_tab_cb), extension);
g_signal_connect (browser, "notify::load-status",
G_CALLBACK (addons_notify_load_status_cb), extension);
panel = katze_object_get_object (browser, "panel");
scripts = addons_new (ADDONS_USER_SCRIPTS, extension);
@ -1411,7 +1632,8 @@ addons_save_settings (MidoriApp* app,
config_file = g_build_filename (config_dir, "addons", NULL);
katze_mkdir_with_parents (config_dir, 0700);
sokoke_key_file_save_to_file (keyfile, config_file, &error);
if (error)
/* If the folder is /, this is a test run, thus no error */
if (error && !g_str_equal (config_dir, "/"))
{
g_warning (_("The configuration of the extension '%s' couldn't be saved: %s\n"),
_("User addons"), error->message);

View file

@ -334,15 +334,11 @@ feed_panel_row_activated_cb (GtkTreeView* treeview,
MidoriWebSettings* settings;
MidoriBrowser* browser;
gint n;
browser = midori_browser_get_for_widget (GTK_WIDGET (panel));
n = midori_browser_add_item (browser, item);
settings = katze_object_get_object (browser, "settings");
settings = midori_browser_get_settings (browser);
if (!katze_object_get_boolean (settings, "open-tabs-in-the-background"))
midori_browser_set_current_page (browser, n);
g_object_unref (settings);
}
g_object_unref (item);
}
@ -485,11 +481,9 @@ feed_panel_open_in_tab_activate_cb (GtkWidget* menuitem,
browser = midori_browser_get_for_widget (GTK_WIDGET (panel));
n = midori_browser_add_item (browser, item);
settings = katze_object_get_object (browser, "settings");
settings = midori_browser_get_settings (browser);
if (!katze_object_get_boolean (settings, "open-tabs-in-the-background"))
midori_browser_set_current_page (browser, n);
g_object_unref (settings);
}
}
@ -584,10 +578,9 @@ feed_panel_button_release_event_cb (GtkWidget* widget,
browser = midori_browser_get_for_widget (GTK_WIDGET (panel));
n = midori_browser_add_item (browser, item);
settings = katze_object_get_object (browser, "settings");
settings = midori_browser_get_settings (browser);
if (!katze_object_get_boolean (settings, "open-tabs-in-the-background"))
midori_browser_set_current_page (browser, n);
g_object_unref (settings);
}
}
else

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2010 André Stösel <Midori-Plugin@PyIT.de>
Copyright (C) 2010 André Stösel <andre@stoesel.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -29,7 +29,7 @@ private abstract class HistoryWindow : Gtk.Window {
window_position: Gtk.WindowPosition.CENTER,
browser: browser);
}
public void walk (int step) {
public virtual void walk (int step) {
Gtk.TreePath? path;
Gtk.TreeViewColumn? column;
@ -50,23 +50,9 @@ private abstract class HistoryWindow : Gtk.Window {
}
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");
protected Gtk.HBox? hbox;
protected Gtk.VBox? vbox;
protected void store_append_row (GLib.PtrArray list, Gtk.ListStore store, out Gtk.TreeIter iter) {
for (var i = list.len; i > 0; i--) {
Midori.View view = list.index (i - 1) as Midori.View;
@ -80,8 +66,34 @@ private class TabWindow : HistoryWindow {
TabTreeCells.TREE_CELL_STRING, title,
TabTreeCells.TREE_CELL_POINTER, view);
}
}
protected virtual void insert_rows (Gtk.ListStore store) {
Gtk.TreeIter iter;
unowned GLib.PtrArray list = this.browser.get_data<GLib.PtrArray> ("history-list-tab-history");
unowned GLib.PtrArray list_new = this.browser.get_data<GLib.PtrArray> ("history-list-tab-history-new");
store_append_row (list, store, out iter);
store_append_row (list_new, store, out iter);
}
public TabWindow (Midori.Browser browser) {
base (browser);
this.vbox = new Gtk.VBox (false, 1);
this.add (this.vbox);
this.hbox = new Gtk.HBox (false, 1);
var sw = new Gtk.ScrolledWindow (null, null);
sw.set_policy (PolicyType.NEVER , PolicyType.AUTOMATIC);
sw.set_shadow_type (ShadowType.ETCHED_IN);
this.hbox.pack_start (sw, true, true, 0);
var store = new Gtk.ListStore (TabTreeCells.TREE_CELL_COUNT,
typeof (Gdk.Pixbuf), typeof (string), typeof (void*));
this.insert_rows (store);
this.vbox.pack_start (this.hbox, true, true, 0);
this.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);
@ -96,6 +108,17 @@ private class TabWindow : HistoryWindow {
TabTreeCells.TREE_CELL_STRING, "Title",
new CellRendererText (), "text", 1);
Requisition requisition;
int height;
int max_lines = 10;
this.treeview.size_request (out requisition);
if (store.length > max_lines) {
height = requisition.height / store.length * max_lines + 2;
} else {
height = requisition.height + 2;
}
sw.set_size_request (320, height);
this.show_all ();
}
public override void make_update () {
@ -115,6 +138,31 @@ private class TabWindow : HistoryWindow {
}
}
private class NewTabWindow : TabWindow {
protected bool first_step = true;
protected override void insert_rows (Gtk.ListStore store) {
Gtk.TreeIter iter;
unowned GLib.PtrArray list = this.browser.get_data<GLib.PtrArray> ("history-list-tab-history-new");
store_append_row (list, store, out iter);
if ((int)list.len == 0) {
var label = new Gtk.Label (_("There are no unvisited tabs"));
this.vbox.pack_start (label, true, true, 0);
unowned GLib.PtrArray list_old = this.browser.get_data<GLib.PtrArray> ("history-list-tab-history");
store_append_row (list_old, store, out iter);
}
}
public override void walk (int step) {
if (this.first_step == false || step != 1) {
base.walk (step);
}
this.first_step = false;
}
public NewTabWindow (Midori.Browser browser) {
base (browser);
}
}
private class HistoryList : Midori.Extension {
protected uint modifier_count;
protected HistoryWindow? history_window;
@ -139,6 +187,13 @@ private class HistoryList : Midori.Extension {
return false;
}
public void walk (Gtk.Action action, Browser browser, Type type, int step) {
Midori.View? view = null;
view = browser.get_data<Midori.View?> ("history-list-last-change");
if (view != null) {
this.tab_list_resort (browser, view);
browser.set_data<Midori.View?> ("history-list-last-change", null);
}
if (this.history_window == null || this.history_window.get_type () != type) {
if (this.history_window == null) {
this.modifier_count = Midori.Sokoke.gtk_action_count_modifiers (action);
@ -158,6 +213,8 @@ private class HistoryList : Midori.Extension {
*/
if (type == typeof (TabWindow)) {
this.history_window = new TabWindow (browser);
} else if (type == typeof (NewTabWindow)) {
this.history_window = new NewTabWindow (browser);
}
}
var hw = this.history_window as HistoryWindow;
@ -190,8 +247,32 @@ private class HistoryList : Midori.Extension {
action.set_accel_group (acg);
action.connect_accelerator ();
action = new Gtk.Action ("HistoryListNextNewTab",
_("Next new Tab (History List)"),
_("Next new tab from history"), null);
action.activate.connect ((a) => {
this.walk (a, browser, typeof (NewTabWindow), 1);
});
action_group.add_action_with_accel (action, "<Ctrl>1");
action.set_accel_group (acg);
action.connect_accelerator ();
action = new Gtk.Action ("HistoryListPreviousNewTab",
_("Previous new Tab (History List)"),
_("Previous new tab from history"), null);
action.activate.connect ((a) => {
this.walk (a, browser, typeof (NewTabWindow), -1);
});
action_group.add_action_with_accel (action, "<Ctrl>2");
action.set_accel_group (acg);
action.connect_accelerator ();
browser.set_data<GLib.PtrArray*> ("history-list-tab-history",
new GLib.PtrArray ());
browser.set_data<GLib.PtrArray*> ("history-list-tab-history-new",
new GLib.PtrArray ());
browser.set_data<Midori.View?> ("history-list-last-change", null);
foreach (var tab in browser.get_tabs ())
tab_added (browser, tab);
browser.add_tab.connect (tab_added);
@ -199,7 +280,8 @@ private class HistoryList : Midori.Extension {
browser.notify["tab"].connect (this.tab_changed);
}
void browser_removed (Midori.Browser browser) {
string[] callbacks = { "HistoryListNextTab", "HistoryListPreviousTab" };
string[] callbacks = { "HistoryListNextTab", "HistoryListPreviousTab",
"HistoryListNextNewTab", "HistoryListPreviousNewTab" };
Gtk.ActionGroup action_group;
action_group = browser.get_action_group ();
@ -214,20 +296,40 @@ private class HistoryList : Midori.Extension {
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");
unowned GLib.PtrArray list = browser.get_data<GLib.PtrArray> ("history-list-tab-history-new");
list.add (view);
}
void tab_removed (Midori.Browser browser, Midori.View view) {
unowned GLib.PtrArray list = browser.get_data<GLib.PtrArray> ("history-list-tab-history");
unowned GLib.PtrArray list_new = browser.get_data<GLib.PtrArray> ("history-list-tab-history-new");
list.remove (view);
list_new.remove (view);
browser.set_data<Midori.View?> ("history-list-last-change", null);
if ((int) list.len > 0 || (int) list_new.len > 0) {
var hw = new TabWindow (browser);
hw.make_update ();
hw.destroy ();
}
}
void tab_changed (GLib.Object window, GLib.ParamSpec pspec) {
Midori.Browser browser = window as Midori.Browser;
Midori.View view = null;
Midori.View last_view = null;
browser.get ("tab", ref view);
last_view = browser.get_data<Midori.View?> ("history-list-last-change");
if (last_view != null) {
this.tab_list_resort (browser, last_view);
}
browser.set_data<Midori.View?> ("history-list-last-change", view);
}
void tab_list_resort (Midori.Browser browser, Midori.View view) {
unowned GLib.PtrArray list = browser.get_data<GLib.PtrArray> ("history-list-tab-history");
unowned GLib.PtrArray list_new = browser.get_data<GLib.PtrArray> ("history-list-tab-history-new");
list.remove (view);
list_new.remove (view);
list.add (view);
}
void activated (Midori.App app) {
@ -244,8 +346,8 @@ private class HistoryList : Midori.Extension {
internal HistoryList () {
GLib.Object (name: _("History List"),
description: _("Switch tabs with Ctrl+Tab sorted by last usage"),
version: "0.2",
authors: "André Stösel <Midori-Plugin@PyIT.de>");
version: "0.3",
authors: "André Stösel <andre@stoesel.de>");
activate.connect (activated);
deactivate.connect (deactivated);
}

View file

@ -28,9 +28,8 @@ page_holder_notebook_append_view (GtkWidget* notebook)
view = midori_view_new (NULL);
browser = midori_browser_get_for_widget (notebook);
settings = katze_object_get_object (browser, "settings");
settings = midori_browser_get_settings (browser);
midori_view_set_settings (MIDORI_VIEW (view), settings);
g_object_unref (settings);
gtk_widget_show (view);
label = midori_view_get_proxy_tab_label (MIDORI_VIEW (view));
return gtk_notebook_append_page (GTK_NOTEBOOK (notebook), view, label);

View file

@ -79,7 +79,7 @@ statusbar_features_app_add_browser_cb (MidoriApp* app,
statusbar = katze_object_get_object (browser, "statusbar");
bbox = gtk_hbox_new (FALSE, 0);
settings = katze_object_get_object (browser, "settings");
settings = midori_browser_get_settings (browser);
toolbar = katze_object_get_object (browser, "navigationbar");
button = katze_property_proxy (settings, "auto-load-images", "toggle");
g_object_set_data (G_OBJECT (button), "feature-label", _("Images"));
@ -112,7 +112,6 @@ statusbar_features_app_add_browser_cb (MidoriApp* app,
gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
gtk_widget_show_all (bbox);
gtk_box_pack_start (GTK_BOX (statusbar), bbox, FALSE, FALSE, 3);
g_object_unref (settings);
g_object_unref (statusbar);
g_signal_connect (extension, "deactivate",

View file

@ -279,6 +279,20 @@ tab_panel_settings_notify_cb (MidoriWebSettings* settings,
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 2, buttons, -1);
}
static void
tab_panel_toggle_toolbook (GtkWidget* toolbar)
{
/* Hack to ensure correct toolbar visibility */
GtkWidget* toolbook = gtk_widget_get_parent (toolbar);
if (gtk_notebook_get_current_page (GTK_NOTEBOOK (toolbook))
== gtk_notebook_page_num (GTK_NOTEBOOK (toolbook), toolbar))
{
GList* items = gtk_container_get_children (GTK_CONTAINER (toolbar));
sokoke_widget_set_visible (toolbook, items != NULL);
g_list_free (items);
}
}
static void
tab_panel_remove_view (MidoriBrowser* browser,
GtkWidget* view,
@ -287,7 +301,9 @@ tab_panel_remove_view (MidoriBrowser* browser,
if (minimized)
{
GtkToolItem* toolitem = tab_panel_get_toolitem_for_view (view);
GtkWidget* toolbar = tab_panel_get_toolbar_for_browser (browser);
gtk_widget_destroy (GTK_WIDGET (toolitem));
tab_panel_toggle_toolbook (toolbar);
}
else
{
@ -396,7 +412,7 @@ tab_panel_browser_add_tab_cb (MidoriBrowser* browser,
{
GtkWidget* notebook = katze_object_get_object (browser, "notebook");
gint page = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), view);
MidoriWebSettings* settings = katze_object_get_object (browser, "settings");
MidoriWebSettings* settings = midori_browser_get_settings (browser);
gboolean minimized = katze_object_get_boolean (view, "minimized");
GdkPixbuf* icon = midori_view_get_icon (MIDORI_VIEW (view));
const gchar* title = midori_view_get_display_title (MIDORI_VIEW (view));
@ -413,6 +429,7 @@ tab_panel_browser_add_tab_cb (MidoriBrowser* browser,
g_object_set_data (G_OBJECT (view), "tab-panel-ext-toolitem", toolitem);
gtk_widget_show (GTK_WIDGET (toolitem));
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
tab_panel_toggle_toolbook (toolbar);
g_signal_connect (toolitem, "clicked",
G_CALLBACK (tab_panel_toolitem_clicked_cb), view);
g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)), "button-press-event",
@ -444,7 +461,6 @@ tab_panel_browser_add_tab_cb (MidoriBrowser* browser,
}
g_object_unref (notebook);
g_object_unref (settings);
}
static void
@ -609,6 +625,7 @@ extension_init (void)
{
{ STOCK_TAB_PANEL, N_("T_ab Panel"), 0, 0, NULL },
};
MidoriExtension* extension;
factory = gtk_icon_factory_new ();
gtk_stock_add (items, G_N_ELEMENTS (items));
@ -622,7 +639,7 @@ extension_init (void)
gtk_icon_factory_add_default (factory);
g_object_unref (factory);
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", _("Tab Panel"),
"description", _("Show tabs in a vertical panel"),
"version", "0.1",

View file

@ -119,9 +119,8 @@ static GSList *tb_editor_parse_active_items(MidoriBrowser *browser)
GSList *list = NULL;
MidoriWebSettings *settings;
settings = katze_object_get_object(browser, "settings");
settings = midori_browser_get_settings(browser);
g_object_get(settings, "toolbar-items", &items, NULL);
g_object_unref(settings);
names = g_strsplit(items ? items : "", ",", 0);
list = tb_editor_array_to_list((const gchar **) names);
@ -356,9 +355,8 @@ static void tb_editor_update_toolbar(TBEditorWidget *tbw)
gtk_tree_model_foreach(GTK_TREE_MODEL(tbw->store_used), tb_editor_foreach_used, str);
settings = katze_object_get_object(tbw->browser, "settings");
settings = midori_browser_get_settings(tbw->browser);
g_object_set(settings, "toolbar-items", str->str, NULL);
g_object_unref(settings);
g_string_free(str, TRUE);
}

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2008-2010 Christian Dywan <christian@twotoasts.de>
Copyright (C) 2008-2011 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
@ -50,6 +50,9 @@ struct _KatzeArrayClass
gint index);
void
(*clear) (KatzeArray* array);
void
(*update) (KatzeArray* array);
};
G_DEFINE_TYPE (KatzeArray, katze_array, KATZE_TYPE_ITEM);
@ -59,6 +62,7 @@ enum {
REMOVE_ITEM,
MOVE_ITEM,
CLEAR,
UPDATE,
LAST_SIGNAL
};
@ -74,15 +78,10 @@ static void
_katze_array_add_item (KatzeArray* array,
gpointer item)
{
if (katze_array_is_a (array, G_TYPE_OBJECT))
{
GType type = G_OBJECT_TYPE (item);
/* g_return_if_fail (katze_array_is_a (array, type)); */
g_object_ref (item);
if (g_type_is_a (type, KATZE_TYPE_ITEM))
katze_item_set_parent (item, array);
}
GType type = G_OBJECT_TYPE (item);
g_object_ref (item);
if (g_type_is_a (type, KATZE_TYPE_ITEM))
katze_item_set_parent (item, array);
array->items = g_list_append (array->items, item);
}
@ -93,12 +92,9 @@ _katze_array_remove_item (KatzeArray* array,
{
array->items = g_list_remove (array->items, item);
if (katze_array_is_a (array, G_TYPE_OBJECT))
{
if (KATZE_IS_ITEM (item))
katze_item_set_parent (item, NULL);
g_object_unref (item);
}
if (KATZE_IS_ITEM (item))
katze_item_set_parent (item, NULL);
g_object_unref (item);
}
static void
@ -183,6 +179,25 @@ katze_array_class_init (KatzeArrayClass* class)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* KatzeArray::update:
* @array: the object on which the signal is emitted
*
* The array changed and any display widgets should
* be updated.
*
* Since: 0.3.0
**/
signals[UPDATE] = g_signal_new (
"update",
G_TYPE_FROM_CLASS (class),
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
0,
0,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = katze_array_finalize;
@ -195,7 +210,7 @@ katze_array_class_init (KatzeArrayClass* class)
static void
katze_array_init (KatzeArray* array)
{
array->type = G_TYPE_NONE;
array->type = G_TYPE_OBJECT;
array->items = NULL;
}
@ -204,16 +219,12 @@ katze_array_finalize (GObject* object)
{
KatzeArray* array;
guint i;
gpointer item;
array = KATZE_ARRAY (object);
if (katze_array_is_a (array, G_TYPE_OBJECT))
{
gpointer item;
i = 0;
while ((item = g_list_nth_data (array->items, i++)))
g_object_unref (item);
}
i = 0;
while ((item = g_list_nth_data (array->items, i++)))
g_object_unref (item);
g_list_free (array->items);
G_OBJECT_CLASS (katze_array_parent_class)->finalize (object);
@ -225,8 +236,6 @@ katze_array_finalize (GObject* object)
*
* Creates a new #KatzeArray for @type items.
*
* You may only add items of the given type or inherited
* from it to this array *if* @type is an #GObject type.
* The array will keep a reference on each object until
* it is removed from the array.
*
@ -235,14 +244,17 @@ katze_array_finalize (GObject* object)
KatzeArray*
katze_array_new (GType type)
{
KatzeArray* array = g_object_new (KATZE_TYPE_ARRAY, NULL);
KatzeArray* array;
g_return_val_if_fail (g_type_is_a (type, G_TYPE_OBJECT), NULL);
array = g_object_new (KATZE_TYPE_ARRAY, NULL);
array->type = type;
return array;
}
/**
*
* katze_array_is_a:
* @array: a #KatzeArray
* @is_a_type: type to compare with
@ -371,9 +383,6 @@ katze_array_find_token (KatzeArray* array,
guint i;
gpointer item;
if (!katze_array_is_a (array, G_TYPE_OBJECT))
return NULL;
i = 0;
while ((item = g_list_nth_data (array->items, i++)))
{
@ -410,9 +419,6 @@ katze_array_find_uri (KatzeArray* array,
guint i;
gpointer item;
if (!katze_array_is_a (array, G_TYPE_OBJECT))
return NULL;
i = 0;
while ((item = g_list_nth_data (array->items, i++)))
{
@ -502,3 +508,20 @@ katze_array_clear (KatzeArray* array)
g_signal_emit (array, signals[CLEAR], 0);
}
/**
* katze_array_update:
* @array: a #KatzeArray
*
* Indicates that the array changed and any display
* widgets should be updated.
*
* Since: 0.3.0
**/
void
katze_array_update (KatzeArray* array)
{
g_return_if_fail (KATZE_IS_ARRAY (array));
g_signal_emit (array, signals[UPDATE], 0);
}

View file

@ -84,6 +84,15 @@ GList*
katze_array_peek_items (KatzeArray* array);
extern GList* kalistglobal;
/* KATZE_ARRAY_FOREACH_ITEM:
* @item: a #KatzeItem variable
* @array: a #KatzeArray to loop through
*
* Loops through all items of the array. The macro can
* be used like a for() loop.
* If the array is modified during the loop, you must
* use KATZE_ARRAY_FOREACH_ITEM_L instead.
* */
#define KATZE_ARRAY_FOREACH_ITEM(kaitem, kaarray) \
for (kalistglobal = katze_array_peek_items (kaarray), \
kaitem = kalistglobal ? kalistglobal->data : NULL; \
@ -91,9 +100,28 @@ extern GList* kalistglobal;
kalistglobal = g_list_next (kalistglobal), \
kaitem = kalistglobal ? kalistglobal->data : NULL)
/* KATZE_ARRAY_FOREACH_ITEM_L:
* @item: a #KatzeItem variable
* @array: a #KatzeArray to loop through
* @list: a #GList variable
*
* Loops through all items of the array. The list must be freed.
*
* Since: 0.3.0
* */
#define KATZE_ARRAY_FOREACH_ITEM_L(kaitem, kaarray, kalist) \
for (kalist = katze_array_get_items (kaarray), \
kaitem = kalist ? kalist->data : NULL; \
kalist != NULL; \
kalist = g_list_next (kalist), \
kaitem = kalist ? kalist->data : NULL)
void
katze_array_clear (KatzeArray* array);
void
katze_array_update (KatzeArray* array);
G_END_DECLS
#endif /* __KATZE_ARRAY_H__ */

View file

@ -89,6 +89,10 @@ static void
katze_array_action_disconnect_proxy (GtkAction* action,
GtkWidget* proxy);
static void
katze_array_action_proxy_clicked_cb (GtkWidget* proxy,
KatzeArrayAction* array_action);
static void
katze_array_action_class_init (KatzeArrayActionClass* class)
{
@ -277,19 +281,6 @@ katze_array_action_get_property (GObject* object,
static void
katze_array_action_activate (GtkAction* action)
{
GSList* proxies;
proxies = gtk_action_get_proxies (action);
if (!proxies)
return;
do
if (GTK_IS_TOOL_ITEM (proxies->data))
{
}
while ((proxies = g_slist_next (proxies)));
if (GTK_ACTION_CLASS (katze_array_action_parent_class)->activate)
GTK_ACTION_CLASS (katze_array_action_parent_class)->activate (action);
}
@ -449,6 +440,18 @@ katze_array_action_menu_item_select_cb (GtkWidget* proxy,
g_signal_emit (array_action, signals[POPULATE_FOLDER], 0, menu, array, &handled);
}
static void
katze_array_action_menu_deactivate_cb (GtkWidget* menu,
GtkWidget* proxy)
{
void* array_action = g_object_get_data (G_OBJECT (menu), "KatzeArrayAction");
g_signal_handlers_block_by_func (proxy,
katze_array_action_proxy_clicked_cb, array_action);
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (proxy), FALSE);
g_signal_handlers_unblock_by_func (proxy,
katze_array_action_proxy_clicked_cb, array_action);
}
static void
katze_array_action_proxy_clicked_cb (GtkWidget* proxy,
KatzeArrayAction* array_action)
@ -478,6 +481,7 @@ katze_array_action_proxy_clicked_cb (GtkWidget* proxy,
}
menu = gtk_menu_new ();
gtk_menu_attach_to_widget (GTK_MENU (menu), proxy, NULL);
if (!array)
array = array_action->array;
@ -499,6 +503,10 @@ katze_array_action_proxy_clicked_cb (GtkWidget* proxy,
katze_widget_popup (GTK_WIDGET (proxy), GTK_MENU (menu),
NULL, KATZE_MENU_POSITION_LEFT);
#endif
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), TRUE);
g_object_set_data (G_OBJECT (menu), "KatzeArrayAction", array_action);
g_signal_connect (menu, "deactivate",
G_CALLBACK (katze_array_action_menu_deactivate_cb), proxy);
}
static GtkWidget*
@ -515,7 +523,7 @@ katze_array_action_create_tool_item (GtkAction* action)
{
GtkWidget* toolitem;
toolitem = GTK_WIDGET (gtk_tool_button_new (NULL, ""));
toolitem = GTK_WIDGET (gtk_toggle_tool_button_new ());
return toolitem;
}
@ -684,14 +692,19 @@ katze_array_action_create_tool_item_for (KatzeArrayAction* array_action,
if (KATZE_ITEM_IS_SEPARATOR (item))
return gtk_separator_tool_item_new ();
toolitem = gtk_tool_button_new (NULL, "");
g_signal_connect (toolitem, "create-menu-proxy",
G_CALLBACK (katze_array_action_proxy_create_menu_proxy_cb), item);
if (KATZE_ITEM_IS_FOLDER (item))
{
toolitem = gtk_toggle_tool_button_new ();
icon = gtk_widget_render_icon (GTK_WIDGET (toolitem),
GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU, NULL);
}
else
{
toolitem = gtk_tool_button_new (NULL, "");
icon = katze_load_cached_icon (uri, GTK_WIDGET (toolitem));
}
g_signal_connect (toolitem, "create-menu-proxy",
G_CALLBACK (katze_array_action_proxy_create_menu_proxy_cb), item);
image = gtk_image_new_from_pixbuf (icon);
g_object_unref (icon);
gtk_widget_show (image);

View file

@ -856,6 +856,7 @@ katze_throbber_expose_event (GtkWidget* widget,
GdkEventExpose* event)
{
KatzeThrobber* throbber = KATZE_THROBBER (widget);
gint ax, ay;
if (G_UNLIKELY (!throbber->width || !throbber->height))
return TRUE;
@ -867,7 +868,6 @@ katze_throbber_expose_event (GtkWidget* widget,
if (!throbber->animated && (throbber->static_pixbuf
|| throbber->static_icon_name || throbber->static_stock_id))
{
gint ax, ay;
cairo_t* cr;
if (G_UNLIKELY (!throbber->static_pixbuf && throbber->static_icon_name))

View file

@ -134,7 +134,6 @@ settings_and_accels_new (const gchar* config,
GEnumClass* enum_class = G_ENUM_CLASS (
g_type_class_peek (pspec->value_type));
GEnumValue* enum_value;
str = g_key_file_get_string (key_file, "settings", property, NULL);
enum_value = g_enum_get_value_by_name (enum_class, str);
if (enum_value)
@ -142,9 +141,7 @@ settings_and_accels_new (const gchar* config,
else
g_warning (_("Value '%s' is invalid for %s"),
str, property);
g_free (str);
g_type_class_unref (enum_class);
}
else
g_warning (_("Invalid configuration value '%s'"), property);
@ -230,7 +227,7 @@ settings_save_to_file (MidoriWebSettings* settings,
else if (type == G_TYPE_PARAM_ENUM)
{
GEnumClass* enum_class = G_ENUM_CLASS (
g_type_class_ref (pspec->value_type));
g_type_class_peek (pspec->value_type));
gint integer;
GEnumValue* enum_value;
g_object_get (settings, property, &integer, NULL);
@ -391,7 +388,20 @@ search_engines_save_to_file (KatzeArray* search_engines,
return saved;
}
static sqlite3*
static void
midori_history_clear_cb (KatzeArray* array,
sqlite3* db)
{
char* errmsg = NULL;
if (sqlite3_exec (db, "DELETE FROM history; DELETE FROM search",
NULL, NULL, &errmsg) != SQLITE_OK)
{
g_printerr (_("Failed to clear history: %s\n"), errmsg);
sqlite3_free (errmsg);
}
}
static gboolean
midori_history_initialize (KatzeArray* array,
const gchar* filename,
const gchar* bookmarks_filename,
@ -411,7 +421,7 @@ midori_history_initialize (KatzeArray* array,
*errmsg = g_strdup_printf (_("Failed to open database: %s\n"),
sqlite3_errmsg (db));
sqlite3_close (db);
return NULL;
return FALSE;
}
sqlite3_exec (db, "PRAGMA journal_mode = TRUNCATE;", NULL, NULL, errmsg);
@ -426,7 +436,7 @@ midori_history_initialize (KatzeArray* array,
"CREATE TABLE IF NOT EXISTS "
"search (keywords text, uri text, day integer);",
NULL, NULL, errmsg) != SQLITE_OK)
return NULL;
return FALSE;
sqlite3_prepare_v2 (db, "SELECT day FROM history LIMIT 1", -1, &stmt, NULL);
result = sqlite3_step (stmt);
@ -452,18 +462,20 @@ midori_history_initialize (KatzeArray* array,
sql = g_strdup_printf ("ATTACH DATABASE '%s' AS bookmarks", bookmarks_filename);
sqlite3_exec (db, sql, NULL, NULL, errmsg);
g_free (sql);
g_object_set_data (G_OBJECT (array), "db", db);
g_signal_connect (array, "clear",
G_CALLBACK (midori_history_clear_cb), db);
return db;
return TRUE;
}
static void
midori_history_terminate (sqlite3* db,
gint max_history_age)
midori_history_terminate (KatzeArray* array,
gint max_history_age)
{
gchar* sqlcmd;
sqlite3* db = g_object_get_data (G_OBJECT (array), "db");
char* errmsg = NULL;
sqlcmd = g_strdup_printf (
gchar* sqlcmd = g_strdup_printf (
"DELETE FROM history WHERE "
"(julianday(date('now')) - julianday(date(date,'unixepoch')))"
" >= %d", max_history_age);
@ -477,6 +489,15 @@ midori_history_terminate (sqlite3* db,
sqlite3_close (db);
}
static void
midori_bookmarks_add_item_cb (KatzeArray* array,
KatzeItem* item,
sqlite3* db)
{
midori_bookmarks_insert_item_db (db, item,
katze_item_get_meta_string (item, "folder"));
}
static void
midori_bookmarks_remove_item_cb (KatzeArray* array,
KatzeItem* item,
@ -530,6 +551,8 @@ midori_bookmarks_initialize (KatzeArray* array,
"desc text, app integer, toolbar integer);",
NULL, NULL, errmsg) != SQLITE_OK)
return NULL;
g_signal_connect (array, "add-item",
G_CALLBACK (midori_bookmarks_add_item_cb), db);
g_signal_connect (array, "remove-item",
G_CALLBACK (midori_bookmarks_remove_item_cb), db);
return db;
@ -863,6 +886,7 @@ midori_soup_session_prepare (SoupSession* session,
{
"/etc/pki/tls/certs/ca-bundle.crt",
"/etc/ssl/certs/ca-certificates.crt",
"/usr/local/share/certs/ca-root-nss.crt",
NULL
};
guint i;
@ -1047,53 +1071,6 @@ midori_load_cookie_jar (gpointer data)
return FALSE;
}
static gboolean
midori_load_netscape_plugins (gpointer data)
{
MidoriApp* app = MIDORI_APP (data);
KatzeArray* extensions = katze_object_get_object (app, "extensions");
/* FIXME: WebKit should have API to obtain the list of plugins. */
/* FIXME: Monitor folders for newly added and removes files */
GtkWidget* web_view = webkit_web_view_new ();
WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
/* This snippet joins the available plugins into a string like this:
URI1|title1,URI2|title2
FIXME: Ensure separators contained in the string can't break it */
gchar* value = sokoke_js_script_eval (js_context,
"function plugins (l) { var f = new Array (); for (i in l) "
"{ var p = l[i].name + '|' + l[i].filename; "
"if (f.indexOf (p) == -1) f.push (p); } return f; }"
"plugins (navigator.plugins)", NULL);
gchar** items = g_strsplit (value, ",", 0);
guint i = 0;
if (items != NULL)
while (items[i] != NULL)
{
gchar** parts = g_strsplit (items[i], "|", 2);
if (parts && *parts && !g_str_equal (parts[1], "undefined"))
{
MidoriExtension* extension;
gchar* desc = parts[1];
gsize j = 0;
while (desc[j++])
if (desc[j-1] == ';')
desc[j-1] = '\n';
extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", parts[0], "description", desc, NULL);
g_object_set_data (G_OBJECT (extension), "static", (void*)0xdeadbeef);
katze_array_add_item (extensions, extension);
}
g_strfreev (parts);
i++;
}
g_strfreev (items);
g_object_unref (extensions);
return FALSE;
}
static gboolean
midori_load_extensions (gpointer data)
{
@ -1197,9 +1174,6 @@ midori_load_extensions (gpointer data)
}
g_strfreev (active_extensions);
if (g_getenv ("MIDORI_UNARMED") == NULL)
g_idle_add (midori_load_netscape_plugins, app);
#ifdef G_ENABLE_DEBUG
if (startup_timer)
g_debug ("Extensions:\t%f", g_test_timer_elapsed ());
@ -1302,11 +1276,12 @@ midori_load_session (gpointer data)
midori_browser_add_item (browser, item);
}
current = katze_item_get_meta_integer (KATZE_ITEM (_session), "current");
if (current < 0)
current = 0;
midori_browser_set_current_page (browser, current);
if (!(item = katze_array_get_nth_item (_session, current)))
{
current = 0;
item = katze_array_get_nth_item (_session, 0);
}
midori_browser_set_current_page (browser, current);
if (!g_strcmp0 (katze_item_get_uri (item), ""))
midori_browser_activate_action (browser, "Location");
@ -1407,6 +1382,8 @@ midori_web_app_browser_notify_load_status_cb (MidoriBrowser* browser,
{
GtkWidget* view = midori_browser_get_current_tab (browser);
GdkPixbuf* icon = midori_view_get_icon (MIDORI_VIEW (view));
if (midori_view_is_blank (MIDORI_VIEW (view)))
icon = NULL;
gtk_window_set_icon (GTK_WINDOW (browser), icon);
}
}
@ -1514,7 +1491,6 @@ midori_inactivity_timeout (gpointer data)
guint i = 0;
GtkWidget* view;
KatzeArray* history = katze_object_get_object (mit->browser, "history");
sqlite3* db;
KatzeArray* trash = katze_object_get_object (mit->browser, "trash");
GList* data_items = sokoke_register_privacy_item (NULL, NULL, NULL);
@ -1522,9 +1498,8 @@ midori_inactivity_timeout (gpointer data)
gtk_widget_destroy (view);
midori_browser_set_current_uri (mit->browser, mit->uri);
/* Clear all private data */
if (history && (db = g_object_get_data (G_OBJECT (history), "db")))
sqlite3_exec (db, "DELETE FROM history; DELETE FROM search",
NULL, NULL, NULL);
if (history != NULL)
katze_array_clear (history);
if (trash != NULL)
katze_array_clear (trash);
for (; data_items != NULL; data_items = g_list_next (data_items))
@ -1858,7 +1833,7 @@ main (int argc,
}
else
{
settings = katze_object_get_object (browser, "settings");
settings = g_object_ref (midori_browser_get_settings (browser));
g_object_set (settings,
"show-menubar", FALSE,
"show-navigationbar", FALSE,
@ -2008,7 +1983,7 @@ main (int argc,
if (g_access (old_bookmarks, F_OK) == 0)
{
midori_bookmarks_import (old_bookmarks, db);
g_unlink(old_bookmarks);
/* Leave old bookmarks around */
}
g_free (old_bookmarks);
g_object_set_data (G_OBJECT (bookmarks), "db", db);
@ -2052,14 +2027,13 @@ main (int argc,
katze_assign (config_file, g_build_filename (config, "history.db", NULL));
errmsg = NULL;
if ((db = midori_history_initialize (history, config_file, bookmarks_file ,&errmsg)) == NULL)
if (!midori_history_initialize (history, config_file, bookmarks_file, &errmsg))
{
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);
midori_startup_timer ("History read: \t%f");
/* In case of errors */
@ -2203,7 +2177,7 @@ main (int argc,
settings = katze_object_get_object (app, "settings");
g_object_get (settings, "maximum-history-age", &max_history_age, NULL);
midori_history_terminate (db, max_history_age);
midori_history_terminate (history, max_history_age);
/* Removing KatzeHttpCookies makes it save outstanding changes */
soup_session_remove_feature_by_type (webkit_get_default_session (),
KATZE_TYPE_HTTP_COOKIES);

View file

@ -42,6 +42,9 @@
#if HAVE_LIBNOTIFY
#include <libnotify/notify.h>
#ifndef NOTIFY_CHECK_VERSION
#define NOTIFY_CHECK_VERSION(x,y,z) 0
#endif
#endif
struct _MidoriApp
@ -1203,8 +1206,11 @@ midori_app_send_notification (MidoriApp* app,
if (notify_is_initted ())
{
NotifyNotification* note;
#if NOTIFY_CHECK_VERSION (0, 7, 0)
note = notify_notification_new (title, message, "midori");
#else
note = notify_notification_new (title, message, "midori", NULL);
#endif
notify_notification_show (note, NULL);
g_object_unref (note);
}

View file

@ -294,18 +294,93 @@ katze_array_from_xmlDocPtr (KatzeArray* array,
}
static gboolean
katze_array_from_opera_file (KatzeArray* array,
FILE* file)
katze_array_from_netscape_file (KatzeArray* array,
const gchar* filename)
{
gchar line[200];
gchar* partial_line = NULL;
gchar* line = NULL;
GIOChannel* channel = g_io_channel_new_file (filename, "r", 0);
KatzeArray* folder = array;
KatzeItem* item = NULL;
if (!channel)
return FALSE;
while (g_io_channel_read_line (channel, &line, NULL, NULL, NULL)
== G_IO_STATUS_NORMAL)
{
g_strstrip (line);
/* parse lines with bookmarks data only, skip the rest */
if (!strncmp (line, "<D", 2) || !strncmp (line, "</D", 3))
{
gchar** element = g_strsplit_set (line, "<>", -1);
/* current item */
if (katze_str_equal (element[1], "DT"))
{
/* item is bookmark */
if (!strncmp (element[3], "A HREF", 6))
{
gchar** parts = g_strsplit (line, "\"", -1);
item = katze_item_new ();
katze_array_add_item (folder, item);
item->name = g_strdup (element[4]);
item->uri = g_strdup (parts[1]);
g_strfreev (parts);
}
/* item is folder */
if (!strncmp (element[3], "H3", 2))
{
item = (KatzeItem*)katze_array_new (KATZE_TYPE_ARRAY);
katze_array_add_item (folder, item);
folder = (KatzeArray*)item;
item->name = g_strdup (element[4]);
}
}
/* item description */
if (item && katze_str_equal (element[1], "DD"))
{
if (element[2])
item->text = g_strdup (element[2]);
item = NULL;
}
/* end of current folder, level-up */
if (katze_str_equal (element[1], "/DL"))
{
if (folder != array)
folder = katze_item_get_parent ((KatzeItem*)folder);
continue;
}
g_strfreev (element);
}
continue;
}
g_io_channel_shutdown (channel, FALSE, 0);
g_io_channel_unref (channel);
return TRUE;
}
static gboolean
katze_array_from_opera_file (KatzeArray* array,
const gchar* filename)
{
gchar* line = NULL;
GIOChannel* channel = g_io_channel_new_file (filename, "r", 0);
KatzeArray* folder = array;
KatzeItem* item = NULL;
while (fgets (line, 200, file))
if (!channel)
return FALSE;
while (g_io_channel_read_line (channel, &line, NULL, NULL, NULL)
== G_IO_STATUS_NORMAL)
{
gboolean incomplete_line = (strlen (line) == 199);
g_strstrip (line);
/* skip file header */
if (katze_str_equal (line, "Options: encoding = utf8, version=3")
|| katze_str_equal (line, "Opera Hotlist version 2.0"))
{
item = NULL;
continue;
}
if (line[0] == '\0')
{
item = NULL;
@ -340,30 +415,7 @@ katze_array_from_opera_file (KatzeArray* array,
}
else if (item)
{
gchar** parts;
/* Handle lines longer than 200 characters */
if (incomplete_line)
{
if (partial_line)
{
gchar* chunk = g_strconcat (partial_line, line, NULL);
katze_assign (partial_line, chunk);
}
else
partial_line = g_strdup (line);
continue;
}
if (partial_line)
{
gchar* full_line = g_strconcat (partial_line, line, NULL);
katze_assign (partial_line, NULL);
parts = g_strsplit (full_line, "=", 2);
g_free (full_line);
}
else
parts = g_strsplit (line, "=", 2);
gchar** parts = g_strsplit (line, "=", 2);
if (parts && parts[0] && parts[1])
{
@ -392,6 +444,8 @@ katze_array_from_opera_file (KatzeArray* array,
else
g_warning ("Unexpected property outside of element: %s", line);
}
g_io_channel_shutdown (channel, FALSE, 0);
g_io_channel_unref (channel);
return TRUE;
}
@ -433,6 +487,36 @@ midori_array_from_file (KatzeArray* array,
if (!format)
format = "";
/* netscape html */
if (!*format && g_str_has_suffix (filename, ".html"))
{
FILE* file;
if ((file = g_fopen (filename, "r")))
{
gchar line[50];
while (fgets (line, 50, file))
{
g_strstrip (line);
if (katze_str_equal (line, "<!DOCTYPE NETSCAPE-Bookmark-file-1>"))
{
if (!katze_array_from_netscape_file (array, filename))
{
/* Parsing failed */
fclose (file);
if (error)
*error = g_error_new_literal (G_FILE_ERROR,
G_FILE_ERROR_FAILED, _("Malformed document."));
return FALSE;
}
return TRUE;
}
else
break;
}
fclose (file);
}
}
/* Opera6 */
if (katze_str_equal (format, "opera")
|| (!*format && g_str_has_suffix (filename, ".adr")))
@ -454,7 +538,7 @@ midori_array_from_file (KatzeArray* array,
verify++;
else if (verify == 2)
{
if (!katze_array_from_opera_file (array, file))
if (!katze_array_from_opera_file (array, filename))
{
/* Parsing failed */
fclose (file);
@ -591,15 +675,17 @@ string_append_item (GString* string,
{
KatzeItem* _item;
KatzeArray* array = KATZE_ARRAY (item);
GList* list;
g_string_append (string, "<folder>\n");
/* FIXME: " folded=\"no\" */
string_append_xml_element (string, "title", katze_item_get_name (item));
string_append_xml_element (string, "desc", katze_item_get_text (item));
KATZE_ARRAY_FOREACH_ITEM (_item, array)
KATZE_ARRAY_FOREACH_ITEM_L (_item, array, list)
string_append_item (string, _item);
g_string_append (string, metadata);
g_string_append (string, "</folder>\n");
g_list_free (list);
}
else if (katze_item_get_uri (item))
{
@ -679,6 +765,7 @@ katze_array_to_xbel (KatzeArray* array,
{
gchar* metadata = katze_item_metadata_to_xbel (KATZE_ITEM (array));
KatzeItem* item;
GList* list;
GString* markup = g_string_new (
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
@ -691,11 +778,12 @@ katze_array_to_xbel (KatzeArray* array,
string_append_xml_element (markup, "title", katze_item_get_name (KATZE_ITEM (array)));
string_append_xml_element (markup, "desc", katze_item_get_text (KATZE_ITEM (array)));
g_string_append (markup, metadata);
KATZE_ARRAY_FOREACH_ITEM (item, array)
KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
string_append_item (markup, item);
g_string_append (markup, "</xbel>\n");
g_free (metadata);
g_list_free (list);
return g_string_free (markup, FALSE);
}

View file

@ -178,11 +178,6 @@ midori_bookmarks_export_array_db (sqlite3* db,
KatzeArray* array,
const gchar* folder);
void
midori_bookmarks_insert_item_db (sqlite3* db,
KatzeItem* item,
gchar* folder);
void
midori_browser_open_bookmark (MidoriBrowser* browser,
KatzeItem* item);
@ -476,6 +471,7 @@ midori_browser_update_history_title (MidoriBrowser* browser,
g_return_if_fail (katze_item_get_uri (item) != NULL);
db = g_object_get_data (G_OBJECT (browser->history), "db");
g_return_if_fail (db != NULL);
if (!stmt)
{
const gchar* sqlcmd;
@ -909,8 +905,6 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
gchar* selected;
GtkTreeView* treeview;
GtkTreeModel* model;
if (!new_bookmark)
katze_array_remove_item (browser->bookmarks, bookmark);
@ -930,23 +924,13 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
}
selected = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combo_folder));
if (!strcmp (selected, _("Toplevel folder")))
selected = g_strdup ("");
midori_bookmarks_insert_item_db (db, bookmark, selected);
if (new_bookmark)
{
treeview = g_object_get_data (G_OBJECT (browser->bookmarks), "treeview");
model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
gtk_tree_store_insert_with_values (GTK_TREE_STORE (model),
NULL, NULL, G_MAXINT, 0, bookmark, -1);
}
katze_assign (selected, g_strdup (""));
katze_item_set_meta_string (bookmark, "folder", selected);
katze_array_add_item (browser->bookmarks, bookmark);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_toolbar)))
if (!gtk_widget_get_visible (browser->bookmarkbar)
&& browser->bookmarks != NULL)
if (!gtk_widget_get_visible (browser->bookmarkbar))
_action_set_active (browser, "Bookmarkbar", TRUE);
g_free (selected);
return_status = TRUE;
@ -2218,14 +2202,46 @@ static void
_action_add_desktop_shortcut_activate (GtkAction* action,
MidoriBrowser* browser)
{
#if defined (GDK_WINDOWING_X11)
#if HAVE_HILDON
/* TODO: Implement */
#elif defined (GDK_WINDOWING_X11)
GtkWidget* tab = midori_browser_get_current_tab (browser);
KatzeItem* item = midori_view_get_proxy_item (MIDORI_VIEW (tab));
const gchar* app_name = katze_item_get_name (item);
gchar* app_exec = g_strconcat ("midori -a ", katze_item_get_uri (item), NULL);
const gchar* icon_uri = midori_view_get_icon_uri (MIDORI_VIEW (tab));
gchar* app_icon;
GKeyFile* keyfile = g_key_file_new ();
gchar* filename = g_strconcat (app_name, ".desktop", NULL);
gchar* app_dir;
int i = 0;
while (filename[i] != '\0')
{
if (filename[i] == '/')
filename[i] = '_';
i++;
}
app_dir = g_build_filename (g_get_user_data_dir (),
"applications", filename, NULL);
app_icon = katze_net_get_cached_path (NULL, icon_uri, "icons");
if (!g_file_test (app_icon, G_FILE_TEST_EXISTS))
katze_assign (app_icon, g_strdup (STOCK_WEB_BROWSER));
g_key_file_set_string (keyfile, "Desktop Entry", "Version", "1.0");
g_key_file_set_string (keyfile, "Desktop Entry", "Type", "Application");
g_key_file_set_string (keyfile, "Desktop Entry", "Name", app_name);
g_key_file_set_string (keyfile, "Desktop Entry", "Exec", app_exec);
g_key_file_set_string (keyfile, "Desktop Entry", "TryExec", "midori");
g_key_file_set_string (keyfile, "Desktop Entry", "Icon", app_icon);
g_key_file_set_string (keyfile, "Desktop Entry", "Categories", "Network;");
sokoke_key_file_save_to_file (keyfile, app_dir, NULL);
g_free (app_dir);
g_free (filename);
g_free (app_exec);
g_key_file_free (keyfile);
#elif defined(GDK_WINDOWING_QUARTZ)
/* TODO: Implement */
#elif defined (GDK_WINDOWING_WIN32)
/* TODO: Implement */
#elif HAVE_HILDON
/* TODO: Implement */
#endif
}
@ -2921,9 +2937,8 @@ _action_compact_menu_populate_popup (GtkAction* action,
{ "WindowNew" },
{ "PrivateBrowsing" },
{ "Open" },
#if HAVE_HILDON
{ "Find" },
#else
#if !HAVE_HILDON
{ "Print" },
{ NULL },
{ "Panel" },
@ -3989,6 +4004,7 @@ _action_bookmarks_import_activate (GtkAction* action,
gint icon_width = 16;
guint i;
KatzeItem* item;
KatzeArray* bookmarks;
sqlite3* db;
const gchar* sqlcmd;
KatzeArray* bookmarkdirs;
@ -4038,7 +4054,7 @@ _action_bookmarks_import_activate (GtkAction* action,
g_free (path);
}
gtk_list_store_insert_with_values (model, NULL, G_MAXINT,
0, _("Import from a file"), 1, NULL, 2, NULL, 3, icon_width, -1);
0, _("Import from XBEL or HTML file"), 1, NULL, 2, NULL, 3, icon_width, -1);
gtk_combo_box_set_active (combobox, 0);
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (content_area), hbox);
@ -4095,14 +4111,17 @@ _action_bookmarks_import_activate (GtkAction* action,
}
error = NULL;
if (path && !midori_array_from_file (browser->bookmarks, path, NULL, &error))
bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
if (path && !midori_array_from_file (bookmarks, path, NULL, &error))
{
sokoke_message_dialog (GTK_MESSAGE_ERROR,
_("Failed to import bookmarks"), error ? error->message : "");
if (error)
g_error_free (error);
}
midori_bookmarks_import_array_db (db, browser->bookmarks, selected);
midori_bookmarks_import_array_db (db, bookmarks, selected);
katze_array_update (browser->bookmarks);
g_object_unref (bookmarks);
g_free (selected);
g_free (path);
}
@ -4118,6 +4137,7 @@ _action_bookmarks_export_activate (GtkAction* action,
gchar* path = NULL;
GError* error;
sqlite3* db;
KatzeArray* bookmarks;
if (!browser->bookmarks || !gtk_widget_get_visible (GTK_WIDGET (browser)))
return;
@ -4135,14 +4155,16 @@ _action_bookmarks_export_activate (GtkAction* action,
error = NULL;
db = g_object_get_data (G_OBJECT (browser->history), "db");
midori_bookmarks_export_array_db (db, browser->bookmarks, "");
if (!midori_array_to_file (browser->bookmarks, path, "xbel", &error))
bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
midori_bookmarks_export_array_db (db, bookmarks, "");
if (!midori_array_to_file (bookmarks, path, "xbel", &error))
{
sokoke_message_dialog (GTK_MESSAGE_ERROR,
_("Failed to export bookmarks"), error ? error->message : "");
if (error)
g_error_free (error);
}
g_object_unref (bookmarks);
g_free (path);
}
@ -4184,24 +4206,7 @@ midori_browser_clear_private_data_response_cb (GtkWidget* dialog,
button = g_object_get_data (G_OBJECT (dialog), "history");
if (gtk_toggle_button_get_active (button))
{
const gchar* sqlcmd = "DELETE FROM history";
sqlite3* db = g_object_get_data (G_OBJECT (browser->history), "db");
char* errmsg = NULL;
if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK)
{
g_printerr (_("Failed to clear history: %s\n"), errmsg);
sqlite3_free (errmsg);
}
else
{
sqlcmd = "DELETE FROM search";
if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK)
{
g_printerr (_("Failed to clear search history: %s\n"), errmsg);
sqlite3_free (errmsg);
}
}
katze_array_clear (browser->history);
clear_prefs |= MIDORI_CLEAR_HISTORY;
}
button = g_object_get_data (G_OBJECT (dialog), "trash");
@ -4403,10 +4408,11 @@ _action_tab_duplicate_activate (GtkAction* action,
{
GtkWidget* view = midori_browser_get_current_tab (browser);
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
GtkWidget* new_view = midori_view_new_with_uri (
midori_view_get_display_uri (MIDORI_VIEW (view)),
NULL, browser->settings);
GtkWidget* new_view = midori_view_new_with_title (
NULL, browser->settings, FALSE);
const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
g_signal_emit_by_name (view, "new-view", new_view, where);
midori_view_set_uri (MIDORI_VIEW (new_view), uri);
}
static void
@ -4514,8 +4520,8 @@ _action_help_link_activate (GtkAction* action,
uri = free_uri = g_filename_to_uri (path, NULL, NULL);
if (g_access (path, F_OK) != 0)
{
if (g_access (DOCDIR "/midori/user/midori.html", F_OK) == 0)
uri = "file://" DOCDIR "/midori/user/midori.html";
if (g_access (DOCDIR "/user/midori.html", F_OK) == 0)
uri = "file://" DOCDIR "/user/midori.html";
else
#endif
uri = "error:nodocs share/doc/midori/user/midori.html";
@ -4526,16 +4532,16 @@ _action_help_link_activate (GtkAction* action,
}
#else
#ifdef DOCDIR
uri = "file://" DOCDIR "/midori/user/midori.html";
if (g_access (DOCDIR "/midori/user/midori.html", F_OK) != 0)
uri = "file://" DOCDIR "/user/midori.html";
if (g_access (DOCDIR "/user/midori.html", F_OK) != 0)
#endif
uri = "error:nodocs " DOCDIR "/midori/user/midori.html";
uri = "error:nodocs " DOCDIR "/user/midori.html";
#endif
}
else if (!strncmp ("HelpFAQ", action_name, 7))
uri = "http://wiki.xfce.org/midori/faq";
else if (!strncmp ("HelpBugs", action_name, 8))
uri = "http://www.twotoasts.de/bugs/";
uri = PACKAGE_BUGREPORT;
else
uri = NULL;
@ -4584,7 +4590,7 @@ midori_panel_notify_page_cb (MidoriPanel* panel,
GParamSpec* pspec,
MidoriBrowser* browser)
{
gint page = katze_object_get_boolean (panel, "page");
gint page = midori_panel_get_current_page (panel);
if (page > -1)
g_object_set (browser->settings, "last-panel-page", page, NULL);
}
@ -4750,10 +4756,7 @@ midori_browser_notebook_button_press_event_after_cb (GtkNotebook* notebook,
if (/*(event->type == GDK_2BUTTON_PRESS && event->button == 1)
|| */(event->type == GDK_BUTTON_PRESS && event->button == 2))
{
gint n;
GtkWidget* view = midori_view_new_with_uri ("", NULL, browser->settings);
g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1);
n = midori_browser_add_tab (browser, view);
gint n = midori_browser_add_uri (browser, "");
midori_browser_set_current_page (browser, n);
return TRUE;
@ -4816,7 +4819,7 @@ static const GtkActionEntry entries[] =
N_("Add to Speed _dial"), "<Ctrl>h",
N_("Add shortcut to speed dial"), G_CALLBACK (_action_add_speed_dial_activate) },
{ "AddDesktopShortcut", NULL,
N_("Add Shortcut to the _desktop"), "<Ctrl>h",
N_("Add Shortcut to the _desktop"), "<Ctrl>j",
N_("Add shortcut to the desktop"), G_CALLBACK (_action_add_desktop_shortcut_activate) },
{ "AddNewsFeed", NULL,
N_("Subscribe to News _feed"), NULL,
@ -4852,9 +4855,6 @@ static const GtkActionEntry entries[] =
{ "Copy", GTK_STOCK_COPY,
NULL, "<Ctrl>c",
N_("Copy the selected text"), G_CALLBACK (_action_copy_activate) },
{ "Copy_", GTK_STOCK_COPY,
NULL, "<Ctrl>c",
N_("Copy the selected text"), G_CALLBACK (_action_copy_activate) },
{ "Paste", GTK_STOCK_PASTE,
NULL, "<Ctrl>v",
N_("Paste text from the clipboard"), G_CALLBACK (_action_paste_activate) },
@ -5330,6 +5330,7 @@ midori_browser_new_history_item (MidoriBrowser* browser,
day = sokoke_time_t_to_julian (&now);
db = g_object_get_data (G_OBJECT (browser->history), "db");
g_return_if_fail (db != NULL);
if (!stmt)
{
const gchar* sqlcmd;
@ -5702,7 +5703,7 @@ midori_browser_init (MidoriBrowser* browser)
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
"name", "CompactMenu",
"label", _("_Menu"),
"stock-id", STOCK_WEB_BROWSER,
"stock-id", GTK_STOCK_PROPERTIES,
"tooltip", _("Menu"),
"array", katze_array_new (KATZE_TYPE_ITEM),
NULL);
@ -5776,8 +5777,9 @@ midori_browser_init (MidoriBrowser* browser)
#endif
_action_set_sensitive (browser, "EncodingCustom", FALSE);
_action_set_visible (browser, "LastSession", FALSE);
/* FIXME: Show once implemented */
#if !HAVE_HILDON && !defined (GDK_WINDOWING_X11)
_action_set_visible (browser, "AddDesktopShortcut", FALSE);
#endif
_action_set_visible (browser, "Bookmarks", browser->bookmarks != NULL);
_action_set_visible (browser, "BookmarkAdd", browser->bookmarks != NULL);
@ -6454,6 +6456,8 @@ midori_browser_set_bookmarks (MidoriBrowser* browser,
if (!bookmarks)
return;
if (katze_object_get_boolean (browser->settings, "show-bookmarkbar"))
_action_set_active (browser, "Bookmarkbar", TRUE);
g_object_ref (bookmarks);
g_signal_connect (settings, "notify::show-bookmarkbar",
G_CALLBACK (midori_browser_show_bookmarkbar_notify_value_cb), browser);
@ -6712,23 +6716,24 @@ midori_browser_add_item (MidoriBrowser* browser,
g_return_val_if_fail (KATZE_IS_ITEM (item), -1);
uri = katze_item_get_uri (item);
if (!uri)
uri = "about:blank";
title = katze_item_get_name (item);
view = midori_view_new_with_title (title, browser->settings,
g_object_get_data (G_OBJECT (item), "midori-view-append") ? TRUE : FALSE);
page = midori_browser_add_tab (browser, view);
/* Blank pages should not be delayed */
if (katze_item_get_meta_integer (item, "delay") > 0
&& uri != NULL && strcmp (uri, "about:blank") != 0)
&& strcmp (uri, "about:blank") != 0)
{
gchar* new_uri = g_strdup_printf ("pause:%s", uri);
view = midori_view_new_with_uri (new_uri, title, browser->settings);
midori_view_set_uri (MIDORI_VIEW (view), new_uri);
g_free (new_uri);
}
else
view = midori_view_new_with_uri (uri, title, browser->settings);
midori_view_set_uri (MIDORI_VIEW (view), uri);
/* FIXME: We should have public API for that */
if (g_object_get_data (G_OBJECT (item), "midori-view-append"))
g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1);
page = midori_browser_add_tab (browser, view);
proxy_item = midori_view_get_proxy_item (MIDORI_VIEW (view));
if ((keys = katze_item_get_meta_keys (item)))
{
@ -6756,12 +6761,15 @@ midori_browser_add_uri (MidoriBrowser* browser,
const gchar* uri)
{
GtkWidget* view;
gint n;
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
g_return_val_if_fail (uri != NULL, -1);
view = midori_view_new_with_uri (uri, NULL, browser->settings);
return midori_browser_add_tab (browser, view);
view = midori_view_new_with_title (NULL, browser->settings, FALSE);
n = midori_browser_add_tab (browser, view);
midori_view_set_uri (MIDORI_VIEW (view), uri);
return n;
}
/**
@ -6872,8 +6880,14 @@ void
midori_browser_set_current_page (MidoriBrowser* browser,
gint n)
{
gint n_pages;
GtkWidget* view;
g_return_if_fail (MIDORI_IS_BROWSER (browser));
n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook));
g_return_if_fail (n < n_pages);
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n);
view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), n);
if (midori_view_is_blank (MIDORI_VIEW (view)))

View file

@ -566,7 +566,8 @@ midori_extension_get_config_dir (MidoriExtension* extension)
if (!extension->priv->config_dir)
{
gchar* filename = g_object_get_data (G_OBJECT (extension), "filename");
g_return_val_if_fail (filename != NULL, NULL);
if (!filename)
return "/";
extension->priv->config_dir = g_build_filename (
sokoke_set_config_dir (NULL), "extensions", filename, NULL);
}

View file

@ -30,9 +30,6 @@ struct _MidoriPanel
GtkWidget* labelbar;
GtkWidget* toolbar;
GtkToolItem* button_align;
GtkToolItem* button_detach;
GtkToolItem* button_controls;
GtkWidget* toolbar_label;
GtkWidget* frame;
GtkWidget* toolbook;
@ -194,6 +191,8 @@ midori_panel_class_init (MidoriPanelClass* class)
* Whether to show operating controls.
*
* Since: 0.1.9
*
* Deprecated: 0.3.0
*/
g_object_class_install_property (gobject_class,
PROP_SHOW_CONTROLS,
@ -210,6 +209,8 @@ midori_panel_class_init (MidoriPanelClass* class)
* Whether to align the panel on the right.
*
* Since: 0.1.3
*
* Deprecated: 0.3.0
*/
g_object_class_install_property (gobject_class,
PROP_RIGHT_ALIGNED,
@ -338,31 +339,11 @@ midori_panel_detach_page (MidoriPanel* panel,
midori_panel_set_current_page (panel, n > 0 ? n - 1 : 0);
toolitem = gtk_toolbar_get_nth_item (GTK_TOOLBAR (panel->toolbar),
n > 0 ? n - 1 : 0);
if (!gtk_notebook_get_n_pages (GTK_NOTEBOOK (panel->notebook)))
gtk_widget_set_sensitive (GTK_WIDGET (panel->button_detach), FALSE);
g_signal_connect (window, "delete-event",
G_CALLBACK (midori_panel_detached_window_delete_event_cb), panel);
gtk_widget_show (window);
}
static void
midori_panel_button_detach_clicked_cb (GtkWidget* toolbutton,
MidoriPanel* panel)
{
/* FIXME: What happens when the browser is destroyed? */
/* FIXME: What about multiple browsers? */
/* FIXME: Should we remember if the child was detached? */
gint n = midori_panel_get_current_page (panel);
midori_panel_detach_page (panel, n);
}
static void
midori_panel_button_align_clicked_cb (GtkWidget* toolitem,
MidoriPanel* panel)
{
midori_panel_set_right_aligned (panel, !panel->right_aligned);
}
static void
midori_panel_destroy_cb (MidoriPanel* panel)
{
@ -405,33 +386,6 @@ midori_panel_init (MidoriPanel* panel)
gtk_container_add (GTK_CONTAINER (toolitem), panel->toolbar_label);
gtk_container_set_border_width (GTK_CONTAINER (toolitem), 6);
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_FULLSCREEN);
gtk_widget_set_sensitive (GTK_WIDGET (toolitem), FALSE);
panel->button_detach = toolitem;
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem),
_("Detach chosen panel from the window"));
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem),
_("Detach chosen panel from the window"));
g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_panel_button_detach_clicked_cb), panel);
#if HAVE_OSX
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, 0);
#else
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);
#endif
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem),
_("Align sidepanel to the right"));
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem),
_("Align sidepanel to the right"));
g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_panel_button_align_clicked_cb), panel);
#if HAVE_OSX
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, 0);
#else
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);
#endif
panel->button_align = toolitem;
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_CLOSE);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), _("Close panel"));
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem), _("Close panel"));
@ -450,7 +404,6 @@ midori_panel_init (MidoriPanel* panel)
gtk_notebook_set_show_border (GTK_NOTEBOOK (panel->toolbook), FALSE);
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (panel->toolbook), FALSE);
gtk_box_pack_start (GTK_BOX (vbox), panel->toolbook, FALSE, FALSE, 0);
gtk_widget_show (panel->toolbook);
/* Create the notebook */
panel->notebook = gtk_notebook_new ();
@ -497,12 +450,6 @@ midori_panel_set_property (GObject* object,
break;
case PROP_SHOW_CONTROLS:
panel->show_controls = g_value_get_boolean (value);
sokoke_widget_set_visible (panel->labelbar, panel->show_controls);
sokoke_widget_set_visible (panel->toolbar, panel->show_controls);
if (panel->button_controls)
gtk_toggle_tool_button_set_active (
GTK_TOGGLE_TOOL_BUTTON (panel->button_controls),
!panel->show_controls);
break;
case PROP_RIGHT_ALIGNED:
midori_panel_set_right_aligned (panel, g_value_get_boolean (value));
@ -589,15 +536,7 @@ midori_panel_set_right_aligned (MidoriPanel* panel,
box = gtk_widget_get_parent (panel->toolbar);
gtk_box_reorder_child (GTK_BOX (box), panel->toolbar,
right_aligned ? -1 : 0);
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (panel->button_align),
right_aligned ? GTK_STOCK_GO_BACK : GTK_STOCK_GO_FORWARD);
panel->right_aligned = right_aligned;
gtk_tool_button_set_label (GTK_TOOL_BUTTON (panel->button_align),
!panel->right_aligned ? _("Align sidepanel to the right")
: _("Align sidepanel to the left"));
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (panel->button_align),
!panel->right_aligned ? _("Align sidepanel to the right")
: _("Align sidepanel to the left"));
g_object_notify (G_OBJECT (panel), "right-aligned");
}
@ -644,9 +583,6 @@ midori_panel_construct_tool_item (MidoriPanel* panel,
g_signal_connect (viewable, "destroy",
G_CALLBACK (midori_panel_widget_destroy_cb), toolitem);
if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (panel->notebook)))
gtk_widget_set_sensitive (GTK_WIDGET (panel->button_detach), TRUE);
return GTK_TOOL_ITEM (toolitem);
}
@ -677,16 +613,6 @@ midori_panel_action_activate_cb (GtkRadioAction* action,
}
}
#if !HAVE_HILDON
static void
midori_panel_show_controls_toggled_cb (GtkWidget* menuitem,
MidoriPanel* panel)
{
if (panel->show_controls != !gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (menuitem)))
g_object_set (panel, "show-controls", !panel->show_controls, NULL);
}
#endif
/**
* midori_panel_append_page:
* @panel: a #MidoriPanel
@ -749,17 +675,6 @@ midori_panel_append_page (MidoriPanel* panel,
gtk_container_add (GTK_CONTAINER (panel->notebook), scrolled);
toolbar = midori_viewable_get_toolbar (viewable);
#if !HAVE_HILDON
toolitem = gtk_toggle_tool_button_new_from_stock (GTK_STOCK_PROPERTIES);
gtk_tool_item_set_tooltip_text (toolitem, _("Hide operating controls"));
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (toolitem),
!panel->show_controls);
g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_panel_show_controls_toggled_cb), panel);
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, 0);
gtk_widget_show (GTK_WIDGET (toolitem));
panel->button_controls = toolitem;
#endif
gtk_widget_show (toolbar);
gtk_container_add (GTK_CONTAINER (panel->toolbook), toolbar);
g_signal_connect (viewable, "destroy",
@ -954,8 +869,7 @@ midori_panel_set_current_page (MidoriPanel* panel,
gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->toolbook), n);
toolbar = gtk_notebook_get_nth_page (GTK_NOTEBOOK (panel->toolbook), n);
items = gtk_container_get_children (GTK_CONTAINER (toolbar));
sokoke_widget_set_visible (panel->toolbook,
g_list_nth_data (items, 1) != NULL);
sokoke_widget_set_visible (panel->toolbook, items != NULL);
g_list_free (items);
gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->notebook), n);
label = midori_viewable_get_label (MIDORI_VIEWABLE (viewable));

View file

@ -413,22 +413,14 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
#if !HAVE_HILDON
button = katze_property_proxy (settings, "auto-load-images", NULL);
INDENTED_ADD (button);
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 15) || HAVE_HILDON
if (katze_widget_has_touchscreen_mode (parent ?
GTK_WIDGET (parent) : GTK_WIDGET (preferences)))
button = katze_property_proxy (settings, "kinetic-scrolling", NULL);
else
{
button = katze_property_proxy (settings, "enforce-96-dpi", NULL);
gtk_button_set_label (GTK_BUTTON (button), _("Enforce 96 dots per inch"));
gtk_widget_set_tooltip_text (button, _("Enforce a video dot density of 96 DPI"));
}
#if WEBKIT_CHECK_VERSION (1, 1, 6)
button = katze_property_proxy (settings, "enable-spell-checking", NULL);
#else
button = katze_property_proxy (settings, "middle-click-opens-selection", NULL);
button = katze_property_proxy (settings, "enforce-96-dpi", NULL);
gtk_button_set_label (GTK_BUTTON (button), _("Enforce 96 dots per inch"));
gtk_widget_set_tooltip_text (button, _("Enforce a video dot density of 96 DPI"));
#endif
SPANNED_ADD (button);
#if !HAVE_HILDON
button = katze_property_proxy (settings, "enable-scripts", NULL);
INDENTED_ADD (button);
button = katze_property_proxy (settings, "enable-plugins", NULL);
@ -442,18 +434,20 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
gtk_widget_set_tooltip_text (button, _("Whether scripts are allowed to open popup windows automatically"));
SPANNED_ADD (button);
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 6)
FRAME_NEW (_("Spell Checking"));
button = katze_property_proxy (settings, "enable-spell-checking", NULL);
gtk_button_set_label (GTK_BUTTON (button), _("Enable Spell Checking"));
gtk_widget_set_tooltip_text (button, _("Enable spell checking while typing"));
INDENTED_ADD (button);
entry = katze_property_proxy (settings, "spell-checking-languages", "languages");
/* i18n: The example should be adjusted to contain a good local default */
gtk_widget_set_tooltip_text (entry, _("A comma separated list of "
"languages to be used for spell checking, for example \"en_GB,de_DE\""));
SPANNED_ADD (entry);
button = NULL;
#if WEBKIT_CHECK_VERSION (1, 1, 15) || HAVE_HILDON
if (katze_widget_has_touchscreen_mode (parent ?
GTK_WIDGET (parent) : GTK_WIDGET (preferences)))
button = katze_property_proxy (settings, "kinetic-scrolling", NULL);
#else
button = katze_property_proxy (settings, "middle-click-opens-selection", NULL);
#endif
if (button != NULL)
INDENTED_ADD (button);
button = katze_property_label (settings, "preferred-languages");
INDENTED_ADD (button);
entry = katze_property_proxy (settings, "preferred-languages", "languages");
SPANNED_ADD (entry);
/* Page "Interface" */
PAGE_NEW (GTK_STOCK_CONVERT, _("Interface"));
@ -521,10 +515,6 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
INDENTED_ADD (label);
button = katze_property_proxy (settings, "identify-as", "custom-user-agent");
SPANNED_ADD (button);
label = katze_property_label (settings, "preferred-languages");
INDENTED_ADD (label);
entry = katze_property_proxy (settings, "preferred-languages", "languages");
SPANNED_ADD (entry);
/* Page "Privacy" */
PAGE_NEW (GTK_STOCK_INDEX, _("Privacy"));

View file

@ -403,20 +403,21 @@ midori_search_action_manage_activate_cb (GtkWidget* menuitem,
/* static */ GdkPixbuf*
midori_search_action_get_icon (KatzeItem* item,
GtkWidget* widget,
const gchar** icon_name)
const gchar** icon_name,
gboolean in_entry)
{
const gchar* icon;
GdkScreen* screen;
GtkIconTheme* icon_theme;
if ((icon = katze_item_get_uri (item)) && (g_strstr_len (icon, 8, "://")))
return katze_load_cached_icon (icon, widget);
screen = gtk_widget_get_screen (widget);
icon_theme = gtk_icon_theme_get_for_screen (screen);
if ((icon = katze_item_get_icon (item)) && *icon)
{
GdkScreen* screen;
GtkIconTheme* icon_theme;
screen = gtk_widget_get_screen (widget);
icon_theme = gtk_icon_theme_get_for_screen (screen);
if (gtk_icon_theme_has_icon (icon_theme, icon))
{
*icon_name = icon;
@ -424,7 +425,12 @@ midori_search_action_get_icon (KatzeItem* item,
}
}
*icon_name = GTK_STOCK_FILE;
if (in_entry && gtk_icon_theme_has_icon (icon_theme, "edit-find-option-symbolic"))
*icon_name = "edit-find-option-symbolic";
else if (gtk_icon_theme_has_icon (icon_theme, "edit-find-option"))
*icon_name = "edit-find-option";
else
*icon_name = "edit-find";
return NULL;
}
@ -455,7 +461,7 @@ midori_search_action_icon_released_cb (GtkWidget* entry,
menuitem = gtk_image_menu_item_new_with_label (
katze_item_get_name (item));
image = gtk_image_new ();
icon = midori_search_action_get_icon (item, entry, &icon_name);
icon = midori_search_action_get_icon (item, entry, &icon_name, FALSE);
if (icon)
{
gtk_image_set_from_pixbuf (GTK_IMAGE (image), icon);
@ -520,7 +526,7 @@ midori_search_action_set_entry_icon (MidoriSearchAction* search_action,
const gchar* icon_name;
icon = midori_search_action_get_icon (search_action->current_item,
entry, &icon_name);
entry, &icon_name, TRUE);
if (icon)
{
gtk_icon_entry_set_icon_from_pixbuf (GTK_ICON_ENTRY (entry),
@ -825,7 +831,7 @@ midori_search_action_dialog_render_icon_cb (GtkTreeViewColumn* column,
gtk_tree_model_get (model, iter, 0, &item, -1);
search_action = g_object_get_data (G_OBJECT (treeview), "search-action");
if ((icon = midori_search_action_get_icon (item, treeview, &icon_name)))
if ((icon = midori_search_action_get_icon (item, treeview, &icon_name, FALSE)))
{
g_object_set (renderer, "pixbuf", icon, "yalign", 0.25, NULL);
g_object_unref (icon);

View file

@ -20,7 +20,7 @@
Names should match with epiphany and/ or xdg spec */
#define STOCK_BOOKMARK "stock_bookmark"
#define STOCK_BOOKMARKS "vcard"
#define STOCK_BOOKMARKS "user-bookmarks"
#define STOCK_CONSOLE "terminal"
#define STOCK_EXTENSION "extension"
#define STOCK_EXTENSIONS "extension"

View file

@ -59,6 +59,10 @@ midori_view_item_meta_data_changed (KatzeItem* item,
const gchar* key,
MidoriView* view);
static void
_midori_view_set_settings (MidoriView* view,
MidoriWebSettings* settings);
struct _MidoriView
{
GtkVBox parent_instance;
@ -470,7 +474,7 @@ midori_view_class_init (MidoriViewClass* class)
"Title",
"The title of the currently loaded page",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
flags));
/**
* MidoriView:security:
@ -600,8 +604,9 @@ midori_view_class_init (MidoriViewClass* class)
}
static void
midori_view_update_title (MidoriView* view)
midori_view_set_title (MidoriView* view, const gchar* title)
{
katze_assign (view->title, g_strdup (title));
#ifndef G_OS_WIN32
/* If left-to-right text is combined with right-to-left text the default
behaviour of Pango can result in awkwardly aligned text. For example
@ -1447,9 +1452,9 @@ midori_view_apply_scroll_position (MidoriView* view)
{
if (view->scrollh > 0)
{
GtkAdjustment* adjustment = katze_object_get_object (view->scrolled_window, "hadjustment");
GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (view->scrolled_window);
GtkAdjustment* adjustment = gtk_scrolled_window_get_hadjustment (scrolled);
gtk_adjustment_set_value (adjustment, view->scrollh);
g_object_unref (adjustment);
}
view->scrollh = -3;
}
@ -1457,9 +1462,9 @@ midori_view_apply_scroll_position (MidoriView* view)
{
if (view->scrollv > 0)
{
GtkAdjustment* adjustment = katze_object_get_object (view->scrolled_window, "vadjustment");
GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (view->scrolled_window);
GtkAdjustment* adjustment = gtk_scrolled_window_get_vadjustment (scrolled);
gtk_adjustment_set_value (adjustment, view->scrollv);
g_object_unref (adjustment);
}
view->scrollv = -3;
}
@ -1542,7 +1547,8 @@ midori_web_view_notify_icon_uri_cb (WebKitWebView* web_view,
GParamSpec* pspec,
MidoriView* view)
{
katze_assign (view->icon_uri, katze_object_get_string (web_view, "icon-uri"));
const gchar* icon_uri = webkit_web_view_get_icon_uri (web_view);
katze_assign (view->icon_uri, g_strdup (icon_uri));
_midori_web_view_load_icon (view);
}
#endif
@ -1553,8 +1559,8 @@ webkit_web_view_notify_title_cb (WebKitWebView* web_view,
GParamSpec* pspec,
MidoriView* view)
{
g_object_get (web_view, "title", &view->title, NULL);
midori_view_update_title (view);
const gchar* title = webkit_web_view_get_title (web_view);
midori_view_set_title (view, title);
g_object_notify (G_OBJECT (view), "title");
}
#else
@ -1609,26 +1615,33 @@ webkit_web_view_hovering_over_link_cb (WebKitWebView* web_view,
static void
midori_view_ensure_link_uri (MidoriView* view,
gint *x,
gint *y)
gint *y,
GdkEventButton* event)
{
g_return_if_fail (MIDORI_IS_VIEW (view));
#if WEBKIT_CHECK_VERSION (1, 1, 15)
if (view->web_view && gtk_widget_get_window (view->web_view))
{
gint ex, ey;
GdkEventButton event;
GdkEventButton ev;
if (!event) {
gint ex, ey;
event = &ev;
gdk_window_get_pointer (gtk_widget_get_window (view->web_view), &ex, &ey, NULL);
event->x = ex;
event->y = ey;
}
gdk_window_get_pointer (gtk_widget_get_window (view->web_view), &ex, &ey, NULL);
if (x != NULL)
*x = ex;
*x = event->x;
if (y != NULL)
*y = ey;
*y = event->y;
event.x = ex;
event.y = ey;
katze_object_assign (view->hit_test, webkit_web_view_get_hit_test_result (
WEBKIT_WEB_VIEW (view->web_view), &event));
katze_object_assign (view->hit_test,
g_object_ref (
webkit_web_view_get_hit_test_result (
WEBKIT_WEB_VIEW (view->web_view), event)));
katze_assign (view->link_uri,
katze_object_get_string (view->hit_test, "link-uri"));
}
@ -1650,7 +1663,7 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
gboolean background;
event->state = event->state & MIDORI_KEYS_MODIFIER_MASK;
midori_view_ensure_link_uri (view, NULL, NULL);
midori_view_ensure_link_uri (view, NULL, NULL, event);
link_uri = midori_view_get_link_uri (view);
switch (event->button)
@ -1801,9 +1814,16 @@ gtk_widget_key_press_event_cb (WebKitWebView* web_view,
event->state = event->state & MIDORI_KEYS_MODIFIER_MASK;
/* Handle oddities in Russian keyboard layouts */
if (event->hardware_keycode == ';')
event->keyval = ',';
else if (event->hardware_keycode == '<')
event->keyval = '.';
/* Find links by number: . to show links, type number, Return to go */
if (event->keyval == '.'
|| (view->find_links > -1 && (digit != -1 || event->keyval == GDK_Return)))
|| (view->find_links > -1
&& (digit != -1 || event->keyval == GDK_Return || event->keyval == GDK_Escape)))
{
WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (web_view);
JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
@ -1850,10 +1870,11 @@ gtk_widget_key_press_event_cb (WebKitWebView* web_view,
"if (return_key || typeof links[i * 10] == 'undefined') {"
" for (var j = 0; j < links.length; j++)"
" links[j].style.display = 'none !important';"
" links[i].parentNode.href; }",
" if (typeof links[i] != 'undefined')"
" links[i].parentNode.href; }",
view->find_links, event->keyval == GDK_Return);
result = sokoke_js_script_eval (js_context, script, NULL);
if (strcmp (result, "undefined"))
if (result && strstr (result, "://"))
{
view->find_links = -1;
if (MIDORI_MOD_NEW_TAB (event->state))
@ -2236,7 +2257,7 @@ midori_view_populate_popup (MidoriView* view,
gboolean is_image;
gboolean is_media;
midori_view_ensure_link_uri (view, &x, &y);
midori_view_ensure_link_uri (view, &x, &y, NULL);
context = katze_object_get_int (view->hit_test, "context");
has_selection = context & WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION;
/* Ensure view->selected_text */
@ -2801,9 +2822,8 @@ webkit_web_view_create_web_view_cb (GtkWidget* web_view,
new_view = view;
else
{
new_view = (MidoriView*)midori_view_new_with_uri (NULL, NULL,
view->settings);
midori_view_construct_web_view (new_view);
new_view = (MidoriView*)midori_view_new_with_title (NULL,
view->settings, FALSE);
g_signal_connect (new_view->web_view, "web-view-ready",
G_CALLBACK (webkit_web_view_web_view_ready_cb), view);
}
@ -3015,10 +3035,10 @@ midori_view_notify_hadjustment_cb (MidoriView* view,
GParamSpec* pspec,
gpointer data)
{
GtkAdjustment* hadjustment = katze_object_get_object (view->scrolled_window, "hadjustment");
GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (view->scrolled_window);
GtkAdjustment* hadjustment = gtk_scrolled_window_get_hadjustment (scrolled);
g_signal_connect (hadjustment, "notify::value",
G_CALLBACK (midori_view_hadjustment_notify_value_cb), view);
g_object_unref (hadjustment);
}
static void
@ -3035,10 +3055,10 @@ midori_view_notify_vadjustment_cb (MidoriView* view,
GParamSpec* pspec,
gpointer data)
{
GtkAdjustment* vadjustment = katze_object_get_object (view->scrolled_window, "vadjustment");
GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (view->scrolled_window);
GtkAdjustment* vadjustment = gtk_scrolled_window_get_vadjustment (scrolled);
g_signal_connect (vadjustment, "notify::value",
G_CALLBACK (midori_view_vadjustment_notify_value_cb), view);
g_object_unref (vadjustment);
}
static void
@ -3048,6 +3068,16 @@ katze_net_object_maybe_unref (gpointer object)
g_object_unref (object);
}
static GHashTable* midori_view_get_memory (void)
{
static GHashTable* memory = NULL;
if (!memory)
memory = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, katze_net_object_maybe_unref);
return g_hash_table_ref (memory);
}
static void
midori_view_init (MidoriView* view)
{
@ -3057,8 +3087,7 @@ midori_view_init (MidoriView* view)
view->mime_type = g_strdup ("");
view->icon = NULL;
view->icon_uri = NULL;
view->memory = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, katze_net_object_maybe_unref);
view->memory = midori_view_get_memory ();
view->progress = 0.0;
view->load_status = MIDORI_LOAD_FINISHED;
view->minimized = FALSE;
@ -3091,6 +3120,8 @@ midori_view_init (MidoriView* view)
G_CALLBACK (midori_view_notify_hadjustment_cb), view);
g_signal_connect (view->scrolled_window, "notify::vadjustment",
G_CALLBACK (midori_view_notify_vadjustment_cb), view);
midori_view_construct_web_view (view);
}
static void
@ -3107,13 +3138,22 @@ midori_view_finalize (GObject* object)
midori_view_item_meta_data_changed, view);
if (view->thumb_view)
{
gtk_widget_destroy (view->thumb_view);
view->thumb_view = NULL;
}
katze_assign (view->uri, NULL);
katze_assign (view->title, NULL);
katze_object_assign (view->icon, NULL);
katze_assign (view->icon_uri, NULL);
g_hash_table_destroy (view->memory);
if (view->memory)
{
g_hash_table_unref (view->memory);
view->memory = NULL;
}
katze_assign (view->statusbar_text, NULL);
katze_assign (view->link_uri, NULL);
katze_assign (view->selected_text, NULL);
@ -3141,8 +3181,7 @@ midori_view_set_property (GObject* object,
switch (prop_id)
{
case PROP_TITLE:
katze_assign (view->title, g_value_dup_string (value));
midori_view_update_title (view);
midori_view_set_title (view, g_value_get_string (value));
break;
case PROP_MINIMIZED:
view->minimized = g_value_get_boolean (value);
@ -3162,7 +3201,7 @@ midori_view_set_property (GObject* object,
katze_assign (view->statusbar_text, g_value_dup_string (value));
break;
case PROP_SETTINGS:
midori_view_set_settings (view, g_value_get_object (value));
_midori_view_set_settings (view, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -3228,10 +3267,7 @@ midori_view_focus_in_event (GtkWidget* widget,
{
MidoriView* view = MIDORI_VIEW (widget);
/* Always propagate focus to the child web view,
* create it if it's not there yet. */
if (!view->web_view)
midori_view_construct_web_view (view);
/* Always propagate focus to the child web view */
gtk_widget_grab_focus (view->web_view);
return TRUE;
}
@ -3244,7 +3280,7 @@ midori_view_focus_in_event (GtkWidget* widget,
*
* Return value: a new #MidoriView
*
* Deprecated: 0.2.8: Use midori_view_new_with_uri() instead.
* Deprecated: 0.2.8: Use midori_view_new_with_title() instead.
**/
GtkWidget*
midori_view_new (KatzeNet* net)
@ -3253,10 +3289,25 @@ midori_view_new (KatzeNet* net)
}
static void
_midori_view_update_settings (MidoriView* view)
_midori_view_set_settings (MidoriView* view,
MidoriWebSettings* settings)
{
gboolean zoom_text_and_images, kinetic_scrolling;
if (view->settings)
g_signal_handlers_disconnect_by_func (view->settings,
midori_view_settings_notify_cb, view);
katze_object_assign (view->settings, settings);
if (!settings)
return;
g_object_ref (settings);
g_signal_connect (settings, "notify",
G_CALLBACK (midori_view_settings_notify_cb), view);
g_object_set (view->web_view, "settings", settings, NULL);
g_free (view->download_manager);
g_free (view->news_aggregator);
@ -3281,36 +3332,29 @@ _midori_view_update_settings (MidoriView* view)
}
/**
* midori_view_new_with_uri:
* midori_view_new_with_title:
* @uri: an URI string, or %NULL
* @title: a title, or %NULL
* @settings: a #MidoriWebSettings, or %NULL
* @append: if %TRUE, the view should be appended
*
* Creates a new view with the specified parameters that
* is visible by default.
*
* Return value: a new #MidoriView
*
* Since: 0.2.8
* Since: 0.3.0
**/
GtkWidget*
midori_view_new_with_uri (const gchar* uri,
const gchar* title,
MidoriWebSettings* settings)
midori_view_new_with_title (const gchar* title,
MidoriWebSettings* settings,
gboolean append)
{
MidoriView* view = g_object_new (MIDORI_TYPE_VIEW, NULL);
view->title = g_strdup (title);
if (title != NULL)
midori_view_update_title (view);
MidoriView* view = g_object_new (MIDORI_TYPE_VIEW, "title", title, NULL);
if (settings)
{
view->settings = g_object_ref (settings);
_midori_view_update_settings (view);
g_signal_connect (settings, "notify",
G_CALLBACK (midori_view_settings_notify_cb), view);
}
if (uri != NULL)
midori_view_set_uri (view, uri);
_midori_view_set_settings (view, settings);
if (append)
g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1);
gtk_widget_show ((GtkWidget*)view);
return (GtkWidget*)view;
}
@ -3376,25 +3420,12 @@ midori_view_set_settings (MidoriView* view,
MidoriWebSettings* settings)
{
g_return_if_fail (MIDORI_IS_VIEW (view));
g_return_if_fail (!settings || MIDORI_IS_WEB_SETTINGS (settings));
g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings));
if (view->settings == settings)
return;
if (view->settings)
g_signal_handlers_disconnect_by_func (view->settings,
midori_view_settings_notify_cb, view);
katze_object_assign (view->settings, settings);
if (settings)
{
g_object_ref (settings);
if (view->web_view)
g_object_set (view->web_view, "settings", settings, NULL);
_midori_view_update_settings (view);
g_signal_connect (settings, "notify",
G_CALLBACK (midori_view_settings_notify_cb), view);
}
_midori_view_set_settings (view, settings);
g_object_notify (G_OBJECT (view), "settings");
}
@ -3501,13 +3532,11 @@ midori_view_web_inspector_inspect_web_view_cb (gpointer inspector,
}
static gboolean
midori_view_web_inspector_show_window_cb (gpointer inspector,
MidoriView* view)
midori_view_web_inspector_show_window_cb (WebKitWebInspector* inspector,
MidoriView* view)
{
GtkWidget* inspector_view = katze_object_get_object (inspector, "web-view");
GtkWidget* window = gtk_widget_get_toplevel (inspector_view);
g_object_unref (inspector_view);
WebKitWebView* inspector_view = webkit_web_inspector_get_web_view (inspector);
GtkWidget* window = gtk_widget_get_toplevel (GTK_WIDGET (inspector_view));
if (!window)
return FALSE;
gtk_window_present (GTK_WINDOW (window));
@ -3518,9 +3547,8 @@ static gboolean
midori_view_web_inspector_attach_window_cb (gpointer inspector,
MidoriView* view)
{
GtkWidget* inspector_view = katze_object_get_object (inspector, "web-view");
WebKitWebView* inspector_view = webkit_web_inspector_get_web_view (inspector);
g_signal_emit (view, signals[ATTACH_INSPECTOR], 0, inspector_view);
g_object_unref (inspector_view);
return TRUE;
}
@ -3528,15 +3556,15 @@ static gboolean
midori_view_web_inspector_detach_window_cb (gpointer inspector,
MidoriView* view)
{
GtkWidget* inspector_view = katze_object_get_object (inspector, "web-view");
GtkWidget* parent = gtk_widget_get_parent (inspector_view);
g_object_unref (inspector_view);
WebKitWebView* inspector_view = webkit_web_inspector_get_web_view (inspector);
GtkWidget* parent = gtk_widget_get_parent (GTK_WIDGET (inspector_view));
if (GTK_IS_WINDOW (parent))
return FALSE;
gtk_widget_hide (parent);
gtk_container_remove (GTK_CONTAINER (parent), inspector_view);
gtk_container_remove (GTK_CONTAINER (parent), GTK_WIDGET (inspector_view));
midori_view_web_inspector_construct_window (inspector,
WEBKIT_WEB_VIEW (view->web_view), inspector_view, view);
WEBKIT_WEB_VIEW (view->web_view), GTK_WIDGET (inspector_view), view);
return TRUE;
}
@ -3647,7 +3675,7 @@ midori_view_construct_web_view (MidoriView* view)
gtk_container_add (GTK_CONTAINER (view->scrolled_window), view->web_view);
gtk_widget_show_all (view->scrolled_window);
inspector = katze_object_get_object (view->web_view, "web-inspector");
inspector = webkit_web_view_get_inspector ((WebKitWebView*)view->web_view);
g_object_connect (inspector,
"signal::inspect-web-view",
midori_view_web_inspector_inspect_web_view_cb, view,
@ -3658,7 +3686,6 @@ midori_view_construct_web_view (MidoriView* view)
"signal::detach-window",
midori_view_web_inspector_detach_window_cb, view,
NULL);
g_object_unref (inspector);
}
/**
@ -3666,6 +3693,10 @@ midori_view_construct_web_view (MidoriView* view)
* @view: a #MidoriView
*
* Opens the specified URI in the view.
*
* Since 0.3.0 a warning is shown if the view is not yet
* contained in a browser. This is because extensions
* can't monitor page loading if that happens.
**/
void
midori_view_set_uri (MidoriView* view,
@ -3675,14 +3706,15 @@ midori_view_set_uri (MidoriView* view,
g_return_if_fail (MIDORI_IS_VIEW (view));
if (!gtk_widget_get_parent (GTK_WIDGET (view)))
g_warning ("Calling %s() before adding the view to a browser. This "
"breaks extensions that monitor page loading.", G_STRFUNC);
/* Treat "about:blank" and "" equally, see midori_view_is_blank(). */
if (!uri || !strcmp (uri, "about:blank")) uri = "";
if (g_getenv ("MIDORI_UNARMED") == NULL)
{
if (!view->web_view)
midori_view_construct_web_view (view);
if (view->speed_dial_in_new_tabs && !strcmp (uri, ""))
{
#if !WEBKIT_CHECK_VERSION (1, 1, 14)
@ -3847,6 +3879,7 @@ midori_view_set_uri (MidoriView* view,
data = g_strdup_printf (
"<html><head><title>about:version</title></head>"
"<body><h1>about:version</h1>"
"<p>Version numbers in brackets show the version used at runtime.</p>"
"<img src=\"res://logo-shade.png\" "
"style=\"position: absolute; right: 15px; bottom: 15px; z-index: -9;\">"
"<table>"
@ -4227,10 +4260,11 @@ midori_view_tab_label_menu_duplicate_tab_cb (GtkWidget* menuitem,
MidoriView* view)
{
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
GtkWidget* new_view = midori_view_new_with_uri (
midori_view_get_display_uri (view),
NULL, view->settings);
GtkWidget* new_view = midori_view_new_with_title (
NULL, view->settings, FALSE);
const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where);
midori_view_set_uri (MIDORI_VIEW (new_view), uri);
}
static void
@ -4331,9 +4365,9 @@ midori_view_get_tab_menu (MidoriView* view)
}
static gboolean
midori_view_tab_label_button_release_event (GtkWidget* tab_label,
GdkEventButton* event,
GtkWidget* widget)
midori_view_tab_label_button_press_event (GtkWidget* tab_label,
GdkEventButton* event,
GtkWidget* widget)
{
if (event->button == 2)
{
@ -4564,8 +4598,8 @@ midori_view_get_proxy_tab_label (MidoriView* view)
if (!view->close_buttons_on_tabs)
gtk_widget_hide (view->tab_close);
g_signal_connect (event_box, "button-release-event",
G_CALLBACK (midori_view_tab_label_button_release_event), view);
g_signal_connect (event_box, "button-press-event",
G_CALLBACK (midori_view_tab_label_button_press_event), view);
g_signal_connect (view->tab_close, "style-set",
G_CALLBACK (midori_view_tab_icon_style_set_cb), NULL);
g_signal_connect (view->tab_close, "clicked",
@ -4666,7 +4700,9 @@ midori_view_can_zoom_in (MidoriView* view)
{
g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
return view->web_view != NULL && !g_str_has_prefix (view->mime_type, "image/");
return view->web_view != NULL
&& (katze_object_get_boolean (view->settings, "zoom-text-and-images")
|| !g_str_has_prefix (view->mime_type, "image/"));
}
gboolean
@ -4674,7 +4710,9 @@ midori_view_can_zoom_out (MidoriView* view)
{
g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
return view->web_view != NULL && !g_str_has_prefix (view->mime_type, "image/");
return view->web_view != NULL
&& (katze_object_get_boolean (view->settings, "zoom-text-and-images")
|| !g_str_has_prefix (view->mime_type, "image/"));
}
gboolean
@ -4907,31 +4945,14 @@ midori_view_print_create_custom_widget_cb (GtkPrintOperation* operation,
box = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (box), 4);
button = gtk_check_button_new ();
g_object_set_data (G_OBJECT (operation), "print-backgrounds", button);
button = katze_property_proxy (view->settings, "print-backgrounds", NULL);
gtk_button_set_label (GTK_BUTTON (button), _("Print background images"));
gtk_widget_set_tooltip_text (button, _("Whether background images should be printed"));
if (katze_object_get_boolean (view->settings, "print-backgrounds"))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
gtk_widget_show_all (box);
return box;
}
static void
midori_view_print_custom_widget_apply_cb (GtkPrintOperation* operation,
GtkWidget* widget,
MidoriView* view)
{
GtkWidget* button;
button = g_object_get_data (G_OBJECT (operation), "print-backgrounds");
g_object_set (view->settings,
"print-backgrounds",
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)),
NULL);
}
#endif
static void
@ -4968,8 +4989,6 @@ midori_view_print (MidoriView* view)
#endif
g_signal_connect (operation, "create-custom-widget",
G_CALLBACK (midori_view_print_create_custom_widget_cb), view);
g_signal_connect (operation, "custom-widget-apply",
G_CALLBACK (midori_view_print_custom_widget_apply_cb), view);
error = NULL;
webkit_web_frame_print_full (frame, operation,
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, &error);
@ -5244,7 +5263,7 @@ thumb_view_load_status_cb (MidoriView* thumb_view,
gchar* js;
gsize sz;
if (katze_object_get_enum (thumb_view, "load-status") != MIDORI_LOAD_FINISHED)
if (midori_view_get_load_status (thumb_view) != MIDORI_LOAD_FINISHED)
return;
gtk_widget_realize (midori_view_get_web_view (MIDORI_VIEW (thumb_view)));
@ -5307,7 +5326,7 @@ midori_view_speed_dial_inject_thumb (MidoriView* view,
if (!view->thumb_view)
{
view->thumb_view = midori_view_new_with_uri (NULL, NULL, NULL);
view->thumb_view = midori_view_new_with_title (NULL, NULL, FALSE);
gtk_container_add (GTK_CONTAINER (notebook), view->thumb_view);
/* We use an empty label. It's not invisible but at least hard to spot. */
label = gtk_event_box_new ();
@ -5318,7 +5337,7 @@ midori_view_speed_dial_inject_thumb (MidoriView* view,
thumb_view = view->thumb_view;
settings = g_object_new (MIDORI_TYPE_WEB_SETTINGS, "enable-scripts", FALSE,
"enable-plugins", FALSE, "auto-load-images", TRUE, NULL);
midori_view_set_settings (MIDORI_VIEW (thumb_view), settings);
_midori_view_set_settings (MIDORI_VIEW (thumb_view), settings);
g_object_set_data (G_OBJECT (thumb_view), "dom-id", dom_id);
g_signal_connect (thumb_view, "notify::load-status",

View file

@ -81,9 +81,9 @@ GtkWidget*
midori_view_new (KatzeNet* net);
GtkWidget*
midori_view_new_with_uri (const gchar* uri,
const gchar* title,
MidoriWebSettings* settings);
midori_view_new_with_title (const gchar* title,
MidoriWebSettings* settings,
gboolean append);
void
midori_view_set_settings (MidoriView* view,

View file

@ -151,6 +151,7 @@ enum
PROP_ENABLE_SCRIPTS,
PROP_ENABLE_PLUGINS,
PROP_ENABLE_DEVELOPER_EXTRAS,
PROP_ENABLE_SPELL_CHECKING,
PROP_ENABLE_HTML5_DATABASE,
PROP_ENABLE_HTML5_LOCAL_STORAGE,
PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
@ -547,7 +548,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
"toolbar-items",
_("Toolbar Items"),
_("The items to show on the toolbar"),
"TabNew,Back,Forward,Next,ReloadStop,Location,Panel,Search,Trash",
"TabNew,Back,Forward,Next,ReloadStop,BookmarkAdd,Location,Search,Trash",
flags));
g_object_class_install_property (gobject_class,
@ -565,6 +566,8 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
* Whether to show the operating controls of the panel.
*
* Since: 0.1.9
*
* Deprecated: 0.3.0
*/
g_object_class_install_property (gobject_class,
PROP_SHOW_PANEL_CONTROLS,
@ -681,6 +684,8 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
* Note: Only since 0.2.0 is this value actually used.
*
* Since: 0.1.7
*
* Deprecated: 0.3.0
*/
g_object_class_install_property (gobject_class,
PROP_ASK_FOR_DESTINATION_FOLDER,
@ -701,6 +706,8 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
* Whether to show a notification when a transfer has been completed.
*
* Since: 0.1.7
*
* Deprecated: 0.3.0
*/
g_object_class_install_property (gobject_class,
PROP_NOTIFY_TRANSFER_COMPLETED,
@ -878,6 +885,15 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
"Enable special extensions for developers",
TRUE,
flags));
#if WEBKIT_CHECK_VERSION (1, 1, 6)
g_object_class_install_property (gobject_class,
PROP_ENABLE_SPELL_CHECKING,
g_param_spec_boolean ("enable-spell-checking",
_("Enable Spell Checking"),
_("Enable spell checking while typing"),
TRUE,
flags));
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 8)
g_object_class_install_property (gobject_class,
PROP_ENABLE_HTML5_DATABASE,
@ -1071,7 +1087,8 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
/**
* MidoriWebSettings:preferred-languages:
*
* A comma separated list of languages preferred for rendering multilingual webpages.
* A comma separated list of languages preferred for rendering multilingual
* webpages and spell checking.
*
* Since: 0.2.3
*/
@ -1438,13 +1455,23 @@ midori_web_settings_set_property (GObject* object,
g_value_get_boolean (value), NULL);
break;
case PROP_ENABLE_PLUGINS:
g_object_set (web_settings, "WebKitWebSettings::enable-plugins",
g_value_get_boolean (value), NULL);
g_object_set (web_settings,
"WebKitWebSettings::enable-plugins", g_value_get_boolean (value),
#if WEBKIT_CHECK_VERSION (1, 1, 22)
"enable-java-applet", g_value_get_boolean (value),
#endif
NULL);
break;
case PROP_ENABLE_DEVELOPER_EXTRAS:
g_object_set (web_settings, "WebKitWebSettings::enable-developer-extras",
g_value_get_boolean (value), NULL);
break;
#if WEBKIT_CHECK_VERSION (1, 1, 6)
case PROP_ENABLE_SPELL_CHECKING:
g_object_set (web_settings, "WebKitWebSettings::enable-spell-checking",
g_value_get_boolean (value), NULL);
break;
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 8)
case PROP_ENABLE_HTML5_DATABASE:
g_object_set (web_settings, "WebKitWebSettings::enable-html5-database",
@ -1519,6 +1546,10 @@ midori_web_settings_set_property (GObject* object,
break;
case PROP_PREFERRED_LANGUAGES:
katze_assign (web_settings->http_accept_language, g_value_dup_string (value));
#if WEBKIT_CHECK_VERSION (1, 1, 6)
g_object_set (web_settings, "spell-checking-languages",
web_settings->http_accept_language, NULL);
#endif
break;
case PROP_CLEAR_PRIVATE_DATA:
web_settings->clear_private_data = g_value_get_int (value);
@ -1686,6 +1717,12 @@ midori_web_settings_get_property (GObject* object,
g_value_set_boolean (value, katze_object_get_boolean (web_settings,
"WebKitWebSettings::enable-developer-extras"));
break;
#if WEBKIT_CHECK_VERSION (1, 1, 6)
case PROP_ENABLE_SPELL_CHECKING:
g_value_set_boolean (value, katze_object_get_boolean (web_settings,
"WebKitWebSettings::enable-spell-checking"));
break;
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 8)
case PROP_ENABLE_HTML5_DATABASE:
g_value_set_boolean (value, katze_object_get_boolean (web_settings,

View file

@ -45,31 +45,31 @@ namespace Midori {
public unowned GLib.Object get_proxy_items ();
[NoAccessorMethod]
public Gtk.MenuBar menubar { get; }
public Gtk.MenuBar menubar { owned get; }
[NoAccessorMethod]
public Gtk.Toolbar navigationbar { get; }
public Gtk.Toolbar navigationbar { owned get; }
[NoAccessorMethod]
public Gtk.Notebook notebook { get; }
public Gtk.Notebook notebook { owned get; }
[NoAccessorMethod]
public Gtk.Widget panel { get; }
public Gtk.Widget panel { owned get; }
[NoAccessorMethod]
public string uri { get; set; }
public string uri { owned get; set; }
public Gtk.Widget? tab { get; set; }
[NoAccessorMethod]
public uint load_status { get; }
[NoAccessorMethod]
public Gtk.Statusbar statusbar { get; }
public Gtk.Statusbar statusbar { owned get; }
[NoAccessorMethod]
public string statusbar_text { get; set; }
public string statusbar_text { owned get; set; }
public Midori.WebSettings settings { get; set; }
[NoAccessorMethod]
public GLib.Object bookmarks { get; set; }
public GLib.Object bookmarks { owned get; set; }
[NoAccessorMethod]
public GLib.Object trash { get; set; }
public GLib.Object trash { owned get; set; }
[NoAccessorMethod]
public GLib.Object search_engines { get; set; }
public GLib.Object search_engines { owned get; set; }
[NoAccessorMethod]
public GLib.Object history { get; set; }
public GLib.Object history { owned get; set; }
[NoAccessorMethod]
public bool show_tabs { get; set; }
@ -107,6 +107,8 @@ namespace Midori {
public class View : Gtk.VBox {
[CCode (type = "GtkWidget*")]
public View (GLib.Object net);
public View.with_title (string? title=null, WebSettings? settings=null
, bool append=false);
public void set_uri (string uri);
public bool is_blank ();
public unowned string get_display_uri ();

View file

@ -420,7 +420,8 @@ sokoke_spawn_program (const gchar* command,
g_return_val_if_fail (command != NULL, FALSE);
g_return_val_if_fail (argument != NULL, FALSE);
if (!g_strstr_len (argument, 8, "://"))
if (!g_strstr_len (argument, 8, "://")
&& !g_str_has_prefix (argument, "about:"))
{
gboolean success;
@ -827,15 +828,22 @@ sokoke_magic_uri (const gchar* uri)
* sokoke_uri_unescape_string:
* @uri: an URI string
*
* Unescape @uri if needed, and pass through '+'.
* Unescape @uri if needed, and pass through '+' and '%20'.
*
* Return value: a newly allocated URI
**/
gchar*
sokoke_uri_unescape_string (const gchar* uri)
{
if (strchr (uri,'%'))
return g_uri_unescape_string (uri, "+");
if (strchr (uri,'%') || strchr (uri, ' '))
{
/* Preserve %20 for pasting URLs into other windows */
gchar* unescaped = g_uri_unescape_string (uri, "+");
gchar* spaced = sokoke_replace_variables (unescaped, " ", "%20", NULL);
g_free (unescaped);
return spaced;
}
return g_strdup (uri);
}
@ -1101,6 +1109,17 @@ sokoke_on_entry_focus_out_event (GtkEntry* entry,
return FALSE;
}
static void
sokoke_on_entry_drag_data_received (GtkEntry* entry,
GdkDragContext* drag_context,
gint x,
gint y,
guint timestamp,
gpointer user_data)
{
sokoke_on_entry_focus_in_event (entry, NULL, NULL);
}
void
sokoke_entry_set_default_text (GtkEntry* entry,
const gchar* default_text)
@ -1115,6 +1134,12 @@ sokoke_entry_set_default_text (GtkEntry* entry,
sokoke_widget_set_pango_font_style (GTK_WIDGET (entry),
PANGO_STYLE_ITALIC);
gtk_entry_set_text (entry, default_text);
g_signal_connect (entry, "drag-data-received",
G_CALLBACK (sokoke_on_entry_drag_data_received), NULL);
g_signal_connect (entry, "focus-in-event",
G_CALLBACK (sokoke_on_entry_focus_in_event), NULL);
g_signal_connect (entry, "focus-out-event",
G_CALLBACK (sokoke_on_entry_focus_out_event), NULL);
}
else if (!gtk_widget_has_focus (GTK_WIDGET (entry)))
{
@ -1129,10 +1154,6 @@ sokoke_entry_set_default_text (GtkEntry* entry,
}
g_object_set_data (G_OBJECT (entry), "sokoke_default_text",
(gpointer)default_text);
g_signal_connect (entry, "focus-in-event",
G_CALLBACK (sokoke_on_entry_focus_in_event), NULL);
g_signal_connect (entry, "focus-out-event",
G_CALLBACK (sokoke_on_entry_focus_out_event), NULL);
}
gchar*

View file

@ -131,12 +131,13 @@ midori_bookmarks_export_array_db (sqlite3* db,
KatzeArray* root_array;
KatzeArray* subarray;
KatzeItem* item;
GList* list;
sqlcmd = g_strdup_printf ("SELECT * FROM bookmarks where folder='%s'", folder);
root_array = katze_array_from_sqlite (db, sqlcmd);
g_free (sqlcmd);
KATZE_ARRAY_FOREACH_ITEM (item, root_array)
KATZE_ARRAY_FOREACH_ITEM_L (item, root_array, list)
{
if (KATZE_ITEM_IS_FOLDER (item))
{
@ -148,6 +149,7 @@ midori_bookmarks_export_array_db (sqlite3* db,
else
katze_array_add_item (array, item);
}
g_list_free (list);
}
void
@ -155,14 +157,16 @@ midori_bookmarks_import_array_db (sqlite3* db,
KatzeArray* array,
const gchar* folder)
{
GList* list;
KatzeItem* item;
KATZE_ARRAY_FOREACH_ITEM (item, array)
KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
{
if (KATZE_IS_ARRAY (item))
midori_bookmarks_import_array_db (db, KATZE_ARRAY (item), folder);
midori_bookmarks_insert_item_db (db, item, folder);
}
g_list_free (list);
}
static KatzeArray*
@ -232,7 +236,7 @@ midori_bookmarks_read_from_db_to_model (MidoriBookmarks* bookmarks,
void
midori_bookmarks_insert_item_db (sqlite3* db,
KatzeItem* item,
const gchar* folder)
const gchar* folder)
{
gchar* sqlcmd;
char* errmsg = NULL;
@ -240,6 +244,9 @@ midori_bookmarks_insert_item_db (sqlite3* db,
gchar* parent;
gchar* uri;
/* Bookmarks must have a name, import may produce invalid items */
g_return_if_fail (katze_item_get_name (item));
if (KATZE_ITEM_IS_BOOKMARK (item))
uri = g_strdup (katze_item_get_uri (item));
else
@ -275,6 +282,24 @@ midori_bookmarks_insert_item_db (sqlite3* db,
sqlite3_free (sqlcmd);
}
static void
midori_bookmarks_add_item_cb (KatzeArray* array,
KatzeItem* item,
MidoriBookmarks* bookmarks)
{
GtkTreeModel* model;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
if (!g_strcmp0 (katze_item_get_meta_string (item, "folder"), ""))
gtk_tree_store_insert_with_values (GTK_TREE_STORE (model),
NULL, NULL, G_MAXINT, 0, item, -1);
else
{
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_remove_item_cb (KatzeArray* array,
KatzeItem* item,
@ -286,6 +311,17 @@ midori_bookmarks_remove_item_cb (KatzeArray* array,
GTK_TREE_STORE (model), NULL, NULL, bookmarks->filter);
}
static void
midori_bookmarks_update_cb (KatzeArray* array,
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,
@ -318,7 +354,8 @@ midori_bookmarks_row_changed_cb (GtkTreeModel* model,
parent_name = g_strdup ("");
katze_array_remove_item (bookmarks->array, item);
midori_bookmarks_insert_item_db (db, item, parent_name);
katze_item_set_meta_string (item, "folder", parent_name);
katze_array_add_item (bookmarks->array, item);
}
static void
@ -393,6 +430,7 @@ midori_bookmarks_get_toolbar (MidoriViewable* viewable)
toolbar = gtk_toolbar_new ();
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
bookmarks->toolbar = toolbar;
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_ADD);
gtk_widget_set_name (GTK_WIDGET (toolitem), "BookmarkAdd");
@ -468,11 +506,13 @@ midori_bookmarks_set_app (MidoriBookmarks* bookmarks,
g_object_ref (app);
bookmarks->array = katze_object_get_object (app, "bookmarks");
g_object_set_data (G_OBJECT (bookmarks->array), "treeview", bookmarks->treeview);
midori_bookmarks_read_from_db_to_model (bookmarks, GTK_TREE_STORE (model), NULL, "", NULL);
g_signal_connect (bookmarks->array, "add-item",
G_CALLBACK (midori_bookmarks_add_item_cb), bookmarks);
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 (bookmarks->array, "update",
G_CALLBACK (midori_bookmarks_update_cb), bookmarks);
g_signal_connect_after (model, "row-changed",
G_CALLBACK (midori_bookmarks_row_changed_cb),
bookmarks);
@ -777,23 +817,8 @@ midori_bookmarks_key_release_event_cb (GtkWidget* widget,
GdkEventKey* event,
MidoriBookmarks* bookmarks)
{
GtkTreeModel* model;
GtkTreeIter iter;
if (event->keyval != GDK_Delete)
return FALSE;
if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
{
KatzeItem* item;
KatzeArray* parent;
gtk_tree_model_get (model, &iter, 0, &item, -1);
parent = katze_item_get_parent (item);
katze_array_remove_item (parent, item);
g_object_unref (item);
}
if (event->keyval == GDK_Delete)
midori_bookmarks_delete_clicked_cb (widget, bookmarks);
return FALSE;
}
@ -923,6 +948,7 @@ midori_bookmarks_init (MidoriBookmarks* bookmarks)
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 ();
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
gtk_tree_view_column_set_cell_data_func (column, renderer_pixbuf,

View file

@ -357,6 +357,7 @@ midori_extensions_init (MidoriExtensions* extensions)
G_CALLBACK (midori_extensions_cell_renderer_toggled_cb), extensions);
gtk_tree_view_append_column (GTK_TREE_VIEW (extensions->treeview), column);
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
renderer_text = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column, renderer_text, FALSE);
gtk_tree_view_column_set_cell_data_func (column, renderer_text,

View file

@ -154,25 +154,6 @@ midori_history_format_date (KatzeItem *item)
return sdate;
}
static void
midori_history_clear_db (MidoriHistory* history)
{
gchar* sqlcmd;
sqlite3* db;
char* errmsg = NULL;
db = g_object_get_data (G_OBJECT (history->array), "db");
sqlcmd = sqlite3_mprintf ("DELETE FROM history");
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 void
midori_history_remove_item_from_db (MidoriHistory* history,
KatzeItem* item)
@ -231,11 +212,11 @@ midori_history_read_from_db (MidoriHistory* history,
gchar* filterstr;
sqlcmd = "SELECT * FROM ("
" SELECT uri, title, day FROM history"
" SELECT uri, title, day, date FROM history"
" WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri "
"UNION ALL "
" SELECT replace (uri, '%s', keywords) AS uri, "
" keywords AS title, day FROM search "
" keywords AS title, day, 0 AS date 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);
@ -327,7 +308,7 @@ midori_history_clear_clicked_cb (GtkWidget* toolitem,
if (result != GTK_RESPONSE_YES)
return;
midori_history_clear_db (history);
katze_array_clear (history->array);
}
static void
@ -453,6 +434,14 @@ midori_history_add_item_cb (KatzeArray* array,
0, 0, NULL, -1);
}
static void
midori_history_clear_cb (KatzeArray* array,
MidoriHistory* history)
{
GtkTreeView* treeview = GTK_TREE_VIEW (history->treeview);
GtkTreeModel* model = gtk_tree_view_get_model (treeview);
gtk_tree_store_clear (GTK_TREE_STORE (model));
}
static void
midori_history_set_app (MidoriHistory* history,
MidoriApp* app)
@ -463,12 +452,14 @@ midori_history_set_app (MidoriHistory* history,
{
g_signal_handlers_disconnect_by_func (history->array,
midori_history_add_item_cb, history);
g_signal_handlers_disconnect_by_func (history->array,
midori_history_clear_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));
}
katze_assign (history->app, app);
katze_object_assign (history->app, app);
if (!app)
return;
g_object_ref (app);
@ -476,6 +467,8 @@ midori_history_set_app (MidoriHistory* history,
history->array = katze_object_get_object (app, "history");
g_signal_connect (history->array, "add-item",
G_CALLBACK (midori_history_add_item_cb), history);
g_signal_connect (history->array, "clear",
G_CALLBACK (midori_history_clear_cb), history);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (history->treeview));
if (history->array)
midori_history_read_from_db_to_model (history, GTK_TREE_STORE (model), NULL, 0, NULL);
@ -948,6 +941,7 @@ midori_history_init (MidoriHistory* history)
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 ();
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
gtk_tree_view_column_set_cell_data_func (column, renderer_pixbuf,
@ -992,6 +986,8 @@ midori_history_finalize (GObject* object)
g_signal_handlers_disconnect_by_func (history->array,
midori_history_add_item_cb, history);
g_signal_handlers_disconnect_by_func (history->array,
midori_history_clear_cb, history);
g_object_unref (history->array);
katze_assign (history->filter, NULL);
}

View file

@ -547,6 +547,7 @@ midori_transfers_init (MidoriTransfers* transfers)
transfers->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (treestore));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (transfers->treeview), FALSE);
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
gtk_tree_view_column_set_cell_data_func (column, renderer_pixbuf,

2919
po/ar.po Normal file

File diff suppressed because it is too large Load diff

1683
po/ca.po

File diff suppressed because it is too large Load diff

1108
po/cs.po

File diff suppressed because it is too large Load diff

1222
po/de.po

File diff suppressed because it is too large Load diff

1541
po/el.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

1821
po/fi.po

File diff suppressed because it is too large Load diff

707
po/fr.po

File diff suppressed because it is too large Load diff

1465
po/gl.po

File diff suppressed because it is too large Load diff

1600
po/hr.po

File diff suppressed because it is too large Load diff

1658
po/hu.po

File diff suppressed because it is too large Load diff

1617
po/it.po

File diff suppressed because it is too large Load diff

1036
po/ja.po

File diff suppressed because it is too large Load diff

1493
po/ko.po

File diff suppressed because it is too large Load diff

1192
po/lt.po

File diff suppressed because it is too large Load diff

952
po/pl.po

File diff suppressed because it is too large Load diff

1338
po/pt.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

1363
po/ru.po

File diff suppressed because it is too large Load diff

1802
po/tr.po

File diff suppressed because it is too large Load diff

1206
po/uk.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,157 +0,0 @@
/*
Copyright (C) 2009 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.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include "midori.h"
#include "midori-bookmarks.h"
static void
bookmarks_panel_create (void)
{
MidoriApp* app;
MidoriBookmarks* bookmarks;
gpointer value;
app = g_object_new (MIDORI_TYPE_APP, NULL);
bookmarks = g_object_new (MIDORI_TYPE_BOOKMARKS, NULL);
value = katze_object_get_object (bookmarks, "app");
g_assert (value == NULL);
gtk_widget_destroy (GTK_WIDGET (bookmarks));
bookmarks = g_object_new (MIDORI_TYPE_BOOKMARKS, "app", app, NULL);
value = katze_object_get_object (bookmarks, "app");
g_assert (value == app);
gtk_widget_destroy (GTK_WIDGET (bookmarks));
bookmarks = g_object_new (MIDORI_TYPE_BOOKMARKS, NULL);
g_object_set (bookmarks, "app", app, NULL);
value = katze_object_get_object (bookmarks, "app");
g_assert (value == app);
gtk_widget_destroy (GTK_WIDGET (bookmarks));
}
static KatzeItem*
bookmark_new (const gchar* uri,
const gchar* title)
{
return g_object_new (KATZE_TYPE_ITEM, "uri", uri, "name", title, NULL);
}
static KatzeArray*
folder_new (const gchar* title)
{
KatzeArray* folder;
folder = katze_array_new (KATZE_TYPE_ARRAY);
g_object_set (folder, "name", title, NULL);
return folder;
}
static void
bookmarks_panel_fill (void)
{
MidoriApp* app;
KatzeArray* array;
MidoriBookmarks* bookmarks;
GList* children;
GtkWidget* treeview;
GtkTreeModel* model;
GtkTreeIter iter;
KatzeItem* bookmark;
KatzeArray* folder;
guint n;
gpointer value;
app = g_object_new (MIDORI_TYPE_APP, NULL);
array = katze_array_new (KATZE_TYPE_ARRAY);
g_object_set (app, "bookmarks", array, NULL);
value = katze_object_get_object (app, "bookmarks");
g_assert (value == array);
bookmarks = g_object_new (MIDORI_TYPE_BOOKMARKS, "app", app, NULL);
children = gtk_container_get_children (GTK_CONTAINER (bookmarks));
treeview = g_list_nth_data (children, 0);
g_list_free (children);
g_assert (GTK_IS_TREE_VIEW (treeview));
model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
g_assert (GTK_IS_TREE_MODEL (model));
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 0);
bookmark = bookmark_new ("http://www.example.com", "Example");
katze_array_add_item (array, bookmark);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 1);
katze_array_remove_item (array, bookmark);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 0);
bookmark = bookmark_new ("http://www.example.com", "Example");
katze_array_add_item (array, bookmark);
folder = folder_new ("Empty");
katze_array_add_item (array, folder);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 2);
katze_array_remove_item (array, folder);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 1);
folder = folder_new ("Empty");
katze_array_add_item (array, folder);
folder = folder_new ("Kurioses");
katze_array_add_item (array, folder);
bookmark = bookmark_new ("http://www.ende.de", "Das Ende");
katze_array_add_item (folder, bookmark);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 3);
folder = folder_new ("Miscellaneous");
katze_array_add_item (array, folder);
gtk_tree_model_iter_nth_child (model, &iter, NULL, 3);
n = gtk_tree_model_iter_n_children (model, &iter);
g_assert_cmpint (n, ==, 0);
bookmark = bookmark_new ("http://thesaurus.reference.com/", "Thesaurus");
katze_array_add_item (folder, bookmark);
n = gtk_tree_model_iter_n_children (model, &iter);
g_assert_cmpint (n, ==, 1);
bookmark = bookmark_new ("http://en.wikipedia.org/", "Wikipedia");
katze_array_add_item (folder, bookmark);
n = gtk_tree_model_iter_n_children (model, &iter);
g_assert_cmpint (n, ==, 2);
katze_array_remove_item (folder, bookmark);
n = gtk_tree_model_iter_n_children (model, &iter);
g_assert_cmpint (n, ==, 1);
katze_array_remove_item (array, folder);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 3);
katze_array_add_item (array, folder);
/* katze_array_clear (folder);
n = gtk_tree_model_iter_n_children (model, &iter);
g_assert_cmpint (n, ==, 0); */
katze_array_clear (array);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 0);
}
int
main (int argc,
char** argv)
{
/* libSoup uses threads, therefore if WebKit is built with libSoup
or Midori is using it, we need to initialize threads. */
if (!g_thread_supported ()) g_thread_init (NULL);
g_test_init (&argc, &argv, NULL);
gtk_init_check (&argc, &argv);
g_test_add_func ("/bookmarks/panel/create", bookmarks_panel_create);
g_test_add_func ("/bookmarks/panel/fill", bookmarks_panel_fill);
return g_test_run ();
}

View file

@ -39,7 +39,9 @@ browser_create (void)
if (g_strcmp0 (gtk_action_get_name (action), "WindowClose"))
if (g_strcmp0 (gtk_action_get_name (action), "EncodingCustom"))
if (g_strcmp0 (gtk_action_get_name (action), "AddSpeedDial"))
gtk_action_activate (action);
if (g_strcmp0 (gtk_action_get_name (action), "PrivateBrowsing"))
if (g_strcmp0 (gtk_action_get_name (action), "AddDesktopShortcut"))
gtk_action_activate (action);
actions = g_list_next (actions);
}
g_list_free (actions);

View file

@ -1,328 +0,0 @@
/*
Copyright (C) 2009 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.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include "midori.h"
/* This is a private function */
GtkWidget*
midori_location_action_entry_for_proxy (GtkWidget* proxy);
static const gchar* compare_urls[] = {
"http://en.wikipedia.org/wiki/Foul",
"http://de.wikipedia.org/wiki/Düsseldorf",
"http://de.wikipedia.org/wiki/Düsseldorf",
"http://ja.wikipedia.org/wiki/若井はんじ・けんじ",
"http://www.johannkönig.com",
"http://şøñđëřżēıċħęŋđőmæîņĭśŧşũþėŗ.de",
};
static void
completion_compare (void)
{
const guint runs = 10000;
guint t;
gdouble elapsed = 0.0;
for (t = 0; t < runs; t++)
{
g_test_timer_start ();
guint i, j;
for (i = 0; i < G_N_ELEMENTS (compare_urls); i++)
{
gchar* url = katze_collfold (compare_urls[i]);
for (j = 0; j < G_N_ELEMENTS (compare_urls); j++)
katze_utf8_stristr (compare_urls[i], url);
g_free (url);
}
elapsed += g_test_timer_elapsed ();
}
g_print ("%f seconds for comparison\n", elapsed / runs);
}
typedef struct
{
const gchar* uri;
const gchar* name;
} CompletionItem;
static const CompletionItem items[] = {
{ "http://one.com", "One" },
{ "http://one.com/", "One" }, /* Duplicate */
{ "http://one.com/", "One One" }, /* Duplicate */
{ "http://one.com", "One Two" }, /* Duplicate */
{ "http://two.com", "Two" },
{ "http://three.com", "Three" },
{ "http://one.com/one/", "One off" },
{ "http://four.org", "One" },
{ "https://four.org", "Four" },
{ "ftp://four.org/", "ごオルゴ" },
{ "http://muenchen.de/weißwürste/", "Münchner Weißwürste" }, /* Umlauts */
};
static const guint items_n = 9;
static void
completion_count (void)
{
MidoriLocationAction* action;
GtkWidget* toolitem;
GtkWidget* location_entry;
GtkWidget* entry;
GtkTreeModel* model;
guint n, i;
action = g_object_new (MIDORI_TYPE_LOCATION_ACTION, NULL);
toolitem = gtk_action_create_tool_item (GTK_ACTION (action));
location_entry = midori_location_action_entry_for_proxy (toolitem);
entry = gtk_bin_get_child (GTK_BIN (location_entry));
model = gtk_combo_box_get_model (GTK_COMBO_BOX (location_entry));
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 0);
midori_location_action_add_item (action, "http://one.com", NULL, "One");
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 1);
midori_location_action_clear (action);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 0);
for (i = 0; i < G_N_ELEMENTS (items); i++)
midori_location_action_add_item (action, items[i].uri,
NULL, items[i].name);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, items_n);
/* Adding the exact same items again shouldn't increase the total amount */
for (i = 0; i < G_N_ELEMENTS (items); i++)
midori_location_action_add_item (action, items[i].uri,
NULL, items[i].name);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, items_n);
}
/* Components to construct test addresses, the numbers take into account
how many items minus duplicates are unique. */
static const gchar* protocols[] = {
"http", "https", "ftp"
};
static const guint protocols_n = 3;
static const gchar* subs[] = {
"", "www.", "ww2.", "ftp."
};
static const guint subs_n = 4;
static const gchar* slds[] = {
"one", "two", "four", "six", "seven"/*, "Seven", "SEVEN"*/
};
static const guint slds_n = 5;
static const gchar* tlds[] = {
"com", "org", "net", "de", "co.uk", "com.au"/*, "Com.Au", "COM.AU"*/
};
static const guint tlds_n = 6;
static const gchar* files[] = {
"/", "/index.html", "/img.png", /*"/weißwürste",*/ "/images/"
/*, "/Images", "/IMAGES/"*/
};
static const guint files_n = 4;
static const gchar* inputs[] = {
"http://www.one.com/index", "http://two.de/images", "http://six.com.au/img"/*,
"http://muenchen.de/weißwürste/"*/
};
static const gchar* additions[] = {
"http://www.one.com/invention", "http://two.de/island", "http://six.com.au/ish"
};
static void location_action_fill (MidoriLocationAction* action)
{
guint i, j, k, l, m;
for (i = 0; i < G_N_ELEMENTS (protocols); i++)
for (j = 0; j < G_N_ELEMENTS (subs); j++)
for (k = 0; k < G_N_ELEMENTS (slds); k++)
for (l = 0; l < G_N_ELEMENTS (tlds); l++)
for (m = 0; m < G_N_ELEMENTS (files); m++)
{
gchar* uri = g_strdup_printf ("%s://%s%s.%s%s",
protocols[i], subs[j], slds[k], tlds[l], files[m]);
midori_location_action_add_item (action, uri, NULL, uri);
g_free (uri);
}
}
static void
completion_fill (void)
{
MidoriLocationAction* action;
GtkWidget* toolitem;
GtkWidget* location_entry;
GtkWidget* entry;
GtkTreeModel* model;
guint i, items_added, items_added_effective, n;
gdouble elapsed;
action = g_object_new (MIDORI_TYPE_LOCATION_ACTION, NULL);
toolitem = gtk_action_create_tool_item (GTK_ACTION (action));
location_entry = midori_location_action_entry_for_proxy (toolitem);
entry = gtk_bin_get_child (GTK_BIN (location_entry));
g_print ("...\n");
items_added = G_N_ELEMENTS (protocols) * G_N_ELEMENTS (subs)
* G_N_ELEMENTS (slds) * G_N_ELEMENTS (tlds) * G_N_ELEMENTS (files);
items_added_effective = protocols_n * subs_n * slds_n * tlds_n * files_n;
g_print ("Adding %d items, effectively %d items:\n",
items_added, items_added_effective);
/* Since adding items when the action is frozen is very fast,
we run it 5 times and take the average time. */
elapsed = 0.0;
for (i = 0; i < 5; i++)
{
midori_location_action_clear (action);
midori_location_action_freeze (action);
g_test_timer_start ();
location_action_fill (action);
elapsed += g_test_timer_elapsed ();
midori_location_action_thaw (action);
}
model = gtk_combo_box_get_model (GTK_COMBO_BOX (location_entry));
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, items_added_effective);
g_print ("%f seconds, the action is frozen\n", elapsed / 5.0);
midori_location_action_clear (action);
g_test_timer_start ();
location_action_fill (action);
elapsed = g_test_timer_elapsed ();
model = gtk_combo_box_get_model (GTK_COMBO_BOX (location_entry));
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, items_added_effective);
g_print ("%f seconds, the action updates normally\n", elapsed);
/* We don't clear the action intentionally in order to see
how long adding only duplicates takes. */
g_test_timer_start ();
location_action_fill (action);
elapsed = g_test_timer_elapsed ();
model = gtk_combo_box_get_model (GTK_COMBO_BOX (location_entry));
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, items_added_effective);
g_print ("%f seconds, adding exact duplicates\n", elapsed);
g_print ("...");
}
static guint matches = 0;
static guint matches_expected = 0;
static gboolean
entry_completion_insert_prefix_cb (GtkEntryCompletion* completion,
const gchar* prefix,
MidoriLocationAction* action)
{
GtkWidget* entry = gtk_entry_completion_get_entry (completion);
const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
if (!g_strrstr (prefix, text))
g_print ("Match failed, input: %s, result: %s\n",
text, prefix);
g_assert (g_strrstr (prefix, text));
midori_location_action_delete_item_from_uri (action, text);
midori_location_action_add_uri (action, text);
matches++;
return FALSE;
}
static void
completion_match (void)
{
MidoriLocationAction* action;
GtkWidget* toolitem;
GtkWidget* location_entry;
GtkWidget* entry;
GtkEntryCompletion* completion;
guint i;
action = g_object_new (MIDORI_TYPE_LOCATION_ACTION, NULL);
midori_location_action_freeze (action);
location_action_fill (action);
midori_location_action_thaw (action);
toolitem = gtk_action_create_tool_item (GTK_ACTION (action));
location_entry = midori_location_action_entry_for_proxy (toolitem);
entry = gtk_bin_get_child (GTK_BIN (location_entry));
completion = gtk_entry_get_completion (GTK_ENTRY (entry));
g_signal_connect (completion, "insert-prefix",
G_CALLBACK (entry_completion_insert_prefix_cb), action);
gtk_entry_completion_set_inline_completion (completion, TRUE);
gtk_entry_completion_set_popup_single_match (completion, FALSE);
for (i = 0; i < G_N_ELEMENTS (inputs); i++)
{
matches_expected++;
gtk_entry_set_text (GTK_ENTRY (entry), inputs[i]);
gtk_entry_completion_complete (completion);
gtk_entry_completion_insert_prefix (completion);
if (matches != matches_expected)
g_print ("Match failed, input: %s, result: %s\n",
inputs[i], gtk_entry_get_text (GTK_ENTRY (entry)));
g_assert_cmpint (matches, ==, matches_expected);
}
for (i = 0; i < G_N_ELEMENTS (additions); i++)
{
midori_location_action_add_uri (action, additions[i]);
midori_location_action_delete_item_from_uri (action, additions[i]);
midori_location_action_add_uri (action, additions[i]);
}
for (i = 0; i < G_N_ELEMENTS (inputs); i++)
{
matches_expected++;
gtk_entry_set_text (GTK_ENTRY (entry), inputs[i]);
gtk_entry_completion_complete (completion);
gtk_entry_completion_insert_prefix (completion);
if (matches != matches_expected)
g_print ("Match failed, input: %s, result: %s\n",
inputs[i], gtk_entry_get_text (GTK_ENTRY (entry)));
g_assert_cmpint (matches, ==, matches_expected);
}
for (i = 0; i < G_N_ELEMENTS (additions); i++)
{
matches_expected++;
gtk_entry_set_text (GTK_ENTRY (entry), additions[i]);
gtk_entry_completion_complete (completion);
gtk_entry_completion_insert_prefix (completion);
if (matches != matches_expected)
g_print ("Match failed, input: %s, result: %s\n",
additions[i], gtk_entry_get_text (GTK_ENTRY (entry)));
g_assert_cmpint (matches, ==, matches_expected);
}
}
int
main (int argc,
char** argv)
{
/* libSoup uses threads, so we need to initialize threads. */
if (!g_thread_supported ()) g_thread_init (NULL);
g_test_init (&argc, &argv, NULL);
gtk_init_check (&argc, &argv);
g_test_add_func ("/completion/compare", completion_compare);
g_test_add_func ("/completion/count", completion_count);
g_test_add_func ("/completion/fill", completion_fill);
g_test_add_func ("/completion/match", completion_match);
return g_test_run ();
}

View file

@ -172,8 +172,8 @@ extension_activate (gconstpointer data)
{
MidoriApp* app = midori_app_new ();
MidoriExtension* extension = MIDORI_EXTENSION (data);
/* g_signal_emit_by_name (extension, "activate", app);
midori_extension_deactivate (extension); */
g_signal_emit_by_name (extension, "activate", app);
midori_extension_deactivate (extension);
g_object_unref (app);
}
@ -237,6 +237,8 @@ main (int argc,
g_test_init (&argc, &argv, NULL);
gtk_init_check (&argc, &argv);
if (!g_thread_supported ()) g_thread_init (NULL);
soup_session_add_feature_by_type (webkit_get_default_session (),
SOUP_TYPE_COOKIE_JAR);
g_test_add_func ("/extensions/create", extension_create);
g_test_add_func ("/extensions/settings", extension_settings);

View file

@ -1,221 +0,0 @@
/*
Copyright (C) 2009 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.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include "midori.h"
#include "midori-history.h"
#include "sokoke.h"
static void
history_panel_create (void)
{
MidoriApp* app;
MidoriHistory* history;
gpointer value;
app = g_object_new (MIDORI_TYPE_APP, NULL);
history = g_object_new (MIDORI_TYPE_HISTORY, NULL);
value = katze_object_get_object (history, "app");
g_assert (value == NULL);
gtk_widget_destroy (GTK_WIDGET (history));
history = g_object_new (MIDORI_TYPE_HISTORY, "app", app, NULL);
value = katze_object_get_object (history, "app");
g_assert (value == app);
gtk_widget_destroy (GTK_WIDGET (history));
history = g_object_new (MIDORI_TYPE_HISTORY, NULL);
g_object_set (history, "app", app, NULL);
value = katze_object_get_object (history, "app");
g_assert (value == app);
gtk_widget_destroy (GTK_WIDGET (history));
}
static KatzeItem*
bookmark_new (const gchar* uri,
const gchar* title)
{
return g_object_new (KATZE_TYPE_ITEM, "uri", uri, "name", title, NULL);
}
static KatzeArray*
folder_new (const gchar* title)
{
KatzeArray* folder;
folder = katze_array_new (KATZE_TYPE_ARRAY);
g_object_set (folder, "name", title, NULL);
return folder;
}
static void
history_panel_fill (void)
{
MidoriApp* app;
KatzeArray* array;
MidoriHistory* history;
GList* children;
GtkWidget* treeview;
GtkTreeModel* model;
GtkTreeIter iter;
KatzeItem* bookmark;
KatzeArray* folder;
guint n;
gpointer value;
app = g_object_new (MIDORI_TYPE_APP, NULL);
array = katze_array_new (KATZE_TYPE_ARRAY);
g_object_set (app, "history", array, NULL);
value = katze_object_get_object (app, "history");
g_assert (value == array);
history = g_object_new (MIDORI_TYPE_HISTORY, "app", app, NULL);
children = gtk_container_get_children (GTK_CONTAINER (history));
treeview = g_list_nth_data (children, 1);
g_list_free (children);
g_assert (GTK_IS_TREE_VIEW (treeview));
model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
g_assert (GTK_IS_TREE_MODEL (model));
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 0);
bookmark = bookmark_new ("http://www.example.com", "Example");
katze_array_add_item (array, bookmark);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 1);
katze_array_remove_item (array, bookmark);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 0);
bookmark = bookmark_new ("http://www.example.com", "Example");
katze_array_add_item (array, bookmark);
folder = folder_new ("Empty");
katze_array_add_item (array, folder);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 2);
katze_array_remove_item (array, folder);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 1);
folder = folder_new ("Empty");
katze_array_add_item (array, folder);
folder = folder_new ("Kurioses");
katze_array_add_item (array, folder);
bookmark = bookmark_new ("http://www.ende.de", "Das Ende");
katze_array_add_item (folder, bookmark);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 3);
folder = folder_new ("Miscellaneous");
katze_array_add_item (array, folder);
gtk_tree_model_iter_nth_child (model, &iter, NULL, 3);
n = gtk_tree_model_iter_n_children (model, &iter);
g_assert_cmpint (n, ==, 0);
bookmark = bookmark_new ("http://thesaurus.reference.com/", "Thesaurus");
katze_array_add_item (folder, bookmark);
n = gtk_tree_model_iter_n_children (model, &iter);
g_assert_cmpint (n, ==, 1);
bookmark = bookmark_new ("http://en.wikipedia.org/", "Wikipedia");
katze_array_add_item (folder, bookmark);
n = gtk_tree_model_iter_n_children (model, &iter);
g_assert_cmpint (n, ==, 2);
katze_array_remove_item (folder, bookmark);
n = gtk_tree_model_iter_n_children (model, &iter);
g_assert_cmpint (n, ==, 1);
katze_array_remove_item (array, folder);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 3);
katze_array_add_item (array, folder);
/* katze_array_clear (folder);
n = gtk_tree_model_iter_n_children (model, &iter);
g_assert_cmpint (n, ==, 0); */
katze_array_clear (array);
n = gtk_tree_model_iter_n_children (model, NULL);
g_assert_cmpint (n, ==, 0);
}
static void
notify_load_status_cb (GtkWidget* view,
GParamSpec* pspec,
guint* done)
{
MidoriLoadStatus status;
status = midori_view_get_load_status (MIDORI_VIEW (view));
if (*done == 2 && status == MIDORI_LOAD_COMMITTED)
*done = 1;
else if (*done == 1 && status == MIDORI_LOAD_FINISHED)
*done = 0;
}
static void
history_browser_add (void)
{
MidoriBrowser* browser;
MidoriWebSettings* settings;
KatzeArray* array;
GtkWidget* view;
guint done;
KatzeItem* date;
gsize i;
GtkActionGroup* action_group;
GtkAction* action;
browser = midori_browser_new ();
settings = midori_web_settings_new ();
array = katze_array_new (KATZE_TYPE_ARRAY);
g_object_set (browser, "settings", settings, "history", array, NULL);
view = midori_view_new (NULL);
midori_browser_add_tab (browser, view);
midori_view_set_uri (MIDORI_VIEW (view),
"data:text/html;charset=utf-8,<title>Test</title>Test");
g_signal_connect (view, "notify::load-status",
G_CALLBACK (notify_load_status_cb), &done);
done = 2;
while (done)
gtk_main_iteration ();
g_assert_cmpint (katze_array_get_length (array), ==, 1);
date = katze_array_get_nth_item (array, 0);
g_assert_cmpint (katze_array_get_length (KATZE_ARRAY (date)), ==, 1);
i = 0;
gtk_widget_show (view);
midori_browser_set_current_tab (browser, view);
g_assert (midori_browser_get_current_tab (browser) == view);
done = 2;
action_group = midori_browser_get_action_group (browser);
action = gtk_action_group_get_action (action_group, "Location");
midori_location_action_set_uri (MIDORI_LOCATION_ACTION (action),
"data:text/html;charset=utf-8,<title>Test</title>Test");
g_signal_emit_by_name (action, "submit-uri",
"data:text/html;charset=utf-8,<title>Test</title>Test", FALSE);
while (done)
gtk_main_iteration ();
g_assert_cmpint (katze_array_get_length (array), ==, 1);
date = katze_array_get_nth_item (array, 0);
g_assert_cmpint (katze_array_get_length (KATZE_ARRAY (date)), ==, 1);
i = 0;
}
int
main (int argc,
char** argv)
{
/* libSoup uses threads, so we need to initialize threads. */
if (!g_thread_supported ()) g_thread_init (NULL);
g_test_init (&argc, &argv, NULL);
gtk_init_check (&argc, &argv);
sokoke_register_stock_items ();
g_test_add_func ("/history/panel/create", history_panel_create);
g_test_add_func ("/history/panel/fill", history_panel_fill);
g_test_add_func ("/history/browser/add", history_browser_add);
return g_test_run ();
}

View file

@ -161,8 +161,8 @@ static void
magic_uri_search (void)
{
test_input ("sm midori", SM "midori");
test_input ("sm cats dogs", SM "cats dogs");
test_input ("se cats dogs", SM "cats dogs");
test_input ("sm cats dogs", SM "cats%20dogs");
test_input ("se cats dogs", SM "cats%20dogs");
test_input ("dict midori", NULL);
test_input ("cats", NULL);
test_input ("cats dogs", NULL);
@ -185,9 +185,9 @@ magic_uri_search (void)
test_input ("de.po verbose", NULL);
test_input ("verbose de.po", NULL);
test_input ("g de.po verbose", NULL);
test_input ("sm de.po verbose", SM "de.po verbose");
test_input ("sm de.po verbose", SM "de.po%20verbose");
test_input ("sm warning: configure /dev/net: virtual",
SM "warning: configure /dev/net: virtual");
SM "warning:%20configure%20/dev/net:%20virtual");
test_input ("g \"ISO 9001:2000 certified\"", NULL);
test_input ("g conference \"April 2, 7:00 am\"", NULL);
test_input ("max@mustermann.de", NULL);

View file

@ -133,11 +133,14 @@ properties_object_get_set (GObject* object)
G_PARAM_SPEC_ENUM (pspec)->default_value, NULL);
for (k = enum_class->minimum; k < enum_class->maximum; k++)
{
GEnumValue* enum_value = g_enum_get_value (enum_class, k);
GEnumValue* enum_value;
GEnumValue* enum_value_;
enum_value = g_enum_get_value (enum_class, k);
if (!enum_value)
g_error ("%s.%s has no value %d",
G_OBJECT_TYPE_NAME (object), property, k);
GEnumValue* enum_value_ = g_enum_get_value_by_name (enum_class,
enum_value_ = g_enum_get_value_by_name (enum_class,
enum_value->value_name);
if (!enum_value)
g_error ("%s.%s has no value '%s'",

View file

@ -97,22 +97,29 @@ midori_findbar_case_sensitive (MidoriFindbar* findbar)
}
void
midori_findbar_find (MidoriFindbar* findbar,
gboolean forward)
midori_findbar_find_text (MidoriFindbar* findbar,
const gchar* text,
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 = midori_findbar_case_sensitive (findbar);
midori_view_search_text (MIDORI_VIEW (view), text, case_sensitive, forward);
}
void
midori_findbar_find (MidoriFindbar* findbar,
gboolean forward)
{
const gchar* text = gtk_entry_get_text (GTK_ENTRY (findbar->find_text));
midori_findbar_find_text (findbar, text, forward);
}
void
midori_findbar_invoke (MidoriFindbar* findbar)
{
@ -161,20 +168,28 @@ midori_findbar_button_close_clicked_cb (GtkWidget* widget,
}
static void
midori_findbar_text_changed_cb (GtkWidget* entry,
MidoriFindbar* findbar)
midori_findbar_preedit_changed_cb (GtkWidget* entry,
const gchar* preedit,
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) > 1)
midori_findbar_find (findbar, TRUE);
if (g_utf8_strlen (preedit, -1) > 1)
midori_findbar_find_text (findbar, preedit, TRUE);
}
}
static void
midori_findbar_text_changed_cb (GtkWidget* entry,
MidoriFindbar* findbar)
{
const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
midori_findbar_preedit_changed_cb (entry, text, findbar);
}
static gboolean
midori_findbar_text_focus_out_event_cb (GtkWidget* entry,
GdkEventFocus* event,
@ -227,6 +242,8 @@ midori_findbar_init (MidoriFindbar* findbar)
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, "preedit-changed",
G_CALLBACK (midori_findbar_preedit_changed_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",

View file

@ -42,6 +42,11 @@ void
midori_findbar_find (MidoriFindbar* findbar,
gboolean forward);
void
midori_findbar_find_text (MidoriFindbar* findbar,
const gchar* text,
gboolean forward);
void
midori_findbar_set_can_find (MidoriFindbar* findbar,
gboolean can_find);

View file

@ -28,8 +28,8 @@ import misc
from Configure import find_program_impl
major = 0
minor = 2
micro = 9
minor = 3
micro = 0
APPNAME = 'midori'
VERSION = str (major) + '.' + str (minor) + '.' + str (micro)
@ -161,6 +161,7 @@ def configure (conf):
dirname_default ('DOCDIR', os.path.join (conf.env['MDATADIR'], 'doc'))
if not APPNAME in conf.env['DOCDIR']:
conf.env['DOCDIR'] += '/' + APPNAME
conf.define ('DOCDIR', conf.env['DOCDIR'])
if option_enabled ('apidocs'):
conf.find_program ('gtkdoc-scan', var='GTKDOC_SCAN')
@ -276,7 +277,7 @@ def configure (conf):
conf.define ('PACKAGE_VERSION', VERSION)
conf.define ('PACKAGE_NAME', APPNAME)
conf.define ('PACKAGE_BUGREPORT', 'http://www.twotoasts.de/bugs')
conf.define ('PACKAGE_BUGREPORT', 'https://bugs.launchpad.net/midori')
conf.define ('GETTEXT_PACKAGE', APPNAME)
conf.define ('MIDORI_MAJOR_VERSION', major)
@ -417,7 +418,7 @@ def build (bld):
bld.add_group ()
if bld.env['docs']:
bld.install_files ('${DOCDIR}/' + '/', \
bld.install_files ('${DOCDIR}/', \
'AUTHORS COPYING ChangeLog EXPAT README')
# Install default configuration