Introduce helper for correctly restoring tabs

We need to ensure a reference on the item.
This commit is contained in:
Christian Dywan 2011-12-07 22:31:13 +01:00
parent 6143654279
commit e698ba3380

View file

@ -2817,6 +2817,19 @@ _action_trash_populate_popup (GtkAction* action,
gtk_widget_show (menuitem); gtk_widget_show (menuitem);
} }
static gint
midori_browser_restore_tab (MidoriBrowser* browser,
KatzeItem* item)
{
gint n;
g_object_ref (item);
katze_array_remove_item (browser->trash, item);
n = midori_browser_add_item (browser, item);
g_object_unref (item);
return n;
}
static gboolean static gboolean
_action_trash_activate_item_alt (GtkAction* action, _action_trash_activate_item_alt (GtkAction* action,
KatzeItem* item, KatzeItem* item,
@ -2825,17 +2838,13 @@ _action_trash_activate_item_alt (GtkAction* action,
{ {
if (MIDORI_EVENT_NEW_TAB (gtk_get_current_event ())) if (MIDORI_EVENT_NEW_TAB (gtk_get_current_event ()))
{ {
guint n; midori_browser_set_current_page_smartly (browser,
katze_array_remove_item (browser->trash, item); midori_browser_restore_tab (browser, item));
n = midori_browser_add_item (browser, item);
midori_browser_set_current_page_smartly (browser, n);
} }
else if (button == 1) else if (button == 1)
{ {
guint n; midori_browser_set_current_page (browser,
katze_array_remove_item (browser->trash, item); midori_browser_restore_tab (browser, item));
n = midori_browser_add_item (browser, item);
midori_browser_set_current_page (browser, n);
} }
return TRUE; return TRUE;
@ -5107,7 +5116,6 @@ _action_undo_tab_close_activate (GtkAction* action,
{ {
guint last; guint last;
KatzeItem* item; KatzeItem* item;
guint n;
if (!browser->trash) if (!browser->trash)
return; return;
@ -5115,9 +5123,8 @@ _action_undo_tab_close_activate (GtkAction* action,
/* Reopen the most recent trash item */ /* Reopen the most recent trash item */
last = katze_array_get_length (browser->trash) - 1; last = katze_array_get_length (browser->trash) - 1;
item = katze_array_get_nth_item (browser->trash, last); item = katze_array_get_nth_item (browser->trash, last);
katze_array_remove_item (browser->trash, item); midori_browser_set_current_page (browser,
n = midori_browser_add_item (browser, item); midori_browser_restore_tab (browser, item));
midori_browser_set_current_page (browser, n);
} }
static void static void