From: Christian Dywan Date: Fri, 25 Sep 2009 21:57:44 +0000 (+0200) Subject: Save back and forward history in the session (disabled) X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ead8e88864567bccfdd39c34c4e1e52813db808;p=midori Save back and forward history in the session (disabled) --- diff --git a/midori/midori-array.c b/midori/midori-array.c index 4ea123b2..7004bea1 100644 --- a/midori/midori-array.c +++ b/midori/midori-array.c @@ -364,8 +364,13 @@ katze_item_metadata_to_xbel (KatzeItem* item) i = 0; while ((key = g_list_nth_data (keys, i++))) if (katze_item_get_meta_string (item, key)) + { + gchar* escaped = + g_markup_escape_text (katze_item_get_meta_string (item, key), -1); g_string_append_printf (markup, " %s:%s=\"%s\"", namespace, key, - katze_item_get_meta_string (item, key)); + escaped); + g_free (escaped); + } g_string_append_printf (markup, "/>\n\n"); return g_string_free (markup, FALSE); } diff --git a/midori/midori-view.c b/midori/midori-view.c index d884af95..53b77203 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -97,6 +97,7 @@ struct _MidoriView GtkWidget* tab_close; KatzeItem* item; gint scrollh, scrollv; + gboolean back_forward_set; KatzeNet* net; }; @@ -750,6 +751,49 @@ webkit_web_view_load_committed_cb (WebKitWebView* web_view, katze_assign (view->uri, g_strdup (uri)); if (view->item) { + #if 0 + /* Load back forward history from meta data. WebKit does not seem to + respect the order of items, so the feature is unusable. */ + if (!view->back_forward_set) + { + WebKitWebBackForwardList* list; + gchar* key; + guint i; + const gchar* data; + WebKitWebHistoryItem* item; + + list = webkit_web_view_get_back_forward_list (web_view); + + key = g_strdup ("back4"); + for (i = 4; i > 0; i--) + { + key[4] = 48 + i; + if ((data = katze_item_get_meta_string (view->item, key))) + { + item = webkit_web_history_item_new_with_data (data, NULL); + webkit_web_back_forward_list_add_item (list, item); + g_object_unref (item); + } + } + + #if 0 + key[0] = 'f'; + key[1] = 'o'; + key[2] = 'r'; + key[3] = 'e'; + for (i = 4; i > 0; i--) + { + key[4] = 48 + i; + item = webkit_web_history_item_new_with_data (data, NULL); + webkit_web_back_forward_list_add_item (list, item); + g_object_unref (item); + } + #endif + g_free (key); + view->back_forward_set = TRUE; + } + #endif + katze_item_set_uri (view->item, uri); katze_item_set_added (view->item, time (NULL)); } @@ -941,6 +985,50 @@ webkit_web_view_notify_uri_cb (WebKitWebView* web_view, GParamSpec* pspec, MidoriView* view) { + #if 0 + if (view->item) + { + /* Save back forward history as meta data. This is disabled + because we can't reliably restore these atm. */ + WebKitWebView* web_view; + WebKitWebBackForwardList* list; + GList* back; + GList* forward; + + web_view = WEBKIT_WEB_VIEW (view->web_view); + list = webkit_web_view_get_back_forward_list (web_view); + back = webkit_web_back_forward_list_get_back_list_with_limit (list, 5); + forward = webkit_web_back_forward_list_get_forward_list_with_limit (list, 5); + guint i; + WebKitWebHistoryItem* item; + gchar* key = g_strdup ("back0"); + + i = 0; + while ((item = g_list_nth_data (back, i++))) + { + katze_item_set_meta_string (view->item, key, + webkit_web_history_item_get_uri (item)); + key[4] = 48 + i; + } + + #if 0 + key[0] = 'f'; + key[1] = 'o'; + key[2] = 'r'; + key[3] = 'e'; + key[4] = 48; + i = 0; + while ((item = g_list_nth_data (forward, i++))) + { + katze_item_set_meta_string (view->item, key, + webkit_web_history_item_get_uri (item)); + key[4] = 48 + i; + } + #endif + g_free (key); + } + #endif + g_object_get (web_view, "uri", &view->uri, NULL); g_object_notify (G_OBJECT (view), "uri"); } @@ -2057,6 +2145,7 @@ midori_view_init (MidoriView* view) view->item = NULL; view->scrollh = view->scrollv = 0; + view->back_forward_set = FALSE; view->download_manager = NULL; view->news_aggregator = NULL;