Imported Upstream version 0.1.10

This commit is contained in:
Ryan Niebur 2009-09-15 21:59:15 -07:00
parent ec64b98001
commit 3aa165bda2
42 changed files with 16035 additions and 6998 deletions

View file

@ -55,6 +55,7 @@ Translations:
pl: Przemysław Sitek <el.pescado@gazeta.pl>
pl: Lukasz Romanowicz <romanowicz88@gmail.com>
pt_PT: Sérgio Marques <smarquespt@gmail.com>
pt_BR: Rogério Brito <rbrito@ime.usp.br>
ro: Igor Știrbu <igor.stirbu@gmail.com>
ro: Mișu Moldovan <dumol@gnome.ro>
ru: Troitskiy Nikita <niktr@mail.ru>

View file

@ -1,5 +1,23 @@
This file is licensed under the terms of the expat license, see the file EXPAT.
v0.1.10:
+ Fix freezing when opening multiple windows
+ Revamp Adblock with WebKitGTK+ 1.1.14 API
+ Greatly improve the address completion
+ Always show news feed icon
+ Better handling of feeds in the feed panel
+ Add Gtk+ and WebKit version to the About dialog
+ Improve tab panel and support minimized tabs
+ Implement disabling of extensions in crahs dialog
+ Don't make the web inspector transient
+ Tidy up the Preferences a bit
+ Load default bookmarks and config from /etc
+ Do not use xprop at runtime
+ Use GNOME proxy server if libsoup-gnome is installed
+ Integrate Save As with transfers
+ Save HTTP logins in a text file
+ Support Undo and Redo with WebKitGTK+ 1.1.14
v0.1.9:
+ Preserve navigation history with new tabs
+ Implement clearing private data when quitting

View file

@ -9,7 +9,7 @@ token=g
[Wikipedia]
name=Wikipedia
text=The free encyclopedia
uri=http://en.wikipedia.org/wiki/%s
uri=http://en.wikipedia.org/wiki/Special:Search/%s
icon=
token=wp

View file

@ -20,11 +20,19 @@
#include <unistd.h>
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 14)
static GHashTable* pattern = NULL;
static gchar *
adblock_fixup_regexp (gchar* src)
{
gchar* dst;
gchar* s;
if (!(src && *src))
return g_strdup ("");
/* FIXME: Avoid always allocating twice the string */
s = dst = g_malloc (strlen (src) * 2);
@ -308,19 +316,8 @@ adblock_browser_populate_tool_menu_cb (MidoriBrowser* browser,
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
}
static void
adblock_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser,
MidoriExtension* extension)
{
g_signal_connect (browser, "populate-tool-menu",
G_CALLBACK (adblock_browser_populate_tool_menu_cb), extension);
g_signal_connect (extension, "deactivate",
G_CALLBACK (adblock_deactivate_cb), browser);
}
static gboolean
adblock_is_matched (const gchar* pattern,
adblock_is_matched (const gchar* patt,
const GRegex* regex,
const gchar* uri)
{
@ -328,19 +325,43 @@ adblock_is_matched (const gchar* pattern,
}
static void
adblock_session_request_queued_cb (SoupSession* session,
SoupMessage* msg,
GHashTable* pattern)
adblock_resource_request_starting_cb (WebKitWebView* web_view,
WebKitWebFrame* web_frame,
WebKitWebResource* web_resource,
WebKitNetworkRequest* request,
WebKitNetworkResponse* response,
MidoriView* view)
{
SoupURI* soup_uri = soup_message_get_uri (msg);
gchar* uri = soup_uri ? soup_uri_to_string (soup_uri, FALSE) : g_strdup ("");
if (g_hash_table_find (pattern, (GHRFunc) adblock_is_matched, uri))
const gchar* uri = webkit_network_request_get_uri (request);
if (g_hash_table_find (pattern, (GHRFunc) adblock_is_matched, (char*)uri))
{
/* g_debug ("match! '%s'", uri); */
/* FIXME: This leads to funny error pages if frames are blocked */
soup_message_set_response (msg, "text/plain", SOUP_MEMORY_STATIC, "adblock", 7);
webkit_network_request_set_uri (request, "about:blank");
/* TODO: Need to figure out how to indicate what was blocked */
}
g_free (uri);
}
static void
adblock_add_tab_cb (MidoriBrowser* browser,
MidoriView* view)
{
GtkWidget* web_view = gtk_bin_get_child (GTK_BIN (view));
g_signal_connect (web_view, "resource-request-starting",
G_CALLBACK (adblock_resource_request_starting_cb), view);
}
static void
adblock_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser,
MidoriExtension* extension)
{
if (pattern)
g_signal_connect (browser, "add-tab",
G_CALLBACK (adblock_add_tab_cb), 0);
g_signal_connect (browser, "populate-tool-menu",
G_CALLBACK (adblock_browser_populate_tool_menu_cb), extension);
g_signal_connect (extension, "deactivate",
G_CALLBACK (adblock_deactivate_cb), browser);
}
static gchar*
@ -373,7 +394,7 @@ adblock_parse_file (gchar* path)
if ((file = g_fopen (path, "r")))
{
GHashTable* pattern = g_hash_table_new_full (g_str_hash, g_str_equal,
GHashTable* patt = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free,
(GDestroyNotify)g_regex_unref);
@ -387,6 +408,9 @@ adblock_parse_file (gchar* path)
gchar* parsed;
parsed = adblock_parse_line (line);
if (!parsed)
continue;
regex = g_regex_new (parsed, G_REGEX_OPTIMIZE,
G_REGEX_MATCH_NOTEMPTY, &error);
if (error)
@ -398,34 +422,27 @@ adblock_parse_file (gchar* path)
else
{
have_pattern = TRUE;
g_hash_table_insert (pattern, parsed, regex);
g_hash_table_insert (patt, parsed, regex);
}
}
fclose (file);
if (have_pattern)
return pattern;
return patt;
}
/* FIXME: This should presumably be freed, but there's a possible crash
g_free (path); */
return NULL;
}
#if WEBKIT_CHECK_VERSION (1, 1, 3)
static void
adblock_download_notify_status_cb (WebKitDownload* download,
GParamSpec* pspec,
gchar* path)
{
SoupSession* session = webkit_get_default_session ();
GHashTable* pattern = adblock_parse_file (path);
if (pattern)
g_signal_connect_data (session, "request-queued",
G_CALLBACK (adblock_session_request_queued_cb),
pattern, (GClosureNotify)g_hash_table_destroy, 0);
pattern = adblock_parse_file (path);
/* g_object_unref (download); */
}
#endif
static void
adblock_activate_cb (MidoriExtension* extension,
@ -461,7 +478,6 @@ adblock_activate_cb (MidoriExtension* extension,
gchar* path = g_build_filename (folder, filename, NULL);
if (!g_file_test (path, G_FILE_TEST_EXISTS))
{
#if WEBKIT_CHECK_VERSION (1, 1, 3)
WebKitNetworkRequest* request;
WebKitDownload* download;
gchar* destination = g_filename_to_uri (path, NULL, NULL);
@ -474,18 +490,9 @@ adblock_activate_cb (MidoriExtension* extension,
g_signal_connect (download, "notify::status",
G_CALLBACK (adblock_download_notify_status_cb), path);
webkit_download_start (download);
#else
/* FIXME: Is it worth to rewrite this without WebKitDownload? */
#endif
}
else
{
GHashTable* pattern = adblock_parse_file (path);
if (pattern)
g_signal_connect_data (session, "request-queued",
G_CALLBACK (adblock_session_request_queued_cb),
pattern, (GClosureNotify)g_hash_table_destroy, 0);
}
pattern = adblock_parse_file (path);
g_free (filename);
}
}
@ -517,7 +524,6 @@ test_adblock_pattern (void)
{
gint temp;
gchar* filename;
GHashTable* pattern;
temp = g_file_open_tmp ("midori_adblock_match_test_XXXXXX", &filename, NULL);
@ -555,19 +561,25 @@ extension_test (void)
}
#endif
#endif
MidoriExtension*
extension_init (void)
{
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", _("Advertisement blocker"),
"description", _("Block advertisements according to a filter list"),
#if WEBKIT_CHECK_VERSION (1, 1, 14)
"version", "0.1",
#endif
"authors", "Christian Dywan <christian@twotoasts.de>",
NULL);
#if WEBKIT_CHECK_VERSION (1, 1, 14)
midori_extension_install_string_list (extension, "filters", NULL, G_MAXSIZE);
g_signal_connect (extension, "activate",
G_CALLBACK (adblock_activate_cb), NULL);
#endif
return extension;
}

View file

@ -11,12 +11,6 @@
#include "feed-atom.h"
#define atom_get_link_attribute(item, attribute) \
(gchar*)g_object_get_data (G_OBJECT (item), attribute)
#define atom_set_link_attribute(item, attribute, value) \
g_object_set_data (G_OBJECT (item), attribute, value)
static gboolean
atom_is_valid (FeedParser* fparser)
{
@ -102,8 +96,8 @@ atom_get_link (KatzeItem* item,
gboolean newlink;
newlink = FALSE;
oldtype = atom_get_link_attribute (item, "linktype");
oldrel = atom_get_link_attribute (item, "linkrel");
oldtype = (gchar*)katze_item_get_meta_string (item, "feedpanel:linktype");
oldrel = (gchar*)katze_item_get_meta_string (item, "feedpanel:linkrel");
newtype = (gchar*)xmlGetProp (node, BAD_CAST "type");
newrel = (gchar*)xmlGetProp (node, BAD_CAST "rel");
@ -127,21 +121,21 @@ atom_get_link (KatzeItem* item,
if (newlink)
{
katze_item_set_uri (item, href);
atom_set_link_attribute (item, "linkrel", newrel);
atom_set_link_attribute (item, "linktype", newrel);
katze_item_set_meta_string (item, "feedpanel:linkrel", newrel);
katze_item_set_meta_string (item, "feedpanel:linktype", newtype);
}
else
{
xmlFree (href);
xmlFree (newrel);
xmlFree (newtype);
}
}
static gchar*
atom_get_title (FeedParser* fparser)
{
if (!katze_item_get_name (fparser->item))
const gchar* name;
if (!(name = katze_item_get_name (fparser->item)))
{
gchar* type;
@ -159,9 +153,10 @@ atom_get_title (FeedParser* fparser)
if (content)
return content;
}
}
return feed_get_element_string (fparser);
}
return g_strdup (name);
}
static void
atom_preparse_entry (FeedParser* fparser)
@ -245,8 +240,8 @@ atom_postparse_entry (FeedParser* fparser)
if (KATZE_IS_ITEM (fparser->item))
{
atom_set_link_attribute (fparser->item, "linkrel", NULL);
atom_set_link_attribute (fparser->item, "linktype", NULL);
katze_item_set_meta_string (fparser->item, "feedpanel:linkrel", NULL);
katze_item_set_meta_string (fparser->item, "feedpanel:linktype", NULL);
if (*fparser->error)
{
@ -330,8 +325,8 @@ atom_postparse_feed (FeedParser* fparser)
{
if (KATZE_IS_ARRAY (fparser->item))
{
atom_set_link_attribute (fparser->item, "linkrel", NULL);
atom_set_link_attribute (fparser->item, "linktype", NULL);
katze_item_set_meta_string (fparser->item, "feedpanel:linkrel", NULL);
katze_item_set_meta_string (fparser->item, "feedpanel:linktype", NULL);
}
if (!*fparser->error)

View file

@ -29,7 +29,6 @@ feed_get_element_string (FeedParser* fparser)
*/
return g_strdup (" ");
}
return (gchar*)xmlNodeListGetString (fparser->doc, node->children, 1);
}
@ -74,6 +73,14 @@ gchar*
feed_get_element_markup (FeedParser* fparser)
{
gchar* markup;
xmlNodePtr node = fparser->node;
if (node->children &&
!xmlIsBlankNode (node->children) &&
node->children->type == XML_ELEMENT_NODE)
{
return (gchar*) xmlNodeGetContent (node->children);
}
markup = feed_get_element_string (fparser);
return feed_remove_markup (markup);

View file

@ -58,7 +58,7 @@ typedef struct
enum
{
FEED_READ,
FEED_READ = 1,
FEED_REMOVE
};
@ -67,6 +67,11 @@ feed_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser,
MidoriExtension* extension);
static gboolean
secondary_icon_released_cb (GtkAction* action,
GtkWidget* widget,
FeedPrivate* priv);
static void
feed_deactivate_cb (MidoriExtension* extension,
FeedPrivate* priv)
@ -74,6 +79,13 @@ feed_deactivate_cb (MidoriExtension* extension,
if (priv)
{
MidoriApp* app = midori_extension_get_app (extension);
GtkActionGroup* action_group;
GtkAction* action;
action_group = midori_browser_get_action_group (priv->browser);
action = gtk_action_group_get_action (action_group, "Location");
g_signal_handlers_disconnect_by_func (action,
secondary_icon_released_cb, priv);
g_signal_handlers_disconnect_by_func (app,
feed_app_add_browser_cb, extension);
@ -241,7 +253,10 @@ feed_transfer_cb (KatzeNetRequest* request,
feed_save_items (netpriv->extension, parent);
}
else
feed_set_flags (netpriv->feed, 0);
{
feed_remove_flags (netpriv->feed, FEED_REMOVE);
feed_remove_flags (netpriv->feed, FEED_READ);
}
}
netpriv->parsers = NULL;
@ -293,30 +308,40 @@ update_feeds (FeedPrivate* priv)
return TRUE;
}
static void
static gboolean
secondary_icon_released_cb (GtkAction* action,
GtkWidget* widget,
FeedPrivate* priv)
{
const gchar* uri;
GtkWidget* view;
g_assert (KATZE_IS_ARRAY (priv->feeds));
uri = midori_location_action_get_uri (MIDORI_LOCATION_ACTION (action));
if (gtk_window_get_focus (GTK_WINDOW (priv->browser)) == widget)
return FALSE;
if ((view = midori_browser_get_current_tab (priv->browser)))
{
const gchar* uri;
uri = g_object_get_data (G_OBJECT (view), "news-feeds");
if (uri && *uri)
{
KatzeArray* feed;
feed = feed_add_item (priv->feeds, uri);
if (feed)
if ((feed = feed_add_item (priv->feeds, uri)))
{
/* FIXME: Let the user know that a feed was added */
feed_save_items (priv->extension, priv->feeds);
update_feed (priv, KATZE_ITEM (feed));
return TRUE;
}
}
}
return FALSE;
}
static void
panel_add_feed_cb (FeedPanel* panel,
FeedPrivate* priv)

View file

@ -24,6 +24,49 @@ tab_panel_settings_notify_cb (MidoriWebSettings* settings,
GParamSpec* pspec,
GtkTreeModel* model);
static void
tab_panel_browser_add_tab_cb (MidoriBrowser* browser,
GtkWidget* view,
MidoriExtension* extension);
static void
tab_panel_browser_remove_tab_cb (MidoriBrowser* browser,
GtkWidget* view,
MidoriExtension* extension);
static void
tab_panel_view_notify_minimized_cb (GtkWidget* view,
GParamSpec* pspec,
MidoriExtension* extension);
static void
tab_panel_view_notify_icon_cb (GtkWidget* view,
GParamSpec* pspec,
MidoriExtension* extension);
static void
tab_panel_view_notify_title_cb (GtkWidget* view,
GParamSpec* pspec,
MidoriExtension* extension);
static GtkTreeModel*
tab_panel_get_model_for_browser (MidoriBrowser* browser)
{
return g_object_get_data (G_OBJECT (browser), "tab-panel-ext-model");
}
static GtkWidget*
tab_panel_get_toolbar_for_browser (MidoriBrowser* browser)
{
return g_object_get_data (G_OBJECT (browser), "tab-panel-ext-toolbar");
}
static GtkToolItem*
tab_panel_get_toolitem_for_view (GtkWidget* view)
{
return g_object_get_data (G_OBJECT (view), "tab-panel-ext-toolitem");
}
static void
tab_panel_deactivate_cb (MidoriExtension* extension,
GtkWidget* panel)
@ -32,18 +75,28 @@ tab_panel_deactivate_cb (MidoriExtension* extension,
GtkTreeModel* model;
MidoriBrowser* browser;
model = g_object_get_data (G_OBJECT (extension), "treemodel");
g_object_unref (model);
browser = midori_browser_get_for_widget (panel);
g_object_set (browser, "show-tabs", TRUE, NULL);
model = tab_panel_get_model_for_browser (browser);
g_object_unref (model);
gtk_widget_destroy (panel);
g_signal_handlers_disconnect_by_func (
extension, tab_panel_deactivate_cb, panel);
g_signal_handlers_disconnect_by_func (
app, tab_panel_app_add_browser_cb, extension);
g_signal_handlers_disconnect_by_func (
browser, tab_panel_browser_add_tab_cb, extension);
g_signal_handlers_disconnect_by_func (
browser, tab_panel_browser_remove_tab_cb, extension);
g_signal_handlers_disconnect_by_func (
browser, tab_panel_settings_notify_cb, model);
g_signal_handlers_disconnect_by_func (
browser, tab_panel_view_notify_minimized_cb, extension);
g_signal_handlers_disconnect_by_func (
browser, tab_panel_view_notify_icon_cb, extension);
g_signal_handlers_disconnect_by_func (
browser, tab_panel_view_notify_title_cb, extension);
}
static void
@ -83,41 +136,6 @@ tab_panel_treeview_query_tooltip_cb (GtkWidget* treeview,
}
#endif
static void
midori_extension_treeview_render_icon_cb (GtkTreeViewColumn* column,
GtkCellRenderer* renderer,
GtkTreeModel* model,
GtkTreeIter* iter,
GtkWidget* treeview)
{
MidoriView* view;
GdkPixbuf* pixbuf;
gtk_tree_model_get (model, iter, 0, &view, -1);
if ((pixbuf = midori_view_get_icon (view)))
g_object_set (renderer, "pixbuf", pixbuf, NULL);
g_object_unref (view);
}
static void
midori_extension_treeview_render_text_cb (GtkTreeViewColumn* column,
GtkCellRenderer* renderer,
GtkTreeModel* model,
GtkTreeIter* iter,
GtkWidget* treeview)
{
MidoriView* view;
gtk_tree_model_get (model, iter, 0, &view, -1);
g_object_set (renderer, "text", midori_view_get_display_title (view),
"ellipsize", midori_view_get_label_ellipsize (view), NULL);
g_object_unref (view);
}
static void
midori_extension_row_activated_cb (GtkTreeView* treeview,
GtkTreePath* path,
@ -143,10 +161,9 @@ midori_extension_row_activated_cb (GtkTreeView* treeview,
}
static void
midori_extension_popup (GtkWidget* widget,
tab_panel_popup (GtkWidget* widget,
GdkEventButton* event,
GtkWidget* view,
MidoriExtension* extension)
GtkWidget* view)
{
GtkWidget* menu = midori_view_get_tab_menu (MIDORI_VIEW (view));
@ -185,7 +202,7 @@ midori_extension_button_release_event_cb (GtkWidget* widget,
else if (event->button == 2)
gtk_widget_destroy (view);
else
midori_extension_popup (widget, event, view, extension);
tab_panel_popup (widget, event, view);
g_object_unref (view);
return TRUE;
@ -215,7 +232,7 @@ midori_extension_popup_menu_cb (GtkWidget* widget,
GtkWidget* view;
gtk_tree_model_get (model, &iter, 0, &view, -1);
midori_extension_popup (widget, NULL, view, extension);
tab_panel_popup (widget, NULL, view);
g_object_unref (view);
}
}
@ -234,22 +251,208 @@ tab_panel_settings_notify_cb (MidoriWebSettings* settings,
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 2, buttons, -1);
}
static void
tab_panel_remove_view (MidoriBrowser* browser,
GtkWidget* view,
gboolean minimized)
{
if (minimized)
{
GtkToolItem* toolitem = tab_panel_get_toolitem_for_view (view);
gtk_widget_destroy (GTK_WIDGET (toolitem));
}
else
{
GtkTreeModel* model = tab_panel_get_model_for_browser (browser);
GtkTreeIter iter;
guint i = 0;
while (gtk_tree_model_iter_nth_child (model, &iter, NULL, i))
{
MidoriView* view_;
gtk_tree_model_get (model, &iter, 0, &view_, -1);
if ((MidoriView*)view == view_)
{
gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
g_object_unref (view_);
break;
}
g_object_unref (view_);
i++;
}
}
}
static void
tab_panel_view_notify_minimized_cb (GtkWidget* view,
GParamSpec* pspec,
MidoriExtension* extension)
{
MidoriBrowser* browser = midori_browser_get_for_widget (view);
gboolean minimized = katze_object_get_boolean (view, "minimized");
tab_panel_remove_view (browser, view, !minimized);
tab_panel_browser_add_tab_cb (browser, view, extension);
}
static void
tab_panel_view_notify_icon_cb (GtkWidget* view,
GParamSpec* pspec,
MidoriExtension* extension)
{
MidoriBrowser* browser = midori_browser_get_for_widget (view);
gboolean minimized = katze_object_get_boolean (view, "minimized");
GdkPixbuf* icon = midori_view_get_icon (MIDORI_VIEW (view));
if (minimized)
{
GtkToolItem* toolitem = tab_panel_get_toolitem_for_view (view);
GtkWidget* image = gtk_tool_button_get_icon_widget (GTK_TOOL_BUTTON (toolitem));
gtk_image_set_from_pixbuf (GTK_IMAGE (image), icon);
}
else
{
GtkTreeModel* model = tab_panel_get_model_for_browser (browser);
GtkTreeIter iter;
guint i = 0;
while (gtk_tree_model_iter_nth_child (model, &iter, NULL, i))
{
MidoriView* view_;
gtk_tree_model_get (model, &iter, 0, &view_, -1);
if ((MidoriView*)view == view_)
{
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 3, icon, -1);
g_object_unref (view_);
break;
}
g_object_unref (view_);
i++;
}
}
}
static void
tab_panel_view_notify_title_cb (GtkWidget* view,
GParamSpec* pspec,
MidoriExtension* extension)
{
MidoriBrowser* browser = midori_browser_get_for_widget (view);
gboolean minimized = katze_object_get_boolean (view, "minimized");
const gchar* title = midori_view_get_display_title (MIDORI_VIEW (view));
if (minimized)
{
GtkToolItem* toolitem = tab_panel_get_toolitem_for_view (view);
gtk_tool_item_set_tooltip_text (toolitem, title);
}
else
{
GtkTreeModel* model = tab_panel_get_model_for_browser (browser);
GtkTreeIter iter;
guint i = 0;
while (gtk_tree_model_iter_nth_child (model, &iter, NULL, i))
{
MidoriView* view_;
gtk_tree_model_get (model, &iter, 0, &view_, -1);
if ((MidoriView*)view == view_)
{
gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
4, title, 5, midori_view_get_label_ellipsize (view_), -1);
g_object_unref (view_);
break;
}
g_object_unref (view_);
i++;
}
}
}
static void
tab_panel_toolitem_clicked_cb (GtkToolItem* toolitem,
GtkWidget* view)
{
MidoriBrowser* browser = midori_browser_get_for_widget (view);
midori_browser_set_current_tab (browser, view);
}
static gboolean
tab_panel_toolitem_button_press_event_cb (GtkToolItem* toolitem,
GdkEventButton* event,
GtkWidget* view)
{
if (event->button == 3)
{
tab_panel_popup (GTK_WIDGET (toolitem), event, view);
return TRUE;
}
return FALSE;
}
static void
tab_panel_browser_add_tab_cb (MidoriBrowser* browser,
GtkWidget* view,
MidoriExtension* extension)
{
GtkTreeModel* model = g_object_get_data (G_OBJECT (extension), "treemodel");
GtkTreeIter iter;
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");
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));
GtkTreeModel* model = tab_panel_get_model_for_browser (browser);
if (minimized)
{
GtkWidget* toolbar = tab_panel_get_toolbar_for_browser (browser);
GtkWidget* image = gtk_image_new_from_pixbuf (
midori_view_get_icon (MIDORI_VIEW (view)));
GtkToolItem* toolitem = gtk_tool_button_new (image, NULL);
gtk_tool_item_set_tooltip_text (toolitem, title);
gtk_widget_show (image);
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);
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",
G_CALLBACK (tab_panel_toolitem_button_press_event_cb), view);
}
else
{
GtkTreeIter iter;
gboolean buttons = katze_object_get_boolean (settings, "close-buttons-on-tabs");
gint ellipsize = midori_view_get_label_ellipsize (MIDORI_VIEW (view));
gtk_tree_store_insert_with_values (GTK_TREE_STORE (model),
&iter, NULL, page, 0, view, 1, GTK_STOCK_CLOSE, 2, buttons, -1);
&iter, NULL, page, 0, view, 1, GTK_STOCK_CLOSE, 2, buttons,
3, icon, 4, title, 5, ellipsize , -1);
}
if (!g_signal_handler_find (view, G_SIGNAL_MATCH_FUNC,
g_signal_lookup ("notify", MIDORI_TYPE_VIEW), 0, NULL,
tab_panel_view_notify_minimized_cb, extension))
{
g_signal_connect (settings, "notify::close-buttons-on-tabs",
G_CALLBACK (tab_panel_settings_notify_cb), model);
g_signal_connect (view, "notify::minimized",
G_CALLBACK (tab_panel_view_notify_minimized_cb), extension);
g_signal_connect (view, "notify::icon",
G_CALLBACK (tab_panel_view_notify_icon_cb), extension);
g_signal_connect (view, "notify::title",
G_CALLBACK (tab_panel_view_notify_title_cb), extension);
}
g_object_unref (notebook);
g_object_unref (settings);
@ -265,30 +468,13 @@ tab_panel_browser_foreach_cb (GtkWidget* view,
static void
tab_panel_browser_remove_tab_cb (MidoriBrowser* browser,
MidoriView* view,
GtkWidget* view,
MidoriExtension* extension)
{
GtkTreeModel* model = g_object_get_data (G_OBJECT (extension), "treemodel");
guint i;
GtkTreeIter iter;
gboolean minimized = katze_object_get_boolean (view, "minimized");
i = 0;
while (gtk_tree_model_iter_nth_child (model, &iter, NULL, i))
{
MidoriView* view_;
gtk_tree_model_get (model, &iter, 0, &view_, -1);
if (view == view_)
{
gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
g_object_unref (view_);
break;
}
g_object_unref (view_);
i++;
}
if (!(GTK_OBJECT_FLAGS (browser) & GTK_IN_DESTRUCTION))
tab_panel_remove_view (browser, view, minimized);
}
static void
@ -309,7 +495,9 @@ tab_panel_app_add_browser_cb (MidoriApp* app,
panel = katze_object_get_object (browser, "panel");
model = g_object_get_data (G_OBJECT (extension), "treemodel");
model = gtk_tree_store_new (6, MIDORI_TYPE_VIEW,
G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
g_object_set_data (G_OBJECT (browser), "tab-panel-ext-model", model);
treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (treeview), FALSE);
@ -321,14 +509,12 @@ tab_panel_app_add_browser_cb (MidoriApp* app,
column = gtk_tree_view_column_new ();
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,
(GtkTreeCellDataFunc)midori_extension_treeview_render_icon_cb,
treeview, NULL);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_pixbuf,
"pixbuf", 3, NULL);
renderer_text = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column, renderer_text, TRUE);
gtk_tree_view_column_set_cell_data_func (column, renderer_text,
(GtkTreeCellDataFunc)midori_extension_treeview_render_text_cb,
treeview, NULL);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_text,
"text", 4, "ellipsize", 5, NULL);
gtk_tree_view_column_set_expand (column, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
column = gtk_tree_view_column_new ();
@ -354,6 +540,7 @@ tab_panel_app_add_browser_cb (MidoriApp* app,
gtk_widget_show (treeview);
toolbar = gtk_toolbar_new ();
g_object_set_data (G_OBJECT (browser), "tab-panel-ext-toolbar", toolbar);
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
gtk_widget_show (toolbar);
@ -386,15 +573,10 @@ static void
tab_panel_activate_cb (MidoriExtension* extension,
MidoriApp* app)
{
GtkTreeStore* model;
KatzeArray* browsers;
MidoriBrowser* browser;
guint i;
model = gtk_tree_store_new (3, MIDORI_TYPE_VIEW,
G_TYPE_STRING, G_TYPE_BOOLEAN);
g_object_set_data (G_OBJECT (extension), "treemodel", model);
browsers = katze_object_get_object (app, "browsers");
i = 0;
while ((browser = katze_array_get_nth_item (browsers, i++)))

View file

@ -604,20 +604,22 @@ static void tb_editor_activate_cb(MidoriExtension *extension, MidoriApp *app)
g_object_unref(browsers);
}
#endif
MidoriExtension *extension_init(void)
{
MidoriExtension* extension = g_object_new(MIDORI_TYPE_EXTENSION,
"name", _("Toolbar Editor"),
"description", _("Easily edit the toolbar layout"),
#if !HAVE_HILDON
"version", "0.1",
#endif
"authors", "Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>",
NULL);
#if !HAVE_HILDON
g_signal_connect(extension, "activate", G_CALLBACK(tb_editor_activate_cb), NULL);
#endif
return extension;
}
#endif

View file

@ -18,10 +18,13 @@
#include <libsoup/soup.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
struct _KatzeHttpAuth
{
GObject parent_instance;
gchar* filename;
GHashTable* logins;
};
struct _KatzeHttpAuthClass
@ -29,6 +32,20 @@ struct _KatzeHttpAuthClass
GObjectClass parent_class;
};
typedef struct
{
KatzeHttpAuth* http_auth;
SoupAuth* auth;
gchar* username;
gchar* password;
} KatzeHttpAuthSave;
typedef struct
{
gchar* username;
gchar* password;
} KatzeHttpAuthLogin;
static void
katze_http_auth_session_feature_iface_init (SoupSessionFeatureInterface *iface,
gpointer data);
@ -37,41 +54,130 @@ G_DEFINE_TYPE_WITH_CODE (KatzeHttpAuth, katze_http_auth, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
katze_http_auth_session_feature_iface_init));
enum
{
PROP_0,
PROP_FILENAME
};
static void
katze_http_auth_set_property (GObject* object,
guint prop_id,
const GValue* value,
GParamSpec* pspec);
static void
katze_http_auth_get_property (GObject* object,
guint prop_id,
GValue* value,
GParamSpec* pspec);
static void
katze_http_auth_finalize (GObject* object);
static gchar*
katze_http_auth_soup_auth_get_hash (SoupAuth* auth)
{
return g_strdup_printf ("%s:%s:%s",
soup_auth_get_host (auth),
soup_auth_get_scheme_name (auth),
soup_auth_get_realm (auth));
}
static void
authentication_message_got_headers_cb (SoupMessage* msg,
KatzeHttpAuthSave* save)
{
/* Anything but 401 and 5xx means the password was accepted */
if (msg->status_code != 401 && msg->status_code < 500)
{
gchar* opaque_info;
FILE* file;
opaque_info = katze_http_auth_soup_auth_get_hash (save->auth);
if (!g_hash_table_lookup (save->http_auth->logins, opaque_info))
{
KatzeHttpAuthLogin* login;
login = g_new (KatzeHttpAuthLogin, 1);
login->username = save->username;
login->password = save->password;
g_hash_table_insert (save->http_auth->logins, opaque_info, login);
if ((file = g_fopen (save->http_auth->filename, "a")))
{
fprintf (file, "%s\t%s\t%s\n", opaque_info,
login->username, login->password);
fclose (file);
}
}
else
{
/* FIXME g_free (save->username);
g_free (save->password); */
}
}
else
{
/* FIXME g_free (save->username);
g_free (save->password); */
}
/* FIXME g_object_unref (save->auth); */
/* FIXME g_free (save); */
g_signal_handlers_disconnect_by_func (msg,
authentication_message_got_headers_cb, save);
}
static void
authentication_dialog_response_cb (GtkWidget* dialog,
gint response,
SoupAuth* auth)
KatzeHttpAuthSave* save)
{
GtkWidget* username;
GtkWidget* password;
SoupSession* session;
SoupMessage* msg;
msg = g_object_get_data (G_OBJECT (dialog), "msg");
if (response == GTK_RESPONSE_OK)
{
GtkEntry* username = g_object_get_data (G_OBJECT (dialog), "username");
GtkEntry* password = g_object_get_data (G_OBJECT (dialog), "password");
username = g_object_get_data (G_OBJECT (dialog), "username");
password = g_object_get_data (G_OBJECT (dialog), "password");
soup_auth_authenticate (save->auth,
gtk_entry_get_text (username), gtk_entry_get_text (password));
soup_auth_authenticate (auth,
gtk_entry_get_text (GTK_ENTRY (username)),
gtk_entry_get_text (GTK_ENTRY (password)));
if (save->http_auth->filename)
{
save->username = g_strdup (gtk_entry_get_text (username));
save->password = g_strdup (gtk_entry_get_text (password));
g_signal_connect (msg, "got-headers",
G_CALLBACK (authentication_message_got_headers_cb), save);
}
else
{
g_object_unref (save->auth);
g_free (save);
}
}
session = g_object_get_data (G_OBJECT (dialog), "session");
msg = g_object_get_data (G_OBJECT (dialog), "msg");
gtk_widget_destroy (dialog);
if (g_object_get_data (G_OBJECT (msg), "paused"))
soup_session_unpause_message (session, msg);
g_object_unref (auth);
gtk_widget_destroy (dialog);
g_object_unref (msg);
}
static void
katze_http_auth_session_authenticate_cb (SoupSession* session,
SoupMessage* msg,
SoupAuth* auth,
gboolean retrying)
gboolean retrying,
KatzeHttpAuth* http_auth)
{
gchar* opaque_info;
KatzeHttpAuthLogin* login;
GtkWidget* dialog;
GtkSizeGroup* sizegroup;
GtkWidget* hbox;
@ -79,21 +185,26 @@ katze_http_auth_session_authenticate_cb (SoupSession* session,
GtkWidget* label;
GtkWidget* align;
GtkWidget* entry;
KatzeHttpAuthSave* save;
/* We want to ask for authentication exactly once, so we
enforce this with a tag. There might be a better way. */
if (!retrying && g_object_get_data (G_OBJECT (msg), "katze-session-tag"))
return;
if (soup_message_is_keepalive (msg))
if (1)
{
/* We use another tag to indicate whether a message is paused.
There doesn't seem to be API in libSoup to find that out. */
soup_session_pause_message (session, msg);
soup_session_pause_message (session, g_object_ref (msg));
g_object_set_data (G_OBJECT (msg), "paused", (void*)1);
}
g_object_set_data (G_OBJECT (msg), "katze-session-tag", (void*)1);
opaque_info = katze_http_auth_soup_auth_get_hash (auth);
login = g_hash_table_lookup (http_auth->logins, opaque_info);
g_free (opaque_info);
dialog = gtk_dialog_new_with_buttons (_("Authentication Required"),
NULL,
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
@ -130,6 +241,8 @@ katze_http_auth_session_authenticate_cb (SoupSession* session,
gtk_size_group_add_widget (sizegroup, align);
gtk_box_pack_start (GTK_BOX (hbox), align, TRUE, TRUE, 0);
entry = gtk_entry_new ();
if (login)
gtk_entry_set_text (GTK_ENTRY (entry), login->username);
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
g_object_set_data (G_OBJECT (dialog), "username", entry);
@ -141,6 +254,8 @@ katze_http_auth_session_authenticate_cb (SoupSession* session,
gtk_size_group_add_widget (sizegroup, align);
gtk_box_pack_start (GTK_BOX (hbox), align, TRUE, TRUE, 0);
entry = gtk_entry_new_with_max_length (32);
if (login)
gtk_entry_set_text (GTK_ENTRY (entry), login->password);
gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
@ -151,15 +266,19 @@ katze_http_auth_session_authenticate_cb (SoupSession* session,
g_object_set_data (G_OBJECT (dialog), "session", session);
g_object_set_data (G_OBJECT (dialog), "msg", msg);
save = g_new (KatzeHttpAuthSave, 1);
save->http_auth = http_auth;
save->auth = g_object_ref (auth);
g_signal_connect (dialog, "response",
G_CALLBACK (authentication_dialog_response_cb), g_object_ref (auth));
G_CALLBACK (authentication_dialog_response_cb), save);
gtk_widget_show (dialog);
}
static void
katze_http_auth_session_request_queued_cb (SoupSession* session,
SoupMessage* msg,
gpointer data)
KatzeHttpAuth* http_auth)
{
/* WebKit has its own authentication dialog in recent versions.
We want only one, and we choose our own to have localization. */
@ -168,7 +287,7 @@ katze_http_auth_session_request_queued_cb (SoupSession* session,
soup_session_remove_feature_by_type (session, type);
g_signal_connect (session, "authenticate",
G_CALLBACK (katze_http_auth_session_authenticate_cb), NULL);
G_CALLBACK (katze_http_auth_session_authenticate_cb), http_auth);
g_signal_handlers_disconnect_by_func (session,
katze_http_auth_session_request_queued_cb, NULL);
}
@ -178,7 +297,7 @@ katze_http_auth_attach (SoupSessionFeature* feature,
SoupSession* session)
{
g_signal_connect (session, "request-queued",
G_CALLBACK (katze_http_auth_session_request_queued_cb), NULL);
G_CALLBACK (katze_http_auth_session_request_queued_cb), feature);
}
static void
@ -202,11 +321,139 @@ katze_http_auth_session_feature_iface_init (SoupSessionFeatureInterface *iface,
static void
katze_http_auth_class_init (KatzeHttpAuthClass* class)
{
/* Nothing to do. */
GObjectClass* gobject_class;
GParamFlags flags;
gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = katze_http_auth_finalize;
gobject_class->set_property = katze_http_auth_set_property;
gobject_class->get_property = katze_http_auth_get_property;
flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
/**
* KatzeHttpAuth:filename:
*
* An absolute path and name of a file for storing logins.
*
* Since: 0.1.10
*/
g_object_class_install_property (gobject_class,
PROP_FILENAME,
g_param_spec_string (
"filename",
"Filename",
"An absolute path and name of a file for storing logins",
NULL,
flags));
}
static void
katze_http_auth_login_free (KatzeHttpAuthLogin* login)
{
g_free (login->username);
g_free (login->password);
g_free (login);
}
static void
katze_http_auth_set_filename (KatzeHttpAuth* http_auth,
const gchar* filename)
{
FILE* file;
katze_assign (http_auth->filename, g_strdup (filename));
g_hash_table_remove_all (http_auth->logins);
if ((file = g_fopen (filename, "r")))
{
gchar line[255];
guint number = 0;
while (fgets (line, 255, file))
{
gchar** parts = g_strsplit (line, "\t", 3);
if (parts && parts[0] && parts[1] && parts[2])
{
KatzeHttpAuthLogin* login;
gint length;
login = g_new (KatzeHttpAuthLogin, 1);
login->username = parts[1];
length = strlen (parts[2]);
if (parts[2][length - 1] == '\n')
length--;
login->password = g_strndup (parts[2], length);
g_hash_table_insert (http_auth->logins, parts[0], login);
g_free (parts);
}
else
{
g_strfreev (parts);
g_warning ("Error in line %d in HTTP Auth file", number);
}
number++;
}
fclose (file);
}
}
static void
katze_http_auth_init (KatzeHttpAuth* http_auth)
{
/* Nothing to do. */
http_auth->filename = NULL;
http_auth->logins = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free, (GDestroyNotify)katze_http_auth_login_free);
}
static void
katze_http_auth_finalize (GObject* object)
{
KatzeHttpAuth* http_auth = KATZE_HTTP_AUTH (object);
g_free (http_auth->filename);
g_hash_table_unref (http_auth->logins);
G_OBJECT_CLASS (katze_http_auth_parent_class)->finalize (object);
}
static void
katze_http_auth_set_property (GObject* object,
guint prop_id,
const GValue* value,
GParamSpec* pspec)
{
KatzeHttpAuth* http_auth = KATZE_HTTP_AUTH (object);
switch (prop_id)
{
case PROP_FILENAME:
katze_http_auth_set_filename (http_auth, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
katze_http_auth_get_property (GObject* object,
guint prop_id,
GValue* value,
GParamSpec* pspec)
{
KatzeHttpAuth* http_auth = KATZE_HTTP_AUTH (object);
switch (prop_id)
{
case PROP_FILENAME:
g_value_set_string (value, http_auth->filename);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}

View file

@ -92,7 +92,13 @@ settings_new_from_file (const gchar* filename,
if (!g_key_file_load_from_file (key_file, filename,
G_KEY_FILE_KEEP_COMMENTS, &error))
{
if (error->code != G_FILE_ERROR_NOENT)
if (error->code == G_FILE_ERROR_NOENT)
{
gchar* config_file = sokoke_find_config_filename ("config");
g_key_file_load_from_file (key_file, config_file,
G_KEY_FILE_KEEP_COMMENTS, NULL);
}
else
printf (_("The configuration couldn't be loaded: %s\n"),
error->message);
g_error_free (error);
@ -182,6 +188,7 @@ settings_save_to_file (MidoriWebSettings* settings,
gboolean saved;
KatzeArray* extensions = katze_object_get_object (app, "extensions");
MidoriExtension* extension;
gchar** _extensions;
key_file = g_key_file_new ();
class = G_OBJECT_GET_CLASS (settings);
@ -239,12 +246,24 @@ settings_save_to_file (MidoriWebSettings* settings,
}
g_free (pspecs);
if (extensions)
{
i = 0;
while ((extension = katze_array_get_nth_item (extensions, i++)))
if (midori_extension_is_active (extension))
g_key_file_set_boolean (key_file, "extensions",
g_object_get_data (G_OBJECT (extension), "filename"), TRUE);
g_object_unref (extensions);
}
else if ((_extensions = g_object_get_data (G_OBJECT (app), "extensions")))
{
i = 0;
while (_extensions[i])
{
g_key_file_set_boolean (key_file, "extensions", _extensions[i], TRUE);
i++;
}
}
saved = sokoke_key_file_save_to_file (key_file, filename, error);
g_key_file_free (key_file);
@ -959,10 +978,10 @@ midori_app_add_browser_cb (MidoriApp* app,
g_object_unref (panel);
}
static void
midori_browser_session_cb (MidoriBrowser* browser,
gpointer pspec,
KatzeArray* session)
static guint save_timeout = 0;
static gboolean
midori_session_save_timeout_cb (KatzeArray* session)
{
gchar* config_file;
GError* error;
@ -975,6 +994,24 @@ midori_browser_session_cb (MidoriBrowser* browser,
g_error_free (error);
}
g_free (config_file);
save_timeout = 0;
g_object_unref (session);
return FALSE;
}
static void
midori_browser_session_cb (MidoriBrowser* browser,
gpointer pspec,
KatzeArray* session)
{
if (!save_timeout)
{
g_object_ref (session);
save_timeout = g_timeout_add_full (G_PRIORITY_LOW, 5000,
(GSourceFunc)midori_session_save_timeout_cb, session, NULL);
}
}
static void
@ -986,36 +1023,63 @@ midori_browser_weak_notify_cb (MidoriBrowser* browser,
}
static void
soup_session_settings_notify_http_proxy_cb (MidoriWebSettings* settings,
GParamSpec* pspec,
SoupSession* session)
midori_soup_session_set_proxy_uri (SoupSession* session,
const gchar* uri)
{
gboolean auto_detect_proxy;
gchar* http_proxy;
gchar* fixed_uri;
SoupURI* proxy_uri;
auto_detect_proxy = katze_object_get_boolean (settings, "auto-detect-proxy");
if (auto_detect_proxy)
http_proxy = g_strdup (g_getenv ("http_proxy"));
else
http_proxy = katze_object_get_string (settings, "http-proxy");
/* soup_uri_new expects a non-NULL string with a protocol */
if (http_proxy && g_str_has_prefix (http_proxy, "http://"))
proxy_uri = soup_uri_new (http_proxy);
else if (http_proxy && *http_proxy)
if (uri && g_str_has_prefix (uri, "http://"))
proxy_uri = soup_uri_new (uri);
else if (uri && *uri)
{
gchar* fixed_http_proxy = g_strconcat ("http://", http_proxy, NULL);
proxy_uri = soup_uri_new (fixed_http_proxy);
g_free (fixed_http_proxy);
fixed_uri = g_strconcat ("http://", uri, NULL);
proxy_uri = soup_uri_new (fixed_uri);
g_free (fixed_uri);
}
else
proxy_uri = NULL;
g_free (http_proxy);
g_object_set (session, "proxy-uri", proxy_uri, NULL);
if (proxy_uri)
soup_uri_free (proxy_uri);
}
static void
soup_session_settings_notify_http_proxy_cb (MidoriWebSettings* settings,
GParamSpec* pspec,
SoupSession* session)
{
gboolean auto_detect_proxy;
auto_detect_proxy = katze_object_get_boolean (settings, "auto-detect-proxy");
if (auto_detect_proxy)
{
gboolean gnome_supported = FALSE;
GModule* module;
GType (*get_type_function) (void);
if (g_module_supported ())
if ((module = g_module_open ("libsoup-gnome-2.4.so", G_MODULE_BIND_LOCAL)))
{
if (g_module_symbol (module, "soup_proxy_resolver_gnome_get_type",
(void*) &get_type_function))
{
soup_session_add_feature_by_type (session, get_type_function ());
gnome_supported = TRUE;
}
}
if (!gnome_supported)
midori_soup_session_set_proxy_uri (session, g_getenv ("http_proxy"));
}
else
{
gchar* http_proxy = katze_object_get_string (settings, "http-proxy");
midori_soup_session_set_proxy_uri (session, http_proxy);
g_free (http_proxy);
}
}
#if !WEBKIT_CHECK_VERSION (1, 1, 11)
static void
soup_session_settings_notify_ident_string_cb (MidoriWebSettings* settings,
GParamSpec* pspec,
@ -1025,6 +1089,7 @@ soup_session_settings_notify_ident_string_cb (MidoriWebSettings* settings,
g_object_set (session, "user-agent", ident_string, NULL);
g_free (ident_string);
}
#endif
static void
midori_soup_session_debug (SoupSession* session)
@ -1049,15 +1114,22 @@ midori_soup_session_prepare (SoupSession* session,
gchar* config_file;
soup_session_settings_notify_http_proxy_cb (settings, NULL, session);
soup_session_settings_notify_ident_string_cb (settings, NULL, session);
g_signal_connect (settings, "notify::http-proxy",
G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
g_signal_connect (settings, "notify::auto-detect-proxy",
G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
#if !WEBKIT_CHECK_VERSION (1, 1, 11)
soup_session_settings_notify_ident_string_cb (settings, NULL, session);
g_signal_connect (settings, "notify::ident-string",
G_CALLBACK (soup_session_settings_notify_ident_string_cb), session);
#endif
soup_session_add_feature_by_type (session, KATZE_TYPE_HTTP_AUTH);
config_file = build_config_filename ("logins");
feature = g_object_new (KATZE_TYPE_HTTP_AUTH, "filename", config_file, NULL);
g_free (config_file);
soup_session_add_feature (session, feature);
g_object_unref (feature);
midori_soup_session_debug (session);
feature = g_object_new (KATZE_TYPE_HTTP_COOKIES, NULL);
@ -1066,6 +1138,7 @@ midori_soup_session_prepare (SoupSession* session,
config_file, (GDestroyNotify)g_free);
soup_session_add_feature (session, SOUP_SESSION_FEATURE (cookie_jar));
soup_session_add_feature (session, feature);
g_object_unref (feature);
}
static void
@ -1086,6 +1159,14 @@ button_reset_session_clicked_cb (GtkWidget* button,
gtk_widget_set_sensitive (button, FALSE);
}
static void
button_disable_extensions_clicked_cb (GtkWidget* button,
MidoriApp* app)
{
g_object_set_data (G_OBJECT (app), "extensions", NULL);
gtk_widget_set_sensitive (button, FALSE);
}
static GtkWidget*
midori_create_diagnostic_dialog (MidoriWebSettings* settings,
KatzeArray* _session)
@ -1095,6 +1176,7 @@ midori_create_diagnostic_dialog (MidoriWebSettings* settings,
GtkIconTheme* icon_theme;
GtkWidget* box;
GtkWidget* button;
MidoriApp* app = katze_item_get_parent (KATZE_ITEM (_session));
dialog = gtk_message_dialog_new (
NULL, 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
@ -1123,8 +1205,11 @@ midori_create_diagnostic_dialog (MidoriWebSettings* settings,
gtk_widget_set_sensitive (button, !katze_array_is_empty (_session));
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 4);
button = gtk_button_new_with_mnemonic (_("Disable all _extensions"));
if (g_object_get_data (G_OBJECT (app), "extensions"))
g_signal_connect (button, "clicked",
G_CALLBACK (button_disable_extensions_clicked_cb), app);
else
gtk_widget_set_sensitive (button, FALSE);
/* FIXME: Disable all extensions */
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 4);
gtk_widget_show_all (box);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box);
@ -1216,10 +1301,10 @@ midori_load_extensions (gpointer data)
(gpointer) &extension_init))
{
extension = extension_init ();
/* FIXME: Validate the extension */
/* Signal that we want the extension to load and save */
g_object_set_data_full (G_OBJECT (extension), "filename",
g_strdup (filename), g_free);
if (midori_extension_is_prepared (extension))
midori_extension_get_config_dir (extension);
}
else
@ -1642,8 +1727,12 @@ main (int argc,
if (execute)
result = midori_app_send_command (app, uris);
else if (uris) /* TODO: Open a tab per URI, seperated by pipes */
else if (uris)
{
/* TODO: Open a tab per URI, seperated by pipes */
/* FIXME: Handle relative files or magic URI here */
result = midori_app_instance_send_uris (app, uris);
}
else
result = midori_app_instance_send_new_browser (app);
@ -1687,25 +1776,9 @@ main (int argc,
g_free (dir);
search_engines = search_engines_new_from_file (config_file, NULL);
#else
const gchar* const * config_dirs = g_get_system_config_dirs ();
i = 0;
while (config_dirs[i])
{
g_object_unref (search_engines);
katze_assign (config_file,
g_build_filename (config_dirs[i], PACKAGE_NAME, "search", NULL));
sokoke_find_config_filename ("search"));
search_engines = search_engines_new_from_file (config_file, NULL);
if (!katze_array_is_empty (search_engines))
break;
i++;
}
if (katze_array_is_empty (search_engines))
{
g_object_unref (search_engines);
katze_assign (config_file,
g_build_filename (SYSCONFDIR, "xdg", PACKAGE_NAME, "search", NULL));
search_engines = search_engines_new_from_file (config_file, NULL);
}
#endif
}
else if (error)
@ -1722,7 +1795,13 @@ main (int argc,
error = NULL;
if (!midori_array_from_file (bookmarks, config_file, "xbel", &error))
{
if (error->code != G_FILE_ERROR_NOENT)
if (error->code == G_FILE_ERROR_NOENT)
{
katze_assign (config_file,
sokoke_find_config_filename ("bookmarks.xbel"));
midori_array_from_file (bookmarks, config_file, "xbel", NULL);
}
else
g_string_append_printf (error_messages,
_("The bookmarks couldn't be loaded: %s\n"), error->message);
g_error_free (error);
@ -1823,6 +1902,15 @@ main (int argc,
while (uri != NULL)
{
item = katze_item_new ();
/* Construct an absolute path if the file is relative */
if (g_file_test (uri, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
{
gchar* current_dir = g_get_current_dir ();
uri_ready = g_strconcat ("file://", current_dir,
G_DIR_SEPARATOR_S, uri, NULL);
g_free (current_dir);
}
else
uri_ready = sokoke_magic_uri (uri, NULL);
katze_item_set_uri (item, uri_ready);
g_free (uri_ready);
@ -1897,6 +1985,8 @@ main (int argc,
}
#endif
katze_item_set_parent (KATZE_ITEM (_session), app);
g_object_set_data (G_OBJECT (app), "extensions", extensions);
/* We test for the presence of a dummy file which is created once
and deleted during normal runtime, but persists in case of a crash. */
katze_assign (config_file, build_config_filename ("running"));
@ -1926,9 +2016,7 @@ main (int argc,
G_CALLBACK (midori_app_add_browser_cb), NULL);
g_idle_add (midori_load_cookie_jar, settings);
g_object_set_data (G_OBJECT (app), "extensions", extensions);
g_idle_add (midori_load_extensions, app);
katze_item_set_parent (KATZE_ITEM (_session), app);
g_idle_add (midori_load_session, _session);
if (execute)
@ -1948,6 +2036,8 @@ main (int argc,
/* Clear data on quit, according to the Clear private data dialog */
g_object_get (settings, "clear-private-data", &clear_prefs, NULL);
if (clear_prefs & MIDORI_CLEAR_ON_QUIT)
{
#if HAVE_SQLITE
midori_remove_config_file (clear_prefs, MIDORI_CLEAR_HISTORY, "history.db");
#endif
@ -1967,6 +2057,15 @@ main (int argc,
g_free (cache);
}
midori_remove_config_file (clear_prefs, MIDORI_CLEAR_TRASH, "tabtrash.xbel");
}
if (katze_object_get_boolean (settings, "load-on-startup")
!= MIDORI_STARTUP_LAST_OPEN_PAGES)
{
katze_assign (config_file, build_config_filename ("session.xbel"));
if (is_writable (config_file))
g_unlink (config_file);
}
g_object_unref (settings);
g_object_unref (app);

View file

@ -246,6 +246,7 @@ midori_array_from_file (KatzeArray* array,
if (!g_file_test (filename, G_FILE_TEST_EXISTS))
{
/* File doesn't exist */
if (error)
*error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_NOENT,
_("File not found."));
return FALSE;
@ -254,6 +255,7 @@ midori_array_from_file (KatzeArray* array,
if ((doc = xmlParseFile (filename)) == NULL)
{
/* No valid xml or broken encoding */
if (error)
*error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Malformed document."));
return FALSE;
@ -263,6 +265,7 @@ midori_array_from_file (KatzeArray* array,
{
/* Parsing failed */
xmlFreeDoc (doc);
if (error)
*error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Malformed document."));
return FALSE;

View file

@ -175,6 +175,14 @@ midori_browser_settings_notify (MidoriWebSettings* web_settings,
GParamSpec* pspec,
MidoriBrowser* browser);
static void
midori_browser_set_bookmarks (MidoriBrowser* browser,
KatzeArray* bookmarks);
static void
midori_browser_add_download_item (MidoriBrowser* browser,
WebKitDownload* download);
static GtkAction*
_action_by_name (MidoriBrowser* browser,
const gchar* name)
@ -585,10 +593,13 @@ midori_view_notify_statusbar_text_cb (MidoriView* view,
{
gchar* text;
if ((GtkWidget*)view == midori_browser_get_current_tab (browser))
{
g_object_get (view, "statusbar-text", &text, NULL);
_midori_browser_set_statusbar_text (browser, text);
g_free (text);
}
}
/* Private function, used by MidoriBookmarks and MidoriHistory */
/* static */ void
@ -777,6 +788,7 @@ midori_view_add_bookmark_cb (GtkWidget* menuitem,
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE);
}
#if !WEBKIT_CHECK_VERSION (1, 1, 3)
static void
midori_browser_save_transfer_cb (KatzeNetRequest* request,
gchar* filename)
@ -801,6 +813,7 @@ midori_browser_save_transfer_cb (KatzeNetRequest* request,
}
g_free (filename);
}
#endif
static void
midori_browser_save_uri (MidoriBrowser* browser,
@ -862,10 +875,27 @@ midori_browser_save_uri (MidoriBrowser* browser,
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
#if WEBKIT_CHECK_VERSION (1, 1, 3)
WebKitNetworkRequest* request;
WebKitDownload* download;
gchar* destination;
#endif
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
#if WEBKIT_CHECK_VERSION (1, 1, 3)
request = webkit_network_request_new (uri);
download = webkit_download_new (request);
g_object_unref (request);
destination = g_filename_to_uri (filename, NULL, NULL);
webkit_download_set_destination_uri (download, destination);
g_free (destination);
midori_browser_add_download_item (browser, download);
webkit_download_start (download);
#else
katze_net_load_uri (browser->net, uri, NULL,
(KatzeNetTransferCb)midori_browser_save_transfer_cb, filename);
#endif
g_free (last_dir);
last_dir = folder;
@ -1168,8 +1198,23 @@ midori_browser_download_notify_progress_cb (WebKitDownload* download,
GParamSpec* pspec,
GtkWidget* progress)
{
gchar* current;
gchar* total;
gchar* size_text;
gchar* text;
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress),
webkit_download_get_progress (download));
current = g_format_size_for_display (webkit_download_get_current_size (download));
total = g_format_size_for_display (webkit_download_get_total_size (download));
size_text = g_strdup_printf (_("%s of %s"), current, total);
g_free (current);
g_free (total);
text = g_strdup_printf ("%s (%s)",
gtk_progress_bar_get_text (GTK_PROGRESS_BAR (progress)),
size_text);
gtk_widget_set_tooltip_text (progress, text);
}
static void
@ -2111,12 +2156,19 @@ _action_edit_activate (GtkAction* action,
MidoriBrowser* browser)
{
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
#if WEBKIT_CHECK_VERSION (1, 1, 14)
gboolean can_undo = FALSE, can_redo = FALSE;
#endif
gboolean can_cut = FALSE, can_copy = FALSE, can_paste = FALSE;
gboolean has_selection, can_select_all = FALSE;
if (WEBKIT_IS_WEB_VIEW (widget))
{
WebKitWebView* view = WEBKIT_WEB_VIEW (widget);
#if WEBKIT_CHECK_VERSION (1, 1, 14)
can_undo = webkit_web_view_can_undo (view);
can_redo = webkit_web_view_can_redo (view);
#endif
can_cut = webkit_web_view_can_cut_clipboard (view);
can_copy = webkit_web_view_can_copy_clipboard (view);
can_paste = webkit_web_view_can_paste_clipboard (view);
@ -2142,6 +2194,10 @@ _action_edit_activate (GtkAction* action,
can_select_all = TRUE;
}
#if WEBKIT_CHECK_VERSION (1, 1, 14)
_action_set_sensitive (browser, "Undo", can_undo);
_action_set_sensitive (browser, "Redo", can_redo);
#endif
_action_set_sensitive (browser, "Cut", can_cut);
_action_set_sensitive (browser, "Copy", can_copy);
_action_set_sensitive (browser, "Paste", can_paste);
@ -2149,6 +2205,26 @@ _action_edit_activate (GtkAction* action,
_action_set_sensitive (browser, "SelectAll", can_select_all);
}
#if WEBKIT_CHECK_VERSION (1, 1, 14)
static void
_action_undo_activate (GtkAction* action,
MidoriBrowser* browser)
{
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
if (WEBKIT_IS_WEB_VIEW (widget))
webkit_web_view_undo (WEBKIT_WEB_VIEW (widget));
}
static void
_action_redo_activate (GtkAction* action,
MidoriBrowser* browser)
{
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
if (WEBKIT_IS_WEB_VIEW (widget))
webkit_web_view_redo (WEBKIT_WEB_VIEW (widget));
}
#endif
static void
_action_cut_activate (GtkAction* action,
MidoriBrowser* browser)
@ -3200,7 +3276,7 @@ _action_location_submit_uri (GtkAction* action,
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
}
static void
static gboolean
_action_location_secondary_icon_released (GtkAction* action,
GtkWidget* widget,
MidoriBrowser* browser)
@ -3212,12 +3288,29 @@ _action_location_secondary_icon_released (GtkAction* action,
const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
if (gtk_window_get_focus (GTK_WINDOW (browser)) == widget)
_action_location_submit_uri (action, uri, FALSE, browser);
else if (g_object_get_data (G_OBJECT (view), "news-feeds"))
else if ((uri = g_object_get_data (G_OBJECT (view), "news-feeds")))
{
if (browser->news_aggregator && *browser->news_aggregator)
sokoke_spawn_program (browser->news_aggregator, uri, TRUE);
else
_action_location_submit_uri (action, uri, FALSE, browser);
{
GtkWidget* dialog = gtk_message_dialog_new (
GTK_WINDOW (browser), 0, GTK_MESSAGE_INFO,
GTK_BUTTONS_OK, "%s", _("New feed"));
gtk_message_dialog_format_secondary_text (
GTK_MESSAGE_DIALOG (dialog), "%s", uri);
gtk_widget_show (dialog);
g_signal_connect_swapped (dialog, "response",
G_CALLBACK (gtk_widget_destroy), dialog);
}
}
else
_action_location_submit_uri (action, uri, FALSE, browser);
return TRUE;
}
return FALSE;
}
static void
_action_search_submit (GtkAction* action,
@ -3904,20 +3997,31 @@ _action_about_activate_email (GtkAboutDialog* about,
const gchar* uri,
gpointer user_data)
{
sokoke_show_uri (NULL, uri, GDK_CURRENT_TIME, NULL);
/* Some email clients need the 'mailto' to function properly */
gchar* newuri = NULL;
if (!g_str_has_prefix (uri, "mailto:"))
newuri = g_strconcat ("mailto:", uri, NULL);
sokoke_show_uri (NULL, newuri ? newuri : uri, GDK_CURRENT_TIME, NULL);
g_free (newuri);
}
static void
_action_about_activate (GtkAction* action,
MidoriBrowser* browser)
{
gchar* comments = g_strdup_printf ("GTK+ %d.%d.%d, WebKitGTK+ %d.%d.%d\n%s",
GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION,
WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION,
_("A lightweight web browser."));
gtk_about_dialog_set_email_hook (_action_about_activate_email, NULL, NULL);
gtk_about_dialog_set_url_hook (_action_about_activate_link, browser, NULL);
gtk_show_about_dialog (GTK_WINDOW (browser),
"logo-icon-name", gtk_window_get_icon_name (GTK_WINDOW (browser)),
"name", PACKAGE_NAME,
"version", PACKAGE_VERSION,
"comments", _("A lightweight web browser."),
"comments", comments,
"copyright", "Copyright © 2007-2009 Christian Dywan",
"website", "http://www.twotoasts.de",
"authors", credits_authors,
@ -4221,6 +4325,14 @@ static const GtkActionEntry entries[] = {
N_("Quit the application"), G_CALLBACK (_action_quit_activate) },
{ "Edit", NULL, N_("_Edit"), NULL, NULL, G_CALLBACK (_action_edit_activate) },
#if WEBKIT_CHECK_VERSION (1, 1, 14)
{ "Undo", GTK_STOCK_UNDO,
NULL, "<Ctrl>z",
N_("Undo the last modification"), G_CALLBACK (_action_undo_activate) },
{ "Redo", GTK_STOCK_REDO,
NULL, "<Ctrl><Shift>z",
N_("Redo the last modification"), G_CALLBACK (_action_redo_activate) },
#endif
{ "Cut", GTK_STOCK_CUT,
NULL, "<Ctrl>x",
N_("Cut the selected text"), G_CALLBACK (_action_cut_activate) },
@ -4475,6 +4587,9 @@ midori_browser_size_allocate_cb (MidoriBrowser* browser,
static void
midori_browser_destroy_cb (MidoriBrowser* browser)
{
if (browser->bookmarks)
midori_browser_set_bookmarks (browser, NULL);
if (G_UNLIKELY (browser->panel_timeout))
g_source_remove (browser->panel_timeout);
if (G_UNLIKELY (browser->alloc_timeout))
@ -4508,6 +4623,11 @@ static const gchar* ui_markup =
"<menuitem action='Quit'/>"
"</menu>"
"<menu action='Edit'>"
#if WEBKIT_CHECK_VERSION (1, 1, 14)
"<menuitem action='Undo'/>"
"<menuitem action='Redo'/>"
"<separator/>"
#endif
"<menuitem action='Cut'/>"
"<menuitem action='Copy'/>"
"<menuitem action='Paste'/>"
@ -4858,7 +4978,7 @@ midori_browser_init (MidoriBrowser* browser)
_action_location_reset_uri, browser,
"signal::submit-uri",
_action_location_submit_uri, browser,
"signal::secondary-icon-released",
"signal-after::secondary-icon-released",
_action_location_secondary_icon_released, browser,
NULL);
gtk_action_group_add_action_with_accel (browser->action_group,
@ -5243,7 +5363,7 @@ midori_browser_init (MidoriBrowser* browser)
gtk_box_pack_start (GTK_BOX (browser->statusbar), browser->transferbar,
FALSE, FALSE, 3);
gtk_widget_show (browser->transferbar);
browser->transferbar_clear = gtk_button_new_with_label (_("Delete All"));
browser->transferbar_clear = gtk_button_new_with_label (_("Clear All"));
icon = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU);
gtk_button_set_image (GTK_BUTTON (browser->transferbar_clear), icon);
g_signal_connect (browser->transferbar_clear, "clicked",
@ -5272,6 +5392,11 @@ midori_browser_finalize (GObject* object)
{
MidoriBrowser* browser = MIDORI_BROWSER (object);
if (browser->settings)
g_signal_handlers_disconnect_by_func (browser->settings,
midori_browser_settings_notify,
browser);
katze_assign (browser->statusbar_text, NULL);
katze_object_assign (browser->settings, NULL);
@ -5541,11 +5666,23 @@ midori_browser_settings_notify (MidoriWebSettings* web_settings,
else if (name == g_intern_string ("toolbar-items"))
_midori_browser_set_toolbar_items (browser, g_value_get_string (&value));
else if (name == g_intern_string ("compact-sidepanel"))
{
g_signal_handlers_block_by_func (browser->panel,
midori_panel_notify_show_titles_cb, browser);
g_object_set (browser->panel, "show-titles",
!g_value_get_boolean (&value), NULL);
else if (name == g_intern_string ("show-controls"))
g_signal_handlers_unblock_by_func (browser->panel,
midori_panel_notify_show_titles_cb, browser);
}
else if (name == g_intern_string ("show-panel-controls"))
{
g_signal_handlers_block_by_func (browser->panel,
midori_panel_notify_show_controls_cb, browser);
g_object_set (browser->panel, "show-controls",
g_value_get_boolean (&value), NULL);
g_signal_handlers_unblock_by_func (browser->panel,
midori_panel_notify_show_controls_cb, browser);
}
else if (name == g_intern_string ("always-show-tabbar"))
_toggle_tabbar_smartly (browser);
else if (name == g_intern_string ("show-navigationbar"))
@ -5652,6 +5789,14 @@ midori_browser_set_bookmarks (MidoriBrowser* browser,
if (browser->bookmarks == bookmarks)
return;
if (browser->bookmarks)
{
g_signal_handlers_disconnect_by_func (
browser->bookmarks, browser_bookmarks_add_item_cb, browser->bookmarkbar);
g_signal_handlers_disconnect_by_func (
browser->bookmarks, browser_bookmarks_remove_item_cb, browser->bookmarkbar);
}
if (bookmarks)
g_object_ref (bookmarks);
katze_object_assign (browser->bookmarks, bookmarks);

View file

@ -33,7 +33,6 @@ struct _MidoriLocationAction
GtkTreeModel* model;
GtkTreeModel* filter_model;
GtkTreeModel* sort_model;
GdkPixbuf* default_icon;
GHashTable* items;
KatzeNet* net;
@ -154,14 +153,23 @@ midori_location_action_class_init (MidoriLocationActionClass* class)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* MidoriLocationAction:secondary-icon-released:
*
* The secondary-icon-released signal is emitted when the mouse button
* is released above the secondary icon.
*
* Since 0.1.10 a signal handler can return %TRUE to stop signal
* emission, for instance to suppress default behavior.
*/
signals[SECONDARY_ICON_RELEASED] = g_signal_new ("secondary-icon-released",
G_TYPE_FROM_CLASS (class),
(GSignalFlags) (G_SIGNAL_RUN_LAST),
0,
0,
g_signal_accumulator_true_handled,
NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
midori_cclosure_marshal_BOOLEAN__OBJECT,
G_TYPE_BOOLEAN, 1,
GTK_TYPE_WIDGET);
signals[RESET_URI] = g_signal_new ("reset-uri",
@ -288,7 +296,6 @@ midori_location_action_freeze (MidoriLocationAction* location_action)
g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
g_return_if_fail (!midori_location_action_is_frozen (location_action));
katze_object_assign (location_action->sort_model, NULL);
katze_object_assign (location_action->filter_model, NULL);
midori_location_action_set_model (location_action, NULL);
@ -307,34 +314,29 @@ midori_location_action_freeze (MidoriLocationAction* location_action)
void
midori_location_action_thaw (MidoriLocationAction* location_action)
{
GtkTreeModel* sort_model;
GtkTreeModel* filter_model;
GtkTreeIter iter;
GtkTreeIter child_iter;
gint i;
g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
g_return_if_fail (midori_location_action_is_frozen (location_action));
sort_model = (GtkTreeModel*)gtk_tree_model_sort_new_with_model (
location_action->model);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model),
gtk_tree_sortable_set_sort_column_id (
GTK_TREE_SORTABLE (location_action->model),
VISITS_COL, GTK_SORT_DESCENDING);
filter_model = gtk_tree_model_filter_new (sort_model, NULL);
filter_model = gtk_tree_model_filter_new (location_action->model, NULL);
gtk_tree_model_filter_set_visible_column (
GTK_TREE_MODEL_FILTER (filter_model), VISIBLE_COL);
location_action->filter_model = filter_model;
location_action->sort_model = sort_model;
midori_location_action_set_model (location_action, location_action->model);
i = MAX_ITEMS;
while (gtk_tree_model_iter_nth_child (sort_model, &iter, NULL, i++))
while (gtk_tree_model_iter_nth_child (location_action->model, &iter, NULL, i++))
{
gtk_tree_model_sort_convert_iter_to_child_iter (
GTK_TREE_MODEL_SORT (sort_model), &child_iter, &iter);
gtk_list_store_set (GTK_LIST_STORE (location_action->model),
&child_iter, VISIBLE_COL, FALSE, -1);
&iter, VISIBLE_COL, FALSE, -1);
}
}
@ -359,7 +361,6 @@ midori_location_action_init (MidoriLocationAction* location_action)
location_action->model = midori_location_action_create_model ();
location_action->filter_model = NULL;
location_action->sort_model = NULL;
midori_location_action_thaw (location_action);
location_action->items = g_hash_table_new_full (g_str_hash, g_str_equal,
@ -377,7 +378,6 @@ midori_location_action_finalize (GObject* object)
katze_assign (location_action->search_engines, NULL);
katze_object_assign (location_action->model, NULL);
katze_object_assign (location_action->sort_model, NULL);
katze_object_assign (location_action->filter_model, NULL);
katze_object_assign (location_action->default_icon, NULL);
@ -605,7 +605,11 @@ midori_location_action_icon_released_cb (GtkWidget* widget,
GtkAction* action)
{
if (icon_pos == GTK_ICON_ENTRY_SECONDARY)
g_signal_emit (action, signals[SECONDARY_ICON_RELEASED], 0, widget);
{
gboolean result;
g_signal_emit (action, signals[SECONDARY_ICON_RELEASED], 0,
widget, &result);
}
}
static void
@ -630,7 +634,7 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
gtk_tree_model_get (model, iter, URI_COL, &uri, TITLE_COL, &title, -1);
desc_uri = desc_title = key = NULL;
desc = desc_uri = desc_title = key = NULL;
if (G_LIKELY (data))
{
entry = gtk_entry_completion_get_entry (GTK_ENTRY_COMPLETION (data));
@ -641,7 +645,7 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
if (G_LIKELY (data && uri))
{
temp = g_ascii_strdown (uri, -1);
if ((start = strstr (temp, key)))
if (key && *key && (start = strstr (temp, key)))
{
len = strlen (key);
skey = g_malloc0 (len + 1);
@ -664,7 +668,7 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
if (G_LIKELY (data && title))
{
temp = g_utf8_strdown (title, -1);
if ((start = strstr (temp, key)))
if (key && *key && (start = strstr (temp, key)))
{
if (!len)
len = strlen (key);
@ -736,33 +740,6 @@ midori_location_entry_completion_match_cb (GtkEntryCompletion* completion,
return match;
}
static void
midori_location_action_set_item (MidoriLocationAction* location_action,
GtkTreeIter* iter,
MidoriLocationEntryItem* item)
{
GdkPixbuf* icon;
GdkPixbuf* new_icon;
/* Ensure we keep the title if we added the same URI with a title before */
if (!item->title)
gtk_tree_model_get (location_action->model, iter, TITLE_COL, &item->title, -1);
gtk_list_store_set (GTK_LIST_STORE (location_action->model), iter,
URI_COL, item->uri, TITLE_COL, item->title, YALIGN_COL, 0.25, -1);
gtk_tree_model_get (location_action->model, iter, FAVICON_COL, &icon, -1);
if (item->favicon)
new_icon = item->favicon;
else if (!icon)
new_icon = location_action->default_icon;
else
new_icon = NULL;
if (new_icon)
gtk_list_store_set (GTK_LIST_STORE (location_action->model), iter,
FAVICON_COL, new_icon, -1);
}
/**
* midori_location_action_iter_lookup:
* @location_action: a #MidoriLocationAction
@ -847,6 +824,69 @@ midori_location_action_iter_insert (MidoriLocationAction* location_action,
return TRUE;
}
static void
midori_location_action_set_item (MidoriLocationAction* location_action,
MidoriLocationEntryItem* item,
gboolean increment_visits,
gboolean filter)
{
GtkTreeModel* model;
GtkTreeModel* filter_model;
GtkTreeIter iter;
GdkPixbuf* icon;
GdkPixbuf* new_icon;
gint visits = 0;
model = location_action->model;
if (midori_location_action_iter_insert (location_action,
item->uri, &iter, G_MAXINT))
gtk_tree_model_get (model, &iter, VISITS_COL, &visits, -1);
if (increment_visits)
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
VISITS_COL, ++visits, VISIBLE_COL, TRUE, -1);
/* Ensure we keep the title if we added the same URI with a title before */
if (!item->title)
gtk_tree_model_get (model, &iter, TITLE_COL, &item->title, -1);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
URI_COL, item->uri, TITLE_COL, item->title, YALIGN_COL, 0.25, -1);
gtk_tree_model_get (model, &iter, FAVICON_COL, &icon, -1);
if (item->favicon)
new_icon = item->favicon;
else if (!icon)
new_icon = location_action->default_icon;
else
new_icon = NULL;
if (new_icon)
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
FAVICON_COL, new_icon, -1);
if (filter)
{
filter_model = location_action->filter_model;
if (filter_model)
{
GtkTreeIter idx;
gint n;
n = gtk_tree_model_iter_n_children (filter_model, NULL);
if (n > MAX_ITEMS)
{
gtk_tree_model_iter_nth_child (filter_model, &idx, NULL, n - 1);
gtk_tree_model_filter_convert_iter_to_child_iter (
GTK_TREE_MODEL_FILTER (filter_model), &iter, &idx);
gtk_list_store_set (GTK_LIST_STORE (model),
&iter, VISIBLE_COL, FALSE, -1);
}
}
}
}
static gboolean
midori_location_entry_match_selected_cb (GtkEntryCompletion* completion,
GtkTreeModel* model,
@ -916,7 +956,7 @@ midori_location_action_completion_init (MidoriLocationAction* location_action,
{
gtk_entry_completion_set_model (completion,
midori_location_action_is_frozen (location_action)
? NULL : location_action->filter_model);
? NULL : location_action->model);
return;
}
@ -925,7 +965,7 @@ midori_location_action_completion_init (MidoriLocationAction* location_action,
g_object_unref (completion);
gtk_entry_completion_set_model (completion,
midori_location_action_is_frozen (location_action)
? NULL : location_action->filter_model);
? NULL : location_action->model);
gtk_entry_completion_set_text_column (completion, URI_COL);
#if GTK_CHECK_VERSION (2, 12, 0)
@ -1157,89 +1197,6 @@ midori_location_action_set_icon (MidoriLocationAction* location_action,
}
}
/**
* midori_location_action_prepend_item:
* @location_action: a #MidoriLocationAction
* @item: a MidoriLocationItem
*
* Prepends @item if it is not already in the list.
* If the item already exists, it is moved before the first item.
* If the maximum is reached, the last item is removed.
**/
static void
midori_location_action_prepend_item (MidoriLocationAction* location_action,
MidoriLocationEntryItem* item)
{
GtkTreeModel* filter_model;
GtkTreeModel* sort_model;
GtkTreeModel* model;
GtkTreeIter iter;
GtkTreeIter sort_iter;
GtkTreeIter idx;
gint n;
gint visits = 0;
filter_model = location_action->filter_model;
sort_model = location_action->sort_model;
model = location_action->model;
if (midori_location_action_iter_insert (location_action,
item->uri, &iter, 0))
{
gtk_tree_model_get_iter_first (model, &idx);
gtk_tree_model_get (model, &iter, VISITS_COL, &visits, -1);
gtk_list_store_move_before (GTK_LIST_STORE (model), &iter, &idx);
}
/* Only increment the visits when we add the uri */
if (!item->title && !item->favicon)
gtk_list_store_set (GTK_LIST_STORE (model), &iter, VISITS_COL, ++visits,
VISIBLE_COL, TRUE, -1);
if (filter_model)
{
n = gtk_tree_model_iter_n_children (filter_model, NULL);
if (n > MAX_ITEMS)
{
gtk_tree_model_iter_nth_child (filter_model, &idx, NULL, n - 1);
gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (filter_model),
&sort_iter, &idx);
gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (sort_model),
&idx, &sort_iter);
gtk_list_store_set (GTK_LIST_STORE (model),
&idx, VISIBLE_COL, FALSE, -1);
}
}
midori_location_action_set_item (location_action, &iter, item);
}
/**
* midori_location_entry_append_item:
* @location_entry: a #MidoriLocationEntry
* @item: a MidoriLocationItem
*
* Appends @item if it is not already in the list.
* @item is not added if the maximum is reached.
**/
static void
midori_location_action_append_item (MidoriLocationAction* location_action,
MidoriLocationEntryItem* item)
{
GtkTreeModel* model;
GtkTreeIter iter;
gint visits = 0;
model = location_action->model;
if (midori_location_action_iter_insert (location_action,
item->uri, &iter, G_MAXINT))
gtk_tree_model_get (model, &iter, VISITS_COL, &visits, -1);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
VISITS_COL, ++visits, VISIBLE_COL, TRUE, -1);
midori_location_action_set_item (location_action, &iter, item);
}
void
midori_location_action_add_uri (MidoriLocationAction* location_action,
const gchar* uri)
@ -1255,7 +1212,7 @@ midori_location_action_add_uri (MidoriLocationAction* location_action,
item.favicon = NULL;
item.uri = uri;
item.title = NULL;
midori_location_action_prepend_item (location_action, &item);
midori_location_action_set_item (location_action, &item, TRUE, TRUE);
katze_assign (location_action->uri, g_strdup (uri));
}
@ -1279,7 +1236,7 @@ midori_location_action_add_item (MidoriLocationAction* location_action,
item.favicon = icon;
item.uri = uri;
item.title = title;
midori_location_action_append_item (location_action, &item);
midori_location_action_set_item (location_action, &item, TRUE, FALSE);
if (midori_location_action_is_frozen (location_action))
return;
@ -1317,7 +1274,7 @@ midori_location_action_set_icon_for_uri (MidoriLocationAction* location_action,
item.favicon = icon;
item.uri = uri;
item.title = NULL;
midori_location_action_prepend_item (location_action, &item);
midori_location_action_set_item (location_action, &item, FALSE, TRUE);
proxies = gtk_action_get_proxies (GTK_ACTION (location_action));
@ -1347,7 +1304,7 @@ midori_location_action_set_title_for_uri (MidoriLocationAction* location_action,
item.favicon = NULL;
item.uri = uri;
item.title = title;
midori_location_action_prepend_item (location_action, &item);
midori_location_action_set_item (location_action, &item, FALSE, TRUE);
}
/**

View file

@ -30,16 +30,6 @@ struct _MidoriLocationEntryClass
G_DEFINE_TYPE (MidoriLocationEntry,
midori_location_entry, GTK_TYPE_COMBO_BOX_ENTRY)
enum
{
FAVICON_COL,
URI_COL,
TITLE_COL,
VISITS_COL,
VISIBLE_COL,
N_COLS
};
static gboolean
entry_key_press_event (GtkWidget* widget,
GdkEventKey* event,

View file

@ -487,18 +487,14 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
gtk_button_set_label (GTK_BUTTON (button), _("Load images automatically"));
gtk_widget_set_tooltip_text (button, _("Load and display images automatically"));
INDENTED_ADD (button, 0, 1, 0, 1);
#if 0
button = katze_property_proxy (settings, "auto-shrink-images", NULL);
gtk_button_set_label (GTK_BUTTON (button), _("Shrink images automatically"));
gtk_widget_set_tooltip_text (button, _("Automatically shrink standalone images to fit"));
#else
button = katze_property_proxy (settings, "middle-click-opens-selection", NULL);
#endif
SPANNED_ADD (button, 1, 2, 0, 1);
button = katze_property_proxy (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"));
INDENTED_ADD (button, 0, 1, 1, 2);
button = katze_property_proxy (settings, "resizable-text-areas", NULL);
gtk_button_set_label (GTK_BUTTON (button), _("Resizable text areas"));
gtk_widget_set_tooltip_text (button, _("Whether text areas are resizable"));
SPANNED_ADD (button, 1, 2, 1, 2);
button = katze_property_proxy (settings, "enable-scripts", NULL);
gtk_button_set_label (GTK_BUTTON (button), _("Enable scripts"));
gtk_widget_set_tooltip_text (button, _("Enable embedded scripting languages"));
@ -547,24 +543,22 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
FILLED_ADD (button, 1, 2, 1, 2);
FRAME_NEW (_("Browsing"));
TABLE_NEW (5, 2);
hbox = gtk_hbox_new (FALSE, 4);
label = katze_property_label (settings, "open-new-pages-in");
INDENTED_ADD (label, 0, 1, 0, 1);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
button = katze_property_proxy (settings, "open-new-pages-in", NULL);
FILLED_ADD (button, 1, 2, 0, 1);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 4);
INDENTED_ADD (hbox, 0, 1, 0, 1);
hbox = gtk_hbox_new (FALSE, 4);
label = katze_property_label (settings, "open-external-pages-in");
INDENTED_ADD (label, 0, 1, 1, 2);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
button = katze_property_proxy (settings, "open-external-pages-in", NULL);
FILLED_ADD (button, 1, 2, 1, 2);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 4);
FILLED_ADD (hbox, 1, 2, 0, 1);
button = katze_property_proxy (settings, "always-show-tabbar", NULL);
INDENTED_ADD (button, 0, 1, 2, 3);
button = katze_property_proxy (settings, "open-tabs-in-the-background", NULL);
INDENTED_ADD (button, 1, 2, 2, 3);
#if !HAVE_HILDON
button = katze_property_proxy (settings, "middle-click-opens-selection", NULL);
INDENTED_ADD (button, 0, 1, 3, 4);
button = katze_property_proxy (settings, "open-popups-in-tabs", NULL);
SPANNED_ADD (button, 1, 2, 3, 4);
#endif
button = katze_property_proxy (settings, "open-tabs-next-to-current", NULL);
WIDGET_ADD (button, 0, 1, 5, 6);
button = katze_property_proxy (settings, "close-buttons-on-tabs", NULL);
@ -659,15 +653,15 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
button = katze_property_proxy (settings, "accept-cookies", NULL);
FILLED_ADD (button, 1, 2, 0, 1);
button = katze_property_proxy (settings, "original-cookies-only", NULL);
SPANNED_ADD (button, 0, 2, 1, 2);
label = katze_property_label (settings, "maximum-cookie-age");
INDENTED_ADD (label, 0, 1, 2, 3);
SPANNED_ADD (button, 0, 1, 1, 2);
hbox = gtk_hbox_new (FALSE, 4);
label = katze_property_label (settings, "maximum-cookie-age");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
entry = katze_property_proxy (settings, "maximum-cookie-age", NULL);
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("days")),
FALSE, FALSE, 0);
FILLED_ADD (hbox, 1, 2, 2, 3);
FILLED_ADD (hbox, 1, 2, 1, 2);
FRAME_NEW (_("History"));
TABLE_NEW (3, 2);
button = katze_property_proxy (settings, "remember-last-visited-pages", NULL);

View file

@ -770,6 +770,7 @@ webkit_web_view_load_error_cb (WebKitWebView* web_view,
guint port;
gchar* res_root;
gchar* stock_root;
gchar* title;
gchar* message;
gchar* result;
@ -778,9 +779,10 @@ webkit_web_view_load_error_cb (WebKitWebView* web_view,
res_root = g_strdup_printf ("http://localhost:%d/res", port);
stock_root = g_strdup_printf ("http://localhost:%d/stock", port);
title = g_strdup_printf (_("Error - %s"), uri);
message = g_strdup_printf (_("The page '%s' couldn't be loaded."), uri);
result = sokoke_replace_variables (template,
"{title}", _("Error"),
"{title}", title,
"{message}", message,
"{description}", error->message,
"{tryagain}", _("Try again"),
@ -789,6 +791,7 @@ webkit_web_view_load_error_cb (WebKitWebView* web_view,
NULL);
g_free (template);
g_free (message);
g_free (title);
webkit_web_frame_load_alternate_string (web_frame,
result, res_root, uri);
@ -847,7 +850,7 @@ webkit_web_view_load_finished_cb (WebKitWebView* web_view,
g_object_notify (G_OBJECT (view), "progress");
midori_view_update_load_status (view, MIDORI_LOAD_FINISHED);
if (view->news_aggregator && *view->news_aggregator)
if (1)
{
JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
/* This snippet joins the available news feeds into a string like this:
@ -861,6 +864,7 @@ webkit_web_view_load_finished_cb (WebKitWebView* web_view,
"feeds (document.getElementsByTagName ('link'))", NULL);
gchar** items = g_strsplit (value, ",", 0);
guint i = 0;
gchar* default_uri = NULL;
katze_array_clear (view->news_feeds);
if (items != NULL)
@ -873,12 +877,13 @@ webkit_web_view_load_finished_cb (WebKitWebView* web_view,
NULL);
katze_array_add_item (view->news_feeds, item);
g_object_unref (item);
if (!default_uri)
default_uri = g_strdup (parts ? *parts : NULL);
g_strfreev (parts);
i++;
}
g_strfreev (items);
g_object_set_data (G_OBJECT (view), "news-feeds",
value && *value ? (void*)1 : (void*)0);
g_object_set_data_full (G_OBJECT (view), "news-feeds", default_uri, g_free);
g_free (value);
/* Ensure load-status is notified again, whether it changed or not */
g_object_notify (G_OBJECT (view), "load-status");
@ -1005,6 +1010,9 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
else if (view->middle_click_opens_selection)
{
guint i = 0;
/* FIXME: This isn't quite correct, we need mouse context */
if (webkit_web_view_can_paste_clipboard (WEBKIT_WEB_VIEW (view->web_view)))
return FALSE;
clipboard = gtk_clipboard_get_for_display (
gtk_widget_get_display (GTK_WIDGET (view)),
GDK_SELECTION_PRIMARY);
@ -1196,7 +1204,26 @@ webkit_web_view_populate_popup_cb (WebKitWebView* web_view,
icon = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (menuitem));
gtk_image_get_stock (GTK_IMAGE (icon), &stock_id, NULL);
if (!strcmp (stock_id, GTK_STOCK_CUT))
{
#if WEBKIT_CHECK_VERSION (1, 1, 14)
if (!strcmp (stock_id, GTK_STOCK_UNDO))
return;
menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
menuitem = sokoke_action_create_popup_menu_item (
gtk_action_group_get_action (actions, "Redo"));
gtk_widget_set_sensitive (menuitem,
webkit_web_view_can_redo (web_view));
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
menuitem = sokoke_action_create_popup_menu_item (
gtk_action_group_get_action (actions, "Undo"));
gtk_widget_set_sensitive (menuitem,
webkit_web_view_can_undo (web_view));
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
#endif
return;
}
if (strcmp (stock_id, GTK_STOCK_FIND))
has_selection = FALSE;
}
@ -1612,6 +1639,17 @@ webkit_web_view_console_message_cb (GtkWidget* web_view,
return TRUE;
}
#if WEBKIT_CHECK_VERSION (1, 1, 5)
static gboolean
midori_view_web_view_print_requested_cb (GtkWidget* web_view,
WebKitWebFrame* web_frame,
MidoriView* view)
{
midori_view_print (view);
return TRUE;
}
#endif
static void
webkit_web_view_window_object_cleared_cb (GtkWidget* web_view,
WebKitWebFrame* web_frame,
@ -1967,7 +2005,6 @@ webkit_web_inspector_inspect_web_view_cb (gpointer inspector,
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
if (GTK_WIDGET_TOPLEVEL (toplevel))
{
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (toplevel));
screen = gtk_window_get_screen (GTK_WINDOW (toplevel));
width = gdk_screen_get_width (screen) / 1.7;
height = gdk_screen_get_height (screen) / 1.7;
@ -2061,6 +2098,10 @@ midori_view_construct_web_view (MidoriView* view)
"signal::download-requested",
webkit_web_view_download_requested_cb, view,
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 5)
"signal::print-requested",
midori_view_web_view_print_requested_cb, view,
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 6)
"signal::load-error",
webkit_web_view_load_error_cb, view,
@ -2126,6 +2167,8 @@ midori_view_set_uri (MidoriView* view,
g_file_get_contents (MDATADIR "/midori/res/speeddial-head.html",
&speed_dial_head, NULL, NULL);
if (G_UNLIKELY (!speed_dial_head))
speed_dial_head = g_strdup ("");
res_server = sokoke_get_res_server ();
port = soup_server_get_port (res_server);
@ -3016,11 +3059,11 @@ midori_view_reload (MidoriView* view,
#if WEBKIT_CHECK_VERSION (1, 1, 6)
/* WebKit 1.1.6 doesn't handle "alternate content" flawlessly,
so reloading via Javascript works but not via API calls. */
title = g_strdup (_("Error"));
title = g_strdup_printf (_("Error - %s"), view->uri);
#else
/* Error pages are special, we want to try loading the destination
again, not the error page which isn't even a proper page */
title = g_strdup_printf (_("Not found - %s"), view->uri);
title = g_strdup_printf (_("Error - %s"), view->uri);
#endif
if (view->title && strstr (title, view->title))
webkit_web_view_open (WEBKIT_WEB_VIEW (view->web_view), view->uri);
@ -3110,6 +3153,43 @@ midori_view_go_forward (MidoriView* view)
webkit_web_view_go_forward (WEBKIT_WEB_VIEW (view->web_view));
}
#if WEBKIT_CHECK_VERSION (1, 1, 5)
static GtkWidget*
midori_view_print_create_custom_widget_cb (GtkPrintOperation* operation,
MidoriView* view)
{
GtkWidget* box;
GtkWidget* button;
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);
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
/**
* midori_view_print
* @view: a #MidoriView
@ -3119,10 +3199,43 @@ midori_view_go_forward (MidoriView* view)
void
midori_view_print (MidoriView* view)
{
WebKitWebFrame* frame;
#if WEBKIT_CHECK_VERSION (1, 1, 5)
GtkPrintOperation* operation;
GError* error;
#endif
g_return_if_fail (MIDORI_IS_VIEW (view));
webkit_web_frame_print (webkit_web_view_get_main_frame (
WEBKIT_WEB_VIEW (view->web_view)));
frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
#if WEBKIT_CHECK_VERSION (1, 1, 5)
operation = gtk_print_operation_new ();
gtk_print_operation_set_custom_tab_label (operation, _("Features"));
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);
g_object_unref (operation);
if (error)
{
GtkWidget* window = gtk_widget_get_toplevel (GTK_WIDGET (view));
GtkWidget* dialog = gtk_message_dialog_new (
GTK_WIDGET_TOPLEVEL (window) ? GTK_WINDOW (window) : NULL,
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE, "%s", error->message);
g_error_free (error);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
}
#else
webkit_web_frame_print (frame);
#endif
}
/**

View file

@ -767,7 +767,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
"middle-click-opens-selection",
_("Middle click opens Selection"),
_("Load an address from the selection via middle click"),
FALSE,
TRUE,
flags));
g_object_class_install_property (gobject_class,
@ -1105,15 +1105,23 @@ generate_ident_string (MidoriIdentity identify_as)
const gchar* lang = pango_language_to_string (gtk_get_default_language ());
#ifndef WEBKIT_USER_AGENT_MAJOR_VERSION
#define WEBKIT_USER_AGENT_MAJOR_VERSION 532
#define WEBKIT_USER_AGENT_MINOR_VERSION 1
#endif
const gchar* webcore = "WebKit/" G_STRINGIFY (WEBKIT_USER_AGENT_MAJOR_VERSION)
"." G_STRINGIFY (WEBKIT_USER_AGENT_MINOR_VERSION) "+";
switch (identify_as)
{
case MIDORI_IDENT_MIDORI:
return g_strdup_printf ("%s (%s; %s; U; %s) WebKit/532+",
appname, platform, os, lang);
return g_strdup_printf ("%s (%s; %s; U; %s) %s",
appname, platform, os, lang, webcore);
case MIDORI_IDENT_SAFARI:
return g_strdup_printf ("Mozilla/5.0 (%s; U; %s; %s) "
"AppleWebKit/532+ (KHTML, like Gecko) Safari/419.3 %s",
platform, os, lang, appname);
"AppleWebKit/532+ (KHTML, like Gecko) Safari/%s %s",
platform, os, lang, webcore, appname);
case MIDORI_IDENT_FIREFOX:
return g_strdup_printf ("Mozilla/5.0 (%s; U; %s; %s; rv:1.8.1) "
"Gecko/20061010 Firefox/2.0 %s",
@ -1323,12 +1331,20 @@ midori_web_settings_set_property (GObject* object,
{
gchar* string = generate_ident_string (web_settings->identify_as);
katze_assign (web_settings->ident_string, string);
#if WEBKIT_CHECK_VERSION (1, 1, 11)
g_object_set (web_settings, "user-agent", string, NULL);
#endif
g_object_notify (object, "ident-string");
}
break;
case PROP_IDENT_STRING:
if (web_settings->identify_as == MIDORI_IDENT_CUSTOM)
{
katze_assign (web_settings->ident_string, g_value_dup_string (value));
#if WEBKIT_CHECK_VERSION (1, 1, 11)
g_object_set (web_settings, "user-agent", web_settings->ident_string, NULL);
#endif
}
break;
case PROP_CACHE_SIZE:
web_settings->cache_size = g_value_get_int (value);

View file

@ -25,6 +25,10 @@
#include <stdlib.h>
#include <string.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
#include <glib/gprintf.h>
@ -294,8 +298,6 @@ gchar*
sokoke_magic_uri (const gchar* uri,
KatzeArray* search_engines)
{
gchar* current_dir;
gchar* result;
gchar** parts;
gchar* search;
const gchar* search_uri;
@ -313,20 +315,13 @@ sokoke_magic_uri (const gchar* uri,
/* Add file:// if we have a local path */
if (g_path_is_absolute (uri))
return g_strconcat ("file://", uri, NULL);
/* Construct an absolute path if the file is relative */
if (g_file_test (uri, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
{
current_dir = g_get_current_dir ();
result = g_strconcat ("file://", current_dir,
G_DIR_SEPARATOR_S, uri, NULL);
g_free (current_dir);
return result;
}
/* Do we have a protocol? */
if (g_strstr_len (uri, 8, "://"))
return sokoke_idn_to_punycode (g_strdup (uri));
/* Do we have a domain, ip address or localhost? */
if (g_ascii_isdigit (uri[0]))
return g_strconcat ("http://", uri, NULL);
search = NULL;
if (!strchr (uri, ' ') &&
((search = strchr (uri, ':')) || (search = strchr (uri, '@'))) &&
@ -339,8 +334,8 @@ sokoke_magic_uri (const gchar* uri,
{
if (!(parts[1][1] == '\0' && !g_ascii_isalpha (parts[1][0])))
if (!strchr (parts[0], ' ') && !strchr (parts[1], ' '))
if ((search = g_strconcat ("http://", uri, NULL)))
{
search = g_strconcat ("http://", uri, NULL);
g_strfreev (parts);
return sokoke_idn_to_punycode (search);
}
@ -418,25 +413,35 @@ sokoke_get_desktop (void)
{
#if HAVE_OSX
return SOKOKE_DESKTOP_OSX;
#else
#elif defined (GDK_WINDOWING_X11)
static SokokeDesktop desktop = SOKOKE_DESKTOP_UNTESTED;
if (G_UNLIKELY (desktop == SOKOKE_DESKTOP_UNTESTED))
{
/* Are we running in Xfce? */
gint result;
gchar *out = NULL;
gchar *err = NULL;
gboolean success = g_spawn_command_line_sync ("xprop -root _DT_SAVE_MODE",
&out, &err, &result, NULL);
g_free (err);
if (success && ! result && out != NULL && strstr (out, "xfce4") != NULL)
desktop = SOKOKE_DESKTOP_XFCE;
else
GdkDisplay* display = gdk_display_get_default ();
Display* xdisplay = GDK_DISPLAY_XDISPLAY (display);
Window root_window = RootWindow (xdisplay, 0);
Atom save_mode_atom = gdk_x11_get_xatom_by_name ("_DT_SAVE_MODE");
Atom actual_type;
int actual_format;
unsigned long n_items, bytes;
gchar* value;
int status = XGetWindowProperty (xdisplay, root_window,
save_mode_atom, 0, (~0L),
False, AnyPropertyType, &actual_type, &actual_format,
&n_items, &bytes, (unsigned char**)&value);
desktop = SOKOKE_DESKTOP_UNKNOWN;
g_free (out);
if (status == Success)
{
if (n_items == 6 && !strncmp (value, "xfce4", 6))
desktop = SOKOKE_DESKTOP_XFCE;
XFree (value);
}
}
return desktop;
#else
return SOKOKE_DESKTOP_UNKNOWN;
#endif
}
@ -957,6 +962,32 @@ sokoke_remove_path (const gchar* path,
return TRUE;
}
/**
* sokoke_find_config_filename:
* @filename: a filename or relative path
*
* Looks for the specified filename in the system config
* directories, depending on the platform.
*
* Return value: a full path
**/
gchar*
sokoke_find_config_filename (const gchar* filename)
{
const gchar* const* config_dirs = g_get_system_config_dirs ();
guint i = 0;
const gchar* config_dir;
while ((config_dir = config_dirs[i++]))
{
gchar* path = g_build_filename (config_dir, PACKAGE_NAME, filename, NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
}
return g_build_filename (SYSCONFDIR, "xdg", PACKAGE_NAME, filename, NULL);
}
/**
* sokoke_find_data_filename:
* @filename: a filename or relative path

View file

@ -151,6 +151,9 @@ gboolean
sokoke_remove_path (const gchar* path,
gboolean ignore_errors);
gchar*
sokoke_find_config_filename (const gchar* filename);
gchar*
sokoke_find_data_filename (const gchar* filename);

View file

@ -935,6 +935,7 @@ midori_bookmarks_finalize (GObject* object)
{
MidoriBookmarks* bookmarks = MIDORI_BOOKMARKS (object);
midori_bookmarks_disconnect_folder (bookmarks, bookmarks->array);
if (bookmarks->app)
g_object_unref (bookmarks->app);
g_object_unref (bookmarks->net);

View file

@ -221,7 +221,10 @@ midori_extensions_treeview_render_tick_cb (GtkTreeViewColumn* column,
gtk_tree_model_get (model, iter, 0, &extension, -1);
g_object_set (renderer, "active", midori_extension_is_active (extension), NULL);
g_object_set (renderer,
"activatable", midori_extension_is_prepared (extension),
"active", midori_extension_is_active (extension),
NULL);
g_object_unref (extension);
}
@ -244,12 +247,16 @@ midori_extensions_treeview_render_text_cb (GtkTreeViewColumn* column,
name = katze_object_get_string (extension, "name");
version = katze_object_get_string (extension, "version");
desc = katze_object_get_string (extension, "description");
text = g_markup_printf_escaped ("<b>%s</b> %s\n%s", name, version, desc);
text = g_markup_printf_escaped ("<b>%s</b> %s\n%s",
name, version && *version ? version : "", desc);
g_free (name);
g_free (version);
g_free (desc);
g_object_set (renderer, "markup", text, NULL);
g_object_set (renderer,
"markup", text,
"sensitive", midori_extension_is_prepared (extension),
NULL);
g_free (text);
g_object_unref (extension);
@ -272,7 +279,7 @@ midori_extensions_treeview_row_activated_cb (GtkTreeView* treeview,
gtk_tree_model_get (model, &iter, 0, &extension, -1);
if (midori_extension_is_active (extension))
midori_extension_deactivate (extension);
else
else if (midori_extension_is_prepared (extension))
g_signal_emit_by_name (extension, "activate", extensions->app);
g_object_unref (extension);
@ -437,7 +444,7 @@ midori_extensions_cell_renderer_toggled_cb (GtkCellRendererToggle* renderer,
gtk_tree_model_get (model, &iter, 0, &extension, -1);
if (midori_extension_is_active (extension))
midori_extension_deactivate (extension);
else
else if (midori_extension_is_prepared (extension))
g_signal_emit_by_name (extension, "activate", extensions->app);
g_object_unref (extension);
@ -460,6 +467,9 @@ midori_extensions_tree_sort_func (GtkTreeModel* model,
name1 = katze_object_get_string (e1, "name");
name2 = katze_object_get_string (e2, "name");
g_object_unref (e1);
g_object_unref (e2);
result = g_strcmp0 (name1, name2);
g_free (name1);

View file

@ -140,6 +140,7 @@ midori_transfers_get_toolbar (MidoriViewable* transfers)
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
gtk_widget_show (GTK_WIDGET (toolitem));
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_CLEAR);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), _("Clear All"));
gtk_tool_item_set_is_important (toolitem, TRUE);
g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_transfers_button_clear_clicked_cb), transfers);

View file

@ -1,2 +1,2 @@
# set of available languages (in alphabetic order)
cs da de el en_GB es et fi fr gl he hu id it ja nl pl pt ro ru sk sr sr@latin sv tr uk zh_CN zh_TW
ast ca cs da de el en_GB es et fi fr gl he hu id it ja nl pl pt pt_BR ro ru sk sr sr@latin sv tr uk zh_CN zh_TW

2309
po/ast.po Normal file

File diff suppressed because it is too large Load diff

2366
po/ca.po Normal file

File diff suppressed because it is too large Load diff

1395
po/cs.po

File diff suppressed because it is too large Load diff

1393
po/da.po

File diff suppressed because it is too large Load diff

640
po/de.po

File diff suppressed because it is too large Load diff

1079
po/el.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

1110
po/es.po

File diff suppressed because it is too large Load diff

1161
po/ja.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

1139
po/pt.po

File diff suppressed because it is too large Load diff

2309
po/pt_BR.po Normal file

File diff suppressed because it is too large Load diff

1424
po/ro.po

File diff suppressed because it is too large Load diff

962
po/ru.po

File diff suppressed because it is too large Load diff

1069
po/sk.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -54,8 +54,6 @@ test_input (const gchar* input,
static void
magic_uri_uri (void)
{
gchar* a, *b;
test_input ("ftp://ftp.mozilla.org", "ftp://ftp.mozilla.org");
test_input ("ftp://ftp.mozilla.org/pub", "ftp://ftp.mozilla.org/pub");
test_input ("http://www.example.com", "http://www.example.com");
@ -64,14 +62,10 @@ magic_uri_uri (void)
test_input ("example.com", "http://example.com");
test_input ("www.google..com", "http://www.google..com");
test_input ("/home/user/midori.html", "file:///home/user/midori.html");
a = g_get_current_dir ();
b = g_strconcat ("file://", a, G_DIR_SEPARATOR_S, "magic-uri.c", NULL);
g_free (a);
test_input ("magic-uri.c", b);
g_free (b);
test_input ("localhost", "http://localhost");
test_input ("localhost:8000", "http://localhost:8000");
test_input ("localhost/rss", "http://localhost/rss");
test_input ("10.0.0.1", "http://10.0.0.1");
test_input ("192.168.1.1", "http://192.168.1.1");
test_input ("192.168.1.1:8000", "http://192.168.1.1:8000");
test_input ("file:///home/mark/foo/bar.html",

View file

@ -25,7 +25,7 @@ import misc
major = 0
minor = 1
micro = 9
micro = 10
APPNAME = 'midori'
VERSION = str (major) + '.' + str (minor) + '.' + str (micro)
@ -210,6 +210,7 @@ def configure (conf):
check_pkg ('webkit-1.0', '1.1.1', args=args)
check_pkg ('libsoup-2.4', '2.25.2')
conf.define ('HAVE_LIBSOUP_2_25_2', 1)
check_pkg ('libsoup-2.4', '2.27.91', False, var='LIBSOUP_2_27_91')
check_pkg ('libxml-2.0', '2.6')
if option_enabled ('hildon'):