예제 #1
0
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetForwardHistory()
{
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist;
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(m_web_view);
    GList* list = webkit_web_back_forward_list_get_forward_list_with_limit(history,
                                                                           m_historyLimit);
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for(guint i = 0; i < g_list_length(list); i++)
    {
        WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i);
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
                                   webkit_web_history_item_get_uri(gtkitem),
                                   webkit_web_history_item_get_title(gtkitem));
        wxitem->m_histItem = gtkitem;
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
        forwardhist.push_back(item);
    }
    return forwardhist;
}
예제 #2
0
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetBackwardHistory()
{
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist;
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(m_web_view);
    GList* list = webkit_web_back_forward_list_get_back_list_with_limit(history,
                                                                        m_historyLimit);
    //We need to iterate in reverse to get the order we desire
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for(int i = g_list_length(list) - 1; i >= 0 ; i--)
    {
        WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i);
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
                                   webkit_web_history_item_get_uri(gtkitem),
                                   webkit_web_history_item_get_title(gtkitem));
        wxitem->m_histItem = gtkitem;
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
        backhist.push_back(item);
    }
    return backhist;
}
예제 #3
0
static char* gtkWebBrowserGetItemHistoryAttrib(Ihandle* ih, int id)
{
  WebKitWebBackForwardList *back_forward_list = webkit_web_view_get_back_forward_list ((WebKitWebView*)ih->handle);
  WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_nth_item(back_forward_list, id);
  char* str = iupStrGetMemory(1024);
  sprintf(str, "%s", webkit_web_history_item_get_uri(item));
  return str;
}
예제 #4
0
static char* gtkWebBrowserGetItemHistoryAttrib(Ihandle* ih, int id)
{
  WebKitWebBackForwardList *back_forward_list = webkit_web_view_get_back_forward_list ((WebKitWebView*)ih->handle);
  WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_nth_item(back_forward_list, id);
  if (item)
    return iupStrReturnStr(webkit_web_history_item_get_uri(item));
  else
    return NULL;
}
예제 #5
0
static void
wxgtk_webview_webkit_load_status(GtkWidget* widget, 
                                 GParamSpec*,
                                 wxWebViewWebKit *webKitCtrl)
{
    if (!webKitCtrl->m_ready) return;

    wxString url = webKitCtrl->GetCurrentURL();

    WebKitLoadStatus status;
    g_object_get(G_OBJECT(widget), "load-status", &status, NULL);

    wxString target; // TODO: get target (if possible)

    if (status == WEBKIT_LOAD_FINISHED)
    {
        WebKitWebBackForwardList* hist = webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(widget));
        WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_current_item(hist);
        //We have to check if we are actually storing history
        //If the item isn't added we add it ourselves, it isn't added otherwise
        //with a custom scheme.
        if(WEBKIT_IS_WEB_HISTORY_ITEM(item) && webkit_web_history_item_get_uri(item) != url)
        {
            WebKitWebHistoryItem*
                newitem = webkit_web_history_item_new_with_data
                          (
                            url.utf8_str(),
                            webKitCtrl->GetCurrentTitle().utf8_str()
                          );
            webkit_web_back_forward_list_add_item(hist, newitem);
        }

        webKitCtrl->m_busy = false;
        wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_LOADED,
                             webKitCtrl->GetId(),
                             url, target);

        if (webKitCtrl && webKitCtrl->GetEventHandler())
            webKitCtrl->GetEventHandler()->ProcessEvent(event);
    }
    else if (status ==  WEBKIT_LOAD_COMMITTED)
    {
        webKitCtrl->m_busy = true;
        wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
                             webKitCtrl->GetId(),
                             url, target);

        if (webKitCtrl && webKitCtrl->GetEventHandler())
            webKitCtrl->GetEventHandler()->ProcessEvent(event);
    }
}
예제 #6
0
파일: session.c 프로젝트: adnandzebic/dwb
/* 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;
}/*}}}*/
예제 #7
0
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetForwardHistory()
{
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist; 
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view));
    GList* list = webkit_web_back_forward_list_get_forward_list_with_limit(history, 
                                                                           m_historyLimit);
    for(guint i = 0; i < g_list_length(list); i++)
    {
        WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i);
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
                                   webkit_web_history_item_get_uri(gtkitem),
                                   webkit_web_history_item_get_title(gtkitem));
        wxitem->m_histItem = gtkitem;
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
        forwardhist.push_back(item);
    }
    return forwardhist;
}
예제 #8
0
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetBackwardHistory()
{
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist; 
    WebKitWebBackForwardList* history;
    history = webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(web_view));
    GList* list = webkit_web_back_forward_list_get_back_list_with_limit(history, 
                                                                        m_historyLimit);
    //We need to iterate in reverse to get the order we desire
    for(int i = g_list_length(list) - 1; i >= 0 ; i--)
    {
        WebKitWebHistoryItem* gtkitem = (WebKitWebHistoryItem*)g_list_nth_data(list, i);
        wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(
                                   webkit_web_history_item_get_uri(gtkitem),
                                   webkit_web_history_item_get_title(gtkitem));
        wxitem->m_histItem = gtkitem;
        wxSharedPtr<wxWebViewHistoryItem> item(wxitem);
        backhist.push_back(item);
    }
    return backhist;
}
예제 #9
0
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;
}
예제 #10
0
    g_assert_cmpint(G_OBJECT(fixture->item)->ref_count, == , 1);
    g_assert(fixture->item != NULL);
}

static void web_history_item_fixture_teardown(WebHistoryItemFixture* fixture,
                                              gconstpointer data)
{
    g_assert(fixture->item != NULL);
    g_assert_cmpint(G_OBJECT(fixture->item)->ref_count, ==, 1);
}

static void test_webkit_web_history_item_get_data(WebHistoryItemFixture* fixture,
                                                  gconstpointer data)
{
    g_assert_cmpstr(webkit_web_history_item_get_title(fixture->item), ==, "Example1");
    g_assert_cmpstr(webkit_web_history_item_get_uri(fixture->item), ==, "http://example.com/");
}

static void test_webkit_web_history_item_alternate_title(WebHistoryItemFixture* fixture,
                                                         gconstpointer data)
{
    webkit_web_history_item_set_alternate_title(fixture->item, "Alternate title");
    g_assert_cmpstr(webkit_web_history_item_get_alternate_title(fixture->item), ==, "Alternate title");
}

int main(int argc, char** argv)
{
    gtk_test_init(&argc, &argv, NULL);

    g_test_bug_base("https://bugs.webkit.org/");
    g_test_add("/webkit/webhistoryitem/get_data",