X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=inline;f=shell%2Fev-window.c;h=9f6f0828ffba403437d6fcc29bc4f0159982c316;hb=c8ec9ff73aa7427358b8cce418e00ea7a3a977c6;hp=d48e4c0019679af8c24c90981df4d4944c94b975;hpb=ab01c765c4ebb57906bfd8cad8b48d63d1278d90;p=evince.git diff --git a/shell/ev-window.c b/shell/ev-window.c index d48e4c00..9f6f0828 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -192,6 +192,7 @@ struct _EvWindowPrivate { #ifdef WITH_GTK_PRINT EvJob *print_job; + gboolean print_preview; GtkPrintJob *gtk_print_job; GtkPrinter *printer; GtkPrintSettings *print_settings; @@ -1092,7 +1093,7 @@ ev_window_setup_document (EvWindow *ev_window) 0, 0, 1.0, &page_width, &page_height); scale = (gdouble)128 / (gdouble)page_width; - + rc = ev_render_context_new (0, 0, scale); ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, rc); g_signal_connect (ev_window->priv->thumbnail_job, "finished", @@ -2171,6 +2172,11 @@ ev_window_clear_print_job (EvWindow *window) g_object_unref (window->priv->print_job); window->priv->print_job = NULL; } + + if (window->priv->gtk_print_job) { + g_object_unref (window->priv->gtk_print_job); + window->priv->gtk_print_job = NULL; + } } static void @@ -2204,13 +2210,8 @@ static void ev_window_print_send (EvWindow *window, const gchar *filename) { - GtkPrintJob *job; GtkPrintSettings *settings; - GError *error = NULL; - if (window->priv->gtk_print_job) - g_object_unref (window->priv->gtk_print_job); - /* Some printers take into account some print settings, * and others don't. However we have exported the document * to a ps or pdf file according to such print settings. So, @@ -2225,25 +2226,54 @@ ev_window_print_send (EvWindow *window, gtk_print_settings_set_scale (settings, 1.0); gtk_print_settings_set_collate (settings, FALSE); gtk_print_settings_set_reverse (settings, FALSE); - - job = gtk_print_job_new ("evince-print", - window->priv->printer, - settings, - window->priv->print_page_setup); - g_object_unref (settings); - - window->priv->gtk_print_job = job; + if (window->priv->print_preview) { + gchar *uri; + gchar *print_settings_file = NULL; - if (gtk_print_job_set_source_file (job, filename, &error)) { - gtk_print_job_send (job, - (GtkPrintJobCompleteFunc)ev_window_print_finished, - window, NULL); + ev_application_set_print_settings (EV_APP, + window->priv->print_settings); + +#if GTK_CHECK_VERSION (2, 11, 0) + print_settings_file = ev_tmp_filename ("print-settings"); + gtk_print_settings_to_file (settings, print_settings_file, NULL); +#endif + uri = g_filename_to_uri (filename, NULL, NULL); + ev_application_open_uri_at_dest (EV_APP, + uri, + gtk_window_get_screen (GTK_WINDOW (window)), + NULL, + EV_WINDOW_MODE_PREVIEW, + TRUE, + print_settings_file, + GDK_CURRENT_TIME); + g_free (print_settings_file); + g_free (uri); } else { - ev_window_clear_print_job (window); - g_warning (error->message); - g_error_free (error); + GtkPrintJob *job; + GError *error = NULL; + + job = gtk_print_job_new ("evince-print", + window->priv->printer, + settings, + window->priv->print_page_setup); + + if (window->priv->gtk_print_job) + g_object_unref (window->priv->gtk_print_job); + window->priv->gtk_print_job = job; + + if (gtk_print_job_set_source_file (job, filename, &error)) { + gtk_print_job_send (job, + (GtkPrintJobCompleteFunc)ev_window_print_finished, + window, NULL); + } else { + ev_window_clear_print_job (window); + g_warning (error->message); + g_error_free (error); + } } + + g_object_unref (settings); } static void @@ -2279,13 +2309,15 @@ ev_window_print_dialog_response_cb (GtkDialog *dialog, GtkPrintPages print_pages; const gchar *file_format; - if (response != GTK_RESPONSE_OK) { + if (response == GTK_RESPONSE_CANCEL) { gtk_widget_destroy (GTK_WIDGET (dialog)); window->priv->print_dialog = NULL; return FALSE; } + window->priv->print_preview = (response == GTK_RESPONSE_APPLY); + if (window->priv->printer) g_object_unref (window->priv->printer); if (window->priv->print_settings) @@ -2430,7 +2462,8 @@ ev_window_print_range (EvWindow *ev_window, int first_page, int last_page) GTK_PRINT_CAPABILITY_COLLATE | GTK_PRINT_CAPABILITY_REVERSE | GTK_PRINT_CAPABILITY_SCALE | - GTK_PRINT_CAPABILITY_GENERATE_PS; + GTK_PRINT_CAPABILITY_GENERATE_PS | + GTK_PRINT_CAPABILITY_PREVIEW; if (EV_IS_FILE_EXPORTER (ev_window->priv->document) && ev_file_exporter_format_supported (EV_FILE_EXPORTER (ev_window->priv->document), @@ -3765,6 +3798,9 @@ ev_window_view_toolbar_cb (GtkAction *action, EvWindow *ev_window) static void ev_window_view_sidebar_cb (GtkAction *action, EvWindow *ev_window) { + if (ev_view_get_presentation (EV_VIEW (ev_window->priv->view))) + return; + update_chrome_flag (ev_window, EV_CHROME_SIDEBAR, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))); } @@ -4398,10 +4434,10 @@ static const GtkToggleActionEntry toggle_entries[] = { { "ViewDual", EV_STOCK_VIEW_DUAL, N_("_Dual"), NULL, N_("Show two pages at once"), G_CALLBACK (ev_window_cmd_dual), FALSE }, - { "ViewFullscreen", NULL, N_("_Fullscreen"), "F11", + { "ViewFullscreen", GTK_STOCK_FULLSCREEN, N_("_Fullscreen"), "F11", N_("Expand the window to fill the screen"), G_CALLBACK (ev_window_cmd_view_fullscreen) }, - { "ViewPresentation", NULL, N_("_Presentation"), "F5", + { "ViewPresentation", EV_STOCK_RUN_PRESENTATION, N_("_Presentation"), "F5", N_("Run document as a presentation"), G_CALLBACK (ev_window_cmd_view_presentation) }, { "ViewBestFit", EV_STOCK_ZOOM_PAGE, N_("_Best Fit"), NULL, @@ -4466,6 +4502,7 @@ register_custom_actions (EvWindow *window, GtkActionGroup *group) "name", PAGE_SELECTOR_ACTION, "label", _("Page"), "tooltip", _("Select Page"), + "icon_name", "text-x-generic", "visible_overflown", FALSE, NULL); g_signal_connect (action, "activate_link", @@ -4476,7 +4513,7 @@ register_custom_actions (EvWindow *window, GtkActionGroup *group) action = g_object_new (EPHY_TYPE_ZOOM_ACTION, "name", ZOOM_CONTROL_ACTION, "label", _("Zoom"), - "stock_id", GTK_STOCK_ZOOM_IN, + "stock_id", EV_STOCK_ZOOM, "tooltip", _("Adjust the zoom level"), "zoom", 1.0, NULL);