コード例 #1
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;
}
コード例 #2
0
static void
ephy_session_tab_closed (EphySession *session,
			 EphyNotebook *notebook,
			 EphyEmbed *embed,
			 gint position)
{
	EphySessionPrivate *priv = session->priv;
	EphyWebView *view;
	const char *address;
#ifdef HAVE_WEBKIT2
	WebKitBackForwardList *source;
#else
	WebKitWebBackForwardList *source;
#endif
	ClosedTab *tab;
	GList *items = NULL;

	view = ephy_embed_get_web_view (embed);
	address = ephy_web_view_get_address (view);

	source = webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view));
#ifdef HAVE_WEBKIT2
	items = webkit_back_forward_list_get_back_list_with_limit (source, EPHY_WEBKIT_BACK_FORWARD_LIMIT);
#else
	items = webkit_web_back_forward_list_get_back_list_with_limit (source, EPHY_WEBKIT_BACK_FORWARD_LIMIT);
#endif
	if (items == NULL && g_strcmp0 (address, "ephy-about:overview") == 0)
		return;

	if (g_queue_get_length (priv->closed_tabs) == MAX_CLOSED_TABS)
	{
		tab = g_queue_pop_tail (priv->closed_tabs);
		if (tab->parent_location && !find_tab_with_notebook (priv->closed_tabs, *tab->parent_location))
		{
			parent_location_free (tab->parent_location, TRUE);
		}

		closed_tab_free (tab);
		tab = NULL;
	}

	items = g_list_reverse (items);
	tab = closed_tab_new (priv->closed_tabs, address, items, position, notebook);
	g_list_free (items);

	g_queue_push_head (priv->closed_tabs, tab);

	if (g_queue_get_length (priv->closed_tabs) == 1)
		g_object_notify (G_OBJECT (session), "can-undo-tab-closed");

	LOG ("Added: %s to the list (%d elements)",
	     address, g_queue_get_length (priv->closed_tabs));
}
コード例 #3
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;
}
コード例 #4
0
ファイル: dialog.c プロジェクト: AjayRamanathan/gimp
static void
update_actions (void)
{
  GtkAction                *action;
  WebKitWebBackForwardList *back_forward_list;
  WebKitWebFrame           *frame;

  back_forward_list =
    webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view));

  /*  update the back button and its menu  */

  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/back");
  gtk_action_set_sensitive (action,
                            webkit_web_view_can_go_back (WEBKIT_WEB_VIEW (view)));

  if (back_forward_list)
    {
      const GList *list;

      list = webkit_web_back_forward_list_get_back_list_with_limit (back_forward_list,
                                                                    12);
      gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (button_prev),
                                     build_menu (list, TRUE));
    }
  else
    {
      gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (button_prev), NULL);
    }

  /*  update the forward button and its menu  */

  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/forward");
  gtk_action_set_sensitive (action,
                            webkit_web_view_can_go_forward (WEBKIT_WEB_VIEW (view)));

  if (back_forward_list)
    {
      const GList *list;

      list = webkit_web_back_forward_list_get_forward_list_with_limit (back_forward_list,
                                                                       12);
      gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (button_next),
                                     build_menu (list, FALSE));
    }
  else
    {
      gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (button_next), NULL);
    }

  /*  update the copy-location action  */
  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/copy-location");

  frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view));
  gtk_action_set_sensitive (action, webkit_web_frame_get_uri (frame) != NULL);

  /*  update the show-index action  */
  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/show-index");
  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
                                gtk_widget_get_visible (sidebar));
}
コード例 #5
0
static void test_webkit_web_history_item_lifetime(void)
{
    WebKitWebView* webView;
    WebKitWebBackForwardList* backForwardList;
    WebKitWebHistoryItem* currentItem;
    WebKitWebHistoryItem* forwardItem;
    WebKitWebHistoryItem* backItem;
    WebKitWebHistoryItem* nthItem;
    WebKitWebHistoryItem* item1;
    WebKitWebHistoryItem* item2;
    WebKitWebHistoryItem* item3;
    WebKitWebHistoryItem* item4;
    GList* backList = NULL;
    GList* forwardList = NULL;
    g_test_bug("19898");

    webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
    g_object_ref_sink(webView);
    backForwardList = webkit_web_view_get_back_forward_list(webView);
    g_assert_cmpint(G_OBJECT(backForwardList)->ref_count, ==, 1);

    /* add test items */
    item1 = webkit_web_history_item_new_with_data("http://example.com/1/", "Site 1");
    webkit_web_back_forward_list_add_item(backForwardList, item1);

    item2 = webkit_web_history_item_new_with_data("http://example.com/2/", "Site 2");
    webkit_web_back_forward_list_add_item(backForwardList, item2);

    item3 = webkit_web_history_item_new_with_data("http://example.com/3/", "Site 3");
    webkit_web_back_forward_list_add_item(backForwardList, item3);

    item4 = webkit_web_history_item_new_with_data("http://example.com/4/", "Site 4");
    webkit_web_back_forward_list_add_item(backForwardList, item4);

    /* make sure these functions don't add unnecessary ref to the history item */
    backItem = webkit_web_back_forward_list_get_back_item(backForwardList);
    g_object_ref(backItem);
    g_assert_cmpint(G_OBJECT(backItem)->ref_count, ==, 2);
    g_object_unref(backItem);
    g_assert_cmpint(G_OBJECT(backItem)->ref_count, ==, 1);

    currentItem = webkit_web_back_forward_list_get_current_item(backForwardList);
    g_object_ref(currentItem);
    g_assert_cmpint(G_OBJECT(currentItem)->ref_count, ==, 2);
    g_object_unref(currentItem);
    g_assert_cmpint(G_OBJECT(currentItem)->ref_count, ==, 1);

    webkit_web_back_forward_list_go_to_item(backForwardList, item2);
    forwardItem = webkit_web_back_forward_list_get_forward_item(backForwardList);
    g_object_ref(forwardItem);
    g_assert_cmpint(G_OBJECT(forwardItem)->ref_count, ==, 2);
    g_object_unref(forwardItem);
    g_assert_cmpint(G_OBJECT(forwardItem)->ref_count, ==, 1);

    nthItem = webkit_web_back_forward_list_get_nth_item(backForwardList, 1);
    g_object_ref(nthItem);
    g_assert_cmpint(G_OBJECT(nthItem)->ref_count, ==, 2);
    g_object_unref(nthItem);
    g_assert_cmpint(G_OBJECT(nthItem)->ref_count, ==, 1);

    backList = webkit_web_back_forward_list_get_back_list_with_limit(backForwardList, 5);
    for (; backList; backList = backList->next)
        g_assert_cmpint(G_OBJECT(backList->data)->ref_count, ==, 1);

    forwardList = webkit_web_back_forward_list_get_forward_list_with_limit(backForwardList, 5);
    for (; forwardList; forwardList = forwardList->next)
        g_assert_cmpint(G_OBJECT(forwardList->data)->ref_count, ==, 1);

    g_list_free(forwardList);
    g_list_free(backList);
    g_assert_cmpint(G_OBJECT(item1)->ref_count, ==, 1);
    g_assert_cmpint(G_OBJECT(item2)->ref_count, ==, 1);
    g_assert_cmpint(G_OBJECT(item3)->ref_count, ==, 1);
    g_assert_cmpint(G_OBJECT(item4)->ref_count, ==, 1);
    g_assert_cmpint(G_OBJECT(backForwardList)->ref_count, ==, 1);
    g_object_unref(webView);
}
コード例 #6
0
static void test_webkit_web_back_forward_list_order(void)
{
    WebKitWebView* webView;
    WebKitWebBackForwardList* webBackForwardList;
    WebKitWebHistoryItem* item1;
    WebKitWebHistoryItem* item2;
    WebKitWebHistoryItem* item3;
    WebKitWebHistoryItem* item4;
    WebKitWebHistoryItem* currentItem;
    GList* backList = NULL;
    GList* forwardList = NULL;
    g_test_bug("22694");

    webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
    g_object_ref_sink(webView);

    webkit_web_view_set_maintains_back_forward_list(webView, TRUE);
    webBackForwardList = webkit_web_view_get_back_forward_list(webView);
    g_assert(webBackForwardList);

    // Check that there is no item.
    g_assert(!webkit_web_back_forward_list_get_current_item(webBackForwardList));
    g_assert_cmpint(webkit_web_back_forward_list_get_forward_length(webBackForwardList), ==, 0);
    g_assert_cmpint(webkit_web_back_forward_list_get_back_length(webBackForwardList), ==, 0);
    g_assert(!webkit_web_view_can_go_forward(webView));
    g_assert(!webkit_web_view_can_go_back(webView));

    // Add a new items
    item1 = webkit_web_history_item_new_with_data("http://example.com/1/", "Site 1");
    webkit_web_back_forward_list_add_item(webBackForwardList, item1);
    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item1));

    item2 = webkit_web_history_item_new_with_data("http://example.com/2/", "Site 2");
    webkit_web_back_forward_list_add_item(webBackForwardList, item2);
    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item2));

    item3 = webkit_web_history_item_new_with_data("http://example.com/3/", "Site 3");
    webkit_web_back_forward_list_add_item(webBackForwardList, item3);
    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item3));

    item4 = webkit_web_history_item_new_with_data("http://example.com/4/", "Site 4");
    webkit_web_back_forward_list_add_item(webBackForwardList, item4);
    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item4));

    // check the back list order
    backList = webkit_web_back_forward_list_get_back_list_with_limit(webBackForwardList, 5);
    g_assert(backList);

    currentItem = WEBKIT_WEB_HISTORY_ITEM(backList->data);
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/3/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Site 3");
    backList = backList->next;

    currentItem = WEBKIT_WEB_HISTORY_ITEM(backList->data);
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/2/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Site 2");
    backList = backList->next;

    currentItem = WEBKIT_WEB_HISTORY_ITEM(backList->data);
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/1/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Site 1");
    g_list_free(backList);

    // check the forward list order
    g_assert(webkit_web_view_go_to_back_forward_item(webView, item1));
    forwardList = webkit_web_back_forward_list_get_forward_list_with_limit(webBackForwardList,5);
    g_assert(forwardList);

    currentItem = WEBKIT_WEB_HISTORY_ITEM(forwardList->data);
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/4/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Site 4");
    forwardList = forwardList->next;

    currentItem = WEBKIT_WEB_HISTORY_ITEM(forwardList->data);
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/3/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Site 3");
    forwardList = forwardList->next;

    currentItem = WEBKIT_WEB_HISTORY_ITEM(forwardList->data);
    g_assert_cmpstr(webkit_web_history_item_get_uri(currentItem), ==, "http://example.com/2/");
    g_assert_cmpstr(webkit_web_history_item_get_title(currentItem), ==, "Site 2");

    g_list_free(forwardList);
    g_object_unref(webView);
}