Exemplo n.º 1
0
static void
notebook_page_added_cb (GtkWidget *notebook,
			EphyEmbed *embed,
			guint position,
			EphySession *session)
{
#ifdef HAVE_WEBKIT2
	g_signal_connect (ephy_embed_get_web_view (embed), "load-changed",
			  G_CALLBACK (load_changed_cb), session);
#else
	g_signal_connect (ephy_embed_get_web_view (embed), "notify::load-status",
			  G_CALLBACK (load_status_notify_cb), session);
#endif
}
static void
ephy_push_scroller_scroll_pixels (EphyEmbed *embed, int scroll_x, int scroll_y)
{
	GtkAdjustment *adj;
	gdouble value;
	gdouble new_value;
	gdouble page_size;
	gdouble upper;
	gdouble lower;
	GtkWidget *sw;

	sw = gtk_widget_get_parent (GTK_WIDGET (ephy_embed_get_web_view (embed)));
	g_return_if_fail (GTK_IS_SCROLLED_WINDOW (sw));

	adj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (sw));
	upper = gtk_adjustment_get_upper (adj);
	lower = gtk_adjustment_get_lower (adj);
	value = gtk_adjustment_get_value (adj);
	page_size = gtk_adjustment_get_page_size (adj);

	new_value = CLAMP (value - scroll_x, lower, upper - page_size);
	gtk_adjustment_set_value (adj, new_value);

	adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw));
	upper = gtk_adjustment_get_upper (adj);
	lower = gtk_adjustment_get_lower (adj);
	value = gtk_adjustment_get_value (adj);
	page_size = gtk_adjustment_get_page_size (adj);

	new_value = CLAMP (value - scroll_y, lower, upper - page_size);
	gtk_adjustment_set_value (adj, new_value);
}
Exemplo n.º 3
0
static GtkWidget *
build_tab_label (EphyNotebook *nb, EphyEmbed *embed)
{
  GtkWidget *tab_label;
  EphyWebView *view;

  tab_label = ephy_tab_label_new ();
  g_signal_connect (tab_label, "close-clicked", G_CALLBACK (close_button_clicked_cb), embed);

  /* Set up drag-and-drop target */
  g_signal_connect (tab_label, "drag-data-received",
                    G_CALLBACK (notebook_drag_data_received_cb), embed);
  gtk_drag_dest_set (tab_label, GTK_DEST_DEFAULT_ALL,
                     url_drag_types, G_N_ELEMENTS (url_drag_types),
                     GDK_ACTION_MOVE | GDK_ACTION_COPY);
  gtk_drag_dest_add_text_targets (tab_label);

  /* Hook the label up to the tab properties */
  view = ephy_embed_get_web_view (embed);

  g_signal_connect_object (embed, "notify::title",
                           G_CALLBACK (rebuild_tab_menu_cb), nb, 0);

  g_object_bind_property (view, "title", tab_label, "label-text", G_BINDING_DEFAULT);
  g_object_bind_property (view, "display-address", tab_label, "label-uri", G_BINDING_DEFAULT);
  g_object_bind_property (view, "icon", tab_label, "icon-buf", G_BINDING_DEFAULT);
  g_object_bind_property (view, "is-loading", tab_label, "spinning", G_BINDING_DEFAULT);
  g_object_bind_property (view, "is-playing-audio", tab_label, "audio", G_BINDING_DEFAULT);

  return tab_label;
}
Exemplo n.º 4
0
static void
notebook_page_removed_cb (GtkWidget *notebook,
			  EphyEmbed *embed,
			  guint position,
			  EphySession *session)
{
	ephy_session_save (session, SESSION_STATE);

#ifdef HAVE_WEBKIT2
	g_signal_handlers_disconnect_by_func
		(ephy_embed_get_web_view (embed), G_CALLBACK (load_changed_cb),
		 session);
#else
	g_signal_handlers_disconnect_by_func
		(ephy_embed_get_web_view (embed), G_CALLBACK (load_status_notify_cb),
		 session);
#endif
}
Exemplo n.º 5
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));
}
Exemplo n.º 6
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);
	}
}
Exemplo n.º 7
0
static void
ephy_notebook_switch_page_cb (GtkNotebook *notebook,
                              GtkWidget   *page,
                              guint        page_num,
                              gpointer     data)
{
  EphyNotebook *nb = EPHY_NOTEBOOK (notebook);
  GtkWidget *child;

  child = gtk_notebook_get_nth_page (notebook, page_num);
  if (!ephy_web_view_is_in_auth_dialog (ephy_embed_get_web_view (EPHY_EMBED (child))))
    gtk_widget_grab_focus (child);

  /* Remove the old page, we dont want to grow unnecessarily
   * the list */
  if (nb->focused_pages) {
    nb->focused_pages =
      g_list_remove (nb->focused_pages, child);
  }

  nb->focused_pages = g_list_append (nb->focused_pages, child);
}
Exemplo n.º 8
0
static void
session_command_open_uris (EphySession *session,
			   char **uris,
			   const char *options,
			   guint32 user_time)
{
	EphyShell *shell;
	EphyWindow *window;
	EphyEmbed *embed;
	EphySessionPrivate *priv;
	EphyNewTabFlags flags = 0;
	guint i;

	priv = session->priv;

	shell = ephy_shell_get_default ();

	g_object_ref (shell);

	window = ephy_session_get_active_window (session);

	if (options != NULL && strstr (options, "external") != NULL)
	{
		flags |= EPHY_NEW_TAB_FROM_EXTERNAL;
	}
	if (options != NULL && strstr (options, "new-window") != NULL)
	{
		window = NULL;
		flags |= EPHY_NEW_TAB_IN_NEW_WINDOW;
	}
	else if (options != NULL && strstr (options, "new-tab") != NULL)
	{
		flags |= EPHY_NEW_TAB_IN_EXISTING_WINDOW |
			 EPHY_NEW_TAB_JUMP;
	}

	for (i = 0; uris[i] != NULL; ++i)
	{
		const char *url = uris[i];
		EphyNewTabFlags page_flags;
#ifdef HAVE_WEBKIT2
		WebKitURIRequest *request = NULL;
#else
		WebKitNetworkRequest *request = NULL;
#endif

		if (url[0] == '\0')
		{
			page_flags = EPHY_NEW_TAB_HOME_PAGE;
		}
		else
		{
			page_flags = EPHY_NEW_TAB_OPEN_PAGE;
#ifdef HAVE_WEBKIT2
			request = webkit_uri_request_new (url);
#else
			request = webkit_network_request_new (url);
#endif
		}

		/* For the first URI, if we have a valid recovery
		 * window, reuse the already existing embed instead of
		 * creating a new one, except if we still want to
		 * present the option to resume a crashed session, in
		 * that case use a new tab in the same window */
		if (i == 0 && priv->resume_window != NULL)
		{
			EphyWebView *web_view;
			
			embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (priv->resume_window));
			web_view = ephy_embed_get_web_view (embed);
			ephy_web_view_load_url (web_view, url);
		}
		else
		{
			embed = ephy_shell_new_tab_full (shell, window,
							 NULL /* parent tab */,
							 request,
							 flags | page_flags,
							 EPHY_WEB_VIEW_CHROME_ALL,
							 FALSE /* is popup? */,
							 user_time);
		}

		if (request)
			g_object_unref (request);

		window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed)));
	}

	g_object_unref (shell);
}