static gboolean
button_press_event_cb (GtkWidget *widget,
                       GdkEventButton *event,
                       EphyWindow *window)
{
    gint tab_number;
    EphyEmbed *embed;

    if (event->button != 2 || event->type != GDK_BUTTON_PRESS)
        return FALSE;

    /* I wish this wasn't so gash and copy-pasty... Connecting
     * to button-press-event on the tab doesn't ever get called.*/
    tab_number = find_tab_num_at_pos (EPHY_NOTEBOOK (widget),
                                      event->x_root, event->y_root);

    if (tab_number < 0)
        return FALSE;

    embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (widget),
                        tab_number));

    if (embed == NULL)
        return FALSE;

    ephy_embed_container_remove_child (EPHY_EMBED_CONTAINER (window), embed);

    return TRUE;
}
Exemple #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);
	}
}
static void
ephy_greasemonkey_extension_install_cb (GtkAction *action,
					EphyWindow *window)
{
	EphyEmbed *embed;
	EphyDownload *download;
	WindowData *data;
	const char *url;
	char *filename;

	data = (WindowData *) g_object_get_data (G_OBJECT (window),
						 WINDOW_DATA_KEY);
	g_return_if_fail (data != NULL);

	url = data->last_clicked_url;
	g_return_if_fail (url != NULL);

	embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
	g_return_if_fail (embed != NULL);

	LOG ("Installing script at '%s'", url);

	download = ephy_download_new_for_uri (url);

	filename = script_name_build (url);
	ephy_download_set_destination_uri (download, filename);
	g_free (filename);

	g_signal_connect (download, "completed",
			  G_CALLBACK (save_source_completed_cb), window);
	g_signal_connect (download, "error",
			  G_CALLBACK (save_source_error_cb), window);

	data->pending_downloads = g_list_prepend (data->pending_downloads,
						  download);

	ephy_download_start (download);
}
Exemple #4
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);
}