39 #include <glib/gstdio.h>
40 #include <glib/gi18n.h>
80 #include "ev-view-type-builtins.h"
94 #include "ev-gdbus-generated.h"
98 #ifdef GDK_WINDOWING_X11
100 #include <X11/extensions/XInput2.h>
229 EvEvinceWindow *skeleton;
230 gchar *dbus_object_path;
242 #define EV_WINDOW_GET_PRIVATE(object) \
243 (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_WINDOW, EvWindowPrivate))
245 #define EV_WINDOW_IS_PRESENTATION(w) (w->priv->presentation_view != NULL)
247 #define GS_LOCKDOWN_SCHEMA_NAME "org.gnome.desktop.lockdown"
248 #define GS_LOCKDOWN_SAVE "disable-save-to-disk"
249 #define GS_LOCKDOWN_PRINT "disable-printing"
250 #define GS_LOCKDOWN_PRINT_SETUP "disable-print-setup"
253 #define EV_WINDOW_DBUS_OBJECT_PATH "/org/gnome/evince/Window/%d"
254 #define EV_WINDOW_DBUS_INTERFACE "org.gnome.evince.Window"
257 #define GS_SCHEMA_NAME "org.gnome.Evince"
258 #define GS_OVERRIDE_RESTRICTIONS "override-restrictions"
259 #define GS_PAGE_CACHE_SIZE "page-cache-size"
260 #define GS_AUTO_RELOAD "auto-reload"
261 #define GS_LAST_DOCUMENT_DIRECTORY "document-directory"
262 #define GS_LAST_PICTURES_DIRECTORY "pictures-directory"
263 #define GS_ALLOW_LINKS_CHANGE_ZOOM "allow-links-change-zoom"
265 #define SIDEBAR_DEFAULT_SIZE 132
266 #define LINKS_SIDEBAR_ID "links"
267 #define THUMBNAILS_SIDEBAR_ID "thumbnails"
268 #define ATTACHMENTS_SIDEBAR_ID "attachments"
269 #define LAYERS_SIDEBAR_ID "layers"
270 #define ANNOTS_SIDEBAR_ID "annotations"
271 #define BOOKMARKS_SIDEBAR_ID "bookmarks"
273 #define EV_PRINT_SETTINGS_FILE "print-settings"
274 #define EV_PRINT_SETTINGS_GROUP "Print Settings"
275 #define EV_PAGE_SETUP_GROUP "Page Setup"
277 #define EV_TOOLBARS_FILENAME "evince-toolbar.xml"
279 #define TOOLBAR_RESOURCE_PATH "/org/gnome/evince/shell/ui/toolbar.xml"
281 #define FULLSCREEN_POPUP_TIMEOUT 2
282 #define FULLSCREEN_TRANSITION_DURATION 1000
285 GTK_PRINT_SETTINGS_COLLATE,
286 GTK_PRINT_SETTINGS_REVERSE,
287 GTK_PRINT_SETTINGS_NUMBER_UP,
288 GTK_PRINT_SETTINGS_SCALE,
289 GTK_PRINT_SETTINGS_PRINT_PAGES,
290 GTK_PRINT_SETTINGS_PAGE_RANGES,
291 GTK_PRINT_SETTINGS_PAGE_SET,
292 GTK_PRINT_SETTINGS_OUTPUT_URI
316 const char *filename);
319 gboolean unfullscreen_window);
322 gboolean unfullscreen_window);
386 screen = gtk_window_get_screen (GTK_WINDOW (window));
403 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window), name);
404 g_simple_action_set_enabled (G_SIMPLE_ACTION (action), enabled);
413 gboolean has_document =
FALSE;
414 gboolean ok_to_print =
TRUE;
415 gboolean ok_to_copy =
TRUE;
416 gboolean has_properties =
TRUE;
417 gboolean override_restrictions =
TRUE;
418 gboolean can_get_text =
FALSE;
419 gboolean can_find =
FALSE;
420 gboolean can_find_in_page;
421 gboolean can_annotate =
FALSE;
423 gboolean recent_view_mode;
424 gboolean dual_mode =
FALSE;
425 gboolean has_pages =
FALSE;
426 int n_pages = 0, page = -1;
433 has_pages = n_pages > 0;
437 if (!info || info->fields_mask == 0) {
438 has_properties =
FALSE;
454 override_restrictions =
484 ok_to_copy && !recent_view_mode);
486 ok_to_print && !recent_view_mode);
488 has_document && has_properties &&
491 has_document && !recent_view_mode);
497 has_document && !recent_view_mode);
499 has_document && !recent_view_mode);
503 can_get_text && !recent_view_mode);
527 has_pages && !recent_view_mode);
566 has_pages && can_find_in_page &&
569 has_pages && can_find_in_page &&
577 !presentation_mode &&
582 !presentation_mode &&
612 !presentation_mode &&
619 g_assert (GTK_IS_WIDGET (widget));
622 gtk_widget_show (widget);
624 gtk_widget_hide (widget);
631 gboolean toolbar, sidebar;
632 gboolean presentation;
660 const gchar *mode = NULL;
662 action = g_action_map_lookup_action (G_ACTION_MAP (window),
"sizing-mode");
679 g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_string (mode));
719 gtk_box_reorder_child (GTK_BOX (window->
priv->
main_box),
743 if (window->priv->message_area)
746 va_start (args, format);
747 msg = g_strdup_vprintf (format, args);
759 g_signal_connect (area,
"response",
762 gtk_widget_show (area);
775 if (window->priv->message_area)
778 va_start (args, format);
779 msg = g_strdup_vprintf (format, args);
789 g_signal_connect (area,
"response",
792 gtk_widget_show (area);
837 gboolean retval =
FALSE;
839 gtk_tree_model_get (tree_model, iter,
850 g_object_unref (link);
871 gtk_tree_model_foreach (model,
875 g_object_unref (model);
890 const gchar *link_title;
907 title = g_strdup_printf (
_(
"Page %s"), page_label);
916 g_object_unref (new_link);
952 gchar *caret_position;
957 position = g_variant_new (
"(uu)", page, offset);
958 caret_position = g_variant_print (position,
FALSE);
959 g_variant_unref (position);
962 g_free (caret_position);
980 GtkWidget *current_page;
984 "current_page", ¤t_page,
1000 g_assert_not_reached();
1003 g_object_unref (current_page);
1010 const gchar *page_id)
1065 g_settings_get_boolean (settings,
"show-sidebar"));
1071 g_settings_get_int (settings,
"sidebar-size"));
1074 gchar *sidebar_page_id = g_settings_get_string (settings,
"sidebar-page");
1077 g_free (sidebar_page_id);
1083 g_settings_get_boolean (settings,
"continuous"));
1087 g_settings_get_boolean (settings,
"dual-page"));
1091 g_settings_get_boolean (settings,
"dual-page-odd-left"));
1095 g_settings_get_boolean (settings,
"inverted-colors"));
1098 EvSizingMode mode = g_settings_get_enum (settings,
"sizing-mode");
1099 GEnumValue *enum_value = g_enum_get_value (g_type_class_peek (EV_TYPE_SIZING_MODE), mode);
1106 g_settings_get_double (settings,
"zoom"));
1111 g_settings_get_boolean (settings,
"fullscreen"));
1118 gboolean show_toolbar;
1119 gboolean show_sidebar;
1141 gtk_paned_set_position (GTK_PANED (window->
priv->
hpaned), sidebar_size);
1154 gboolean inverted_colors =
FALSE;
1155 gboolean continuous =
FALSE;
1156 gboolean dual_page =
FALSE;
1157 gboolean dual_page_odd_left =
FALSE;
1158 gboolean fullscreen =
FALSE;
1171 GEnumValue *enum_value;
1173 enum_value = g_enum_get_value_by_nick
1174 (g_type_class_peek (EV_TYPE_SIZING_MODE), sizing_mode);
1238 gdouble width_ratio;
1239 gdouble height_ratio;
1252 if (page == n_pages - 1)
1262 g_settings_get (window->
priv->
default_settings,
"window-ratio",
"(dd)", &width_ratio, &height_ratio);
1263 if (width_ratio > 0. && height_ratio > 0.) {
1264 gdouble document_width;
1265 gdouble document_height;
1268 gint request_height;
1271 &document_width, &document_height);
1273 request_width = (gint)(width_ratio * document_width + 0.5);
1274 request_height = (gint)(height_ratio * document_height + 0.5);
1276 screen = gtk_window_get_screen (GTK_WINDOW (window));
1278 request_width = MIN (request_width, gdk_screen_get_width (screen));
1279 request_height = MIN (request_height, gdk_screen_get_height (screen));
1282 if (request_width > 0 && request_height > 0) {
1283 gtk_window_resize (GTK_WINDOW (window),
1304 gtk_window_maximize (GTK_WINDOW (window));
1307 gtk_window_unmaximize (GTK_WINDOW (window));
1313 gtk_window_move (GTK_WINDOW (window), x, y);
1318 gtk_window_resize (GTK_WINDOW (window), width, height);
1325 gboolean presentation;
1338 gboolean caret_navigation;
1339 gchar *caret_position;
1344 position = g_variant_parse (G_VARIANT_TYPE (
"(uu)"), caret_position, NULL, NULL, NULL);
1348 g_variant_get (position,
"(uu)", &page, &offset);
1349 g_variant_unref (position);
1366 guint page_cache_mb;
1370 page_cache_mb * 1024 * 1024);
1391 g_settings_get_boolean (settings,
"show-sidebar"));
1395 gtk_paned_set_position (GTK_PANED (ev_window->
priv->
hpaned),
1396 g_settings_get_int (settings,
"sidebar-size"));
1416 #ifdef HAVE_DESKTOP_SCHEMAS
1418 lockdown_changed (GSettings *lockdown,
1465 #ifdef HAVE_DESKTOP_SCHEMAS
1470 G_CALLBACK (lockdown_changed),
1488 GtkSearchEntry *entry;
1499 else if (!gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (ev_window->
priv->
search_bar)))
1500 gtk_widget_grab_focus (ev_window->
priv->
view);
1540 ev_window_warning_message (ev_window,
"%s",
1541 _(
"The document contains no pages"));
1543 ev_window_warning_message (ev_window,
"%s",
1544 _(
"The document contains only empty pages"));
1585 const gchar *password;
1641 g_object_unref (link_action);
1642 g_object_unref (link);
1662 gchar *display_name;
1664 g_assert (job_load->
uri);
1673 ev_window_emit_doc_loaded (ev_window);
1684 GPasswordSave flags;
1694 g_clear_object (&ev_window->
priv->
dest);
1709 g_signal_connect_swapped (ev_window->
priv->
monitor,
"changed",
1753 text = g_uri_unescape_string (job_load->
uri, NULL);
1754 display_name = g_markup_escape_text (text, -1);
1756 ev_window_error_message (ev_window, job->error,
1757 _(
"Unable to open document “%s”."),
1759 g_free (display_name);
1772 g_object_unref (ev_window->
priv->
dest);
1783 g_clear_object (&ev_window->
priv->
dest);
1787 if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (ev_window->
priv->
search_bar)))
1844 GSourceFunc
function)
1849 g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
1869 if (response == GTK_RESPONSE_CANCEL)
1879 gchar *display_name;
1884 text = g_uri_unescape_string (ev_window->
priv->
uri, NULL);
1885 display_name = g_markup_escape_text (text, -1);
1887 text = g_strdup_printf (
_(
"Loading document from “%s”"),
1895 GTK_RESPONSE_CANCEL,
1897 g_signal_connect (area,
"response",
1900 gtk_widget_show (area);
1904 g_free (display_name);
1914 gchar *display_name;
1919 text = g_uri_unescape_string (ev_window->
priv->
local_uri, NULL);
1920 display_name = g_markup_escape_text (text, -1);
1922 ev_window_error_message (ev_window, error,
1923 _(
"Unable to open document “%s”."),
1925 g_free (display_name);
1933 GAsyncResult *async_result,
1937 GError *error = NULL;
1939 info = g_file_query_info_finish (source, async_result, &error);
1943 g_error_free (error);
1947 g_file_info_get_modification_time (info, &mtime);
1949 g_object_unref (info);
1952 g_object_unref (source);
1957 GAsyncResult *async_result,
1960 GError *error = NULL;
1962 g_file_mount_enclosing_volume_finish (source, async_result, &error);
1966 g_object_unref (source);
1967 g_error_free (error);
1977 GAsyncResult *async_result,
1980 GError *error = NULL;
1985 g_file_copy_finish (source, async_result, &error);
1988 g_file_query_info_async (source,
1989 G_FILE_ATTRIBUTE_TIME_MODIFIED,
1990 0, G_PRIORITY_DEFAULT,
1997 if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_MOUNTED)) {
1998 GMountOperation *operation;
2000 operation = gtk_mount_operation_new (GTK_WINDOW (ev_window));
2001 g_file_mount_enclosing_volume (source,
2006 g_object_unref (operation);
2007 }
else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
2010 g_free (ev_window->
priv->
uri);
2012 g_object_unref (source);
2017 g_object_unref (source);
2020 g_error_free (error);
2025 goffset total_bytes,
2034 if (total_bytes <= 0)
2037 fraction = n_bytes / (gdouble)total_bytes;
2038 status = g_strdup_printf (
_(
"Downloading document (%d%%)"),
2039 (gint)(fraction * 100));
2056 char *base_name, *
template;
2063 base_name = g_file_get_basename (source_file);
2064 template = g_strdup_printf (
"document.XXXXXX-%s", base_name);
2069 if (tmp_file == NULL) {
2070 ev_window_error_message (ev_window, err,
2071 "%s",
_(
"Failed to load remote file."));
2077 g_object_unref (tmp_file);
2085 target_file = g_file_new_for_uri (ev_window->
priv->
local_uri);
2086 g_file_copy_async (source_file, target_file,
2087 G_FILE_COPY_OVERWRITE,
2094 g_object_unref (target_file);
2105 const gchar *search_string)
2113 g_strdup (search_string) : NULL;
2116 g_ascii_strcasecmp (ev_window->
priv->
uri, uri) == 0) {
2133 g_free (ev_window->
priv->
uri);
2134 ev_window->
priv->
uri = g_strdup (uri);
2141 source_file = g_file_new_for_uri (uri);
2153 g_signal_connect_swapped (ev_window->
priv->
bookmarks,
"changed",
2162 g_object_unref (ev_window->
priv->
dest);
2163 ev_window->
priv->
dest = dest ? g_object_ref (dest) : NULL;
2174 if (!g_file_is_native (source_file) && !ev_window->
priv->
local_uri) {
2178 g_object_unref (source_file);
2188 const gchar *search_string)
2203 g_free (ev_window->
priv->
uri);
2221 g_object_unref (link_action);
2222 g_object_unref (link);
2238 GtkSearchEntry *entry;
2242 gtk_entry_set_text (GTK_ENTRY (entry), search_string);
2247 g_signal_connect_swapped (ev_window->
priv->
monitor,
"changed",
2265 gtk_box_pack_start (GTK_BOX (ev_window->
priv->
main_box),
2310 text = g_strdup_printf (
_(
"Reloading document from %s"),
2317 GTK_RESPONSE_CANCEL,
2319 g_signal_connect (area,
"response",
2322 gtk_widget_show (area);
2331 GAsyncResult *async_result,
2334 GError *error = NULL;
2338 g_file_copy_finish (remote, async_result, &error);
2340 if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
2341 ev_window_error_message (ev_window, error,
2342 "%s",
_(
"Failed to reload document."));
2343 g_error_free (error);
2348 g_object_unref (remote);
2353 goffset total_bytes,
2362 if (total_bytes <= 0)
2365 fraction = n_bytes / (gdouble)total_bytes;
2366 status = g_strdup_printf (
_(
"Downloading document (%d%%)"),
2367 (gint)(fraction * 100));
2379 GAsyncResult *async_result,
2384 GError *error = NULL;
2386 info = g_file_query_info_finish (remote, async_result, &error);
2388 g_error_free (error);
2389 g_object_unref (remote);
2395 g_file_info_get_modification_time (info, &mtime);
2404 target_file = g_file_new_for_uri (ev_window->
priv->
local_uri);
2405 g_file_copy_async (remote, target_file,
2406 G_FILE_COPY_OVERWRITE,
2413 g_object_unref (target_file);
2417 g_object_unref (remote);
2421 g_object_unref (info);
2429 remote = g_file_new_for_uri (ev_window->
priv->
uri);
2431 g_file_query_info_async (remote,
2432 G_FILE_ATTRIBUTE_TIME_MODIFIED,
2433 0, G_PRIORITY_DEFAULT,
2447 g_object_unref (ev_window->
priv->
dest);
2448 ev_window->
priv->
dest = dest ? g_object_ref (dest) : NULL;
2457 static const gchar *
2460 switch (directory) {
2461 case G_USER_DIRECTORY_PICTURES:
2463 case G_USER_DIRECTORY_DOCUMENTS:
2471 GtkFileChooser *file_chooser,
2473 GUserDirectory directory)
2481 if (folder_uri == NULL && uri != NULL) {
2482 GFile *file, *parent;
2484 file = g_file_new_for_uri (uri);
2485 parent = g_file_get_parent (file);
2486 g_object_unref (file);
2488 folder_uri = g_file_get_uri (parent);
2489 g_object_unref (parent);
2494 gtk_file_chooser_set_current_folder_uri (file_chooser, folder_uri);
2496 dir = g_get_user_special_dir (directory);
2497 gtk_file_chooser_set_current_folder (file_chooser,
2498 dir ? dir : g_get_home_dir ());
2501 g_free (folder_uri);
2506 GtkFileChooser *file_chooser,
2507 GUserDirectory directory)
2509 gchar *uri, *folder;
2511 folder = gtk_file_chooser_get_current_folder (file_chooser);
2512 if (g_strcmp0 (folder, g_get_user_special_dir (directory)) == 0) {
2516 uri = gtk_file_chooser_get_current_folder_uri (file_chooser);
2531 if (response_id == GTK_RESPONSE_OK) {
2535 G_USER_DIRECTORY_DOCUMENTS);
2537 uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (chooser));
2540 gtk_window_get_screen (GTK_WINDOW (ev_window)),
2541 gtk_get_current_event_time ());
2543 g_slist_foreach (uris, (GFunc)g_free, NULL);
2544 g_slist_free (uris);
2547 gtk_widget_destroy (chooser);
2552 GVariant *parameter,
2558 chooser = gtk_file_chooser_dialog_new (
_(
"Open Document"),
2559 GTK_WINDOW (window),
2560 GTK_FILE_CHOOSER_ACTION_OPEN,
2562 GTK_RESPONSE_CANCEL,
2563 GTK_STOCK_OPEN, GTK_RESPONSE_OK,
2567 gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (chooser),
TRUE);
2568 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser),
FALSE);
2571 NULL, G_USER_DIRECTORY_DOCUMENTS);
2573 g_signal_connect (chooser,
"response",
2577 gtk_widget_show (chooser);
2593 gtk_window_present (GTK_WINDOW (new_window));
2598 GVariant *parameter,
2621 ev_window =
EV_WINDOW (g_object_get_data (G_OBJECT (dst),
"ev-window"));
2627 save_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dst),
"save-type"));
2628 uri = g_file_get_uri (dst);
2629 switch (save_type) {
2631 text = g_strdup_printf (
_(
"Saving document to %s"), uri);
2634 text = g_strdup_printf (
_(
"Saving attachment to %s"), uri);
2637 text = g_strdup_printf (
_(
"Saving image to %s"), uri);
2640 g_assert_not_reached ();
2648 GTK_RESPONSE_CANCEL,
2650 g_signal_connect (area,
"response",
2653 gtk_widget_show (area);
2662 GAsyncResult *async_result,
2666 GError *error = NULL;
2668 ev_window =
EV_WINDOW (g_object_get_data (G_OBJECT (dst),
"ev-window"));
2671 if (g_file_copy_finish (src, async_result, &error)) {
2676 if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
2679 name = g_file_get_basename (dst);
2680 ev_window_error_message (ev_window, error,
2681 _(
"The file could not be saved as “%s”."),
2686 g_error_free (error);
2691 goffset total_bytes,
2699 ev_window =
EV_WINDOW (g_object_get_data (G_OBJECT (dst),
"ev-window"));
2704 if (total_bytes <= 0)
2707 fraction = n_bytes / (gdouble)total_bytes;
2708 save_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dst),
"save-type"));
2710 switch (save_type) {
2712 status = g_strdup_printf (
_(
"Uploading document (%d%%)"),
2713 (gint)(fraction * 100));
2716 status = g_strdup_printf (
_(
"Uploading attachment (%d%%)"),
2717 (gint)(fraction * 100));
2720 status = g_strdup_printf (
_(
"Uploading image (%d%%)"),
2721 (gint)(fraction * 100));
2724 g_assert_not_reached ();
2742 g_object_set_data (G_OBJECT (dst),
"ev-window", ev_window);
2743 g_object_set_data (G_OBJECT (dst),
"save-type", GINT_TO_POINTER (save_type));
2744 g_file_copy_async (src, dst,
2745 G_FILE_COPY_OVERWRITE,
2753 g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
2767 g_signal_handlers_disconnect_by_func (ev_window->
priv->
save_job,
2780 ev_window_error_message (window, job->error,
2781 _(
"The file could not be saved as “%s”."),
2797 if (response_id != GTK_RESPONSE_OK) {
2798 gtk_widget_destroy (fc);
2803 G_USER_DIRECTORY_DOCUMENTS);
2805 uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
2814 g_signal_connect (ev_window->
priv->
save_job,
"finished",
2821 gtk_widget_destroy (fc);
2831 fc = gtk_file_chooser_dialog_new (
2833 GTK_WINDOW (ev_window), GTK_FILE_CHOOSER_ACTION_SAVE,
2834 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
2835 GTK_STOCK_SAVE, GTK_RESPONSE_OK,
2839 gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
2840 gtk_dialog_set_alternative_button_order (GTK_DIALOG (fc),
2842 GTK_RESPONSE_CANCEL,
2845 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fc),
FALSE);
2846 gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc),
TRUE);
2847 file = g_file_new_for_uri (ev_window->
priv->
uri);
2848 base_name = g_file_get_basename (file);
2849 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc), base_name);
2850 g_object_unref (file);
2855 G_USER_DIRECTORY_DOCUMENTS);
2857 g_signal_connect (fc,
"response",
2861 gtk_widget_show (fc);
2866 GVariant *parameter,
2876 GVariant *parameter,
2883 char *unescaped_uri;
2884 GError *error = NULL;
2887 unescaped_uri = g_uri_unescape_string (uri, NULL);
2888 command = g_strdup_printf (
"%s \"%s\"",
nautilus_sendto, unescaped_uri);
2889 g_free (unescaped_uri);
2890 app_info = g_app_info_create_from_commandline (command, NULL, 0, &error);
2892 GdkAppLaunchContext *context;
2895 screen = gtk_window_get_screen (GTK_WINDOW (ev_window));
2896 context = gdk_display_get_app_launch_context (gdk_screen_get_display (screen));
2897 gdk_app_launch_context_set_screen (context, screen);
2898 gdk_app_launch_context_set_timestamp (context, gtk_get_current_event_time ());
2899 g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (context), &error);
2900 g_object_unref (context);
2902 g_object_unref (app_info);
2907 ev_window_error_message (ev_window, error,
"%s",
2908 _(
"Could not send current document"));
2909 g_error_free (error);
2915 GVariant *parameter,
2921 GAppInfo *app = NULL;
2922 GdkAppLaunchContext *context;
2923 GdkDisplay *display;
2927 GError *error = NULL;
2929 app = g_app_info_get_default_for_type (
"inode/directory",
FALSE);
2935 file = g_file_new_for_uri (window->
priv->
uri);
2936 list.next = list.prev = NULL;
2939 display = gtk_widget_get_display (GTK_WIDGET (window));
2940 screen = gtk_widget_get_screen (GTK_WIDGET (window));
2941 timestamp = gtk_get_current_event_time ();
2943 context = gdk_display_get_app_launch_context (display);
2944 gdk_app_launch_context_set_screen (context, screen);
2945 gdk_app_launch_context_set_timestamp (context, timestamp);
2947 g_app_info_launch (app, &list,
2948 G_APP_LAUNCH_CONTEXT (context), &error);
2950 if (error != NULL) {
2953 uri = g_file_get_uri (file);
2954 g_warning (
"Could not show containing folder for \"%s\": %s",
2955 uri, error->message);
2957 g_error_free (error);
2961 g_object_unref (context);
2962 g_object_unref (app);
2968 GKeyFile *print_settings_file;
2970 GError *error = NULL;
2972 print_settings_file = g_key_file_new ();
2976 if (!g_key_file_load_from_file (print_settings_file,
2978 G_KEY_FILE_KEEP_COMMENTS |
2979 G_KEY_FILE_KEEP_TRANSLATIONS,
2983 if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
2984 g_warning (
"%s", error->message);
2986 g_error_free (error);
2991 return print_settings_file;
3000 GError *error = NULL;
3004 data = g_key_file_to_data (key_file, &data_length, NULL);
3005 g_file_set_contents (filename, data, data_length, &error);
3007 g_warning (
"Failed to save print settings: %s", error->message);
3008 g_error_free (error);
3036 value = gtk_print_settings_get (print_settings,
3044 g_key_file_free (key_file);
3049 GtkPageSetup *page_setup)
3058 "page-setup-orientation", NULL);
3060 "page-setup-margin-top", NULL);
3062 "page-setup-margin-bottom", NULL);
3064 "page-setup-margin-left", NULL);
3066 "page-setup-margin-right", NULL);
3069 g_key_file_free (key_file);
3076 gtk_page_setup_get_orientation (page_setup));
3078 gtk_page_setup_get_top_margin (page_setup, GTK_UNIT_MM));
3080 gtk_page_setup_get_bottom_margin (page_setup, GTK_UNIT_MM));
3082 gtk_page_setup_get_left_margin (page_setup, GTK_UNIT_MM));
3084 gtk_page_setup_get_right_margin (page_setup, GTK_UNIT_MM));
3098 gchar *value = NULL;
3102 gtk_print_settings_set (print_settings,
3109 GtkPageSetup *page_setup)
3112 gdouble double_value;
3113 GtkPaperSize *paper_size = gtk_page_setup_get_paper_size (page_setup);
3118 gtk_page_setup_set_orientation (page_setup, int_value);
3120 gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_PORTRAIT);
3125 gtk_page_setup_set_top_margin (page_setup, double_value, GTK_UNIT_MM);
3127 gtk_page_setup_set_top_margin (page_setup,
3128 gtk_paper_size_get_default_top_margin (paper_size, GTK_UNIT_MM),
3134 gtk_page_setup_set_bottom_margin (page_setup, double_value, GTK_UNIT_MM);
3136 gtk_page_setup_set_bottom_margin (page_setup,
3137 gtk_paper_size_get_default_bottom_margin (paper_size, GTK_UNIT_MM),
3143 gtk_page_setup_set_left_margin (page_setup, double_value, GTK_UNIT_MM);
3145 gtk_page_setup_set_left_margin (page_setup,
3146 gtk_paper_size_get_default_left_margin (paper_size, GTK_UNIT_MM),
3152 gtk_page_setup_set_right_margin (page_setup, double_value, GTK_UNIT_MM);
3154 gtk_page_setup_set_right_margin (page_setup,
3155 gtk_paper_size_get_default_right_margin (paper_size, GTK_UNIT_MM),
3160 static GtkPrintSettings *
3167 gtk_print_settings_new ();
3169 return print_settings ? print_settings : gtk_print_settings_new ();
3172 static GtkPageSetup *
3175 GtkPageSetup *page_setup;
3179 gtk_page_setup_new ();
3181 return page_setup ? page_setup : gtk_page_setup_new ();
3213 text = g_strdup_printf (ngettext (
"%d pending job in queue",
3214 "%d pending jobs in queue",
3215 n_jobs - 1), n_jobs - 1);
3226 gtk_widget_destroy (window);
3233 GtkPrintOperationResult result,
3239 case GTK_PRINT_OPERATION_RESULT_APPLY: {
3246 GtkPageSetup *page_setup;
3254 case GTK_PRINT_OPERATION_RESULT_ERROR: {
3256 GError *error = NULL;
3265 dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
3266 GTK_DIALOG_DESTROY_WITH_PARENT,
3269 "%s",
_(
"Failed to print document"));
3270 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
3271 "%s", error->message);
3272 g_signal_connect (dialog,
"response",
3273 G_CALLBACK (gtk_widget_destroy),
3275 gtk_widget_show (dialog);
3277 g_error_free (error);
3280 case GTK_PRINT_OPERATION_RESULT_CANCEL:
3286 g_object_unref (op);
3300 if (response == GTK_RESPONSE_CANCEL) {
3306 gtk_widget_hide (GTK_WIDGET (area));
3314 const gchar *status;
3322 const gchar *job_name;
3326 text = g_strdup_printf (
_(
"Printing job “%s”"), job_name);
3333 GTK_RESPONSE_CANCEL,
3336 g_signal_connect (area,
"response",
3339 gtk_widget_show (area);
3368 GKeyFile *print_settings_file;
3370 GtkPageSetup *print_page_setup;
3372 gint document_last_page;
3373 gboolean embed_page_setup;
3374 gchar *output_basename;
3375 gchar *unescaped_basename;
3376 const gchar *document_uri;
3387 g_warning (
"%s",
"Printing is not supported for document\n");
3391 g_signal_connect (op,
"begin_print",
3393 (gpointer)ev_window);
3394 g_signal_connect (op,
"status_changed",
3396 (gpointer)ev_window);
3397 g_signal_connect (op,
"done",
3399 (gpointer)ev_window);
3412 if (first_page != 1 || last_page != document_last_page) {
3416 range.start = first_page - 1;
3417 range.end = last_page - 1;
3419 gtk_print_settings_set_print_pages (print_settings,
3420 GTK_PRINT_PAGES_RANGES);
3421 gtk_print_settings_set_page_ranges (print_settings,
3426 output_basename = g_path_get_basename (document_uri);
3427 dot = g_strrstr (output_basename,
".");
3431 unescaped_basename = g_uri_unescape_string (output_basename, NULL);
3433 gtk_print_settings_set (print_settings,
3434 GTK_PRINT_SETTINGS_OUTPUT_BASENAME,
3435 unescaped_basename);
3436 g_free (unescaped_basename);
3437 g_free (output_basename);
3443 embed_page_setup = ev_window->priv->lockdown_settings ?
3444 !g_settings_get_boolean (ev_window->priv->lockdown_settings,
3449 g_object_unref (print_settings);
3450 g_object_unref (print_page_setup);
3451 g_key_file_free (print_settings_file);
3485 g_object_add_weak_pointer (G_OBJECT (ev_window->
priv->
properties),
3487 gtk_window_set_transient_for (GTK_WINDOW (ev_window->
priv->
properties),
3488 GTK_WINDOW (ev_window));
3501 gtk_widget_destroy (GTK_WIDGET (dialog));
3503 if (response == GTK_RESPONSE_YES)
3512 gtk_widget_destroy (GTK_WIDGET (dialog));
3515 case GTK_RESPONSE_YES:
3518 case GTK_RESPONSE_NO:
3519 gtk_widget_destroy (GTK_WIDGET (ev_window));
3521 case GTK_RESPONSE_CANCEL:
3533 gchar *text, *markup;
3534 const gchar *secondary_text, *secondary_text_command;
3541 secondary_text =
_(
"Document contains form fields that have been filled out. ");
3544 secondary_text =
_(
"Document contains new or modified annotations. ");
3549 dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
3551 GTK_MESSAGE_QUESTION,
3556 text = g_markup_printf_escaped (
_(
"Reload document “%s”?"),
3557 gtk_window_get_title (GTK_WINDOW (ev_window)));
3558 secondary_text_command =
_(
"If you reload the document, changes will be permanently lost.");
3559 gtk_dialog_add_buttons (GTK_DIALOG (dialog),
3565 g_signal_connect (dialog,
"response",
3569 text = g_markup_printf_escaped (
_(
"Save a copy of document “%s” before closing?"),
3570 gtk_window_get_title (GTK_WINDOW (ev_window)));
3571 secondary_text_command =
_(
"If you don’t save a copy, changes will be permanently lost.");
3572 gtk_dialog_add_buttons (GTK_DIALOG (dialog),
3573 _(
"Close _without Saving"),
3576 GTK_RESPONSE_CANCEL,
3580 g_signal_connect (dialog,
"response",
3585 markup = g_strdup_printf (
"<b>%s</b>", text);
3588 gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), markup);
3591 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
3592 "%s %s", secondary_text, secondary_text_command);
3593 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
3594 gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
3597 GTK_RESPONSE_CANCEL,
3600 gtk_widget_show (dialog);
3610 gtk_widget_destroy (GTK_WIDGET (dialog));
3613 case GTK_RESPONSE_YES:
3616 gtk_widget_destroy (GTK_WIDGET (ev_window));
3620 case GTK_RESPONSE_NO:
3624 gtk_widget_set_sensitive (GTK_WIDGET (ev_window),
FALSE);
3627 gtk_widget_destroy (GTK_WIDGET (ev_window));
3630 case GTK_RESPONSE_CANCEL:
3640 gchar *text, *markup;
3646 if (n_print_jobs == 0)
3649 dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
3651 GTK_MESSAGE_QUESTION,
3654 if (n_print_jobs == 1) {
3656 const gchar *job_name;
3661 text = g_strdup_printf (
_(
"Wait until print job “%s” finishes before closing?"),
3667 text = g_strdup_printf (ngettext(
"There is %d print job active. "
3668 "Wait until print finishes before closing?",
3669 "There are %d print jobs active. "
3670 "Wait until print finishes before closing?",
3675 markup = g_strdup_printf (
"<b>%s</b>", text);
3678 gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), markup);
3681 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%s",
3682 _(
"If you close the window, pending print "
3683 "jobs will not be printed."));
3685 gtk_dialog_add_buttons (GTK_DIALOG (dialog),
3686 _(
"Cancel _print and Close"),
3689 GTK_RESPONSE_CANCEL,
3690 _(
"Close _after Printing"),
3693 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
3694 gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
3697 GTK_RESPONSE_CANCEL,
3700 g_signal_connect (dialog,
"response",
3703 gtk_widget_show (dialog);
3731 GVariant *parameter,
3737 gtk_widget_destroy (GTK_WIDGET (ev_window));
3742 GVariant *parameter,
3746 GtkWidget *page_selector;
3759 GVariant *parameter,
3764 g_signal_emit_by_name (window->
priv->
view,
"scroll", GTK_SCROLL_PAGE_FORWARD, GTK_ORIENTATION_VERTICAL);
3769 GVariant *parameter,
3774 g_signal_emit_by_name (window->
priv->
view,
"scroll", GTK_SCROLL_PAGE_BACKWARD, GTK_ORIENTATION_VERTICAL);
3786 g_simple_action_set_state (action, state);
3798 g_simple_action_set_state (action, state);
3809 g_variant_get_boolean (state));
3810 g_simple_action_set_state (action, state);
3821 mode = g_variant_get_string (state, NULL);
3823 if (g_str_equal (mode,
"fit-page"))
3825 else if (g_str_equal (mode,
"fit-width"))
3827 else if (g_str_equal (mode,
"automatic"))
3829 else if (g_str_equal (mode,
"free"))
3832 g_assert_not_reached ();
3834 g_simple_action_set_state (action, state);
3839 GVariant *parameter,
3843 gdouble zoom = g_variant_get_double (parameter);
3852 GVariant *parameter,
3867 if (g_variant_get_boolean (state))
3872 g_simple_action_set_state (action, state);
3877 GVariant *parameter,
3918 GVariant *parameter,
3922 gboolean search_mode_enabled;
3927 search_mode_enabled = gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (ev_window->
priv->
search_bar));
3931 if (!search_mode_enabled)
3946 GVariant *parameter,
3950 gboolean search_mode_enabled;
3955 search_mode_enabled = gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (ev_window->
priv->
search_bar));
3959 if (!search_mode_enabled)
3967 GVariant *parameter,
3982 gtk_paned_get_position (GTK_PANED (
object)));
3988 GtkTreeModel *model;
3989 GtkWidget *page_selector;
4004 g_object_unref (model);
4011 gboolean fullscreen;
4013 action = g_action_map_lookup_action (G_ACTION_MAP (window),
"fullscreen");
4015 g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (fullscreen));
4030 if (!gtk_revealer_get_reveal_child (GTK_REVEALER (window->
priv->
fs_revealer))) {
4058 if (gtk_revealer_get_reveal_child (GTK_REVEALER (window->
priv->
fs_revealer)))
4091 gboolean fullscreen_window =
TRUE;
4098 fullscreen_window =
FALSE;
4113 gtk_revealer_set_transition_type (GTK_REVEALER (window->
priv->
fs_revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
4117 gtk_container_remove (GTK_CONTAINER (window), window->
priv->
main_box);
4142 gtk_container_add (GTK_CONTAINER (window), window->
priv->
fs_overlay);
4150 if (fullscreen_window)
4151 gtk_window_fullscreen (GTK_WINDOW (window));
4152 gtk_widget_grab_focus (window->
priv->
view);
4160 gboolean unfullscreen_window)
4176 gtk_container_remove (GTK_CONTAINER (window), window->
priv->
fs_overlay);
4178 gtk_container_add (GTK_CONTAINER (window), window->
priv->
main_box);
4186 if (unfullscreen_window)
4187 gtk_window_unfullscreen (GTK_WINDOW (window));
4200 if (g_variant_get_boolean (state)) {
4206 g_simple_action_set_state (action, state);
4218 gtk_application_inhibit (GTK_APPLICATION (g_application_get_default ()),
4219 GTK_WINDOW (window),
4220 GTK_APPLICATION_INHIBIT_IDLE,
4221 _(
"Running in presentation mode"));
4233 gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default ()),
4243 action = g_action_map_lookup_action (G_ACTION_MAP (window),
"presentation");
4244 g_simple_action_set_state (G_SIMPLE_ACTION (action),
4273 gboolean fullscreen_window =
TRUE;
4276 gboolean inverted_colors;
4285 fullscreen_window =
FALSE;
4317 if (fullscreen_window)
4318 gtk_window_fullscreen (GTK_WINDOW (window));
4330 gboolean unfullscreen_window)
4343 gtk_container_remove (GTK_CONTAINER (window->
priv->
main_box),
4350 if (unfullscreen_window)
4351 gtk_window_unfullscreen (GTK_WINDOW (window));
4353 gtk_widget_grab_focus (window->
priv->
view);
4368 if (g_variant_get_boolean (state)) {
4379 GdkEventWindowState *event)
4383 if (GTK_WIDGET_CLASS (ev_window_parent_class)->window_state_event) {
4384 GTK_WIDGET_CLASS (ev_window_parent_class)->window_state_event (widget, event);
4387 if ((event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) == 0)
4390 if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) {
4409 GtkWidget *child = NULL;
4410 GtkWidget *real_child;
4417 switch (page_mode) {
4425 g_assert_not_reached ();
4429 if (child != real_child) {
4440 GVariant *parameter,
4459 GVariant *parameter,
4484 g_variant_get_boolean (state));
4485 g_simple_action_set_state (action, state);
4499 g_settings_set_boolean (settings,
"continuous",
4501 g_settings_set_boolean (settings,
"dual-page",
4503 g_settings_set_boolean (settings,
"dual-page-odd-left",
4505 g_settings_set_boolean (settings,
"fullscreen",
4507 g_settings_set_boolean (settings,
"inverted-colors",
4510 g_settings_set_enum (settings,
"sizing-mode", sizing_mode);
4515 g_settings_set_double (settings,
"zoom", zoom);
4517 g_settings_set_boolean (settings,
"show-sidebar",
4518 gtk_widget_get_visible (priv->
sidebar));
4519 g_settings_set_int (settings,
"sidebar-size",
4520 gtk_paned_get_position (GTK_PANED (priv->
hpaned)));
4521 g_settings_set_string (settings,
"sidebar-page",
4523 g_settings_apply (settings);
4528 GVariant *parameter,
4539 GVariant *parameter,
4550 GVariant *parameter,
4560 GVariant *parameter,
4570 GVariant *parameter,
4580 GVariant *parameter,
4590 GVariant *parameter,
4600 GVariant *parameter,
4611 GVariant *parameter,
4615 int n_pages, current_page;
4620 if (current_page + 10 < n_pages) {
4627 GVariant *parameter,
4635 if (current_page - 10 >= 0) {
4661 for (it = items; it; it = it->next) {
4665 item = g_menu_item_new (bookmark->
title, NULL);
4666 g_menu_item_set_action_and_target (item,
"win.goto-bookmark",
"u", bookmark->
page);
4669 g_object_unref (item);
4672 g_list_free (items);
4677 GVariant *parameter,
4686 bm.
title = g_strdup_printf (
_(
"Page %s"), page_label);
4687 g_free (page_label);
4695 GVariant *parameter,
4705 GVariant *parameter,
4718 GVariant *parameter,
4728 GVariant *parameter,
4734 if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (window->
priv->
search_bar)))
4741 gtk_widget_grab_focus (window->
priv->
view);
4748 GEnumValue *enum_value;
4754 enum_value = g_enum_get_value (g_type_class_peek (EV_TYPE_SIZING_MODE), mode);
4756 enum_value->value_nick);
4776 "hscrollbar-policy",
4778 GTK_POLICY_AUTOMATIC : GTK_POLICY_NEVER,
4779 "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
4808 gboolean continuous;
4813 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"continuous");
4814 g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (continuous));
4840 action = g_action_map_lookup_action (G_ACTION_MAP (window),
"inverted-colors");
4841 g_simple_action_set_state (G_SIMPLE_ACTION (action),
4842 g_variant_new_boolean (inverted_colors));
4859 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"dual-page");
4860 g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (dual_page));
4878 GVariant *parameter,
4894 gboolean show_side_pane;
4899 show_side_pane = g_variant_get_boolean (state);
4900 g_simple_action_set_state (action, g_variant_new_boolean (show_side_pane));
4924 gboolean visible = gtk_widget_get_visible (GTK_WIDGET (ev_sidebar));
4926 g_action_group_change_action_state (G_ACTION_GROUP (ev_window),
"show-side-pane",
4927 g_variant_new_boolean (visible));
4933 gtk_widget_grab_focus (ev_window->
priv->
view);
4941 gboolean show_external =
FALSE;
4942 gboolean show_internal =
FALSE;
4945 g_clear_object (&ev_window->
priv->
link);
4949 ev_window->
priv->
link = g_object_ref (link);
4956 show_internal =
TRUE;
4960 show_external =
TRUE;
4968 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"open-link");
4969 g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show_external);
4971 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"copy-link-address");
4972 g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show_external);
4974 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"go-to-link");
4975 g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show_internal);
4977 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"open-link-new-window");
4978 g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show_internal);
4986 gboolean show_image =
FALSE;
4988 g_clear_object (&ev_window->
priv->
image);
4990 ev_window->
priv->
image = g_object_ref (image);
4994 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"save-image");
4995 g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show_image);
4997 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"copy-image");
4998 g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show_image);
5006 gboolean show_annot_props =
FALSE;
5007 gboolean show_attachment =
FALSE;
5008 gboolean can_remove_annots =
FALSE;
5010 g_clear_object (&ev_window->
priv->
annot);
5012 ev_window->
priv->
annot = g_object_ref (annot);
5021 show_attachment =
TRUE;
5027 g_object_ref (attachment));
5035 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"annot-properties");
5036 g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show_annot_props);
5038 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"remove-annot");
5039 g_simple_action_set_enabled (G_SIMPLE_ACTION (action), annot != NULL && can_remove_annots);
5041 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"open-attachment");
5042 g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show_attachment);
5044 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"save-attachment");
5045 g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show_attachment);
5054 gboolean has_link =
FALSE;
5055 gboolean has_image =
FALSE;
5056 gboolean has_annot =
FALSE;
5058 for (l = items; l; l = g_list_next (l)) {
5080 gtk_menu_attach_to_widget (GTK_MENU (ev_window->
priv->
view_popup),
5081 GTK_WIDGET (ev_window), NULL);
5085 NULL, NULL, NULL, NULL,
5086 3, gtk_get_current_event_time ());
5097 g_assert (attach_list != NULL);
5099 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"open-attachment");
5100 g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
TRUE);
5102 action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
"save-attachment");
5103 g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
TRUE);
5111 GTK_WIDGET (ev_window), NULL);
5115 NULL, NULL, NULL, NULL,
5116 3, gtk_get_current_event_time ());
5136 gtk_window_get_screen (GTK_WINDOW (ev_window)),
5137 NULL, 0, NULL, gtk_get_current_event_time ());
5178 gtk_widget_queue_draw (GTK_WIDGET (ev_window->
priv->
view));
5200 gboolean enabled = gtk_search_bar_get_search_mode (search_bar);
5221 g_error (
"Find action should be insensitive since document doesn't support find");
5232 gtk_paned_pack1 (GTK_PANED (ev_window->
priv->
hpaned),
5239 g_action_group_change_action_state (G_ACTION_GROUP (ev_window),
"toggle-find", g_variant_new_boolean (
TRUE));
5243 const char *search_string = gtk_entry_get_text (GTK_ENTRY (entry));
5245 if (search_string && search_string[0])
5257 gtk_container_remove (GTK_CONTAINER (ev_window->
priv->
hpaned),
5259 gtk_paned_pack1 (GTK_PANED (ev_window->
priv->
hpaned),
5264 gtk_widget_grab_focus (ev_window->
priv->
view);
5265 g_action_group_change_action_state (G_ACTION_GROUP (ev_window),
"toggle-find", g_variant_new_boolean (
FALSE));
5272 GdkDragContext *context,
5275 GtkSelectionData *selection_data,
5283 GSList *uri_list = NULL;
5286 source = gtk_drag_get_source_widget (context);
5287 if (source && widget == gtk_widget_get_toplevel (source)) {
5288 gtk_drag_finish (context,
FALSE,
FALSE, time);
5292 uris = gtk_selection_data_get_uris (selection_data);
5294 gtk_drag_finish (context,
FALSE,
FALSE, time);
5298 for (i = 0; uris[i]; i++) {
5299 uri_list = g_slist_prepend (uri_list, (gpointer) uris[i]);
5303 gtk_window_get_screen (GTK_WINDOW (window)),
5305 gtk_drag_finish (context,
TRUE,
FALSE, time);
5308 g_slist_free (uri_list);
5322 action = g_action_map_lookup_action (G_ACTION_MAP (window),
"caret-navigation");
5323 g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (enabled));
5332 if (response_id == GTK_RESPONSE_YES)
5343 gtk_widget_grab_focus (window->
priv->
view);
5352 GtkWidget *message_area;
5370 _(
"Enable caret navigation?"),
5371 GTK_STOCK_NO, GTK_RESPONSE_NO,
5372 _(
"_Enable"), GTK_RESPONSE_YES,
5375 _(
"Pressing F7 turns the caret navigation on or off. "
5376 "This feature places a moveable cursor in text pages, "
5377 "allowing you to move around and select text with your keyboard. "
5378 "Do you want to enable the caret navigation?"));
5381 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
5384 gtk_widget_show_all (hbox);
5387 gtk_box_pack_start (GTK_BOX (box), hbox,
TRUE,
TRUE, 0);
5389 g_signal_connect (message_area,
"response",
5393 gtk_widget_show (message_area);
5404 if (g_variant_get_boolean (state))
5409 g_simple_action_set_state (action, state);
5420 g_signal_handlers_disconnect_by_func (mpkeys,
5426 if (priv->skeleton != NULL) {
5427 ev_window_emit_closed (window);
5429 g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (priv->skeleton));
5430 g_object_unref (priv->skeleton);
5431 priv->skeleton = NULL;
5432 g_free (priv->dbus_object_path);
5433 priv->dbus_object_path = NULL;
5460 g_object_unref (priv->
monitor);
5494 g_signal_handlers_disconnect_by_func (priv->
model,
5497 g_object_unref (priv->
model);
5507 g_object_unref (priv->
view);
5542 g_object_unref (priv->
link);
5547 g_object_unref (priv->
image);
5552 g_object_unref (priv->
annot);
5558 (GFunc) g_object_unref,
5575 g_object_unref (priv->
dest);
5580 g_object_unref (priv->
history);
5589 G_OBJECT_CLASS (ev_window_parent_class)->dispose (
object);
5605 static gpointer grand_parent_class = NULL;
5606 GtkWindow *
window = GTK_WINDOW (widget);
5608 if (grand_parent_class == NULL)
5609 grand_parent_class = g_type_class_peek_parent (ev_window_parent_class);
5612 if (gtk_window_propagate_key_event (window, event))
5616 if (gtk_window_activate_key (window, event))
5620 return GTK_WIDGET_CLASS (grand_parent_class)->key_press_event (widget, event);
5633 GObjectClass *g_object_class = G_OBJECT_CLASS (ev_window_class);
5634 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (ev_window_class);
5719 gtk_widget_grab_focus (window->
priv->
view);
5810 g_object_get (ev_sidebar_page,
"main_widget", &widget, NULL);
5812 if (widget != NULL) {
5813 g_signal_connect_object (widget,
"focus_in_event",
5816 g_object_unref (widget);
5823 if (!(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)) {
5826 maximized = event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED;
5837 GdkWindowState state;
5838 gdouble document_width, document_height;
5843 state = gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (window)));
5845 if (!(state & GDK_WINDOW_STATE_FULLSCREEN)) {
5848 &document_width, &document_height);
5850 (
double)event->width / document_width,
5851 (
double)event->height / document_height);
5869 GList file_list = {NULL};
5870 GdkAppLaunchContext *context;
5872 GError *error = NULL;
5874 if (filename == NULL)
5877 if (g_path_is_absolute (filename)) {
5878 file = g_file_new_for_path (filename);
5883 dir = g_path_get_dirname (window->
priv->
uri);
5884 base_file = g_file_new_for_uri (dir);
5887 file = g_file_resolve_relative_path (base_file, filename);
5888 g_object_unref (base_file);
5891 app_info = g_file_query_default_handler (file, NULL, &error);
5893 ev_window_error_message (window, error,
5895 _(
"Unable to launch external application."));
5896 g_object_unref (file);
5897 g_error_free (error);
5902 screen = gtk_window_get_screen (GTK_WINDOW (window));
5903 context = gdk_display_get_app_launch_context (gdk_screen_get_display (screen));
5904 gdk_app_launch_context_set_screen (context, screen);
5905 gdk_app_launch_context_set_timestamp (context, gtk_get_current_event_time ());
5907 file_list.data = file;
5908 if (!g_app_info_launch (app_info, &file_list, G_APP_LAUNCH_CONTEXT (context), &error)) {
5909 ev_window_error_message (window, error,
5911 _(
"Unable to launch external application."));
5912 g_error_free (error);
5915 g_object_unref (app_info);
5916 g_object_unref (file);
5927 GError *error = NULL;
5929 GdkAppLaunchContext *context;
5932 screen = gtk_window_get_screen (GTK_WINDOW (window));
5933 context = gdk_display_get_app_launch_context (gdk_screen_get_display (screen));
5934 gdk_app_launch_context_set_screen (context, screen);
5935 gdk_app_launch_context_set_timestamp (context, gtk_get_current_event_time ());
5937 if (!g_strstr_len (uri, strlen (uri),
"://") &&
5938 !g_str_has_prefix (uri,
"mailto:")) {
5942 if (g_str_has_prefix (uri,
"www.")) {
5943 new_uri = g_strdup_printf (
"http://%s", uri);
5945 GFile *file, *parent;
5947 file = g_file_new_for_uri (window->
priv->
uri);
5948 parent = g_file_get_parent (file);
5949 g_object_unref (file);
5951 gchar *parent_uri = g_file_get_uri (parent);
5953 new_uri = g_build_filename (parent_uri, uri, NULL);
5954 g_free (parent_uri);
5955 g_object_unref (parent);
5957 new_uri = g_strdup_printf (
"file:///%s", uri);
5960 ret = g_app_info_launch_default_for_uri (new_uri, G_APP_LAUNCH_CONTEXT (context), &error);
5963 ret = g_app_info_launch_default_for_uri (uri, G_APP_LAUNCH_CONTEXT (context), &error);
5967 ev_window_error_message (window, error,
5968 "%s",
_(
"Unable to open external link"));
5969 g_error_free (error);
5981 dir = g_path_get_dirname (window->
priv->
uri);
5988 gtk_window_get_screen (GTK_WINDOW (window)),
5992 gtk_get_current_event_time ());
6002 if (g_ascii_strcasecmp (name,
"FirstPage") == 0) {
6003 g_action_group_activate_action (G_ACTION_GROUP (window),
"go-first-page", NULL);
6004 }
else if (g_ascii_strcasecmp (name,
"PrevPage") == 0) {
6005 g_action_group_activate_action (G_ACTION_GROUP (window),
"go-previous-page", NULL);
6006 }
else if (g_ascii_strcasecmp (name,
"NextPage") == 0) {
6007 g_action_group_activate_action (G_ACTION_GROUP (window),
"go-next-page", NULL);
6008 }
else if (g_ascii_strcasecmp (name,
"LastPage") == 0) {
6009 g_action_group_activate_action (G_ACTION_GROUP (window),
"go-last-page", NULL);
6010 }
else if (g_ascii_strcasecmp (name,
"GoToPage") == 0) {
6011 g_action_group_activate_action (G_ACTION_GROUP (window),
"select-page", NULL);
6012 }
else if (g_ascii_strcasecmp (name,
"Find") == 0) {
6013 g_action_group_activate_action (G_ACTION_GROUP (window),
"find", NULL);
6014 }
else if (g_ascii_strcasecmp (name,
"Close") == 0) {
6015 g_action_group_activate_action (G_ACTION_GROUP (window),
"close", NULL);
6016 }
else if (g_ascii_strcasecmp (name,
"Print") == 0) {
6017 g_action_group_activate_action (G_ACTION_GROUP (window),
"print", NULL);
6019 g_warning (
"Unimplemented named action: %s, please post a "
6020 "bug report in Evince bugzilla "
6021 "(http://bugzilla.gnome.org) with a testcase.",
6053 g_assert_not_reached ();
6059 GVariant *parameter,
6069 GVariant *parameter,
6089 GVariant *parameter,
6105 GdkPixbufFormat *format)
6109 gchar *uri_extension;
6112 extensions = gdk_pixbuf_format_get_extensions (format);
6113 for (i = 0; extensions[i]; i++) {
6114 if (g_str_has_suffix (uri, extensions[i])) {
6115 g_strfreev (extensions);
6116 return g_file_new_for_uri (uri);
6120 uri_extension = g_strconcat (uri,
".", extensions[0], NULL);
6121 target_file = g_file_new_for_uri (uri_extension);
6122 g_free (uri_extension);
6123 g_strfreev (extensions);
6135 GError *error = NULL;
6140 GdkPixbufFormat *format;
6141 GtkFileFilter *filter;
6143 if (response_id != GTK_RESPONSE_OK) {
6144 gtk_widget_destroy (fc);
6149 G_USER_DIRECTORY_PICTURES);
6151 uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
6152 filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (fc));
6153 format = g_object_get_data (G_OBJECT (filter),
"pixbuf-format");
6155 if (format == NULL) {
6159 if (format == NULL && g_strrstr (uri,
".") == NULL) {
6162 if (format == NULL) {
6168 if (format == NULL) {
6169 ev_window_error_message (ev_window, NULL,
6171 _(
"Couldn’t find appropriate format to save image"));
6173 gtk_widget_destroy (fc);
6181 is_native = g_file_is_native (target_file);
6183 filename = g_file_get_path (target_file);
6186 if (
ev_mkstemp (
"saveimage.XXXXXX", &filename, &error) == -1)
6195 file_format = gdk_pixbuf_format_get_name (format);
6196 gdk_pixbuf_save (pixbuf, filename, file_format, &error, NULL);
6197 g_free (file_format);
6198 g_object_unref (pixbuf);
6202 ev_window_error_message (ev_window, error,
6203 "%s",
_(
"The image could not be saved."));
6204 g_error_free (error);
6206 g_object_unref (target_file);
6207 gtk_widget_destroy (fc);
6215 source_file = g_file_new_for_path (filename);
6218 source_file, target_file);
6219 g_object_unref (source_file);
6223 g_object_unref (target_file);
6224 gtk_widget_destroy (fc);
6229 GVariant *parameter,
6238 fc = gtk_file_chooser_dialog_new (
_(
"Save Image"),
6239 GTK_WINDOW (window),
6240 GTK_FILE_CHOOSER_ACTION_SAVE,
6242 GTK_RESPONSE_CANCEL,
6243 GTK_STOCK_SAVE, GTK_RESPONSE_OK,
6246 gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
6247 gtk_dialog_set_alternative_button_order (GTK_DIALOG (fc),
6249 GTK_RESPONSE_CANCEL,
6252 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fc),
FALSE);
6253 gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc),
TRUE);
6258 G_USER_DIRECTORY_PICTURES);
6260 g_signal_connect (fc,
"response",
6264 gtk_widget_show (fc);
6269 GVariant *parameter,
6272 GtkClipboard *clipboard;
6279 clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window),
6280 GDK_SELECTION_CLIPBOARD);
6286 gtk_clipboard_set_image (clipboard, pixbuf);
6287 g_object_unref (pixbuf);
6292 GVariant *parameter,
6296 const gchar *author;
6299 gboolean popup_is_open;
6308 gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
6309 if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_APPLY) {
6310 gtk_widget_destroy (GTK_WIDGET (dialog));
6359 gtk_widget_destroy (GTK_WIDGET (dialog));
6364 GVariant *parameter,
6375 GVariant *parameter,
6385 screen = gtk_window_get_screen (GTK_WINDOW (window));
6387 for (l = window->
priv->
attach_list; l && l->data; l = g_list_next (l)) {
6389 GError *error = NULL;
6396 ev_window_error_message (window, error,
6397 "%s",
_(
"Unable to open attachment"));
6398 g_error_free (error);
6411 GtkFileChooserAction fc_action;
6415 if (response_id != GTK_RESPONSE_OK) {
6416 gtk_widget_destroy (fc);
6421 G_USER_DIRECTORY_DOCUMENTS);
6423 uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
6424 target_file = g_file_new_for_uri (uri);
6425 g_object_get (G_OBJECT (fc),
"action", &fc_action, NULL);
6426 is_dir = (fc_action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
6427 is_native = g_file_is_native (target_file);
6429 for (l = ev_window->
priv->
attach_list; l && l->data; l = g_list_next (l)) {
6431 GFile *save_to = NULL;
6432 GError *error = NULL;
6438 save_to = g_file_get_child (target_file,
6442 save_to = g_object_ref (target_file);
6452 ev_window_error_message (ev_window, error,
6453 "%s",
_(
"The attachment could not be saved."));
6454 g_error_free (error);
6455 g_object_unref (save_to);
6464 dest_file = g_file_get_child (target_file,
6467 dest_file = g_object_ref (target_file);
6471 save_to, dest_file);
6473 g_object_unref (dest_file);
6476 g_object_unref (save_to);
6480 g_object_unref (target_file);
6482 gtk_widget_destroy (fc);
6487 GVariant *parameter,
6500 fc = gtk_file_chooser_dialog_new (
6501 _(
"Save Attachment"),
6502 GTK_WINDOW (window),
6503 attachment ? GTK_FILE_CHOOSER_ACTION_SAVE : GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
6505 GTK_RESPONSE_CANCEL,
6506 GTK_STOCK_SAVE, GTK_RESPONSE_OK,
6509 gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
6510 gtk_dialog_set_alternative_button_order (GTK_DIALOG (fc),
6512 GTK_RESPONSE_CANCEL,
6515 gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc),
TRUE);
6516 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fc),
FALSE);
6519 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc),
6523 G_USER_DIRECTORY_DOCUMENTS);
6525 g_signal_connect (fc,
"response",
6529 gtk_widget_show (fc);
6537 if (!gtk_window_is_active (GTK_WINDOW (window)))
6548 if (strcmp (key,
"Play") == 0) {
6550 }
else if (strcmp (key,
"Previous") == 0) {
6554 g_action_group_activate_action (G_ACTION_GROUP (window),
"go-previous-page", NULL);
6555 }
else if (strcmp (key,
"Next") == 0) {
6559 g_action_group_activate_action (G_ACTION_GROUP (window),
"go-next-page", NULL);
6560 }
else if (strcmp (key,
"FastForward") == 0) {
6561 g_action_group_activate_action (G_ACTION_GROUP (window),
"go-last-page", NULL);
6562 }
else if (strcmp (key,
"Rewind") == 0) {
6563 g_action_group_activate_action (G_ACTION_GROUP (window),
"go-first-page", NULL);
6576 if (window->
priv->skeleton == NULL)
6579 timestamp = gtk_get_current_event_time ();
6580 if (g_path_is_absolute (link->
filename)) {
6581 input_gfile = g_file_new_for_path (link->
filename);
6583 GFile *gfile, *parent_gfile;
6585 gfile = g_file_new_for_uri (window->
priv->
uri);
6586 parent_gfile = g_file_get_parent (gfile);
6589 if (parent_gfile == NULL) {
6590 g_printerr (
"Document URI is '/'\n");
6594 input_gfile = g_file_get_child (parent_gfile, link->
filename);
6595 g_object_unref (parent_gfile);
6596 g_object_unref (gfile);
6599 uri_input = g_file_get_uri (input_gfile);
6600 g_object_unref (input_gfile);
6602 ev_evince_window_emit_sync_source (window->
priv->skeleton,
6604 g_variant_new (
"(ii)", link->
line, link->
col),
6610 ev_window_emit_closed (
EvWindow *window)
6612 if (window->
priv->skeleton == NULL)
6615 ev_evince_window_emit_closed (window->
priv->skeleton);
6621 g_dbus_connection_flush_sync (g_application_get_dbus_connection (g_application_get_default ()), NULL, NULL);
6625 ev_window_emit_doc_loaded (
EvWindow *window)
6627 if (window->
priv->skeleton == NULL)
6630 ev_evince_window_emit_document_loaded (window->
priv->skeleton, window->
priv->
uri);
6634 handle_sync_view_cb (EvEvinceWindow *
object,
6635 GDBusMethodInvocation *invocation,
6636 const gchar *source_file,
6637 GVariant *source_point,
6644 link.
filename = (
char *) source_file;
6645 g_variant_get (source_point,
"(ii)", &link.
line, &link.
col);
6647 gtk_window_present_with_time (GTK_WINDOW (window), timestamp);
6650 ev_evince_window_complete_sync_view (
object, invocation);
6658 const char *resource_path,
6664 data = g_resources_lookup_data (resource_path, 0, error);
6668 retval = gtk_css_provider_load_from_data (provider,
6669 g_bytes_get_data (data, NULL),
6670 g_bytes_get_size (data),
6672 g_bytes_unref (data);
6680 static gsize initialization_value = 0;
6682 if (g_once_init_enter (&initialization_value)) {
6683 GtkCssProvider *css_provider;
6684 GError *error = NULL;
6686 css_provider = gtk_css_provider_new ();
6688 "/org/gnome/evince/ui/evince.css",
6690 g_assert_no_error (error);
6691 gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
6692 GTK_STYLE_PROVIDER (css_provider),
6693 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
6694 g_object_unref (css_provider);
6696 g_once_init_leave (&initialization_value, 1);
6703 GtkBuilder *builder;
6704 GError *error = NULL;
6705 GtkWidget *sidebar_widget;
6707 GtkWidget *searchbar_revealer;
6709 guint page_cache_mb;
6710 gboolean allow_links_change_zoom;
6711 GtkEntry *search_entry;
6713 GDBusConnection *connection;
6714 static gint window_id = 0;
6718 g_signal_connect (ev_window,
"configure_event",
6720 g_signal_connect (ev_window,
"window_state_event",
6726 connection = g_application_get_dbus_connection (g_application_get_default ());
6728 EvEvinceWindow *skeleton;
6730 ev_window->
priv->dbus_object_path = g_strdup_printf (EV_WINDOW_DBUS_OBJECT_PATH, window_id++);
6732 skeleton = ev_evince_window_skeleton_new ();
6733 if (g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton),
6735 ev_window->
priv->dbus_object_path,
6737 ev_window->
priv->skeleton = skeleton;
6738 g_signal_connect (skeleton,
"handle-sync-view",
6739 G_CALLBACK (handle_sync_view_cb),
6742 g_printerr (
"Failed to register bus object %s: %s\n",
6743 ev_window->
priv->dbus_object_path, error->message);
6744 g_error_free (error);
6745 g_free (ev_window->
priv->dbus_object_path);
6746 ev_window->
priv->dbus_object_path = NULL;
6749 g_object_unref (skeleton);
6750 ev_window->
priv->skeleton = NULL;
6762 g_signal_connect (ev_window->
priv->
history,
"activate-link",
6765 g_signal_connect (ev_window->
priv->
history,
"changed",
6771 app_info = g_app_info_get_default_for_uri_scheme (
"mailto");
6773 g_clear_object (&app_info);
6775 ev_window->
priv->
main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
6776 gtk_container_add (GTK_CONTAINER (ev_window), ev_window->
priv->
main_box);
6779 g_action_map_add_action_entries (G_ACTION_MAP (ev_window),
6789 gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (ev_window->
priv->
toolbar),
TRUE);
6790 gtk_window_set_titlebar (GTK_WINDOW (ev_window), ev_window->
priv->
toolbar);
6811 gtk_box_pack_start (GTK_BOX (ev_window->
priv->
main_box),
6816 gtk_search_bar_set_show_close_button (GTK_SEARCH_BAR (ev_window->
priv->
search_bar),
TRUE);
6820 gtk_entry_set_width_chars (search_entry, 32);
6821 gtk_entry_set_max_length (search_entry, 512);
6829 searchbar_revealer = gtk_revealer_new ();
6830 g_object_bind_property (G_OBJECT (searchbar_revealer),
"reveal-child",
6832 G_BINDING_BIDIRECTIONAL);
6833 gtk_container_add (GTK_CONTAINER (searchbar_revealer), ev_window->
priv->
search_bar);
6834 gtk_widget_show (GTK_WIDGET (searchbar_revealer));
6839 gtk_box_pack_start (GTK_BOX (ev_window->
priv->
main_box),
6844 ev_window->
priv->
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
6858 gtk_paned_pack1 (GTK_PANED (ev_window->
priv->
hpaned),
6866 g_signal_connect (sidebar_widget,
6867 "notify::main-widget",
6871 gtk_widget_show (sidebar_widget);
6877 g_signal_connect (sidebar_widget,
6881 g_signal_connect (sidebar_widget,
6886 gtk_widget_show (sidebar_widget);
6892 g_signal_connect_object (sidebar_widget,
6896 gtk_widget_show (sidebar_widget);
6902 g_signal_connect (sidebar_widget,
6903 "layers_visibility_changed",
6906 gtk_widget_show (sidebar_widget);
6912 g_signal_connect (sidebar_widget,
6916 gtk_widget_show (sidebar_widget);
6922 gtk_widget_show (sidebar_widget);
6926 ev_window->
priv->
view_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
6928 overlay = gtk_overlay_new ();
6940 gtk_box_pack_start (GTK_BOX (ev_window->
priv->
view_box),
6943 gtk_widget_show (overlay);
6945 gtk_paned_add2 (GTK_PANED (ev_window->
priv->
hpaned),
6953 page_cache_mb * 1024 * 1024);
6957 allow_links_change_zoom);
6965 g_signal_connect_object (ev_window->
priv->
view,
"focus_in_event",
6968 g_signal_connect_swapped (ev_window->
priv->
view,
"external-link",
6971 g_signal_connect_object (ev_window->
priv->
view,
"handle-link",
6974 g_signal_connect_object (ev_window->
priv->
view,
"popup",
6977 g_signal_connect_object (ev_window->
priv->
view,
"selection-changed",
6980 g_signal_connect_object (ev_window->
priv->
view,
"annot-added",
6983 g_signal_connect_object (ev_window->
priv->
view,
"annot-removed",
6986 g_signal_connect_object (ev_window->
priv->
view,
"layers-changed",
6989 g_signal_connect_object (ev_window->
priv->
view,
"notify::is-loading",
6992 g_signal_connect_object (ev_window->
priv->
view,
"cursor-moved",
6996 g_signal_connect_swapped (ev_window->
priv->
view,
"sync-source",
6997 G_CALLBACK (ev_window_sync_source),
7000 gtk_widget_show (ev_window->
priv->
view);
7011 g_object_ref (ev_window->
priv->
view);
7018 g_signal_connect_swapped (ev_window->
priv->
model,
7022 g_signal_connect (ev_window->
priv->
model,
7026 g_signal_connect (ev_window->
priv->
model,
7030 g_signal_connect (ev_window->
priv->
model,
7031 "notify::sizing-mode",
7034 g_signal_connect (ev_window->
priv->
model,
7038 g_signal_connect (ev_window->
priv->
model,
7039 "notify::continuous",
7042 g_signal_connect (ev_window->
priv->
model,
7043 "notify::dual-page",
7046 g_signal_connect (ev_window->
priv->
model,
7047 "notify::dual-odd-left",
7050 g_signal_connect (ev_window->
priv->
model,
7051 "notify::inverted-colors",
7061 "notify::current-page",
7086 g_signal_connect (search_entry,
7091 "notify::search-mode-enabled",
7096 builder = gtk_builder_new_from_resource (
"/org/gnome/evince/gtk/menus.ui");
7097 ev_window->
priv->
view_popup_menu = g_object_ref (G_MENU_MODEL (gtk_builder_get_object (builder,
"view-popup-menu")));
7098 ev_window->
priv->
attachment_popup_menu = g_object_ref (G_MENU_MODEL (gtk_builder_get_object (builder,
"attachments-popup")));
7099 g_object_unref (builder);
7104 g_signal_connect_swapped (mpkeys,
"key_pressed",
7110 gtk_widget_grab_focus (ev_window->
priv->
view);
7116 gtk_window_set_default_size (GTK_WINDOW (ev_window), 600, 600);
7122 gtk_drag_dest_set (GTK_WIDGET (ev_window),
7123 GTK_DEST_DEFAULT_ALL,
7126 gtk_drag_dest_add_uri_targets (GTK_WIDGET (ev_window));
7139 GtkWidget *ev_window;
7142 "type", GTK_WINDOW_TOPLEVEL,
7143 "application", g_application_get_default (),
7144 "show-menubar",
FALSE,
7154 return ev_window->
priv->dbus_object_path;
7163 g_return_val_if_fail (
EV_WINDOW (ev_window), NULL);
7171 g_return_val_if_fail (
EV_WINDOW (ev_window), NULL);
7179 g_return_val_if_fail (
EV_WINDOW (ev_window), NULL);
7187 g_return_val_if_fail (
EV_WINDOW (ev_window), NULL);
7195 g_return_if_fail (
EV_WINDOW (ev_window));
7197 gtk_widget_grab_focus (ev_window->
priv->
view);