From: Christian Dywan Date: Sat, 7 Mar 2009 13:00:14 +0000 (+0100) Subject: Implement Last Visited Pages menu and toolbar item X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1af23afbe8bb0a8b736ee1f410ee700f14dbbccd;p=midori Implement Last Visited Pages menu and toolbar item We use the name of history folders now to store dates instead of the token. This makes it possible to show history in an action. --- diff --git a/midori/main.c b/midori/main.c index 05f6d149..b5849c1c 100644 --- a/midori/main.c +++ b/midori/main.c @@ -762,7 +762,7 @@ midori_history_add_items (void* data, katze_item_set_added (KATZE_ITEM (parent), day); strftime (token, sizeof (token), "%x", localtime ((time_t *)&date)); - katze_item_set_token (KATZE_ITEM (parent), token); + katze_item_set_name (KATZE_ITEM (parent), token); katze_array_add_item (array, parent); } katze_array_add_item (parent, item); diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 8bfa767d..1b13ee37 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -1796,8 +1796,9 @@ midori_browser_toolbar_popup_context_menu_cb (GtkWidget* widget, { GtkAction* widget_action = gtk_widget_get_action (widget); const gchar* actions[] = { "TabNew", "Open", "SaveAs", "Print", "Find", - "Preferences", "Window", "Bookmarks", "ReloadStop", "ZoomIn", "Separator", - "ZoomOut", "Back", "Forward", "Homepage", "Panel", "Trash", "Search" }; + "Preferences", "Window", "Bookmarks", "RecentlyVisited", + "ReloadStop", "ZoomIn", "Separator", "ZoomOut", "Back", "Forward", + "Homepage", "Panel", "Trash", "Search" }; GtkWidget* submenu; gsize i; @@ -3336,7 +3337,7 @@ static const gchar* ui_markup = "" "" "" - /* "" */ + "" "" "" "" @@ -3431,7 +3432,7 @@ midori_browser_new_history_item (MidoriBrowser* browser, strftime (token, sizeof (token), "%x", localtime (&now)); parent = katze_array_new (KATZE_TYPE_ARRAY); katze_item_set_added (KATZE_ITEM (parent), day); - katze_item_set_token (KATZE_ITEM (parent), token); + katze_item_set_name (KATZE_ITEM (parent), token); katze_array_add_item (browser->history, parent); katze_array_add_item (parent, item); } @@ -3442,12 +3443,18 @@ midori_browser_history_remove_item_cb (KatzeArray* folder, KatzeItem* item, MidoriBrowser* browser) { - GtkAction* location_action = _action_by_name (browser, "Location"); + GtkAction* action; + + action = _action_by_name (browser, "Location"); midori_location_action_delete_item_from_uri ( - MIDORI_LOCATION_ACTION (location_action), katze_item_get_uri (item)); + MIDORI_LOCATION_ACTION (action), katze_item_get_uri (item)); g_signal_handlers_disconnect_by_func (folder, midori_browser_history_remove_item_cb, browser); + + action = _action_by_name (browser, "RecentlyVisited"); + if ((KatzeArray*)item == katze_array_action_get_array (KATZE_ARRAY_ACTION (action))) + g_object_set (action, "array", NULL, NULL); } static void @@ -3487,12 +3494,15 @@ midori_browser_history_clear_cb (KatzeArray* history, { GtkAction* location_action = _action_by_name (browser, "Location"); midori_location_action_clear (MIDORI_LOCATION_ACTION (location_action)); + g_object_set (_action_by_name (browser, "RecentlyVisited"), + "array", NULL, NULL); } static void midori_browser_set_history (MidoriBrowser* browser, KatzeArray* history) { + KatzeItem* recently_visited; GtkAction* action; time_t now; gint64 day; @@ -3508,12 +3518,17 @@ midori_browser_set_history (MidoriBrowser* browser, g_object_ref (history); katze_object_assign (browser->history, history); - midori_browser_history_clear_cb (browser->history, browser); + midori_browser_history_clear_cb (history, browser); - g_object_set (_action_by_name (browser, "RecentlyVisited"), - "array", browser->history, NULL); + if (history && ((recently_visited = katze_array_get_nth_item (history, + katze_array_get_length (KATZE_ARRAY (history)) - 1)))) + g_object_set (_action_by_name (browser, "RecentlyVisited"), + "array", recently_visited, NULL); + else + g_object_set (_action_by_name (browser, "RecentlyVisited"), + "array", NULL, NULL); - if (!browser->history) + if (!history) return; g_signal_connect (browser->history, "clear", diff --git a/panels/midori-history.c b/panels/midori-history.c index 3ef50bba..b3687fcd 100644 --- a/panels/midori-history.c +++ b/panels/midori-history.c @@ -596,7 +596,7 @@ midori_history_treeview_render_text_cb (GtkTreeViewColumn* column, if (age > 7) { - g_object_set (renderer, "text", katze_item_get_token (item), NULL); + g_object_set (renderer, "text", katze_item_get_name (item), NULL); } else if (age > 6) {