Merge lp:~meese/midori/fix-bug1287809 into lp:midori

Proposed by meese
Status: Superseded
Proposed branch: lp:~meese/midori/fix-bug1287809
Merge into: lp:midori
Diff against target: 182 lines (+75/-9)
2 files modified
katze/katze-item.c (+1/-1)
midori/midori-browser.c (+74/-8)
To merge this branch: bzr merge lp:~meese/midori/fix-bug1287809
Reviewer Review Type Date Requested Status
Cris Dywan Needs Fixing
Review via email: mp+229538@code.launchpad.net

This proposal supersedes a proposal from 2014-06-07.

This proposal has been superseded by a proposal from 2014-08-24.

Commit message

Restore tab history from the trash

Description of the change

fixes 1287809 by saving history in item that is put in the trash and restored to view on undo

To post a comment you must log in.
Revision history for this message
Robert Roth (evfool) wrote : Posted in a previous version of this proposal

Looks fine overall, one minor comment, see it inline.

Revision history for this message
Cris Dywan (kalikiana) wrote :

39 + KatzeArray* history;

Directly exposing and using a member is problematic. I would in fact prefer for now use g_object_get_data (G_OBJECT (item), "tab-history") to avoid adding API.
Later the code would be better to migrate towards Midori.HistoryWebsite which is cleaner than tucking more features onto KatzeItem, also using it for the trash itself and for session management (see related code for the session restoring https://code.launchpad.net/~midori/midori/tabHistory/+merge/211230).
(I realize these sort of plans should be documented in a wiki page somewhere… sorry about that)

tl;dr; I'd appreciate if you'd change it to g_object_get_data (G_OBJECT (item), "tab-history") for now without adding API.

review: Needs Fixing
lp:~meese/midori/fix-bug1287809 updated
6720. By meese

change to attach history with g_objecct_get_data ,remove katze changes

Revision history for this message
meese (meese) wrote :

fixed

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'katze/katze-item.c'
2--- katze/katze-item.c 2014-05-20 02:15:05 +0000
3+++ katze/katze-item.c 2014-08-13 00:37:48 +0000
4@@ -8,7 +8,7 @@
5
6 See the file COPYING for the full license text.
7 */
8-
9+
10 #include "katze-item.h"
11 #include "katze-utils.h"
12 #include "midori/midori-core.h"
13
14=== modified file 'midori/midori-browser.c'
15--- midori/midori-browser.c 2014-07-30 17:47:30 +0000
16+++ midori/midori-browser.c 2014-08-13 00:37:48 +0000
17@@ -1426,6 +1426,34 @@
18 }
19
20 static void
21+midori_browser_view_copy_to_item_history (GtkWidget* view,
22+ KatzeItem* item)
23+{
24+#ifndef HAVE_WEBKIT2
25+ WebKitWebView* copy_from;
26+ WebKitWebBackForwardList* list_from;
27+ guint length_from;
28+ gint i;
29+ GPtrArray* history;
30+
31+ copy_from = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
32+ list_from = webkit_web_view_get_back_forward_list (copy_from);
33+ length_from = webkit_web_back_forward_list_get_back_length (list_from);
34+ history = g_ptr_array_new ();
35+
36+ for (i = -length_from; i <= -1 ; i++)
37+ {
38+ WebKitWebHistoryItem* hist_item = webkit_web_back_forward_list_get_nth_item (list_from, i);
39+ if (hist_item == NULL)
40+ break;
41+ g_object_ref ((gpointer) hist_item);
42+ g_ptr_array_add (history, (gpointer) hist_item);
43+ }
44+ g_object_set_data (G_OBJECT (item), "tab-history", (gpointer) history);
45+#endif
46+}
47+
48+static void
49 midori_view_destroy_cb (GtkWidget* view,
50 MidoriBrowser* browser)
51 {
52@@ -1436,7 +1464,10 @@
53 && !midori_tab_is_blank (MIDORI_TAB (view)))
54 {
55 if (browser->trash)
56+ {
57+ midori_browser_view_copy_to_item_history (view,item);
58 katze_array_add_item (browser->trash, item);
59+ }
60 midori_browser_update_history (item, "website", "leave");
61 }
62 midori_browser_disconnect_tab (browser, MIDORI_VIEW (view));
63@@ -1508,6 +1539,39 @@
64 #endif
65 }
66
67+
68+static void
69+midori_browser_view_copy_from_item_history (GtkWidget* view,
70+ KatzeItem* item)
71+{
72+#ifndef HAVE_WEBKIT2
73+ WebKitWebView* copy_to;
74+ WebKitWebBackForwardList* list_to;
75+ gint i;
76+ GPtrArray* list_from;
77+
78+ copy_to = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
79+ list_to = webkit_web_view_get_back_forward_list (copy_to);
80+
81+ if (item == NULL)
82+ return;
83+ list_from = g_object_get_data (G_OBJECT (item), "tab-history");
84+ if (list_from == NULL)
85+ return;
86+
87+ for (i = 0; i < list_from->len; i++)
88+ {
89+ WebKitWebHistoryItem* hist_item = (WebKitWebHistoryItem*) g_ptr_array_index (list_from, i);
90+ if (hist_item == NULL)
91+ break;
92+ webkit_web_back_forward_list_add_item (list_to, hist_item);
93+ }
94+ g_ptr_array_unref (list_from);
95+#endif
96+}
97+
98+
99+
100 static gboolean
101 midori_browser_notify_new_tab_timeout_cb (MidoriBrowser *browser)
102 {
103@@ -1947,7 +2011,7 @@
104 g_free (old);
105 }
106
107-static void
108+static void
109 _update_reload_tooltip (GtkWidget* widget,
110 GdkEventKey* event,
111 gboolean released)
112@@ -1960,12 +2024,12 @@
113 GdkModifierType mask;
114 gdk_window_get_pointer (gtk_widget_get_window (widget), NULL, NULL, &mask);
115 const gchar *target;
116-
117+
118 if ( mask & GDK_SHIFT_MASK)
119 {
120 target = _("Reload page without caching");
121 }
122- else
123+ else
124 {
125 target = _("Reload the current page");
126 }
127@@ -3126,10 +3190,11 @@
128 KatzeItem* item)
129 {
130 GtkWidget* view;
131-
132 g_object_ref (item);
133 katze_array_remove_item (browser->trash, item);
134 view = midori_browser_add_item (browser, item);
135+ midori_browser_view_copy_from_item_history (view,item);
136+
137 g_object_unref (item);
138 return view;
139 }
140@@ -5543,6 +5608,7 @@
141 static void
142 midori_browser_destroy_cb (MidoriBrowser* browser)
143 {
144+
145 g_object_set_data (G_OBJECT (browser), "midori-browser-destroyed", (void*)1);
146
147 if (G_UNLIKELY (browser->panel_timeout))
148@@ -6366,7 +6432,7 @@
149 {
150 gtk_action_activate (_action_by_name (browser, "TabDuplicate"));
151 }
152-
153+
154 GtkWidget* parent = gtk_widget_get_parent (toolitem);
155 GtkAction* action = gtk_activatable_get_related_action (
156 GTK_ACTIVATABLE (parent));
157@@ -7565,14 +7631,14 @@
158 browser = gtk_window_get_transient_for (GTK_WINDOW (browser));
159 if (!MIDORI_IS_BROWSER (browser))
160 {
161- /* For some reason, when called on the widget of the
162+ /* For some reason, when called on the widget of the
163 * application menubar we get here.
164 */
165
166 GList* top_levels = gtk_window_list_toplevels ();
167 GList *iter;
168
169- for (iter = top_levels; iter; iter = g_list_next (iter))
170+ for (iter = top_levels; iter; iter = g_list_next (iter))
171 {
172 browser = iter->data;
173
174@@ -7582,7 +7648,7 @@
175 return MIDORI_BROWSER (browser);
176 }
177 }
178-
179+
180 g_list_free (top_levels);
181 return NULL;
182 }

Subscribers

People subscribed via source and target branches

to all changes: