Commit c57fc804 authored by gheet's avatar gheet
Browse files

Adding PAPI printbackend

Adding a new print backend module using libpapi detals see GNOME#382676.
(gheet)
parent 0fd185fa
...@@ -1879,6 +1879,28 @@ else ...@@ -1879,6 +1879,28 @@ else
AM_CONDITIONAL(HAVE_CUPS, false) AM_CONDITIONAL(HAVE_CUPS, false)
fi fi
# Checks to see if we should compile with PAPI backend for GTK+
#
AC_ARG_ENABLE(papi,
[AC_HELP_STRING([--disable-papi]
[disable papi print backend])],,
[enable_papi=auto])
if test "x$enable_papi" = "xauto"
then
AC_MSG_CHECKING(libpapi)
AC_CHECK_LIB(papi, papiServiceCreate, have_papi=yes, have_papi=no)
if test $have_papi = yes; then
AC_DEFINE([HAVE_PAPI], [], [Define to 1 if libpapi available])
fi
AM_CONDITIONAL(HAVE_PAPI, test $have_papi = yes)
else
AM_CONDITIONAL(HAVE_PAPI, false)
fi
AM_CONDITIONAL(HAVE_PAPI_CUPS, test $have_papi = yes && test "x$CUPS_CONFIG" != "xno")
gtk_save_cppflags="$CPPFLAGS" gtk_save_cppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $GTK_DEP_CFLAGS" CPPFLAGS="$CPPFLAGS $GTK_DEP_CFLAGS"
...@@ -2107,6 +2129,7 @@ modules/printbackends/Makefile ...@@ -2107,6 +2129,7 @@ modules/printbackends/Makefile
modules/printbackends/cups/Makefile modules/printbackends/cups/Makefile
modules/printbackends/lpr/Makefile modules/printbackends/lpr/Makefile
modules/printbackends/file/Makefile modules/printbackends/file/Makefile
modules/printbackends/papi/Makefile
modules/printbackends/test/Makefile modules/printbackends/test/Makefile
perf/Makefile perf/Makefile
contrib/Makefile contrib/Makefile
......
...@@ -10,11 +10,19 @@ endif ...@@ -10,11 +10,19 @@ endif
SUBDIRS = theme-bits . tests SUBDIRS = theme-bits . tests
DIST_SUBDIRS=theme-bits tests DIST_SUBDIRS=theme-bits tests
if HAVE_PAPI_CUPS
GTK_PRINT_BACKENDS=file,papi,cups
else
if HAVE_CUPS if HAVE_CUPS
GTK_PRINT_BACKENDS=file,cups GTK_PRINT_BACKENDS=file,cups
else else
if HAVE_PAPI
GTK_PRINT_BACKENDS=file,papi
else
GTK_PRINT_BACKENDS=file,lpr GTK_PRINT_BACKENDS=file,lpr
endif endif
endif
endif
INCLUDES = \ INCLUDES = \
-DG_LOG_DOMAIN=\"Gtk\" \ -DG_LOG_DOMAIN=\"Gtk\" \
......
...@@ -10,6 +10,10 @@ if TEST_PRINT_BACKEND ...@@ -10,6 +10,10 @@ if TEST_PRINT_BACKEND
SUBDIRS += test SUBDIRS += test
endif endif
if HAVE_PAPI
SUBDIRS += papi
endif
DIST_SUBDIRS = cups file lpr test DIST_SUBDIRS = cups file lpr test
-include $(top_srcdir)/git.mk -include $(top_srcdir)/git.mk
if OS_WIN32
no_undefined = -no-undefined
endif
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/gtk \
-I$(top_builddir)/gtk \
-I$(top_srcdir)/gdk \
-I$(top_builddir)/gdk \
-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED \
$(GTK_DEP_CFLAGS) \
$(GTK_DEBUG_FLAGS)
LDADDS = \
$(GTK_DEP_LIBS) \
$(top_builddir)/gtk/$(gtktargetlib)
backenddir = $(libdir)/gtk-2.0/$(GTK_BINARY_VERSION)/printbackends
backend_LTLIBRARIES = libprintbackend-papi.la
libprintbackend_papi_la_SOURCES = \
gtkprinterpapi.c \
gtkprintbackendpapi.c
noinst_HEADERS = \
gtkprinterpapi.h \
gtkprintbackendpapi.h
libprintbackend_papi_la_LDFLAGS = -avoid-version -module $(no_undefined)
libprintbackend_papi_la_LIBADD = $(LDADDS) -lpapi
This diff is collapsed.
/* GTK - The GIMP Toolkit
* gtkprintbackendpapi.h: Default implementation of GtkPrintBackend
* for printing to papi
* Copyright (C) 2003, Red Hat, Inc.
* Copyright (C) 2009, Sun Microsystems, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_PRINT_BACKEND_PAPI_H__
#define __GTK_PRINT_BACKEND_PAPI_H__
#include <glib-object.h>
#include "gtkprintbackend.h"
G_BEGIN_DECLS
#define GTK_TYPE_PRINT_BACKEND_PAPI (gtk_print_backend_papi_get_type ())
#define GTK_PRINT_BACKEND_PAPI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_BACKEND_PAPI, GtkPrintBackendPapi))
#define GTK_IS_PRINT_BACKEND_PAPI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_BACKEND_PAPI))
typedef struct _GtkPrintBackendPapi GtkPrintBackendPapi;
GtkPrintBackend *gtk_print_backend_papi_new (void);
GType gtk_print_backend_papi_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GTK_PRINT_BACKEND_PAPI_H__ */
/* GtkPrinterPapi
* Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
* Copyright (C) 2009 Ghee Teo <ghee.teo@sun.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gtkprinterpapi.h"
static void gtk_printer_papi_init (GtkPrinterPapi *printer);
static void gtk_printer_papi_class_init (GtkPrinterPapiClass *class);
static void gtk_printer_papi_finalize (GObject *object);
static GtkPrinterClass *gtk_printer_papi_parent_class;
static GType gtk_printer_papi_type = 0;
void
gtk_printer_papi_register_type (GTypeModule *module)
{
static const GTypeInfo object_info =
{
sizeof (GtkPrinterPapiClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gtk_printer_papi_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkPrinterPapi),
0, /* n_preallocs */
(GInstanceInitFunc) gtk_printer_papi_init,
};
gtk_printer_papi_type = g_type_module_register_type (module,
GTK_TYPE_PRINTER,
"GtkPrinterPapi",
&object_info, 0);
}
GType
gtk_printer_papi_get_type (void)
{
return gtk_printer_papi_type;
}
static void
gtk_printer_papi_class_init (GtkPrinterPapiClass *class)
{
GObjectClass *object_class = (GObjectClass *) class;
gtk_printer_papi_parent_class = g_type_class_peek_parent (class);
object_class->finalize = gtk_printer_papi_finalize;
}
static void
gtk_printer_papi_init (GtkPrinterPapi *printer)
{
printer->printer_name = NULL;
}
static void
gtk_printer_papi_finalize (GObject *object)
{
GtkPrinterPapi *printer;
g_return_if_fail (object != NULL);
printer = GTK_PRINTER_PAPI (object);
g_free(printer->printer_name);
G_OBJECT_CLASS (gtk_printer_papi_parent_class)->finalize (object);
}
/**
* gtk_printer_papi_new:
*
* Creates a new #GtkPrinterPapi.
*
* Return value: a new #GtkPrinterPapi
*
* Since: 2.10
**/
GtkPrinterPapi *
gtk_printer_papi_new (const char *name,
GtkPrintBackend *backend)
{
GObject *result;
GtkPrinterPapi *pp;
result = g_object_new (GTK_TYPE_PRINTER_PAPI,
"name", name,
"backend", backend,
"is-virtual", TRUE,
NULL);
pp = GTK_PRINTER_PAPI(result);
pp->printer_name = g_strdup (name);
return (GtkPrinterPapi *) pp;
}
/* GtkPrinterPapi
* Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
* Copyright (C) 2009 Ghee Teo <ghee.teo@sun.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_PRINTER_PAPI_H__
#define __GTK_PRINTER_PAPI_H__
#include <glib.h>
#include <glib-object.h>
#include <papi.h>
#include "gtkunixprint.h"
G_BEGIN_DECLS
#define GTK_TYPE_PRINTER_PAPI (gtk_printer_papi_get_type ())
#define GTK_PRINTER_PAPI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINTER_PAPI, GtkPrinterPapi))
#define GTK_PRINTER_PAPI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINTER_PAPI, GtkPrinterPapiClass))
#define GTK_IS_PRINTER_PAPI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINTER_PAPI))
#define GTK_IS_PRINTER_PAPI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINTER_PAPI))
#define GTK_PRINTER_PAPI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINTER_PAPI, GtkPrinterPapiClass))
typedef struct _GtkPrinterPapi GtkPrinterPapi;
typedef struct _GtkPrinterPapiClass GtkPrinterPapiClass;
typedef struct _GtkPrinterPapiPrivate GtkPrinterPapiPrivate;
struct _GtkPrinterPapi
{
GtkPrinter parent_instance;
gchar *printer_name;
};
struct _GtkPrinterPapiClass
{
GtkPrinterClass parent_class;
};
GType gtk_printer_papi_get_type (void) G_GNUC_CONST;
void gtk_printer_papi_register_type (GTypeModule *module);
GtkPrinterPapi *gtk_printer_papi_new (const char *name, GtkPrintBackend *backend);
G_END_DECLS
#endif /* __GTK_PRINTER_PAPI_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment