#include "ev-window-title.h"
#include "ev-navigation-action.h"
#include "ev-page-action.h"
+#include "ev-open-recent-action.h"
#include "ev-sidebar.h"
#include "ev-sidebar-links.h"
#include "ev-sidebar-attachments.h"
#include "ev-jobs.h"
#include "ev-sidebar-page.h"
#include "eggfindbar.h"
-
-#ifndef HAVE_GTK_RECENT
-#include "egg-recent-view-uimanager.h"
-#include "egg-recent-view.h"
-#include "egg-recent-model.h"
-#endif
-
#include "egg-toolbar-editor.h"
#include "egg-editable-toolbar.h"
#include "egg-toolbars-model.h"
#include <glib/gstdio.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <gnome.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libgnomevfs/gnome-vfs-async-ops.h>
+#include <libgnomevfs/gnome-vfs-ops.h>
#include <gconf/gconf-client.h>
+#include <errno.h>
+#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+
+#include "ev-message-area.h"
+#if !GLIB_CHECK_VERSION (2, 13, 3)
char *xdg_user_dir_lookup (char *type);
+#endif
typedef enum {
PAGE_MODE_DOCUMENT,
GtkWidget *main_box;
GtkWidget *menubar;
- GtkWidget *toolbar_dock;
GtkWidget *toolbar;
GtkWidget *hpaned;
+ GtkWidget *view_box;
GtkWidget *sidebar;
GtkWidget *find_bar;
GtkWidget *scrolled_window;
GtkWidget *view;
+ GtkWidget *message_area;
GtkWidget *password_view;
GtkWidget *sidebar_thumbs;
GtkWidget *sidebar_links;
GtkWidget *sidebar_attachments;
- GtkWidget *preview_toolbar;
/* Dialogs */
GtkWidget *properties;
GtkActionGroup *action_group;
GtkActionGroup *view_popup_action_group;
GtkActionGroup *attachment_popup_action_group;
-#ifdef HAVE_GTK_RECENT
GtkRecentManager *recent_manager;
GtkActionGroup *recent_action_group;
guint recent_ui_id;
-#endif
GtkUIManager *ui_manager;
/* Fullscreen mode */
GtkWidget *fullscreen_toolbar;
- GtkWidget *fullscreen_popup;
- guint fullscreen_timeout_id;
+
+ /* Presentation mode */
+ guint presentation_timeout_id;
+
+ /* Preview mode */
+ GtkWidget *preview_toolbar;
+ gchar *print_settings_file;
/* Popup view */
GtkWidget *view_popup;
char *local_uri;
EvLinkDest *dest;
gboolean unlink_temp_file;
+ gboolean in_reload;
EvDocument *document;
EvHistory *history;
EvPageCache *page_cache;
EvWindowPageMode page_mode;
EvWindowTitle *title;
-#ifndef HAVE_GTK_RECENT
- EggRecentViewUIManager *recent_view;
-#endif
EvJob *load_job;
EvJob *thumbnail_job;
+ EvJob *save_job;
#ifdef WITH_GNOME_PRINT
GnomePrintJob *print_job;
#endif
#ifdef WITH_GTK_PRINT
EvJob *print_job;
+ gboolean print_preview;
GtkPrintJob *gtk_print_job;
GtkPrinter *printer;
GtkPrintSettings *print_settings;
#define GCONF_LOCKDOWN_SAVE "/desktop/gnome/lockdown/disable_save_to_disk"
#define GCONF_LOCKDOWN_PRINT "/desktop/gnome/lockdown/disable_printing"
-#define FULLSCREEN_TIMEOUT 5 * 1000
+#define PRESENTATION_TIMEOUT 5
#define SIDEBAR_DEFAULT_SIZE 132
#define LINKS_SIDEBAR_ID "links"
#define THUMBNAILS_SIDEBAR_ID "thumbnails"
#define ATTACHMENTS_SIDEBAR_ID "attachments"
-static void ev_window_update_actions (EvWindow *ev_window);
-static void ev_window_update_fullscreen_popup (EvWindow *window);
+#ifdef WITH_GTK_PRINT
+static const gchar *document_print_settings[] = {
+ GTK_PRINT_SETTINGS_N_COPIES,
+ GTK_PRINT_SETTINGS_COLLATE,
+ GTK_PRINT_SETTINGS_REVERSE,
+ GTK_PRINT_SETTINGS_NUMBER_UP,
+ GTK_PRINT_SETTINGS_SCALE,
+ GTK_PRINT_SETTINGS_PRINT_PAGES,
+ GTK_PRINT_SETTINGS_PAGE_RANGES,
+ GTK_PRINT_SETTINGS_PAGE_SET
+};
+#endif /* WITH_GTK_PRINT */
+
+static void ev_window_update_actions (EvWindow *ev_window);
static void ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar,
GParamSpec *pspec,
EvWindow *ev_window);
static void ev_window_print_job_cb (EvJobPrint *job,
EvWindow *window);
#endif
+static void ev_window_save_job_cb (EvJobSave *save,
+ EvWindow *window);
static void ev_window_sizing_mode_changed_cb (EvView *view,
GParamSpec *pspec,
EvWindow *ev_window);
static void ev_view_popup_cmd_copy_image (GtkAction *action,
EvWindow *window);
static void ev_attachment_popup_cmd_open_attachment (GtkAction *action,
- EvWindow *window);
-static void ev_attachment_popup_cmd_save_attachment_as (GtkAction *action,
- EvWindow *window);
+ EvWindow *window);
+static void ev_attachment_popup_cmd_save_attachment_as (GtkAction *action,
+ EvWindow *window);
static void ev_window_cmd_view_best_fit (GtkAction *action,
EvWindow *ev_window);
static void ev_window_cmd_view_page_width (GtkAction *action,
EvWindow *ev_window);
-static void fullscreen_set_timeout (EvWindow *window);
-static gboolean fullscreen_motion_notify_cb (GtkWidget *widget,
- GdkEventMotion *event,
- gpointer user_data);
-static gboolean fullscreen_leave_notify_cb (GtkWidget *widget,
- GdkEventCrossing *event,
- gpointer user_data);
-static void view_handle_link_cb (EvView *view,
- EvLink *link,
- EvWindow *window);
+static void view_handle_link_cb (EvView *view,
+ EvLink *link,
+ EvWindow *window);
+static void ev_window_cmd_edit_find (GtkAction *action,
+ EvWindow *ev_window);
+static void find_bar_search_changed_cb (EggFindBar *find_bar,
+ GParamSpec *param,
+ EvWindow *ev_window);
G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
-static gdouble
-ev_window_get_screen_dpi (EvWindow *ev_window)
-{
- GdkScreen *screen;
- gdouble xdpi, ydpi;
-
- screen = gtk_window_get_screen (GTK_WINDOW (ev_window));
-
- xdpi = 25.4 * gdk_screen_get_width (screen) / gdk_screen_get_width_mm (screen);
- ydpi = 25.4 * gdk_screen_get_height (screen) / gdk_screen_get_height_mm (screen);
-
- return (xdpi + ydpi) / 2.0;
-}
-
static void
ev_window_set_action_sensitive (EvWindow *ev_window,
const char *name,
has_properties = FALSE;
}
- if (has_document && ev_document_can_get_text (document)) {
+ if (has_document && EV_IS_SELECTION (document)) {
can_get_text = TRUE;
}
/* Toolbar-specific actions: */
ev_window_set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
ev_window_set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
- ev_window_set_action_sensitive (ev_window, NAVIGATION_ACTION, has_pages);
+ ev_window_set_action_sensitive (ev_window, NAVIGATION_ACTION, FALSE);
+ ev_window_set_action_sensitive (ev_window, "PreviewPrint", has_pages && ok_to_print);
ev_window_update_actions (ev_window);
}
ZOOM_CONTROL_ACTION);
real_zoom = ev_view_get_zoom (EV_VIEW (ev_window->priv->view));
- real_zoom *= 72.0 / ev_window_get_screen_dpi (ev_window);
+ real_zoom *= 72.0 / get_screen_dpi (GTK_WINDOW (ev_window));
zoom = ephy_zoom_get_nearest_zoom_level (real_zoom);
ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action), zoom);
fullscreen_toolbar = ((priv->chrome & EV_CHROME_FULLSCREEN_TOOLBAR) != 0 ||
(priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && fullscreen;
findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
- sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !fullscreen_mode;
+ sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !presentation;
preview_toolbar = (priv->chrome& EV_CHROME_PREVIEW_TOOLBAR);
set_widget_visibility (priv->menubar, menubar);
- set_widget_visibility (priv->toolbar_dock, toolbar);
+ set_widget_visibility (priv->toolbar, toolbar);
set_widget_visibility (priv->find_bar, findbar);
set_widget_visibility (priv->sidebar, sidebar);
- set_widget_visibility (priv->preview_toolbar, preview_toolbar);
+
+ if (priv->preview_toolbar)
+ set_widget_visibility (priv->preview_toolbar, preview_toolbar);
ev_window_set_action_sensitive (window, "EditToolbar", toolbar);
gtk_widget_set_sensitive (priv->menubar, menubar);
- if (priv->fullscreen_popup != NULL) {
+ if (priv->fullscreen_toolbar != NULL) {
set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar);
- set_widget_visibility (priv->fullscreen_popup, fullscreen_toolbar);
}
}
} else {
priv->chrome &= ~flag;
}
-
- update_chrome_visibility (window);
}
static void
}
static void
-ev_window_error_dialog_response_cb (GtkWidget *dialog,
- gint response_id,
- EvWindow *ev_window)
+ev_window_set_message_area (EvWindow *window,
+ GtkWidget *area)
+{
+ if (window->priv->message_area == area)
+ return;
+
+ if (window->priv->message_area)
+ gtk_widget_destroy (window->priv->message_area);
+ window->priv->message_area = area;
+
+ if (!area)
+ return;
+
+ gtk_box_pack_start (GTK_BOX (window->priv->view_box),
+ window->priv->message_area,
+ FALSE, FALSE, 0);
+ gtk_box_reorder_child (GTK_BOX (window->priv->view_box),
+ window->priv->message_area, 0);
+ g_object_add_weak_pointer (G_OBJECT (window->priv->message_area),
+ (gpointer) &(window->priv->message_area));
+}
+
+static void
+ev_window_error_message_response_cb (EvMessageArea *area,
+ gint response_id,
+ EvWindow *window)
{
- gtk_widget_destroy (dialog);
+ ev_window_set_message_area (window, NULL);
}
static void
-ev_window_error_dialog (GtkWindow *window, const gchar *msg, GError *error)
+ev_window_error_message (GtkWindow *window, const gchar *msg, GError *error)
{
- GtkWidget *dialog;
+ GtkWidget *area;
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- msg);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s", error->message);
- g_signal_connect (dialog, "response",
- G_CALLBACK (ev_window_error_dialog_response_cb),
- window);
- gtk_widget_show (dialog);
+ if (EV_WINDOW (window)->priv->message_area)
+ return;
+
+ area = ev_message_area_new (GTK_MESSAGE_ERROR,
+ msg,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CANCEL,
+ NULL);
+ ev_message_area_set_secondary_text (EV_MESSAGE_AREA (area), error->message);
+ g_signal_connect (area, "response",
+ G_CALLBACK (ev_window_error_message_response_cb),
+ window);
+ gtk_widget_show (area);
+ ev_window_set_message_area (EV_WINDOW (window), area);
}
static void
EvLinkAction *action;
EvLinkDest *dest;
+ if (window->priv->history == NULL)
+ return;
+
+ if (!EV_IS_DOCUMENT_LINKS (window->priv->document))
+ return;
+
if (link) {
action = g_object_ref (ev_link_get_action (link));
dest = ev_link_action_get_dest (action);
find_task.page_label = page_label;
find_task.chapter = NULL;
- if (EV_IS_DOCUMENT_LINKS (window->priv->document) &&
- ev_document_links_has_document_links (EV_DOCUMENT_LINKS (window->priv->document))) {
+ if (ev_document_links_has_document_links (EV_DOCUMENT_LINKS (window->priv->document))) {
GtkTreeModel *model;
g_object_get (G_OBJECT (window->priv->sidebar_links), "model", &model, NULL);
if (uri && ev_metadata_manager_get (uri, "page", &page, TRUE)) {
n_pages = ev_page_cache_get_n_pages (window->priv->page_cache);
new_page = CLAMP (g_value_get_int (&page), 0, n_pages - 1);
- if (new_page == n_pages - 1)
+ if (!window->priv->in_reload && new_page == n_pages - 1)
new_page = 0;
ev_page_cache_set_current_page (window->priv->page_cache,
new_page);
} else if (strcmp (page_id, THUMBNAILS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
} else if (strcmp (page_id, ATTACHMENTS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) {
- ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), attachments);
}
g_value_unset (&sidebar_page);
} else if (document && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
if (ev_metadata_manager_get (uri, "sidebar_visibility", &sidebar_visibility, FALSE)) {
update_chrome_flag (window, EV_CHROME_SIDEBAR, g_value_get_boolean (&sidebar_visibility));
g_value_unset (&sidebar_visibility);
+ update_chrome_visibility (window);
}
}
gdouble zoom_value;
zoom_value = g_value_get_double (&zoom);
- zoom_value *= ev_window_get_screen_dpi (window) / 72.0;
+ zoom_value *= get_screen_dpi (GTK_WINDOW (window)) / 72.0;
ev_view_set_zoom (view, zoom_value, FALSE);
g_value_unset (&zoom);
}
}
static void
+ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation)
+{
+
+ EvRenderContext *rc;
+ gint page_width, page_height;
+ gdouble scale;
+ EvDocument *document = ev_window->priv->document;
+
+ if (!EV_IS_DOCUMENT_THUMBNAILS (document)) {
+ return;
+ }
+
+ ev_window_clear_thumbnail_job (ev_window);
+
+ ev_page_cache_get_size (ev_window->priv->page_cache,
+ 0, 0, 1.0,
+ &page_width, &page_height);
+ scale = (gdouble)128 / (gdouble)page_width;
+
+ rc = ev_render_context_new (rotation, 0, scale);
+
+ ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, rc);
+ g_signal_connect (ev_window->priv->thumbnail_job, "finished",
+ G_CALLBACK (ev_window_set_icon_from_thumbnail),
+ ev_window);
+ ev_job_queue_add_job (EV_JOB (ev_window->priv->thumbnail_job), EV_JOB_PRIORITY_LOW);
+ g_object_unref (rc);
+}
+
+static gboolean
ev_window_setup_document (EvWindow *ev_window)
{
const EvDocumentInfo *info;
- EvDocument *document;
- EvView *view = EV_VIEW (ev_window->priv->view);
+ EvDocument *document = ev_window->priv->document;
EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
GtkAction *action;
-
- document = 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 (ev_window->priv->page_cache, "history-changed",
- G_CALLBACK (history_changed_cb), ev_window);
-
+
if (EV_IS_DOCUMENT_FIND (document)) {
g_signal_connect_object (G_OBJECT (document),
"find_changed",
G_CALLBACK (find_changed_cb),
ev_window, 0);
}
+
+ ev_window_refresh_window_thumbnail (ev_window, 0);
- if (EV_IS_DOCUMENT_THUMBNAILS (document)) {
- EvRenderContext *rc;
- gint page_width, page_height;
- gdouble scale;
-
- ev_window_clear_thumbnail_job (ev_window);
-
- ev_page_cache_get_size (ev_window->priv->page_cache,
- 0, 0, 1.0,
- &page_width, &page_height);
- scale = (gdouble)128 / (gdouble)page_width;
-
- rc = ev_render_context_new (0, 0, scale);
- ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, rc);
- g_signal_connect (ev_window->priv->thumbnail_job, "finished",
- G_CALLBACK (ev_window_set_icon_from_thumbnail),
- ev_window);
- ev_job_queue_add_job (EV_JOB (ev_window->priv->thumbnail_job), EV_JOB_PRIORITY_LOW);
- g_object_unref (rc);
- }
-
- ev_sidebar_set_document (sidebar, document);
-
- if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
- ev_view_set_document (view, document);
- }
ev_window_set_page_mode (ev_window, PAGE_MODE_DOCUMENT);
-
ev_window_title_set_document (ev_window->priv->title, document);
ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri);
+ ev_sidebar_set_document (sidebar, document);
+
action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
ev_page_action_set_document (EV_PAGE_ACTION (action), document);
ev_window_setup_action_sensitivity (ev_window);
ev_window->priv->document);
}
+ info = ev_page_cache_get_info (ev_window->priv->page_cache);
+ update_document_mode (ev_window, info->mode);
+
+ return FALSE;
+}
+
+static void
+ev_window_set_document (EvWindow *ev_window, EvDocument *document)
+{
+ EvView *view = EV_VIEW (ev_window->priv->view);
+
+ if (ev_window->priv->document)
+ g_object_unref (ev_window->priv->document);
+ ev_window->priv->document = g_object_ref (document);
+
+ ev_window_set_message_area (ev_window, NULL);
+
+ 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 (ev_window->priv->page_cache, "history-changed",
+ G_CALLBACK (history_changed_cb), ev_window);
+
setup_size_from_metadata (ev_window);
- setup_document_from_metadata (ev_window);
setup_sidebar_from_metadata (ev_window, document);
+ setup_document_from_metadata (ev_window);
- info = ev_page_cache_get_info (ev_window->priv->page_cache);
- update_document_mode (ev_window, info->mode);
+ if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
+ ev_view_set_document (view, document);
+ }
+
+ g_idle_add ((GSourceFunc)ev_window_setup_document, ev_window);
}
static void
static void
ev_window_clear_load_job (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->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;
+ }
}
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) {
- g_unlink (filename);
- g_free (filename);
- }
- g_free (ev_window->priv->local_uri);
- ev_window->priv->local_uri = NULL;
- }
+ if (ev_window->priv->local_uri) {
+ ev_tmp_uri_unlink (ev_window->priv->local_uri);
+ g_free (ev_window->priv->local_uri);
+ ev_window->priv->local_uri = NULL;
+ }
+}
+
+static void
+ev_window_clear_print_settings_file (EvWindow *ev_window)
+{
+ if (ev_window->priv->print_settings_file) {
+ g_unlink (ev_window->priv->print_settings_file);
+ g_free (ev_window->priv->print_settings_file);
+ ev_window->priv->print_settings_file = NULL;
+ }
}
static void
/* Success! */
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_set_document (ev_window, document);
+
if (job->mode != EV_WINDOW_MODE_PREVIEW) {
setup_view_from_metadata (ev_window);
}
ev_window_add_recent (ev_window, ev_window->priv->uri);
}
- ev_window_setup_document (ev_window);
-
if (job->dest) {
EvLink *link;
EvLinkAction *link_action;
break;
}
- ev_window_clear_load_job (ev_window);
+ /* Restart the search after reloading */
+ if (ev_window->priv->in_reload) {
+ GtkWidget *widget;
+
+ widget = gtk_window_get_focus (GTK_WINDOW (ev_window));
+ if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
+ find_bar_search_changed_cb (EGG_FIND_BAR (ev_window->priv->find_bar),
+ NULL, ev_window);
+ }
+ } else if (job->search_string && EV_IS_DOCUMENT_FIND (document)) {
+ ev_window_cmd_edit_find (NULL, ev_window);
+ egg_find_bar_set_search_string (EGG_FIND_BAR (ev_window->priv->find_bar),
+ job->search_string);
+ }
+
+ ev_window_clear_load_job (ev_window);
+ ev_window->priv->in_reload = FALSE;
return;
}
ev_window_popup_password_dialog (ev_window);
} else {
- ev_window_error_dialog (GTK_WINDOW (ev_window),
- _("Unable to open document"),
- job->error);
+ ev_window_error_message (GTK_WINDOW (ev_window),
+ _("Unable to open document"),
+ job->error);
ev_window_clear_load_job (ev_window);
+ ev_window->priv->in_reload = FALSE;
}
return;
}
static gint
-xfer_update_progress_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSXferProgressInfo *info,
- EvWindow *ev_window)
+open_xfer_update_progress_callback (GnomeVFSAsyncHandle *handle,
+ GnomeVFSXferProgressInfo *info,
+ EvWindow *ev_window)
{
switch (info->status) {
case GNOME_VFS_XFER_PROGRESS_STATUS_OK:
const char *uri,
EvLinkDest *dest,
EvWindowRunMode mode,
- gboolean unlink_temp_file)
+ const gchar *search_string,
+ gboolean unlink_temp_file,
+ const gchar *print_settings)
{
GnomeVFSURI *source_uri;
GnomeVFSURI *target_uri;
+
+ if (ev_window->priv->uri &&
+ g_ascii_strcasecmp (ev_window->priv->uri, uri) == 0) {
+ ev_window->priv->in_reload = TRUE;
+ }
ev_window_close_dialogs (ev_window);
ev_window_clear_load_job (ev_window);
ev_window_clear_local_uri (ev_window);
+ ev_window_clear_print_settings_file (ev_window);
ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE);
ev_window->priv->unlink_temp_file = unlink_temp_file;
+ if (mode == EV_WINDOW_MODE_PREVIEW) {
+ ev_window->priv->print_settings_file = print_settings ?
+ g_strdup (print_settings) : NULL;
+ }
+
if (ev_window->priv->uri)
g_free (ev_window->priv->uri);
ev_window->priv->uri = g_strdup (uri);
setup_size_from_metadata (ev_window);
- ev_window->priv->load_job = ev_job_load_new (uri, dest, mode);
+ ev_window->priv->load_job = ev_job_load_new (uri, dest, mode, search_string);
g_signal_connect (ev_window->priv->load_job,
"finished",
G_CALLBACK (ev_window_load_job_cb),
GNOME_VFS_XFER_ERROR_MODE_ABORT,
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
GNOME_VFS_PRIORITY_DEFAULT,
- (GnomeVFSAsyncXferProgressCallback)xfer_update_progress_callback,
+ (GnomeVFSAsyncXferProgressCallback)
+ open_xfer_update_progress_callback,
ev_window,
NULL, NULL);
gint response_id,
EvWindow *ev_window)
{
+ gchar *uri;
+
if (response_id == GTK_RESPONSE_OK) {
GSList *uris;
g_slist_foreach (uris, (GFunc)g_free, NULL);
g_slist_free (uris);
}
- ev_application_set_chooser_uri (EV_APP,
- gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser)));
+
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser));
+ ev_application_set_chooser_uri (EV_APP, uri);
+ g_free (uri);
gtk_widget_destroy (chooser);
}
} else if (window->priv->uri != NULL) {
gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (chooser),
window->priv->uri);
- }
- else {
+ } else {
+#if GLIB_CHECK_VERSION (2, 13, 3)
+ const gchar *folder;
+
+ folder = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser),
+ folder ? folder : g_get_home_dir ());
+#else
char *folder;
+
folder = xdg_user_dir_lookup ("DOCUMENTS");
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser),
folder);
free (folder);
+#endif
}
g_signal_connect (chooser, "response",
new_filename = ev_window_create_tmp_symlink (old_filename, &error);
if (error) {
- ev_window_error_dialog (GTK_WINDOW (window),
- _("Cannot open a copy."),
- error);
+ ev_window_error_message (GTK_WINDOW (window),
+ _("Cannot open a copy."),
+ error);
g_error_free (error);
g_free (old_filename);
gtk_window_get_screen (GTK_WINDOW (window)),
dest,
0,
+ NULL,
TRUE,
+ NULL,
GDK_CURRENT_TIME);
g_free (symlink_uri);
}
g_object_unref (dest);
}
-#ifdef HAVE_GTK_RECENT
static void
-ev_window_cmd_recent_file_activate (GtkAction *action,
- EvWindow *window)
+ev_window_cmd_recent_file_activate (GtkAction *action,
+ EvWindow *window)
{
GtkRecentInfo *info;
const gchar *uri;
ev_application_open_uri_at_dest (EV_APP, uri,
gtk_window_get_screen (GTK_WINDOW (window)),
- NULL, 0, FALSE,
+ NULL, 0, NULL, FALSE, NULL,
GDK_CURRENT_TIME);
}
-#else
+
static void
-ev_window_cmd_recent_file_activate (GtkAction *action,
- EvWindow *ev_window)
+ev_window_open_recent_action_item_activated (EvOpenRecentAction *action,
+ const gchar *uri,
+ EvWindow *window)
{
- char *uri;
- EggRecentItem *item;
-
- item = egg_recent_view_uimanager_get_item (ev_window->priv->recent_view,
- action);
-
- uri = egg_recent_item_get_uri (item);
-
- ev_application_open_uri (EV_APP, uri, NULL,
- GDK_CURRENT_TIME, NULL);
-
- g_free (uri);
+ ev_application_open_uri_at_dest (EV_APP, uri,
+ gtk_window_get_screen (GTK_WINDOW (window)),
+ NULL, 0, NULL, FALSE, NULL,
+ GDK_CURRENT_TIME);
}
-#endif /* HAVE_GTK_RECENT */
static void
ev_window_add_recent (EvWindow *window, const char *filename)
{
-#ifdef HAVE_GTK_RECENT
gtk_recent_manager_add_item (window->priv->recent_manager, filename);
-#else
- EggRecentItem *item;
-
- item = egg_recent_item_new_from_uri (filename);
- egg_recent_item_add_group (item, "Evince");
- egg_recent_model_add_full (ev_application_get_recent_model (EV_APP), item);
-#endif /* HAVE_GTK_RECENT */
}
-#ifdef HAVE_GTK_RECENT
static gint
compare_recent_items (GtkRecentInfo *a, GtkRecentInfo *b)
{
return 0;
}
-#endif /* HAVE_GTK_RECENT */
/*
* Doubles underscore to avoid spurious menu accels.
static void
ev_window_setup_recent (EvWindow *ev_window)
{
-#ifdef HAVE_GTK_RECENT
GList *items, *l;
guint n_items = 0;
const gchar *evince = g_get_application_name ();
g_list_foreach (items, (GFunc) gtk_recent_info_unref, NULL);
g_list_free (items);
-#else /* HAVE_GTK_RECENT */
- 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);
+}
+
+static gint
+save_xfer_update_progress_callback (GnomeVFSAsyncHandle *handle,
+ GnomeVFSXferProgressInfo *info,
+ GnomeVFSURI *tmp_uri)
+{
+ switch (info->status) {
+ case GNOME_VFS_XFER_PROGRESS_STATUS_OK:
+ if (info->phase == GNOME_VFS_XFER_PHASE_COMPLETED) {
+ gchar *uri;
- egg_recent_view_uimanager_show_icons (EGG_RECENT_VIEW_UIMANAGER (ev_window->priv->recent_view), FALSE);
+ uri = gnome_vfs_uri_to_string (tmp_uri, 0);
+ ev_tmp_uri_unlink (uri);
+ g_free (uri);
+ gnome_vfs_uri_unref (tmp_uri);
+ }
+ return 1;
+ case GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR:
+ if (info->vfs_status != GNOME_VFS_OK) {
+ GtkWidget *dialog;
+ gchar *uri;
+
+ dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("The file could not be saved as ā%sā."),
+ info->target_name);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ gnome_vfs_result_to_string (info->vfs_status));
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy),
+ NULL);
+ gtk_widget_show (dialog);
+
+ uri = gnome_vfs_uri_to_string (tmp_uri, 0);
+ ev_tmp_uri_unlink (uri);
+ g_free (uri);
+ gnome_vfs_uri_unref (tmp_uri);
+ }
+ return 1;
+ case GNOME_VFS_XFER_PROGRESS_STATUS_OVERWRITE:
+ case GNOME_VFS_XFER_PROGRESS_STATUS_DUPLICATE:
+ return 1;
+ default:
+ g_assert_not_reached ();
+ }
- egg_recent_view_set_model (EGG_RECENT_VIEW (ev_window->priv->recent_view),
- ev_application_get_recent_model (EV_APP));
+ return 0;
+}
- egg_recent_view_uimanager_set_trailing_sep (ev_window->priv->recent_view, TRUE);
+static void
+ev_window_save_remote (EvWindow *ev_window,
+ GnomeVFSURI *src,
+ GnomeVFSURI *dst)
+{
+ GnomeVFSAsyncHandle *handle;
+ GList *slist = NULL;
+ GList *tlist = NULL;
- g_signal_connect (ev_window->priv->recent_view, "activate",
- G_CALLBACK (ev_window_cmd_recent_file_activate), ev_window);
-#endif /* HAVE_GTK_RECENT */
+ slist = g_list_prepend (slist, src);
+ tlist = g_list_prepend (tlist, dst);
+ gnome_vfs_async_xfer (&handle, slist, tlist,
+ GNOME_VFS_XFER_DEFAULT | GNOME_VFS_XFER_FOLLOW_LINKS,
+ GNOME_VFS_XFER_ERROR_MODE_ABORT,
+ GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
+ GNOME_VFS_PRIORITY_DEFAULT,
+ (GnomeVFSAsyncXferProgressCallback)
+ save_xfer_update_progress_callback,
+ gnome_vfs_uri_ref (src),
+ NULL, NULL);
+ g_list_free (slist);
+ g_list_free (tlist);
+}
+
+static void
+ev_window_clear_save_job (EvWindow *ev_window)
+{
+ if (ev_window->priv->save_job != NULL) {
+ if (!ev_window->priv->save_job->finished)
+ ev_job_queue_remove_job (ev_window->priv->save_job);
+
+ g_signal_handlers_disconnect_by_func (ev_window->priv->save_job,
+ ev_window_save_job_cb,
+ ev_window);
+ g_object_unref (ev_window->priv->save_job);
+ ev_window->priv->save_job = NULL;
+ }
+}
+
+static void
+ev_window_save_job_cb (EvJobSave *job,
+ EvWindow *window)
+{
+ if (job->error) {
+ gchar *msg;
+
+ msg = g_strdup_printf (_("The file could not be saved as ā%sā."), job->uri);
+ ev_window_error_message (GTK_WINDOW (window), msg, job->error);
+ g_free (msg);
+ }
+
+ ev_window_clear_save_job (window);
}
static void
gint response_id,
EvWindow *ev_window)
{
- const gchar *uri_unc;
- gint fd;
- gchar *filename;
- gchar *tmp_filename;
- GError *error = NULL;
-
+ gchar *uri;
+
if (response_id != GTK_RESPONSE_OK) {
gtk_widget_destroy (fc);
return;
}
-
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fc));
- tmp_filename = g_strdup_printf ("%s.XXXXXX", filename);
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
- fd = g_mkstemp (tmp_filename);
- if (fd == -1) {
- gchar *display_name;
- gint save_errno = errno;
-
- display_name = g_filename_display_name (tmp_filename);
- g_set_error (&error,
- G_FILE_ERROR,
- g_file_error_from_errno (save_errno),
- _("Failed to create file ā%sā: %s"),
- display_name, g_strerror (save_errno));
- g_free (display_name);
- } else {
- gchar *uri;
-
- uri = g_filename_to_uri (tmp_filename, NULL, NULL);
-
- ev_document_doc_mutex_lock ();
- ev_document_save (ev_window->priv->document, uri, &error);
- ev_document_doc_mutex_unlock ();
-
- g_free (uri);
- close (fd);
- }
-
- if (!error) {
- uri_unc = g_object_get_data (G_OBJECT (ev_window->priv->document),
- "uri-uncompressed");
- if (uri_unc) {
- EvCompressionType ctype;
- gchar *uri_comp;
- gchar *uri;
- const gchar *ext;
-
- ctype = EV_COMPRESSION_NONE;
-
- ext = g_strrstr (ev_window->priv->uri, ".gz");
- if (ext && g_ascii_strcasecmp (ext, ".gz") == 0)
- ctype = EV_COMPRESSION_GZIP;
-
- ext = g_strrstr (ev_window->priv->uri, ".bz2");
- if (ext && g_ascii_strcasecmp (ext, ".bz2") == 0)
- ctype = EV_COMPRESSION_BZIP2;
-
- uri = g_filename_to_uri (tmp_filename, NULL, NULL);
- uri_comp = ev_file_compress (uri, ctype, &error);
- g_free (uri);
- g_unlink (tmp_filename);
- g_free (tmp_filename);
-
- if (!uri_comp || error) {
- tmp_filename = NULL;
- } else {
- tmp_filename = g_filename_from_uri (uri_comp,
- NULL, NULL);
- }
-
- g_free (uri_comp);
- }
- }
+ ev_window_clear_save_job (ev_window);
+ ev_window->priv->save_job = ev_job_save_new (ev_window->priv->document,
+ uri, ev_window->priv->uri);
+ g_signal_connect (ev_window->priv->save_job, "finished",
+ G_CALLBACK (ev_window_save_job_cb),
+ ev_window);
+ /* The priority doesn't matter for this job */
+ ev_job_queue_add_job (ev_window->priv->save_job, EV_JOB_PRIORITY_LOW);
- if (tmp_filename && g_rename (tmp_filename, filename) == -1) {
- g_unlink (tmp_filename);
- }
-
- if (error) {
- gchar *msg;
- gchar *uri;
-
- uri = g_filename_to_uri (filename, NULL, NULL);
- msg = g_strdup_printf (_("The file could not be saved as ā%sā."), uri);
- ev_window_error_dialog (GTK_WINDOW (ev_window), msg, error);
- g_free (msg);
- g_free (uri);
- g_error_free (error);
- }
-
- g_free (tmp_filename);
- g_free (filename);
+ g_free (uri);
gtk_widget_destroy (fc);
}
GtkWidget *fc;
gchar *base_name;
gchar *file_name;
+#if GLIB_CHECK_VERSION (2, 13, 3)
+ const gchar *folder;
+#else
gchar *folder;
+#endif
fc = gtk_file_chooser_dialog_new (
_("Save a Copy"),
ev_document_factory_add_filters (fc, ev_window->priv->document);
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
- gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER (fc), TRUE);
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fc), FALSE);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE);
file_name = gnome_vfs_format_uri_for_display (ev_window->priv->uri);
base_name = g_path_get_basename (file_name);
- folder = xdg_user_dir_lookup ("DOCUMENTS");
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc), base_name);
+
+#if GLIB_CHECK_VERSION (2, 13, 3)
+ folder = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fc),
+ folder ? folder : g_get_home_dir ());
+#else
+ folder = xdg_user_dir_lookup ("DOCUMENTS");
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fc), folder);
+ free (folder);
+#endif
+
g_free (file_name);
g_free (base_name);
- free (folder);
g_signal_connect (fc, "response",
G_CALLBACK (file_save_dialog_response_cb),
g_object_unref (window->priv->print_job);
window->priv->print_job = NULL;
}
-}
+
+ if (window->priv->gtk_print_job) {
+ g_object_unref (window->priv->gtk_print_job);
+ window->priv->gtk_print_job = NULL;
+ }
+}
+
+static void
+ev_window_load_print_settings_from_metadata (EvWindow *window)
+{
+ gchar *uri = window->priv->uri;
+ gint i;
+
+ /* Load print setting that are specific to the document */
+ for (i = 0; i < G_N_ELEMENTS (document_print_settings); i++) {
+ GValue value = { 0, };
+ gboolean success;
+
+ success = ev_metadata_manager_get (uri, document_print_settings[i], &value, TRUE);
+ gtk_print_settings_set (window->priv->print_settings,
+ document_print_settings[i],
+ success ? g_value_get_string (&value) : NULL);
+ }
+}
+
+static void
+ev_window_save_print_settings (EvWindow *window)
+{
+ gchar *uri = window->priv->uri;
+ gint i;
+
+ /* Save print settings that are specific to the document */
+ for (i = 0; i < G_N_ELEMENTS (document_print_settings); i++) {
+ const gchar *value;
+
+ value = gtk_print_settings_get (window->priv->print_settings,
+ document_print_settings[i]);
+ ev_metadata_manager_set_string (uri, document_print_settings[i], value);
+ }
+}
static void
ev_window_print_finished (GtkPrintJob *print_job,
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
+ } else {
+ /* If printed successfully, save print settings */
+ ev_application_set_print_settings (EV_APP,
+ window->priv->print_settings);
+ ev_window_save_print_settings (window);
}
}
ev_window_print_send (EvWindow *window,
const gchar *filename)
{
- GtkPrintJob *job;
GtkPrintSettings *settings;
- GError *error = NULL;
+ EvFileExporterCapabilities capabilities;
- if (window->priv->gtk_print_job)
- g_object_unref (window->priv->gtk_print_job);
-
/* Some printers take into account some print settings,
* and others don't. However we have exported the document
* to a ps or pdf file according to such print settings. So,
* settings set to default values.
*/
settings = gtk_print_settings_copy (window->priv->print_settings);
- gtk_print_settings_set_n_copies (settings, 1);
+ capabilities = ev_file_exporter_get_capabilities (EV_FILE_EXPORTER (window->priv->document));
+
gtk_print_settings_set_page_ranges (settings, NULL, 0);
- gtk_print_settings_set_page_set (settings, GTK_PAGE_SET_ALL);
gtk_print_settings_set_print_pages (settings, GTK_PRINT_PAGES_ALL);
- gtk_print_settings_set_scale (settings, 1.0);
- gtk_print_settings_set_collate (settings, FALSE);
- gtk_print_settings_set_reverse (settings, FALSE);
-
- job = gtk_print_job_new ("evince-print",
- window->priv->printer,
- settings,
- window->priv->print_page_setup);
-
- g_object_unref (settings);
+ if (capabilities & EV_FILE_EXPORTER_CAN_COPIES)
+ gtk_print_settings_set_n_copies (settings, 1);
+ if (capabilities & EV_FILE_EXPORTER_CAN_PAGE_SET)
+ gtk_print_settings_set_page_set (settings, GTK_PAGE_SET_ALL);
+ if (capabilities & EV_FILE_EXPORTER_CAN_SCALE)
+ gtk_print_settings_set_scale (settings, 1.0);
+ if (capabilities & EV_FILE_EXPORTER_CAN_COLLATE)
+ gtk_print_settings_set_collate (settings, FALSE);
+ if (capabilities & EV_FILE_EXPORTER_CAN_REVERSE)
+ gtk_print_settings_set_reverse (settings, FALSE);
+ if (capabilities & EV_FILE_EXPORTER_CAN_NUMBER_UP) {
+ gtk_print_settings_set_number_up (settings, 1);
+ gtk_print_settings_set_int (settings, "cups-"GTK_PRINT_SETTINGS_NUMBER_UP, 1);
+ }
- window->priv->gtk_print_job = job;
+ if (window->priv->print_preview) {
+ gchar *uri;
+ gchar *print_settings_file = NULL;
- if (gtk_print_job_set_source_file (job, filename, &error)) {
- gtk_print_job_send (job,
- (GtkPrintJobCompleteFunc)ev_window_print_finished,
- window, NULL);
+ ev_application_set_print_settings (EV_APP,
+ window->priv->print_settings);
+
+#if GTK_CHECK_VERSION (2, 11, 0)
+ print_settings_file = ev_tmp_filename ("print-settings");
+ gtk_print_settings_to_file (settings, print_settings_file, NULL);
+#endif
+ uri = g_filename_to_uri (filename, NULL, NULL);
+ ev_application_open_uri_at_dest (EV_APP,
+ uri,
+ gtk_window_get_screen (GTK_WINDOW (window)),
+ NULL,
+ EV_WINDOW_MODE_PREVIEW,
+ NULL,
+ TRUE,
+ print_settings_file,
+ GDK_CURRENT_TIME);
+ g_free (print_settings_file);
+ g_free (uri);
} else {
- ev_window_clear_print_job (window);
- g_warning (error->message);
- g_error_free (error);
+ GtkPrintJob *job;
+ GError *error = NULL;
+
+ job = gtk_print_job_new ("evince-print",
+ window->priv->printer,
+ settings,
+ window->priv->print_page_setup);
+
+ if (window->priv->gtk_print_job)
+ g_object_unref (window->priv->gtk_print_job);
+ window->priv->gtk_print_job = job;
+
+ if (gtk_print_job_set_source_file (job, filename, &error)) {
+ gtk_print_job_send (job,
+ (GtkPrintJobCompleteFunc)ev_window_print_finished,
+ window, NULL);
+ } else {
+ ev_window_clear_print_job (window);
+ g_warning (error->message);
+ g_error_free (error);
+ }
}
+
+ g_object_unref (settings);
}
static void
EvPrintPageSet page_set;
gint n_ranges = 0;
gint copies;
+ gint pages_per_sheet;
gboolean collate;
gboolean reverse;
gdouble scale;
GtkPrintPages print_pages;
const gchar *file_format;
- if (response != GTK_RESPONSE_OK) {
+ if (response == GTK_RESPONSE_CANCEL) {
gtk_widget_destroy (GTK_WIDGET (dialog));
window->priv->print_dialog = NULL;
return FALSE;
}
+ window->priv->print_preview = (response == GTK_RESPONSE_APPLY);
+
if (window->priv->printer)
g_object_unref (window->priv->printer);
if (window->priv->print_settings)
ranges = g_memdup (page_range, n_ranges * sizeof (GtkPageRange));
}
break;
- default:
+ case GTK_PRINT_PAGES_ALL: {
+ gint n_pages;
+
+ n_pages = ev_page_cache_get_n_pages (ev_page_cache_get (window->priv->document));
+
+ ranges = g_new0 (EvPrintRange, 1);
+
+ ranges->start = 0;
+ ranges->end = n_pages - 1;
+ n_ranges = 1;
+ }
break;
}
scale = gtk_print_settings_get_scale (window->priv->print_settings) * 0.01;
width = gtk_page_setup_get_paper_width (window->priv->print_page_setup,
- GTK_UNIT_PIXEL);
+ GTK_UNIT_POINTS);
height = gtk_page_setup_get_paper_height (window->priv->print_page_setup,
- GTK_UNIT_PIXEL);
-
+ GTK_UNIT_POINTS);
+
if (scale != 1.0) {
width *= scale;
height *= scale;
}
+ pages_per_sheet = gtk_print_settings_get_number_up (window->priv->print_settings);
+
copies = gtk_print_settings_get_n_copies (window->priv->print_settings);
collate = gtk_print_settings_get_collate (window->priv->print_settings);
reverse = gtk_print_settings_get_reverse (window->priv->print_settings);
width, height,
ranges, n_ranges,
page_set,
+ pages_per_sheet,
copies, collate,
reverse);
current_page = ev_page_cache_get_current_page (page_cache);
document_last_page = ev_page_cache_get_n_pages (page_cache);
- if (!ev_window->priv->print_settings)
- ev_window->priv->print_settings = gtk_print_settings_new ();
+ if (!ev_window->priv->print_settings) {
+ ev_window->priv->print_settings = gtk_print_settings_copy (
+ ev_application_get_print_settings (EV_APP));
+ ev_window_load_print_settings_from_metadata (ev_window);
+ }
if (first_page != 1 || last_page != document_last_page) {
GtkPageRange range;
dialog = gtk_print_unix_dialog_new (_("Print"), GTK_WINDOW (ev_window));
ev_window->priv->print_dialog = dialog;
- capabilities = GTK_PRINT_CAPABILITY_PAGE_SET |
- GTK_PRINT_CAPABILITY_COPIES |
- GTK_PRINT_CAPABILITY_COLLATE |
- GTK_PRINT_CAPABILITY_REVERSE |
- GTK_PRINT_CAPABILITY_SCALE |
- GTK_PRINT_CAPABILITY_GENERATE_PS;
-
- if (EV_IS_FILE_EXPORTER (ev_window->priv->document) &&
- ev_file_exporter_format_supported (EV_FILE_EXPORTER (ev_window->priv->document),
- EV_FILE_FORMAT_PDF)) {
- capabilities |= GTK_PRINT_CAPABILITY_GENERATE_PDF;
- }
-
+ capabilities = GTK_PRINT_CAPABILITY_PREVIEW |
+ ev_file_exporter_get_capabilities (EV_FILE_EXPORTER (ev_window->priv->document));
gtk_print_unix_dialog_set_manual_capabilities (GTK_PRINT_UNIX_DIALOG (dialog),
capabilities);
update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, TRUE);
ev_window_set_action_sensitive (window, "ViewToolbar", FALSE);
+ update_chrome_visibility (window);
action = gtk_action_group_get_action (window->priv->action_group,
PAGE_SELECTOR_ACTION);
}
update_chrome_flag (ev_window, EV_CHROME_FINDBAR, TRUE);
+ update_chrome_visibility (ev_window);
gtk_widget_grab_focus (ev_window->priv->find_bar);
}
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
+ update_chrome_flag (ev_window, EV_CHROME_FINDBAR, TRUE);
+ update_chrome_visibility (ev_window);
+ gtk_widget_grab_focus (ev_window->priv->find_bar);
ev_view_find_next (EV_VIEW (ev_window->priv->view));
}
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
+ update_chrome_flag (ev_window, EV_CHROME_FINDBAR, TRUE);
+ update_chrome_visibility (ev_window);
+ gtk_widget_grab_focus (ev_window->priv->find_bar);
ev_view_find_previous (EV_VIEW (ev_window->priv->view));
}
ev_view_copy (EV_VIEW (ev_window->priv->view));
}
-static void
-ev_window_update_fullscreen_popup (EvWindow *window)
-{
- 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_FULLSCREEN_TOOLBAR) != 0 ||
- (window->priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0;
- popup_width = popup->requisition.width;
- popup_height = popup->requisition.height;
-
- screen = gtk_widget_get_screen (GTK_WIDGET (window));
- gdk_screen_get_monitor_geometry (screen,
- gdk_screen_get_monitor_at_window
- (screen,
- GTK_WIDGET (window)->window),
- &screen_rect);
- if (toolbar) {
- gtk_widget_set_size_request (popup,
- screen_rect.width,
- -1);
- gtk_window_move (GTK_WINDOW (popup),
- screen_rect.x,
- screen_rect.y);
-
- } else {
- if (gtk_widget_get_direction (popup) == GTK_TEXT_DIR_RTL)
- {
- gtk_window_move (GTK_WINDOW (popup),
- screen_rect.x,
- screen_rect.y);
- } else {
- gtk_window_move (GTK_WINDOW (popup),
- screen_rect.x + screen_rect.width - popup_width,
- screen_rect.y);
- }
- }
-}
-
-static void
-screen_size_changed_cb (GdkScreen *screen,
- EvWindow *window)
-{
- ev_window_update_fullscreen_popup (window);
-}
-
static void
ev_window_sidebar_position_change_cb (GObject *object, GParamSpec *pspec,
EvWindow *ev_window)
}
static void
-destroy_fullscreen_popup (EvWindow *window)
-{
- if (window->priv->fullscreen_popup != NULL)
- {
- gtk_widget_destroy (window->priv->fullscreen_popup);
- window->priv->fullscreen_popup = NULL;
- }
-}
-
-static void
-exit_fullscreen_button_clicked_cb (GtkWidget *button, EvWindow *window)
+ev_window_update_fullscreen_action (EvWindow *window)
{
GtkAction *action;
action = gtk_action_group_get_action (window->priv->action_group, "ViewFullscreen");
- g_return_if_fail (action != NULL);
-
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
+ g_signal_handlers_block_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+ ev_view_get_fullscreen (EV_VIEW (window->priv->view)));
+ g_signal_handlers_unblock_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
}
static void
-fullscreen_popup_size_request_cb (GtkWidget *popup, GtkRequisition *req, EvWindow *window)
+fullscreen_toolbar_setup_item_properties (GtkUIManager *ui_manager)
{
- ev_window_update_fullscreen_popup (window);
-}
+ GtkWidget *item;
-static gboolean
-fullscreen_timeout_cb (EvWindow *window)
-{
- EvView *view = EV_VIEW (window->priv->view);
+ item = gtk_ui_manager_get_widget (ui_manager, "/FullscreenToolbar/GoPreviousPage");
+ g_object_set (item, "is-important", FALSE, NULL);
- if (!view ||
- (!ev_view_get_fullscreen (EV_VIEW (view)) &&
- !ev_view_get_presentation (EV_VIEW (view))))
- return FALSE;
+ item = gtk_ui_manager_get_widget (ui_manager, "/FullscreenToolbar/GoNextPage");
+ g_object_set (item, "is-important", FALSE, NULL);
- update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR, FALSE);
- ev_view_hide_cursor (EV_VIEW (window->priv->view));
- window->priv->fullscreen_timeout_id = 0;
-
- return FALSE;
-}
-
-static void
-fullscreen_set_timeout (EvWindow *window)
-{
- if (window->priv->fullscreen_timeout_id != 0) {
- g_source_remove (window->priv->fullscreen_timeout_id);
- }
+ item = gtk_ui_manager_get_widget (ui_manager, "/FullscreenToolbar/StartPresentation");
+ g_object_set (item, "is-important", TRUE, NULL);
- window->priv->fullscreen_timeout_id =
- g_timeout_add (FULLSCREEN_TIMEOUT, (GSourceFunc)fullscreen_timeout_cb, window);
-
- update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR, TRUE);
- update_chrome_visibility (window);
- ev_view_show_cursor (EV_VIEW (window->priv->view));
+ item = gtk_ui_manager_get_widget (ui_manager, "/FullscreenToolbar/LeaveFullscreen");
+ g_object_set (item, "is-important", TRUE, NULL);
}
static void
-fullscreen_clear_timeout (EvWindow *window)
+fullscreen_toolbar_remove_shadow (GtkWidget *toolbar)
{
- if (window->priv->fullscreen_timeout_id != 0) {
- g_source_remove (window->priv->fullscreen_timeout_id);
+ static gboolean done = FALSE;
+
+ if (!done) {
+ gtk_rc_parse_string (
+ "\n"
+ " style \"fullscreen-toolbar-style\"\n"
+ " {\n"
+ " GtkToolbar::shadow-type=GTK_SHADOW_NONE\n"
+ " }\n"
+ "\n"
+ " widget \"*.fullscreen-toolbar\" style \"fullscreen-toolbar-style\"\n"
+ "\n");
+ done = TRUE;
}
- window->priv->fullscreen_timeout_id = 0;
- update_chrome_visibility (window);
- ev_view_show_cursor (EV_VIEW (window->priv->view));
-}
-
-
-static gboolean
-fullscreen_motion_notify_cb (GtkWidget *widget,
- GdkEventMotion *event,
- gpointer user_data)
-{
- EvWindow *window = EV_WINDOW (user_data);
-
- fullscreen_set_timeout (window);
-
- return FALSE;
+ gtk_widget_set_name (toolbar, "fullscreen-toolbar");
}
-static gboolean
-fullscreen_leave_notify_cb (GtkWidget *widget,
- GdkEventCrossing *event,
- gpointer user_data)
-{
- EvWindow *window = EV_WINDOW (user_data);
-
- fullscreen_clear_timeout (window);
-
- return FALSE;
-}
-
-static GtkWidget *
-ev_window_get_exit_fullscreen_button (EvWindow *window)
-{
- GtkWidget *button, *icon, *label, *hbox;
-
- button = gtk_button_new ();
- g_signal_connect (button, "clicked",
- G_CALLBACK (exit_fullscreen_button_clicked_cb),
- window);
- gtk_widget_show (button);
-
- hbox = gtk_hbox_new (FALSE, 2);
- gtk_widget_show (hbox);
- gtk_container_add (GTK_CONTAINER (button), hbox);
-
- icon = gtk_image_new_from_stock (EV_STOCK_LEAVE_FULLSCREEN, GTK_ICON_SIZE_BUTTON);
- gtk_widget_show (icon);
- gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
-
- label = gtk_label_new (_("Leave Fullscreen"));
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- return button;
-}
-
-static GtkWidget *
-ev_window_create_fullscreen_popup (EvWindow *window)
-{
- 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, FALSE), NULL);
-
- popup = gtk_window_new (GTK_WINDOW_POPUP);
- hbox = gtk_hbox_new (FALSE, 0);
- button = ev_window_get_exit_fullscreen_button (window);
-
- gtk_container_add (GTK_CONTAINER (popup), hbox);
- gtk_box_pack_start (GTK_BOX (hbox), window->priv->fullscreen_toolbar,
- TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
-
- gtk_widget_show (button);
- gtk_widget_show (hbox);
-
- gtk_window_set_resizable (GTK_WINDOW (popup), FALSE);
-
- 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_update_fullscreen_action (EvWindow *window)
+ev_window_run_fullscreen (EvWindow *window)
{
- GtkAction *action;
+ if (!window->priv->fullscreen_toolbar) {
+ window->priv->fullscreen_toolbar =
+ gtk_ui_manager_get_widget (window->priv->ui_manager,
+ "/FullscreenToolbar");
- action = gtk_action_group_get_action (window->priv->action_group, "ViewFullscreen");
- g_signal_handlers_block_by_func
- (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- ev_view_get_fullscreen (EV_VIEW (window->priv->view)));
- g_signal_handlers_unblock_by_func
- (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
-}
+ gtk_toolbar_set_style (GTK_TOOLBAR (window->priv->fullscreen_toolbar),
+ GTK_TOOLBAR_BOTH_HORIZ);
+ fullscreen_toolbar_remove_shadow (window->priv->fullscreen_toolbar);
+ fullscreen_toolbar_setup_item_properties (window->priv->ui_manager);
-static void
-ev_window_run_fullscreen (EvWindow *window)
-{
- if (window->priv->fullscreen_popup == NULL)
- window->priv->fullscreen_popup
- = ev_window_create_fullscreen_popup (window);
+ gtk_box_pack_start (GTK_BOX (window->priv->main_box),
+ window->priv->fullscreen_toolbar,
+ FALSE, FALSE, 0);
+ gtk_box_reorder_child (GTK_BOX (window->priv->main_box),
+ window->priv->fullscreen_toolbar, 1);
+ }
g_object_set (G_OBJECT (window->priv->scrolled_window),
"shadow-type", GTK_SHADOW_NONE,
ev_view_set_fullscreen (EV_VIEW (window->priv->view), TRUE);
ev_window_update_fullscreen_action (window);
+
+ /* If the user doesn't have the main toolbar he/she won't probably want
+ * the toolbar in fullscreen mode. See bug #483048
+ */
+ update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR,
+ (window->priv->chrome & EV_CHROME_TOOLBAR) != 0);
+ update_chrome_visibility (window);
gtk_window_fullscreen (GTK_WINDOW (window));
gtk_widget_grab_focus (window->priv->view);
- ev_window_update_fullscreen_popup (window);
-
- g_signal_connect (window->priv->view,
- "motion-notify-event",
- G_CALLBACK (fullscreen_motion_notify_cb),
- window);
- g_signal_connect (window->priv->view,
- "leave-notify-event",
- G_CALLBACK (fullscreen_leave_notify_cb),
- window);
- fullscreen_set_timeout (window);
if (!ev_window_is_empty (window))
ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", TRUE);
ev_view_set_fullscreen (view, FALSE);
ev_window_update_fullscreen_action (window);
+ update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR, FALSE);
+ update_chrome_visibility (window);
gtk_window_unfullscreen (GTK_WINDOW (window));
- g_signal_handlers_disconnect_by_func (window->priv->view,
- (gpointer) fullscreen_motion_notify_cb,
- window);
- g_signal_handlers_disconnect_by_func (window->priv->view,
- (gpointer) fullscreen_leave_notify_cb,
- window);
- fullscreen_clear_timeout (window);
-
if (!ev_window_is_empty (window))
ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", FALSE);
}
}
}
+static gboolean
+presentation_timeout_cb (EvWindow *window)
+{
+ EvView *view = EV_VIEW (window->priv->view);
+
+ if (!view || !ev_view_get_presentation (EV_VIEW (view)))
+ return FALSE;
+
+ ev_view_hide_cursor (EV_VIEW (window->priv->view));
+ window->priv->presentation_timeout_id = 0;
+
+ return FALSE;
+}
+
+static void
+presentation_set_timeout (EvWindow *window)
+{
+ if (window->priv->presentation_timeout_id > 0) {
+ g_source_remove (window->priv->presentation_timeout_id);
+ }
+
+#if GLIB_CHECK_VERSION (2, 13, 0)
+ window->priv->presentation_timeout_id =
+ g_timeout_add_seconds (PRESENTATION_TIMEOUT,
+ (GSourceFunc)presentation_timeout_cb, window);
+#else
+ window->priv->presentation_timeout_id =
+ g_timeout_add (PRESENTATION_TIMEOUT * 1000,
+ (GSourceFunc)presentation_timeout_cb, window);
+#endif
+
+ ev_view_show_cursor (EV_VIEW (window->priv->view));
+}
+
+static void
+presentation_clear_timeout (EvWindow *window)
+{
+ if (window->priv->presentation_timeout_id > 0) {
+ g_source_remove (window->priv->presentation_timeout_id);
+ }
+
+ window->priv->presentation_timeout_id = 0;
+
+ ev_view_show_cursor (EV_VIEW (window->priv->view));
+}
+
+static gboolean
+presentation_motion_notify_cb (GtkWidget *widget,
+ GdkEventMotion *event,
+ gpointer user_data)
+{
+ EvWindow *window = EV_WINDOW (user_data);
+
+ presentation_set_timeout (window);
+
+ return FALSE;
+}
+
+static gboolean
+presentation_leave_notify_cb (GtkWidget *widget,
+ GdkEventCrossing *event,
+ gpointer user_data)
+{
+ EvWindow *window = EV_WINDOW (user_data);
+
+ presentation_clear_timeout (window);
+
+ return FALSE;
+}
+
static void
ev_window_update_presentation_action (EvWindow *window)
{
ev_view_set_presentation (EV_VIEW (window->priv->view), TRUE);
ev_window_update_presentation_action (window);
+ update_chrome_visibility (window);
+
gtk_widget_grab_focus (window->priv->view);
gtk_window_fullscreen (GTK_WINDOW (window));
g_signal_connect (window->priv->view,
"motion-notify-event",
- G_CALLBACK (fullscreen_motion_notify_cb),
+ G_CALLBACK (presentation_motion_notify_cb),
window);
g_signal_connect (window->priv->view,
"leave-notify-event",
- G_CALLBACK (fullscreen_leave_notify_cb),
+ G_CALLBACK (presentation_leave_notify_cb),
window);
- fullscreen_set_timeout (window);
+ presentation_set_timeout (window);
ev_application_screensaver_disable (EV_APP);
ev_view_set_presentation (EV_VIEW (window->priv->view), FALSE);
ev_window_update_presentation_action (window);
+ update_chrome_visibility (window);
gtk_window_unfullscreen (GTK_WINDOW (window));
g_signal_handlers_disconnect_by_func (window->priv->view,
- (gpointer) fullscreen_motion_notify_cb,
+ (gpointer) presentation_motion_notify_cb,
window);
g_signal_handlers_disconnect_by_func (window->priv->view,
- (gpointer) fullscreen_leave_notify_cb,
+ (gpointer) presentation_leave_notify_cb,
window);
- fullscreen_clear_timeout (window);
+ presentation_clear_timeout (window);
ev_application_screensaver_enable (EV_APP);
{
gboolean presentation;
- g_return_if_fail (EV_IS_WINDOW (window));
+ g_return_if_fail (EV_IS_WINDOW (window));
ev_window_stop_fullscreen (window);
presentation = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
static void
ev_window_run_preview (EvWindow *window)
{
- ev_view_set_continuous (EV_VIEW (window->priv->view), FALSE);
+ GtkAction *action;
- update_chrome_flag (window, EV_CHROME_TOOLBAR, FALSE);
- update_chrome_flag (window, EV_CHROME_MENUBAR, FALSE);
- update_chrome_flag (window, EV_CHROME_SIDEBAR, FALSE);
-
- update_chrome_flag (window, EV_CHROME_PREVIEW_TOOLBAR, TRUE);
-
- update_chrome_visibility (window);
-}
+ if (!window->priv->preview_toolbar) {
+ window->priv->preview_toolbar =
+ gtk_ui_manager_get_widget (window->priv->ui_manager,
+ "/PreviewToolbar");
-static gboolean
-ev_window_focus_in_event (GtkWidget *widget, GdkEventFocus *event)
-{
- EvWindow *window = EV_WINDOW (widget);
- EvWindowPrivate *priv = window->priv;
-
- if (ev_view_get_fullscreen (EV_VIEW (priv->view)))
- fullscreen_set_timeout (window);
-
- return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_in_event (widget, event);
-}
-
-static gboolean
-ev_window_focus_out_event (GtkWidget *widget, GdkEventFocus *event)
-{
- EvWindow *window = EV_WINDOW (widget);
- EvWindowPrivate *priv = window->priv;
+ gtk_box_pack_start (GTK_BOX (window->priv->main_box),
+ window->priv->preview_toolbar,
+ FALSE, FALSE, 0);
+ gtk_box_reorder_child (GTK_BOX (window->priv->main_box),
+ window->priv->preview_toolbar, 1);
+ }
+
+ ev_view_set_continuous (EV_VIEW (window->priv->view), FALSE);
+
+ update_chrome_flag (window, EV_CHROME_TOOLBAR, FALSE);
+ update_chrome_flag (window, EV_CHROME_MENUBAR, FALSE);
+ update_chrome_flag (window, EV_CHROME_SIDEBAR, FALSE);
- if (ev_view_get_fullscreen (EV_VIEW (priv->view))) {
- fullscreen_set_timeout (window);
- gtk_widget_hide (priv->fullscreen_popup);
- }
+ update_chrome_flag (window, EV_CHROME_PREVIEW_TOOLBAR, TRUE);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "PreviewPrint");
+#if GTK_CHECK_VERSION (2, 11, 0)
+ gtk_action_set_visible (action, TRUE);
+#else
+ gtk_action_set_visible (action, FALSE);
+#endif
- return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_out_event (widget, event);
+ update_chrome_visibility (window);
}
static void
if (screen == old_screen)
return;
-#ifdef HAVE_GTK_RECENT
- if (old_screen) {
- g_signal_handlers_disconnect_by_func (
- gtk_recent_manager_get_for_screen (old_screen),
- G_CALLBACK (ev_window_setup_recent), window);
- }
-
- priv->recent_manager = gtk_recent_manager_get_for_screen (screen);
- g_signal_connect_swapped (priv->recent_manager,
- "changed",
- G_CALLBACK (ev_window_setup_recent),
- window);
-#endif
-
- ev_view_set_screen_dpi (EV_VIEW (window->priv->view),
- ev_window_get_screen_dpi (window));
+ ev_view_set_screen_dpi (EV_VIEW (priv->view),
+ get_screen_dpi (GTK_WINDOW (window)));
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);
-
- 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
gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 400);
editor = egg_toolbar_editor_new (ev_window->priv->ui_manager,
- ev_application_get_toolbars_model (EV_APP, FALSE));
+ 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);
gchar *uri;
uri = g_strdup (ev_window->priv->uri);
- ev_window_open_uri (ev_window, uri, NULL, 0, FALSE);
+ ev_window_open_uri (ev_window, uri, NULL, 0, NULL, FALSE, NULL);
g_free (uri);
}
ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
{
GError *error = NULL;
+ GdkScreen *screen;
+ char *command;
+ const char *lang;
+ char *uri = NULL;
- g_return_if_fail (EV_IS_WINDOW (ev_window));
+ int i;
- gnome_help_display ("evince.xml", NULL, &error);
+ const char * const * langs = g_get_language_names ();
+
+ for (i = 0; langs[i]; i++) {
+ lang = langs[i];
+ if (strchr (lang, '.')) {
+ continue;
+ }
+
+ uri = g_build_filename(GNOMEDATADIR,
+ "/gnome/help/" PACKAGE,
+ lang,
+ "/evince.xml",
+ NULL);
+
+ if (g_file_test (uri, G_FILE_TEST_EXISTS)) {
+ break;
+ }
+ g_free (uri);
+ uri = NULL;
+ }
- if(error != NULL) {
+ if (uri == NULL) {
+ g_warning ("Cannot find help");
+ return;
+ }
+
+ command = g_strconcat ("gnome-help ghelp://", uri, NULL);
+ g_free (uri);
+
+ screen = gtk_widget_get_screen (GTK_WIDGET (ev_window));
+ gdk_spawn_command_line_on_screen (screen, command, &error);
+ if (error != NULL) {
g_warning (error->message);
g_error_free (error);
}
+ g_free (command);
}
static void
ev_window_cmd_leave_fullscreen (GtkAction *action, EvWindow *window)
{
- gtk_window_unfullscreen (GTK_WINDOW (window));
+ ev_window_stop_fullscreen (window);
+}
+
+static void
+ev_window_cmd_start_presentation (GtkAction *action, EvWindow *window)
+{
+ ev_window_stop_fullscreen (window);
+ ev_window_run_presentation (window);
+}
+
+#ifdef WITH_GTK_PRINT
+static void ev_window_do_preview_print (EvWindow *window);
+
+static gboolean
+ev_window_enumerate_printer_cb (GtkPrinter *printer,
+ EvWindow *window)
+{
+ EvWindowPrivate *priv = window->priv;
+ const gchar *printer_name;
+
+ printer_name = gtk_print_settings_get_printer (priv->print_settings);
+ if ((printer_name
+ && strcmp (printer_name, gtk_printer_get_name (printer)) == 0) ||
+ (!printer_name && gtk_printer_is_default (printer))) {
+ if (priv->printer)
+ g_object_unref (priv->printer);
+ priv->printer = g_object_ref (printer);
+
+ /* Now that we have the printer, we'll start the print */
+ ev_window_do_preview_print (window);
+
+ return TRUE; /* we're done */
+ }
+
+ return FALSE; /* continue the enumeration */
+}
+
+static void
+ev_window_preview_print_finished (GtkPrintJob *print_job,
+ EvWindow *window,
+ GError *error)
+{
+ if (error) {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Failed to print document"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ error->message);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+
+ g_object_unref (print_job);
+ gtk_widget_destroy (GTK_WIDGET (window));
+}
+
+static void
+ev_window_do_preview_print (EvWindow *window)
+{
+ EvWindowPrivate *priv = window->priv;
+ GtkPageSetup *page_setup;
+ GtkPrintJob *job;
+ gchar *filename;
+ GError *error = NULL;
+
+ g_assert (priv->print_settings != NULL);
+ g_assert (priv->printer != NULL);
+
+ page_setup = gtk_page_setup_new ();
+
+ job = gtk_print_job_new ("evince-print",
+ priv->printer,
+ priv->print_settings,
+ page_setup);
+
+ g_object_unref (priv->print_settings);
+ priv->print_settings = NULL;
+ g_object_unref (priv->printer);
+ priv->printer = NULL;
+ g_object_unref (page_setup);
+
+ filename = g_filename_from_uri (priv->local_uri ?
+ priv->local_uri : priv->uri,
+ NULL, NULL);
+
+ if (gtk_print_job_set_source_file (job, filename, &error)) {
+ gtk_print_job_send (job,
+ (GtkPrintJobCompleteFunc)ev_window_preview_print_finished,
+ window, NULL);
+ } else {
+ g_warning (error->message);
+ g_error_free (error);
+ }
+
+ g_free (filename);
+
+ gtk_widget_hide (GTK_WIDGET (window));
+}
+
+#endif /* WITH_GTK_PRINT */
+
+static void
+ev_window_cmd_preview_print (GtkAction *action, EvWindow *window)
+{
+#ifdef WITH_GTK_PRINT
+ EvWindowPrivate *priv = window->priv;
+ GtkPrintSettings *print_settings = NULL;
+#if GTK_CHECK_VERSION (2, 11, 0)
+ const gchar *print_settings_file = priv->print_settings_file;
+
+ if (print_settings_file) {
+ if (g_file_test (print_settings_file, G_FILE_TEST_IS_REGULAR)) {
+ GError *error = NULL;
+
+ print_settings = gtk_print_settings_new_from_file (print_settings_file,
+ &error);
+
+ if (error) {
+ g_warning (error->message);
+ g_error_free (error);
+ print_settings = NULL;
+ }
+ }
+ }
+#endif /* GTK 2.11.0 */
+
+ if (!print_settings)
+ print_settings = gtk_print_settings_new ();
+
+ if (priv->print_settings)
+ g_object_unref (priv->print_settings);
+ priv->print_settings = print_settings;
+
+ gtk_enumerate_printers ((GtkPrinterFunc) ev_window_enumerate_printer_cb,
+ window, NULL, FALSE);
+#endif /* WITH_GTK_PRINT */
}
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, FALSE);
+ update_chrome_visibility (window);
gtk_widget_grab_focus (window->priv->view);
} else {
gboolean fullscreen;
}
}
-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
save_sizing_mode (EvWindow *window)
{
scrolled_window = ev_window->priv->scrolled_window;
- g_signal_handlers_disconnect_by_func (ev_window->priv->view, update_view_size, ev_window);
+ g_signal_handlers_disconnect_by_func (ev_window->priv->view, ev_view_update_view_size, scrolled_window);
if (sizing_mode != EV_SIZING_FREE)
- update_view_size (NULL, ev_window);
+ ev_view_update_view_size (EV_VIEW (ev_window->priv->view),
+ GTK_SCROLLED_WINDOW (scrolled_window));
switch (sizing_mode) {
case EV_SIZING_BEST_FIT:
"vscrollbar-policy", GTK_POLICY_AUTOMATIC,
NULL);
g_signal_connect (ev_window->priv->view, "zoom_invalid",
- G_CALLBACK (update_view_size),
- ev_window);
+ G_CALLBACK (ev_view_update_view_size),
+ scrolled_window);
break;
case EV_SIZING_FIT_WIDTH:
g_object_set (G_OBJECT (scrolled_window),
"vscrollbar-policy", GTK_POLICY_AUTOMATIC,
NULL);
g_signal_connect (ev_window->priv->view, "zoom_invalid",
- G_CALLBACK (update_view_size),
- ev_window);
+ G_CALLBACK (ev_view_update_view_size),
+ scrolled_window);
break;
case EV_SIZING_FREE:
g_object_set (G_OBJECT (scrolled_window),
gdouble zoom;
zoom = ev_view_get_zoom (view);
- zoom *= 72.0 / ev_window_get_screen_dpi (ev_window);
+ zoom *= 72.0 / get_screen_dpi (GTK_WINDOW(ev_window));
ev_metadata_manager_set_double (ev_window->priv->uri, "zoom", zoom);
}
}
ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (window->priv->sidebar_thumbs),
rotation);
+ ev_window_refresh_window_thumbnail (window, rotation);
}
static void
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
update_chrome_flag (ev_window, EV_CHROME_TOOLBAR, active);
+ update_chrome_visibility (ev_window);
ev_metadata_manager_set_boolean (NULL, "show_toolbar", active);
}
static void
ev_window_view_sidebar_cb (GtkAction *action, EvWindow *ev_window)
{
+ if (ev_view_get_presentation (EV_VIEW (ev_window->priv->view)))
+ return;
+
update_chrome_flag (ev_window, EV_CHROME_SIDEBAR,
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ update_chrome_visibility (ev_window);
}
static void
action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
- if (!ev_view_get_presentation (view) &&
- !ev_view_get_fullscreen (view)) {
-
+ if (!ev_view_get_presentation (view)) {
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
GTK_WIDGET_VISIBLE (ev_sidebar));
EvWindow *ev_window)
{
update_chrome_flag (ev_window, EV_CHROME_FINDBAR, FALSE);
+ update_chrome_visibility (ev_window);
}
static void
EvWindow *ev_window)
{
gboolean case_sensitive;
- gboolean visible;
const char *search_string;
- /* Either the string or case sensitivity could have changed,
- * we connect this callback to both. We also connect it
- * to ::visible so when the find bar is hidden, we should
- * pretend the search string is NULL/""
- */
+ /* Either the string or case sensitivity could have changed. */
case_sensitive = egg_find_bar_get_case_sensitive (find_bar);
- visible = GTK_WIDGET_VISIBLE (find_bar);
search_string = egg_find_bar_get_search_string (find_bar);
ev_view_search_changed (EV_VIEW(ev_window->priv->view));
if (ev_window->priv->document &&
EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
- if (visible && search_string && search_string[0]) {
+ if (search_string && search_string[0]) {
ev_document_doc_mutex_lock ();
ev_document_find_begin (EV_DOCUMENT_FIND (ev_window->priv->document),
ev_page_cache_get_current_page (ev_window->priv->page_cache),
}
}
+static void
+find_bar_visibility_changed_cb (EggFindBar *find_bar,
+ GParamSpec *param,
+ EvWindow *ev_window)
+{
+ gboolean visible;
+
+ visible = GTK_WIDGET_VISIBLE (find_bar);
+
+ if (ev_window->priv->document &&
+ EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
+ ev_view_set_highlight_search (EV_VIEW(ev_window->priv->view), visible);
+ ev_view_search_changed (EV_VIEW(ev_window->priv->view));
+ ev_window_update_actions (ev_window);
+
+ if (!visible)
+ egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar), NULL);
+ }
+}
+
static void
find_bar_scroll(EggFindBar *find_bar, GtkScrollType scroll, EvWindow* ev_window)
{
if (mode == EV_SIZING_FREE) {
ev_view_set_zoom (EV_VIEW (ev_window->priv->view),
- zoom * ev_window_get_screen_dpi (ev_window) / 72.0,
+ zoom * get_screen_dpi (GTK_WINDOW (ev_window)) / 72.0,
FALSE);
}
}
priv->attachment_popup_action_group = NULL;
}
-#ifdef HAVE_GTK_RECENT
if (priv->recent_action_group) {
g_object_unref (priv->recent_action_group);
priv->recent_action_group = NULL;
}
priv->recent_ui_id = 0;
-#else
- if (priv->recent_view) {
- g_object_unref (priv->recent_view);
- priv->recent_view = NULL;
- }
-#endif /* HAVE_GTK_RECENT */
if (priv->page_cache) {
g_signal_handlers_disconnect_by_func (priv->page_cache, page_changed_cb, window);
ev_window_clear_load_job (window);
}
+ if (priv->save_job) {
+ ev_window_clear_save_job (window);
+ }
+
if (priv->thumbnail_job) {
ev_window_clear_thumbnail_job (window);
}
priv->history = NULL;
}
- if (priv->fullscreen_timeout_id) {
- g_source_remove (priv->fullscreen_timeout_id);
- priv->fullscreen_timeout_id = 0;
+ if (priv->print_settings_file) {
+ ev_window_clear_print_settings_file (window);
+ priv->print_settings_file = NULL;
+ }
+
+ if (priv->presentation_timeout_id > 0) {
+ g_source_remove (priv->presentation_timeout_id);
+ priv->presentation_timeout_id = 0;
}
- destroy_fullscreen_popup (window);
G_OBJECT_CLASS (ev_window_parent_class)->dispose (object);
}
g_object_class->dispose = ev_window_dispose;
g_object_class->finalize = ev_window_finalize;
- 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));
/* Edit menu */
{ "EditCopy", GTK_STOCK_COPY, NULL, "<control>C", NULL,
G_CALLBACK (ev_window_cmd_edit_copy) },
-#ifdef HAVE_GTK_RECENT
{ "EditSelectAll", GTK_STOCK_SELECT_ALL, N_("Select _All"), "<control>A", NULL,
-#else
- { "EditSelectAll", NULL, N_("Select _All"), "<control>A", NULL,
-#endif /* HAVE_GTK_RECENT */
G_CALLBACK (ev_window_cmd_edit_select_all) },
{ "EditFind", GTK_STOCK_FIND, N_("_Find..."), "<control>F",
N_("Find a word or phrase in the document"),
G_CALLBACK (ev_window_cmd_help_about) },
/* Toolbar-only */
- { "LeaveFullscreen", EV_STOCK_LEAVE_FULLSCREEN, N_("Leave Fullscreen"), NULL,
+ { "LeaveFullscreen", GTK_STOCK_LEAVE_FULLSCREEN, N_("Leave Fullscreen"), NULL,
N_("Leave fullscreen mode"),
G_CALLBACK (ev_window_cmd_leave_fullscreen) },
+ { "StartPresentation", EV_STOCK_RUN_PRESENTATION, N_("Start Presentation"), NULL,
+ N_("Start a presentation"),
+ G_CALLBACK (ev_window_cmd_start_presentation) },
+ { "PreviewPrint", GTK_STOCK_PRINT, N_("Print"), NULL,
+ N_("Print this document"),
+ G_CALLBACK (ev_window_cmd_preview_print) },
/* Accellerators */
{ "Escape", NULL, "", "Escape", "",
{ "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",
+ { "ViewFullscreen", GTK_STOCK_FULLSCREEN, N_("_Fullscreen"), "F11",
N_("Expand the window to fill the screen"),
G_CALLBACK (ev_window_cmd_view_fullscreen) },
- { "ViewPresentation", NULL, N_("_Presentation"), "F5",
+ { "ViewPresentation", EV_STOCK_RUN_PRESENTATION, N_("Pre_sentation"), "F5",
N_("Run document as a presentation"),
G_CALLBACK (ev_window_cmd_view_presentation) },
{ "ViewBestFit", EV_STOCK_ZOOM_PAGE, N_("_Best Fit"), NULL,
"name", PAGE_SELECTOR_ACTION,
"label", _("Page"),
"tooltip", _("Select Page"),
+ "icon_name", "text-x-generic",
"visible_overflown", FALSE,
NULL);
g_signal_connect (action, "activate_link",
action = g_object_new (EPHY_TYPE_ZOOM_ACTION,
"name", ZOOM_CONTROL_ACTION,
"label", _("Zoom"),
- "stock_id", GTK_STOCK_ZOOM_IN,
+ "stock_id", EV_STOCK_ZOOM,
"tooltip", _("Adjust the zoom level"),
"zoom", 1.0,
NULL);
G_CALLBACK (navigation_action_activate_link_cb), window);
gtk_action_group_add_action (group, action);
g_object_unref (action);
+
+ action = g_object_new (EV_TYPE_OPEN_RECENT_ACTION,
+ "name", "FileOpenRecent",
+ "label", _("_Open..."),
+ "tooltip", _("Open an existing document"),
+ "stock_id", GTK_STOCK_OPEN,
+ NULL);
+ g_signal_connect (action, "activate",
+ G_CALLBACK (ev_window_cmd_file_open), window);
+ g_signal_connect (action, "item_activated",
+ G_CALLBACK (ev_window_open_recent_action_item_activated),
+ window);
+ gtk_action_group_add_action (group, action);
+ g_object_unref (action);
}
static void
ev_window_set_view_accels_sensitivity (window, TRUE);
+ update_chrome_visibility (window);
+
return FALSE;
}
allowing to launch executables is a good idea though. -- marco */
}
-static gboolean
-uri_is_valid (const gchar *uri)
-{
- gchar *p = (gchar *) uri;
-
- if (!p || !g_ascii_isalpha (*p))
- return FALSE;
-
- p++;
- while (g_ascii_isalnum (*p))
- p++;
-
- return (g_ascii_strncasecmp (p, "://", strlen ("://")) == 0);
-}
-
static void
launch_external_uri (EvWindow *window, EvLinkAction *action)
{
const gchar *uri = ev_link_action_get_uri (action);
-
- if (!uri_is_valid (uri)) {
- GtkWidget *dialog;
+ GnomeVFSResult result = gnome_vfs_url_show (uri);
+ GtkWidget *dialog;
+ gchar* message = NULL;
+ switch(result) {
+ case GNOME_VFS_OK:
+ break;
+ case GNOME_VFS_ERROR_BAD_PARAMETERS:
+ message = _("Invalid URI: ā%sā");
+ break;
+ case GNOME_VFS_ERROR_NOT_SUPPORTED:
+ message = _("Unsupported URI: ā%sā");
+ break;
+ default:
+ message = _("Unknown error");
+ }
+ if(message) {
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
_("Unable to open external link"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("Invalid URI: ā%sā"), uri);
+ message, uri);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy),
NULL);
gtk_widget_show (dialog);
- return;
}
-
- gnome_vfs_url_show (uri);
+ return;
}
static void
gtk_window_get_screen (GTK_WINDOW (window)),
ev_link_action_get_dest (action),
0,
+ NULL,
FALSE,
+ NULL,
GDK_CURRENT_TIME);
g_free (uri);
gint response_id,
EvWindow *ev_window)
{
- gchar *uri;
- gchar *filename;
- GError *error = NULL;
+ GnomeVFSURI *target_uri;
+ gchar *uri;
+ gchar *filename;
+ gboolean is_local;
+ GError *error = NULL;
if (response_id != GTK_RESPONSE_OK) {
gtk_widget_destroy (fc);
}
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
- filename = g_filename_from_uri (uri, NULL, NULL);
+ target_uri = gnome_vfs_uri_new (uri);
+ is_local = gnome_vfs_uri_is_local (target_uri);
+
+ if (is_local) {
+ filename = g_filename_from_uri (uri, NULL, NULL);
+ } else {
+ filename = ev_tmp_filename ("saveimage");
+ }
+
g_free (uri);
/* FIXME: allow saving in other image formats than png */
filename, "png", &error, NULL);
if (error) {
- ev_window_error_dialog (GTK_WINDOW (ev_window),
- _("The image could not be saved."),
- error);
+ ev_window_error_message (GTK_WINDOW (ev_window),
+ _("The image could not be saved."),
+ error);
g_error_free (error);
+ g_free (filename);
+ gnome_vfs_uri_unref (target_uri);
+ gtk_widget_destroy (fc);
+
+ return;
}
- g_free (filename);
+ if (!is_local) {
+ GnomeVFSURI *source_uri;
+ gchar *local_uri;
+ local_uri = g_filename_to_uri (filename, NULL, NULL);
+ source_uri = gnome_vfs_uri_new (local_uri);
+ g_free (local_uri);
+ ev_window_save_remote (ev_window, source_uri, target_uri);
+ gnome_vfs_uri_unref (source_uri);
+ }
+
+ g_free (filename);
+ gnome_vfs_uri_unref (target_uri);
gtk_widget_destroy (fc);
}
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fc), FALSE);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE);
filter = gtk_file_filter_new ();
ev_attachment_open (attachment, &error);
if (error) {
- ev_window_error_dialog (GTK_WINDOW (window),
- _("Unable to open attachment"),
- error);
+ ev_window_error_message (GTK_WINDOW (window),
+ _("Unable to open attachment"),
+ error);
g_error_free (error);
}
}
gint response_id,
EvWindow *ev_window)
{
+ GnomeVFSURI *target_uri;
gchar *uri;
GList *l;
GtkFileChooserAction fc_action;
gboolean is_dir;
+ gboolean is_local;
if (response_id != GTK_RESPONSE_OK) {
gtk_widget_destroy (fc);
}
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
-
+ target_uri = gnome_vfs_uri_new (uri);
g_object_get (G_OBJECT (fc), "action", &fc_action, NULL);
is_dir = (fc_action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+ is_local = gnome_vfs_uri_is_local (target_uri);
for (l = ev_window->priv->attach_list; l && l->data; l = g_list_next (l)) {
EvAttachment *attachment;
attachment = (EvAttachment *) l->data;
- if (is_dir) {
- filename = g_strjoin ("/", uri,
- ev_attachment_get_name (attachment),
- NULL);
+ if (is_local) {
+ if (is_dir) {
+ filename = g_strjoin ("/", uri,
+ ev_attachment_get_name (attachment),
+ NULL);
+ } else {
+ filename = g_strdup (uri);
+ }
} else {
- filename = g_strdup (uri);
+ filename = ev_tmp_filename ("saveattachment");
}
-
+
ev_attachment_save (attachment, filename, &error);
- g_free (filename);
if (error) {
- ev_window_error_dialog (GTK_WINDOW (ev_window),
- _("The attachment could not be saved."),
- error);
+ ev_window_error_message (GTK_WINDOW (ev_window),
+ _("The attachment could not be saved."),
+ error);
g_error_free (error);
+ g_free (filename);
+
+ continue;
+ }
+
+ if (!is_local) {
+ GnomeVFSURI *src_uri;
+ GnomeVFSURI *dest_uri;
+ gchar *local_uri;
+
+ if (is_dir) {
+ const gchar *name = ev_attachment_get_name (attachment);
+
+ dest_uri = gnome_vfs_uri_append_file_name (target_uri,
+ name);
+ } else {
+ dest_uri = gnome_vfs_uri_ref (target_uri);
+ }
+
+ local_uri = g_filename_to_uri (filename, NULL, NULL);
+ src_uri = gnome_vfs_uri_new (local_uri);
+ g_free (local_uri);
+ ev_window_save_remote (ev_window, src_uri, dest_uri);
+ gnome_vfs_uri_unref (src_uri);
+ gnome_vfs_uri_unref (dest_uri);
}
+
+ g_free (filename);
}
g_free (uri);
+ gnome_vfs_uri_unref (target_uri);
gtk_widget_destroy (fc);
}
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE);
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fc), FALSE);
if (attachment)
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc),
GtkActionGroup *action_group;
GtkAccelGroup *accel_group;
GError *error = NULL;
- GtkWidget *sidebar_widget, *toolbar_dock;
+ GtkWidget *sidebar_widget;
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);
- g_signal_connect (ev_window, "notify",
- G_CALLBACK (fullscreen_timeout_cb), NULL);
ev_window->priv = EV_WINDOW_GET_PRIVATE (ev_window);
g_error_free (error);
}
-#ifdef HAVE_GTK_RECENT
+#if GTK_CHECK_VERSION(2,11,4)
+ ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
+#else
+ /* It's fine to just use the one of the default screen here */
ev_window->priv->recent_manager = gtk_recent_manager_get_for_screen (
- gtk_widget_get_screen (GTK_WIDGET (ev_window)));
+ gdk_screen_get_default ());
+#endif
ev_window->priv->recent_action_group = NULL;
ev_window->priv->recent_ui_id = 0;
g_signal_connect_swapped (ev_window->priv->recent_manager,
"changed",
G_CALLBACK (ev_window_setup_recent),
ev_window);
-#endif /* HAVE_GTK_RECENT */
-
+
ev_window->priv->menubar =
gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
"/MainMenu");
ev_window->priv->menubar,
FALSE, FALSE, 0);
- /* 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.
- */
- toolbar_dock = ev_window->priv->toolbar_dock = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), toolbar_dock,
- FALSE, FALSE, 0);
- gtk_widget_show (toolbar_dock);
-
ev_window->priv->toolbar = GTK_WIDGET
(g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
"ui-manager", ev_window->priv->ui_manager,
"popup-path", "/ToolbarPopup",
- "model", ev_application_get_toolbars_model (EV_APP, FALSE),
+ "model", ev_application_get_toolbars_model (EV_APP),
NULL));
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);
-
- /* Preview toolbar */
- ev_window->priv->preview_toolbar = egg_editable_toolbar_new_with_model
- (ev_window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP, TRUE), NULL);
- gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), ev_window->priv->preview_toolbar,
+ gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),
+ ev_window->priv->toolbar,
FALSE, FALSE, 0);
+ gtk_widget_show (ev_window->priv->toolbar);
/* Add the main area */
ev_window->priv->hpaned = gtk_hpaned_new ();
/* Stub sidebar, for now */
+ sidebar_widget = ev_sidebar_thumbnails_new ();
+ 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);
+
sidebar_widget = ev_sidebar_links_new ();
ev_window->priv->sidebar_links = sidebar_widget;
g_signal_connect (sidebar_widget,
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
sidebar_widget);
- sidebar_widget = ev_sidebar_thumbnails_new ();
- 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->view_box = gtk_vbox_new (FALSE, 0);
ev_window->priv->scrolled_window =
GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,
"shadow-type", GTK_SHADOW_IN,
NULL));
+ gtk_box_pack_start (GTK_BOX (ev_window->priv->view_box),
+ ev_window->priv->scrolled_window,
+ TRUE, TRUE, 0);
gtk_widget_show (ev_window->priv->scrolled_window);
gtk_paned_add2 (GTK_PANED (ev_window->priv->hpaned),
- ev_window->priv->scrolled_window);
+ ev_window->priv->view_box);
+ gtk_widget_show (ev_window->priv->view_box);
ev_window->priv->view = ev_view_new ();
ev_view_set_screen_dpi (EV_VIEW (ev_window->priv->view),
- ev_window_get_screen_dpi (ev_window));
+ get_screen_dpi (GTK_WINDOW (ev_window)));
ev_window->priv->password_view = ev_password_view_new ();
g_signal_connect_swapped (ev_window->priv->password_view,
"unlock",
ev_window);
g_signal_connect (ev_window->priv->find_bar,
"notify::visible",
- G_CALLBACK (find_bar_search_changed_cb),
+ G_CALLBACK (find_bar_visibility_changed_cb),
ev_window);
g_signal_connect (ev_window->priv->find_bar,
"scroll",