X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-window.c;h=4cd8b6423735b2842b985eb5d8564af8bc534106;hb=e62fbd4433b5039abab3986590c900d661ffe67a;hp=22409aae61ec90e72607071633b3bd1e73f9525d;hpb=e5c6189ac2baf74dd18c49ab64d7fe01e7763dee;p=evince.git diff --git a/shell/ev-window.c b/shell/ev-window.c index 22409aae..4cd8b642 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -5,7 +5,7 @@ * Copyright (C) 2004 Martin Kretzschmar * Copyright (C) 2004 Red Hat, Inc. * Copyright (C) 2000, 2001, 2002, 2003, 2004 Marco Pesenti Gritti - * Copyright (C) 2003, 2004, 2005 Christian Persch + * Copyright © 2003, 2004, 2005, 2009 Christian Persch * * Author: * Martin Kretzschmar @@ -38,11 +38,7 @@ #include #include #include -#if GTK_CHECK_VERSION (2, 14, 0) -#include -#else -#include -#endif + #ifdef WITH_GCONF #include #endif @@ -73,7 +69,6 @@ #include "ev-jobs.h" #include "ev-message-area.h" #include "ev-metadata-manager.h" -#include "ev-mount-operation.h" #include "ev-navigation-action.h" #include "ev-open-recent-action.h" #include "ev-page-action.h" @@ -144,6 +139,10 @@ struct _EvWindowPrivate { GtkWidget *sidebar_attachments; GtkWidget *sidebar_layers; + /* Menubar accels */ + guint menubar_accel_keyval; + GdkModifierType menubar_accel_modifier; + /* Progress Messages */ guint progress_idle; GCancellable *progress_cancellable; @@ -203,7 +202,6 @@ struct _EvWindowPrivate { /* Printing */ GQueue *print_queue; - GtkPrinter *printer; GtkPrintSettings *print_settings; GtkPageSetup *print_page_setup; gboolean close_after_print; @@ -370,7 +368,7 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window) ok_to_copy = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_COPY); } - if (has_document && !EV_IS_FILE_EXPORTER(document)) + if (has_document && !ev_print_operation_exists_for_document(document)) ok_to_print = FALSE; #ifdef WITH_GCONF @@ -388,7 +386,7 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window) /* 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, "FilePrintSetup", has_pages && ok_to_print); + ev_window_set_action_sensitive (ev_window, "FilePageSetup", has_pages && ok_to_print); 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); @@ -440,6 +438,8 @@ ev_window_update_actions (EvWindow *ev_window) has_pages && can_find_in_page); ev_window_set_action_sensitive (ev_window, "EditFindPrevious", has_pages && can_find_in_page); + ev_window_set_action_sensitive (ev_window, "F3", + has_pages && can_find_in_page); presentation_mode = ev_view_get_presentation (view); @@ -546,7 +546,6 @@ update_chrome_visibility (EvWindow *window) set_widget_visibility (priv->sidebar, sidebar); ev_window_set_action_sensitive (window, "EditToolbar", toolbar); - gtk_widget_set_sensitive (priv->menubar, menubar); if (priv->fullscreen_toolbar != NULL) { set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar); @@ -994,10 +993,12 @@ setup_document_from_metadata (EvWindow *window) request_width = MIN (request_width, gdk_screen_get_width (screen)); request_height = MIN (request_width, gdk_screen_get_height (screen)); } - - gtk_window_resize (GTK_WINDOW (window), - request_width, - request_height); + + if (request_width > 0 && request_height > 0) { + gtk_window_resize (GTK_WINDOW (window), + request_width, + request_height); + } g_value_unset (&width_ratio); g_value_unset (&height_ratio); } @@ -1159,7 +1160,8 @@ ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation) EvDocument *document = ev_window->priv->document; if (!EV_IS_DOCUMENT_THUMBNAILS (document) || - ev_page_cache_get_n_pages (ev_window->priv->page_cache) <= 0) { + ev_page_cache_get_n_pages (ev_window->priv->page_cache) <= 0 || + ev_page_cache_check_dimensions (ev_window->priv->page_cache)) { return; } @@ -1214,6 +1216,8 @@ ev_window_setup_document (EvWindow *ev_window) info = ev_page_cache_get_info (ev_window->priv->page_cache); update_document_mode (ev_window, info->mode); + gtk_widget_grab_focus (ev_window->priv->view); + return FALSE; } @@ -1246,15 +1250,19 @@ ev_window_set_document (EvWindow *ev_window, EvDocument *document) ev_window->priv->dest = NULL; } - if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) { - ev_view_set_document (view, document); - } else { + if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) <= 0) { ev_window_warning_message (ev_window, "%s", _("The document contains no pages")); + } else if (ev_page_cache_check_dimensions (ev_window->priv->page_cache)) { + ev_window_warning_message (ev_window, "%s", + _("The document contains only empty pages")); + } else { + ev_view_set_document (view, document); } if (ev_window->priv->setup_document_idle > 0) g_source_remove (ev_window->priv->setup_document_idle); + ev_window->priv->setup_document_idle = g_idle_add ((GSourceFunc)ev_window_setup_document, ev_window); } @@ -1314,7 +1322,7 @@ ev_window_clear_local_uri (EvWindow *ev_window) } static void -ev_window_clear_temp_file (EvWindow *ev_window) +ev_window_clear_temp_symlink (EvWindow *ev_window) { GFile *file, *tempdir; @@ -1322,10 +1330,24 @@ ev_window_clear_temp_file (EvWindow *ev_window) return; file = g_file_new_for_uri (ev_window->priv->uri); - tempdir = g_file_new_for_path (g_get_tmp_dir ()); + tempdir = g_file_new_for_path (ev_tmp_dir ()); if (g_file_has_prefix (file, tempdir)) { - g_file_delete (file, NULL, NULL); + GFileInfo *file_info; + GError *error = NULL; + + file_info = g_file_query_info (file, + G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK, + G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, + NULL, &error); + if (file_info) { + if (g_file_info_get_is_symlink (file_info)) + g_file_delete (file, NULL, NULL); + g_object_unref (file_info); + } else { + g_warning ("Error deleting temp symlink: %s\n", error->message); + g_error_free (error); + } } g_object_unref (file); @@ -1574,12 +1596,15 @@ show_loading_progress (EvWindow *ev_window) { GtkWidget *area; gchar *text; + gchar *display_name; if (ev_window->priv->message_area) return FALSE; - - text = g_strdup_printf (_("Loading document from %s"), - ev_window->priv->uri); + + display_name = escape_uri_for_display (ev_window->priv->uri); + text = g_strdup_printf (_("Loading document from “%s”"), + display_name); + area = ev_progress_message_area_new (GTK_STOCK_OPEN, text, GTK_STOCK_CLOSE, @@ -1592,7 +1617,9 @@ show_loading_progress (EvWindow *ev_window) ev_window); gtk_widget_show (area); ev_window_set_message_area (ev_window, area); + g_free (text); + g_free (display_name); return FALSE; } @@ -1675,19 +1702,17 @@ window_open_file_copy_ready_cb (GFile *source, return; } - if (error->domain == G_IO_ERROR && - error->code == G_IO_ERROR_NOT_MOUNTED) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_MOUNTED)) { GMountOperation *operation; - operation = ev_mount_operation_new (GTK_WINDOW (ev_window)); + operation = gtk_mount_operation_new (GTK_WINDOW (ev_window)); g_file_mount_enclosing_volume (source, G_MOUNT_MOUNT_NONE, operation, NULL, (GAsyncReadyCallback)mount_volume_ready_cb, ev_window); g_object_unref (operation); - } else if (error->domain == G_IO_ERROR && - error->code == G_IO_ERROR_CANCELLED) { + } else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { ev_window_clear_load_job (ev_window); ev_window_clear_local_uri (ev_window); g_free (ev_window->priv->uri); @@ -1875,8 +1900,7 @@ reload_remote_copy_ready_cb (GFile *remote, g_file_copy_finish (remote, async_result, &error); if (error) { - if (error->domain != G_IO_ERROR || - error->code != G_IO_ERROR_CANCELLED) + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) ev_window_error_message (ev_window, error, "%s", _("Failed to reload document.")); g_error_free (error); @@ -2000,24 +2024,25 @@ file_open_dialog_response_cb (GtkWidget *chooser, gint response_id, EvWindow *ev_window) { - gchar *uri; - if (response_id == GTK_RESPONSE_OK) { GSList *uris; + gchar *uri; uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (chooser)); ev_application_open_uri_list (EV_APP, uris, gtk_window_get_screen (GTK_WINDOW (ev_window)), GDK_CURRENT_TIME); - - g_slist_foreach (uris, (GFunc)g_free, NULL); + + g_slist_foreach (uris, (GFunc)g_free, NULL); g_slist_free (uris); - } - uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser)); - ev_application_set_chooser_uri (EV_APP, uri); - g_free (uri); + uri = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (chooser)); + ev_application_set_filechooser_uri (EV_APP, + GTK_FILE_CHOOSER_ACTION_OPEN, + uri); + g_free (uri); + } gtk_widget_destroy (chooser); } @@ -2025,7 +2050,9 @@ file_open_dialog_response_cb (GtkWidget *chooser, static void ev_window_cmd_file_open (GtkAction *action, EvWindow *window) { - GtkWidget *chooser; + GtkWidget *chooser; + const gchar *default_uri; + gchar *parent_uri = NULL; chooser = gtk_file_chooser_dialog_new (_("Open Document"), GTK_WINDOW (window), @@ -2038,12 +2065,23 @@ ev_window_cmd_file_open (GtkAction *action, EvWindow *window) ev_document_factory_add_filters (chooser, NULL); gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (chooser), TRUE); gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), FALSE); - if (ev_application_get_chooser_uri (EV_APP) != NULL) { - gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (chooser), - ev_application_get_chooser_uri (EV_APP)); - } else if (window->priv->uri != NULL) { - gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (chooser), - window->priv->uri); + + default_uri = ev_application_get_filechooser_uri (EV_APP, GTK_FILE_CHOOSER_ACTION_OPEN); + if (!default_uri && window->priv->uri) { + GFile *file, *parent; + + file = g_file_new_for_uri (window->priv->uri); + parent = g_file_get_parent (file); + if (parent) { + parent_uri = g_file_get_uri (parent); + default_uri = parent_uri; + g_object_unref (parent); + } + g_object_unref (file); + } + + if (default_uri) { + gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (chooser), default_uri); } else { const gchar *folder; @@ -2051,7 +2089,8 @@ ev_window_cmd_file_open (GtkAction *action, EvWindow *window) gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), folder ? folder : g_get_home_dir ()); } - + g_free (parent_uri); + g_signal_connect (chooser, "response", G_CALLBACK (file_open_dialog_response_cb), window); @@ -2062,10 +2101,11 @@ ev_window_cmd_file_open (GtkAction *action, EvWindow *window) static gchar * ev_window_create_tmp_symlink (const gchar *filename, GError **error) { - gchar *tmp_filename = NULL; - gchar *name; - gint res; - guint i = 0; + gchar *tmp_filename = NULL; + gchar *name; + guint i = 0; + GError *link_error = NULL; + GFile *tmp_file = NULL; name = g_path_get_basename (filename); @@ -2074,29 +2114,32 @@ ev_window_create_tmp_symlink (const gchar *filename, GError **error) if (tmp_filename) g_free (tmp_filename); + if (tmp_file) + g_object_unref (tmp_file); + g_clear_error (&link_error); basename = g_strdup_printf ("%s-%d", name, i++); tmp_filename = g_build_filename (ev_tmp_dir (), basename, NULL); g_free (basename); - } while ((res = symlink (filename, tmp_filename)) != 0 && errno == EEXIST); - - g_free (name); + tmp_file = g_file_new_for_path (tmp_filename); + } while (!g_file_make_symbolic_link (tmp_file, filename, NULL, &link_error) && + g_error_matches (link_error, G_IO_ERROR, G_IO_ERROR_EXISTS)); - if (res != 0 && errno != EEXIST) { - if (error) { - *error = g_error_new (G_FILE_ERROR, - g_file_error_from_errno (errno), - _("Couldn't create symlink “%s”: %s"), - tmp_filename, strerror (errno)); - } + g_free (name); + g_object_unref (tmp_file); + if (link_error) { + g_propagate_prefixed_error (error, + link_error, + _("Couldn't create symlink “%s”: "), + tmp_filename); g_free (tmp_filename); - + return NULL; } - + return tmp_filename; } @@ -2398,8 +2441,7 @@ window_save_file_copy_ready_cb (GFile *src, return; } - if (error->domain != G_IO_ERROR || - error->code != G_IO_ERROR_CANCELLED) { + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { gchar *name; name = g_file_get_basename (dst); @@ -2514,17 +2556,32 @@ file_save_dialog_response_cb (GtkWidget *fc, EvWindow *ev_window) { gchar *uri; - + GFile *file, *parent; + if (response_id != GTK_RESPONSE_OK) { gtk_widget_destroy (fc); return; } - + uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc)); + file = g_file_new_for_uri (uri); + parent = g_file_get_parent (file); + g_object_unref (file); + if (parent) { + gchar *folder_uri; + + folder_uri = g_file_get_uri (parent); + ev_application_set_filechooser_uri (EV_APP, + GTK_FILE_CHOOSER_ACTION_SAVE, + folder_uri); + g_free (folder_uri); + g_object_unref (parent); + } + /* FIXME: remote copy should be done here rather than in the save job, * so that we can track progress and cancel the operation */ - + ev_window_clear_save_job (ev_window); ev_window->priv->save_job = ev_job_save_new (ev_window->priv->document, uri, ev_window->priv->uri); @@ -2544,7 +2601,7 @@ ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window) GtkWidget *fc; gchar *base_name; GFile *file; - const gchar *folder; + const gchar *default_uri; fc = gtk_file_chooser_dialog_new ( _("Save a Copy"), @@ -2565,14 +2622,21 @@ ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window) file = g_file_new_for_uri (ev_window->priv->uri); base_name = g_file_get_basename (file); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc), base_name); - - folder = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS); - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fc), - folder ? folder : g_get_home_dir ()); - + + default_uri = ev_application_get_filechooser_uri (EV_APP, GTK_FILE_CHOOSER_ACTION_SAVE); + if (default_uri) { + gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (fc), default_uri); + } else { + const gchar *folder; + + folder = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS); + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fc), + folder ? folder : g_get_home_dir ()); + } + g_object_unref (file); g_free (base_name); - + g_signal_connect (fc, "response", G_CALLBACK (file_save_dialog_response_cb), ev_window); @@ -2927,6 +2991,11 @@ ev_window_print_range (EvWindow *ev_window, ev_window->priv->print_queue = g_queue_new (); op = ev_print_operation_new (ev_window->priv->document); + if (!op) { + g_warning ("%s", "Printing is not supported for document\n"); + return; + } + g_signal_connect (op, "begin_print", G_CALLBACK (ev_window_print_operation_begin_print), (gpointer)ev_window); @@ -2947,6 +3016,12 @@ ev_window_print_range (EvWindow *ev_window, ev_window_load_print_settings_from_metadata (ev_window); } + if (!ev_window->priv->print_page_setup) { + ev_window->priv->print_page_setup = gtk_page_setup_copy ( + ev_application_get_page_setup (EV_APP)); + ev_window_load_print_page_setup_from_metadata (ev_window); + } + if (first_page != 1 || last_page != document_last_page) { GtkPageRange range; @@ -2963,8 +3038,7 @@ ev_window_print_range (EvWindow *ev_window, ev_print_operation_set_job_name (op, gtk_window_get_title (GTK_WINDOW (ev_window))); ev_print_operation_set_current_page (op, current_page); ev_print_operation_set_print_settings (op, ev_window->priv->print_settings); - if (ev_window->priv->print_page_setup) - ev_print_operation_set_default_page_setup (op, ev_window->priv->print_page_setup); + ev_print_operation_set_default_page_setup (op, ev_window->priv->print_page_setup); ev_print_operation_run (op, GTK_WINDOW (ev_window)); } @@ -3552,6 +3626,35 @@ ev_window_cmd_view_presentation (GtkAction *action, EvWindow *window) } } +static void +ev_window_setup_gtk_settings (EvWindow *window) +{ + GtkSettings *settings; + GdkScreen *screen; + gchar *menubar_accel_accel; + + screen = gtk_window_get_screen (GTK_WINDOW (window)); + settings = gtk_settings_get_for_screen (screen); + + g_object_get (settings, + "gtk-menu-bar-accel", &menubar_accel_accel, + NULL); + if (menubar_accel_accel != NULL && menubar_accel_accel[0] != '\0') { + gtk_accelerator_parse (menubar_accel_accel, + &window->priv->menubar_accel_keyval, + &window->priv->menubar_accel_modifier); + if (window->priv->menubar_accel_keyval == 0) { + g_warning ("Failed to parse menu bar accelerator '%s'\n", + menubar_accel_accel); + } + } else { + window->priv->menubar_accel_keyval = 0; + window->priv->menubar_accel_modifier = 0; + } + + g_free (menubar_accel_accel); +} + static void ev_window_screen_changed (GtkWidget *widget, GdkScreen *old_screen) @@ -3564,6 +3667,7 @@ ev_window_screen_changed (GtkWidget *widget, if (screen == old_screen) return; + ev_window_setup_gtk_settings (window); ev_view_set_screen_dpi (EV_VIEW (priv->view), get_screen_dpi (GTK_WINDOW (window))); @@ -3783,7 +3887,6 @@ ev_window_cmd_view_autoscroll (GtkAction *action, EvWindow *ev_window) ev_view_autoscroll_start (EV_VIEW (ev_window->priv->view)); } -#if GTK_CHECK_VERSION (2, 14, 0) static void ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window) { @@ -3799,56 +3902,6 @@ ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window) g_error_free (error); } } -#else /* !GTK_CHECK_VERSION (2, 14, 0) */ -static void -ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window) -{ - GError *error = NULL; - GdkScreen *screen; - char *command; - const char *lang; - char *uri = NULL; - - int i; - - const char * const * langs = g_get_language_names (); - - for (i = 0; langs[i]; i++) { - lang = langs[i]; - if (strchr (lang, '.')) { - continue; - } - - uri = g_build_filename(GNOMEDATADIR, - "/gnome/help/" PACKAGE, - lang, - "/evince.xml", - NULL); - - if (g_file_test (uri, G_FILE_TEST_EXISTS)) { - break; - } - g_free (uri); - uri = NULL; - } - - if (uri == NULL) { - g_warning ("Cannot find help"); - return; - } - - command = g_strconcat ("gnome-help ghelp://", uri, NULL); - g_free (uri); - - screen = gtk_widget_get_screen (GTK_WIDGET (ev_window)); - gdk_spawn_command_line_on_screen (screen, command, &error); - if (error != NULL) { - g_warning ("%s", error->message); - g_error_free (error); - } - g_free (command); -} -#endif /* GTK_CHECK_VERSION (2, 14, 0) */ static void ev_window_cmd_leave_fullscreen (GtkAction *action, EvWindow *window) @@ -4094,6 +4147,7 @@ ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window) "Bryan Clark ", "Carlos Garcia Campos ", "Wouter Bolsterlee ", + "Christian Persch ", NULL }; @@ -4138,7 +4192,7 @@ ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window) "name", _("Evince"), "version", VERSION, "copyright", - _("\xc2\xa9 1996-2007 The Evince authors"), + _("© 1996–2009 The Evince authors"), "license", license_trans, "website", "http://www.gnome.org/projects/evince", "comments", comments, @@ -4546,10 +4600,17 @@ ev_window_drag_data_received (GtkWidget *widget, guint time) { - EvWindow *window = EV_WINDOW (widget); - gchar **uris; - gint i = 0; - GSList *uri_list = NULL; + EvWindow *window = EV_WINDOW (widget); + gchar **uris; + gint i = 0; + GSList *uri_list = NULL; + GtkWidget *source; + + source = gtk_drag_get_source_widget (context); + if (source && widget == gtk_widget_get_toplevel (source)) { + gtk_drag_finish (context, FALSE, FALSE, time); + return; + } uris = gtk_selection_data_get_uris (selection_data); if (!uris) { @@ -4699,11 +4760,6 @@ ev_window_dispose (GObject *object) ev_window_close_dialogs (window); - if (window->priv->printer) { - g_object_unref (window->priv->printer); - window->priv->printer = NULL; - } - if (window->priv->print_settings) { g_object_unref (window->priv->print_settings); window->priv->print_settings = NULL; @@ -4741,6 +4797,8 @@ ev_window_dispose (GObject *object) } if (priv->uri) { + /* Delete the uri if it's a temp symlink (open a copy) */ + ev_window_clear_temp_symlink (window); g_free (priv->uri); priv->uri = NULL; } @@ -4773,6 +4831,64 @@ ev_window_dispose (GObject *object) G_OBJECT_CLASS (ev_window_parent_class)->dispose (object); } +static void +menubar_deactivate_cb (GtkWidget *menubar, + EvWindow *window) +{ + g_signal_handlers_disconnect_by_func (menubar, + G_CALLBACK (menubar_deactivate_cb), + window); + + gtk_menu_shell_deselect (GTK_MENU_SHELL (menubar)); + + update_chrome_visibility (window); +} + +static gboolean +ev_window_key_press_event (GtkWidget *widget, + GdkEventKey *event) +{ + EvWindow *ev_window = EV_WINDOW (widget); + EvWindowPrivate *priv = ev_window->priv; + gboolean handled = FALSE; + + /* Propagate the event to the view first + * It's needed to be able to type in + * annot popups windows + */ + if (priv->view) { + g_object_ref (priv->view); + if (GTK_WIDGET_IS_SENSITIVE (priv->view)) + handled = gtk_widget_event (priv->view, (GdkEvent*) event); + g_object_unref (priv->view); + } + + if (!handled && !ev_view_get_presentation (EV_VIEW (priv->view))) { + guint modifier = event->state & gtk_accelerator_get_default_mod_mask (); + + if (priv->menubar_accel_keyval != 0 && + event->keyval == priv->menubar_accel_keyval && + modifier == priv->menubar_accel_modifier) { + if (!GTK_WIDGET_VISIBLE (priv->menubar)) { + g_signal_connect (priv->menubar, "deactivate", + G_CALLBACK (menubar_deactivate_cb), + ev_window); + + gtk_widget_show (priv->menubar); + gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menubar), + FALSE); + + handled = TRUE; + } + } + } + + if (!handled) + handled = GTK_WIDGET_CLASS (ev_window_parent_class)->key_press_event (widget, event); + + return handled; +} + static void ev_window_class_init (EvWindowClass *ev_window_class) { @@ -4782,6 +4898,7 @@ ev_window_class_init (EvWindowClass *ev_window_class) g_object_class->dispose = ev_window_dispose; g_object_class->finalize = ev_window_finalize; + widget_class->key_press_event = ev_window_key_press_event; widget_class->screen_changed = ev_window_screen_changed; widget_class->window_state_event = ev_window_state_event; widget_class->drag_data_received = ev_window_drag_data_received; @@ -4807,7 +4924,7 @@ static const GtkActionEntry entries[] = { { "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), "S", N_("Save a copy of the current document"), G_CALLBACK (ev_window_cmd_save_as) }, - { "FilePrintSetup", NULL, N_("Print Set_up..."), NULL, + { "FilePageSetup", GTK_STOCK_PAGE_SETUP, N_("Page Set_up..."), NULL, N_("Setup the page settings for printing"), G_CALLBACK (ev_window_cmd_file_print_setup) }, { "FilePrint", GTK_STOCK_PRINT, N_("_Print..."), "P", @@ -4885,6 +5002,8 @@ static const GtkActionEntry entries[] = { G_CALLBACK (ev_window_cmd_escape) }, { "Slash", GTK_STOCK_FIND, NULL, "slash", NULL, G_CALLBACK (ev_window_cmd_edit_find) }, + { "F3", NULL, "", "F3", NULL, + G_CALLBACK (ev_window_cmd_edit_find_next) }, { "PageDown", NULL, "", "Page_Down", NULL, G_CALLBACK (ev_window_cmd_scroll_forward) }, { "PageUp", NULL, "", "Page_Up", NULL, @@ -5238,7 +5357,7 @@ launch_action (EvWindow *window, EvLinkAction *action) GAppInfo *app_info; GFile *file; GList file_list = {NULL}; - GAppLaunchContext *context = NULL; + GAppLaunchContext *context; GError *error = NULL; if (filename == NULL) @@ -5269,12 +5388,10 @@ launch_action (EvWindow *window, EvLinkAction *action) return; } -#if GTK_CHECK_VERSION (2, 14, 0) 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); -#endif file_list.data = file; if (!g_app_info_launch (app_info, &file_list, context, &error)) { @@ -5297,17 +5414,13 @@ launch_external_uri (EvWindow *window, EvLinkAction *action) const gchar *uri = ev_link_action_get_uri (action); GError *error = NULL; gboolean ret; -#if GTK_CHECK_VERSION (2, 14, 0) - GAppLaunchContext *context = NULL; -#endif + GAppLaunchContext *context; -#if GTK_CHECK_VERSION (2, 14, 0) 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); -#endif if (!g_strstr_len (uri, strlen (uri), "://") && !g_str_has_prefix (uri, "mailto:")) { @@ -5369,6 +5482,8 @@ do_action_named (EvWindow *window, EvLinkAction *action) ev_window_cmd_edit_find (NULL, window); } else if (g_ascii_strcasecmp (name, "Close") == 0) { ev_window_cmd_file_close_window (NULL, window); + } else if (g_ascii_strcasecmp (name, "Print") == 0) { + ev_window_cmd_file_print (NULL, window); } else { g_warning ("Unimplemented named action: %s, please post a " "bug report in Evince bugzilla " @@ -5776,6 +5891,7 @@ ev_window_init (EvWindow *ev_window) GError *error = NULL; GtkWidget *sidebar_widget; GObject *mpkeys; + gchar *ui_path; g_signal_connect (ev_window, "configure_event", G_CALLBACK (window_configure_event_cb), NULL); @@ -5830,12 +5946,15 @@ ev_window_init (EvWindow *ev_window) gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager, action_group, 0); - if (!gtk_ui_manager_add_ui_from_file (ev_window->priv->ui_manager, - DATADIR"/evince-ui.xml", - &error)) { + ui_path = g_build_filename (ev_application_get_data_dir (EV_APP), + "evince-ui.xml", NULL); + if (!gtk_ui_manager_add_ui_from_file ( + ev_window->priv->ui_manager, ui_path, &error)) + { g_warning ("building menus failed: %s", error->message); g_error_free (error); } + g_free (ui_path); ev_window->priv->recent_manager = gtk_recent_manager_get_default (); ev_window->priv->recent_action_group = NULL; @@ -6069,13 +6188,15 @@ ev_window_init (EvWindow *ev_window) G_CALLBACK (ev_window_media_player_key_pressed), ev_window); } - + /* Give focus to the document view */ gtk_widget_grab_focus (ev_window->priv->view); /* Set it user interface params */ ev_window_setup_recent (ev_window); + ev_window_setup_gtk_settings (ev_window); + setup_chrome_from_metadata (ev_window); set_chrome_actions (ev_window); update_chrome_visibility (ev_window);