Merge lp:~midori/midori/tabHistory into lp:midori

Proposed by Christian Dywan
Status: Work in progress
Proposed branch: lp:~midori/midori/tabHistory
Merge into: lp:midori
Diff against target: 69 lines (+34/-0)
2 files modified
extensions/tabby.vala (+20/-0)
midori/midori-view.c (+14/-0)
To merge this branch: bzr merge lp:~midori/midori/tabHistory
Reviewer Review Type Date Requested Status
Midori Devs Pending
Review via email: mp+211230@code.launchpad.net

Commit message

Restore tab history from session via HistoryWebsite

To post a comment you must log in.

Unmerged revisions

6606. By Christian Dywan

Restore tab history from session via HistoryWebsite

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'extensions/tabby.vala'
2--- extensions/tabby.vala 2014-03-16 22:53:49 +0000
3+++ extensions/tabby.vala 2014-03-17 00:52:25 +0000
4@@ -378,6 +378,7 @@
5 unowned Katze.Item item = view.get_proxy_item ();
6 int64 tab_id = item.get_meta_integer ("tabby-id");
7 string sqlcmd = "UPDATE `tabs` SET uri = :uri WHERE session_id = :session_id AND id = :tab_id;";
8+ // TODO: Update tan_history
9 try {
10 database.prepare (sqlcmd,
11 ":uri", typeof (string), uri,
12@@ -501,6 +502,24 @@
13 }
14 }
15
16+ private void restore_tab_history(Katze.Item item) {
17+ var items = new GenericArray<Midori.HistoryWebsite> ();
18+ int64 tab_id = item.get_meta_integer ("tabby-id");
19+ string sqlcmd = "SELECT url, title FROM tab_history WHERE tab_id = :tab_id ORDER BY tstamp";
20+ try {
21+ var statement = database.prepare (sqlcmd,
22+ ":tab_id", typeof (int64), tab_id);
23+ while (statement.step ()) {
24+ string url = statement.get_string ("url");
25+ string title = statement.get_string ("title");
26+ items.add (new Midori.HistoryWebsite (url, title, 0));
27+ }
28+ item.set_data<GenericArray<Midori.HistoryWebsite>> ("tab-history", items);
29+ } catch (Error error) {
30+ critical (_("Failed to select from database: %s"), error.message);
31+ }
32+ }
33+
34 public override Katze.Array get_tabs() {
35 Katze.Array tabs = new Katze.Array (typeof (Katze.Item));
36
37@@ -520,6 +539,7 @@
38 item.set_meta_string ("sorting", sorting.to_string ());
39 // See midori_browser_step_history: don't add to history
40 item.set_meta_string ("history-step", "ignore");
41+ restore_tab_history (item);
42 tabs.add_item (item);
43 }
44 } catch (Error error) {
45
46=== modified file 'midori/midori-view.c'
47--- midori/midori-view.c 2014-03-16 22:37:47 +0000
48+++ midori/midori-view.c 2014-03-17 00:52:25 +0000
49@@ -3156,6 +3156,20 @@
50 _midori_view_set_settings (view, settings);
51 if (item)
52 {
53+#ifndef HAVE_WEBKIT2
54+ GPtrArray* items = g_object_get_data (G_OBJECT (item), "tab-history");
55+ WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view->web_view));
56+ int i = 0;
57+ while (items && i < items->len)
58+ {
59+ const gchar* uri = midori_history_website_get_uri (items->pdata[i]);
60+ const gchar* title = midori_history_item_get_title (items->pdata[i]);
61+ WebKitWebHistoryItem* hitem = webkit_web_history_item_new_with_data (uri, title);
62+ webkit_web_back_forward_list_add_item (list, hitem);
63+ g_object_unref (hitem);
64+ i++;
65+ }
66+#endif
67 katze_object_assign (view->item, katze_item_copy (item));
68 midori_tab_set_minimized (MIDORI_TAB (view),
69 katze_item_get_meta_string (view->item, "minimized") != NULL);

Subscribers

People subscribed via source and target branches

to all changes: