#endif
#include "ev-window.h"
+#include "ev-window-title.h"
#include "ev-page-action.h"
#include "ev-sidebar.h"
#include "ev-sidebar-links.h"
#include "ev-password.h"
#include "ev-password-view.h"
#include "ev-print-job.h"
+#include "ev-properties-dialog.h"
+#include "ev-ps-exporter.h"
#include "ev-document-thumbnails.h"
#include "ev-document-links.h"
-#include "ev-document-types.h"
+#include "ev-document-fonts.h"
#include "ev-document-find.h"
#include "ev-document-security.h"
+#include "ev-document-types.h"
#include "ev-job-queue.h"
+#include "ev-jobs.h"
+#include "ev-sidebar-page.h"
#include "eggfindbar.h"
-#include "egg-recent-view-gtk.h"
+#include "egg-recent-view-uimanager.h"
#include "egg-recent-view.h"
-#include "egg-recent-model.h"
#include "egg-toolbar-editor.h"
-#include "egg-toolbars-model.h"
#include "egg-editable-toolbar.h"
+#include "egg-recent-model.h"
+#include "egg-toolbars-model.h"
#include "ephy-zoom.h"
#include "ephy-zoom-action.h"
#include "ev-application.h"
#include "ev-stock-icons.h"
+#include "ev-metadata-manager.h"
#include "ev-file-helpers.h"
+#include "ev-utils.h"
+#include "ev-debug.h"
+
#include <poppler.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gnome.h>
-
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
#include <libgnomeprintui/gnome-print-dialog.h>
-
+#include <libgnomevfs/gnome-vfs-utils.h>
#include <gconf/gconf-client.h>
#include <string.h>
typedef enum {
EV_CHROME_MENUBAR = 1 << 0,
EV_CHROME_TOOLBAR = 1 << 1,
- EV_CHROME_SIDEBAR = 1 << 2,
- EV_CHROME_FINDBAR = 1 << 3,
- EV_CHROME_STATUSBAR = 1 << 4,
- EV_CHROME_NORMAL = EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR | EV_CHROME_SIDEBAR | EV_CHROME_STATUSBAR
+ EV_CHROME_FINDBAR = 1 << 2,
+ EV_CHROME_RAISE_TOOLBAR = 1 << 3,
+ EV_CHROME_NORMAL = EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR
} EvChrome;
struct _EvWindowPrivate {
+ /* UI */
+ EvChrome chrome;
+
GtkWidget *main_box;
GtkWidget *menubar;
GtkWidget *toolbar_dock;
GtkWidget *view;
GtkWidget *page_view;
GtkWidget *password_view;
+ GtkWidget *sidebar_thumbs;
+ GtkWidget *sidebar_links;
+
+ EvWindowTitle *title;
+
+ /* Dialogs */
+ GtkWidget *properties;
+ /* UI Builders */
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
- gchar *toolbar_file;
- EggToolbarsModel *toolbar_model;
-
- GtkWidget *statusbar;
- guint help_message_cid;
- guint view_message_cid;
+ /* Fullscreen mode */
GtkWidget *fullscreen_toolbar;
GtkWidget *fullscreen_popup;
- char *uri;
+ GSource *fullscreen_timeout_source;
+ /* Document */
+ char *uri;
+ char *local_uri;
EvDocument *document;
EvPageCache *page_cache;
EvWindowPageMode page_mode;
+
/* These members are used temporarily when in PAGE_MODE_PASSWORD */
EvDocument *password_document;
GtkWidget *password_dialog;
char *password_uri;
- EvChrome chrome;
- GSource *fullscreen_timeout_source;
+ /* Job used to load document */
+ EvJob *xfer_job;
+ EvJob *load_job;
- /* recent file stuff */
- EggRecentModel *recent_model;
- EggRecentViewGtk *recent_view;
+ EggRecentViewUIManager *recent_view;
};
static const GtkTargetEntry ev_drop_types[] = {
#define PAGE_SELECTOR_ACTION "PageSelector"
#define ZOOM_CONTROL_ACTION "ViewZoom"
-#define GCONF_CHROME_TOOLBAR "/apps/evince/show_toolbar"
-#define GCONF_CHROME_SIDEBAR "/apps/evince/show_sidebar"
-#define GCONF_CHROME_STATUSBAR "/apps/evince/show_statusbar"
+#define GCONF_OVERRIDE_RESTRICTIONS "/apps/evince/override_restrictions"
+#define GCONF_LOCKDOWN_SAVE "/desktop/gnome/lockdown/disable_save_to_disk"
+#define GCONF_LOCKDOWN_PRINT "/desktop/gnome/lockdown/disable_printing"
-#define GCONF_SIDEBAR_SIZE "/apps/evince/sidebar_size"
+#define FULLSCREEN_TIMEOUT 5 * 1000
#define SIDEBAR_DEFAULT_SIZE 132
+#define LINKS_SIDEBAR_ID "links"
+#define THUMBNAILS_SIDEBAR_ID "thumbnails"
+
+#define PRINT_CONFIG_FILENAME "ev-print-config.xml"
static void ev_window_update_fullscreen_popup (EvWindow *window);
static void ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar,
EvWindow *ev_window);
static void ev_window_set_page_mode (EvWindow *window,
EvWindowPageMode page_mode);
-static gboolean start_loading_document (EvWindow *ev_window,
- EvDocument *document,
- const char *uri);
+static void ev_window_load_job_cb (EvJobLoad *job,
+ gpointer data);
+static void ev_window_xfer_job_cb (EvJobXfer *job,
+ gpointer data);
static void ev_window_sizing_mode_changed_cb (EvView *view,
GParamSpec *pspec,
EvWindow *ev_window);
EvWindow *ev_window);
static void ev_window_add_recent (EvWindow *window,
const char *filename);
-static void ev_window_fullscreen (EvWindow *window);
-static void ev_window_unfullscreen (EvWindow *window);
+static void ev_window_run_fullscreen (EvWindow *window);
+static void ev_window_stop_fullscreen (EvWindow *window);
static void ev_window_cmd_view_fullscreen (GtkAction *action,
EvWindow *window);
static void ev_window_run_presentation (EvWindow *window);
static void ev_window_stop_presentation (EvWindow *window);
static void ev_window_cmd_view_presentation (GtkAction *action,
EvWindow *window);
+static void show_fullscreen_popup (EvWindow *window);
G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
int n_pages = 0, page = -1;
gboolean ok_to_print = TRUE;
gboolean ok_to_copy = TRUE;
+ gboolean has_properties = TRUE;
+ gboolean override_restrictions = FALSE;
+ gboolean can_get_text = FALSE;
+ gboolean ok_to_copy_text = FALSE;
+ GConfClient *client;
view = EV_VIEW (ev_window->priv->view);
+
document = ev_window->priv->document;
+
if (document)
info = ev_page_cache_get_info (ev_window->priv->page_cache);
+
page_mode = ev_window->priv->page_mode;
has_document = document != NULL;
+
if (has_document && ev_window->priv->page_cache) {
page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
has_pages = has_document && n_pages > 0;
}
- if (info && info->fields_mask & EV_DOCUMENT_INFO_PERMISSIONS) {
+ client = gconf_client_get_default ();
+ override_restrictions = gconf_client_get_bool (client,
+ GCONF_OVERRIDE_RESTRICTIONS,
+ NULL);
+ if (!override_restrictions && info && info->fields_mask & EV_DOCUMENT_INFO_PERMISSIONS) {
ok_to_print = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT);
ok_to_copy = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_COPY);
}
+ if (has_document && !EV_IS_PS_EXPORTER(document))
+ ok_to_print = FALSE;
+
+ if (!info || info->fields_mask == 0) {
+ has_properties = FALSE;
+ }
+
+ if (gconf_client_get_bool (client, GCONF_LOCKDOWN_SAVE, NULL)) {
+ ok_to_copy = FALSE;
+ }
+
+ if (gconf_client_get_bool (client, GCONF_LOCKDOWN_PRINT, NULL)) {
+ ok_to_print = FALSE;
+ }
+
+ g_object_unref (client);
+
+ if (has_document && ev_document_can_get_text (document)) {
+ can_get_text = TRUE;
+ ok_to_copy_text = ev_view_get_has_selection (view);
+ }
+
/* File menu */
/* "FileOpen": always sensitive */
set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy);
set_action_sensitive (ev_window, "FilePrint", has_pages && ok_to_print);
+ set_action_sensitive (ev_window, "FileProperties", has_document && has_properties);
/* "FileCloseWindow": always sensitive */
/* Edit menu */
-
sensitive = has_pages && ev_document_can_get_text (document);
- set_action_sensitive (ev_window, "EditCopy", sensitive && ok_to_copy);
- set_action_sensitive (ev_window, "EditSelectAll", sensitive && ok_to_copy);
+ set_action_sensitive (ev_window, "EditCopy", sensitive && ok_to_copy_text);
+ set_action_sensitive (ev_window, "EditSelectAll", sensitive && can_get_text);
set_action_sensitive (ev_window, "EditFind",
has_pages && EV_IS_DOCUMENT_FIND (document));
set_action_sensitive (ev_window, "Slash",
has_pages && EV_IS_DOCUMENT_FIND (document));
set_action_sensitive (ev_window, "EditFindNext",
ev_view_can_find_next (view));
+ set_action_sensitive (ev_window, "EditRotateLeft", has_pages);
+ set_action_sensitive (ev_window, "EditRotateRight", has_pages);
/* View menu */
set_action_sensitive (ev_window, "ViewContinuous", has_pages);
set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
- if (has_pages && ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
+ if (has_pages &&
+ ev_view_get_sizing_mode (view) != EV_SIZING_FIT_WIDTH &&
+ ev_view_get_sizing_mode (view) != EV_SIZING_BEST_FIT) {
GtkAction *action;
float zoom;
float real_zoom;
update_chrome_visibility (EvWindow *window)
{
EvWindowPrivate *priv = window->priv;
- gboolean menubar, toolbar, sidebar, findbar, statusbar, fullscreen_toolbar;
+ gboolean menubar, toolbar, findbar, fullscreen_toolbar;
gboolean fullscreen_mode, presentation, fullscreen;
presentation = ev_view_get_presentation (EV_VIEW (priv->view));
fullscreen_mode = fullscreen || presentation;
menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !fullscreen_mode;
- toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0 && !fullscreen_mode;
- sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !fullscreen_mode;
- fullscreen_toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0;
- statusbar = (priv->chrome & EV_CHROME_STATUSBAR) != 0 && !fullscreen_mode;
+ toolbar = ((priv->chrome & EV_CHROME_TOOLBAR) != 0 ||
+ (priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && !fullscreen_mode;
+ fullscreen_toolbar = ((priv->chrome & EV_CHROME_TOOLBAR) != 0 ||
+ (priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0);
findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
set_widget_visibility (priv->menubar, menubar);
set_widget_visibility (priv->toolbar_dock, toolbar);
set_action_sensitive (window, "EditToolbar", toolbar);
- set_widget_visibility (priv->sidebar, sidebar);
set_widget_visibility (priv->find_bar, findbar);
- set_widget_visibility (priv->statusbar, statusbar);
- set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar);
if (priv->fullscreen_popup != NULL) {
- set_widget_visibility (priv->fullscreen_popup, fullscreen);
+ if (fullscreen)
+ show_fullscreen_popup (window);
+ else
+ set_widget_visibility (priv->fullscreen_popup, FALSE);
+
+ set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar);
}
}
static void
-update_chrome_flag (EvWindow *window, EvChrome flag, const char *pref, gboolean active)
+update_chrome_flag (EvWindow *window, EvChrome flag, gboolean active)
{
EvWindowPrivate *priv = window->priv;
- GConfClient *client;
if (active) {
priv->chrome |= flag;
- }
- else {
+ } else {
priv->chrome &= ~flag;
}
- if (pref != NULL) {
- client = gconf_client_get_default ();
- gconf_client_set_bool (client, pref, active, NULL);
- g_object_unref (client);
- }
-
update_chrome_visibility (window);
}
{
GtkAction *action;
+ update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, TRUE);
+ set_action_sensitive (window, "ViewToolbar", FALSE);
+
action = gtk_action_group_get_action (window->priv->action_group,
PAGE_SELECTOR_ACTION);
ev_page_action_grab_focus (EV_PAGE_ACTION (action));
{
g_return_val_if_fail (EV_IS_WINDOW (ev_window), FALSE);
- return ev_window->priv->document == NULL;
+ return (ev_window->priv->document == NULL) &&
+ (ev_window->priv->load_job == NULL) &&
+ (ev_window->priv->xfer_job == NULL);
+}
+
+static void
+unable_to_load_dialog_response_cb (GtkWidget *dialog,
+ gint response_id,
+ EvWindow *ev_window)
+{
+ gtk_widget_destroy (dialog);
}
static void
_("Unable to open document"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%s", error_message);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (unable_to_load_dialog_response_cb),
+ ev_window);
+ gtk_widget_show (dialog);
}
static void
-update_window_title (EvDocument *document, GParamSpec *pspec, EvWindow *ev_window)
+find_changed_cb (EvDocument *document, int page, EvWindow *ev_window)
{
- char *title = NULL;
- char *doc_title = NULL;
- gboolean password_needed;
-
- password_needed = (ev_window->priv->password_document != NULL);
- if (document && ev_window->priv->page_cache) {
- doc_title = ev_page_cache_get_title (ev_window->priv->page_cache);
-
- /* Make sure we get a valid title back */
- if (doc_title) {
- if (doc_title[0] == '\000' ||
- !g_utf8_validate (doc_title, -1, NULL)) {
- g_free (doc_title);
- doc_title = NULL;
- }
- }
- }
+ update_action_sensitivity (ev_window);
+}
- if (doc_title) {
- char *p;
+static void
+page_changed_cb (EvPageCache *page_cache,
+ gint page,
+ EvWindow *ev_window)
+{
+ update_action_sensitivity (ev_window);
- for (p = doc_title; *p; ++p) {
- /* an '\n' byte is always ASCII, no need for UTF-8 special casing */
- if (*p == '\n')
- *p = ' ';
- }
+ if (ev_window->priv->uri) {
+ ev_metadata_manager_set_int (ev_window->priv->uri, "page", page);
}
+}
- if (doc_title == NULL && ev_window->priv->uri) {
- char *basename;
-
- basename = g_path_get_basename (ev_window->priv->uri);
- doc_title = gnome_vfs_unescape_string_for_display (basename);
- g_free (basename);
+static void
+update_document_mode (EvWindow *window, EvDocumentMode mode)
+{
+ if (mode == EV_DOCUMENT_MODE_PRESENTATION) {
+ ev_window_run_presentation (window);
}
-
- if (password_needed) {
- if (doc_title == NULL) {
- title = g_strdup (_("Document Viewer - Password Required"));
- } else {
- title = g_strdup_printf (_("%s - Password Required"), doc_title);
- }
- } else {
- if (doc_title == NULL) {
- title = g_strdup (_("Document Viewer"));
- } else {
- title = g_strdup (doc_title);
- }
+ else if (mode == EV_DOCUMENT_MODE_FULL_SCREEN) {
+ ev_window_run_fullscreen (window);
}
+}
- gtk_window_set_title (GTK_WINDOW (ev_window), title);
+static void
+update_sidebar_visibility (EvWindow *window)
+{
+ char *uri = window->priv->uri;
+ GValue sidebar_visibility = { 0, };
- g_free (doc_title);
- g_free (title);
+ if (uri && ev_metadata_manager_get (uri, "sidebar_visibility", &sidebar_visibility, TRUE)) {
+ set_widget_visibility (window->priv->sidebar,
+ g_value_get_boolean (&sidebar_visibility));
+ }
}
static void
-find_changed_cb (EvDocument *document, int page, EvWindow *ev_window)
+setup_document_from_metadata (EvWindow *window)
{
- update_action_sensitivity (ev_window);
+ char *uri = window->priv->uri;
+ GValue page = { 0, };
+
+ /* Page */
+ if (uri && ev_metadata_manager_get (uri, "page", &page, TRUE)) {
+ ev_page_cache_set_current_page (window->priv->page_cache,
+ g_value_get_int (&page));
+ }
}
static void
-page_changed_cb (EvPageCache *page_cache,
- gint page,
- EvWindow *ev_window)
+setup_chrome_from_metadata (EvWindow *window)
{
- update_action_sensitivity (ev_window);
+ EvChrome chrome = EV_CHROME_NORMAL;
+ GValue show_toolbar = { 0, };
+
+ if (ev_metadata_manager_get (NULL, "show_toolbar", &show_toolbar, FALSE)) {
+ if (!g_value_get_boolean (&show_toolbar));
+ chrome &= ~EV_CHROME_TOOLBAR;
+ }
+ window->priv->chrome = chrome;
}
+
static void
-update_document_mode (EvWindow *window, EvDocumentMode mode)
+setup_sidebar_from_metadata (EvWindow *window, EvDocument *document)
{
- if (mode == EV_DOCUMENT_MODE_FULL_SCREEN) {
- ev_window_fullscreen (window);
- } else if (mode == EV_DOCUMENT_MODE_PRESENTATION) {
- ev_window_run_presentation (window);
+ char *uri = window->priv->uri;
+ GtkWidget *sidebar = window->priv->sidebar;
+ GtkWidget *links = window->priv->sidebar_links;
+ GtkWidget *thumbs = window->priv->sidebar_thumbs;
+ GValue sidebar_size = { 0, };
+ GValue sidebar_page = { 0, };
+
+ if (ev_metadata_manager_get (uri, "sidebar_size", &sidebar_size, FALSE)) {
+ gtk_paned_set_position (GTK_PANED (window->priv->hpaned),
+ g_value_get_int (&sidebar_size));
+ }
+
+ if (ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page, FALSE)) {
+ const char *page_id = g_value_get_string (&sidebar_page);
+
+ if (strcmp (page_id, "links") == 0) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
+ } else if (strcmp (page_id, "thumbnails")) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
+ }
+ } else {
+ if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
+ } else if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
+ }
}
+
+ update_sidebar_visibility (window);
}
static void
GtkAction *action;
document = ev_window->priv->document;
- ev_window->priv->page_cache = ev_document_get_page_cache (ev_window->priv->document);
+ ev_window->priv->page_cache = ev_page_cache_get (ev_window->priv->document);
g_signal_connect (ev_window->priv->page_cache, "page-changed", G_CALLBACK (page_changed_cb), ev_window);
- g_signal_connect_object (G_OBJECT (document),
- "notify::title",
- G_CALLBACK (update_window_title),
- ev_window, 0);
if (EV_IS_DOCUMENT_FIND (document)) {
g_signal_connect_object (G_OBJECT (document),
"find_changed",
ev_view_set_document (view, document);
}
- update_window_title (document, NULL, ev_window);
+ ev_window_title_set_document (ev_window->priv->title, document);
+ ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri);
action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
ev_page_action_set_document (EV_PAGE_ACTION (action), document);
update_action_sensitivity (ev_window);
info = ev_page_cache_get_info (ev_window->priv->page_cache);
update_document_mode (ev_window, info->mode);
+
+ if (ev_window->priv->properties) {
+ ev_properties_dialog_set_document (EV_PROPERTIES_DIALOG (ev_window->priv->properties),
+ ev_window->priv->document);
+ }
+
+ setup_document_from_metadata (ev_window);
+ setup_sidebar_from_metadata (ev_window, document);
}
static void
EvDocument *document;
gchar *uri;
- password = ev_password_dialog_get_password (password_dialog);
+ password = ev_password_dialog_get_password (EV_PASSWORD_DIALOG (password_dialog));
if (password) {
ev_document_doc_mutex_lock ();
ev_document_security_set_password (EV_DOCUMENT_SECURITY (ev_window->priv->password_document),
}
g_free (password);
+ ev_password_dialog_save_password (EV_PASSWORD_DIALOG (password_dialog));
+
document = ev_window->priv->password_document;
uri = ev_window->priv->password_uri;
ev_window->priv->password_document = NULL;
ev_window->priv->password_uri = NULL;
- if (start_loading_document (ev_window, document, uri)) {
- gtk_widget_destroy (password_dialog);
- }
+ ev_window_title_set_type (ev_window->priv->title, EV_WINDOW_TITLE_DOCUMENT);
+ ev_job_queue_add_job (ev_window->priv->load_job, EV_JOB_PRIORITY_HIGH);
+
+ gtk_widget_destroy (password_dialog);
+
g_object_unref (document);
g_free (uri);
gtk_widget_destroy (password_dialog);
}
-/* Called either by start_loading_document or by the "unlock" callback on the
+/* Called either by ev_window_load_job_cb or by the "unlock" callback on the
* password_view page. It assumes that ev_window->priv->password_* has been set
* correctly. These are cleared by password_dialog_response() */
gtk_widget_set_sensitive (ev_window->priv->password_view, FALSE);
- update_window_title (ev_window->priv->password_document, NULL, ev_window);
- if (ev_window->priv->password_dialog == NULL) {
- gchar *basename, *file_name;
+ ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->password_uri);
+ ev_window_title_set_type (ev_window->priv->title, EV_WINDOW_TITLE_PASSWORD);
- basename = g_path_get_basename (ev_window->priv->password_uri);
- file_name = gnome_vfs_unescape_string_for_display (basename);
+ if (ev_window->priv->password_dialog == NULL) {
ev_window->priv->password_dialog =
- ev_password_dialog_new (GTK_WIDGET (ev_window), file_name);
+ g_object_new (EV_TYPE_PASSWORD_DIALOG, "uri", ev_window->priv->password_uri, NULL);
+ gtk_window_set_transient_for (GTK_WINDOW (ev_window->priv->password_dialog), GTK_WINDOW (ev_window));
+
g_object_add_weak_pointer (G_OBJECT (ev_window->priv->password_dialog),
(gpointer *) &(ev_window->priv->password_dialog));
g_signal_connect (ev_window->priv->password_dialog,
"response",
G_CALLBACK (password_dialog_response),
ev_window);
- g_free (basename);
- g_free (file_name);
gtk_widget_show (ev_window->priv->password_dialog);
} else {
- ev_password_dialog_set_bad_pass (ev_window->priv->password_dialog);
+ ev_password_dialog_set_bad_pass (EV_PASSWORD_DIALOG (ev_window->priv->password_dialog));
}
}
-/* This wil try to load the document. It might be called multiple times on the
- * same document by the password dialog.
+
+static void
+ev_window_clear_jobs (EvWindow *ev_window)
+{
+ if (ev_window->priv->load_job != NULL) {
+
+ if (!ev_window->priv->load_job->finished)
+ ev_job_queue_remove_job (ev_window->priv->load_job);
+
+ g_signal_handlers_disconnect_by_func (ev_window->priv->load_job, ev_window_load_job_cb, ev_window);
+ g_object_unref (ev_window->priv->load_job);
+ ev_window->priv->load_job = NULL;
+ }
+
+ if (ev_window->priv->xfer_job != NULL) {
+
+ if (!ev_window->priv->xfer_job->finished)
+ ev_job_queue_remove_job (ev_window->priv->xfer_job);
+
+ g_signal_handlers_disconnect_by_func (ev_window->priv->xfer_job, ev_window_xfer_job_cb, ev_window);
+ g_object_unref (ev_window->priv->xfer_job);
+ ev_window->priv->xfer_job = NULL;
+ }
+}
+
+static void
+ev_window_clear_local_uri (EvWindow *ev_window)
+{
+ char *filename;
+
+ if (ev_window->priv->local_uri) {
+ filename = g_filename_from_uri (ev_window->priv->local_uri, NULL, NULL);
+ if (filename != NULL) {
+ unlink (filename);
+ g_free (filename);
+ }
+ g_free (ev_window->priv->local_uri);
+ ev_window->priv->local_uri = NULL;
+ }
+}
+
+/* This callback will executed when load job will be finished.
*
* Since the flow of the error dialog is very confusing, we assume that both
* document and uri will go away after this function is called, and thus we need
* ev_window->priv->password_{uri,document}, and thus people who call this
* function should _not_ necessarily expect those to exist after being
* called. */
-static gboolean
-start_loading_document (EvWindow *ev_window,
- EvDocument *document,
- const char *uri)
+static void
+ev_window_load_job_cb (EvJobLoad *job,
+ gpointer data)
{
- gboolean result;
- GError *error = NULL;
+ EvWindow *ev_window = EV_WINDOW (data);
+ EvDocument *document = EV_JOB (job)->document;
g_assert (document);
g_assert (document != ev_window->priv->document);
- g_assert (uri);
+ g_assert (job->uri);
+
if (ev_window->priv->password_document) {
g_object_unref (ev_window->priv->password_document);
ev_window->priv->password_document = NULL;
ev_window->priv->password_uri = NULL;
}
- result = ev_document_load (document, uri, &error);
-
/* Success! */
- if (result) {
+ if (job->error == NULL) {
if (ev_window->priv->document)
g_object_unref (ev_window->priv->document);
ev_window->priv->document = g_object_ref (document);
ev_window_setup_document (ev_window);
- ev_window_add_recent (ev_window, uri);
-
- return TRUE;
+ ev_window_add_recent (ev_window, ev_window->priv->uri);
+ ev_window_clear_jobs (ev_window);
+
+ return;
}
- /* unable to load the document */
- g_assert (error != NULL);
-
- if (error->domain == EV_DOCUMENT_ERROR &&
- error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
+ if (job->error->domain == EV_DOCUMENT_ERROR &&
+ job->error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
gchar *base_name, *file_name;
ev_window->priv->password_document = g_object_ref (document);
- ev_window->priv->password_uri = g_strdup (uri);
-
- base_name = g_path_get_basename (uri);
- file_name = gnome_vfs_unescape_string_for_display (base_name);
+ ev_window->priv->password_uri = g_strdup (job->uri);
+ file_name = gnome_vfs_format_uri_for_display (job->uri);
+ base_name = g_path_get_basename (file_name);
ev_password_view_set_file_name (EV_PASSWORD_VIEW (ev_window->priv->password_view),
- file_name);
+ base_name);
g_free (file_name);
g_free (base_name);
ev_window_set_page_mode (ev_window, PAGE_MODE_PASSWORD);
ev_window_popup_password_dialog (ev_window);
} else {
- unable_to_load (ev_window, error->message);
- }
- g_error_free (error);
+ unable_to_load (ev_window, job->error->message);
+ }
- return FALSE;
+ return;
}
-static gboolean
-sanity_check_uri (EvWindow *window, const char *uri)
+static void
+ev_window_xfer_job_cb (EvJobXfer *job,
+ gpointer data)
{
- gboolean result = FALSE;
- GnomeVFSURI *vfs_uri;
- char *err;
-
- vfs_uri = gnome_vfs_uri_new (uri);
- if (vfs_uri) {
- if (gnome_vfs_uri_exists (vfs_uri)) {
- result = TRUE;
- }
- }
+ EvWindow *ev_window = EV_WINDOW (data);
- if (!result) {
- err = g_strdup_printf (_("The file %s does not exist."), uri);
- unable_to_load (window, err);
- g_free (err);
- }
- return result;
+
+ if (job->error != NULL) {
+ unable_to_load (ev_window, job->error->message);
+ ev_window_clear_jobs (ev_window);
+ } else {
+ char *uri;
+
+ EvDocument *document = g_object_ref (EV_JOB (job)->document);
+
+ if (job->local_uri) {
+ ev_window->priv->local_uri = g_strdup (job->local_uri);
+ uri = ev_window->priv->local_uri;
+ } else {
+ ev_window->priv->local_uri = NULL;
+ uri = ev_window->priv->uri;
+ }
+
+ ev_window_clear_jobs (ev_window);
+
+ ev_window->priv->load_job = ev_job_load_new (document, uri);
+ g_signal_connect (ev_window->priv->load_job,
+ "finished",
+ G_CALLBACK (ev_window_load_job_cb),
+ ev_window);
+ ev_job_queue_add_job (ev_window->priv->load_job, EV_JOB_PRIORITY_HIGH);
+ g_object_unref (document);
+ }
}
-void
-ev_window_open (EvWindow *ev_window, const char *uri)
+static void
+setup_view_from_metadata (EvWindow *window)
{
- EvDocument *document = NULL;
- GType document_type;
- char *mime_type = NULL;
+ EvView *view = EV_VIEW (window->priv->view);
+ char *uri = window->priv->uri;
+ GEnumValue *enum_value;
+ GValue width = { 0, };
+ GValue height = { 0, };
+ GValue maximized = { 0, };
+ GValue x = { 0, };
+ GValue y = { 0, };
+ GValue sizing_mode = { 0, };
+ GValue zoom = { 0, };
+ GValue continuous = { 0, };
+ GValue dual_page = { 0, };
+ GValue presentation = { 0, };
+ GValue fullscreen = { 0, };
+ GValue rotation = { 0, };
+
+ /* Window size */
+ if (!GTK_WIDGET_VISIBLE (window)) {
+ gboolean restore_size = TRUE;
+
+ if (ev_metadata_manager_get (uri, "window_maximized", &maximized, TRUE)) {
+ if (g_value_get_boolean (&maximized)) {
+ gtk_window_maximize (GTK_WINDOW (window));
+ restore_size = FALSE;
+ }
+ }
- if (!sanity_check_uri (ev_window, uri)) {
- return;
+ if (restore_size &&
+ ev_metadata_manager_get (uri, "window_width", &width, TRUE) &&
+ ev_metadata_manager_get (uri, "window_height", &height, TRUE)) {
+ gtk_window_set_default_size (GTK_WINDOW (window),
+ g_value_get_int (&width),
+ g_value_get_int (&height));
+ }
+ if (restore_size &&
+ ev_metadata_manager_get (uri, "window_x", &x, TRUE) &&
+ ev_metadata_manager_get (uri, "window_y", &y, TRUE)) {
+ gtk_window_move (GTK_WINDOW (window), g_value_get_int (&x),
+ g_value_get_int (&y));
+ }
}
- g_free (ev_window->priv->uri);
- ev_window->priv->uri = g_strdup (uri);
+ /* Sizing mode */
+ if (ev_metadata_manager_get (uri, "sizing_mode", &sizing_mode, FALSE)) {
+ enum_value = g_enum_get_value_by_nick
+ (EV_SIZING_MODE_CLASS, g_value_get_string (&sizing_mode));
+ g_value_unset (&sizing_mode);
+ ev_view_set_sizing_mode (view, enum_value->value);
+ }
- document_type = ev_document_type_lookup (uri, &mime_type);
- if (document_type != G_TYPE_INVALID) {
- document = g_object_new (document_type, NULL);
+ /* Zoom */
+ if (ev_metadata_manager_get (uri, "zoom", &zoom, FALSE) &&
+ ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
+ ev_view_set_zoom (view, g_value_get_double (&zoom), FALSE);
}
- if (document) {
- start_loading_document (ev_window, document, uri);
- /* See the comment on start_loading_document on ref counting.
- * As the password dialog flow is confusing, we're very explicit
- * on ref counting. */
- g_object_unref (document);
- } else {
- char *error_message;
+ /* Continuous */
+ if (ev_metadata_manager_get (uri, "continuous", &continuous, FALSE)) {
+ ev_view_set_continuous (view, g_value_get_boolean (&continuous));
+ }
+
+ /* Dual page */
+ if (ev_metadata_manager_get (uri, "dual-page", &dual_page, FALSE)) {
+ ev_view_set_dual_page (view, g_value_get_boolean (&dual_page));
+ }
+
+ /* Presentation */
+ if (ev_metadata_manager_get (uri, "presentation", &presentation, FALSE)) {
+ if (g_value_get_boolean (&presentation)) {
+ ev_window_run_presentation (window);
+ }
+ }
- error_message = g_strdup_printf (_("Unhandled MIME type: '%s'"),
- mime_type?mime_type:"<Unknown MIME Type>");
- unable_to_load (ev_window, error_message);
- g_free (error_message);
+ /* Fullscreen */
+ if (ev_metadata_manager_get (uri, "fullscreen", &fullscreen, FALSE)) {
+ if (g_value_get_boolean (&fullscreen)) {
+ ev_window_run_fullscreen (window);
+ }
}
- g_free (mime_type);
+ /* Rotation */
+ if (ev_metadata_manager_get (uri, "rotation", &rotation, TRUE)) {
+ if (g_value_get_int (&rotation)) {
+ switch (g_value_get_int (&rotation)) {
+ case 90:
+ ev_view_set_rotation (view, 90);
+ break;
+ case 180:
+ ev_view_set_rotation (view, 180);
+ break;
+ case 270:
+ ev_view_set_rotation (view, 270);
+ break;
+ default:
+ break;
+ }
+ }
+ }
}
-static void
-ev_window_open_uri_list (EvWindow *ev_window, GList *uri_list)
+void
+ev_window_open_uri (EvWindow *ev_window, const char *uri)
{
- GList *list;
- gchar *uri;
+ if (ev_window->priv->password_dialog)
+ gtk_widget_destroy (ev_window->priv->password_dialog);
+
+ g_free (ev_window->priv->uri);
+ ev_window->priv->uri = g_strdup (uri);
+
+ setup_view_from_metadata (ev_window);
- g_return_if_fail (uri_list != NULL);
+ ev_window_clear_jobs (ev_window);
+ ev_window_clear_local_uri (ev_window);
- list = uri_list;
- while (list) {
- uri = gnome_vfs_uri_to_string (list->data, GNOME_VFS_URI_HIDE_NONE);
-
- if (ev_document_type_lookup (uri, NULL) != G_TYPE_INVALID) {
- if (ev_window_is_empty (EV_WINDOW (ev_window))) {
- ev_window_open (ev_window, uri);
-
- gtk_widget_show (GTK_WIDGET (ev_window));
- } else {
- EvWindow *new_window;
-
- new_window = ev_application_new_window (EV_APP);
- ev_window_open (new_window, uri);
-
- gtk_widget_show (GTK_WIDGET (new_window));
- }
- }
+ ev_window->priv->xfer_job = ev_job_xfer_new (uri);
+ g_signal_connect (ev_window->priv->xfer_job,
+ "finished",
+ G_CALLBACK (ev_window_xfer_job_cb),
+ ev_window);
+ ev_job_queue_add_job (ev_window->priv->xfer_job, EV_JOB_PRIORITY_HIGH);
+}
- g_free (uri);
+static void
+file_open_dialog_response_cb (GtkWidget *chooser,
+ gint response_id,
+ EvWindow *ev_window)
+{
+ if (response_id == GTK_RESPONSE_OK) {
+ GSList *uris;
+
+ uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (chooser));
- list = g_list_next (list);
+ ev_application_open_uri_list (EV_APP, uris, GDK_CURRENT_TIME);
+
+ g_slist_foreach (uris, (GFunc)g_free, NULL);
+ g_slist_free (uris);
}
+
+ gtk_widget_destroy (chooser);
}
static void
-ev_window_cmd_file_open (GtkAction *action, EvWindow *ev_window)
+ev_window_cmd_file_open (GtkAction *action, EvWindow *window)
{
- ev_application_open (EV_APP, NULL);
+ GtkWidget *chooser;
+
+ chooser = gtk_file_chooser_dialog_new (_("Open Document"),
+ GTK_WINDOW (window),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL);
+
+ ev_document_types_add_filters (chooser, NULL);
+ gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (chooser), TRUE);
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), FALSE);
+
+ g_signal_connect (chooser, "response",
+ G_CALLBACK (file_open_dialog_response_cb),
+ window);
+
+ gtk_widget_show (chooser);
}
static void
-ev_window_cmd_recent_file_activate (EggRecentViewGtk *view, EggRecentItem *item,
+ev_window_cmd_recent_file_activate (GtkAction *action,
EvWindow *ev_window)
{
char *uri;
- GtkWidget *window;
+ EggRecentItem *item;
+
+ item = egg_recent_view_uimanager_get_item (ev_window->priv->recent_view,
+ action);
uri = egg_recent_item_get_uri (item);
- window = GTK_WIDGET (ev_application_get_empty_window (EV_APP));
- gtk_widget_show (window);
- ev_window_open (EV_WINDOW (window), uri);
+ ev_application_open_uri (EV_APP, uri, NULL, GDK_CURRENT_TIME, NULL);
g_free (uri);
}
{
EggRecentItem *item;
- if (strstr (filename, "file:///") == NULL)
- return;
-
item = egg_recent_item_new_from_uri (filename);
egg_recent_item_add_group (item, "Evince");
- egg_recent_model_add_full (window->priv->recent_model, item);
+ egg_recent_model_add_full (ev_application_get_recent_model (EV_APP), item);
}
static void
ev_window_setup_recent (EvWindow *ev_window)
{
- GtkWidget *menu_item;
- GtkWidget *menu;
- menu_item = gtk_ui_manager_get_widget (ev_window->priv->ui_manager, "/MainMenu/FileMenu");
- menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_item));
- menu_item = gtk_ui_manager_get_widget (ev_window->priv->ui_manager, "/MainMenu/FileMenu/RecentFilesMenu");
+ ev_window->priv->recent_view = egg_recent_view_uimanager_new (ev_window->priv->ui_manager,
+ "/MainMenu/FileMenu/RecentFilesMenu",
+ G_CALLBACK (ev_window_cmd_recent_file_activate),
+ ev_window);
- g_return_if_fail (menu != NULL);
- g_return_if_fail (menu_item != NULL);
-
- /* it would be better if we just filtered by mime-type, but there
- * doesn't seem to be an easy way to figure out which mime-types we
- * can handle */
- ev_window->priv->recent_model = egg_recent_model_new (EGG_RECENT_MODEL_SORT_MRU);
-
- ev_window->priv->recent_view = egg_recent_view_gtk_new (menu, menu_item);
- egg_recent_view_gtk_show_icons (EGG_RECENT_VIEW_GTK (ev_window->priv->recent_view), FALSE);
- egg_recent_model_set_limit (ev_window->priv->recent_model, 5);
+ egg_recent_view_uimanager_show_icons (EGG_RECENT_VIEW_UIMANAGER (ev_window->priv->recent_view), FALSE);
egg_recent_view_set_model (EGG_RECENT_VIEW (ev_window->priv->recent_view),
- ev_window->priv->recent_model);
-
- egg_recent_model_set_filter_groups (ev_window->priv->recent_model,
- "Evince", NULL);
+ ev_application_get_recent_model (EV_APP));
- egg_recent_view_gtk_set_trailing_sep (ev_window->priv->recent_view, TRUE);
+ egg_recent_view_uimanager_set_trailing_sep (ev_window->priv->recent_view, TRUE);
g_signal_connect (ev_window->priv->recent_view, "activate",
G_CALLBACK (ev_window_cmd_recent_file_activate), ev_window);
gtk_widget_destroy (error_dialog);
}
+static void
+file_save_dialog_response_cb (GtkWidget *fc,
+ gint response_id,
+ EvWindow *ev_window)
+{
+ gboolean success;
+
+ if (response_id == GTK_RESPONSE_OK) {
+ const char *uri;
+
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
+
+ ev_document_doc_mutex_lock ();
+ success = ev_document_save (ev_window->priv->document, uri, NULL);
+ ev_document_doc_mutex_unlock ();
+
+ if (!success) {
+ save_error_dialog (GTK_WINDOW (fc), uri);
+ }
+ }
+
+ gtk_widget_destroy (fc);
+}
+
static void
ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window)
{
GtkWidget *fc;
- GtkFileFilter *pdf_filter, *all_filter;
- gchar *uri = NULL;
- gboolean success;
+ gchar *base_name;
+ gchar *file_name;
fc = gtk_file_chooser_dialog_new (
_("Save a Copy"),
- NULL, GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_WINDOW (ev_window), GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
NULL);
- gtk_window_set_modal (GTK_WINDOW (fc), TRUE);
-
- pdf_filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (pdf_filter, _("PDF Documents"));
- gtk_file_filter_add_mime_type (pdf_filter, "application/pdf");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fc), pdf_filter);
-
- all_filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (all_filter, _("All Files"));
- gtk_file_filter_add_pattern (all_filter, "*");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fc), all_filter);
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (fc), pdf_filter);
+ ev_document_types_add_filters (fc, ev_window->priv->document);
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
+
+ file_name = gnome_vfs_format_uri_for_display (ev_window->priv->uri);
+ base_name = g_path_get_basename (file_name);
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc), base_name);
+ g_free (file_name);
+ g_free (base_name);
+
+ g_signal_connect (fc, "response",
+ G_CALLBACK (file_save_dialog_response_cb),
+ ev_window);
gtk_widget_show (fc);
+}
- while (gtk_dialog_run (GTK_DIALOG (fc)) == GTK_RESPONSE_OK) {
- uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
+static gboolean
+using_pdf_printer (GnomePrintConfig *config)
+{
+ const guchar *driver;
-/* FIXME
- if (g_file_test (uri, G_FILE_TEST_EXISTS) &&
- !overwrite_existing_file (GTK_WINDOW (fc), uri))
- continue;
-*/
-
- ev_document_doc_mutex_lock ();
- success = ev_document_save (ev_window->priv->document, uri, NULL);
- ev_document_doc_mutex_unlock ();
+ driver = gnome_print_config_get (
+ config, (const guchar *)"Settings.Engine.Backend.Driver");
- if (success)
- break;
+ if (driver) {
+ if (!strcmp ((const gchar *)driver, "gnome-print-pdf"))
+ return TRUE;
else
- save_error_dialog (GTK_WINDOW (fc), uri);
+ return FALSE;
}
- gtk_widget_destroy (fc);
+
+ return FALSE;
}
static gboolean
return TRUE;
else
return FALSE;
- } else if (transport) {
+ } else if (transport) { /* these transports default to PostScript */
if (!strcmp ((const gchar *)transport, "CUPS"))
return TRUE;
else if (!strcmp ((const gchar *)transport, "LPD"))
return FALSE;
}
+static GnomePrintConfig *
+load_print_config_from_file (void)
+{
+ GnomePrintConfig *print_config = NULL;
+ char *file_name, *contents = NULL;
+
+ file_name = g_build_filename (ev_dot_dir (), PRINT_CONFIG_FILENAME,
+ NULL);
+
+ if (g_file_get_contents (file_name, &contents, NULL, NULL)) {
+ print_config = gnome_print_config_from_string (contents, 0);
+ g_free (contents);
+ }
+
+ if (print_config == NULL) {
+ print_config = gnome_print_config_default ();
+ }
+
+ g_free (file_name);
+
+ return print_config;
+}
+
+static void
+save_print_config_to_file (GnomePrintConfig *config)
+{
+ char *file_name, *str;
+
+ g_return_if_fail (config != NULL);
+
+ str = gnome_print_config_to_string (config, 0);
+ if (str == NULL) return;
+
+ file_name = g_build_filename (ev_dot_dir (),
+ PRINT_CONFIG_FILENAME,
+ NULL);
+
+#ifdef HAVE_G_FILE_SET_CONTENTS
+ g_file_set_contents (file_name, str, -1, NULL);
+#else
+ ev_file_set_contents (file_name, str, -1, NULL);
+#endif
+
+ g_free (file_name);
+ g_free (str);
+}
+
static void
ev_window_print (EvWindow *window)
{
EvPageCache *page_cache;
int last_page;
- page_cache = ev_document_get_page_cache (window->priv->document);
+ page_cache = ev_page_cache_get (window->priv->document);
last_page = ev_page_cache_get_n_pages (page_cache);
ev_window_print_range (window, 1, -1);
}
+const char *
+ev_window_get_uri (EvWindow *ev_window)
+{
+ return ev_window->priv->uri;
+}
+
void
ev_window_print_range (EvWindow *ev_window, int first_page, int last_page)
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
g_return_if_fail (ev_window->priv->document != NULL);
- page_cache = ev_document_get_page_cache (ev_window->priv->document);
+ page_cache = ev_page_cache_get (ev_window->priv->document);
if (last_page == -1) {
last_page = ev_page_cache_get_n_pages (page_cache);
}
- config = gnome_print_config_default ();
+ config = load_print_config_from_file ();
job = gnome_print_job_new (config);
print_dialog = gnome_print_dialog_new (job, (guchar *) _("Print"),
/* FIXME: Change this when we have the first backend
* that can print more than postscript
*/
- if (!using_postscript_printer (config)) {
+ if (using_pdf_printer (config)) {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (
+ GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ _("Generating PDF is not supported"));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ continue;
+ } else if (!using_postscript_printer (config)) {
GtkWidget *dialog;
dialog = gtk_message_dialog_new (
continue;
}
+ save_print_config_to_file (config);
+
print_job = g_object_new (EV_TYPE_PRINT_JOB,
"gnome_print_job", job,
"document", ev_window->priv->document,
break;
}
+ g_object_unref (job);
+
gtk_widget_destroy (print_dialog);
if (print_job != NULL) {
ev_print_job_print (print_job, GTK_WINDOW (ev_window));
g_object_unref (print_job);
}
+
+ g_object_unref (config);
}
static void
ev_window_print (ev_window);
}
+static void
+ev_window_cmd_file_properties (GtkAction *action, EvWindow *ev_window)
+{
+ if (ev_window->priv->properties == NULL) {
+ ev_window->priv->properties = ev_properties_dialog_new ();
+ ev_properties_dialog_set_document (EV_PROPERTIES_DIALOG (ev_window->priv->properties),
+ ev_window->priv->document);
+ g_object_add_weak_pointer (G_OBJECT (ev_window->priv->properties),
+ (gpointer *) &(ev_window->priv->properties));
+ gtk_window_set_transient_for (GTK_WINDOW (ev_window->priv->properties),
+ GTK_WINDOW (ev_window));
+ }
+
+ gtk_widget_show (ev_window->priv->properties);
+}
+
static void
ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window)
{
} else if (!EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
find_not_supported_dialog (ev_window);
} else {
- update_chrome_flag (ev_window, EV_CHROME_FINDBAR, NULL, TRUE);
+ update_chrome_flag (ev_window, EV_CHROME_FINDBAR, TRUE);
gtk_widget_grab_focus (ev_window->priv->find_bar);
}
{
GtkWidget *popup = window->priv->fullscreen_popup;
int popup_width, popup_height;
+ GdkScreen *screen;
GdkRectangle screen_rect;
gboolean toolbar;
g_return_if_fail (popup != NULL);
- toolbar = (window->priv->chrome & EV_CHROME_TOOLBAR) != 0;
+ if (GTK_WIDGET (window)->window == NULL)
+ return;
+
+ toolbar = (window->priv->chrome & EV_CHROME_TOOLBAR) != 0 ||
+ (window->priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0;
popup_width = popup->requisition.width;
popup_height = popup->requisition.height;
- /* FIXME multihead */
- gdk_screen_get_monitor_geometry (gdk_screen_get_default (),
+ screen = gtk_widget_get_screen (GTK_WIDGET (window));
+ gdk_screen_get_monitor_geometry (screen,
gdk_screen_get_monitor_at_window
- (gdk_screen_get_default (),
+ (screen,
GTK_WIDGET (window)->window),
&screen_rect);
if (toolbar) {
ev_window_sidebar_position_change_cb (GObject *object, GParamSpec *pspec,
EvWindow *ev_window)
{
- GConfClient *client;
- int sidebar_size;
-
- sidebar_size = gtk_paned_get_position (GTK_PANED (object));
-
- client = gconf_client_get_default ();
- gconf_client_set_int (client, GCONF_SIDEBAR_SIZE, sidebar_size, NULL);
- g_object_unref (client);
+ if (ev_window->priv->uri) {
+ ev_metadata_manager_set_int (ev_window->priv->uri, "sidebar_size",
+ gtk_paned_get_position (GTK_PANED (object)));
+ }
}
static void
g_object_set (window->priv->fullscreen_popup, "visible", FALSE, NULL);
ev_view_hide_cursor (EV_VIEW (window->priv->view));
+ g_source_unref (window->priv->fullscreen_timeout_source);
window->priv->fullscreen_timeout_source = NULL;
return FALSE;
{
GSource *source;
- if (window->priv->fullscreen_timeout_source != NULL)
+ if (window->priv->fullscreen_timeout_source != NULL) {
+ g_source_unref (window->priv->fullscreen_timeout_source);
g_source_destroy (window->priv->fullscreen_timeout_source);
+ }
- source = g_timeout_source_new (1000);
+ source = g_timeout_source_new (FULLSCREEN_TIMEOUT);
g_source_set_callback (source, fullscreen_timeout_cb, window, NULL);
g_source_attach (source, NULL);
window->priv->fullscreen_timeout_source = source;
static void
fullscreen_clear_timeout (EvWindow *window)
{
- if (window->priv->fullscreen_timeout_source != NULL)
+ if (window->priv->fullscreen_timeout_source != NULL) {
+ g_source_unref (window->priv->fullscreen_timeout_source);
g_source_destroy (window->priv->fullscreen_timeout_source);
+ }
window->priv->fullscreen_timeout_source = NULL;
ev_view_show_cursor (EV_VIEW (window->priv->view));
}
+
+static void
+show_fullscreen_popup (EvWindow *window)
+{
+ if (!GTK_WIDGET_VISIBLE (window->priv->fullscreen_popup)) {
+ g_object_set (window->priv->fullscreen_popup, "visible", TRUE, NULL);
+ ev_view_show_cursor (EV_VIEW (window->priv->view));
+ }
+
+ fullscreen_set_timeout (window);
+}
+
static gboolean
fullscreen_motion_notify_cb (GtkWidget *widget,
GdkEventMotion *event,
{
EvWindow *window = EV_WINDOW (user_data);
- if (!GTK_WIDGET_VISIBLE (window->priv->fullscreen_popup)) {
- g_object_set (window->priv->fullscreen_popup, "visible", TRUE, NULL);
- ev_view_show_cursor (EV_VIEW (window->priv->view));
- }
-
- fullscreen_set_timeout (window);
+ show_fullscreen_popup (window);
return FALSE;
}
GtkWidget *popup;
GtkWidget *hbox;
GtkWidget *button;
+ GdkScreen *screen;
+
+ window->priv->fullscreen_toolbar = egg_editable_toolbar_new_with_model
+ (window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP));
popup = gtk_window_new (GTK_WINDOW_POPUP);
hbox = gtk_hbox_new (FALSE, 0);
gtk_window_set_resizable (GTK_WINDOW (popup), FALSE);
- /* FIXME multihead */
- g_signal_connect_object (gdk_screen_get_default (), "size-changed",
+ screen = gtk_widget_get_screen (GTK_WIDGET (window));
+ g_signal_connect_object (screen, "size-changed",
G_CALLBACK (screen_size_changed_cb),
window, 0);
g_signal_connect_object (popup, "size_request",
G_CALLBACK (fullscreen_popup_size_request_cb),
window, 0);
+ gtk_window_set_screen (GTK_WINDOW (popup),
+ gtk_widget_get_screen (GTK_WIDGET (window)));
+
return popup;
}
}
static void
-ev_window_fullscreen (EvWindow *window)
+ev_window_run_fullscreen (EvWindow *window)
{
ev_view_set_fullscreen (EV_VIEW (window->priv->view), TRUE);
if (window->priv->fullscreen_popup == NULL)
window->priv->fullscreen_popup
= ev_window_create_fullscreen_popup (window);
+
update_chrome_visibility (window);
+ gtk_widget_hide (window->priv->sidebar);
g_object_set (G_OBJECT (window->priv->scrolled_window),
"shadow-type", GTK_SHADOW_NONE,
NULL);
-
+
g_signal_connect (window->priv->view,
"motion-notify-event",
G_CALLBACK (fullscreen_motion_notify_cb),
ev_window_update_fullscreen_action (window);
gtk_window_fullscreen (GTK_WINDOW (window));
ev_window_update_fullscreen_popup (window);
+
+ if (window->priv->uri) {
+ ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", TRUE);
+ }
}
static void
-ev_window_unfullscreen (EvWindow *window)
+ev_window_stop_fullscreen (EvWindow *window)
{
EvView *view = EV_VIEW (window->priv->view);
+ if (!ev_view_get_fullscreen (EV_VIEW (view)))
+ return;
+
ev_view_set_fullscreen (view, FALSE);
g_object_set (G_OBJECT (window->priv->scrolled_window),
"shadow-type", GTK_SHADOW_IN,
ev_window_update_fullscreen_action (window);
gtk_window_unfullscreen (GTK_WINDOW (window));
update_chrome_visibility (window);
+ update_sidebar_visibility (window);
+
+ if (window->priv->uri) {
+ ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", FALSE);
+ }
}
static void
fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (fullscreen) {
- ev_window_fullscreen (window);
+ ev_window_run_fullscreen (window);
} else {
- ev_window_unfullscreen (window);
+ ev_window_stop_fullscreen (window);
}
}
gtk_window_fullscreen (GTK_WINDOW (window));
ev_window_update_presentation_action (window);
update_chrome_visibility (window);
+ gtk_widget_hide (window->priv->sidebar);
+
+ if (window->priv->uri) {
+ ev_metadata_manager_set_boolean (window->priv->uri, "presentation", TRUE);
+ }
}
static void
ev_window_stop_presentation (EvWindow *window)
{
- if (! ev_view_get_presentation (EV_VIEW (window->priv->view)))
+ if (!ev_view_get_presentation (EV_VIEW (window->priv->view)))
return;
g_object_set (G_OBJECT (window->priv->scrolled_window),
gtk_window_unfullscreen (GTK_WINDOW (window));
ev_window_update_presentation_action (window);
update_chrome_visibility (window);
+ update_sidebar_visibility (window);
+
+ if (window->priv->uri) {
+ ev_metadata_manager_set_boolean (window->priv->uri, "presentation", FALSE);
+ }
}
static void
gboolean presentation;
g_return_if_fail (EV_IS_WINDOW (window));
+ ev_window_stop_fullscreen (window);
presentation = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (presentation) {
}
}
-static gboolean
-ev_window_state_event (GtkWidget *widget, GdkEventWindowState *event)
-{
- EvWindow *window = EV_WINDOW (widget);
-
- if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) {
- gboolean show;
-
- show = (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) == 0;
-
- gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (window->priv->statusbar),
- show);
- }
-
- return FALSE;
-}
-
static gboolean
ev_window_focus_in_event (GtkWidget *widget, GdkEventFocus *event)
{
NULL);
if (fullscreen)
- gtk_widget_show (priv->fullscreen_popup);
+ show_fullscreen_popup (window);
return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_in_event (widget, event);
}
return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_out_event (widget, event);
}
+static void
+ev_window_screen_changed (GtkWidget *widget,
+ GdkScreen *old_screen)
+{
+ EvWindow *window = EV_WINDOW (widget);
+ EvWindowPrivate *priv = window->priv;
+ GdkScreen *screen;
+
+ if (GTK_WIDGET_CLASS (ev_window_parent_class)->screen_changed) {
+ GTK_WIDGET_CLASS (ev_window_parent_class)->screen_changed (widget, old_screen);
+ }
+
+ if (priv->fullscreen_popup != NULL) {
+ g_signal_handlers_disconnect_by_func
+ (old_screen, G_CALLBACK (screen_size_changed_cb), window);
+
+ screen = gtk_widget_get_screen (widget);
+ g_signal_connect_object (screen, "size-changed",
+ G_CALLBACK (screen_size_changed_cb),
+ window, 0);
+ gtk_window_set_screen (GTK_WINDOW (priv->fullscreen_popup), screen);
+
+ ev_window_update_fullscreen_popup (window);
+ }
+}
+
static void
ev_window_set_page_mode (EvWindow *window,
EvWindowPageMode page_mode)
EvWindow *ev_window = EV_WINDOW (data);
egg_editable_toolbar_set_edit_mode
(EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), FALSE);
- egg_toolbars_model_save (ev_window->priv->toolbar_model,
- ev_window->priv->toolbar_file, "1.0");
+ ev_application_save_toolbars_model (EV_APP);
gtk_widget_destroy (GTK_WIDGET (dialog));
}
+static void
+ev_window_cmd_edit_rotate_left (GtkAction *action, EvWindow *ev_window)
+{
+ ev_view_rotate_left (EV_VIEW (ev_window->priv->view));
+}
+
+static void
+ev_window_cmd_edit_rotate_right (GtkAction *action, EvWindow *ev_window)
+{
+ ev_view_rotate_right (EV_VIEW (ev_window->priv->view));
+}
+
static void
ev_window_cmd_edit_toolbar (GtkAction *action, EvWindow *ev_window)
{
GtkWidget *dialog;
GtkWidget *editor;
- g_return_if_fail (EV_IS_WINDOW (ev_window));
-
- dialog = gtk_dialog_new_with_buttons (_("Toolbar editor"), GTK_WINDOW (ev_window),
+
+ dialog = gtk_dialog_new_with_buttons (_("Toolbar Editor"),
+ GTK_WINDOW (ev_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE,
- GTK_RESPONSE_CANCEL,
+ GTK_RESPONSE_CLOSE,
NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
+ gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 400);
editor = egg_toolbar_editor_new (ev_window->priv->ui_manager,
- ev_window->priv->toolbar_model);
+ ev_application_get_toolbars_model (EV_APP));
gtk_container_set_border_width (GTK_CONTAINER (editor), 5);
gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
-
+
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), editor);
egg_toolbar_editor_load_actions (EGG_TOOLBAR_EDITOR (editor),
- DATADIR"/evince-toolbar.xml");
+ DATADIR "/evince-toolbar.xml");
egg_editable_toolbar_set_edit_mode
(EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), TRUE);
- gtk_widget_show_all (dialog);
-
- g_signal_connect (G_OBJECT (dialog), "response",
+ g_signal_connect (dialog, "response",
G_CALLBACK (ev_window_cmd_edit_toolbar_cb),
ev_window);
+ gtk_widget_show_all (dialog);
}
static void
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_page_cache_prev_page (ev_window->priv->page_cache);
+ ev_view_previous_page (EV_VIEW (ev_window->priv->view));
}
static void
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_page_cache_next_page (ev_window->priv->page_cache);
+ ev_view_next_page (EV_VIEW (ev_window->priv->view));
}
static void
ev_page_cache_set_current_page (ev_window->priv->page_cache, n_pages - 1);
}
+static void
+ev_window_cmd_go_forward (GtkAction *action, EvWindow *ev_window)
+{
+ int n_pages, current_page;
+
+ g_return_if_fail (EV_IS_WINDOW (ev_window));
+
+ n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
+ current_page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
+
+ if (current_page + 10 < n_pages)
+ ev_page_cache_set_current_page (ev_window->priv->page_cache, current_page + 10);
+}
+
+static void
+ev_window_cmd_go_backward (GtkAction *action, EvWindow *ev_window)
+{
+ int current_page;
+
+ g_return_if_fail (EV_IS_WINDOW (ev_window));
+
+ current_page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
+
+ if (current_page - 10 >= 0)
+ ev_page_cache_set_current_page (ev_window->priv->page_cache, current_page - 10);
+}
+
static void
ev_window_cmd_view_reload (GtkAction *action, EvWindow *ev_window)
{
page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
uri = g_strdup (ev_window->priv->uri);
- ev_window_open (ev_window, uri);
+ ev_window_open_uri (ev_window, uri);
/* In case the number of pages in the document has changed. */
page = CLAMP (page, 0, ev_page_cache_get_n_pages (ev_window->priv->page_cache));
widget = gtk_window_get_focus (GTK_WINDOW (window));
if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
- update_chrome_flag (window, EV_CHROME_FINDBAR, NULL, FALSE);
+ update_chrome_flag (window, EV_CHROME_FINDBAR, FALSE);
+ gtk_widget_grab_focus (window->priv->view);
} else {
gboolean fullscreen;
gboolean presentation;
NULL);
if (fullscreen)
- ev_window_unfullscreen (window);
+ ev_window_stop_fullscreen (window);
if (presentation)
ev_window_stop_presentation (window);
hsb_requisition.height + scrollbar_spacing);
}
+static void
+save_sizing_mode (EvWindow *window)
+{
+ EvSizingMode mode;
+ GEnumValue *enum_value;
+
+ if (window->priv->uri) {
+ mode = ev_view_get_sizing_mode (EV_VIEW (window->priv->view));
+ enum_value = g_enum_get_value (EV_SIZING_MODE_CLASS, mode);
+
+ ev_metadata_manager_set_string (window->priv->uri, "sizing_mode",
+ enum_value->value_nick);
+ }
+}
+
static void
ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec,
EvWindow *ev_window)
}
update_sizing_buttons (ev_window);
+ save_sizing_mode (ev_window);
+}
+
+static void
+ev_window_zoom_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_window)
+{
+ update_action_sensitivity (ev_window);
+
+ if (ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
+ ev_metadata_manager_set_double (ev_window->priv->uri, "zoom",
+ ev_view_get_zoom (view));
+ }
+}
+
+static void
+ev_window_update_continuous_action (EvWindow *window)
+{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (window->priv->action_group, "ViewContinuous");
+ g_signal_handlers_block_by_func
+ (action, G_CALLBACK (ev_window_cmd_continuous), window);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+ ev_view_get_continuous (EV_VIEW (window->priv->view)));
+ g_signal_handlers_unblock_by_func
+ (action, G_CALLBACK (ev_window_cmd_continuous), window);
+}
+
+static void
+ev_window_update_dual_page_action (EvWindow *window)
+{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (window->priv->action_group, "ViewDual");
+ g_signal_handlers_block_by_func
+ (action, G_CALLBACK (ev_window_cmd_dual), window);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+ ev_view_get_dual_page (EV_VIEW (window->priv->view)));
+ g_signal_handlers_unblock_by_func
+ (action, G_CALLBACK (ev_window_cmd_dual), window);
+}
+
+static void
+ev_window_continuous_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_window)
+{
+ ev_window_update_continuous_action (ev_window);
+
+ if (ev_window->priv->uri) {
+ ev_metadata_manager_set_boolean (ev_window->priv->uri, "continuous",
+ ev_view_get_continuous (EV_VIEW (ev_window->priv->view)));
+ }
+}
+
+static void
+ev_window_rotation_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *window)
+{
+ int rotation;
+
+ rotation = ev_view_get_rotation (EV_VIEW (window->priv->view));
+
+ if (window->priv->uri) {
+ ev_metadata_manager_set_int (window->priv->uri, "rotation",
+ rotation);
+ }
+
+ ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (window->priv->sidebar_thumbs),
+ rotation);
+}
+
+static void
+ev_window_has_selection_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *window)
+{
+ update_action_sensitivity (window);
}
static void
-ev_window_zoom_changed_cb (EvView *view, GParamSpec *pspec,
- EvWindow *ev_window)
+ev_window_dual_mode_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_window)
{
- update_action_sensitivity (ev_window);
+ ev_window_update_dual_page_action (ev_window);
+
+ if (ev_window->priv->uri) {
+ ev_metadata_manager_set_boolean (ev_window->priv->uri, "dual-page",
+ ev_view_get_dual_page (EV_VIEW (ev_window->priv->view)));
+ }
}
static char *
"name", _("Evince"),
"version", VERSION,
"copyright",
- _("\xc2\xa9 1996-2004 The Evince authors"),
+ _("\xc2\xa9 1996-2005 The Evince authors"),
"license", license_trans,
"website", "http://www.gnome.org/projects/evince",
"comments", comments,
static void
ev_window_view_toolbar_cb (GtkAction *action, EvWindow *ev_window)
{
- update_chrome_flag (ev_window, EV_CHROME_TOOLBAR,
- GCONF_CHROME_TOOLBAR,
- gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ gboolean active;
+
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ update_chrome_flag (ev_window, EV_CHROME_TOOLBAR, active);
+ ev_metadata_manager_set_boolean (NULL, "show_toolbar", active);
}
static void
-ev_window_view_statusbar_cb (GtkAction *action, EvWindow *ev_window)
+ev_window_view_sidebar_cb (GtkAction *action, EvWindow *ev_window)
{
- update_chrome_flag (ev_window, EV_CHROME_STATUSBAR,
- GCONF_CHROME_STATUSBAR,
- gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ set_widget_visibility (ev_window->priv->sidebar,
+ gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
}
static void
-ev_window_view_sidebar_cb (GtkAction *action, EvWindow *ev_window)
+ev_window_sidebar_current_page_changed_cb (EvSidebar *ev_sidebar,
+ GParamSpec *pspec,
+ EvWindow *ev_window)
{
- update_chrome_flag (ev_window, EV_CHROME_SIDEBAR,
- GCONF_CHROME_SIDEBAR,
- gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ GtkWidget *current_page;
+ const char *id;
+
+ g_object_get (G_OBJECT (ev_sidebar), "current_page", ¤t_page, NULL);
+
+ if (current_page == ev_window->priv->sidebar_links) {
+ id = LINKS_SIDEBAR_ID;
+ } else if (current_page == ev_window->priv->sidebar_thumbs) {
+ id = THUMBNAILS_SIDEBAR_ID;
+ } else {
+ g_assert_not_reached();
+ }
+
+ g_object_unref (current_page);
+
+ if (ev_window->priv->uri) {
+ ev_metadata_manager_set_string (ev_window->priv->uri, "sidebar_page", id);
+ }
}
static void
ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, GParamSpec *pspec,
EvWindow *ev_window)
{
+ EvView *view = EV_VIEW (ev_window->priv->view);
GtkAction *action;
- gboolean visible, fullscreen;
-
- g_object_get (ev_window->priv->view,
- "fullscreen", &fullscreen,
- NULL);
- visible = GTK_WIDGET_VISIBLE (ev_sidebar);
- /* In fullscreen mode the sidebar is not visible,
- * but we don't want to update the chrome
- */
- if (fullscreen)
- return;
-
action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
g_signal_handlers_block_by_func
(action, G_CALLBACK (ev_window_view_sidebar_cb), ev_window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+ GTK_WIDGET_VISIBLE (ev_sidebar));
g_signal_handlers_unblock_by_func
(action, G_CALLBACK (ev_window_view_sidebar_cb), ev_window);
- update_chrome_flag (ev_window, EV_CHROME_SIDEBAR,
- GCONF_CHROME_SIDEBAR, visible);
-}
-
-static void
-menu_item_select_cb (GtkMenuItem *proxy, EvWindow *ev_window)
-{
- GtkAction *action;
- char *message;
-
- action = g_object_get_data (G_OBJECT (proxy), "gtk-action");
- g_return_if_fail (action != NULL);
-
- g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
- if (message) {
- gtk_statusbar_push (GTK_STATUSBAR (ev_window->priv->statusbar),
- ev_window->priv->help_message_cid, message);
- g_free (message);
- }
-}
-
-static void
-menu_item_deselect_cb (GtkMenuItem *proxy, EvWindow *ev_window)
-{
- gtk_statusbar_pop (GTK_STATUSBAR (ev_window->priv->statusbar),
- ev_window->priv->help_message_cid);
-}
-
-static void
-connect_proxy_cb (GtkUIManager *ui_manager, GtkAction *action,
- GtkWidget *proxy, EvWindow *ev_window)
-{
- if (GTK_IS_MENU_ITEM (proxy)) {
- g_signal_connect (proxy, "select",
- G_CALLBACK (menu_item_select_cb), ev_window);
- g_signal_connect (proxy, "deselect",
- G_CALLBACK (menu_item_deselect_cb),
- ev_window);
- }
-}
-
-static void
-disconnect_proxy_cb (GtkUIManager *ui_manager, GtkAction *action,
- GtkWidget *proxy, EvWindow *ev_window)
-{
- if (GTK_IS_MENU_ITEM (proxy)) {
- g_signal_handlers_disconnect_by_func
- (proxy, G_CALLBACK (menu_item_select_cb), ev_window);
- g_signal_handlers_disconnect_by_func
- (proxy, G_CALLBACK (menu_item_deselect_cb), ev_window);
- }
-}
-
-static void
-view_status_changed_cb (EvView *view,
- GParamSpec *pspec,
- EvWindow *ev_window)
-{
- const char *message;
-
- gtk_statusbar_pop (GTK_STATUSBAR (ev_window->priv->statusbar),
- ev_window->priv->view_message_cid);
-
- message = ev_view_get_status (view);
- if (message) {
- gtk_statusbar_push (GTK_STATUSBAR (ev_window->priv->statusbar),
- ev_window->priv->view_message_cid, message);
+ if (!ev_view_get_presentation (view) &&
+ !ev_view_get_fullscreen (view)) {
+ ev_metadata_manager_set_boolean (ev_window->priv->uri, "sidebar_visibility",
+ GTK_WIDGET_VISIBLE (ev_sidebar));
}
}
find_bar_close_cb (EggFindBar *find_bar,
EvWindow *ev_window)
{
- update_chrome_flag (ev_window, EV_CHROME_FINDBAR, NULL, FALSE);
+ update_chrome_flag (ev_window, EV_CHROME_FINDBAR, FALSE);
}
static void
ev_document_find_cancel (EV_DOCUMENT_FIND (ev_window->priv->document));
ev_document_doc_mutex_unlock ();
+ update_action_sensitivity (ev_window);
egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
NULL);
gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
mode = EV_SIZING_FIT_WIDTH;
} else {
mode = EV_SIZING_FREE;
- ev_view_set_zoom (EV_VIEW (ev_window->priv->view), zoom, FALSE);
}
ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), mode);
+
+ if (mode == EV_SIZING_FREE) {
+ ev_view_set_zoom (EV_VIEW (ev_window->priv->view), zoom, FALSE);
+ }
+}
+
+static void
+ev_window_finalize (GObject *object)
+{
+ GList *windows = ev_application_get_windows (EV_APP);
+
+ if (windows == NULL) {
+ ev_application_shutdown (EV_APP);
+ } else {
+ g_list_free (windows);
+ }
+
+ G_OBJECT_CLASS (ev_window_parent_class)->finalize (object);
}
static void
EvWindow *window = EV_WINDOW (object);
EvWindowPrivate *priv = window->priv;
- if (priv->toolbar_model) {
- g_object_unref (priv->toolbar_model);
- g_free (priv->toolbar_file);
- priv->toolbar_model = NULL;
- priv->toolbar_file = NULL;
+ if (priv->title) {
+ ev_window_title_free (priv->title);
+ priv->title = NULL;
+ }
+
+ if (priv->recent_view) {
+ g_object_unref (priv->recent_view);
+ priv->recent_view = NULL;
}
if (priv->ui_manager) {
priv->page_view = NULL;
}
+ if (priv->load_job || priv->xfer_job) {
+ ev_window_clear_jobs (window);
+ }
+
+ if (priv->local_uri) {
+ ev_window_clear_local_uri (window);
+ }
+
if (priv->password_document) {
g_object_unref (priv->password_document);
priv->password_document = NULL;
priv->password_uri = NULL;
}
+ if (priv->password_dialog) {
+ gtk_widget_destroy (priv->password_dialog);
+ }
+
if (priv->find_bar) {
g_signal_handlers_disconnect_by_func
(window->priv->find_bar,
priv->find_bar = NULL;
}
+ if (priv->uri) {
+ g_free (priv->uri);
+ priv->uri = NULL;
+ }
+
+ if (window->priv->fullscreen_timeout_source) {
+ g_source_unref (window->priv->fullscreen_timeout_source);
+ g_source_destroy (window->priv->fullscreen_timeout_source);
+ window->priv->fullscreen_timeout_source = NULL;
+ }
destroy_fullscreen_popup (window);
G_OBJECT_CLASS (ev_window_parent_class)->dispose (object);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (ev_window_class);
g_object_class->dispose = ev_window_dispose;
+ g_object_class->finalize = ev_window_finalize;
- widget_class->window_state_event = ev_window_state_event;
widget_class->focus_in_event = ev_window_focus_in_event;
widget_class->focus_out_event = ev_window_focus_out_event;
+ widget_class->screen_changed = ev_window_screen_changed;
g_type_class_add_private (g_object_class, sizeof (EvWindowPrivate));
}
{ "Help", NULL, N_("_Help") },
/* File menu */
- { "FileOpen", GTK_STOCK_OPEN, NULL, "<control>O",
+ { "FileOpen", GTK_STOCK_OPEN, N_("_Open..."), "<control>O",
N_("Open an existing document"),
G_CALLBACK (ev_window_cmd_file_open) },
- { "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), NULL,
- N_("Save the current document with a new filename"),
+ { "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), NULL, NULL,
G_CALLBACK (ev_window_cmd_save_as) },
- { "FilePrint", GTK_STOCK_PRINT, N_("Print..."), "<control>P",
+ { "FilePrint", GTK_STOCK_PRINT, N_("_Print..."), "<control>P",
N_("Print this document"),
G_CALLBACK (ev_window_cmd_file_print) },
- { "FileCloseWindow", GTK_STOCK_CLOSE, NULL, "<control>W",
- N_("Close this window"),
+ { "FileProperties", GTK_STOCK_PROPERTIES, N_("P_roperties"), "<alt>Return", NULL,
+ G_CALLBACK (ev_window_cmd_file_properties) },
+ { "FileCloseWindow", GTK_STOCK_CLOSE, NULL, "<control>W", NULL,
G_CALLBACK (ev_window_cmd_file_close_window) },
/* Edit menu */
- { "EditCopy", GTK_STOCK_COPY, NULL, "<control>C",
- N_("Copy text from the document"),
+ { "EditCopy", GTK_STOCK_COPY, NULL, "<control>C", NULL,
G_CALLBACK (ev_window_cmd_edit_copy) },
- { "EditSelectAll", NULL, N_("Select _All"), "<control>A",
- N_("Select the entire page"),
+ { "EditSelectAll", NULL, N_("Select _All"), "<control>A", NULL,
G_CALLBACK (ev_window_cmd_edit_select_all) },
{ "EditFind", GTK_STOCK_FIND, NULL, "<control>F",
N_("Find a word or phrase in the document"),
G_CALLBACK (ev_window_cmd_edit_find) },
- { "EditFindNext", NULL, N_("Find Ne_xt"), "<control>G",
- N_("Find next occurrence of the word or phrase"),
+ { "EditFindNext", NULL, N_("Find Ne_xt"), "<control>G", NULL,
G_CALLBACK (ev_window_cmd_edit_find_next) },
- { "EditToolbar", NULL, N_("T_oolbar"), NULL,
- N_("Customize the toolbar"),
+ { "EditToolbar", NULL, N_("T_oolbar"), NULL, NULL,
G_CALLBACK (ev_window_cmd_edit_toolbar) },
+ { "EditRotateLeft", NULL, N_("Rotate _Left"), NULL, NULL,
+ G_CALLBACK (ev_window_cmd_edit_rotate_left) },
+ { "EditRotateRight", NULL, N_("Rotate _Right"), NULL, NULL,
+ G_CALLBACK (ev_window_cmd_edit_rotate_right) },
/* View menu */
{ "ViewZoomIn", GTK_STOCK_ZOOM_IN, NULL, "<control>plus",
G_CALLBACK (ev_window_cmd_go_last_page) },
/* Help menu */
- { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1",
- N_("Display help for the viewer application"),
+ { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", NULL,
G_CALLBACK (ev_window_cmd_help_contents) },
- { "HelpAbout", GTK_STOCK_ABOUT, N_("_About"), NULL,
- N_("Display credits for the document viewer creators"),
+ { "HelpAbout", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL,
G_CALLBACK (ev_window_cmd_help_about) },
/* Toolbar-only */
/* Accellerators */
{ "Escape", NULL, "", "Escape", "",
G_CALLBACK (ev_window_cmd_escape) },
- { "Slash", GTK_STOCK_FIND, NULL, "slash",
- N_("Find a word or phrase in the document"),
+ { "Slash", GTK_STOCK_FIND, NULL, "slash", NULL,
G_CALLBACK (ev_window_cmd_edit_find) },
- { "PageDown", NULL, "", "Page_Down",
- N_("Scroll one page forward"),
+ { "PageDown", NULL, "", "Page_Down", NULL,
G_CALLBACK (ev_window_cmd_scroll_forward) },
- { "PageUp", NULL, "", "Page_Up",
- N_("Scroll one page backward"),
+ { "PageUp", NULL, "", "Page_Up", NULL,
G_CALLBACK (ev_window_cmd_scroll_backward) },
- { "Space", NULL, "", "space",
- N_("Scroll one page forward"),
+ { "Space", NULL, "", "space", NULL,
G_CALLBACK (ev_window_cmd_scroll_forward) },
- { "ShiftSpace", NULL, "", "<shift>space",
- N_("Scroll one page backward"),
+ { "ShiftSpace", NULL, "", "<shift>space", NULL,
G_CALLBACK (ev_window_cmd_scroll_backward) },
- { "BackSpace", NULL, "", "BackSpace",
- N_("Scroll one page backward"),
+ { "BackSpace", NULL, "", "BackSpace", NULL,
G_CALLBACK (ev_window_cmd_scroll_backward) },
- { "ShiftBackSpace", NULL, "", "<shift>BackSpace",
- N_("Scroll one page forward"),
+ { "ShiftBackSpace", NULL, "", "<shift>BackSpace", NULL,
G_CALLBACK (ev_window_cmd_scroll_forward) },
- { "Plus", GTK_STOCK_ZOOM_IN, NULL, "plus",
- N_("Enlarge the document"),
+ { "Plus", GTK_STOCK_ZOOM_IN, NULL, "plus", NULL,
G_CALLBACK (ev_window_cmd_view_zoom_in) },
- { "Minus", GTK_STOCK_ZOOM_OUT, NULL, "minus",
- N_("Shrink the document"),
+ { "CtrlEqual", GTK_STOCK_ZOOM_IN, NULL, "<control>equal", NULL,
+ G_CALLBACK (ev_window_cmd_view_zoom_in) },
+ { "Equal", GTK_STOCK_ZOOM_IN, NULL, "equal", NULL,
+ G_CALLBACK (ev_window_cmd_view_zoom_in) },
+ { "Minus", GTK_STOCK_ZOOM_OUT, NULL, "minus", NULL,
+ G_CALLBACK (ev_window_cmd_view_zoom_out) },
+ { "FocusPageSelector", NULL, "", "<control>l", NULL,
+ G_CALLBACK (ev_window_cmd_focus_page_selector) },
+ { "GoBackwardFast", NULL, "", "<shift>Page_Up", NULL,
+ G_CALLBACK (ev_window_cmd_go_backward) },
+ { "GoForwardFast", NULL, "", "<shift>Page_Down", NULL,
+ G_CALLBACK (ev_window_cmd_go_forward) },
+ { "KpPlus", GTK_STOCK_ZOOM_IN, NULL, "KP_Add", NULL,
+ G_CALLBACK (ev_window_cmd_view_zoom_in) },
+ { "KpMinus", GTK_STOCK_ZOOM_OUT, NULL, "KP_Subtract", NULL,
+ G_CALLBACK (ev_window_cmd_view_zoom_out) },
+ { "CtrlKpPlus", GTK_STOCK_ZOOM_IN, NULL, "<control>KP_Add", NULL,
+ G_CALLBACK (ev_window_cmd_view_zoom_in) },
+ { "CtrlKpMinus", GTK_STOCK_ZOOM_OUT, NULL, "<control>KP_Subtract", NULL,
G_CALLBACK (ev_window_cmd_view_zoom_out) },
- { "FocusPageSelector", NULL, "", "<control>l",
- N_("Focus the page selector"),
- G_CALLBACK (ev_window_cmd_focus_page_selector) }
};
/* Toggle items */
{ "ViewToolbar", NULL, N_("_Toolbar"), "<shift><control>T",
N_("Show or hide the toolbar"),
G_CALLBACK (ev_window_view_toolbar_cb), TRUE },
- { "ViewStatusbar", NULL, N_("_Statusbar"), NULL,
- N_("Show or hide the statusbar"),
- G_CALLBACK (ev_window_view_statusbar_cb), TRUE },
- { "ViewSidebar", NULL, N_("Side _pane"), "F9",
+ { "ViewSidebar", NULL, N_("Side _Pane"), "F9",
N_("Show or hide the side pane"),
G_CALLBACK (ev_window_view_sidebar_cb), TRUE },
- { "ViewContinuous", NULL, N_("_Continuous"), NULL,
+ { "ViewContinuous", EV_STOCK_VIEW_CONTINUOUS, N_("_Continuous"), NULL,
N_("Show the entire document"),
G_CALLBACK (ev_window_cmd_continuous), TRUE },
- { "ViewDual", NULL, N_("_Dual"), NULL,
+ { "ViewDual", EV_STOCK_VIEW_DUAL, N_("_Dual"), NULL,
N_("Show two pages at once"),
G_CALLBACK (ev_window_cmd_dual), FALSE },
{ "ViewFullscreen", NULL, N_("_Fullscreen"), "F11",
N_("Expand the window to fill the screen"),
G_CALLBACK (ev_window_cmd_view_fullscreen) },
- { "ViewPresentation", NULL, N_("_Presentation"), "F12",
+ { "ViewPresentation", NULL, N_("_Presentation"), "F5",
N_("Run document as a presentation"),
G_CALLBACK (ev_window_cmd_view_presentation) },
{ "ViewBestFit", EV_STOCK_ZOOM_PAGE, N_("_Best Fit"), NULL,
gint x, gint y, GtkSelectionData *selection_data,
guint info, guint time, gpointer gdata)
{
- GList *uri_list = NULL;
+ GList *uri_list = NULL;
+ GSList *uris = NULL;
+ gchar *uri;
uri_list = gnome_vfs_uri_list_parse ((gchar *) selection_data->data);
if (uri_list) {
- ev_window_open_uri_list (EV_WINDOW (widget), uri_list);
-
+ while (uri_list) {
+ uri = gnome_vfs_uri_to_string (uri_list->data, GNOME_VFS_URI_HIDE_NONE);
+ uris = g_slist_append (uris, (gpointer) uri);
+
+ uri_list = g_list_next (uri_list);
+ }
+
gnome_vfs_uri_list_free (uri_list);
+
+ ev_application_open_uri_list (EV_APP, uris, 0);
+
+ g_slist_free (uris);
gtk_drag_finish (context, TRUE, FALSE, time);
}
{
g_return_if_fail (EV_IS_WINDOW (window));
- ev_page_cache_set_link (window->priv->page_cache, link);
+ ev_view_goto_link (EV_VIEW (window->priv->view), link);
gtk_widget_grab_focus (window->priv->view);
}
(priv->chrome & EV_CHROME_TOOLBAR) != 0);
g_signal_handlers_unblock_by_func
(action, G_CALLBACK (ev_window_view_toolbar_cb), window);
-
- action= gtk_action_group_get_action (action_group, "ViewSidebar");
- g_signal_handlers_block_by_func
- (action, G_CALLBACK (ev_window_view_sidebar_cb), window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- (priv->chrome & EV_CHROME_SIDEBAR) != 0);
- g_signal_handlers_unblock_by_func
- (action, G_CALLBACK (ev_window_view_sidebar_cb), window);
-
- action= gtk_action_group_get_action (action_group, "ViewStatusbar");
- g_signal_handlers_block_by_func
- (action, G_CALLBACK (ev_window_view_statusbar_cb), window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- (priv->chrome & EV_CHROME_STATUSBAR) != 0);
- g_signal_handlers_unblock_by_func
- (action, G_CALLBACK (ev_window_view_statusbar_cb), window);
-}
-
-static EvChrome
-load_chrome (void)
-{
- EvChrome chrome = EV_CHROME_NORMAL;
- GConfClient *client;
- GConfValue *value;
-
- client = gconf_client_get_default ();
-
- value = gconf_client_get (client, GCONF_CHROME_TOOLBAR, NULL);
- if (value != NULL) {
- if (value->type == GCONF_VALUE_BOOL && !gconf_value_get_bool (value)) {
- chrome &= ~EV_CHROME_TOOLBAR;
- }
- gconf_value_free (value);
- }
-
- value = gconf_client_get (client, GCONF_CHROME_SIDEBAR, NULL);
- if (value != NULL) {
- if (value->type == GCONF_VALUE_BOOL && !gconf_value_get_bool (value)) {
- chrome &= ~EV_CHROME_SIDEBAR;
- }
- gconf_value_free (value);
- }
-
- value = gconf_client_get (client, GCONF_CHROME_STATUSBAR, NULL);
- if (value != NULL) {
- if (value->type == GCONF_VALUE_BOOL && !gconf_value_get_bool (value)) {
- chrome &= ~EV_CHROME_STATUSBAR;
- }
- gconf_value_free (value);
- }
-
- g_object_unref (client);
-
- return chrome;
}
static void
action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
ev_page_action_set_model (EV_PAGE_ACTION (action), model);
+ g_object_unref (model);
}
static void
-set_view_actions_sensitivity (EvWindow *window, gboolean sensitive)
+ev_window_set_view_accels_sensitivity (EvWindow *window, gboolean sensitive)
{
if (window->priv->action_group) {
set_action_sensitive (window, "PageDown", sensitive);
set_action_sensitive (window, "Slash", sensitive);
set_action_sensitive (window, "Plus", sensitive);
set_action_sensitive (window, "Minus", sensitive);
+ set_action_sensitive (window, "KpPlus", sensitive);
+ set_action_sensitive (window, "KpMinus", sensitive);
+ set_action_sensitive (window, "Equal", sensitive);
}
}
-static void
+static gboolean
view_actions_focus_in_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *window)
{
- set_view_actions_sensitivity (window, TRUE);
+ update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, FALSE);
+ set_action_sensitive (window, "ViewToolbar", TRUE);
+
+ ev_window_set_view_accels_sensitivity (window, TRUE);
+
+ return FALSE;
}
-static void
+static gboolean
view_actions_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *window)
{
- set_view_actions_sensitivity (window, FALSE);
+ ev_window_set_view_accels_sensitivity (window, FALSE);
+
+ return FALSE;
}
static void
-enable_view_actions_for_widget (EvWindow *window, GtkWidget *widget)
+sidebar_page_main_widget_update_cb (GObject *ev_sidebar_page,
+ GParamSpec *pspec,
+ EvWindow *ev_window)
{
- g_signal_connect_object (widget, "focus_in_event",
- G_CALLBACK (view_actions_focus_in_cb),
- window, 0);
- g_signal_connect_object (widget, "focus_out_event",
- G_CALLBACK (view_actions_focus_out_cb),
- window, 0);
+ GtkWidget *widget;
+
+ g_object_get (ev_sidebar_page, "main_widget", &widget, NULL);
+
+ if (widget != NULL) {
+ g_signal_connect_object (widget, "focus_in_event",
+ G_CALLBACK (view_actions_focus_in_cb),
+ ev_window, 0);
+ g_signal_connect_object (widget, "focus_out_event",
+ G_CALLBACK (view_actions_focus_out_cb),
+ ev_window, 0);
+ g_object_unref (widget);
+ }
+}
+
+static gboolean
+window_state_event_cb (EvWindow *window, GdkEventWindowState *event, gpointer dummy)
+{
+ char *uri = window->priv->uri;
+
+ if (uri && !(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)) {
+ gboolean maximized;
+
+ maximized = event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED;
+ ev_metadata_manager_set_boolean (uri, "window_maximized", maximized);
+ }
+
+ return FALSE;
+}
+
+static gboolean
+window_configure_event_cb (EvWindow *window, GdkEventConfigure *event, gpointer dummy)
+{
+ char *uri = window->priv->uri;
+ GdkWindowState state;
+ int x, y, width, height;
+
+ state = gdk_window_get_state (GTK_WIDGET (window)->window);
+
+ if (uri && !(state & GDK_WINDOW_STATE_FULLSCREEN)) {
+ gtk_window_get_position (GTK_WINDOW (window), &x, &y);
+ gtk_window_get_size (GTK_WINDOW (window), &width, &height);
+
+ ev_metadata_manager_set_int (uri, "window_x", x);
+ ev_metadata_manager_set_int (uri, "window_y", y);
+ ev_metadata_manager_set_int (uri, "window_width", width);
+ ev_metadata_manager_set_int (uri, "window_height", height);
+ }
+
+ return FALSE;
+}
+
+static void
+sidebar_links_link_activated_cb (EvSidebarLinks *sidebar_links, EvLink *link, EvWindow *window)
+{
+ ev_view_goto_link (EV_VIEW (window->priv->view), link);
+}
+
+static void
+launch_link (EvWindow *window, EvLink *link)
+{
+ const char *filename = ev_link_get_filename (link);
+ char *uri = NULL;
+
+ if (filename && g_path_is_absolute (filename)) {
+ uri = gnome_vfs_get_uri_from_local_path (filename);
+ } else {
+ GnomeVFSURI *base_uri, *resolved_uri;
+
+ base_uri = gnome_vfs_uri_new (window->priv->uri);
+ if (base_uri && filename) {
+ resolved_uri = gnome_vfs_uri_resolve_relative (base_uri, filename);
+ if (resolved_uri) {
+ uri = gnome_vfs_uri_to_string (resolved_uri, GNOME_VFS_URI_HIDE_NONE);
+ gnome_vfs_uri_unref (resolved_uri);
+ }
+ gnome_vfs_uri_unref (base_uri);
+ }
+ }
+
+ if (uri) {
+ gnome_vfs_url_show (uri);
+ } else {
+ gnome_vfs_url_show (filename);
+ }
+
+ g_free (uri);
+
+ /* According to the PDF spec filename can be an executable. I'm not sure
+ allowing to launch executables is a good idea though. -- marco */
+}
+
+static void
+launch_external_uri (EvWindow *window, EvLink *link)
+{
+ const char *uri;
+ char *escaped;
+
+ uri = ev_link_get_uri (link);
+ escaped = gnome_vfs_escape_host_and_path_string (uri);
+
+ gnome_vfs_url_show (escaped);
+ g_free (escaped);
+}
+
+static void
+view_external_link_cb (EvView *view, EvLink *link, EvWindow *window)
+{
+ switch (ev_link_get_link_type (link)) {
+ case EV_LINK_TYPE_EXTERNAL_URI:
+ launch_external_uri (window, link);
+ break;
+ case EV_LINK_TYPE_LAUNCH:
+ launch_link (window, link);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
}
static void
GtkActionGroup *action_group;
GtkAccelGroup *accel_group;
GError *error = NULL;
- GtkWidget *sidebar_widget, *toolbar_dock, *tree_view;
- GConfValue *value;
- GConfClient *client;
- int sidebar_size;
+ GtkWidget *sidebar_widget, *toolbar_dock;
+
+ g_signal_connect (ev_window, "configure_event",
+ G_CALLBACK (window_configure_event_cb), NULL);
+ g_signal_connect (ev_window, "window_state_event",
+ G_CALLBACK (window_state_event_cb), NULL);
ev_window->priv = EV_WINDOW_GET_PRIVATE (ev_window);
ev_window->priv->page_mode = PAGE_MODE_DOCUMENT;
- update_window_title (NULL, NULL, ev_window);
+ ev_window->priv->title = ev_window_title_new (ev_window);
ev_window->priv->main_box = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (ev_window), ev_window->priv->main_box);
gtk_ui_manager_get_accel_group (ev_window->priv->ui_manager);
gtk_window_add_accel_group (GTK_WINDOW (ev_window), accel_group);
- set_view_actions_sensitivity (ev_window, FALSE);
-
- g_signal_connect (ev_window->priv->ui_manager, "connect_proxy",
- G_CALLBACK (connect_proxy_cb), ev_window);
- g_signal_connect (ev_window->priv->ui_manager, "disconnect_proxy",
- G_CALLBACK (disconnect_proxy_cb), ev_window);
+ ev_window_set_view_accels_sensitivity (ev_window, FALSE);
if (!gtk_ui_manager_add_ui_from_file (ev_window->priv->ui_manager,
DATADIR"/evince-ui.xml",
ev_window->priv->menubar,
FALSE, FALSE, 0);
- /* Toolbar editor */
- ev_window->priv->toolbar_model = egg_toolbars_model_new ();
-
- ev_window->priv->toolbar_file = g_build_filename
- (ev_dot_dir (), "evince_toolbar.xml", NULL);
-
- if (!g_file_test (ev_window->priv->toolbar_file, G_FILE_TEST_EXISTS)) {
- egg_toolbars_model_load (ev_window->priv->toolbar_model,
- DATADIR"/evince-toolbar.xml");
- } else {
- egg_toolbars_model_load (ev_window->priv->toolbar_model,
- ev_window->priv->toolbar_file);
- }
-
- egg_toolbars_model_set_flags (ev_window->priv->toolbar_model, 0,
- EGG_TB_MODEL_NOT_REMOVABLE);
-
/* This sucks, but there is no way to have a draw=no, expand=true separator
* in a GtkUIManager-built toolbar. So, just add another toolbar.
* See gtk+ bug 166489.
gtk_widget_show (toolbar_dock);
ev_window->priv->toolbar = egg_editable_toolbar_new_with_model
- (ev_window->priv->ui_manager, ev_window->priv->toolbar_model);
+ (ev_window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP));
egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar),
"DefaultToolBar");
gtk_box_pack_start (GTK_BOX (toolbar_dock), ev_window->priv->toolbar,
TRUE, TRUE, 0);
gtk_widget_show (ev_window->priv->toolbar);
- ev_window->priv->fullscreen_toolbar =
- gtk_ui_manager_get_widget (ev_window->priv->ui_manager, "/LeaveFullscreenToolbar");
- gtk_toolbar_set_show_arrow (GTK_TOOLBAR (ev_window->priv->fullscreen_toolbar), TRUE);
-
-
/* Add the main area */
ev_window->priv->hpaned = gtk_hpaned_new ();
g_signal_connect (ev_window->priv->hpaned,
G_CALLBACK (ev_window_sidebar_position_change_cb),
ev_window);
- sidebar_size = SIDEBAR_DEFAULT_SIZE;
- client = gconf_client_get_default ();
- value = gconf_client_get (client, GCONF_SIDEBAR_SIZE, NULL);
- if (value != NULL) {
- if (value->type == GCONF_VALUE_INT) {
- sidebar_size = gconf_value_get_int (value);
- }
- gconf_value_free (value);
- }
- g_object_unref (client);
- gtk_paned_set_position (GTK_PANED (ev_window->priv->hpaned), sidebar_size);
+ gtk_paned_set_position (GTK_PANED (ev_window->priv->hpaned), SIDEBAR_DEFAULT_SIZE);
gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), ev_window->priv->hpaned,
TRUE, TRUE, 0);
gtk_widget_show (ev_window->priv->hpaned);
/* Stub sidebar, for now */
sidebar_widget = ev_sidebar_links_new ();
+ ev_window->priv->sidebar_links = sidebar_widget;
g_signal_connect (sidebar_widget,
"notify::model",
G_CALLBACK (sidebar_widget_model_set),
ev_window);
- tree_view = ev_sidebar_links_get_treeview
- (EV_SIDEBAR_LINKS (sidebar_widget));
- enable_view_actions_for_widget (ev_window, tree_view);
+ g_signal_connect (sidebar_widget,
+ "link_activated",
+ G_CALLBACK (sidebar_links_link_activated_cb),
+ ev_window);
+ sidebar_page_main_widget_update_cb (G_OBJECT (sidebar_widget), NULL, ev_window);
gtk_widget_show (sidebar_widget);
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
sidebar_widget);
sidebar_widget = ev_sidebar_thumbnails_new ();
- tree_view = ev_sidebar_thumbnails_get_treeview
- (EV_SIDEBAR_THUMBNAILS (sidebar_widget));
- enable_view_actions_for_widget (ev_window, tree_view);
+ ev_window->priv->sidebar_thumbs = sidebar_widget;
+ g_signal_connect (sidebar_widget,
+ "notify::main-widget",
+ G_CALLBACK (sidebar_page_main_widget_update_cb),
+ ev_window);
+ sidebar_page_main_widget_update_cb (G_OBJECT (sidebar_widget), NULL, ev_window);
gtk_widget_show (sidebar_widget);
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
sidebar_widget);
+
ev_window->priv->scrolled_window =
GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,
"shadow-type", GTK_SHADOW_IN,
"unlock",
G_CALLBACK (ev_window_popup_password_dialog),
ev_window);
- enable_view_actions_for_widget (ev_window, ev_window->priv->view);
+ g_signal_connect_object (ev_window->priv->view, "focus_in_event",
+ G_CALLBACK (view_actions_focus_in_cb),
+ ev_window, 0);
+ g_signal_connect_object (ev_window->priv->view, "focus_out_event",
+ G_CALLBACK (view_actions_focus_out_cb),
+ ev_window, 0);
+ g_signal_connect_object (ev_window->priv->view, "external-link",
+ G_CALLBACK (view_external_link_cb),
+ ev_window, 0);
gtk_widget_show (ev_window->priv->view);
gtk_widget_show (ev_window->priv->password_view);
+ ev_window->priv->find_bar = egg_find_bar_new ();
+ gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
+ ev_window->priv->find_bar,
+ FALSE, TRUE, 0);
+
/* We own a ref on these widgets, as we can swap them in and out */
g_object_ref (ev_window->priv->view);
//g_object_ref (ev_window->priv->page_view);
"notify::find-status",
G_CALLBACK (view_find_status_changed_cb),
ev_window);
- g_signal_connect (ev_window->priv->view,
- "notify::status",
- G_CALLBACK (view_status_changed_cb),
- ev_window);
g_signal_connect (ev_window->priv->view,
"notify::sizing-mode",
G_CALLBACK (ev_window_sizing_mode_changed_cb),
"notify::zoom",
G_CALLBACK (ev_window_zoom_changed_cb),
ev_window);
+ g_signal_connect (ev_window->priv->view,
+ "notify::dual-page",
+ G_CALLBACK (ev_window_dual_mode_changed_cb),
+ ev_window);
+ g_signal_connect (ev_window->priv->view,
+ "notify::continuous",
+ G_CALLBACK (ev_window_continuous_changed_cb),
+ ev_window);
+ g_signal_connect (ev_window->priv->view,
+ "notify::rotation",
+ G_CALLBACK (ev_window_rotation_changed_cb),
+ ev_window);
+ g_signal_connect (ev_window->priv->view,
+ "notify::has-selection",
+ G_CALLBACK (ev_window_has_selection_changed_cb),
+ ev_window);
- ev_window->priv->statusbar = gtk_statusbar_new ();
- gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
- ev_window->priv->statusbar,
- FALSE, TRUE, 0);
- ev_window->priv->help_message_cid = gtk_statusbar_get_context_id
- (GTK_STATUSBAR (ev_window->priv->statusbar), "help_message");
- ev_window->priv->view_message_cid = gtk_statusbar_get_context_id
- (GTK_STATUSBAR (ev_window->priv->statusbar), "view_message");
-
- ev_window->priv->find_bar = egg_find_bar_new ();
- gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
- ev_window->priv->find_bar,
- FALSE, TRUE, 0);
-
- ev_window_setup_recent (ev_window);
- ev_window->priv->chrome = load_chrome ();
- set_chrome_actions (ev_window);
- update_chrome_visibility (ev_window);
-
- /* Connect sidebar signals */
+ /* Connect sidebar signals */
g_signal_connect (ev_window->priv->sidebar,
"notify::visible",
G_CALLBACK (ev_window_sidebar_visibility_changed_cb),
ev_window);
-
+ g_signal_connect (ev_window->priv->sidebar,
+ "notify::current-page",
+ G_CALLBACK (ev_window_sidebar_current_page_changed_cb),
+ ev_window);
+
/* Connect to find bar signals */
g_signal_connect (ev_window->priv->find_bar,
"previous",
g_signal_connect (G_OBJECT (ev_window), "drag_data_received",
G_CALLBACK (drag_data_received_cb), NULL);
- /* Set it to something random to force a change */
+ /* Set it user interface params */
+
+ ev_window_setup_recent (ev_window);
+ setup_chrome_from_metadata (ev_window);
+ set_chrome_actions (ev_window);
+ update_chrome_visibility (ev_window);
+
+ gtk_window_set_default_size (GTK_WINDOW (ev_window),
+ 600, 600);
+ setup_view_from_metadata (ev_window);
ev_window_sizing_mode_changed_cb (EV_VIEW (ev_window->priv->view), NULL, ev_window);
update_action_sensitivity (ev_window);
}
+
+GtkWidget *
+ev_window_new (void)
+{
+ GtkWidget *ev_window;
+
+ ev_window = GTK_WIDGET (g_object_new (EV_TYPE_WINDOW,
+ "type", GTK_WINDOW_TOPLEVEL,
+ NULL));
+
+ return ev_window;
+}