]> spindle.queued.net Git - midori/commitdiff
Implement Last Visited Pages menu and toolbar item
authorChristian Dywan <christian@twotoasts.de>
Sat, 7 Mar 2009 13:00:14 +0000 (14:00 +0100)
committerChristian Dywan <christian@twotoasts.de>
Sat, 7 Mar 2009 13:00:14 +0000 (14:00 +0100)
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.

midori/main.c
midori/midori-browser.c
panels/midori-history.c

index 05f6d149cf6d7eb43588b8b5e5f7b50d152f972a..b5849c1c7ddb5f21c2fdb7d53e31ee0d90c61f8c 100644 (file)
@@ -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);
index 8bfa767d47396c74193b20f9e555c3475d560ae8..1b13ee3722420eca34dd21404fecfc75d222902a 100644 (file)
@@ -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 =
     "<menuitem action='Location'/>"
     "<menuitem action='Search'/>"
     "<menuitem action='Trash'/>"
-    /* "<menuitem action='RecentlyVisited'/>" */
+    "<menuitem action='RecentlyVisited'/>"
    "</menu>"
    "<menuitem action='Bookmarks'/>"
    "<menu action='Tools'>"
@@ -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",
index 3ef50bbad55222ff300eeab2219bd8d0bd75ec78..b3687fcd79de7943eb95673a9c05f3e91735a0df 100644 (file)
@@ -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)
         {