#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.h"
+#include "ev-properties-dialog.h"
+#include "ev-ps-exporter.h"
#include "ev-document-thumbnails.h"
#include "ev-document-links.h"
#include "ev-document-fonts.h"
#include "ev-document-types.h"
#include "ev-job-queue.h"
#include "ev-jobs.h"
-#include "ev-statusbar.h"
#include "ev-sidebar-page.h"
#include "eggfindbar.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>
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_RAISE_TOOLBAR = 1 << 5,
- 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 {
GtkWidget *view;
GtkWidget *page_view;
GtkWidget *password_view;
- GtkWidget *statusbar;
GtkWidget *sidebar_thumbs;
+ GtkWidget *sidebar_links;
+
+ EvWindowTitle *title;
/* Dialogs */
- EvProperties *properties;
+ GtkWidget *properties;
/* UI Builders */
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
- gchar *toolbar_file;
- EggToolbarsModel *toolbar_model;
-
/* Fullscreen mode */
GtkWidget *fullscreen_toolbar;
GtkWidget *fullscreen_popup;
- GSource *fullscreen_timeout_source;
+ GSource *fullscreen_timeout_source;
/* Document */
char *uri;
EvJob *xfer_job;
EvJob *load_job;
- /* recent file stuff */
- EggRecentModel *recent_model;
EggRecentViewUIManager *recent_view;
};
#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_CHROME_TOOLBAR "/apps/evince/show_toolbar"
+#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_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_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;
+ 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);
+
/* 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);
+ set_action_sensitive (ev_window, "FileProperties", has_document && has_properties);
/* "FileCloseWindow": always sensitive */
/* Edit menu */
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);
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));
menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !fullscreen_mode;
toolbar = ((priv->chrome & EV_CHROME_TOOLBAR) != 0 ||
(priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && !fullscreen_mode;
- sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !fullscreen_mode;
fullscreen_toolbar = ((priv->chrome & EV_CHROME_TOOLBAR) != 0 ||
(priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0);
- statusbar = (priv->chrome & EV_CHROME_STATUSBAR) != 0 && !fullscreen_mode;
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) {
if (fullscreen)
show_fullscreen_popup (window);
else
set_widget_visibility (priv->fullscreen_popup, FALSE);
+
+ set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar);
}
}
(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_load (EvWindow *ev_window,
const char *error_message)
_("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);
-}
-
-static void
-update_window_title (EvDocument *document, GParamSpec *pspec, 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 = g_strdup (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)) {
- doc_title = NULL;
- }
- }
- }
-
- if (doc_title) {
- char *p;
-
- for (p = doc_title; *p; ++p) {
- /* an '\n' byte is always ASCII, no need for UTF-8 special casing */
- if (*p == '\n')
- *p = ' ';
- }
- }
-
- 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);
- }
-
- 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);
- }
- }
-
- gtk_window_set_title (GTK_WINDOW (ev_window), title);
-
- g_free (doc_title);
- g_free (title);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (unable_to_load_dialog_response_cb),
+ ev_window);
+ gtk_widget_show (dialog);
}
static void
EvWindow *ev_window)
{
update_action_sensitivity (ev_window);
+
+ if (ev_window->priv->uri) {
+ ev_metadata_manager_set_int (ev_window->priv->uri, "page", page);
+ }
}
static void
ev_window_run_presentation (window);
}
else if (mode == EV_DOCUMENT_MODE_FULL_SCREEN) {
- ev_window_fullscreen (window);
+ ev_window_run_fullscreen (window);
}
}
+static void
+update_sidebar_visibility (EvWindow *window)
+{
+ char *uri = window->priv->uri;
+ GValue sidebar_visibility = { 0, };
+
+ if (uri && ev_metadata_manager_get (uri, "sidebar_visibility", &sidebar_visibility)) {
+ set_widget_visibility (window->priv->sidebar,
+ g_value_get_boolean (&sidebar_visibility));
+ }
+}
+
+static void
+setup_document_from_metadata (EvWindow *window)
+{
+ char *uri = window->priv->uri;
+ GValue page = { 0, };
+
+ /* Page */
+ if (uri && ev_metadata_manager_get (uri, "page", &page)) {
+ ev_page_cache_set_current_page (window->priv->page_cache,
+ g_value_get_int (&page));
+ }
+}
+
+static void
+setup_sidebar_from_metadata (EvWindow *window, EvDocument *document)
+{
+ 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)) {
+ 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)) {
+ 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
ev_window_setup_document (EvWindow *ev_window)
{
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->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);
update_document_mode (ev_window, info->mode);
if (ev_window->priv->properties) {
- ev_properties_set_document (ev_window->priv->properties,
- ev_window->priv->document);
+ 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;
-
+
+ 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);
- ev_statusbar_push (EV_STATUSBAR (ev_window->priv->statusbar),
- EV_CONTEXT_PROGRESS,
- _("Loading document. Please wait"));
-
- ev_statusbar_set_progress (EV_STATUSBAR (ev_window->priv->statusbar),
- TRUE);
-
gtk_widget_destroy (password_dialog);
g_object_unref (document);
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_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));
}
}
g_assert (document != ev_window->priv->document);
g_assert (job->uri);
- ev_statusbar_pop (EV_STATUSBAR (ev_window->priv->statusbar),
- EV_CONTEXT_PROGRESS);
-
- ev_statusbar_set_progress (EV_STATUSBAR (ev_window->priv->statusbar),
- FALSE);
-
if (ev_window->priv->password_document) {
g_object_unref (ev_window->priv->password_document);
ev_window->priv->password_document = NULL;
ev_window->priv->password_document = g_object_ref (document);
ev_window->priv->password_uri = g_strdup (job->uri);
- base_name = g_path_get_basename (job->uri);
- file_name = gnome_vfs_unescape_string_for_display (base_name);
-
+ 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);
if (job->error != NULL) {
- ev_statusbar_pop (EV_STATUSBAR (ev_window->priv->statusbar),
- EV_CONTEXT_PROGRESS);
- ev_statusbar_set_progress (EV_STATUSBAR (ev_window->priv->statusbar),
- FALSE);
-
unable_to_load (ev_window, job->error->message);
ev_window_clear_jobs (ev_window);
} else {
}
}
+static void
+setup_view_from_metadata (EvWindow *window)
+{
+ 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, };
+
+ if (window->priv->uri == NULL) {
+ return;
+ }
+
+ /* Window size */
+ if (!GTK_WIDGET_VISIBLE (window)) {
+ gboolean restore_size = TRUE;
+
+ if (ev_metadata_manager_get (uri, "window_maximized", &maximized)) {
+ if (g_value_get_boolean (&maximized)) {
+ gtk_window_maximize (GTK_WINDOW (window));
+ restore_size = FALSE;
+ }
+ }
+
+ if (restore_size &&
+ ev_metadata_manager_get (uri, "window_x", &x) &&
+ ev_metadata_manager_get (uri, "window_y", &y) &&
+ ev_metadata_manager_get (uri, "window_width", &width) &&
+ ev_metadata_manager_get (uri, "window_height", &height)) {
+ gtk_window_set_default_size (GTK_WINDOW (window),
+ g_value_get_int (&width),
+ g_value_get_int (&height));
+ gtk_window_move (GTK_WINDOW (window), g_value_get_int (&x),
+ g_value_get_int (&y));
+ }
+ }
+
+ /* Sizing mode */
+ if (ev_metadata_manager_get (uri, "sizing_mode", &sizing_mode)) {
+ 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);
+ }
+
+ /* Zoom */
+ if (ev_metadata_manager_get (uri, "zoom", &zoom) &&
+ ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
+ ev_view_set_zoom (view, g_value_get_double (&zoom), FALSE);
+ }
+
+ /* Continuous */
+ if (ev_metadata_manager_get (uri, "continuous", &continuous)) {
+ ev_view_set_continuous (view, g_value_get_boolean (&continuous));
+ }
+
+ /* Dual page */
+ if (ev_metadata_manager_get (uri, "dual-page", &dual_page)) {
+ ev_view_set_dual_page (view, g_value_get_boolean (&dual_page));
+ }
+
+ /* Presentation */
+ if (ev_metadata_manager_get (uri, "presentation", &presentation)) {
+ if (g_value_get_boolean (&presentation)) {
+ ev_window_run_presentation (window);
+ }
+ }
+
+ /* Fullscreen */
+ if (ev_metadata_manager_get (uri, "fullscreen", &fullscreen)) {
+ if (g_value_get_boolean (&fullscreen)) {
+ ev_window_run_fullscreen (window);
+ }
+ }
+
+ /* Rotation */
+ if (ev_metadata_manager_get (uri, "rotation", &rotation)) {
+ 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;
+ }
+ }
+ }
+}
+
void
ev_window_open_uri (EvWindow *ev_window, const char *uri)
{
g_free (ev_window->priv->uri);
ev_window->priv->uri = g_strdup (uri);
+
+ setup_view_from_metadata (ev_window);
ev_window_clear_jobs (ev_window);
ev_window_clear_local_uri (ev_window);
G_CALLBACK (ev_window_xfer_job_cb),
ev_window);
ev_job_queue_add_job (ev_window->priv->xfer_job, EV_JOB_PRIORITY_HIGH);
-
- ev_statusbar_push (EV_STATUSBAR (ev_window->priv->statusbar),
- EV_CONTEXT_PROGRESS,
- _("Loading document. Please wait"));
- ev_statusbar_set_progress (EV_STATUSBAR (ev_window->priv->statusbar),
- TRUE);
}
-void
-ev_window_open_uri_list (EvWindow *ev_window, GSList *uri_list)
+static void
+file_open_dialog_response_cb (GtkWidget *chooser,
+ gint response_id,
+ EvWindow *ev_window)
{
- GSList *list;
- gchar *uri;
-
- g_return_if_fail (uri_list != NULL);
-
- list = uri_list;
- while (list) {
-
- uri = (gchar *)list->data;
-
- if (ev_window_is_empty (EV_WINDOW (ev_window))) {
- ev_window_open_uri (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_uri (new_window, uri);
-
- gtk_widget_show (GTK_WIDGET (new_window));
- }
+ if (response_id == GTK_RESPONSE_OK) {
+ GSList *uris;
- g_free (uri);
+ uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (chooser));
- list = g_slist_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
{
char *uri;
EggRecentItem *item;
- GtkWidget *window;
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_uri (EV_WINDOW (window), uri);
+
+ ev_application_open_uri (EV_APP, uri, NULL, GDK_CURRENT_TIME, NULL);
g_free (uri);
}
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)
{
-
-
- /* 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_uimanager_new (ev_window->priv->ui_manager,
"/MainMenu/FileMenu/RecentFilesMenu",
G_CALLBACK (ev_window_cmd_recent_file_activate),
ev_window);
egg_recent_view_uimanager_show_icons (EGG_RECENT_VIEW_UIMANAGER (ev_window->priv->recent_view), FALSE);
- egg_recent_model_set_limit (ev_window->priv->recent_model, 5);
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_uimanager_set_trailing_sep (ev_window->priv->recent_view, TRUE);
}
static void
-ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window)
+file_save_dialog_response_cb (GtkWidget *fc,
+ gint response_id,
+ EvWindow *ev_window)
{
- GtkWidget *fc;
+ gboolean success;
- gchar *uri;
- gchar *basename;
- static char* folder = NULL;
+ if (response_id == GTK_RESPONSE_OK) {
+ const char *uri;
- gboolean success;
+ 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;
+ 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);
- ev_document_types_add_filters_for_type (fc, G_TYPE_FROM_INSTANCE (ev_window->priv->document));
+ ev_document_types_add_filters (fc, ev_window->priv->document);
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
- if (folder) {
- gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER (fc),
- folder);
- }
-
- basename = g_path_get_basename (ev_window->priv->uri);
- gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc), basename);
- g_free (basename);
+ 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;
}
- if (folder != NULL)
- g_free (folder);
-
- folder = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (fc));
-
- 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)
{
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)
{
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_cmd_file_properties (GtkAction *action, EvWindow *ev_window)
{
if (ev_window->priv->properties == NULL) {
- ev_window->priv->properties = ev_properties_new ();
- ev_properties_set_document (ev_window->priv->properties,
- ev_window->priv->document);
+ 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));
}
- ev_properties_show (ev_window->priv->properties, GTK_WIDGET (ev_window));
+ gtk_widget_show (ev_window->priv->properties);
}
static void
{
GtkWidget *popup = window->priv->fullscreen_popup;
int popup_width, popup_height;
+ GdkScreen *screen;
GdkRectangle screen_rect;
gboolean toolbar;
g_return_if_fail (popup != NULL);
+ 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));
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 maximized;
-
- maximized = (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) == 0;
-
- ev_statusbar_set_maximized (EV_STATUSBAR (window->priv->statusbar),
- maximized);
- }
-
- return FALSE;
-}
-
static gboolean
ev_window_focus_in_event (GtkWidget *widget, GdkEventFocus *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));
}
ev_window_cmd_edit_rotate_left (GtkAction *action, EvWindow *ev_window)
{
ev_view_rotate_left (EV_VIEW (ev_window->priv->view));
- ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (ev_window->priv->sidebar_thumbs));
}
static void
ev_window_cmd_edit_rotate_right (GtkAction *action, EvWindow *ev_window)
{
ev_view_rotate_right (EV_VIEW (ev_window->priv->view));
- ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (ev_window->priv->sidebar_thumbs));
}
static void
{
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
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);
+ 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)
+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_dual_mode_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *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_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_mode;
-
- fullscreen_mode = ev_view_get_presentation (EV_VIEW (ev_window->priv->view)) ||
- ev_view_get_fullscreen (EV_VIEW (ev_window->priv->view));
-
- 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_mode)
- 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) {
- ev_statusbar_push (EV_STATUSBAR (ev_window->priv->statusbar),
- EV_CONTEXT_VIEW, message);
- g_free (message);
- }
-}
-
-static void
-menu_item_deselect_cb (GtkMenuItem *proxy, EvWindow *ev_window)
-{
- ev_statusbar_pop (EV_STATUSBAR (ev_window->priv->statusbar),
- EV_CONTEXT_VIEW);
-}
-
-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;
-
- ev_statusbar_pop (EV_STATUSBAR (ev_window->priv->statusbar),
- EV_CONTEXT_HELP);
-
- message = ev_view_get_status (view);
- if (message) {
- ev_statusbar_push (EV_STATUSBAR (ev_window->priv->statusbar),
- EV_CONTEXT_HELP, 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));
}
}
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));
}
}
+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_list_free (windows);
+ G_OBJECT_CLASS (ev_window_parent_class)->finalize (object);
+}
+
static void
ev_window_dispose (GObject *object)
{
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->recent_model) {
- g_object_unref (priv->recent_model);
- priv->recent_model = NULL;
+ if (priv->title) {
+ ev_window_title_free (priv->title);
+ priv->title = NULL;
}
if (priv->recent_view) {
priv->recent_view = NULL;
}
-
if (priv->ui_manager) {
g_object_unref (priv->ui_manager);
priv->ui_manager = NULL;
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;
}
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) },
- { "FileProperties", GTK_STOCK_PROPERTIES, N_("Properties"), "<alt>Return",
- N_("View the properties of this document"),
+ { "FileProperties", GTK_STOCK_PROPERTIES, N_("P_roperties"), "<alt>Return", NULL,
G_CALLBACK (ev_window_cmd_file_properties) },
- { "FileCloseWindow", GTK_STOCK_CLOSE, NULL, "<control>W",
- N_("Close this window"),
+ { "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,
- N_("Rotate the document to the left"),
+ { "EditRotateLeft", NULL, N_("Rotate _Left"), NULL, NULL,
G_CALLBACK (ev_window_cmd_edit_rotate_left) },
- { "EditRotateRight", NULL, N_("Rotate _Right"), NULL,
- N_("Rotate the document to the right"),
+ { "EditRotateRight", NULL, N_("Rotate _Right"), NULL, NULL,
G_CALLBACK (ev_window_cmd_edit_rotate_right) },
/* View menu */
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) },
- { "CtrlEqual", GTK_STOCK_ZOOM_IN, NULL, "<control>equal",
- N_("Enlarge the document"),
+ { "CtrlEqual", GTK_STOCK_ZOOM_IN, NULL, "<control>equal", NULL,
G_CALLBACK (ev_window_cmd_view_zoom_in) },
- { "Minus", GTK_STOCK_ZOOM_OUT, NULL, "minus",
- N_("Shrink the document"),
+ { "Minus", GTK_STOCK_ZOOM_OUT, NULL, "minus", NULL,
G_CALLBACK (ev_window_cmd_view_zoom_out) },
- { "FocusPageSelector", NULL, "", "<control>l",
- N_("Focus the page selector"),
+ { "FocusPageSelector", NULL, "", "<control>l", NULL,
G_CALLBACK (ev_window_cmd_focus_page_selector) },
- { "GoBackwardFast", NULL, "", "<shift>Page_Up",
- N_("Go ten pages backward"),
+ { "GoBackwardFast", NULL, "", "<shift>Page_Up", NULL,
G_CALLBACK (ev_window_cmd_go_backward) },
- { "GoForwardFast", NULL, "", "<shift>Page_Down",
- N_("Go ten pages forward"),
+ { "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) },
};
/* 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", EV_STOCK_VIEW_CONTINUOUS, N_("_Continuous"), NULL,
{ "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,
gnome_vfs_uri_list_free (uri_list);
- ev_window_open_uri_list (EV_WINDOW (widget), uris);
+ ev_application_open_uri_list (EV_APP, uris, 0);
g_slist_free (uris);
{
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
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
-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);
}
}
-static void
+static gboolean
view_actions_focus_in_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *window)
{
update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, NULL, FALSE);
set_action_sensitive (window, "ViewToolbar", TRUE);
- set_view_actions_sensitivity (window, 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
}
}
+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
ev_window_init (EvWindow *ev_window)
{
GtkAccelGroup *accel_group;
GError *error = NULL;
GtkWidget *sidebar_widget, *toolbar_dock;
- GConfValue *value;
- GConfClient *client;
- int sidebar_size;
+
+ 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);
+ 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),
"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);
- ev_window->priv->statusbar = ev_statusbar_new ();
- gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
- ev_window->priv->statusbar,
- FALSE, TRUE, 0);
-
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,
"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",
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,
+ "default-width", 600,
+ "default-height", 600,
+ NULL));
+
+ return ev_window;
+}