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.
This commit is contained in:
Christian Dywan 2009-03-07 14:00:14 +01:00
parent aa181a4a6f
commit 1af23afbe8
3 changed files with 27 additions and 12 deletions

View file

@ -762,7 +762,7 @@ midori_history_add_items (void* data,
katze_item_set_added (KATZE_ITEM (parent), day); katze_item_set_added (KATZE_ITEM (parent), day);
strftime (token, sizeof (token), "%x", strftime (token, sizeof (token), "%x",
localtime ((time_t *)&date)); 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 (array, parent);
} }
katze_array_add_item (parent, item); katze_array_add_item (parent, item);

View file

@ -1796,8 +1796,9 @@ midori_browser_toolbar_popup_context_menu_cb (GtkWidget* widget,
{ {
GtkAction* widget_action = gtk_widget_get_action (widget); GtkAction* widget_action = gtk_widget_get_action (widget);
const gchar* actions[] = { "TabNew", "Open", "SaveAs", "Print", "Find", const gchar* actions[] = { "TabNew", "Open", "SaveAs", "Print", "Find",
"Preferences", "Window", "Bookmarks", "ReloadStop", "ZoomIn", "Separator", "Preferences", "Window", "Bookmarks", "RecentlyVisited",
"ZoomOut", "Back", "Forward", "Homepage", "Panel", "Trash", "Search" }; "ReloadStop", "ZoomIn", "Separator", "ZoomOut", "Back", "Forward",
"Homepage", "Panel", "Trash", "Search" };
GtkWidget* submenu; GtkWidget* submenu;
gsize i; gsize i;
@ -3336,7 +3337,7 @@ static const gchar* ui_markup =
"<menuitem action='Location'/>" "<menuitem action='Location'/>"
"<menuitem action='Search'/>" "<menuitem action='Search'/>"
"<menuitem action='Trash'/>" "<menuitem action='Trash'/>"
/* "<menuitem action='RecentlyVisited'/>" */ "<menuitem action='RecentlyVisited'/>"
"</menu>" "</menu>"
"<menuitem action='Bookmarks'/>" "<menuitem action='Bookmarks'/>"
"<menu action='Tools'>" "<menu action='Tools'>"
@ -3431,7 +3432,7 @@ midori_browser_new_history_item (MidoriBrowser* browser,
strftime (token, sizeof (token), "%x", localtime (&now)); strftime (token, sizeof (token), "%x", localtime (&now));
parent = katze_array_new (KATZE_TYPE_ARRAY); parent = katze_array_new (KATZE_TYPE_ARRAY);
katze_item_set_added (KATZE_ITEM (parent), day); 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 (browser->history, parent);
katze_array_add_item (parent, item); katze_array_add_item (parent, item);
} }
@ -3442,12 +3443,18 @@ midori_browser_history_remove_item_cb (KatzeArray* folder,
KatzeItem* item, KatzeItem* item,
MidoriBrowser* browser) 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_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, g_signal_handlers_disconnect_by_func (folder,
midori_browser_history_remove_item_cb, midori_browser_history_remove_item_cb,
browser); 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 static void
@ -3487,12 +3494,15 @@ midori_browser_history_clear_cb (KatzeArray* history,
{ {
GtkAction* location_action = _action_by_name (browser, "Location"); GtkAction* location_action = _action_by_name (browser, "Location");
midori_location_action_clear (MIDORI_LOCATION_ACTION (location_action)); midori_location_action_clear (MIDORI_LOCATION_ACTION (location_action));
g_object_set (_action_by_name (browser, "RecentlyVisited"),
"array", NULL, NULL);
} }
static void static void
midori_browser_set_history (MidoriBrowser* browser, midori_browser_set_history (MidoriBrowser* browser,
KatzeArray* history) KatzeArray* history)
{ {
KatzeItem* recently_visited;
GtkAction* action; GtkAction* action;
time_t now; time_t now;
gint64 day; gint64 day;
@ -3508,12 +3518,17 @@ midori_browser_set_history (MidoriBrowser* browser,
g_object_ref (history); g_object_ref (history);
katze_object_assign (browser->history, 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"), if (history && ((recently_visited = katze_array_get_nth_item (history,
"array", browser->history, NULL); 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; return;
g_signal_connect (browser->history, "clear", g_signal_connect (browser->history, "clear",

View file

@ -596,7 +596,7 @@ midori_history_treeview_render_text_cb (GtkTreeViewColumn* column,
if (age > 7) 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) else if (age > 6)
{ {