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
=== modified file 'katze/katze-item.c'
--- katze/katze-item.c 2014-05-20 02:15:05 +0000
+++ katze/katze-item.c 2014-08-13 00:37:48 +0000
@@ -8,7 +8,7 @@
88
9 See the file COPYING for the full license text.9 See the file COPYING for the full license text.
10*/10*/
1111
12#include "katze-item.h"12#include "katze-item.h"
13#include "katze-utils.h"13#include "katze-utils.h"
14#include "midori/midori-core.h"14#include "midori/midori-core.h"
1515
=== modified file 'midori/midori-browser.c'
--- midori/midori-browser.c 2014-07-30 17:47:30 +0000
+++ midori/midori-browser.c 2014-08-13 00:37:48 +0000
@@ -1426,6 +1426,34 @@
1426}1426}
14271427
1428static void1428static void
1429midori_browser_view_copy_to_item_history (GtkWidget* view,
1430 KatzeItem* item)
1431{
1432#ifndef HAVE_WEBKIT2
1433 WebKitWebView* copy_from;
1434 WebKitWebBackForwardList* list_from;
1435 guint length_from;
1436 gint i;
1437 GPtrArray* history;
1438
1439 copy_from = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
1440 list_from = webkit_web_view_get_back_forward_list (copy_from);
1441 length_from = webkit_web_back_forward_list_get_back_length (list_from);
1442 history = g_ptr_array_new ();
1443
1444 for (i = -length_from; i <= -1 ; i++)
1445 {
1446 WebKitWebHistoryItem* hist_item = webkit_web_back_forward_list_get_nth_item (list_from, i);
1447 if (hist_item == NULL)
1448 break;
1449 g_object_ref ((gpointer) hist_item);
1450 g_ptr_array_add (history, (gpointer) hist_item);
1451 }
1452 g_object_set_data (G_OBJECT (item), "tab-history", (gpointer) history);
1453#endif
1454}
1455
1456static void
1429midori_view_destroy_cb (GtkWidget* view,1457midori_view_destroy_cb (GtkWidget* view,
1430 MidoriBrowser* browser)1458 MidoriBrowser* browser)
1431{1459{
@@ -1436,7 +1464,10 @@
1436 && !midori_tab_is_blank (MIDORI_TAB (view)))1464 && !midori_tab_is_blank (MIDORI_TAB (view)))
1437 {1465 {
1438 if (browser->trash)1466 if (browser->trash)
1467 {
1468 midori_browser_view_copy_to_item_history (view,item);
1439 katze_array_add_item (browser->trash, item);1469 katze_array_add_item (browser->trash, item);
1470 }
1440 midori_browser_update_history (item, "website", "leave");1471 midori_browser_update_history (item, "website", "leave");
1441 }1472 }
1442 midori_browser_disconnect_tab (browser, MIDORI_VIEW (view));1473 midori_browser_disconnect_tab (browser, MIDORI_VIEW (view));
@@ -1508,6 +1539,39 @@
1508#endif1539#endif
1509}1540}
15101541
1542
1543static void
1544midori_browser_view_copy_from_item_history (GtkWidget* view,
1545 KatzeItem* item)
1546{
1547#ifndef HAVE_WEBKIT2
1548 WebKitWebView* copy_to;
1549 WebKitWebBackForwardList* list_to;
1550 gint i;
1551 GPtrArray* list_from;
1552
1553 copy_to = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
1554 list_to = webkit_web_view_get_back_forward_list (copy_to);
1555
1556 if (item == NULL)
1557 return;
1558 list_from = g_object_get_data (G_OBJECT (item), "tab-history");
1559 if (list_from == NULL)
1560 return;
1561
1562 for (i = 0; i < list_from->len; i++)
1563 {
1564 WebKitWebHistoryItem* hist_item = (WebKitWebHistoryItem*) g_ptr_array_index (list_from, i);
1565 if (hist_item == NULL)
1566 break;
1567 webkit_web_back_forward_list_add_item (list_to, hist_item);
1568 }
1569 g_ptr_array_unref (list_from);
1570#endif
1571}
1572
1573
1574
1511static gboolean1575static gboolean
1512midori_browser_notify_new_tab_timeout_cb (MidoriBrowser *browser)1576midori_browser_notify_new_tab_timeout_cb (MidoriBrowser *browser)
1513{1577{
@@ -1947,7 +2011,7 @@
1947 g_free (old);2011 g_free (old);
1948}2012}
19492013
1950static void 2014static void
1951_update_reload_tooltip (GtkWidget* widget,2015_update_reload_tooltip (GtkWidget* widget,
1952 GdkEventKey* event,2016 GdkEventKey* event,
1953 gboolean released)2017 gboolean released)
@@ -1960,12 +2024,12 @@
1960 GdkModifierType mask;2024 GdkModifierType mask;
1961 gdk_window_get_pointer (gtk_widget_get_window (widget), NULL, NULL, &mask);2025 gdk_window_get_pointer (gtk_widget_get_window (widget), NULL, NULL, &mask);
1962 const gchar *target;2026 const gchar *target;
1963 2027
1964 if ( mask & GDK_SHIFT_MASK)2028 if ( mask & GDK_SHIFT_MASK)
1965 {2029 {
1966 target = _("Reload page without caching");2030 target = _("Reload page without caching");
1967 }2031 }
1968 else 2032 else
1969 {2033 {
1970 target = _("Reload the current page");2034 target = _("Reload the current page");
1971 }2035 }
@@ -3126,10 +3190,11 @@
3126 KatzeItem* item)3190 KatzeItem* item)
3127{3191{
3128 GtkWidget* view;3192 GtkWidget* view;
3129
3130 g_object_ref (item);3193 g_object_ref (item);
3131 katze_array_remove_item (browser->trash, item);3194 katze_array_remove_item (browser->trash, item);
3132 view = midori_browser_add_item (browser, item);3195 view = midori_browser_add_item (browser, item);
3196 midori_browser_view_copy_from_item_history (view,item);
3197
3133 g_object_unref (item);3198 g_object_unref (item);
3134 return view;3199 return view;
3135}3200}
@@ -5543,6 +5608,7 @@
5543static void5608static void
5544midori_browser_destroy_cb (MidoriBrowser* browser)5609midori_browser_destroy_cb (MidoriBrowser* browser)
5545{5610{
5611
5546 g_object_set_data (G_OBJECT (browser), "midori-browser-destroyed", (void*)1);5612 g_object_set_data (G_OBJECT (browser), "midori-browser-destroyed", (void*)1);
55475613
5548 if (G_UNLIKELY (browser->panel_timeout))5614 if (G_UNLIKELY (browser->panel_timeout))
@@ -6366,7 +6432,7 @@
6366 {6432 {
6367 gtk_action_activate (_action_by_name (browser, "TabDuplicate"));6433 gtk_action_activate (_action_by_name (browser, "TabDuplicate"));
6368 }6434 }
6369 6435
6370 GtkWidget* parent = gtk_widget_get_parent (toolitem);6436 GtkWidget* parent = gtk_widget_get_parent (toolitem);
6371 GtkAction* action = gtk_activatable_get_related_action (6437 GtkAction* action = gtk_activatable_get_related_action (
6372 GTK_ACTIVATABLE (parent));6438 GTK_ACTIVATABLE (parent));
@@ -7565,14 +7631,14 @@
7565 browser = gtk_window_get_transient_for (GTK_WINDOW (browser));7631 browser = gtk_window_get_transient_for (GTK_WINDOW (browser));
7566 if (!MIDORI_IS_BROWSER (browser))7632 if (!MIDORI_IS_BROWSER (browser))
7567 {7633 {
7568 /* For some reason, when called on the widget of the 7634 /* For some reason, when called on the widget of the
7569 * application menubar we get here.7635 * application menubar we get here.
7570 */7636 */
75717637
7572 GList* top_levels = gtk_window_list_toplevels ();7638 GList* top_levels = gtk_window_list_toplevels ();
7573 GList *iter;7639 GList *iter;
75747640
7575 for (iter = top_levels; iter; iter = g_list_next (iter)) 7641 for (iter = top_levels; iter; iter = g_list_next (iter))
7576 {7642 {
7577 browser = iter->data;7643 browser = iter->data;
75787644
@@ -7582,7 +7648,7 @@
7582 return MIDORI_BROWSER (browser);7648 return MIDORI_BROWSER (browser);
7583 }7649 }
7584 }7650 }
7585 7651
7586 g_list_free (top_levels);7652 g_list_free (top_levels);
7587 return NULL;7653 return NULL;
7588 }7654 }

Subscribers

People subscribed via source and target branches

to all changes: