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));
}
Beispiel #2
0
static void
arbitrary_url_cb (GSettings *settings,
		  char *key,
		  EphyWindow *window)
{
	EphyEmbed *embed;
	const char *address;

	/* Restore the real web page address when disabling entry */
	if (g_settings_get_boolean (settings, key))
	{
		embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
		/* embed is NULL on startup */
		if (embed == NULL)
			return;

		address = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
		ephy_window_set_location (window, address);
		ephy_web_view_set_typed_address (ephy_embed_get_web_view (embed), NULL);
	}
}