svnno****@sourc*****
svnno****@sourc*****
Wed Feb 4 08:16:51 JST 2009
Revision: 3604 http://svn.sourceforge.jp/view?root=kazehakase&view=rev&rev=3604 Author: ikezoe Date: 2009-02-04 08:16:51 +0900 (Wed, 04 Feb 2009) Log Message: ----------- 2009-02-04 Hiroyuki Ikezoe <poinc****@ikezo*****> * module/embed/webkit-gtk/kz-webkit-gtk.c: Implement copy_page and shistory_copy. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/module/embed/webkit-gtk/kz-webkit-gtk.c Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2009-02-03 04:23:16 UTC (rev 3603) +++ kazehakase/trunk/ChangeLog 2009-02-03 23:16:51 UTC (rev 3604) @@ -1,3 +1,8 @@ +2009-02-04 Hiroyuki Ikezoe <poinc****@ikezo*****> + + * module/embed/webkit-gtk/kz-webkit-gtk.c: Implement copy_page and + shistory_copy. + 2009-02-03 Hiroyuki Ikezoe <poinc****@ikezo*****> * module/embed/ie/kz-ie.c: Added many functions related to history. Modified: kazehakase/trunk/module/embed/webkit-gtk/kz-webkit-gtk.c =================================================================== --- kazehakase/trunk/module/embed/webkit-gtk/kz-webkit-gtk.c 2009-02-03 04:23:16 UTC (rev 3603) +++ kazehakase/trunk/module/embed/webkit-gtk/kz-webkit-gtk.c 2009-02-03 23:16:51 UTC (rev 3604) @@ -100,6 +100,14 @@ KzBookmark *history); static void set_history (KzEmbed *kzembed, KzBookmark *history); +static void copy_page (KzEmbed *src_embed, + KzEmbed *dest_embed, + KzEmbedCopyType type); +static gboolean shistory_copy (KzEmbed *src_embed, + KzEmbed *dest_embed, + gboolean back_history, + gboolean forward_history, + gboolean set_current); static gboolean shistory_get_pos (KzEmbed *kzembed, gint *pos, gint *count); @@ -232,8 +240,8 @@ iface->incremental_search = NULL; iface->selection_is_collapsed = selection_is_collapsed; iface->get_links = NULL; - iface->copy_page = NULL; - iface->shistory_copy = NULL; + iface->copy_page = copy_page; + iface->shistory_copy = shistory_copy; iface->shistory_get_pos = shistory_get_pos; iface->shistory_get_nth = shistory_get_nth; iface->reload = reload; @@ -761,7 +769,7 @@ KzBookmark *child = KZ_BOOKMARK(node->data); item = webkit_web_history_item_new_with_data(kz_bookmark_get_link(child), - kz_bookmark_get_title(child)); + kz_bookmark_get_title(child)); webkit_web_back_forward_list_add_item(list, item); total++; } @@ -772,7 +780,49 @@ webkit_web_view_go_to_back_forward_item(KZ_WEBKIT_GTK_GET_PRIVATE(kzembed)->web_view, item); } +static void +copy_page (KzEmbed *src_embed, KzEmbed *dest_embed, KzEmbedCopyType type) +{ + webkit_web_view_open(KZ_WEBKIT_GTK_GET_PRIVATE (dest_embed)->web_view, + KZ_WEBKIT_GTK_GET_PRIVATE(src_embed)->location); +} + static gboolean +shistory_copy (KzEmbed *src_embed, KzEmbed *dest_embed, + gboolean back_history, gboolean forward_history, + gboolean set_current) +{ + WebKitWebBackForwardList *src_list, *dest_list; + WebKitWebHistoryItem *current_item; + gint length, i; + + src_list = webkit_web_view_get_back_forward_list(KZ_WEBKIT_GTK_GET_PRIVATE(src_embed)->web_view); + if (!src_list) + return FALSE; + dest_list = webkit_web_view_get_back_forward_list(KZ_WEBKIT_GTK_GET_PRIVATE(dest_embed)->web_view); + if (!dest_list) + return FALSE; + + current_item = webkit_web_back_forward_list_get_current_item(src_list); + + /* Remove all items in dest list. */ + webkit_web_back_forward_list_set_limit(dest_list, 0); + + length = webkit_web_back_forward_list_get_back_length(src_list); + length += webkit_web_back_forward_list_get_forward_length(src_list); + length++; + for (i = 0; i < length; i++) { + WebKitWebHistoryItem *item; + item = webkit_web_back_forward_list_get_nth_item(src_list, i); + webkit_web_back_forward_list_add_item(dest_list, item); + } + + webkit_web_back_forward_list_go_to_item(dest_list, current_item); + + return TRUE; +} + +static gboolean shistory_get_pos (KzEmbed *kzembed, gint *pos, gint *count) { WebKitWebBackForwardList *list; @@ -796,10 +846,15 @@ { WebKitWebBackForwardList *list; WebKitWebHistoryItem *item; + gint back_length; list = webkit_web_view_get_back_forward_list(KZ_WEBKIT_GTK_GET_PRIVATE(kzembed)->web_view); if (!list) return; + back_length = webkit_web_back_forward_list_get_back_length(list); + if (!is_relative) + nth -= back_length; + item = webkit_web_back_forward_list_get_nth_item(list, nth); if (!item) return;