#include "ev-password.h"
#include "ev-password-view.h"
#include "ev-print-job.h"
+#include "ev-properties.h"
#include "ev-document-thumbnails.h"
#include "ev-document-links.h"
+#include "ev-document-fonts.h"
#include "ev-document-types.h"
#include "ev-document-find.h"
#include "ev-document-security.h"
static void ev_window_sizing_mode_changed_cb (EvView *view,
GParamSpec *pspec,
EvWindow *ev_window);
+static void ev_window_zoom_changed_cb (EvView *view,
+ GParamSpec *pspec,
+ 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_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)
{
EvView *view;
EvDocument *document;
+ const EvDocumentInfo *info = NULL;
EvWindowPageMode page_mode;
gboolean sensitive, has_pages = FALSE, has_document;
int n_pages = 0, page = -1;
+ gboolean ok_to_print = TRUE;
+ gboolean ok_to_copy = TRUE;
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) {
has_pages = has_document && n_pages > 0;
}
+ if (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);
+ }
+
/* File menu */
/* "FileOpen": always sensitive */
- set_action_sensitive (ev_window, "FileSaveAs", has_document);
- set_action_sensitive (ev_window, "FilePrint", has_pages);
+ 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);
/* "FileCloseWindow": always sensitive */
/* Edit menu */
-
sensitive = has_pages && ev_document_can_get_text (document);
- set_action_sensitive (ev_window, "EditCopy", sensitive);
- set_action_sensitive (ev_window, "EditSelectAll", sensitive);
+ 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, "EditFind",
has_pages && EV_IS_DOCUMENT_FIND (document));
set_action_sensitive (ev_window, "Slash",
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);
}
}
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);
+ 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)) {
- g_free (doc_title);
doc_title = NULL;
}
}
static void
ev_window_setup_document (EvWindow *ev_window)
{
- EvDocumentInfo *info;
+ const EvDocumentInfo *info;
EvDocument *document;
EvView *view = EV_VIEW (ev_window->priv->view);
EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
ev_page_action_set_document (EV_PAGE_ACTION (action), document);
update_action_sensitivity (ev_window);
- info = ev_document_get_info (document);
+ info = ev_page_cache_get_info (ev_window->priv->page_cache);
update_document_mode (ev_window, info->mode);
- ev_document_info_free (info);
}
static void
ev_window_print (ev_window);
}
+static void
+ev_window_cmd_file_properties (GtkAction *action, EvWindow *ev_window)
+{
+ EvDocument *document = ev_window->priv->document;
+ EvDocumentInfo *info;
+ GtkDialog *dialog;
+ GtkTreeModel *fonts;
+
+ if (EV_IS_DOCUMENT_FONTS (document)) {
+ fonts = ev_document_fonts_get_fonts_model (EV_DOCUMENT_FONTS (document));
+ } else {
+ fonts = NULL;
+ }
+
+ info = ev_document_get_info (document);
+ dialog = ev_properties_new (info, fonts);
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (ev_window));
+ gtk_dialog_run (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ ev_document_info_free (info);
+}
+
static void
ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window)
{
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;
}
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);
}
ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
ev_view_zoom_in (EV_VIEW (ev_window->priv->view));
- update_action_sensitivity (ev_window);
}
static void
ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
ev_view_zoom_out (EV_VIEW (ev_window->priv->view));
- update_action_sensitivity (ev_window);
}
static void
}
}
+static void
+update_view_size (EvView *view, EvWindow *window)
+{
+ int width, height;
+ GtkRequisition vsb_requisition;
+ GtkRequisition hsb_requisition;
+ int scrollbar_spacing;
+
+ /* Calculate the width available for the */
+ width = window->priv->scrolled_window->allocation.width;
+ height = window->priv->scrolled_window->allocation.height;
+
+ if (gtk_scrolled_window_get_shadow_type (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)) == GTK_SHADOW_IN) {
+ width -= 2 * window->priv->view->style->xthickness;
+ height -= 2 * window->priv->view->style->ythickness;
+ }
+
+ gtk_widget_size_request (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)->vscrollbar,
+ &vsb_requisition);
+ gtk_widget_size_request (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)->hscrollbar,
+ &hsb_requisition);
+ gtk_widget_style_get (window->priv->scrolled_window,
+ "scrollbar_spacing", &scrollbar_spacing,
+ NULL);
+
+ ev_view_set_zoom_for_size (EV_VIEW (window->priv->view),
+ MAX (1, width),
+ MAX (1, height),
+ vsb_requisition.width + scrollbar_spacing,
+ hsb_requisition.height + scrollbar_spacing);
+}
+
static void
ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec,
EvWindow *ev_window)
scrolled_window = ev_window->priv->scrolled_window;
+ g_signal_handlers_disconnect_by_func (ev_window->priv->view, update_view_size, ev_window);
+
+ if (sizing_mode != EV_SIZING_FREE)
+ update_view_size (NULL, ev_window);
+
switch (sizing_mode) {
case EV_SIZING_BEST_FIT:
g_object_set (G_OBJECT (scrolled_window),
"hscrollbar-policy", GTK_POLICY_NEVER,
"vscrollbar-policy", GTK_POLICY_AUTOMATIC,
NULL);
+ g_signal_connect (ev_window->priv->view, "zoom_invalid",
+ G_CALLBACK (update_view_size),
+ ev_window);
break;
case EV_SIZING_FIT_WIDTH:
g_object_set (G_OBJECT (scrolled_window),
"hscrollbar-policy", GTK_POLICY_NEVER,
"vscrollbar-policy", GTK_POLICY_AUTOMATIC,
NULL);
+ g_signal_connect (ev_window->priv->view, "zoom_invalid",
+ G_CALLBACK (update_view_size),
+ ev_window);
break;
case EV_SIZING_FREE:
g_object_set (G_OBJECT (scrolled_window),
update_sizing_buttons (ev_window);
}
+static void
+ev_window_zoom_changed_cb (EvView *view, GParamSpec *pspec,
+ EvWindow *ev_window)
+{
+ update_action_sensitivity (ev_window);
+}
+
static char *
build_comments_string (void)
{
}
ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), mode);
- update_action_sensitivity (ev_window);
}
static void
priv->find_bar = NULL;
}
+ if (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);
{ "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"),
+ G_CALLBACK (ev_window_cmd_file_properties) },
{ "FileCloseWindow", GTK_STOCK_CLOSE, NULL, "<control>W",
N_("Close this window"),
G_CALLBACK (ev_window_cmd_file_close_window) },
{ "ShiftBackSpace", NULL, "", "<shift>BackSpace",
N_("Scroll one page forward"),
G_CALLBACK (ev_window_cmd_scroll_forward) },
+ { "Plus", GTK_STOCK_ZOOM_IN, NULL, "plus",
+ N_("Enlarge the document"),
+ G_CALLBACK (ev_window_cmd_view_zoom_in) },
+ { "Minus", GTK_STOCK_ZOOM_OUT, NULL, "minus",
+ N_("Shrink the document"),
+ 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) }
{ "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",
set_action_sensitive (window, "ShiftSpace", sensitive);
set_action_sensitive (window, "BackSpace", sensitive);
set_action_sensitive (window, "ShiftBackSpace", sensitive);
+ set_action_sensitive (window, "Slash", sensitive);
+ set_action_sensitive (window, "Plus", sensitive);
+ set_action_sensitive (window, "Minus", sensitive);
}
}
"notify::sizing-mode",
G_CALLBACK (ev_window_sizing_mode_changed_cb),
ev_window);
+ g_signal_connect (ev_window->priv->view,
+ "notify::zoom",
+ G_CALLBACK (ev_window_zoom_changed_cb),
+ ev_window);
ev_window->priv->statusbar = gtk_statusbar_new ();
gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),