diff --git a/embed/ephy-download.c b/embed/ephy-download.c index 10b010f6f3d5e9f19e4156e13f1ff42ef379657e..1dffe2271ef39db9314e53b004e3164e3f5ef9b3 100644 --- a/embed/ephy-download.c +++ b/embed/ephy-download.c @@ -25,7 +25,6 @@ #include "ephy-embed.h" #include "ephy-embed-shell.h" #include "ephy-embed-type-builtins.h" -#include "ephy-evince-document-view.h" #include "ephy-file-helpers.h" #include "ephy-flatpak-utils.h" #include "ephy-prefs.h" @@ -44,7 +43,6 @@ struct _EphyDownload { char *content_type; gboolean show_notification; - gboolean in_document_mode; EphyDownloadActionType action; guint32 start_time; @@ -635,16 +633,6 @@ download_decide_destination_cb (WebKitDownload *wk_download, const gchar *suggested_filename, EphyDownload *download) { - if (download->in_document_mode) { - g_autofree gchar *tmp_file = g_strdup_printf ("%s/%s", g_get_user_cache_dir (), suggested_filename); - g_autofree gchar *file_uri = g_filename_to_uri (tmp_file, NULL, NULL); - - webkit_download_set_allow_overwrite (wk_download, TRUE); - webkit_download_set_destination (wk_download, file_uri); - - return TRUE; - } - if (webkit_download_get_destination (wk_download)) return TRUE; @@ -827,9 +815,3 @@ ephy_download_disable_desktop_notification (EphyDownload *download) download->show_notification = FALSE; } - -void -ephy_download_enable_evince_document_mode (EphyDownload *download) -{ - download->in_document_mode = TRUE; -} diff --git a/embed/ephy-download.h b/embed/ephy-download.h index fa6bc917f49116cff254f57f07fb7a377376b7ce..d2435812fc6c81a8c9cd37447364a69e72bc5fd1 100644 --- a/embed/ephy-download.h +++ b/embed/ephy-download.h @@ -36,33 +36,32 @@ typedef enum EPHY_DOWNLOAD_ACTION_OPEN } EphyDownloadActionType; -EphyDownload *ephy_download_new (WebKitDownload *download); -EphyDownload *ephy_download_new_for_uri (const char *uri); +EphyDownload *ephy_download_new (WebKitDownload *download); +EphyDownload *ephy_download_new_for_uri (const char *uri); -void ephy_download_cancel (EphyDownload *download); -gboolean ephy_download_is_active (EphyDownload *download); -gboolean ephy_download_succeeded (EphyDownload *download); -gboolean ephy_download_failed (EphyDownload *download, - GError **error); +void ephy_download_cancel (EphyDownload *download); +gboolean ephy_download_is_active (EphyDownload *download); +gboolean ephy_download_succeeded (EphyDownload *download); +gboolean ephy_download_failed (EphyDownload *download, + GError **error); -void ephy_download_set_destination_uri (EphyDownload *download, - const char *destination); +void ephy_download_set_destination_uri (EphyDownload *download, + const char *destination); -WebKitDownload *ephy_download_get_webkit_download (EphyDownload *download); +WebKitDownload *ephy_download_get_webkit_download (EphyDownload *download); -const char *ephy_download_get_destination_uri (EphyDownload *download); -const char *ephy_download_get_content_type (EphyDownload *download); +const char *ephy_download_get_destination_uri (EphyDownload *download); +const char *ephy_download_get_content_type (EphyDownload *download); -guint32 ephy_download_get_start_time (EphyDownload *download); +guint32 ephy_download_get_start_time (EphyDownload *download); -EphyDownloadActionType ephy_download_get_action (EphyDownload *download); -void ephy_download_set_action (EphyDownload *download, - EphyDownloadActionType action); -gboolean ephy_download_do_download_action (EphyDownload *download, - EphyDownloadActionType action, - guint32 user_time); +EphyDownloadActionType ephy_download_get_action (EphyDownload *download); +void ephy_download_set_action (EphyDownload *download, + EphyDownloadActionType action); +gboolean ephy_download_do_download_action (EphyDownload *download, + EphyDownloadActionType action, + guint32 user_time); void ephy_download_disable_desktop_notification - (EphyDownload *download); -void ephy_download_enable_evince_document_mode (EphyDownload *download); + (EphyDownload *download); G_END_DECLS diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c index 3ed224d0a87bb347460ec12317fdc379bdc5de53..3a97c0193ddddace4637669670d9d5e326d316bf 100644 --- a/embed/ephy-embed-shell.c +++ b/embed/ephy-embed-shell.c @@ -1130,9 +1130,7 @@ download_started_cb (WebKitWebContext *web_context, { EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell); EphyDownload *ephy_download; - EphyEmbed *embed; gboolean ephy_download_set; - WebKitWebView *web_view; /* Is download locked down? */ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN, @@ -1151,14 +1149,7 @@ download_started_cb (WebKitWebContext *web_context, return; ephy_download = ephy_download_new (download); - - web_view = webkit_download_get_web_view (download); - embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view); - ephy_embed_download_started (embed, ephy_download); - - if (ephy_embed_get_mode (embed) != EPHY_EMBED_MODE_EVINCE_DOCUMENT) - ephy_downloads_manager_add_download (priv->downloads_manager, ephy_download); - + ephy_downloads_manager_add_download (priv->downloads_manager, ephy_download); g_object_unref (ephy_download); } diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c index 97b61fcc7d2ca08fd25e2d97c6c861812dd1151f..be93896303a0ee3ff4ffad1b62a7f935970cdbe1 100644 --- a/embed/ephy-embed-utils.c +++ b/embed/ephy-embed-utils.c @@ -30,7 +30,6 @@ #include "ephy-string.h" #include "ephy-view-source-handler.h" -#include #include #include #include @@ -416,27 +415,3 @@ ephy_embed_utils_shutdown (void) g_clear_pointer (&non_search_regex, g_regex_unref); g_clear_pointer (&domain_regex, g_regex_unref); } - -gboolean -ephy_embed_utils_mime_type_is_supported_evince_document (const char *mime_type) -{ - GList *doc_types = ev_backends_manager_get_all_types_info (); - GList *l; - gboolean found = FALSE; - - for (l = doc_types; l != NULL && !found; l = l->next) { - EvTypeInfo *info = (EvTypeInfo *)l->data; - guint i; - - for (i = 0; info->mime_types[i] != NULL; ++i) { - if (g_ascii_strcasecmp (mime_type, info->mime_types[i]) == 0) { - found = TRUE; - break; - } - } - } - - g_list_free (doc_types); - - return found; -} diff --git a/embed/ephy-embed-utils.h b/embed/ephy-embed-utils.h index 4bd0f65028ccc3e11b3c0913bf1f11ddd02e0cde..3f99b7d897266ad4c70517cb7a3df3e1906eedc9 100644 --- a/embed/ephy-embed-utils.h +++ b/embed/ephy-embed-utils.h @@ -36,19 +36,18 @@ G_BEGIN_DECLS #define EPHY_WEBKIT_BACK_FORWARD_LIMIT 100 -char* ephy_embed_utils_link_message_parse (const char *message); -gboolean ephy_embed_utils_address_has_web_scheme (const char *address); -gboolean ephy_embed_utils_address_is_existing_absolute_filename (const char *address); -gboolean ephy_embed_utils_address_is_valid (const char *address); -char* ephy_embed_utils_normalize_address (const char *address); -char * ephy_embed_utils_autosearch_address (const char *search_key); -char * ephy_embed_utils_normalize_or_autosearch_address (const char *address); -gboolean ephy_embed_utils_url_is_empty (const char *location); -gboolean ephy_embed_utils_is_no_show_address (const char *address); -char *ephy_embed_utils_get_title_from_address (const char *address); -gboolean ephy_embed_utils_urls_have_same_origin (const char *a_url, - const char *b_url); -void ephy_embed_utils_shutdown (void); -gboolean ephy_embed_utils_mime_type_is_supported_evince_document (const char *mime_type); +char* ephy_embed_utils_link_message_parse (const char *message); +gboolean ephy_embed_utils_address_has_web_scheme (const char *address); +gboolean ephy_embed_utils_address_is_existing_absolute_filename (const char *address); +gboolean ephy_embed_utils_address_is_valid (const char *address); +char* ephy_embed_utils_normalize_address (const char *address); +char * ephy_embed_utils_autosearch_address (const char *search_key); +char * ephy_embed_utils_normalize_or_autosearch_address (const char *address); +gboolean ephy_embed_utils_url_is_empty (const char *location); +gboolean ephy_embed_utils_is_no_show_address (const char *address); +char *ephy_embed_utils_get_title_from_address (const char *address); +gboolean ephy_embed_utils_urls_have_same_origin (const char *a_url, + const char *b_url); +void ephy_embed_utils_shutdown (void); G_END_DECLS diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 7a1d5a66b9b31831d5f12dd3f87ad367216b4ca6..0cea1428b223b5d8edcc5a99e77bfcef8133879e 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -29,7 +29,6 @@ #include "ephy-embed-prefs.h" #include "ephy-embed-shell.h" #include "ephy-embed-utils.h" -#include "ephy-evince-document-view.h" #include "ephy-find-toolbar.h" #include "ephy-notification-container.h" #include "ephy-prefs.h" @@ -66,7 +65,6 @@ struct _EphyEmbed { GtkWidget *floating_bar; GtkWidget *progress; GtkWidget *fullscreen_message_label; - GtkWidget *document_view; char *title; WebKitURIRequest *delayed_request; @@ -76,9 +74,6 @@ struct _EphyEmbed { GSList *messages; GSList *keys; - EphyEmbedMode mode; - char *saved_title; - guint seq_context_id; guint seq_message_id; @@ -392,7 +387,6 @@ ephy_embed_dispose (GObject *object) embed->fullscreen_message_id = 0; } - g_clear_pointer (&embed->saved_title, g_free); g_clear_object (&embed->delayed_request); g_clear_pointer (&embed->delayed_state, webkit_web_view_session_state_unref); @@ -1024,86 +1018,3 @@ ephy_embed_detach_notification_container (EphyEmbed *embed) gtk_container_remove (GTK_CONTAINER (embed->overlay), g_object_ref (GTK_WIDGET (container))); } } - -void -ephy_embed_set_mode (EphyEmbed *embed, EphyEmbedMode mode) -{ - g_assert (EPHY_IS_EMBED (embed)); - - if (embed->mode == mode) - return; - - switch (mode) { - case EPHY_EMBED_MODE_WEB_VIEW: - if (embed->document_view != NULL) { - gtk_widget_destroy (embed->document_view); - embed->document_view = NULL; - } - gtk_widget_set_visible (GTK_WIDGET (embed->paned), TRUE); - - if (embed->saved_title) { - ephy_embed_set_title (embed, embed->saved_title); - g_clear_pointer (&embed->saved_title, g_free); - } - break; - case EPHY_EMBED_MODE_EVINCE_DOCUMENT: - gtk_widget_set_visible (GTK_WIDGET (embed->paned), FALSE); - embed->document_view = ephy_evince_document_view_new (); - ephy_evince_document_set_embed (EPHY_EVINCE_DOCUMENT_VIEW (embed->document_view), embed); - gtk_box_pack_start (GTK_BOX (embed), - embed->document_view, - TRUE, TRUE, 0); - gtk_widget_show_all (embed->document_view); - break; - } - - embed->mode = mode; -} - -EphyEmbedMode -ephy_embed_get_mode (EphyEmbed *embed) -{ - return embed->mode; -} - -static void -document_download_failed_cb (WebKitDownload *download, - GError *error, - EphyEmbed *embed) -{ - /* Error occured: Switch back to web view */ - ephy_embed_set_mode (embed, EPHY_EMBED_MODE_WEB_VIEW); -} - -static void -document_download_finished_cb (WebKitDownload *download, - EphyEmbed *embed) -{ - const char *document_uri = webkit_download_get_destination (download); - - if (!embed->document_view) - return; - - ephy_evince_document_view_load_uri (EPHY_EVINCE_DOCUMENT_VIEW (embed->document_view), - document_uri); - - embed->saved_title = g_strdup (embed->title); - ephy_embed_set_title (embed, g_path_get_basename (document_uri)); -} - -gboolean -ephy_embed_download_started (EphyEmbed *embed, - EphyDownload *ephy_download) -{ - WebKitDownload *download = ephy_download_get_webkit_download (ephy_download); - gboolean ret = FALSE; - - if (embed->mode == EPHY_EMBED_MODE_EVINCE_DOCUMENT) { - ephy_download_enable_evince_document_mode (ephy_download); - g_signal_connect (download, "failed", G_CALLBACK (document_download_failed_cb), embed); - g_signal_connect (download, "finished", G_CALLBACK (document_download_finished_cb), embed); - ret = TRUE; - } - - return ret; -} diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index 1eeb39e83c112e146bbc71fe9e59815f3f81fd09..919a6d3662c922acbd7970911aa5bb203a0dcd5f 100644 --- a/embed/ephy-embed.h +++ b/embed/ephy-embed.h @@ -37,11 +37,6 @@ typedef enum { EPHY_EMBED_TOP_WIDGET_POLICY_DESTROY_ON_TRANSITION } EphyEmbedTopWidgetPolicy; -typedef enum { - EPHY_EMBED_MODE_WEB_VIEW, - EPHY_EMBED_MODE_EVINCE_DOCUMENT -} EphyEmbedMode; - EphyWebView* ephy_embed_get_web_view (EphyEmbed *embed); EphyFindToolbar* ephy_embed_get_find_toolbar (EphyEmbed *embed); void ephy_embed_add_top_widget (EphyEmbed *embed, @@ -59,10 +54,5 @@ gboolean ephy_embed_inspector_is_loaded (EphyEmbed *embed); const char *ephy_embed_get_title (EphyEmbed *embed); void ephy_embed_attach_notification_container (EphyEmbed *embed); void ephy_embed_detach_notification_container (EphyEmbed *embed); -void ephy_embed_set_mode (EphyEmbed *embed, - EphyEmbedMode mode); -EphyEmbedMode ephy_embed_get_mode (EphyEmbed *embed); -gboolean ephy_embed_download_started (EphyEmbed *embed, - EphyDownload *ephy_download); G_END_DECLS diff --git a/embed/ephy-evince-document-view.c b/embed/ephy-evince-document-view.c deleted file mode 100644 index 6d4ffd401d53e1bdf506d3d888158a9954c56d04..0000000000000000000000000000000000000000 --- a/embed/ephy-evince-document-view.c +++ /dev/null @@ -1,332 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ -/* vim: set sw=2 ts=2 sts=2 et: */ -/* - * Copyright © 2012 Igalia S.L. - * Copyright © 2018 Jan-Michael Brummer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "ephy-evince-document-view.h" -#include "ephy-embed-shell.h" - -#include - -#include -#include -#include - -struct _EphyEvinceDocumentView { - GtkBox parent_instance; - - GtkWidget *view; - GtkWidget *current_page; - GtkWidget *total_page; - GtkWidget *sizing_mode; - GtkWidget *popup; - - EphyEmbed *embed; - - EvJob *job; - EvDocumentModel *model; - SoupURI *uri; -}; - -G_DEFINE_TYPE (EphyEvinceDocumentView, ephy_evince_document_view, GTK_TYPE_BOX) - -static void -ephy_evince_document_view_finalize (GObject *object) -{ - EphyEvinceDocumentView *self = EPHY_EVINCE_DOCUMENT_VIEW (object); - - if (self->uri != NULL) { - g_unlink (self->uri->path); - - g_clear_pointer (&self->uri, soup_uri_free); - } - - if (self->job != NULL) { - ev_job_cancel (self->job); - g_clear_object (&self->job); - } - - g_clear_object (&self->model); - - G_OBJECT_CLASS (ephy_evince_document_view_parent_class)->finalize (object); -} - -static void -on_save_button_clicked (GtkButton *button, - EphyEvinceDocumentView *self) -{ - g_autoptr (GtkFileChooserNative) native = NULL; - GtkFileChooser *chooser; - GError *error = NULL; - gint res; - g_autofree gchar *basename = g_path_get_basename (self->uri->path); - - native = gtk_file_chooser_native_new (_("Save File"), - NULL, - GTK_FILE_CHOOSER_ACTION_SAVE, - NULL, - NULL); - - chooser = GTK_FILE_CHOOSER (native); - - gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE); - - gtk_file_chooser_set_current_name (chooser, basename); - - res = gtk_native_dialog_run (GTK_NATIVE_DIALOG (native)); - if (res == GTK_RESPONSE_ACCEPT) { - g_autofree gchar *filename; - GFile *source = g_file_new_for_uri (self->uri->path); - GFile *dest; - - filename = gtk_file_chooser_get_filename (chooser); - dest = g_file_new_for_path (filename); - - if (!g_file_copy (source, dest, G_FILE_COPY_NONE, NULL, NULL, NULL, &error)) { - g_warning ("%s(): Could not copy file: %s\n", __FUNCTION__, error->message); - g_error_free (error); - } - } -} - -static void -view_external_link_cb (EvView *view, - EvLinkAction *action, - EphyEvinceDocumentView *self) -{ - EvLinkActionType type = ev_link_action_get_action_type (action); - EphyWebView *webview; - const gchar *url; - - if (type != EV_LINK_ACTION_TYPE_EXTERNAL_URI) - return; - - url = ev_link_action_get_uri (action); - - webview = ephy_embed_get_web_view (self->embed); - ephy_web_view_load_url (webview, url); -} - -static void -ephy_evince_document_view_constructed (GObject *object) -{ - EphyEvinceDocumentView *self = EPHY_EVINCE_DOCUMENT_VIEW (object); - GtkWidget *box; - GtkWidget *entry_box; - GtkWidget *save_button; - GtkWidget *scrolled_window; - GtkWidget *separator; - - G_OBJECT_CLASS (ephy_evince_document_view_parent_class)->constructed (object); - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - - self->view = ev_view_new (); - g_signal_connect (self->view, "external-link", G_CALLBACK (view_external_link_cb), self); - gtk_container_add (GTK_CONTAINER (scrolled_window), self->view); - gtk_box_pack_start (GTK_BOX (self), scrolled_window, TRUE, TRUE, 0); - - self->model = ev_document_model_new (); - ev_view_set_model (EV_VIEW (self->view), self->model); - - separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); - gtk_box_pack_start (GTK_BOX (self), separator, FALSE, TRUE, 0); - - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_widget_set_margin_start (box, 6); - gtk_widget_set_margin_end (box, 6); - gtk_widget_set_margin_top (box, 6); - gtk_widget_set_margin_bottom (box, 6); - gtk_box_pack_start (GTK_BOX (self), box, FALSE, TRUE, 0); - - entry_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_style_context_add_class (gtk_widget_get_style_context (entry_box), GTK_STYLE_CLASS_LINKED); - gtk_style_context_add_class (gtk_widget_get_style_context (entry_box), GTK_STYLE_CLASS_RAISED); - gtk_box_pack_start (GTK_BOX (box), entry_box, FALSE, TRUE, 0); - - self->current_page = gtk_entry_new (); - gtk_entry_set_width_chars (GTK_ENTRY (self->current_page), 2); - gtk_box_pack_start (GTK_BOX (entry_box), self->current_page, FALSE, TRUE, 0); - - self->total_page = gtk_entry_new (); - gtk_entry_set_width_chars (GTK_ENTRY (self->total_page), 5); - gtk_widget_set_sensitive (self->total_page, FALSE); - gtk_box_pack_start (GTK_BOX (entry_box), self->total_page, FALSE, TRUE, 0); - - save_button = gtk_button_new_from_icon_name ("document-save-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); - g_signal_connect (save_button, "clicked", G_CALLBACK (on_save_button_clicked), self); - gtk_box_pack_end (GTK_BOX (box), save_button, FALSE, TRUE, 0); - - self->sizing_mode = gtk_combo_box_text_new (); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (self->sizing_mode), _("Fit Page")); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (self->sizing_mode), _("Fit Width")); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (self->sizing_mode), _("Free")); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (self->sizing_mode), _("Automatic")); - gtk_box_pack_end (GTK_BOX (box), self->sizing_mode, FALSE, TRUE, 0); -} - -static void -ephy_evince_document_view_class_init (EphyEvinceDocumentViewClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->constructed = ephy_evince_document_view_constructed; - object_class->finalize = ephy_evince_document_view_finalize; -} - -static void -ephy_evince_document_view_init (EphyEvinceDocumentView *self) -{ -} - -GtkWidget * -ephy_evince_document_view_new (void) -{ - return g_object_new (EPHY_TYPE_EVINCE_DOCUMENT_VIEW, - "orientation", GTK_ORIENTATION_VERTICAL, - NULL); -} - -static void -on_page_changed (EvDocumentModel *model, - gint old_page, - gint new_page, - EphyEvinceDocumentView *self) -{ - g_autofree gchar *page = g_strdup_printf ("%d", new_page + 1); - - gtk_entry_set_text (GTK_ENTRY (self->current_page), page); -} - -static void -on_current_page_activate (GtkEntry *entry, - EphyEvinceDocumentView *self) -{ - const gchar *text = gtk_entry_get_text (entry); - gint page = atoi (text); - - ev_document_model_set_page (self->model, page - 1); -} - -static void -on_sizing_mode_changed (GtkComboBox *widget, - EphyEvinceDocumentView *self) -{ - gint index = gtk_combo_box_get_active (widget); - - ev_document_model_set_sizing_mode (self->model, index); -} - -static void -on_popup_copy_activate (GtkMenuItem *menuitem, - EphyEvinceDocumentView *self) -{ - GtkClipboard *clipboard; - g_autofree gchar *selected_text = ev_view_get_selected_text (EV_VIEW (self->view)); - - clipboard = gtk_widget_get_clipboard (GTK_WIDGET (self), GDK_SELECTION_CLIPBOARD); - gtk_clipboard_set_text (GTK_CLIPBOARD (clipboard), selected_text, strlen (selected_text)); -} - -static gboolean -on_view_popup_cb (EvView *view, - GList *items, - EphyEvinceDocumentView *self) -{ - if (!ev_view_get_has_selection (view)) - return TRUE; - - if (!self->popup) { - GtkWidget *copy = gtk_menu_item_new_with_label (_("Copy")); - self->popup = gtk_menu_new (); - g_signal_connect (copy, "activate", G_CALLBACK (on_popup_copy_activate), self); - gtk_menu_shell_append (GTK_MENU_SHELL (self->popup), copy); - gtk_menu_attach_to_widget (GTK_MENU (self->popup), GTK_WIDGET (self), NULL); - gtk_widget_show_all (self->popup); - } - - gtk_menu_popup_at_pointer (GTK_MENU (self->popup), NULL); - - return TRUE; -} - -static void -document_load_job_finished (EvJob *job, - EphyEvinceDocumentView *self) -{ - g_autofree gchar *total_pages = NULL; - gint n_pages; - - if (ev_job_is_failed (job)) { - g_warning ("Failed to load document: %s", job->error->message); - g_error_free (job->error); - - return; - } - - ev_document_model_set_document (self->model, job->document); - n_pages = ev_document_get_n_pages (job->document); - - /* Translators: Number of x total pages */ - total_pages = g_strdup_printf (_("of %d"), n_pages); - g_signal_connect (self->model, "page-changed", G_CALLBACK (on_page_changed), self); - g_signal_connect (self->current_page, "activate", G_CALLBACK (on_current_page_activate), self); - gtk_entry_set_text (GTK_ENTRY (self->total_page), total_pages); - gtk_entry_set_text (GTK_ENTRY (self->current_page), "1"); - g_signal_connect (self->sizing_mode, "changed", G_CALLBACK (on_sizing_mode_changed), self); - gtk_combo_box_set_active (GTK_COMBO_BOX (self->sizing_mode), ev_document_model_get_sizing_mode (self->model)); - - g_signal_connect_object (self->view, "popup", G_CALLBACK (on_view_popup_cb), self, 0); -} - -void -ephy_evince_document_view_load_uri (EphyEvinceDocumentView *self, - const char *uri) -{ - g_return_if_fail (EPHY_EVINCE_DOCUMENT_VIEW (self)); - g_return_if_fail (uri != NULL); - - if (self->uri != NULL) { - if (strcmp (self->uri->path, uri) != 0) - g_unlink (self->uri->path); - - g_clear_pointer (&self->uri, soup_uri_free); - } - - if (self->job != NULL) { - ev_job_cancel (self->job); - - g_clear_object (&self->job); - } - - self->uri = soup_uri_new (uri); - - self->job = ev_job_load_new (uri); - g_signal_connect_object (self->job, "finished", G_CALLBACK (document_load_job_finished), self, 0); - ev_job_scheduler_push_job (self->job, EV_JOB_PRIORITY_NONE); -} - -void -ephy_evince_document_set_embed (EphyEvinceDocumentView *self, - EphyEmbed *embed) -{ - self->embed = embed; -} diff --git a/embed/ephy-evince-document-view.h b/embed/ephy-evince-document-view.h deleted file mode 100644 index 6f9b0617f838e6580dc6770b7cbe11e28abc4342..0000000000000000000000000000000000000000 --- a/embed/ephy-evince-document-view.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ -/* vim: set sw=2 ts=2 sts=2 et: */ -/* - * Copyright © 2012 Igalia S.L. - * Copyright © 2018 Jan-Michael Brummer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef _EPHY_EVINCE_DOCUMENT_VIEW_H -#define _EPHY_EVINCE_DOCUMENT_VIEW_H - -#include - -#include "ephy-embed.h" - -G_BEGIN_DECLS - -#define EPHY_TYPE_EVINCE_DOCUMENT_VIEW (ephy_evince_document_view_get_type ()) - -G_DECLARE_FINAL_TYPE (EphyEvinceDocumentView, ephy_evince_document_view, EPHY, EVINCE_DOCUMENT_VIEW, GtkBox) - - -GType ephy_evince_document_view_get_type (void); - -GtkWidget *ephy_evince_document_view_new (void); -void ephy_evince_document_view_load_uri (EphyEvinceDocumentView *self, - const char *uri); -void ephy_evince_document_set_embed (EphyEvinceDocumentView *self, - EphyEmbed *embed); - -G_END_DECLS - -#endif /* _EPHY_EVINCE_DOCUMENT_VIEW_H */ diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index ae9b2a2dc8f75789b3a3e890737cf5f6db905f61..2155d482be7f77f77c5feab66904c4e399dc12b1 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -1053,10 +1053,9 @@ static gboolean run_readability_js_if_needed (gpointer data) { EphyWebView *web_view = data; - EphyEmbed *embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view); - /* Internal pages and document mode should never receive reader mode. */ - if (!ephy_embed_utils_is_no_show_address (web_view->address) && ephy_embed_get_mode (embed) != EPHY_EMBED_MODE_EVINCE_DOCUMENT) { + /* Internal pages should never receive reader mode. */ + if (!ephy_embed_utils_is_no_show_address (web_view->address)) { webkit_web_view_run_javascript_from_gresource (WEBKIT_WEB_VIEW (web_view), "/org/gnome/epiphany/readability.js", NULL, @@ -1431,12 +1430,6 @@ decide_policy_cb (WebKitWebView *web_view, response = webkit_response_policy_decision_get_response (response_decision); mime_type = webkit_uri_response_get_mime_type (response); - if (ephy_embed_utils_mime_type_is_supported_evince_document (mime_type)) { - EphyEmbed *embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view); - - ephy_embed_set_mode (embed, EPHY_EMBED_MODE_EVINCE_DOCUMENT); - } - /* If WebKit can't handle the mime type start the download process */ if (webkit_response_policy_decision_is_mime_type_supported (response_decision)) @@ -1892,7 +1885,6 @@ load_changed_cb (WebKitWebView *web_view, gpointer user_data) { EphyWebView *view = EPHY_WEB_VIEW (web_view); - EphyEmbed *embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view); GObject *object = G_OBJECT (web_view); g_object_freeze_notify (object); @@ -1902,7 +1894,6 @@ load_changed_cb (WebKitWebView *web_view, const char *loading_uri = NULL; view->load_failed = FALSE; - ephy_embed_set_mode (embed, EPHY_EMBED_MODE_WEB_VIEW); if (view->snapshot_timeout_id) { g_source_remove (view->snapshot_timeout_id); diff --git a/embed/meson.build b/embed/meson.build index fad2a2956e97ce48df8ae67597140971d82cf0c6..c3c11704f6b92c8fdedddee04640283f333be767 100644 --- a/embed/meson.build +++ b/embed/meson.build @@ -22,7 +22,6 @@ libephyembed_sources = [ 'ephy-embed-utils.c', 'ephy-encoding.c', 'ephy-encodings.c', - 'ephy-evince-document-view.c', 'ephy-file-monitor.c', 'ephy-filters-manager.c', 'ephy-find-toolbar.c', @@ -35,8 +34,6 @@ libephyembed_sources = [ libephyembed_deps = [ libdazzle_dep, ephymisc_dep, - evince_document_dep, - evince_view_dep, gio_dep, glib_dep, gtk_dep, diff --git a/flatpak/org.gnome.Epiphany.json b/flatpak/org.gnome.Epiphany.json index 0b4ed5ad2275c9fc4e15de1e74141124f3ce9e78..6d00eadee01d3d9cf7eeb1b81cada93f6c954df6 100644 --- a/flatpak/org.gnome.Epiphany.json +++ b/flatpak/org.gnome.Epiphany.json @@ -68,31 +68,6 @@ } ] }, - { - "name" : "evince", - "buildsystem" : "meson", - "config-opts" : [ - "-Dplatform=gnome", - "-Dviewer=false", - "-Dpreviewer=false", - "-Dthumbnailer=false", - "-Dnautilus=false", - "-Dgtk_doc=false", - "-Dintrospection=false", - "-Ddbus=false", - "-Dkeyring=disabled", - "-Dgtk_unix_print=disabled", - "-Dthumbnail_cache=disabled", - "-Dgspell=disabled", - "-Dsystemduserunitdir=no" - ], - "sources" : [ - { - "type" : "git", - "url" : "https://gitlab.gnome.org/GNOME/evince.git" - } - ] - }, { "name" : "epiphany", "config-opts" : [ diff --git a/meson.build b/meson.build index 956e6ad6b5a91b219e879aa0b88a1fa6386b15cc..12623a28b2b3c8347d5af0e529a870b6a6f893dc 100644 --- a/meson.build +++ b/meson.build @@ -85,8 +85,6 @@ nettle_requirement = '>= 3.4' webkitgtk_requirement = '>= 2.21.92' cairo_dep = dependency('cairo', version: '>= 1.2') -evince_document_dep = dependency('evince-document-3.0') -evince_view_dep = dependency('evince-view-3.0') gcr_dep = dependency('gcr-3', version: '>= 3.5.5') gdk_dep = dependency('gdk-3.0', version: gtk_requirement) gdk_pixbuf_dep = dependency('gdk-pixbuf-2.0', version: '>= 2.36.5') diff --git a/src/ephy-action-bar-end.c b/src/ephy-action-bar-end.c index 9074392d07ab4da691a909bc2a48a41da7e9ac6c..d20f10b433e07c2305b0ab41e8a1d2fcf923ec96 100644 --- a/src/ephy-action-bar-end.c +++ b/src/ephy-action-bar-end.c @@ -23,8 +23,6 @@ #include "ephy-downloads-popover.h" #include "ephy-downloads-progress-icon.h" -#include "ephy-embed.h" -#include "ephy-embed-container.h" #include "ephy-shell.h" #include "ephy-window.h" @@ -46,19 +44,6 @@ struct _EphyActionBarEnd { G_DEFINE_TYPE (EphyActionBarEnd, ephy_action_bar_end, GTK_TYPE_BOX) -static gboolean -is_document_view_active (void) -{ - EphyShell *shell = ephy_shell_get_default (); - GtkWindow *window; - EphyEmbed *embed; - - window = gtk_application_get_active_window (GTK_APPLICATION (shell)); - embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window)); - - return ephy_embed_get_mode (embed) == EPHY_EMBED_MODE_EVINCE_DOCUMENT; -} - static void remove_downloads_button_attention_style (EphyActionBarEnd *self) { @@ -101,9 +86,6 @@ download_added_cb (EphyDownloadsManager *manager, GtkAllocation rect; DzlBoxTheatric *theatric; - if (is_document_view_active ()) - return; - if (!action_bar_end->downloads_popover) { action_bar_end->downloads_popover = ephy_downloads_popover_new (action_bar_end->downloads_button); gtk_menu_button_set_popover (GTK_MENU_BUTTON (action_bar_end->downloads_button), diff --git a/src/ephy-main.c b/src/ephy-main.c index 0796393c8c2f1b940ecce47a1879568380ed2fd0..8779520752243ec502d81e31f02b448f003f5765 100644 --- a/src/ephy-main.c +++ b/src/ephy-main.c @@ -33,7 +33,6 @@ #include "ephy-web-app-utils.h" #include -#include #include #include #include @@ -409,7 +408,6 @@ main (int argc, } hdy_init (&argc, &argv); - ev_init (); _ephy_shell_create_instance (mode); @@ -435,7 +433,6 @@ main (int argc, if (notify_is_initted ()) notify_uninit (); - ev_shutdown (); ephy_settings_shutdown (); ephy_file_helpers_shutdown (); xmlCleanupParser (); diff --git a/src/ephy-window.c b/src/ephy-window.c index d6d34c85c45ef511e2c29afcbe7d2456895c7258..c6065e4cff431d9822fe0bb26f2c8559e5ed7abf 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -2602,18 +2602,12 @@ static void download_only_load_cb (EphyWebView *view, EphyWindow *window) { - EphyEmbed *embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view); - - /* Do not close tab if evince document mode is active */ - if (ephy_embed_get_mode (embed) == EPHY_EMBED_MODE_EVINCE_DOCUMENT) - return; - if (gtk_notebook_get_n_pages (window->notebook) == 1) { ephy_web_view_load_homepage (view); return; } - g_idle_add (delayed_remove_child, embed); + g_idle_add (delayed_remove_child, EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view)); } static void diff --git a/src/window-commands.c b/src/window-commands.c index 9e53f69e21f48fc89c17e519c7a07f083235f485..ba230af99181f9dfbca9c04a3a549a19561fe283 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -668,13 +668,7 @@ window_cmd_navigation (GSimpleAction *action, web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed); if (strstr (g_action_get_name (G_ACTION (action)), "back")) { - gboolean in_document_mode = ephy_embed_get_mode (embed) == EPHY_EMBED_MODE_EVINCE_DOCUMENT; - - if (in_document_mode) - ephy_embed_set_mode (embed, EPHY_EMBED_MODE_WEB_VIEW); - else - webkit_web_view_go_back (web_view); - + webkit_web_view_go_back (web_view); gtk_widget_grab_focus (GTK_WIDGET (embed)); } else { webkit_web_view_go_forward (web_view);