2008-01-27 Jan Michael Alonzo <jmalonzo@unpluggable.com>
authoralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Jan 2008 19:49:01 +0000 (19:49 +0000)
committeralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Jan 2008 19:49:01 +0000 (19:49 +0000)
        Reviewed by Alp Toker.

        http://bugs.webkit.org/show_bug.cgi?id=14811
        [gtk] [request] add a webkit_gtk_page_go_to_history_item function

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29821 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
ChangeLog
GNUmakefile.am
WebCore/ChangeLog
WebCore/WebCore.pro
WebKit/gtk/ChangeLog
WebKit/gtk/WebView/headers.pri
WebKit/gtk/WebView/webkit.h
WebKit/gtk/WebView/webkitprivate.cpp
WebKit/gtk/WebView/webkitprivate.h
WebKit/gtk/WebView/webkitwebbackforwardlist.cpp [new file with mode: 0644]
WebKit/gtk/WebView/webkitwebbackforwardlist.h [new file with mode: 0644]
WebKit/gtk/WebView/webkitwebhistoryitem.cpp [new file with mode: 0644]
WebKit/gtk/WebView/webkitwebhistoryitem.h [new file with mode: 0644]
WebKit/gtk/WebView/webkitwebview.cpp
WebKit/gtk/WebView/webkitwebview.h

index 5d0dd1a..779b920 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-01-27  Jan Michael Alonzo  <jmalonzo@unpluggable.com>
+
+        Reviewed by Alp Toker.
+
+        http://bugs.webkit.org/show_bug.cgi?id=14811
+        [gtk] [request] add a webkit_gtk_page_go_to_history_item function
+
+        * GNUmakefile.am: Added webkitwebbackforwardlist and webkitwebhistoryitem
+
 2008-01-26  Mark Rowe  <mrowe@apple.com>
 
         Reviewed by Alp Toker.
index 80bd778..c2a4d3a 100644 (file)
@@ -237,7 +237,9 @@ webkitgtk_h_api += \
        WebKit/gtk/WebView/webkit.h \
        WebKit/gtk/WebView/webkitdefines.h \
        WebKit/gtk/WebView/webkitnetworkrequest.h \
+       WebKit/gtk/WebView/webkitwebbackforwardlist.h \
        WebKit/gtk/WebView/webkitwebframe.h \
+       WebKit/gtk/WebView/webkitwebhistoryitem.h \
        WebKit/gtk/WebView/webkitwebsettings.h \
        WebKit/gtk/WebView/webkitwebview.h 
 
@@ -258,7 +260,9 @@ webkitgtk_headers += \
 webkitgtk_sources += \
        WebKit/gtk/WebView/webkitnetworkrequest.cpp \
        WebKit/gtk/WebView/webkitprivate.cpp \
+       WebKit/gtk/WebView/webkitwebbackforwardlist.cpp \
        WebKit/gtk/WebView/webkitwebframe.cpp \
+       WebKit/gtk/WebView/webkitwebhistoryitem.cpp \
        WebKit/gtk/WebView/webkitwebsettings.cpp \
        WebKit/gtk/WebView/webkitwebview.cpp \
        WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp \
index 81e0024..a4699c5 100644 (file)
@@ -1,3 +1,14 @@
+2008-01-27  Jan Michael Alonzo  <jmalonzo@unpluggable.com>
+
+        Reviewed by Alp Toker.
+
+        http://bugs.webkit.org/show_bug.cgi?id=14811
+        [gtk] [request] add a webkit_gtk_page_go_to_history_item function
+
+        Added webkit/gtk webkitwebbackforwardlist and webkitwebhistoryitem
+
+        * WebCore.pro:
+
 2008-01-27  Matt Perry  <mpComplete@gmail.com>
 
         Reviewed and tweaked quite a bit by Darin.
index 2d615e9..8a16838 100644 (file)
@@ -989,7 +989,9 @@ gtk-port {
         ../WebKit/gtk/WebView/webkitdefines.h \
         ../WebKit/gtk/WebView/webkitnetworkrequest.h \
         ../WebKit/gtk/WebView/webkitprivate.h \
+        ../WebKit/gtk/WebView/webkitwebbackforwardlist.h \
         ../WebKit/gtk/WebView/webkitwebframe.h \
+        ../WebKit/gtk/WebView/webkitwebhistoryitem.h \
         ../WebKit/gtk/WebView/webkitwebsettings.h \
         ../WebKit/gtk/WebView/webkitwebview.h \
         ../WebKit/gtk/WebCoreSupport/ChromeClientGtk.h \
@@ -1066,7 +1068,9 @@ gtk-port {
         platform/image-decoders/xbm/XBMImageDecoder.cpp \
         ../WebKit/gtk/WebView/webkitnetworkrequest.cpp \
         ../WebKit/gtk/WebView/webkitprivate.cpp \
+        ../WebKit/gtk/WebView/webkitwebbackforwardlist.cpp \
         ../WebKit/gtk/WebView/webkitwebframe.cpp \
+        ../WebKit/gtk/WebView/webkitwebhistoryitem.cpp \
         ../WebKit/gtk/WebView/webkitwebsettings.cpp \
         ../WebKit/gtk/WebView/webkitwebview.cpp \
         ../WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp \
index f23cd4e..d5aba3a 100644 (file)
@@ -1,3 +1,59 @@
+2008-01-27  Jan Michael Alonzo  <jmalonzo@unpluggable.com>
+
+        Reviewed by Alp Toker.
+
+        http://bugs.webkit.org/show_bug.cgi?id=14811
+        [gtk] [request] add a webkit_gtk_page_go_to_history_item function
+
+        implement back/forward list and history item
+
+        * WebView/headers.pri:
+        * WebView/webkit.h:
+        * WebView/webkitprivate.cpp:
+        * WebView/webkitprivate.h:
+        * WebView/webkitwebbackforwardlist.cpp: Added.
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_dispose):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_class_init):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_init):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_new_with_web_view):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_go_forward):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_go_back):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_contains_item):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_go_to_item):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_forward_list_with_limit):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_back_list_with_limit):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_back_item):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_current_item):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_forward_item):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_nth_item):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_back_length):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_forward_length):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_limit):
+        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_set_limit):
+        * WebView/webkitwebbackforwardlist.h: Added.
+        * WebView/webkitwebhistoryitem.cpp: Added.
+        (_WebKitWebHistoryItemPrivate::webkit_history_items):
+        (_WebKitWebHistoryItemPrivate::webkit_history_item_add):
+        (_WebKitWebHistoryItemPrivate::webkit_history_item_remove):
+        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_dispose):
+        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_finalize):
+        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_class_init):
+        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_init):
+        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new_with_core_item):
+        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new):
+        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new_with_data):
+        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_title):
+        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_alternate_title):
+        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_set_alternate_title):
+        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_uri):
+        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_original_uri):
+        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_last_visited_time):
+        (WebKit::core):
+        (WebKit::kit):
+        * WebView/webkitwebhistoryitem.h: Added.
+        * WebView/webkitwebview.cpp:
+        * WebView/webkitwebview.h:
+
 2008-01-25  Ori Bernstein  <ori@eigenstate.org>
 
         Reviewed by Alp Toker.
index e99765a..d53d825 100644 (file)
@@ -1,6 +1,8 @@
 WEBKIT_API_HEADERS = $$PWD/webkit.h \
                      $$PWD/webkitdefines.h \
                      $$PWD/webkitnetworkrequest.h \
+                     $$PWD/webkitwebbackforwardlist.h \
                      $$PWD/webkitwebframe.h \
+                     $$PWD/webkitwebhistoryitem.h \
                      $$PWD/webkitwebsettings.h \
                      $$PWD/webkitwebview.h
index 2e7cd9d..4412cf6 100644 (file)
@@ -25,5 +25,7 @@
 #include <webkitwebframe.h>
 #include <webkitwebsettings.h>
 #include <webkitwebview.h>
+#include <webkitwebbackforwardlist.h>
+#include <webkitwebhistoryitem.h>
 
 #endif /* __WEBKIT_H__ */
index dc2b6f7..3ddcc49 100644 (file)
@@ -80,7 +80,7 @@ WebKitWebView* kit(WebCore::Page* corePage)
     return client ? client->webView() : 0;
 }
 
-}
+} /** end namespace WebCore */
 
 void webkit_init()
 {
index 3e1aee7..3443cd4 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2007 Holger Hans Peter Freyther
+ * Copyrifht (C) 2008 Jan Michael C. Alonzo
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #include "webkitwebframe.h"
 #include "webkitwebsettings.h"
 #include "webkitnetworkrequest.h"
+#include "webkitwebbackforwardlist.h"
 
+#include "BackForwardList.h"
+#include "HistoryItem.h"
 #include "Settings.h"
 #include "Page.h"
 #include "Frame.h"
 #include "FrameLoaderClient.h"
 
+#include <glib.h>
+
 namespace WebKit {
     WebKitWebView* getViewFromFrame(WebKitWebFrame*);
 
     WebCore::Frame* core(WebKitWebFrame*);
     WebKitWebFrame* kit(WebCore::Frame*);
+
     WebCore::Page* core(WebKitWebView*);
     WebKitWebView* kit(WebCore::Page*);
+
+    WebCore::HistoryItem* core(WebKitWebHistoryItem*);
+    WebKitWebHistoryItem* kit(WebCore::HistoryItem*);
+
+    WebCore::BackForwardList* core(WebKitWebBackForwardList*);
 }
 
 extern "C" {
@@ -62,6 +74,8 @@ extern "C" {
         WebCore::String applicationNameForUserAgent;
         WebCore::String* userAgent;
 
+        WebKitWebBackForwardList* backForwardList;
+        
         gint lastPopupXPosition;
         gint lastPopupYPosition;
 
@@ -91,8 +105,13 @@ extern "C" {
         gchar* uri;
     };
 
+    /* WebKitWebFrame private function */
     WebKitWebFrame* webkit_web_frame_init_with_web_view(WebKitWebView*, WebCore::HTMLFrameOwnerElement*);
 
+    /* WebKitWebHistoryItem private function */
+    WebKitWebHistoryItem* webkit_web_history_item_new_with_core_item(WebCore::HistoryItem*);
+    
+
     // TODO: Move these to webkitwebframe.h once these functions are fully
     // implemented and their API has been discussed.
 
diff --git a/WebKit/gtk/WebView/webkitwebbackforwardlist.cpp b/WebKit/gtk/WebView/webkitwebbackforwardlist.cpp
new file mode 100644 (file)
index 0000000..830e52b
--- /dev/null
@@ -0,0 +1,378 @@
+/*
+ * Copyright (C) 2008 Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "webkitwebbackforwardlist.h"
+#include "webkitprivate.h"
+#include "webkitwebhistoryitem.h"
+#include "webkitwebview.h"
+
+#include <glib.h>
+
+#include "BackForwardList.h"
+#include "HistoryItem.h"
+
+using namespace WebKit;
+
+extern "C" {
+
+struct _WebKitWebBackForwardListPrivate {
+    WebCore::BackForwardList* backForwardList;
+};
+
+#define WEBKIT_WEB_BACK_FORWARD_LIST_GET_PRIVATE(obj)    (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_BACK_FORWARD_LIST, WebKitWebBackForwardListPrivate))
+
+G_DEFINE_TYPE(WebKitWebBackForwardList, webkit_web_back_forward_list, G_TYPE_OBJECT);
+
+static void webkit_web_back_forward_list_class_init(WebKitWebBackForwardListClass* klass)
+{
+    g_type_class_add_private(klass, sizeof(WebKitWebBackForwardListPrivate));
+}
+
+static void webkit_web_back_forward_list_init(WebKitWebBackForwardList* webBackForwardList)
+{
+    webBackForwardList->priv = WEBKIT_WEB_BACK_FORWARD_LIST_GET_PRIVATE(webBackForwardList);
+}
+
+/**
+ * webkit_web_back_forward_list_new_with_web_view:
+ * @webView: the back forward list's #WebKitWebView
+ * 
+ * Creates an instance of the back forward list with a controlling #WebKitWebView
+ *
+ * Return value: a #WebKitWebBackForwardList
+ */
+WebKitWebBackForwardList* webkit_web_back_forward_list_new_with_web_view(WebKitWebView* webView)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL);
+
+    WebKitWebViewPrivate* webViewData = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
+    WebKitWebBackForwardList* webBackForwardList;
+
+    webBackForwardList = WEBKIT_WEB_BACK_FORWARD_LIST(g_object_new(WEBKIT_TYPE_WEB_BACK_FORWARD_LIST, NULL));
+    webBackForwardList->priv->backForwardList = webViewData->corePage->backForwardList();
+    webBackForwardList->priv->backForwardList->setEnabled(TRUE);
+
+    return webBackForwardList;
+}
+
+/**
+ * webkit_web_back_forward_list_go_forward:
+ * @webBackForwardList: a #WebKitWebBackForwardList
+ *
+ * Steps forward in the back forward list
+ */
+void webkit_web_back_forward_list_go_forward(WebKitWebBackForwardList* webBackForwardList)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList));
+
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+    if (backForwardList->enabled())
+        backForwardList->goForward();
+}
+
+/**
+ * webkit_web_back_forward_list_go_back:
+ * @webBackForwardList: a #WebKitWebBackForwardList
+ *
+ * Steps backward in the back forward list
+ */
+void webkit_web_back_forward_list_go_back(WebKitWebBackForwardList* webBackForwardList)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList));
+
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+    if (backForwardList->enabled())
+        backForwardList->goBack();
+}
+
+/**
+ * webkit_web_back_forward_list_contains_item:
+ * @webBackForwardList: a #WebKitWebBackForwardList
+ * @webHistoryItem: the #WebKitWebHistoryItem to check
+ *
+ * Checks if @webHistoryItem is in the back forward list
+ *
+ * Return: %TRUE if @webHistoryItem is in the back forward list, %FALSE if it doesn't
+ */
+gboolean webkit_web_back_forward_list_contains_item(WebKitWebBackForwardList* webBackForwardList, WebKitWebHistoryItem* webHistoryItem)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList), NULL);
+    g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);
+    
+    WebCore::HistoryItem* historyItem = core(webHistoryItem);
+
+    g_return_val_if_fail(historyItem != NULL, FALSE);
+    
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+
+    return (backForwardList->enabled() ? backForwardList->containsItem(historyItem) : FALSE);
+}
+
+/**
+ * webkit_web_back_forward_list_go_to_item:
+ * @webBackForwardList: a #WebKitWebBackForwardList
+ * @webHistoryItem: the #WebKitWebHistoryItem to go to
+ *
+ * Go to the specified @webHistoryItem in the back forward list
+ */
+void webkit_web_back_forward_list_go_to_item(WebKitWebBackForwardList* webBackForwardList, WebKitWebHistoryItem* webHistoryItem)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList));
+    g_return_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem));
+
+    WebCore::HistoryItem* historyItem = core(webHistoryItem);
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+
+    if (backForwardList->enabled() && historyItem)
+        backForwardList->goToItem(historyItem);
+}
+
+/**
+ * webkit_web_back_forward_list_get_forward_list_with_limit:
+ * @webBackForwardList: a #WebKitWebBackForwardList
+ * @limit: the number of items to retrieve
+ *
+ * Returns a list of items that succeed the current item, limited by @limit
+ *
+ * Return value: a #GList of items succeeding the current item, limited by @limit
+ */
+GList* webkit_web_back_forward_list_get_forward_list_with_limit(WebKitWebBackForwardList* webBackForwardList, gint limit)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList), NULL);
+
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+    if (!backForwardList || !backForwardList->enabled())
+        return NULL;
+
+    WebCore::HistoryItemVector items(limit);
+    GList* forwardItems = { 0 };
+    
+    backForwardList->forwardListWithLimit(limit, items);
+   
+    for (unsigned i = 0; i < items.size(); i++) {
+        WebKitWebHistoryItem* webHistoryItem = webkit_web_history_item_new_with_core_item(items[i].get());
+        forwardItems = g_list_prepend(forwardItems, g_object_ref(webHistoryItem));
+    }
+
+    return g_list_reverse(forwardItems);
+}
+
+/**
+ * webkit_web_back_forward_list_get_back_list_with_limit:
+ * @webBackForwardList: a #WebKitWebBackForwardList
+ * @limit: the number of items to retrieve
+ *
+ * Returns a list of items that precede the current item, limited by @limit
+ *
+ * Return value: a #GList of items preceding the current item, limited by @limit
+ */
+GList* webkit_web_back_forward_list_get_back_list_with_limit(WebKitWebBackForwardList* webBackForwardList, gint limit)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList), NULL);
+
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+    if (!backForwardList || !backForwardList->enabled())
+        return NULL;
+
+    WebCore::HistoryItemVector items(limit);
+    GList* backItems = { 0 };
+
+    backForwardList->backListWithLimit(limit, items);
+
+    for (unsigned i = 0; i < items.size(); i++) {
+        WebKitWebHistoryItem* webHistoryItem = webkit_web_history_item_new_with_core_item(items[i].get());
+        backItems = g_list_prepend(backItems, g_object_ref(webHistoryItem));
+    }
+
+    return g_list_reverse(backItems);
+}
+/**
+ * webkit_web_back_forward_list_get_back_item:
+ * @webBackForwardList: a #WebBackForwardList
+ *
+ * Returns the item that precedes the current item
+ *
+ * Return value: the #WebKitWebHistoryItem preceding the current item
+ */
+WebKitWebHistoryItem* webkit_web_back_forward_list_get_back_item(WebKitWebBackForwardList* webBackForwardList)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList), NULL);
+
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+    if (!backForwardList || !backForwardList->enabled())
+        return NULL;
+    
+    WebCore::HistoryItem* historyItem = backForwardList->backItem();
+
+    return (historyItem ? kit(historyItem) : NULL);
+}
+
+/**
+ * webkit_web_back_forward_list_get_current_item:
+ * @webBackForwardList: a #WebKitWebBackForwardList
+ *
+ * Returns the current item.
+ *
+ * Returns a NULL value if the back forward list is empty
+ *
+ * Return value: a #WebKitWebHistoryItem
+ */
+WebKitWebHistoryItem* webkit_web_back_forward_list_get_current_item(WebKitWebBackForwardList* webBackForwardList)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList), NULL);
+
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+    if (!backForwardList || !backForwardList->enabled())
+        return NULL;
+
+    WebCore::HistoryItem* historyItem = backForwardList->currentItem();
+
+    return (historyItem ? kit(historyItem) : NULL);
+}
+
+/**
+ * webkit_web_back_forward_list_get_forward_item:
+ * @webBackForwardList: a #WebKitWebBackForwardList
+ *
+ * Returns the item that succeeds the current item.
+ *
+ * Returns a NULL value if there nothing that succeeds the current item
+ *
+ * Return value: a #WebKitWebHistoryItem
+ */    
+WebKitWebHistoryItem* webkit_web_back_forward_list_get_forward_item(WebKitWebBackForwardList* webBackForwardList)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList), NULL);
+
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+    if (!backForwardList || !backForwardList->enabled())
+        return NULL;
+
+    WebCore::HistoryItem* historyItem = backForwardList->forwardItem();
+
+    return (historyItem ? kit(historyItem) : NULL);
+}
+
+/**
+ * webkit_web_back_forward_list_get_nth_item:
+ * @webBackForwardList: a #WebKitWebBackForwardList
+ * @index: the index of the item
+ *
+ * Returns the item at a given index relative to the current item.
+ *
+ * Return value: the #WebKitWebHistoryItem located at the specified index relative to the current item
+ */
+WebKitWebHistoryItem* webkit_web_back_forward_list_get_nth_item(WebKitWebBackForwardList* webBackForwardList, gint index)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList), NULL);
+
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+    if (!backForwardList)
+        return NULL;
+
+    WebCore::HistoryItem* historyItem = backForwardList->itemAtIndex(index);
+
+    return (historyItem ? kit(historyItem) : NULL);
+}
+
+/**
+ * webkit_web_back_forward_list_get_back_length:
+ * @webBackForwardList: a #WebKitWebBackForwardList
+ *
+ * Returns the number of items that preced the current item.
+ *
+ * Return value: a #gint corresponding to the number of items preceding the current item
+ */
+gint webkit_web_back_forward_list_get_back_length(WebKitWebBackForwardList* webBackForwardList)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList), NULL);
+
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+    if (!backForwardList || !backForwardList->enabled())
+        return 0;
+
+    return backForwardList->backListCount();
+}
+    
+/**
+ * webkit_web_back_forward_list_get_forward_length:
+ * @webBackForwardList: a #WebKitWebBackForwardList
+ *
+ * Returns the number of items that succeed the current item.
+ *
+ * Return value: a #gint corresponding to the nuber of items succeeding the current item
+ */
+gint webkit_web_back_forward_list_get_forward_length(WebKitWebBackForwardList* webBackForwardList)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList), NULL);
+
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+    if (!backForwardList || !backForwardList->enabled())
+        return 0;
+    
+    return backForwardList->forwardListCount();
+}
+
+/**
+ * webkit_web_back_forward_list_get_capacity:
+ * @webBackForwardList: a #WebKitWebBackForwardList
+ *
+ * Returns the maximum limit of the back forward list.
+ *
+ * Return value: a #gint indicating the number of #WebHistoryItem the back forward list can hold
+ */
+gint webkit_web_back_forward_list_get_limit(WebKitWebBackForwardList* webBackForwardList)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList), NULL);
+
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+    if (!backForwardList || !backForwardList->enabled())
+        return 0;
+
+    return backForwardList->capacity();
+}
+    
+/**
+ * webkit_web_back_forward_list_set_limit:
+ * @webBackForwardList: a #WebKitWebBackForwardList
+ * @limit: the limit to set the back forward list to
+ *
+ * Sets the maximum limit of the back forward list. If the back forward list
+ * exceeds its capacity, items will be removed everytime a new item has been
+ * added.
+ */
+void webkit_web_back_forward_list_set_limit(WebKitWebBackForwardList* webBackForwardList, gint limit)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList));
+
+    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
+    if (backForwardList)
+        backForwardList->setCapacity(limit);
+}
+    
+} /* end extern "C" */
+
+WebCore::BackForwardList* WebKit::core(WebKitWebBackForwardList* webBackForwardList)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList), NULL);
+
+    return webBackForwardList->priv ? webBackForwardList->priv->backForwardList : 0;
+}
diff --git a/WebKit/gtk/WebView/webkitwebbackforwardlist.h b/WebKit/gtk/WebView/webkitwebbackforwardlist.h
new file mode 100644 (file)
index 0000000..61fe9cf
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2008 Jan Michael C. Alonzo <jmalonzo@unpluggable.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WEBKIT_WEB_BACK_FORWARD_LIST_H
+#define WEBKIT_WEB_BACK_FORWARD_LIST_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "webkitdefines.h"
+#include "webkitwebhistoryitem.h"
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_BACK_FORWARD_LIST            (webkit_web_back_forward_list_get_type())
+#define WEBKIT_WEB_BACK_FORWARD_LIST(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_BACK_FORWARD_LIST, WebKitWebBackForwardList))
+#define WEBKIT_WEB_BACK_FORWARD_LIST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_WEB_BACK_FORWARD_LIST, WebKitWebBackForwardListClass))
+#define WEBKIT_IS_WEB_BACK_FORWARD_LIST(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_BACK_FORWARD_LIST))
+#define WEBKIT_IS_WEB_BACK_FORWARD_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_WEB_BACK_FORWARD_LIST))
+#define WEBKIT_WEB_BACK_FORWARD_LIST_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_WEB_BACK_FORWARD_LIST, WebKitWebBackForwardListClass))
+
+
+typedef struct _WebKitWebBackForwardListPrivate WebKitWebBackForwardListPrivate;
+typedef struct _WebKitWebBackForwardList WebKitWebBackForwardList;
+typedef struct _WebKitWebBackForwardListClass WebKitWebBackForwardListClass;
+
+
+struct _WebKitWebBackForwardList {
+    GObject parent;
+
+    /*< private >*/
+    WebKitWebBackForwardListPrivate *priv;
+};
+
+struct _WebKitWebBackForwardListClass {
+    GObjectClass parent;
+};
+
+WEBKIT_API GType
+webkit_web_back_forward_list_get_type (void);
+
+WEBKIT_API WebKitWebBackForwardList*
+webkit_web_back_forward_list_new_with_web_view (WebKitWebView* web_view);
+
+WEBKIT_API void
+webkit_web_back_forward_list_go_forward (WebKitWebBackForwardList* web_back_forward_list);
+
+WEBKIT_API void
+webkit_web_back_forward_list_go_back (WebKitWebBackForwardList* web_back_forward_list);
+
+WEBKIT_API gboolean
+webkit_web_back_forward_list_contains_item (WebKitWebBackForwardList* web_back_forward_list, WebKitWebHistoryItem* history_item);
+
+WEBKIT_API void
+webkit_web_back_forward_list_go_to_item (WebKitWebBackForwardList* web_back_forward_list, WebKitWebHistoryItem* history_item);
+
+WEBKIT_API GList*
+webkit_web_back_forward_list_get_forward_list_with_limit (WebKitWebBackForwardList* web_back_forward_list, gint limit);
+
+WEBKIT_API GList*
+webkit_web_back_forward_list_get_back_list_with_limit (WebKitWebBackForwardList* web_back_forward_list, gint limit);
+
+WEBKIT_API WebKitWebHistoryItem*
+webkit_web_back_forward_list_get_back_item (WebKitWebBackForwardList* web_back_forward_list);
+
+WEBKIT_API WebKitWebHistoryItem*
+webkit_web_back_forward_list_get_current_item (WebKitWebBackForwardList* web_back_forward_list);
+
+WEBKIT_API WebKitWebHistoryItem*
+webkit_web_back_forward_list_get_forward_item (WebKitWebBackForwardList* web_back_forward_list);
+
+WEBKIT_API WebKitWebHistoryItem*
+webkit_web_back_forward_list_get_nth_item (WebKitWebBackForwardList* web_back_forward_list, gint index);
+
+WEBKIT_API gint
+webkit_web_back_forward_list_get_back_length (WebKitWebBackForwardList* web_back_forward_list);
+
+WEBKIT_API gint
+webkit_web_back_forward_list_get_forward_length (WebKitWebBackForwardList* web_back_forward_list);
+
+WEBKIT_API gint
+webkit_web_back_forward_list_get_limit (WebKitWebBackForwardList* web_back_forward_list);
+
+WEBKIT_API void
+webkit_web_back_forward_list_set_limit (WebKitWebBackForwardList* web_back_forward_list, gint limit);
+
+G_END_DECLS
+
+
+#endif /* WEBKIT_WEB_BACK_FORWARD_LIST_H */
diff --git a/WebKit/gtk/WebView/webkitwebhistoryitem.cpp b/WebKit/gtk/WebView/webkitwebhistoryitem.cpp
new file mode 100644 (file)
index 0000000..2dca2b2
--- /dev/null
@@ -0,0 +1,334 @@
+/*
+ * Copyright (C) 2008 Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#include "config.h"
+
+#include "webkitwebhistoryitem.h"
+#include "webkitprivate.h"
+
+#include <glib.h>
+
+#include "CString.h"
+#include "HistoryItem.h"
+#include "PlatformString.h"
+
+using namespace WebKit;
+
+extern "C" {
+
+struct _WebKitWebHistoryItemPrivate {
+    WebCore::HistoryItem* historyItem;
+    
+    gchar* title;
+    gchar* alternateTitle;
+    gchar* uri;
+    gchar* originalUri;
+};
+
+#define WEBKIT_WEB_HISTORY_ITEM_GET_PRIVATE(obj)    (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_HISTORY_ITEM, WebKitWebHistoryItemPrivate))
+
+G_DEFINE_TYPE(WebKitWebHistoryItem, webkit_web_history_item, G_TYPE_OBJECT);
+
+
+static GHashTable* webkit_history_items()
+{
+    static GHashTable* historyItems = g_hash_table_new(g_direct_hash, g_direct_equal);   
+    return historyItems;
+}
+
+static void webkit_history_item_add(WebKitWebHistoryItem* webHistoryItem, WebCore::HistoryItem* historyItem) 
+{
+    g_return_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem));
+    
+    GHashTable* table = webkit_history_items();
+
+    historyItem->ref();
+    g_hash_table_insert(table, historyItem, g_object_ref(webHistoryItem));
+}
+
+static void webkit_history_item_remove(WebCore::HistoryItem* historyItem)
+{
+    GHashTable* table = webkit_history_items();
+    WebKitWebHistoryItem* webHistoryItem = (WebKitWebHistoryItem*) g_hash_table_lookup(table, historyItem);
+
+    g_return_if_fail(webHistoryItem != NULL);
+    
+    g_hash_table_remove(table, historyItem);
+    historyItem->deref();
+    g_object_unref(webHistoryItem);
+}
+    
+static void webkit_web_history_item_dispose(GObject* object)
+{
+    WebKitWebHistoryItem* item = WEBKIT_WEB_HISTORY_ITEM(object);
+
+    webkit_history_item_remove(item->priv->historyItem);
+    
+    delete item->priv->historyItem;
+
+    /* destroy table if empty */
+    GHashTable* table = webkit_history_items();
+    if (!g_hash_table_size(table))
+        g_hash_table_destroy(table);
+    
+    G_OBJECT_CLASS(webkit_web_history_item_parent_class)->dispose(object);
+}
+    
+
+static void webkit_web_history_item_finalize(GObject* object)
+{
+    WebKitWebHistoryItem* historyItem = WEBKIT_WEB_HISTORY_ITEM(object);
+
+    g_free(historyItem->priv->title);
+    g_free(historyItem->priv->alternateTitle);
+    g_free(historyItem->priv->uri);
+    g_free(historyItem->priv->originalUri);
+
+    G_OBJECT_CLASS(webkit_web_history_item_parent_class)->finalize(object);
+}
+
+static void webkit_web_history_item_class_init(WebKitWebHistoryItemClass* klass)
+{
+    GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
+
+    gobject_class->dispose = webkit_web_history_item_dispose;
+    gobject_class->finalize = webkit_web_history_item_finalize;
+
+    g_type_class_add_private(gobject_class, sizeof(WebKitWebHistoryItemPrivate));
+}
+
+static void webkit_web_history_item_init(WebKitWebHistoryItem* webHistoryItem)
+{
+    webHistoryItem->priv = WEBKIT_WEB_HISTORY_ITEM_GET_PRIVATE(webHistoryItem);
+}
+
+/* Helper function to create a new WebHistoryItem instance when needed */
+WebKitWebHistoryItem* webkit_web_history_item_new_with_core_item(WebCore::HistoryItem* item)
+{
+    WebKitWebHistoryItem* webHistoryItem = kit(item);
+
+    if (!webHistoryItem) {
+        webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(g_object_new(WEBKIT_TYPE_WEB_HISTORY_ITEM, NULL));
+        webHistoryItem->priv->historyItem = item;
+        webkit_history_item_add(webHistoryItem, webHistoryItem->priv->historyItem);
+    }
+
+    return webHistoryItem;
+}
+
+
+/**
+ * webkit_web_history_item_new:
+ *
+ * Creates a new #WebKitWebHistoryItem instance
+ *
+ * Return value: the new #WebKitWebHistoryItem
+ */
+WebKitWebHistoryItem* webkit_web_history_item_new(void)
+{
+    WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(g_object_new(WEBKIT_TYPE_WEB_HISTORY_ITEM, NULL));
+
+    webHistoryItem->priv->historyItem = new WebCore::HistoryItem();
+
+    webkit_history_item_add(webHistoryItem, webHistoryItem->priv->historyItem);
+
+    return webHistoryItem;
+}
+
+
+/**
+ * webkit_web_history_item_new_with_data:
+ * @uri: the uri of the page
+ * @title: the title of the page
+ *
+ * Creates a new #WebKitWebHistoryItem with the given URI and title
+ *
+ * Return value: the new #WebKitWebHistoryItem
+ */
+WebKitWebHistoryItem* webkit_web_history_item_new_with_data(const gchar* uri, const gchar* title)
+{
+    WebCore::KURL historyUri(uri);
+    WebCore::String historyTitle(title);
+
+    WebKitWebHistoryItem* webHistoryItem = webkit_web_history_item_new();
+
+    webHistoryItem->priv->historyItem = new WebCore::HistoryItem(historyUri, historyTitle);
+
+    webkit_history_item_add(webHistoryItem, webHistoryItem->priv->historyItem);
+        
+    return webHistoryItem;
+}
+
+/**
+ * webkit_web_history_item_get_title:
+ * @webHistoryItem: a #WebKitWebHistoryItem
+ *
+ * Returns the page title of @webHistoryItem
+ */
+const gchar* webkit_web_history_item_get_title(WebKitWebHistoryItem* webHistoryItem)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);
+
+    WebCore::HistoryItem* item = core(WEBKIT_WEB_HISTORY_ITEM(webHistoryItem));
+
+    g_return_val_if_fail(item != NULL, NULL);
+    
+    WebCore::String title = item->title();
+
+    g_free(webHistoryItem->priv->title);
+
+    webHistoryItem->priv->title = g_strdup(title.utf8().data());
+      
+    return webHistoryItem->priv->title;
+}
+
+/**
+ * webkit_web_history_item_get_alternate_title:
+ * @webHistoryItem: a #WebKitWebHistoryItem
+ *
+ * Returns the alternate title of @webHistoryItem
+ *
+ * Return value: the alternate title of @webHistoryItem
+ */
+const gchar* webkit_web_history_item_get_alternate_title(WebKitWebHistoryItem* webHistoryItem)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);
+
+    WebCore::HistoryItem* item = core(WEBKIT_WEB_HISTORY_ITEM(webHistoryItem));
+
+    g_return_val_if_fail(item != NULL, NULL);
+    
+    WebCore::String alternateTitle = item->alternateTitle();
+
+    g_free(webHistoryItem->priv->alternateTitle);
+
+    webHistoryItem->priv->alternateTitle = g_strdup(alternateTitle.utf8().data());
+
+    return webHistoryItem->priv->alternateTitle;
+}
+
+/**
+ * webkit_web_history_item_set_alternate_title:
+ * @webHistoryItem: a #WebKitWebHistoryItem
+ * @title: the alternate title for @this history item
+ *
+ * Sets an alternate title for @webHistoryItem
+ */
+void webkit_web_history_item_set_alternate_title(WebKitWebHistoryItem* webHistoryItem, const gchar* title) 
+{
+    g_return_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem));
+
+    WebCore::HistoryItem* item = core(WEBKIT_WEB_HISTORY_ITEM(webHistoryItem));
+
+    const WebCore::String alternateTitle = title;
+    item->setAlternateTitle(alternateTitle);
+}
+    
+/**
+ * webkit_web_history_item_get_uri:
+ * @webHistoryItem: a #WebKitWebHistoryItem
+ *
+ * Returns the URI of @this
+ *
+ * Return value: the URI of @webHistoryItem
+ */
+const gchar* webkit_web_history_item_get_uri(WebKitWebHistoryItem* webHistoryItem)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);
+
+    WebCore::HistoryItem* item = core(WEBKIT_WEB_HISTORY_ITEM(webHistoryItem));
+
+    g_return_val_if_fail(item != NULL, NULL);
+
+    WebCore::String uri = item->urlString();
+
+    g_free(webHistoryItem->priv->uri);
+
+    webHistoryItem->priv->uri = g_strdup(uri.utf8().data());
+
+    return webHistoryItem->priv->uri;
+}
+
+/**
+ * webkit_web_history_item_get_original_uri:
+ * @webHistoryItem: a #WebKitWebHistoryItem
+ *
+ * Returns the original URI of @webHistoryItem.
+ *
+ * Return value: the original URI of @webHistoryITem
+ */
+const gchar* webkit_web_history_item_get_original_uri(WebKitWebHistoryItem* webHistoryItem)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);
+
+    WebCore::HistoryItem* item = core(WEBKIT_WEB_HISTORY_ITEM(webHistoryItem));
+
+    g_return_val_if_fail(item != NULL, NULL);
+
+    WebCore::String originalUri = item->originalURLString();
+
+    g_free(webHistoryItem->priv->originalUri);
+
+    webHistoryItem->priv->originalUri = g_strdup(originalUri.utf8().data());
+    
+    return webHistoryItem->priv->originalUri;
+}
+
+/**
+ * webkit_web_history_item_get_last_visisted_time :
+ * @webHistoryItem: a #WebKitWebHistoryItem
+ *
+ * Returns the last time @webHistoryItem was visited
+ *
+ * Return value: the time in seconds this @webHistoryItem was last visited
+ */
+gdouble webkit_web_history_item_get_last_visited_time(WebKitWebHistoryItem* webHistoryItem) 
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);
+
+    WebCore::HistoryItem* item = core(WEBKIT_WEB_HISTORY_ITEM(webHistoryItem));
+
+    g_return_val_if_fail(item != NULL, 0);
+
+    return item->lastVisitedTime();
+}
+
+} /* end extern "C" */
+
+WebCore::HistoryItem* WebKit::core(WebKitWebHistoryItem* webHistoryItem)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);
+
+    WebCore::HistoryItem* historyItem = webHistoryItem->priv->historyItem;
+
+    return historyItem ? historyItem : 0;
+}
+
+WebKitWebHistoryItem* WebKit::kit(WebCore::HistoryItem* historyItem)
+{
+    g_return_val_if_fail(historyItem != NULL, NULL);
+    
+    WebKitWebHistoryItem* webHistoryItem;
+    GHashTable* table = webkit_history_items();
+
+    webHistoryItem = (WebKitWebHistoryItem*) g_hash_table_lookup(table, historyItem);
+    return webHistoryItem;
+}
+
diff --git a/WebKit/gtk/WebView/webkitwebhistoryitem.h b/WebKit/gtk/WebView/webkitwebhistoryitem.h
new file mode 100644 (file)
index 0000000..26a024e
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2008 Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WEBKIT_WEB_HISTORY_ITEM_H
+#define WEBKIT_WEB_HISTORY_ITEM_H
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gdk/gdk.h>
+
+#include "webkitdefines.h"
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_HISTORY_ITEM            (webkit_web_history_item_get_type())
+#define WEBKIT_WEB_HISTORY_ITEM(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_HISTORY_ITEM, WebKitWebHistoryItem))
+#define WEBKIT_WEB_HISTORY_ITEM_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_WEB_HISTORY_ITEM, WebKitWebHistoryItemClass))
+#define WEBKIT_IS_WEB_HISTORY_ITEM(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_HISTORY_ITEM))
+#define WEBKIT_IS_WEB_HISTORY_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_WEB_HISTORY_ITEM))
+#define WEBKIT_WEB_HISTORY_ITEM_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_WEB_HISTORY_ITEM, WebKitWebHistoryItemClass))
+
+
+typedef struct _WebKitWebHistoryItemPrivate WebKitWebHistoryItemPrivate;
+typedef struct _WebKitWebHistoryItem WebKitWebHistoryItem;
+typedef struct _WebKitWebHistoryItemClass WebKitWebHistoryItemClass;
+
+struct _WebKitWebHistoryItem {
+    GObject parent;
+
+    /*< private >*/
+    WebKitWebHistoryItemPrivate* priv;
+};
+
+struct _WebKitWebHistoryItemClass {
+    GObjectClass parent;
+};
+
+WEBKIT_API GType
+webkit_web_history_item_get_type (void);
+
+WEBKIT_API WebKitWebHistoryItem*
+webkit_web_history_item_new (void);
+
+WEBKIT_API WebKitWebHistoryItem*
+webkit_web_history_item_new_with_data (const gchar* uri, const gchar* title);
+
+WEBKIT_API const gchar*
+webkit_web_history_item_get_title (WebKitWebHistoryItem* web_history_item);
+
+WEBKIT_API const gchar*
+webkit_web_history_item_get_alternate_title (WebKitWebHistoryItem* web_history_item);
+
+WEBKIT_API void
+webkit_web_history_item_set_alternate_title (WebKitWebHistoryItem* web_history_item, const gchar* title);
+
+WEBKIT_API const gchar*
+webkit_web_history_item_get_uri (WebKitWebHistoryItem* web_history_item);
+
+WEBKIT_API const gchar*
+webkit_web_history_item_get_original_uri (WebKitWebHistoryItem* web_history_item);
+
+WEBKIT_API gdouble
+webkit_web_history_item_get_last_visited_time (WebKitWebHistoryItem* web_history_item);
+
+G_END_DECLS
+
+#endif /* WEBKIT_WEB_HISTORY_ITEM_H */
index 67604c4..8409305 100644 (file)
@@ -3,6 +3,7 @@
  *  Copyright (C) 2007 Christian Dywan <christian@twotoasts.de>
  *  Copyright (C) 2007 Xan Lopez <xan@gnome.org>
  *  Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ *  Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com>
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
 #include "webkitwebview.h"
 #include "webkit-marshal.h"
 #include "webkitprivate.h"
+#include "webkitwebbackforwardlist.h"
+#include "webkitwebhistoryitem.h"
 
 #include "NotImplemented.h"
+#include "BackForwardList.h"
 #include "CString.h"
 #include "ChromeClientGtk.h"
 #include "ContextMenu.h"
@@ -37,6 +41,7 @@
 #include "EditorClientGtk.h"
 #include "EventHandler.h"
 #include "FocusController.h"
+#include "FrameLoaderTypes.h"
 #include "HitTestRequest.h"
 #include "HitTestResult.h"
 #include "GraphicsContext.h"
@@ -579,7 +584,10 @@ static void webkit_web_view_finalize(GObject* object)
     webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object));
 
     WebKitWebViewPrivate* webViewData = WEBKIT_WEB_VIEW_GET_PRIVATE(WEBKIT_WEB_VIEW(object));
+
     delete webViewData->corePage;
+
+    g_object_unref(webViewData->backForwardList);
     g_object_unref(webViewData->webSettings);
     g_object_unref(webViewData->mainFrame);
     g_object_unref(webViewData->imContext);
@@ -1175,6 +1183,9 @@ static void webkit_web_view_init(WebKitWebView* webView)
     webViewData->lastPopupXPosition = webViewData->lastPopupYPosition = -1;
     webViewData->editable = false;
 
+    /* Initialize the view's back/forward list */
+    webViewData->backForwardList = webkit_web_back_forward_list_new_with_web_view(webView);
+
 #if GTK_CHECK_VERSION(2,10,0)
     GdkAtom textHtml = gdk_atom_intern_static_string("text/html");
 #else
@@ -1221,6 +1232,64 @@ WebKitWebSettings* webkit_web_view_get_settings(WebKitWebView* webView)
     return webViewData->webSettings;
 }
 
+/**
+ * webkit_web_view_set_maintains_back_forward_list:
+ * @webView: a #WebKitWebView
+ * @flag: to tell the view to maintain a back or forward list
+ *
+ * Set the view to maintain a back or forward list of history items.
+ */
+void webkit_web_view_set_maintains_back_forward_list(WebKitWebView* webView, gboolean flag)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+    core(webView)->backForwardList()->setEnabled(flag);
+}
+
+/**
+ * webkit_web_view_get_back_forward_list:
+ * @webView: a #WebKitWebView
+ *
+ * Returns a #WebKitWebBackForwardList
+ * 
+ * Return value: the #WebKitWebBackForwardList
+ */
+WebKitWebBackForwardList* webkit_web_view_get_back_forward_list(WebKitWebView* webView)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL);
+
+    WebKitWebViewPrivate* webViewData = WEBKIT_WEB_VIEW_GET_PRIVATE(WEBKIT_WEB_VIEW(webView));
+
+    if (!webViewData->corePage || !webViewData->corePage->backForwardList()->enabled())
+        return NULL;
+
+    return webViewData->backForwardList;
+}
+
+/**
+ * webkit_web_view_go_to_back_forward_item:
+ * @webView: a #WebKitWebView
+ * @item: a #WebKitWebHistoryItem*
+ *
+ * Go to the specified #WebKitWebHistoryItem
+ *
+ * Return value: %TRUE if loading of item is successful, %FALSE if not
+ */
+gboolean webkit_web_view_go_to_back_forward_item(WebKitWebView* webView, WebKitWebHistoryItem* item)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
+    g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(item), FALSE);
+
+    core(webView)->goToItem(core(item), FrameLoadTypeIndexedBackForward);
+    return TRUE;
+}
+
+/**
+ * webkit_web_view_go_backward:
+ * @webView: the #WebKitWebView
+ *
+ * Go to the previous page, if there's any.
+ */
 void webkit_web_view_go_backward(WebKitWebView* webView)
 {
     g_warning("webkit_web_view_go_backward() is obsolete; use webkit_web_view_go_back()");
@@ -1237,8 +1306,7 @@ void webkit_web_view_go_back(WebKitWebView* webView)
 {
     g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
 
-    Frame* frame = core(webkit_web_view_get_main_frame(webView));
-    frame->loader()->goBackOrForward(-1);
+    core(webView)->goBack();
 }
 
 /**
@@ -1268,10 +1336,17 @@ void webkit_web_view_go_forward(WebKitWebView* webView)
 {
     g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
 
-    Frame* frame = core(webkit_web_view_get_main_frame(webView));
-    frame->loader()->goBackOrForward(1);
+    core(webView)->goForward();
 }
 
+/**
+ * webkit_web_view_can_go_backward:
+ * @webView: the #WebKitWebView
+ *
+ * Checks whether the view can go back to the previous page
+ *
+ * Return value: %TRUE if the page can go back, otherwise returns %FALSE
+ */
 gboolean webkit_web_view_can_go_backward(WebKitWebView* webView)
 {
     g_warning("webkit_web_view_can_go_backward() is obsolete; use webkit_web_view_can_go_back()");
@@ -1290,8 +1365,12 @@ gboolean webkit_web_view_can_go_back(WebKitWebView* webView)
 {
     g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
 
-    Frame* frame = core(webkit_web_view_get_main_frame(webView));
-    return frame->loader()->canGoBackOrForward(-1);
+    Page* page = core(webView);
+
+    if (!page || !page->backForwardList()->backItem())
+        return FALSE;
+
+    return TRUE;
 }
 
 /**
@@ -1325,8 +1404,15 @@ gboolean webkit_web_view_can_go_forward(WebKitWebView* webView)
 {
     g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
 
-    Frame* frame = core(webkit_web_view_get_main_frame(webView));
-    return frame->loader()->canGoBackOrForward(1);
+    Page* page = core(webView);
+
+    if (!page)
+        return FALSE;
+
+    if (!page->backForwardList()->forwardItem())
+        return FALSE;
+
+    return TRUE;
 }
 
 void webkit_web_view_open(WebKitWebView* webView, const gchar* uri)
index ab2f5c0..4a6dea0 100644 (file)
@@ -24,6 +24,8 @@
 #include <JavaScriptCore/JSBase.h>
 
 #include "webkitdefines.h"
+#include "webkitwebbackforwardlist.h"
+#include "webkitwebhistoryitem.h"
 #include "webkitwebsettings.h"
 
 G_BEGIN_DECLS
@@ -91,8 +93,14 @@ webkit_web_view_get_type (void);
 WEBKIT_API GtkWidget*
 webkit_web_view_new (void);
 
-WEBKIT_OBSOLETE_API gboolean
-webkit_web_view_can_go_backward (WebKitWebView* web_view);
+WEBKIT_API void
+webkit_web_view_set_maintains_back_forward_list (WebKitWebView* web_view, gboolean flag); 
+
+WEBKIT_API WebKitWebBackForwardList*
+webkit_web_view_get_back_forward_list (WebKitWebView* web_view);
+
+WEBKIT_API gboolean
+webkit_web_view_go_to_back_forward_item (WebKitWebView *web_view, WebKitWebHistoryItem* item);
 
 WEBKIT_API gboolean
 webkit_web_view_can_go_back (WebKitWebView* web_view);
@@ -103,9 +111,6 @@ webkit_web_view_can_go_back_or_forward (WebKitWebView* web_view, gint steps);
 WEBKIT_API gboolean
 webkit_web_view_can_go_forward (WebKitWebView* web_view);
 
-WEBKIT_OBSOLETE_API void
-webkit_web_view_go_backward (WebKitWebView* web_view);
-
 WEBKIT_API void
 webkit_web_view_go_back (WebKitWebView* web_view);
 
@@ -193,6 +198,12 @@ webkit_web_view_set_settings (WebKitWebView* web_view, WebKitWebSettings* settin
 WEBKIT_API WebKitWebSettings*
 webkit_web_view_get_settings (WebKitWebView* web_view);
 
+WEBKIT_OBSOLETE_API gboolean
+webkit_web_view_can_go_backward (WebKitWebView* web_view);
+
+WEBKIT_OBSOLETE_API void
+webkit_web_view_go_backward (WebKitWebView* web_view);
+
 G_END_DECLS
 
 #endif