From a6fd45551db35e90ad13c0c483854740aefa312f Mon Sep 17 00:00:00 2001 From: Hib Eris Date: Tue, 09 Jun 2009 17:33:21 +0000 Subject: [printing] Make use of gtk+-unix-print optional --- diff --git a/configure.ac b/configure.ac index ca89c27..86f13ec 100644 --- a/configure.ac +++ b/configure.ac @@ -99,15 +99,7 @@ esac AC_MSG_RESULT([$os_win32]) AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes") -dnl Check dependencies - -# LIB_CFLAGS for helpers and generic widgets. (libdocument, cut-and-paste) -# BACKEND_CFLAGS for backend implementations. -# FRONTEND_CFLAGS for frontend implementations. (properties, thumbnailer) -# FRONTEND_LIBS -# SHELL_CFLAGS for shell implementation. -# SHELL_LIBS - +dnl Specify required versions of dependencies DBUS_GLIB_REQUIRED=0.70 GTK_REQUIRED=2.14.0 GLIB_REQUIRED=2.18.0 @@ -118,12 +110,21 @@ AC_SUBST([GTK_REQUIRED]) GNOME_ICON_THEME_REQUIRED=2.17.1 LIBXML_REQUIRED=2.5.0 +dnl Check dependencies + +# LIB_CFLAGS for helpers and generic widgets. (libdocument, cut-and-paste) +# BACKEND_CFLAGS for backend implementations. +# FRONTEND_CFLAGS for frontend implementations. (properties, thumbnailer) +# FRONTEND_LIBS +# SHELL_CFLAGS for shell implementation. +# SHELL_LIBS + PKG_CHECK_MODULES(LIBDOCUMENT, gtk+-2.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED) PKG_CHECK_MODULES(LIBVIEW, gtk+-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED) PKG_CHECK_MODULES(BACKEND, gtk+-2.0 >= $GTK_REQUIRED) PKG_CHECK_MODULES(FRONTEND_CORE, gtk+-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED) -PKG_CHECK_MODULES(PREVIEWER, gtk+-2.0 >= $GTK_REQUIRED gtk+-unix-print-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED) -PKG_CHECK_MODULES(SHELL_CORE, libxml-2.0 >= $LIBXML_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gtk+-unix-print-2.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED gthread-2.0) +PKG_CHECK_MODULES(PREVIEWER, gtk+-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED) +PKG_CHECK_MODULES(SHELL_CORE, libxml-2.0 >= $LIBXML_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED gthread-2.0) if test "$os_win32" = no; then PKG_CHECK_MODULES(SMCLIENT, gtk+-2.0 gthread-2.0 sm >= 1.0.0) @@ -143,6 +144,25 @@ LIBS="$LIBS $BACKEND_LIBS" AC_CHECK_FUNCS(cairo_format_stride_for_width) LIBS=$evince_save_LIBS +dnl ========= Check for gtk+-unix-print + +if test "$os_win32" = yes; then + with_gtk_unix_print_default=no +else + with_gtk_unix_print_default=yes +fi + +AC_MSG_CHECKING([whether gtk+-unix-print support is requested]) +AC_ARG_WITH([gtk-unix-print], + [AS_HELP_STRING([--without-gtk-unix-print],[disable the use of gtk-unix-print])], + [],[with_gtk_unix_print=$with_gtk_unix_print_default]) +AC_MSG_RESULT([$with_gtk_unix_print]) + +if test "$with_gtk_unix_print" = "yes"; then + PKG_CHECK_MODULES(GTKUNIXPRINT, [gtk+-unix-print-2.0 >= $GTK_REQUIRED]) + AC_DEFINE([GTKUNIXPRINT_ENABLED], [1], [Define if gtk+-unix-print is enabled.]) +fi + dnl ========= Check for Keyring AC_ARG_WITH(keyring, AC_HELP_STRING([--without-keyring],[disable the use of gnome-keyring]), @@ -258,8 +278,8 @@ BACKEND_CFLAGS="$BACKEND_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE $DEBUG AC_SUBST(BACKEND_CFLAGS) AC_SUBST(BACKEND_LIBS) -SHELL_CFLAGS="$SHELL_CORE_CFLAGS $DBUS_CFLAGS $KEYRING_CFLAGS $GCONF_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE $DEBUG_FLAGS" -SHELL_LIBS="$SHELL_CORE_LIBS $DBUS_LIBS $KEYRING_LIBS $GCONF_LIBS -lz" +SHELL_CFLAGS="$SHELL_CORE_CFLAGS $GTKUNIXPRINT_CFLAGS $DBUS_CFLAGS $KEYRING_CFLAGS $GCONF_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE $DEBUG_FLAGS" +SHELL_LIBS="$SHELL_CORE_LIBS $GTKUNIXPRINT_CFLAGS $DBUS_LIBS $KEYRING_LIBS $GCONF_LIBS -lz" AC_SUBST(SHELL_CFLAGS) AC_SUBST(SHELL_LIBS) @@ -314,15 +334,12 @@ AC_ARG_ENABLE(previewer, esac], [ENABLE_PREVIEWER=yes]) dnl Default value if test x$ENABLE_PREVIEWER = "xyes" ; then - PKG_CHECK_MODULES(PREVIEWER, gtk+-2.0 >= $GTK_REQUIRED gtk+-unix-print-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED, + PKG_CHECK_MODULES(PREVIEWER, gtk+-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED, [ENABLE_PREVIEWER=yes],[ENABLE_PREVIEWER=no]) - if test x$ENABLE_PREVIEWER = "xno" ; then - AC_MSG_WARN([Previewer support is disabled since gtk+-unix-print $GTK_REQUIRED or higher was not found]) - fi fi AM_CONDITIONAL(ENABLE_PREVIEWER, test x$ENABLE_PREVIEWER = "xyes") -PREVIEWER_CFLAGS="$PREVIEWER_CFLAGS $DEBUG_FLAGS" -PREVIEWER_LIBS="$PREVIEWER_LIBS -lz" +PREVIEWER_CFLAGS="$PREVIEWER_CFLAGS $GTKUNIXPRINT_CFLAGS $DEBUG_FLAGS" +PREVIEWER_LIBS="$PREVIEWER_LIBS $GTKUNIXPRINT_LIBS -lz" AC_SUBST(PREVIEWER_CFLAGS) AC_SUBST(PREVIEWER_LIBS) @@ -675,6 +692,7 @@ AC_OUTPUT echo " Configure summary: GConf Support......: $with_gconf + GTK+ Unix Print....: $with_gtk_unix_print Keyring Support....: $WITH_KEYRING DBUS Support.......: $enable_dbus Nautilus Plugin....: $HAVE_NAUTILUS diff --git a/previewer/ev-previewer-window.c b/previewer/ev-previewer-window.c index 15a1607..686fb0d 100644 --- a/previewer/ev-previewer-window.c +++ b/previewer/ev-previewer-window.c @@ -20,7 +20,9 @@ #include +#if GTKUNIXPRINT_ENABLED #include +#endif #include #include #include "ev-page-action.h" @@ -42,7 +44,9 @@ struct _EvPreviewerWindow { /* Printing */ GtkPrintSettings *print_settings; GtkPageSetup *print_page_setup; +#if GTKUNIXPRINT_ENABLED GtkPrinter *printer; +#endif gchar *print_job_title; gchar *source_file; }; @@ -103,6 +107,7 @@ ev_previewer_window_set_view_size (EvPreviewerWindow *window) hsb_requisition.height + scrollbar_spacing); } +#if GTKUNIXPRINT_ENABLED static void ev_previewer_window_error_dialog_run (EvPreviewerWindow *window, GError *error) @@ -120,6 +125,7 @@ ev_previewer_window_error_dialog_run (EvPreviewerWindow *window, gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } +#endif static void ev_previewer_window_previous_page (GtkAction *action, @@ -184,6 +190,7 @@ ev_previewer_window_action_page_activated (GtkAction *action, gtk_widget_grab_focus (GTK_WIDGET (window->view)); } +#if GTKUNIXPRINT_ENABLED static void ev_previewer_window_print_finished (GtkPrintJob *print_job, EvPreviewerWindow *window, @@ -273,6 +280,7 @@ ev_previewer_window_print (GtkAction *action, (GDestroyNotify)ev_previewer_window_enumerate_finished, FALSE); } +#endif static const GtkActionEntry action_entries[] = { { "GoPreviousPage", GTK_STOCK_GO_UP, N_("_Previous Page"), "Page_Up", @@ -287,9 +295,11 @@ static const GtkActionEntry action_entries[] = { { "ViewZoomOut", GTK_STOCK_ZOOM_OUT, NULL, "minus", N_("Shrink the document"), G_CALLBACK (ev_previewer_window_zoom_out) }, +#if GTKUNIXPRINT_ENABLED { "PreviewPrint", GTK_STOCK_PRINT, N_("Print"), NULL, N_("Print this document"), G_CALLBACK (ev_previewer_window_print) } +#endif }; static const GtkToggleActionEntry toggle_action_entries[] = { @@ -368,10 +378,12 @@ ev_previewer_window_dispose (GObject *object) window->print_page_setup = NULL; } +#if GTKUNIXPRINT_ENABLED if (window->printer) { g_object_unref (window->printer); window->printer = NULL; } +#endif if (window->print_job_title) { g_free (window->print_job_title); diff --git a/shell/ev-print-operation.c b/shell/ev-print-operation.c index e583dfb..9c21a1d 100644 --- a/shell/ev-print-operation.c +++ b/shell/ev-print-operation.c @@ -21,7 +21,9 @@ #include "ev-print-operation.h" +#if GTKUNIXPRINT_ENABLED #include +#endif #include #include #include @@ -297,6 +299,7 @@ ev_print_operation_get_progress (EvPrintOperation *op) return op->progress; } +#if GTK_CHECK_VERSION (2, 17, 1) | GTKUNIXPRINT_ENABLED static void ev_print_operation_update_status (EvPrintOperation *op, gint page, @@ -322,6 +325,9 @@ ev_print_operation_update_status (EvPrintOperation *op, g_signal_emit (op, signals[STATUS_CHANGED], 0); } +#endif + +#if GTKUNIXPRINT_ENABLED /* Export interface */ #define EV_TYPE_PRINT_OPERATION_EXPORT (ev_print_operation_export_get_type()) @@ -1372,6 +1378,8 @@ ev_print_operation_export_class_init (EvPrintOperationExportClass *klass) g_object_class->finalize = ev_print_operation_export_finalize; } +#endif /* GTKUNIXPRINT_ENABLED */ + #if GTK_CHECK_VERSION (2, 17, 1) /* Print to cairo interface */ #define EV_TYPE_PRINT_OPERATION_PRINT (ev_print_operation_print_get_type()) @@ -1645,18 +1653,28 @@ ev_print_operation_print_class_init (EvPrintOperationPrintClass *klass) gboolean ev_print_operation_exists_for_document (EvDocument *document) { +#if GTKUNIXPRINT_ENABLED #if GTK_CHECK_VERSION (2, 17, 1) return (EV_IS_FILE_EXPORTER(document) || EV_IS_DOCUMENT_PRINT(document)); #else return EV_IS_FILE_EXPORTER(document); #endif +#else /* ! GTKUNIXPRINT_ENABLED */ +#if GTK_CHECK_VERSION (2, 17, 1) + return EV_IS_DOCUMENT_PRINT(document); +#else + return FALSE; +#endif +#endif /* GTKUNIXPRINT_ENABLED */ } /* Factory method */ EvPrintOperation * ev_print_operation_new (EvDocument *document) { - EvPrintOperation *op; + EvPrintOperation *op = NULL; + + g_return_val_if_fail (ev_print_operation_exists_for_document (document), NULL); #if GTK_CHECK_VERSION (2, 17, 1) if (EV_IS_DOCUMENT_PRINT (document)) @@ -1664,8 +1682,9 @@ ev_print_operation_new (EvDocument *document) "document", document, NULL)); else #endif +#if GTKUNIXPRINT_ENABLED op = EV_PRINT_OPERATION (g_object_new (EV_TYPE_PRINT_OPERATION_EXPORT, "document", document, NULL)); - +#endif return op; } diff --git a/shell/ev-window.c b/shell/ev-window.c index 7984cab..cb8de7c 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -2989,6 +2989,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); -- cgit v0.9.1