static char* gtkWebBrowserGetForwardCountAttrib(Ihandle* ih) { WebKitWebBackForwardList *back_forward_list = webkit_web_view_get_back_forward_list ((WebKitWebView*)ih->handle); char* str = iupStrGetMemory(30); sprintf(str, "%d", webkit_web_back_forward_list_get_forward_length(back_forward_list)); return str; }
size_t LayoutTestController::webHistoryItemCount() { WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame); WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list(webView); if (!list) return -1; // We do not add the current page to the total count as it's not // considered in DRT tests return webkit_web_back_forward_list_get_back_length(list) + webkit_web_back_forward_list_get_forward_length(list); }
/* session_save(const char *) {{{*/ gboolean session_save(const char *name, int flags) { if (!name) { if (s_session_name) name = s_session_name; else if (flags & SESSION_FORCE) name = "default"; } if (!s_has_marked && (flags & SESSION_FORCE) == 0) return false; GString *buffer = g_string_new(NULL); for (GList *l = g_list_first(dwb.state.views); l; l=l->next) { WebKitWebView *web = WEBVIEW(l); WebKitWebBackForwardList *bf_list = webkit_web_view_get_back_forward_list(web); if (VIEW(l)->status->deferred) { g_string_append_printf(buffer, "0|%d %s unknown\n", VIEW(l)->status->lockprotect, VIEW(l)->status->deferred_uri); continue; } for (int i= -webkit_web_back_forward_list_get_back_length(bf_list); i<=webkit_web_back_forward_list_get_forward_length(bf_list); i++) { WebKitWebHistoryItem *item = webkit_web_back_forward_list_get_nth_item(bf_list, i); if (item) { g_string_append_printf(buffer, "%d", i); if (i == 0) g_string_append_printf(buffer, "|%d", VIEW(l)->status->lockprotect); g_string_append_printf(buffer, " %s %s\n", webkit_web_history_item_get_uri(item), webkit_web_history_item_get_title(item)); } } } session_save_file(name, buffer->str, (flags & SESSION_SYNC) != 0); if (! (flags & SESSION_SYNC)) g_free(s_session_name); g_string_free(buffer, true); return true; }/*}}}*/
static gint luaH_webview_push_history(lua_State *L, WebKitWebView *view) { /* obtain the history list of the tab and get information about it */ WebKitWebBackForwardList *bflist = webkit_web_back_forward_list_new_with_web_view(view); WebKitWebHistoryItem *item; gint backlen = webkit_web_back_forward_list_get_back_length(bflist); gint forwardlen = webkit_web_back_forward_list_get_forward_length(bflist); /* compose an overall table with the history list and the position thereof */ lua_createtable(L, 0, 2); /* Set hist[index] = pos */ lua_pushliteral(L, "index"); lua_pushnumber(L, backlen + 1); lua_rawset(L, -3); /* create a table with the history items */ lua_createtable(L, backlen + forwardlen + 1, 0); for(gint i = -backlen; i <= forwardlen; i++) { /* each individual history item is composed of a URL and a page title */ item = webkit_web_back_forward_list_get_nth_item(bflist, i); lua_createtable(L, 0, 2); /* Set hist_item[uri] = uri */ lua_pushliteral(L, "uri"); lua_pushstring(L, item ? webkit_web_history_item_get_uri(item) : "about:blank"); lua_rawset(L, -3); /* Set hist_item[title] = title */ lua_pushliteral(L, "title"); lua_pushstring(L, item ? webkit_web_history_item_get_title(item) : ""); lua_rawset(L, -3); lua_rawseti(L, -2, backlen + i + 1); } /* Set hist[items] = hist_items_table */ lua_pushliteral(L, "items"); lua_insert(L, lua_gettop(L) - 1); lua_rawset(L, -3); return 1; }
static char* gtkWebBrowserGetForwardCountAttrib(Ihandle* ih) { WebKitWebBackForwardList *back_forward_list = webkit_web_view_get_back_forward_list ((WebKitWebView*)ih->handle); return iupStrReturnInt(webkit_web_back_forward_list_get_forward_length(back_forward_list)); }