Commit c36d8f3c authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Added new symbols

2006-05-04  Alexander Larsson  <alexl@redhat.com>

	* gtk/gtk.symbols:
	Added new symbols

	* gtk/gtkpagesetupunixdialog.c:
	* gtk/gtkprintunixdialog.c:
	Destroy backends when finalizing dialogs.
	Fix printer leak in selected_printer_changed.

	* gtk/gtkprintbackend.[ch]:
	Convert from interface to baseclass.
	Move printer hashtable here so that the baseclass can handle
	the slightly complicated ownership model.
	Add gtk_print_backend_destroy which runs the dispose method,
	causing the ref-cycles between the backend and its printers
	to be broken.
	Add gtk_print_backend_unref_at_idle().

	* gtk/gtkprinter.[ch]:
	GtkPrinter objects now ref their backend so that its always
	availible, since its needed for the printer object to work.
	This causes a reference-cycle that is broken using
	gtk_print_backend_destroy.
	Add gtk_printer_compare.

	* gtk/gtkprintoperation-private.h:
	* gtk/gtkprintoperation-unix.c:
	* gtk/gtkprintoperation.c:
	Implement !show_dialog for unix.
	Make sure the print data is fully spooled before returning
	from a sync run_dialog.


	* modules/printbackends/cups/gtkcupsutils.[ch]:
	Add gtk_cups_request_ipp_add_strings

	* modules/printbackends/cups/gtkprintbackendcups.c:
	* modules/printbackends/cups/gtkprintercups.c:
	* modules/printbackends/lpr/gtkprintbackendlpr.c:
	* modules/printbackends/pdf/gtkprintbackendpdf.c:
	Convert backends to derive instead of implementing interface.
	Move common code into baseclass.
	CUPS:
	  Remove the printer polling in dispose, not finalize.
	  In the cups watch, remove the backend at idle instead of
	  immediately, since the unref can cause the module to be unloaded.
	  Limit the number of printer attributes requested
	  Get printer uri in initial printer listing so that we can use
	  the printer object immediately.

	* tests/Makefile.am:
	* tests/testnouiprint.c:
	Add testcase for !show_dialog.
parent 89b5cb64
2006-05-04 Alexander Larsson <alexl@redhat.com>
* gtk/gtk.symbols:
Added new symbols
* gtk/gtkpagesetupunixdialog.c:
* gtk/gtkprintunixdialog.c:
Destroy backends when finalizing dialogs.
Fix printer leak in selected_printer_changed.
* gtk/gtkprintbackend.[ch]:
Convert from interface to baseclass.
Move printer hashtable here so that the baseclass can handle
the slightly complicated ownership model.
Add gtk_print_backend_destroy which runs the dispose method,
causing the ref-cycles between the backend and its printers
to be broken.
Add gtk_print_backend_unref_at_idle().
* gtk/gtkprinter.[ch]:
GtkPrinter objects now ref their backend so that its always
availible, since its needed for the printer object to work.
This causes a reference-cycle that is broken using
gtk_print_backend_destroy.
Add gtk_printer_compare.
* gtk/gtkprintoperation-private.h:
* gtk/gtkprintoperation-unix.c:
* gtk/gtkprintoperation.c:
Implement !show_dialog for unix.
Make sure the print data is fully spooled before returning
from a sync run_dialog.
* modules/printbackends/cups/gtkcupsutils.[ch]:
Add gtk_cups_request_ipp_add_strings
* modules/printbackends/cups/gtkprintbackendcups.c:
* modules/printbackends/cups/gtkprintercups.c:
* modules/printbackends/lpr/gtkprintbackendlpr.c:
* modules/printbackends/pdf/gtkprintbackendpdf.c:
Convert backends to derive instead of implementing interface.
Move common code into baseclass.
CUPS:
Remove the printer polling in dispose, not finalize.
In the cups watch, remove the backend at idle instead of
immediately, since the unref can cause the module to be unloaded.
Limit the number of printer attributes requested
Get printer uri in initial printer listing so that we can use
the printer object immediately.
* tests/Makefile.am:
* tests/testnouiprint.c:
Add testcase for !show_dialog.
2006-05-04 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk.symbols:
......
2006-05-04 Alexander Larsson <alexl@redhat.com>
* gtk/gtk.symbols:
Added new symbols
* gtk/gtkpagesetupunixdialog.c:
* gtk/gtkprintunixdialog.c:
Destroy backends when finalizing dialogs.
Fix printer leak in selected_printer_changed.
* gtk/gtkprintbackend.[ch]:
Convert from interface to baseclass.
Move printer hashtable here so that the baseclass can handle
the slightly complicated ownership model.
Add gtk_print_backend_destroy which runs the dispose method,
causing the ref-cycles between the backend and its printers
to be broken.
Add gtk_print_backend_unref_at_idle().
* gtk/gtkprinter.[ch]:
GtkPrinter objects now ref their backend so that its always
availible, since its needed for the printer object to work.
This causes a reference-cycle that is broken using
gtk_print_backend_destroy.
Add gtk_printer_compare.
* gtk/gtkprintoperation-private.h:
* gtk/gtkprintoperation-unix.c:
* gtk/gtkprintoperation.c:
Implement !show_dialog for unix.
Make sure the print data is fully spooled before returning
from a sync run_dialog.
* modules/printbackends/cups/gtkcupsutils.[ch]:
Add gtk_cups_request_ipp_add_strings
* modules/printbackends/cups/gtkprintbackendcups.c:
* modules/printbackends/cups/gtkprintercups.c:
* modules/printbackends/lpr/gtkprintbackendlpr.c:
* modules/printbackends/pdf/gtkprintbackendpdf.c:
Convert backends to derive instead of implementing interface.
Move common code into baseclass.
CUPS:
Remove the printer polling in dispose, not finalize.
In the cups watch, remove the backend at idle instead of
immediately, since the unref can cause the module to be unloaded.
Limit the number of printer attributes requested
Get printer uri in initial printer listing so that we can use
the printer object immediately.
* tests/Makefile.am:
* tests/testnouiprint.c:
Add testcase for !show_dialog.
2006-05-04 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk.symbols:
......
......@@ -2550,9 +2550,11 @@ gtk_paper_size_get_default
gtk_print_backend_error_quark
gtk_print_backend_get_type G_GNUC_CONST
gtk_print_backend_get_printer_list
gtk_print_backend_printer_list_is_done
gtk_print_backend_find_printer
gtk_print_backend_print_stream
gtk_print_backend_load_modules
gtk_print_backend_unref_at_idle
#endif
#endif
#endif
......
......@@ -110,6 +110,17 @@ static void populate_dialog (GtkPageSetupUnixDialog *dialog
static void fill_paper_sizes_from_printer (GtkPageSetupUnixDialog *dialog,
GtkPrinter *printer);
static void run_custom_paper_dialog (GtkPageSetupUnixDialog *dialog);
static void printer_added_cb (GtkPrintBackend *backend,
GtkPrinter *printer,
GtkPageSetupUnixDialog *dialog);
static void printer_removed_cb (GtkPrintBackend *backend,
GtkPrinter *printer,
GtkPageSetupUnixDialog *dialog);
static void printer_status_cb (GtkPrintBackend *backend,
GtkPrinter *printer,
GtkPageSetupUnixDialog *dialog);
static const char * const common_paper_sizes[] = {
"na_letter",
......@@ -369,7 +380,9 @@ gtk_page_setup_unix_dialog_finalize (GObject *object)
{
GtkPageSetupUnixDialog *dialog = GTK_PAGE_SETUP_UNIX_DIALOG (object);
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
GtkPrintBackend *backend;
GList *node;
if (priv->request_details_tag)
{
g_source_remove (priv->request_details_tag);
......@@ -397,6 +410,21 @@ gtk_page_setup_unix_dialog_finalize (GObject *object)
g_free (priv->waiting_for_printer);
priv->waiting_for_printer = NULL;
for (node = priv->print_backends; node != NULL; node = node->next)
{
backend = GTK_PRINT_BACKEND (node->data);
g_signal_handlers_disconnect_by_func (backend, printer_added_cb, dialog);
g_signal_handlers_disconnect_by_func (backend, printer_removed_cb, dialog);
g_signal_handlers_disconnect_by_func (backend, printer_status_cb, dialog);
gtk_print_backend_destroy (backend);
g_object_unref (backend);
}
g_list_free (priv->print_backends);
priv->print_backends = NULL;
G_OBJECT_CLASS (gtk_page_setup_unix_dialog_parent_class)->finalize (object);
}
......
......@@ -29,7 +29,30 @@
#include "gtkprintbackend.h"
#include "gtkalias.h"
static void gtk_print_backend_base_init (gpointer g_class);
#define GTK_PRINT_BACKEND_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_PRINT_BACKEND, GtkPrintBackendPrivate))
static void gtk_print_backend_dispose (GObject *object);
struct _GtkPrintBackendPrivate
{
GHashTable *printers;
guint printer_list_requested : 1;
guint printer_list_done : 1;
};
enum {
PRINTER_LIST_CHANGED,
PRINTER_LIST_DONE,
PRINTER_ADDED,
PRINTER_REMOVED,
PRINTER_STATUS_CHANGED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
static GObjectClass *backend_parent_class;
GQuark
gtk_print_backend_error_quark (void)
......@@ -142,7 +165,7 @@ _gtk_print_backend_module_class_init (GtkPrintBackendModuleClass *class)
{
GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (class);
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
module_class->load = gtk_print_backend_module_load;
module_class->unload = gtk_print_backend_module_unload;
......@@ -272,107 +295,255 @@ gtk_print_backend_load_modules ()
/*****************************************
* GtkPrintBackend *
*****************************************/
GType
gtk_print_backend_get_type (void)
G_DEFINE_TYPE (GtkPrintBackend, gtk_print_backend, G_TYPE_OBJECT);
static void
gtk_print_backend_class_init (GtkPrintBackendClass *class)
{
static GType print_backend_type = 0;
GObjectClass *object_class;
object_class = (GObjectClass *) class;
if (!print_backend_type)
backend_parent_class = g_type_class_peek_parent (class);
object_class->dispose = gtk_print_backend_dispose;
g_type_class_add_private (class, sizeof (GtkPrintBackendPrivate));
signals[PRINTER_LIST_CHANGED] =
g_signal_new ("printer-list-changed",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkPrintBackendClass, printer_list_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[PRINTER_LIST_DONE] =
g_signal_new ("printer-list-done",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkPrintBackendClass, printer_list_done),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[PRINTER_ADDED] =
g_signal_new ("printer-added",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkPrintBackendClass, printer_added),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, GTK_TYPE_PRINTER);
signals[PRINTER_REMOVED] =
g_signal_new ("printer-removed",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkPrintBackendClass, printer_removed),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, GTK_TYPE_PRINTER);
signals[PRINTER_STATUS_CHANGED] =
g_signal_new ("printer-status-changed",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkPrintBackendClass, printer_status_changed),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, GTK_TYPE_PRINTER);
}
static void
gtk_print_backend_init (GtkPrintBackend *backend)
{
GtkPrintBackendPrivate *priv;
priv = backend->priv = GTK_PRINT_BACKEND_GET_PRIVATE (backend);
priv->printers = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
}
static void
gtk_print_backend_dispose (GObject *object)
{
GtkPrintBackend *backend;
GtkPrintBackendPrivate *priv;
backend = GTK_PRINT_BACKEND (object);
priv = backend->priv;
/* We unref the printers in dispose, not in finalize so that
we can break refcount cycles with gtk_print_backend_destroy */
if (priv->printers)
{
static const GTypeInfo print_backend_info =
{
sizeof (GtkPrintBackendIface), /* class_size */
gtk_print_backend_base_init, /* base_init */
NULL, /* base_finalize */
};
print_backend_type = g_type_register_static (G_TYPE_INTERFACE,
"GtkPrintBackend",
&print_backend_info, 0);
g_type_interface_add_prerequisite (print_backend_type, G_TYPE_OBJECT);
g_hash_table_destroy (priv->printers);
priv->printers = NULL;
}
return print_backend_type;
backend_parent_class->dispose (object);
}
static void
gtk_print_backend_base_init (gpointer g_class)
printer_hash_to_sorted_active_list (const gchar *key,
gpointer value,
GList **out_list)
{
static gboolean initialized = FALSE;
GtkPrinter *printer;
printer = GTK_PRINTER (value);
if (gtk_printer_get_name (printer) == NULL)
return;
if (!gtk_printer_is_active (printer))
return;
*out_list = g_list_insert_sorted (*out_list, value, (GCompareFunc) gtk_printer_compare);
}
void
gtk_print_backend_add_printer (GtkPrintBackend *backend,
GtkPrinter *printer)
{
GtkPrintBackendPrivate *priv;
if (!initialized)
{
GType iface_type = G_TYPE_FROM_INTERFACE (g_class);
g_return_if_fail (GTK_IS_PRINT_BACKEND (backend));
g_signal_new ("printer-list-changed",
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkPrintBackendIface, printer_list_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_new ("printer-added",
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkPrintBackendIface, printer_added),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
g_signal_new ("printer-removed",
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkPrintBackendIface, printer_removed),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
g_signal_new ("printer-status-changed",
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkPrintBackendIface, printer_status_changed),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
priv = backend->priv;
initialized = TRUE;
if (!priv->printers)
return;
g_hash_table_insert (priv->printers,
g_strdup (gtk_printer_get_name (printer)),
g_object_ref (printer));
}
void
gtk_print_backend_remove_printer (GtkPrintBackend *backend,
GtkPrinter *printer)
{
GtkPrintBackendPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_BACKEND (backend));
priv = backend->priv;
if (!priv->printers)
return;
g_hash_table_remove (priv->printers,
gtk_printer_get_name (printer));
}
void
gtk_print_backend_set_list_done (GtkPrintBackend *backend)
{
if (!backend->priv->printer_list_done)
{
backend->priv->printer_list_done = TRUE;
g_signal_emit (backend, signals[PRINTER_LIST_DONE], 0);
}
}
GList *
gtk_print_backend_get_printer_list (GtkPrintBackend *print_backend)
gtk_print_backend_get_printer_list (GtkPrintBackend *backend)
{
g_return_val_if_fail (GTK_IS_PRINT_BACKEND (print_backend), NULL);
GtkPrintBackendPrivate *priv;
GList *result;
g_return_val_if_fail (GTK_IS_PRINT_BACKEND (backend), NULL);
priv = backend->priv;
result = NULL;
if (priv->printers != NULL)
g_hash_table_foreach (priv->printers,
(GHFunc) printer_hash_to_sorted_active_list,
&result);
if (!priv->printer_list_requested && priv->printers != NULL)
{
if (GTK_PRINT_BACKEND_GET_CLASS (backend)->request_printer_list)
GTK_PRINT_BACKEND_GET_CLASS (backend)->request_printer_list (backend);
priv->printer_list_requested = TRUE;
}
return result;;
}
return GTK_PRINT_BACKEND_GET_IFACE (print_backend)->get_printer_list (print_backend);
gboolean
gtk_print_backend_printer_list_is_done (GtkPrintBackend *print_backend)
{
g_return_val_if_fail (GTK_IS_PRINT_BACKEND (print_backend), TRUE);
return print_backend->priv->printer_list_done;
}
GtkPrinter *
gtk_print_backend_find_printer (GtkPrintBackend *print_backend,
gtk_print_backend_find_printer (GtkPrintBackend *backend,
const gchar *printer_name)
{
g_return_val_if_fail (GTK_IS_PRINT_BACKEND (print_backend), NULL);
GtkPrintBackendPrivate *priv;
GtkPrinter *printer;
g_return_val_if_fail (GTK_IS_PRINT_BACKEND (backend), NULL);
priv = backend->priv;
return GTK_PRINT_BACKEND_GET_IFACE (print_backend)->find_printer (print_backend, printer_name);
if (priv->printers)
printer = g_hash_table_lookup (priv->printers, printer_name);
else
printer = NULL;
return printer;
}
void
gtk_print_backend_print_stream (GtkPrintBackend *print_backend,
gtk_print_backend_print_stream (GtkPrintBackend *backend,
GtkPrintJob *job,
gint data_fd,
GtkPrintJobCompleteFunc callback,
gpointer user_data,
GDestroyNotify dnotify)
{
g_return_if_fail (GTK_IS_PRINT_BACKEND (print_backend));
GTK_PRINT_BACKEND_GET_IFACE (print_backend)->print_stream (print_backend,
job,
data_fd,
callback,
user_data,
dnotify);
g_return_if_fail (GTK_IS_PRINT_BACKEND (backend));
GTK_PRINT_BACKEND_GET_CLASS (backend)->print_stream (backend,
job,
data_fd,
callback,
user_data,
dnotify);
}
static gboolean
unref_at_idle_cb (gpointer data)
{
g_object_unref (data);
return FALSE;
}
void
gtk_print_backend_unref_at_idle (GtkPrintBackend *print_backend)
{
g_idle_add (unref_at_idle_cb, print_backend);
}
void
gtk_print_backend_destroy (GtkPrintBackend *print_backend)
{
/* The lifecycle of print backends and printers are tied, such that
the backend owns the printers, but the printers also ref the backend.
This is so that if the app has a reference to a printer its backend
will be around. However, this results in a cycle, which we break
with this call, which causes the print backend to release its printers.
*/
g_object_run_dispose (G_OBJECT (print_backend));
}
#define __GTK_PRINT_BACKEND_C__
......
......@@ -39,7 +39,8 @@
G_BEGIN_DECLS
typedef struct _GtkPrintBackendIface GtkPrintBackendIface;
typedef struct _GtkPrintBackendClass GtkPrintBackendClass;
typedef struct _GtkPrintBackendPrivate GtkPrintBackendPrivate;
#define GTK_PRINT_BACKEND_ERROR (gtk_print_backend_error_quark ())
......@@ -51,22 +52,28 @@ typedef enum
GQuark gtk_print_backend_error_quark (void);
#define GTK_TYPE_PRINT_BACKEND (gtk_print_backend_get_type ())
#define GTK_PRINT_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_BACKEND, GtkPrintBackend))
#define GTK_IS_PRINT_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_BACKEND))
#define GTK_PRINT_BACKEND_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_PRINT_BACKEND, GtkPrintBackendIface))
#define GTK_TYPE_PRINT_BACKEND (gtk_print_backend_get_type ())
#define GTK_PRINT_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_BACKEND, GtkPrintBackend))
#define GTK_PRINT_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINT_BACKEND, GtkPrintBackendClass))
#define GTK_IS_PRINT_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_BACKEND))
#define GTK_IS_PRINT_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINT_BACKEND))
#define GTK_PRINT_BACKEND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINT_BACKEND, GtkPrintBackendClass))
struct _GtkPrintBackendIface
struct _GtkPrintBackend
{
GTypeInterface base_iface;
GObject parent_instance;
/* Global backend methods: */
GList * (*get_printer_list) (GtkPrintBackend *printer_backend);
GtkPrintBackendPrivate *priv;
};
GtkPrinter * (*find_printer) (GtkPrintBackend *print_backend,
const gchar *printer_name);
void (*print_stream) (GtkPrintBackend *print_backend,
GtkPrintJob *job,
struct _GtkPrintBackendClass
{
GObjectClass parent_class;
/* Global backend methods: */
void (*request_printer_list) (GtkPrintBackend *backend);
void (*print_stream) (GtkPrintBackend *backend,
GtkPrintJob *job,
gint data_fd,
GtkPrintJobCompleteFunc callback,
gpointer user_data,
......@@ -97,26 +104,49 @@ struct _GtkPrintBackendIface
double *left,
double *right);
/* Signals
*/
void (*printer_list_changed) (void);
void (*printer_added) (GtkPrinter *printer);
void (*printer_removed) (GtkPrinter *printer);
void (*printer_status_changed) (GtkPrinter *printer);
/* Signals */
void (*printer_list_changed) (GtkPrintBackend *backend);
void (*printer_list_done) (GtkPrintBackend *backend);
void (*printer_added) (GtkPrintBackend *backend,
GtkPrinter *printer);
void (*printer_removed) (GtkPrintBackend *backend,
GtkPrinter *printer);
void (*printer_status_changed) (GtkPrintBackend *backend,
GtkPrinter *printer);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
void (*_gtk_reserved5) (void);
void (*_gtk_reserved6) (void);
void (*_gtk_reserved7) (void);
};
GType gtk_print_backend_get_type (void) G_GNUC_CONST;
GList *gtk_print_backend_get_printer_list (GtkPrintBackend *print_backend);
GtkPrinter *gtk_print_backend_find_printer (GtkPrintBackend *print_backend,
const gchar *printer_name);
void gtk_print_backend_print_stream (GtkPrintBackend *print_backend,
GtkPrintJob *job,
gint data_fd,
GtkPrintJobCompleteFunc callback,
gpointer user_data,
GDestroyNotify dnotify);
GList * gtk_print_backend_load_modules (void);
GList *gtk_print_backend_get_printer_list (GtkPrintBackend *print_backend);
gboolean gtk_print_backend_printer_list_is_done (GtkPrintBackend *print_backend);
GtkPrinter *gtk_print_backend_find_printer (GtkPrintBackend *print_backend,
const gchar *printer_name);
void gtk_print_backend_print_stream (GtkPrintBackend *print_backend,
GtkPrintJob *job,
gint data_fd,
GtkPrintJobCompleteFunc callback,
gpointer user_data,
GDestroyNotify dnotify);
GList * gtk_print_backend_load_modules (void);
void gtk_print_backend_unref_at_idle (GtkPrintBackend *print_backend);
void gtk_print_backend_destroy (GtkPrintBackend *print_backend);
/* Backend-only functions for GtkPrintBackend */
void gtk_print_backend_add_printer (GtkPrintBackend *print_backend,
GtkPrinter *printer);
void gtk_print_backend_remove_printer (GtkPrintBackend *print_backend,
GtkPrinter *printer);
void gtk_print_backend_set_list_done (GtkPrintBackend *backend);
/* Backend-only functions for GtkPrinter */
......
......@@ -52,7 +52,6 @@ struct _GtkPrinterPrivate
gchar *state_message;
gint job_count;
/* Not ref:ed, backend owns printer. */
GtkPrintBackend *backend;
};
......@@ -215,6 +214,9 @@ gtk_printer_finalize (GObject *object)
g_free (priv->state_message);
g_free (priv->icon_name);
if (priv->backend)
g_object_unref (priv->backend);
G_OBJECT_CLASS (gtk_printer_parent_class)->finalize (object);
}
......@@ -234,7 +236,7 @@ gtk_printer_set_property (GObject *object,
break;
case PROP_BACKEND:
priv->backend = GTK_PRINT_BACKEND (g_value_get_object (value));
priv->backend = GTK_PRINT_BACKEND (g_value_dup_object (value));
break;
case PROP_IS_VIRTUAL:
......@@ -340,16 +342,6 @@ gtk_printer_get_backend (GtkPrinter *printer)
return printer->priv->backend;
}
void
gtk_printer_set_backend (GtkPrinter *printer,
GtkPrintBackend *backend)
{
g_return_if_fail (GTK_IS_PRINTER (printer));
g_return_if_fail (GTK_IS_PRINT_BACKEND (backend));
printer->priv->backend = backend;
}
/**
* gtk_printer_get_name:
* @printer: a #GtkPrinter
......@@ -663,8 +655,8 @@ gtk_printer_set_is_default (GtkPrinter *printer,
void
_gtk_printer_request_details (GtkPrinter *printer)
{
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
return backend_iface->printer_request_details (printer);
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend);
return backend_class->printer_request_details (printer);
}
GtkPrinterOptionSet *
......@@ -672,16 +664,16 @@ _gtk_printer_get_options (GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup)
{
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
return backend_iface->printer_get_options (printer, settings, page_setup);
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend);
return backend_class->printer_get_options (printer, settings, page_setup);
}
gboolean
_gtk_printer_mark_conflicts (GtkPrinter *printer,
GtkPrinterOptionSet *options)
{
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
return backend_iface->printer_mark_conflicts (printer, options);
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend);
return backend_class->printer_mark_conflicts (printer, options);
}
void
......@@ -689,8 +681,8 @@ _gtk_printer_get_settings_from_options (GtkPrinter *printer,
GtkPrinterOptionSet *options,
GtkPrintSettings *settings)
{
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
return backend_iface->printer_get_settings_from_options (printer, options, settings);
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend);
return backend_class->printer_get_settings_from_options (printer, options, settings);
}
void
......@@ -699,8 +691,8 @@ _gtk_printer_prepare_for_print (GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup)