X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=shell%2Fev-window.c;h=bee7d341b506e1543e6da22523c5c655f7343ac8;hb=e732e45fbf5930d8c3ac2471ff8912f41152ec7a;hp=042b4f93ba81988b881d3a85e37dc19287c6feec;hpb=0f1c723ad2fe48a0f22e32619985f93ebb2e02ef;p=evince.git diff --git a/shell/ev-window.c b/shell/ev-window.c index 042b4f93..bee7d341 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ /* this file is part of evince, a gnome document viewer * + * Copyright (C) 2009 Juanjo Marín * Copyright (C) 2008 Carlos Garcia Campos * Copyright (C) 2004 Martin Kretzschmar * Copyright (C) 2004 Red Hat, Inc. @@ -59,6 +60,7 @@ #include "ev-document-images.h" #include "ev-document-links.h" #include "ev-document-thumbnails.h" +#include "ev-document-annotations.h" #include "ev-document-type-builtins.h" #include "ev-file-exporter.h" #include "ev-file-helpers.h" @@ -206,6 +208,9 @@ struct _EvWindowPrivate { GtkPrintSettings *print_settings; GtkPageSetup *print_page_setup; gboolean close_after_print; +#ifdef WITH_GCONF + GConfClient *gconf_client; +#endif }; #define EV_WINDOW_GET_PRIVATE(object) \ @@ -215,9 +220,11 @@ struct _EvWindowPrivate { #define ZOOM_CONTROL_ACTION "ViewZoom" #define NAVIGATION_ACTION "Navigation" +#define GCONF_LOCKDOWN_DIR "/desktop/gnome/lockdown" #define GCONF_OVERRIDE_RESTRICTIONS "/apps/evince/override_restrictions" #define GCONF_LOCKDOWN_SAVE "/desktop/gnome/lockdown/disable_save_to_disk" #define GCONF_LOCKDOWN_PRINT "/desktop/gnome/lockdown/disable_printing" +#define GCONF_LOCKDOWN_PRINT_SETUP "/desktop/gnome/lockdown/disable_print_setup" #define PRESENTATION_TIMEOUT 5 @@ -335,18 +342,15 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window) { EvDocument *document = ev_window->priv->document; const EvDocumentInfo *info = NULL; - gboolean has_document = FALSE; gboolean ok_to_print = TRUE; + gboolean ok_to_print_setup = TRUE; gboolean ok_to_copy = TRUE; gboolean has_properties = TRUE; gboolean override_restrictions = TRUE; gboolean can_get_text = FALSE; gboolean has_pages = FALSE; gboolean can_find = FALSE; -#ifdef WITH_GCONF - GConfClient *client; -#endif if (document) { has_document = TRUE; @@ -367,10 +371,10 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window) } #ifdef WITH_GCONF - client = gconf_client_get_default (); - override_restrictions = gconf_client_get_bool (client, - GCONF_OVERRIDE_RESTRICTIONS, - NULL); + if (has_document) + override_restrictions = gconf_client_get_bool (ev_window->priv->gconf_client, + GCONF_OVERRIDE_RESTRICTIONS, + NULL); #endif if (!override_restrictions && info && info->fields_mask & EV_DOCUMENT_INFO_PERMISSIONS) { ok_to_print = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT); @@ -381,21 +385,28 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window) ok_to_print = FALSE; #ifdef WITH_GCONF - if (gconf_client_get_bool (client, GCONF_LOCKDOWN_SAVE, NULL)) { + if (has_document && + gconf_client_get_bool (ev_window->priv->gconf_client, GCONF_LOCKDOWN_SAVE, NULL)) { ok_to_copy = FALSE; } - if (gconf_client_get_bool (client, GCONF_LOCKDOWN_PRINT, NULL)) { + if (has_document && + gconf_client_get_bool (ev_window->priv->gconf_client, GCONF_LOCKDOWN_PRINT, NULL)) { ok_to_print = FALSE; } - g_object_unref (client); + if (has_document && + gconf_client_get_bool (ev_window->priv->gconf_client, GCONF_LOCKDOWN_PRINT_SETUP, NULL)) { + ok_to_print_setup = FALSE; + } #endif /* File menu */ ev_window_set_action_sensitive (ev_window, "FileOpenCopy", has_document); ev_window_set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy); - ev_window_set_action_sensitive (ev_window, "FilePageSetup", has_pages && ok_to_print); +#if !GTK_CHECK_VERSION (2, 17, 4) + ev_window_set_action_sensitive (ev_window, "FilePageSetup", has_pages && ok_to_print && ok_to_print_setup); +#endif ev_window_set_action_sensitive (ev_window, "FilePrint", has_pages && ok_to_print); ev_window_set_action_sensitive (ev_window, "FileProperties", has_document && has_properties); @@ -413,12 +424,18 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window) ev_window_set_action_sensitive (ev_window, "ViewPageWidth", has_pages); ev_window_set_action_sensitive (ev_window, "ViewReload", has_pages); ev_window_set_action_sensitive (ev_window, "ViewAutoscroll", has_pages); + ev_window_set_action_sensitive (ev_window, "ViewInvertedColors", has_pages); /* 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, FALSE); + /* Help menu */ +#ifdef G_OS_WIN32 + ev_window_set_action_sensitive (ev_window, "HelpContents", FALSE); +#endif + ev_window_update_actions (ev_window); } @@ -514,6 +531,8 @@ ev_window_set_view_accels_sensitivity (EvWindow *window, gboolean sensitive) ev_window_set_action_sensitive (window, "KpPlus", sensitive); ev_window_set_action_sensitive (window, "KpMinus", sensitive); ev_window_set_action_sensitive (window, "Equal", sensitive); + ev_window_set_action_sensitive (window, "p", sensitive); + ev_window_set_action_sensitive (window, "n", sensitive); ev_window_set_action_sensitive (window, "Slash", sensitive && can_find); } @@ -935,9 +954,10 @@ setup_model_from_metadata (EvWindow *window) gchar *sizing_mode; gdouble zoom; gint rotation; - gboolean continuous = { 0, }; - gboolean dual_page = { 0, }; - gboolean fullscreen = { 0, }; + gboolean inverted_colors = FALSE; + gboolean continuous = FALSE; + gboolean dual_page = FALSE; + gboolean fullscreen = FALSE; if (!window->priv->metadata) return; @@ -983,6 +1003,10 @@ setup_model_from_metadata (EvWindow *window) ev_document_model_set_rotation (window->priv->model, rotation); } + /* Inverted Colors */ + if (ev_metadata_get_boolean (window->priv->metadata, "inverted-colors", &inverted_colors)) + ev_document_model_set_inverted_colors (window->priv->model, inverted_colors); + /* Continuous */ if (ev_metadata_get_boolean (window->priv->metadata, "continuous", &continuous)) { ev_document_model_set_continuous (window->priv->model, continuous); @@ -1124,6 +1148,8 @@ ev_window_set_icon_from_thumbnail (EvJobThumbnail *job, EvWindow *ev_window) { if (job->thumbnail) { + if (ev_document_model_get_inverted_colors (ev_window->priv->model)) + ev_document_misc_invert_pixbuf (job->thumbnail); gtk_window_set_icon (GTK_WINDOW (ev_window), job->thumbnail); } @@ -1132,10 +1158,11 @@ ev_window_set_icon_from_thumbnail (EvJobThumbnail *job, } static void -ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation) +ev_window_refresh_window_thumbnail (EvWindow *ev_window) { gdouble page_width; gdouble scale; + gint rotation; EvDocument *document = ev_window->priv->document; if (!EV_IS_DOCUMENT_THUMBNAILS (document) || @@ -1148,6 +1175,7 @@ ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation) ev_document_get_page_size (document, 0, &page_width, NULL); scale = 128. / page_width; + rotation = ev_document_model_get_rotation (ev_window->priv->model); ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, 0, rotation, scale); g_signal_connect (ev_window->priv->thumbnail_job, "finished", @@ -1156,6 +1184,17 @@ ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation) ev_job_scheduler_push_job (ev_window->priv->thumbnail_job, EV_JOB_PRIORITY_NONE); } +#ifdef WITH_GCONF +static void +lockdown_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + EvWindow *ev_window) +{ + ev_window_setup_action_sensitivity (ev_window); +} +#endif /* WITH_GCONF */ + static gboolean ev_window_setup_document (EvWindow *ev_window) { @@ -1165,12 +1204,33 @@ ev_window_setup_document (EvWindow *ev_window) ev_window->priv->setup_document_idle = 0; - ev_window_refresh_window_thumbnail (ev_window, 0); + ev_window_refresh_window_thumbnail (ev_window); 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); +#ifdef WITH_GCONF + if (!ev_window->priv->gconf_client) + ev_window->priv->gconf_client = gconf_client_get_default (); + gconf_client_add_dir (ev_window->priv->gconf_client, + GCONF_LOCKDOWN_DIR, + GCONF_CLIENT_PRELOAD_ONELEVEL, + NULL); + gconf_client_add_dir (ev_window->priv->gconf_client, + GCONF_OVERRIDE_RESTRICTIONS, + GCONF_CLIENT_PRELOAD_NONE, + NULL); + gconf_client_notify_add (ev_window->priv->gconf_client, + GCONF_LOCKDOWN_DIR, + (GConfClientNotifyFunc)lockdown_changed, + ev_window, NULL, NULL); + gconf_client_notify_add (ev_window->priv->gconf_client, + GCONF_OVERRIDE_RESTRICTIONS, + (GConfClientNotifyFunc)lockdown_changed, + ev_window, NULL, NULL); +#endif /* WITH_GCONF */ + ev_window_setup_action_sensitivity (ev_window); if (ev_window->priv->history) @@ -1205,18 +1265,6 @@ ev_window_set_document (EvWindow *ev_window, EvDocument *document) ev_window_set_message_area (ev_window, NULL); - if (ev_window->priv->in_reload && ev_window->priv->dest) { - gint page; - - /* Restart the current page */ - page = CLAMP (ev_link_dest_get_page (ev_window->priv->dest), - 0, - ev_document_get_n_pages (document) - 1); - ev_document_model_set_page (ev_window->priv->model, page); - g_object_unref (ev_window->priv->dest); - ev_window->priv->dest = NULL; - } - if (ev_document_get_n_pages (document) <= 0) { ev_window_warning_message (ev_window, "%s", _("The document contains no pages")); @@ -1426,23 +1474,28 @@ ev_window_reload_job_cb (EvJob *job, EvWindow *ev_window) { GtkWidget *widget; - EvLinkDest *dest = NULL; if (ev_job_is_failed (job)) { ev_window_clear_reload_job (ev_window); ev_window->priv->in_reload = FALSE; - g_object_unref (ev_window->priv->dest); - ev_window->priv->dest = NULL; - + if (ev_window->priv->dest) { + g_object_unref (ev_window->priv->dest); + ev_window->priv->dest = NULL; + } + return; } - if (ev_window->priv->dest) { - dest = g_object_ref (ev_window->priv->dest); - } ev_document_model_set_document (ev_window->priv->model, job->document); - ev_window_handle_link (ev_window, dest); + if (ev_window->priv->dest) { + ev_window_handle_link (ev_window, ev_window->priv->dest); + /* Already unrefed by ev_link_action + * FIXME: link action should inc dest ref counting + * or not unref it at all + */ + ev_window->priv->dest = NULL; + } /* Restart the search after reloading */ widget = gtk_window_get_focus (GTK_WINDOW (ev_window)); @@ -1716,10 +1769,11 @@ ev_window_load_file_remote (EvWindow *ev_window, * it helps to resolve some mime types, say cbz. */ base_name = g_file_get_basename (source_file); - template = g_build_filename ("document.XXXXXX-%s", base_name, NULL); + template = g_strdup_printf ("document.XXXXXX-%s", base_name); g_free (base_name); tmp_file = ev_mkstemp_file (template, &err); + g_free (template); if (tmp_file == NULL) { ev_window_error_message (ev_window, err, "%s", _("Failed to load remote file.")); @@ -1738,7 +1792,8 @@ ev_window_load_file_remote (EvWindow *ev_window, target_file = g_file_new_for_uri (ev_window->priv->local_uri); g_file_copy_async (source_file, target_file, - 0, G_PRIORITY_DEFAULT, + G_FILE_COPY_OVERWRITE, + G_PRIORITY_DEFAULT, ev_window->priv->progress_cancellable, (GFileProgressCallback)window_open_file_copy_progress_cb, ev_window, @@ -2052,8 +2107,7 @@ ev_window_reload_document (EvWindow *ev_window, if (ev_window->priv->dest) g_object_unref (ev_window->priv->dest); - /* FIXME: save the scroll position too (xyz dest) */ - ev_window->priv->dest = dest ? g_object_ref (dest) : ev_link_dest_new_page (page); + ev_window->priv->dest = dest ? g_object_ref (dest) : NULL; if (ev_window->priv->local_uri) { ev_window_reload_remote (ev_window); @@ -2075,7 +2129,7 @@ file_open_dialog_response_cb (GtkWidget *chooser, ev_application_open_uri_list (EV_APP, uris, gtk_window_get_screen (GTK_WINDOW (ev_window)), - GDK_CURRENT_TIME); + gtk_get_current_event_time ()); g_slist_foreach (uris, (GFunc)g_free, NULL); g_slist_free (uris); @@ -2177,7 +2231,7 @@ ev_window_cmd_recent_file_activate (GtkAction *action, ev_application_open_uri_at_dest (EV_APP, uri, gtk_window_get_screen (GTK_WINDOW (window)), - NULL, 0, NULL, GDK_CURRENT_TIME); + NULL, 0, NULL, gtk_get_current_event_time ()); } static void @@ -2187,7 +2241,7 @@ ev_window_open_recent_action_item_activated (EvOpenRecentAction *action, { ev_application_open_uri_at_dest (EV_APP, uri, gtk_window_get_screen (GTK_WINDOW (window)), - NULL, 0, NULL, GDK_CURRENT_TIME); + NULL, 0, NULL, gtk_get_current_event_time ()); } static void @@ -2617,24 +2671,25 @@ get_print_settings_file (void) { GKeyFile *print_settings_file; gchar *filename; + GError *error = NULL; print_settings_file = g_key_file_new (); - filename = g_build_filename (ev_application_get_dot_dir (EV_APP), - EV_PRINT_SETTINGS_FILE, NULL); - if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) { - GError *error = NULL; - - g_key_file_load_from_file (print_settings_file, - filename, - G_KEY_FILE_KEEP_COMMENTS | - G_KEY_FILE_KEEP_TRANSLATIONS, - &error); - if (error) { + filename = g_build_filename (ev_application_get_dot_dir (EV_APP, FALSE), + EV_PRINT_SETTINGS_FILE, NULL); + if (!g_key_file_load_from_file (print_settings_file, + filename, + G_KEY_FILE_KEEP_COMMENTS | + G_KEY_FILE_KEEP_TRANSLATIONS, + &error)) { + + /* Don't warn if the file simply doesn't exist */ + if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) g_warning ("%s", error->message); - g_error_free (error); - } + + g_error_free (error); } + g_free (filename); return print_settings_file; @@ -2645,15 +2700,15 @@ save_print_setting_file (GKeyFile *key_file) { gchar *filename; gchar *data; - gssize data_length; + gsize data_length; GError *error = NULL; - filename = g_build_filename (ev_application_get_dot_dir (EV_APP), + filename = g_build_filename (ev_application_get_dot_dir (EV_APP, TRUE), EV_PRINT_SETTINGS_FILE, NULL); - data = g_key_file_to_data (key_file, (gsize *)&data_length, NULL); + data = g_key_file_to_data (key_file, &data_length, NULL); g_file_set_contents (filename, data, data_length, &error); if (error) { - g_warning ("%s", error->message); + g_warning ("Failed to save print settings: %s", error->message); g_error_free (error); } g_free (data); @@ -2907,6 +2962,13 @@ ev_window_print_operation_done (EvPrintOperation *op, print_settings = ev_print_operation_get_print_settings (op); ev_window_save_print_settings (ev_window, print_settings); + + if (ev_print_operation_get_embed_page_setup (op)) { + GtkPageSetup *page_setup; + + page_setup = ev_print_operation_get_default_page_setup (op); + ev_window_save_print_page_setup (ev_window, page_setup); + } } break; @@ -3080,6 +3142,13 @@ ev_window_print_range (EvWindow *ev_window, ev_print_operation_set_current_page (op, current_page); ev_print_operation_set_print_settings (op, print_settings); ev_print_operation_set_default_page_setup (op, print_page_setup); +#ifdef WITH_GCONF + ev_print_operation_set_embed_page_setup (op, !gconf_client_get_bool (ev_window->priv->gconf_client, + GCONF_LOCKDOWN_PRINT_SETUP, + NULL)); +#else + ev_print_operation_set_embed_page_setup (op, TRUE); +#endif g_object_unref (print_settings); g_object_unref (print_page_setup); @@ -3790,6 +3859,14 @@ ev_window_cmd_edit_rotate_right (GtkAction *action, EvWindow *ev_window) ev_document_model_set_rotation (ev_window->priv->model, rotation + 90); } +static void +ev_window_cmd_view_inverted_colors (GtkAction *action, EvWindow *ev_window) +{ + gboolean inverted_colors = ev_document_model_get_inverted_colors (ev_window->priv->model); + + ev_document_model_set_inverted_colors (ev_window->priv->model, !inverted_colors); +} + static void ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, @@ -3801,7 +3878,7 @@ ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, toolbar = EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar); egg_editable_toolbar_set_edit_mode (toolbar, FALSE); - toolbars_file = g_build_filename (ev_application_get_dot_dir (EV_APP), + toolbars_file = g_build_filename (ev_application_get_dot_dir (EV_APP, TRUE), "evince_toolbar.xml", NULL); egg_toolbars_model_save_toolbars (egg_editable_toolbar_get_model (toolbar), toolbars_file, "1.0"); @@ -3945,7 +4022,7 @@ ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window) gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (ev_window)), "ghelp:evince", - GDK_CURRENT_TIME, + gtk_get_current_event_time (), &error); if (error) { ev_window_error_message (ev_window, error, @@ -4111,7 +4188,37 @@ ev_window_rotation_changed_cb (EvDocumentModel *model, ev_metadata_set_int (window->priv->metadata, "rotation", rotation); - ev_window_refresh_window_thumbnail (window, rotation); + ev_window_refresh_window_thumbnail (window); +} + +static void +ev_window_update_inverted_colors_action (EvWindow *window) +{ + GtkAction *action; + + action = gtk_action_group_get_action (window->priv->action_group, "ViewInvertedColors"); + g_signal_handlers_block_by_func + (action, G_CALLBACK (ev_window_cmd_view_inverted_colors), window); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), + ev_document_model_get_inverted_colors (window->priv->model)); + g_signal_handlers_unblock_by_func + (action, G_CALLBACK (ev_window_cmd_view_inverted_colors), window); +} + +static void +ev_window_inverted_colors_changed_cb (EvDocumentModel *model, + GParamSpec *pspec, + EvWindow *window) +{ + gboolean inverted_colors = ev_document_model_get_inverted_colors (model); + + ev_window_update_inverted_colors_action (window); + + if (window->priv->metadata && !ev_window_is_empty (window)) + ev_metadata_set_boolean (window->priv->metadata, "inverted-colors", + inverted_colors); + + ev_window_refresh_window_thumbnail (window); } static void @@ -4383,6 +4490,39 @@ view_menu_image_popup (EvWindow *ev_window, gtk_action_set_visible (action, show_image); } +static void +view_menu_annot_popup (EvWindow *ev_window, + EvAnnotation *annot) +{ + GtkAction *action; + gboolean show_annot = FALSE; + + if (annot && EV_IS_ANNOTATION_ATTACHMENT (annot)) { + EvAttachment *attachment = EV_ANNOTATION_ATTACHMENT (annot)->attachment; + + if (attachment) { + show_annot = TRUE; + if (ev_window->priv->attach_list) { + g_list_foreach (ev_window->priv->attach_list, + (GFunc) g_object_unref, NULL); + g_list_free (ev_window->priv->attach_list); + ev_window->priv->attach_list = NULL; + } + ev_window->priv->attach_list = + g_list_prepend (ev_window->priv->attach_list, + g_object_ref (attachment)); + } + } + + action = gtk_action_group_get_action (ev_window->priv->attachment_popup_action_group, + "OpenAttachment"); + gtk_action_set_visible (action, show_annot); + + action = gtk_action_group_get_action (ev_window->priv->attachment_popup_action_group, + "SaveAttachmentAs"); + gtk_action_set_visible (action, show_annot); +} + static gboolean view_menu_popup_cb (EvView *view, GObject *object, @@ -4395,6 +4535,8 @@ view_menu_popup_cb (EvView *view, EV_IS_LINK (object) ? EV_LINK (object) : NULL); view_menu_image_popup (ev_window, EV_IS_IMAGE (object) ? EV_IMAGE (object) : NULL); + view_menu_annot_popup (ev_window, + EV_IS_ANNOTATION (object) ? EV_ANNOTATION (object) : NULL); gtk_menu_popup (GTK_MENU (ev_window->priv->view_popup), NULL, NULL, NULL, NULL, @@ -4690,7 +4832,14 @@ ev_window_dispose (GObject *object) g_source_remove (priv->setup_document_idle); priv->setup_document_idle = 0; } - + +#ifdef WITH_GCONF + if (priv->gconf_client) { + g_object_unref (priv->gconf_client); + priv->gconf_client = NULL; + } +#endif + if (priv->monitor) { g_object_unref (priv->monitor); priv->monitor = NULL; @@ -4973,6 +5122,7 @@ static const GtkActionEntry entries[] = { { "EditRotateRight", EV_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), "Right", NULL, G_CALLBACK (ev_window_cmd_edit_rotate_right) }, + /* View menu */ { "ViewZoomIn", GTK_STOCK_ZOOM_IN, NULL, "plus", N_("Enlarge the document"), @@ -5039,6 +5189,10 @@ static const GtkActionEntry entries[] = { G_CALLBACK (ev_window_cmd_scroll_forward) }, { "ShiftReturn", NULL, "", "Return", NULL, G_CALLBACK (ev_window_cmd_scroll_backward) }, + { "p", GTK_STOCK_GO_UP, "", "p", NULL, + G_CALLBACK (ev_window_cmd_go_previous_page) }, + { "n", GTK_STOCK_GO_DOWN, "", "n", NULL, + G_CALLBACK (ev_window_cmd_go_next_page) }, { "Plus", GTK_STOCK_ZOOM_IN, NULL, "plus", NULL, G_CALLBACK (ev_window_cmd_view_zoom_in) }, { "CtrlEqual", GTK_STOCK_ZOOM_IN, NULL, "equal", NULL, @@ -5092,6 +5246,10 @@ static const GtkToggleActionEntry toggle_entries[] = { { "ViewPageWidth", EV_STOCK_ZOOM_WIDTH, N_("Fit Page _Width"), NULL, N_("Make the current document fill the window width"), G_CALLBACK (ev_window_cmd_view_page_width) }, + { "ViewInvertedColors", EV_STOCK_INVERTED_COLORS, N_("_Inverted Colors"), "I", + N_("Show page contents with the colors inverted"), + G_CALLBACK (ev_window_cmd_view_inverted_colors) }, + }; /* Popups specific items */ @@ -5112,9 +5270,9 @@ static const GtkActionEntry view_popup_entries [] = { }; static const GtkActionEntry attachment_popup_entries [] = { - { "OpenAttachment", GTK_STOCK_OPEN, N_("_Open..."), NULL, + { "OpenAttachment", GTK_STOCK_OPEN, N_("_Open Attachment"), NULL, NULL, G_CALLBACK (ev_attachment_popup_cmd_open_attachment) }, - { "SaveAttachmentAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), NULL, + { "SaveAttachmentAs", GTK_STOCK_SAVE_AS, N_("_Save Attachment As..."), NULL, NULL, G_CALLBACK (ev_attachment_popup_cmd_save_attachment_as) }, }; @@ -5406,7 +5564,8 @@ launch_action (EvWindow *window, EvLinkAction *action) context = G_APP_LAUNCH_CONTEXT (gdk_app_launch_context_new ()); gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context), gtk_window_get_screen (GTK_WINDOW (window))); - gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context), GDK_CURRENT_TIME); + gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context), + gtk_get_current_event_time ()); file_list.data = file; if (!g_app_info_launch (app_info, &file_list, context, &error)) { @@ -5418,6 +5577,7 @@ launch_action (EvWindow *window, EvLinkAction *action) g_object_unref (app_info); g_object_unref (file); + /* FIXMEchpe: unref launch context? */ /* According to the PDF spec filename can be an executable. I'm not sure allowing to launch executables is a good idea though. -- marco */ @@ -5435,25 +5595,44 @@ launch_external_uri (EvWindow *window, EvLinkAction *action) gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context), gtk_window_get_screen (GTK_WINDOW (window))); gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context), - GDK_CURRENT_TIME); + gtk_get_current_event_time ()); if (!g_strstr_len (uri, strlen (uri), "://") && !g_str_has_prefix (uri, "mailto:")) { - gchar *http; - - /* Not a valid uri, assuming it's http */ - http = g_strdup_printf ("http://%s", uri); - ret = g_app_info_launch_default_for_uri (http, NULL, &error); - g_free (http); + gchar *new_uri; + + /* Not a valid uri, assume http if it starts with www */ + if (g_str_has_prefix (uri, "www.")) { + new_uri = g_strdup_printf ("http://%s", uri); + } else { + GFile *file, *parent; + + file = g_file_new_for_uri (window->priv->uri); + parent = g_file_get_parent (file); + g_object_unref (file); + if (parent) { + gchar *parent_uri = g_file_get_uri (parent); + + new_uri = g_build_filename (parent_uri, uri, NULL); + g_free (parent_uri); + g_object_unref (parent); + } else { + new_uri = g_strdup_printf ("file:///%s", uri); + } + } + ret = g_app_info_launch_default_for_uri (new_uri, context, &error); + g_free (new_uri); } else { - ret = g_app_info_launch_default_for_uri (uri, NULL, &error); + ret = g_app_info_launch_default_for_uri (uri, context, &error); } - + if (ret == FALSE) { - ev_window_error_message (window, error, + ev_window_error_message (window, error, "%s", _("Unable to open external link")); g_error_free (error); } + + /* FIXMEchpe: unref launch context? */ } static void @@ -5473,7 +5652,7 @@ open_remote_link (EvWindow *window, EvLinkAction *action) ev_link_action_get_dest (action), 0, NULL, - GDK_CURRENT_TIME); + gtk_get_current_event_time ()); g_free (uri); } @@ -5753,7 +5932,7 @@ ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window) attachment = (EvAttachment *) l->data; - ev_attachment_open (attachment, screen, GDK_CURRENT_TIME, &error); + ev_attachment_open (attachment, screen, gtk_get_current_event_time (), &error); if (error) { ev_window_error_message (window, error, @@ -5922,7 +6101,7 @@ get_toolbars_model (void) toolbars_model = egg_toolbars_model_new (); - toolbars_file = g_build_filename (ev_application_get_dot_dir (EV_APP), + toolbars_file = g_build_filename (ev_application_get_dot_dir (EV_APP, FALSE), "evince_toolbar.xml", NULL); toolbars_path = g_build_filename (ev_application_get_data_dir (EV_APP), "evince-toolbar.xml", NULL); @@ -5930,8 +6109,8 @@ get_toolbars_model (void) if (!egg_toolbars_model_load_toolbars (toolbars_model, toolbars_file)) { egg_toolbars_model_load_toolbars (toolbars_model, toolbars_path); + goto skip_conversion; } - g_free (toolbars_path); /* Open item doesn't exist anymore, * convert it to OpenRecent for compatibility @@ -5948,7 +6127,10 @@ get_toolbars_model (void) break; } } + + skip_conversion: g_free (toolbars_file); + g_free (toolbars_path); egg_toolbars_model_set_flags (toolbars_model, 0, EGG_TB_MODEL_NOT_REMOVABLE); @@ -5962,6 +6144,7 @@ ev_window_init (EvWindow *ev_window) GtkAccelGroup *accel_group; GError *error = NULL; GtkWidget *sidebar_widget; + GtkWidget *menuitem; EggToolbarsModel *toolbars_model; GObject *mpkeys; gchar *ui_path; @@ -6031,7 +6214,17 @@ ev_window_init (EvWindow *ev_window) g_error_free (error); } g_free (ui_path); - + +#if GTK_CHECK_VERSION (2, 17, 4) + { + GtkAction *action; + + action = gtk_action_group_get_action (ev_window->priv->action_group, + "FilePageSetup"); + g_object_set (action, "visible", FALSE, "sensitive", FALSE, NULL); + } +#endif + ev_window->priv->recent_manager = gtk_recent_manager_get_default (); ev_window->priv->recent_action_group = NULL; ev_window->priv->recent_ui_id = 0; @@ -6046,6 +6239,12 @@ ev_window_init (EvWindow *ev_window) gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), ev_window->priv->menubar, FALSE, FALSE, 0); + menuitem = gtk_ui_manager_get_widget (ev_window->priv->ui_manager, + "/MainMenu/EditMenu/EditRotateLeftMenu"); + gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE); + menuitem = gtk_ui_manager_get_widget (ev_window->priv->ui_manager, + "/MainMenu/EditMenu/EditRotateRightMenu"); + gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE); toolbars_model = get_toolbars_model (); ev_window->priv->toolbar = GTK_WIDGET @@ -6217,6 +6416,10 @@ ev_window_init (EvWindow *ev_window) ev_window); /* Connect to view signals */ + g_signal_connect (ev_window->priv->model, + "notify::inverted-colors", + G_CALLBACK (ev_window_inverted_colors_changed_cb), + ev_window); g_signal_connect (ev_window->priv->view, "notify::has-selection", G_CALLBACK (ev_window_has_selection_changed_cb),