#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 <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
GtkWidget *menubar;
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;
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 */
EvPageCache *page_cache;
EvWindowPageMode page_mode;
EvWindowTitle *title;
-#ifndef HAVE_GTK_RECENT
- EggRecentViewUIManager *recent_view;
-#endif
EvJob *load_job;
EvJob *thumbnail_job;
#define THUMBNAILS_SIDEBAR_ID "thumbnails"
#define ATTACHMENTS_SIDEBAR_ID "attachments"
+#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,
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);
}
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)
{
- gtk_widget_destroy (dialog);
+ 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_dialog (GtkWindow *window, const gchar *msg, GError *error)
+ev_window_error_message_response_cb (EvMessageArea *area,
+ gint response_id,
+ EvWindow *window)
{
- GtkWidget *dialog;
+ ev_window_set_message_area (window, NULL);
+}
- 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);
+static void
+ev_window_error_message (GtkWindow *window, const gchar *msg, GError *error)
+{
+ GtkWidget *area;
+
+ 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
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",
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_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;
}
const char *uri,
EvLinkDest *dest,
EvWindowRunMode mode,
+ 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);
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),
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_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,
+ 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_at_dest (EV_APP, uri,
- gtk_window_get_screen (GTK_WINDOW (ev_window)),
- NULL, 0, FALSE, NULL,
+ gtk_window_get_screen (GTK_WINDOW (window)),
+ NULL, 0, NULL, FALSE, NULL,
GDK_CURRENT_TIME);
-
- g_free (uri);
}
-#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);
-
- egg_recent_view_uimanager_show_icons (EGG_RECENT_VIEW_UIMANAGER (ev_window->priv->recent_view), FALSE);
-
- egg_recent_view_set_model (EGG_RECENT_VIEW (ev_window->priv->recent_view),
- ev_application_get_recent_model (EV_APP));
-
- egg_recent_view_uimanager_set_trailing_sep (ev_window->priv->recent_view, TRUE);
-
- g_signal_connect (ev_window->priv->recent_view, "activate",
- G_CALLBACK (ev_window_cmd_recent_file_activate), ev_window);
-#endif /* HAVE_GTK_RECENT */
}
static gint
gchar *msg;
msg = g_strdup_printf (_("The file could not be saved as ā%sā."), job->uri);
- ev_window_error_dialog (GTK_WINDOW (window), msg, job->error);
+ ev_window_error_message (GTK_WINDOW (window), msg, job->error);
g_free (msg);
}
}
}
+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,
EvWindow *window,
/* If printed successfully, save print settings */
ev_application_set_print_settings (EV_APP,
window->priv->print_settings);
+ ev_window_save_print_settings (window);
}
}
gtk_window_get_screen (GTK_WINDOW (window)),
NULL,
EV_WINDOW_MODE_PREVIEW,
+ NULL,
TRUE,
print_settings_file,
GDK_CURRENT_TIME);
document_last_page = ev_page_cache_get_n_pages (page_cache);
if (!ev_window->priv->print_settings) {
- ev_window->priv->print_settings = g_object_ref (
+ 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) {
g_object_set (item, "is-important", TRUE, NULL);
}
+static void
+fullscreen_toolbar_remove_shadow (GtkWidget *toolbar)
+{
+ 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;
+ }
+
+ gtk_widget_set_name (toolbar, "fullscreen-toolbar");
+}
+
static void
ev_window_run_fullscreen (EvWindow *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);
gtk_box_pack_start (GTK_BOX (window->priv->main_box),
{
gchar *uri;
- ev_window->priv->in_reload = TRUE;
-
uri = g_strdup (ev_window->priv->uri);
- ev_window_open_uri (ev_window, uri, NULL, 0, FALSE, NULL);
+ ev_window_open_uri (ev_window, uri, NULL, 0, NULL, FALSE, NULL);
g_free (uri);
}
if (g_file_test (uri, G_FILE_TEST_EXISTS)) {
break;
}
+ g_free (uri);
+ uri = NULL;
}
if (uri == NULL) {
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);
/* 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 (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
gtk_window_get_screen (GTK_WINDOW (window)),
ev_link_action_get_dest (action),
0,
+ NULL,
FALSE,
NULL,
GDK_CURRENT_TIME);
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);
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);
}
}
ev_attachment_save (attachment, filename, &error);
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);
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
"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);
-
ev_window->priv->toolbar = GTK_WIDGET
(g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
"ui-manager", ev_window->priv->ui_manager,
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),