X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-window.c;h=bc7d1513f2b922573d8e4adb863c1e37216aa1be;hb=6821de696db5b2d3225015b01d428ba8a0302960;hp=284a11f64406b681a1c1abb350b1e861c64e0a5c;hpb=dcbfea198cd2a4550fd4076d5787d15b34d1038f;p=evince.git diff --git a/shell/ev-window.c b/shell/ev-window.c index 284a11f6..bc7d1513 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -38,11 +38,8 @@ #include #include #include -#if GTK_CHECK_VERSION (2, 14, 0) #include -#else -#include -#endif + #ifdef WITH_GCONF #include #endif @@ -73,7 +70,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" @@ -388,7 +384,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 +436,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); @@ -994,10 +992,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 +1159,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; } @@ -1246,15 +1247,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); } @@ -1588,12 +1593,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, @@ -1606,7 +1614,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; } @@ -1689,19 +1699,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); @@ -1889,8 +1897,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); @@ -2076,10 +2083,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); @@ -2088,29 +2096,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; } @@ -2412,8 +2423,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); @@ -3797,7 +3807,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) { @@ -3813,56 +3822,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) @@ -4823,7 +4782,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", @@ -4901,6 +4860,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, @@ -5254,7 +5215,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) @@ -5285,12 +5246,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)) { @@ -5313,17 +5272,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:")) {