2008-07-01 22:57:50 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
2006-04-21 15:09:32 +00:00
|
|
|
* gtkprintbackend.h: Abstract printer backend interfaces
|
|
|
|
* Copyright (C) 2003, Red Hat, 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gmodule.h>
|
|
|
|
|
|
|
|
#include "gtkintl.h"
|
|
|
|
#include "gtkmodules.h"
|
2009-04-21 12:24:32 +00:00
|
|
|
#include "gtkmarshalers.h"
|
2006-04-21 15:09:32 +00:00
|
|
|
#include "gtkprivate.h"
|
|
|
|
#include "gtkprintbackend.h"
|
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
|
2008-09-17 22:07:10 +00:00
|
|
|
static void gtk_print_backend_dispose (GObject *object);
|
|
|
|
static void gtk_print_backend_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gtk_print_backend_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2006-05-04 13:43:32 +00:00
|
|
|
|
|
|
|
struct _GtkPrintBackendPrivate
|
|
|
|
{
|
|
|
|
GHashTable *printers;
|
|
|
|
guint printer_list_requested : 1;
|
|
|
|
guint printer_list_done : 1;
|
2008-09-17 22:07:10 +00:00
|
|
|
GtkPrintBackendStatus status;
|
2009-09-24 13:34:56 +00:00
|
|
|
char **auth_info_required;
|
|
|
|
char **auth_info;
|
2006-05-04 13:43:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PRINTER_LIST_CHANGED,
|
|
|
|
PRINTER_LIST_DONE,
|
|
|
|
PRINTER_ADDED,
|
|
|
|
PRINTER_REMOVED,
|
|
|
|
PRINTER_STATUS_CHANGED,
|
2009-04-21 12:24:32 +00:00
|
|
|
REQUEST_PASSWORD,
|
2006-05-04 13:43:32 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2008-09-17 22:07:10 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_ZERO,
|
|
|
|
PROP_STATUS
|
|
|
|
};
|
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
static GObjectClass *backend_parent_class;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
GQuark
|
|
|
|
gtk_print_backend_error_quark (void)
|
|
|
|
{
|
|
|
|
static GQuark quark = 0;
|
|
|
|
if (quark == 0)
|
|
|
|
quark = g_quark_from_static_string ("gtk-print-backend-error-quark");
|
|
|
|
return quark;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************
|
|
|
|
* GtkPrintBackendModule modules *
|
|
|
|
*****************************************/
|
|
|
|
|
|
|
|
typedef struct _GtkPrintBackendModule GtkPrintBackendModule;
|
|
|
|
typedef struct _GtkPrintBackendModuleClass GtkPrintBackendModuleClass;
|
|
|
|
|
|
|
|
struct _GtkPrintBackendModule
|
|
|
|
{
|
|
|
|
GTypeModule parent_instance;
|
|
|
|
|
|
|
|
GModule *library;
|
|
|
|
|
|
|
|
void (*init) (GTypeModule *module);
|
|
|
|
void (*exit) (void);
|
|
|
|
GtkPrintBackend* (*create) (void);
|
|
|
|
|
|
|
|
gchar *path;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GtkPrintBackendModuleClass
|
|
|
|
{
|
|
|
|
GTypeModuleClass parent_class;
|
|
|
|
};
|
|
|
|
|
2006-05-14 04:25:34 +00:00
|
|
|
G_DEFINE_TYPE (GtkPrintBackendModule, _gtk_print_backend_module, G_TYPE_TYPE_MODULE)
|
2006-04-21 15:09:32 +00:00
|
|
|
#define GTK_TYPE_PRINT_BACKEND_MODULE (_gtk_print_backend_module_get_type ())
|
|
|
|
#define GTK_PRINT_BACKEND_MODULE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), GTK_TYPE_PRINT_BACKEND_MODULE, GtkPrintBackendModule))
|
|
|
|
|
|
|
|
static GSList *loaded_backends;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_print_backend_module_load (GTypeModule *module)
|
|
|
|
{
|
|
|
|
GtkPrintBackendModule *pb_module = GTK_PRINT_BACKEND_MODULE (module);
|
|
|
|
gpointer initp, exitp, createp;
|
|
|
|
|
|
|
|
pb_module->library = g_module_open (pb_module->path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
|
|
|
|
if (!pb_module->library)
|
|
|
|
{
|
2008-10-13 12:54:45 +00:00
|
|
|
g_warning ("%s", g_module_error());
|
2006-04-21 15:09:32 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* extract symbols from the lib */
|
|
|
|
if (!g_module_symbol (pb_module->library, "pb_module_init",
|
|
|
|
&initp) ||
|
|
|
|
!g_module_symbol (pb_module->library, "pb_module_exit",
|
|
|
|
&exitp) ||
|
|
|
|
!g_module_symbol (pb_module->library, "pb_module_create",
|
|
|
|
&createp))
|
|
|
|
{
|
2008-10-13 12:54:45 +00:00
|
|
|
g_warning ("%s", g_module_error());
|
2006-04-21 15:09:32 +00:00
|
|
|
g_module_close (pb_module->library);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pb_module->init = initp;
|
|
|
|
pb_module->exit = exitp;
|
|
|
|
pb_module->create = createp;
|
|
|
|
|
2008-06-19 17:42:14 +00:00
|
|
|
/* call the printbackend's init function to let it */
|
2006-04-21 15:09:32 +00:00
|
|
|
/* setup anything it needs to set up. */
|
|
|
|
pb_module->init (module);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_print_backend_module_unload (GTypeModule *module)
|
|
|
|
{
|
|
|
|
GtkPrintBackendModule *pb_module = GTK_PRINT_BACKEND_MODULE (module);
|
|
|
|
|
|
|
|
pb_module->exit();
|
|
|
|
|
|
|
|
g_module_close (pb_module->library);
|
|
|
|
pb_module->library = NULL;
|
|
|
|
|
|
|
|
pb_module->init = NULL;
|
|
|
|
pb_module->exit = NULL;
|
|
|
|
pb_module->create = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This only will ever be called if an error occurs during
|
|
|
|
* initialization
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
gtk_print_backend_module_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkPrintBackendModule *module = GTK_PRINT_BACKEND_MODULE (object);
|
|
|
|
|
|
|
|
g_free (module->path);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (_gtk_print_backend_module_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gtk_print_backend_module_class_init (GtkPrintBackendModuleClass *class)
|
|
|
|
{
|
|
|
|
GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (class);
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
2006-05-04 13:43:32 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
module_class->load = gtk_print_backend_module_load;
|
|
|
|
module_class->unload = gtk_print_backend_module_unload;
|
|
|
|
|
|
|
|
gobject_class->finalize = gtk_print_backend_module_finalize;
|
|
|
|
}
|
|
|
|
|
2008-09-17 22:07:10 +00:00
|
|
|
static void
|
|
|
|
gtk_print_backend_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkPrintBackend *backend = GTK_PRINT_BACKEND (object);
|
2010-07-07 01:51:19 +00:00
|
|
|
GtkPrintBackendPrivate *priv = backend->priv;
|
2008-09-17 22:07:10 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_STATUS:
|
|
|
|
priv->status = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_print_backend_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkPrintBackend *backend = GTK_PRINT_BACKEND (object);
|
2010-07-07 01:51:19 +00:00
|
|
|
GtkPrintBackendPrivate *priv = backend->priv;
|
2008-09-17 22:07:10 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_STATUS:
|
|
|
|
g_value_set_int (value, priv->status);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
static void
|
|
|
|
_gtk_print_backend_module_init (GtkPrintBackendModule *pb_module)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkPrintBackend *
|
|
|
|
_gtk_print_backend_module_create (GtkPrintBackendModule *pb_module)
|
|
|
|
{
|
|
|
|
GtkPrintBackend *pb;
|
|
|
|
|
|
|
|
if (g_type_module_use (G_TYPE_MODULE (pb_module)))
|
|
|
|
{
|
|
|
|
pb = pb_module->create ();
|
|
|
|
g_type_module_unuse (G_TYPE_MODULE (pb_module));
|
|
|
|
return pb;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-06-02 15:16:13 +00:00
|
|
|
static GtkPrintBackend *
|
2006-06-12 04:39:55 +00:00
|
|
|
_gtk_print_backend_create (const gchar *backend_name)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
|
|
|
GSList *l;
|
2006-06-12 04:39:55 +00:00
|
|
|
gchar *module_path;
|
|
|
|
gchar *full_name;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrintBackendModule *pb_module;
|
|
|
|
GtkPrintBackend *pb;
|
|
|
|
|
|
|
|
for (l = loaded_backends; l != NULL; l = l->next)
|
|
|
|
{
|
|
|
|
pb_module = l->data;
|
|
|
|
|
|
|
|
if (strcmp (G_TYPE_MODULE (pb_module)->name, backend_name) == 0)
|
|
|
|
return _gtk_print_backend_module_create (pb_module);
|
|
|
|
}
|
|
|
|
|
|
|
|
pb = NULL;
|
|
|
|
if (g_module_supported ())
|
|
|
|
{
|
|
|
|
full_name = g_strconcat ("printbackend-", backend_name, NULL);
|
|
|
|
module_path = _gtk_find_module (full_name, "printbackends");
|
|
|
|
g_free (full_name);
|
|
|
|
|
|
|
|
if (module_path)
|
|
|
|
{
|
|
|
|
pb_module = g_object_new (GTK_TYPE_PRINT_BACKEND_MODULE, NULL);
|
|
|
|
|
|
|
|
g_type_module_set_name (G_TYPE_MODULE (pb_module), backend_name);
|
|
|
|
pb_module->path = g_strdup (module_path);
|
|
|
|
|
|
|
|
loaded_backends = g_slist_prepend (loaded_backends,
|
|
|
|
pb_module);
|
|
|
|
|
|
|
|
pb = _gtk_print_backend_module_create (pb_module);
|
2006-05-15 15:24:12 +00:00
|
|
|
|
|
|
|
/* Increase use-count so that we don't unload print backends.
|
2006-06-12 04:39:55 +00:00
|
|
|
* There is a problem with module unloading in the cups module,
|
|
|
|
* see cups_dispatch_watch_finalize for details.
|
|
|
|
*/
|
2006-05-15 15:24:12 +00:00
|
|
|
g_type_module_use (G_TYPE_MODULE (pb_module));
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (module_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pb;
|
|
|
|
}
|
|
|
|
|
2009-12-10 10:23:40 +00:00
|
|
|
/**
|
2011-02-09 04:14:46 +00:00
|
|
|
* gtk_print_backend_load_modules:
|
2009-12-10 10:23:40 +00:00
|
|
|
*
|
|
|
|
* Return value: (element-type GtkPrintBackend) (transfer container):
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
GList *
|
2006-06-12 04:39:55 +00:00
|
|
|
gtk_print_backend_load_modules (void)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
|
|
|
GList *result;
|
|
|
|
GtkPrintBackend *backend;
|
|
|
|
gchar *setting;
|
|
|
|
gchar **backends;
|
|
|
|
gint i;
|
|
|
|
GtkSettings *settings;
|
|
|
|
|
|
|
|
result = NULL;
|
|
|
|
|
|
|
|
settings = gtk_settings_get_default ();
|
2006-06-19 03:52:10 +00:00
|
|
|
if (settings)
|
|
|
|
g_object_get (settings, "gtk-print-backends", &setting, NULL);
|
|
|
|
else
|
|
|
|
setting = g_strdup (GTK_PRINT_BACKENDS);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
backends = g_strsplit (setting, ",", -1);
|
|
|
|
|
|
|
|
for (i = 0; backends[i]; i++)
|
|
|
|
{
|
|
|
|
g_strchug (backends[i]);
|
|
|
|
g_strchomp (backends[i]);
|
|
|
|
backend = _gtk_print_backend_create (backends[i]);
|
|
|
|
|
|
|
|
if (backend)
|
|
|
|
result = g_list_append (result, backend);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_strfreev (backends);
|
|
|
|
g_free (setting);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************
|
|
|
|
* GtkPrintBackend *
|
|
|
|
*****************************************/
|
2006-05-04 13:43:32 +00:00
|
|
|
|
2006-05-14 04:25:34 +00:00
|
|
|
G_DEFINE_TYPE (GtkPrintBackend, gtk_print_backend, G_TYPE_OBJECT)
|
2006-05-04 13:43:32 +00:00
|
|
|
|
2008-05-21 02:17:30 +00:00
|
|
|
static void fallback_printer_request_details (GtkPrinter *printer);
|
|
|
|
static gboolean fallback_printer_mark_conflicts (GtkPrinter *printer,
|
|
|
|
GtkPrinterOptionSet *options);
|
2008-02-06 22:58:47 +00:00
|
|
|
static gboolean fallback_printer_get_hard_margins (GtkPrinter *printer,
|
|
|
|
gdouble *top,
|
|
|
|
gdouble *bottom,
|
|
|
|
gdouble *left,
|
|
|
|
gdouble *right);
|
2008-05-21 02:17:30 +00:00
|
|
|
static GList * fallback_printer_list_papers (GtkPrinter *printer);
|
|
|
|
static GtkPageSetup * fallback_printer_get_default_page_size (GtkPrinter *printer);
|
|
|
|
static GtkPrintCapabilities fallback_printer_get_capabilities (GtkPrinter *printer);
|
2009-04-21 12:24:32 +00:00
|
|
|
static void request_password (GtkPrintBackend *backend,
|
2009-09-24 13:34:56 +00:00
|
|
|
gpointer auth_info_required,
|
|
|
|
gpointer auth_info_default,
|
|
|
|
gpointer auth_info_display,
|
|
|
|
gpointer auth_info_visible,
|
2009-04-21 12:24:32 +00:00
|
|
|
const gchar *prompt);
|
2006-05-24 10:50:57 +00:00
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
static void
|
|
|
|
gtk_print_backend_class_init (GtkPrintBackendClass *class)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
GObjectClass *object_class;
|
|
|
|
object_class = (GObjectClass *) class;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
backend_parent_class = g_type_class_peek_parent (class);
|
|
|
|
|
|
|
|
object_class->dispose = gtk_print_backend_dispose;
|
2008-09-17 22:07:10 +00:00
|
|
|
object_class->set_property = gtk_print_backend_set_property;
|
|
|
|
object_class->get_property = gtk_print_backend_get_property;
|
2006-05-04 13:43:32 +00:00
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
class->printer_request_details = fallback_printer_request_details;
|
|
|
|
class->printer_mark_conflicts = fallback_printer_mark_conflicts;
|
|
|
|
class->printer_get_hard_margins = fallback_printer_get_hard_margins;
|
|
|
|
class->printer_list_papers = fallback_printer_list_papers;
|
2008-05-21 02:17:30 +00:00
|
|
|
class->printer_get_default_page_size = fallback_printer_get_default_page_size;
|
2006-05-24 10:50:57 +00:00
|
|
|
class->printer_get_capabilities = fallback_printer_get_capabilities;
|
2009-04-21 12:24:32 +00:00
|
|
|
class->request_password = request_password;
|
2006-05-24 10:50:57 +00:00
|
|
|
|
2008-09-17 22:07:10 +00:00
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_STATUS,
|
|
|
|
g_param_spec_int ("status",
|
|
|
|
"Status",
|
|
|
|
"The status of the print backend",
|
|
|
|
GTK_PRINT_BACKEND_STATUS_UNKNOWN,
|
|
|
|
GTK_PRINT_BACKEND_STATUS_UNAVAILABLE,
|
|
|
|
GTK_PRINT_BACKEND_STATUS_UNKNOWN,
|
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
g_type_class_add_private (class, sizeof (GtkPrintBackendPrivate));
|
|
|
|
|
|
|
|
signals[PRINTER_LIST_CHANGED] =
|
2006-06-01 05:02:56 +00:00
|
|
|
g_signal_new (I_("printer-list-changed"),
|
2006-05-04 13:43:32 +00:00
|
|
|
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] =
|
2006-06-01 05:02:56 +00:00
|
|
|
g_signal_new (I_("printer-list-done"),
|
2006-05-04 13:43:32 +00:00
|
|
|
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] =
|
2006-06-01 05:02:56 +00:00
|
|
|
g_signal_new (I_("printer-added"),
|
2006-05-04 13:43:32 +00:00
|
|
|
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] =
|
2006-06-01 05:02:56 +00:00
|
|
|
g_signal_new (I_("printer-removed"),
|
2006-05-04 13:43:32 +00:00
|
|
|
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] =
|
2006-06-01 05:02:56 +00:00
|
|
|
g_signal_new (I_("printer-status-changed"),
|
2006-05-04 13:43:32 +00:00
|
|
|
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);
|
2009-04-21 12:24:32 +00:00
|
|
|
signals[REQUEST_PASSWORD] =
|
|
|
|
g_signal_new (I_("request-password"),
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkPrintBackendClass, request_password),
|
|
|
|
NULL, NULL,
|
2009-09-24 13:34:56 +00:00
|
|
|
_gtk_marshal_VOID__POINTER_POINTER_POINTER_POINTER_STRING,
|
|
|
|
G_TYPE_NONE, 5, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING);
|
2006-05-04 13:43:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_print_backend_init (GtkPrintBackend *backend)
|
|
|
|
{
|
|
|
|
GtkPrintBackendPrivate *priv;
|
|
|
|
|
2010-07-07 01:51:19 +00:00
|
|
|
priv = backend->priv = G_TYPE_INSTANCE_GET_PRIVATE (backend,
|
|
|
|
GTK_TYPE_PRINT_BACKEND,
|
|
|
|
GtkPrintBackendPrivate);
|
2006-05-04 13:43:32 +00:00
|
|
|
|
|
|
|
priv->printers = g_hash_table_new_full (g_str_hash, g_str_equal,
|
|
|
|
(GDestroyNotify) g_free,
|
|
|
|
(GDestroyNotify) g_object_unref);
|
2009-09-24 13:34:56 +00:00
|
|
|
priv->auth_info_required = NULL;
|
|
|
|
priv->auth_info = NULL;
|
2006-05-04 13:43:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2006-06-12 04:39:55 +00:00
|
|
|
* we can break refcount cycles with gtk_print_backend_destroy
|
|
|
|
*/
|
2006-05-04 13:43:32 +00:00
|
|
|
if (priv->printers)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
g_hash_table_destroy (priv->printers);
|
|
|
|
priv->printers = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
backend_parent_class->dispose (object);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
static void
|
|
|
|
fallback_printer_request_details (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2006-06-12 04:39:55 +00:00
|
|
|
fallback_printer_mark_conflicts (GtkPrinter *printer,
|
2006-05-24 10:50:57 +00:00
|
|
|
GtkPrinterOptionSet *options)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-02-06 22:58:47 +00:00
|
|
|
static gboolean
|
2006-05-24 10:50:57 +00:00
|
|
|
fallback_printer_get_hard_margins (GtkPrinter *printer,
|
2006-06-12 04:39:55 +00:00
|
|
|
gdouble *top,
|
|
|
|
gdouble *bottom,
|
|
|
|
gdouble *left,
|
|
|
|
gdouble *right)
|
2006-05-24 10:50:57 +00:00
|
|
|
{
|
2009-11-21 09:38:17 +00:00
|
|
|
return FALSE;
|
2006-05-24 10:50:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
fallback_printer_list_papers (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-05-21 02:17:30 +00:00
|
|
|
static GtkPageSetup *
|
|
|
|
fallback_printer_get_default_page_size (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
static GtkPrintCapabilities
|
|
|
|
fallback_printer_get_capabilities (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
static void
|
2006-06-12 04:39:55 +00:00
|
|
|
printer_hash_to_sorted_active_list (const gchar *key,
|
|
|
|
gpointer value,
|
|
|
|
GList **out_list)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
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,
|
2006-06-12 04:39:55 +00:00
|
|
|
GtkPrinter *printer)
|
2006-05-04 13:43:32 +00:00
|
|
|
{
|
|
|
|
GtkPrintBackendPrivate *priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
g_return_if_fail (GTK_IS_PRINT_BACKEND (backend));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
priv = backend->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
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,
|
2006-06-12 04:39:55 +00:00
|
|
|
GtkPrinter *printer)
|
2006-05-04 13:43:32 +00:00
|
|
|
{
|
|
|
|
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);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
|
2009-12-10 10:23:40 +00:00
|
|
|
/**
|
|
|
|
* gtk_print_backend_get_printer_list:
|
|
|
|
*
|
2010-10-01 17:05:12 +00:00
|
|
|
* Returns the current list of printers.
|
|
|
|
*
|
2009-12-10 10:23:40 +00:00
|
|
|
* Return value: (element-type GtkPrinter) (transfer container):
|
2010-10-01 17:05:12 +00:00
|
|
|
* A list of #GtkPrinter objects. The list should be freed
|
|
|
|
* with g_list_free().
|
2009-12-10 10:23:40 +00:00
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
GList *
|
2006-05-04 13:43:32 +00:00
|
|
|
gtk_print_backend_get_printer_list (GtkPrintBackend *backend)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
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;
|
|
|
|
}
|
2008-09-17 22:07:10 +00:00
|
|
|
|
2006-06-12 04:39:55 +00:00
|
|
|
return result;
|
2006-05-04 13:43:32 +00:00
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
gboolean
|
|
|
|
gtk_print_backend_printer_list_is_done (GtkPrintBackend *print_backend)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_BACKEND (print_backend), TRUE);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
return print_backend->priv->printer_list_done;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkPrinter *
|
2006-05-04 13:43:32 +00:00
|
|
|
gtk_print_backend_find_printer (GtkPrintBackend *backend,
|
2006-06-12 04:39:55 +00:00
|
|
|
const gchar *printer_name)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
GtkPrintBackendPrivate *priv;
|
|
|
|
GtkPrinter *printer;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_BACKEND (backend), NULL);
|
|
|
|
|
|
|
|
priv = backend->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
if (priv->printers)
|
|
|
|
printer = g_hash_table_lookup (priv->printers, printer_name);
|
|
|
|
else
|
|
|
|
printer = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
return printer;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-06-12 04:39:55 +00:00
|
|
|
gtk_print_backend_print_stream (GtkPrintBackend *backend,
|
|
|
|
GtkPrintJob *job,
|
2006-06-21 18:16:58 +00:00
|
|
|
GIOChannel *data_io,
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrintJobCompleteFunc callback,
|
2006-06-12 04:39:55 +00:00
|
|
|
gpointer user_data,
|
2006-06-21 18:16:58 +00:00
|
|
|
GDestroyNotify dnotify)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
g_return_if_fail (GTK_IS_PRINT_BACKEND (backend));
|
|
|
|
|
|
|
|
GTK_PRINT_BACKEND_GET_CLASS (backend)->print_stream (backend,
|
|
|
|
job,
|
2006-06-21 18:16:58 +00:00
|
|
|
data_io,
|
2006-05-04 13:43:32 +00:00
|
|
|
callback,
|
|
|
|
user_data,
|
2006-06-21 18:16:58 +00:00
|
|
|
dnotify);
|
2006-05-04 13:43:32 +00:00
|
|
|
}
|
|
|
|
|
2009-04-21 12:24:32 +00:00
|
|
|
void
|
2009-09-24 13:34:56 +00:00
|
|
|
gtk_print_backend_set_password (GtkPrintBackend *backend,
|
|
|
|
gchar **auth_info_required,
|
|
|
|
gchar **auth_info)
|
2009-04-21 12:24:32 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_BACKEND (backend));
|
|
|
|
|
|
|
|
if (GTK_PRINT_BACKEND_GET_CLASS (backend)->set_password)
|
2009-09-24 13:34:56 +00:00
|
|
|
GTK_PRINT_BACKEND_GET_CLASS (backend)->set_password (backend, auth_info_required, auth_info);
|
2009-04-21 12:24:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-24 13:34:56 +00:00
|
|
|
store_entry (GtkEntry *entry,
|
|
|
|
gpointer user_data)
|
2009-04-21 12:24:32 +00:00
|
|
|
{
|
2009-09-24 13:34:56 +00:00
|
|
|
gchar **data = (gchar **) user_data;
|
2009-04-21 12:24:32 +00:00
|
|
|
|
2009-09-24 13:34:56 +00:00
|
|
|
if (*data != NULL)
|
2009-04-21 12:24:32 +00:00
|
|
|
{
|
2009-09-24 13:34:56 +00:00
|
|
|
memset (*data, 0, strlen (*data));
|
|
|
|
g_free (*data);
|
2009-04-21 12:24:32 +00:00
|
|
|
}
|
|
|
|
|
2009-09-24 13:34:56 +00:00
|
|
|
*data = g_strdup (gtk_entry_get_text (entry));
|
2009-04-21 12:24:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
password_dialog_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
GtkPrintBackend *backend)
|
|
|
|
{
|
|
|
|
GtkPrintBackendPrivate *priv = backend->priv;
|
2009-09-24 13:34:56 +00:00
|
|
|
gint i;
|
2009-04-21 12:24:32 +00:00
|
|
|
|
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2009-09-24 13:34:56 +00:00
|
|
|
gtk_print_backend_set_password (backend, priv->auth_info_required, priv->auth_info);
|
2009-04-21 12:24:32 +00:00
|
|
|
else
|
2009-09-24 13:34:56 +00:00
|
|
|
gtk_print_backend_set_password (backend, priv->auth_info_required, NULL);
|
2009-04-21 12:24:32 +00:00
|
|
|
|
2009-09-24 13:34:56 +00:00
|
|
|
for (i = 0; i < g_strv_length (priv->auth_info_required); i++)
|
|
|
|
if (priv->auth_info[i] != NULL)
|
|
|
|
{
|
|
|
|
memset (priv->auth_info[i], 0, strlen (priv->auth_info[i]));
|
|
|
|
g_free (priv->auth_info[i]);
|
|
|
|
priv->auth_info[i] = NULL;
|
|
|
|
}
|
|
|
|
g_free (priv->auth_info);
|
|
|
|
priv->auth_info = NULL;
|
2009-04-21 12:24:32 +00:00
|
|
|
|
2009-09-24 13:34:56 +00:00
|
|
|
g_strfreev (priv->auth_info_required);
|
2009-04-21 12:24:32 +00:00
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
|
|
|
g_object_unref (backend);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-24 13:34:56 +00:00
|
|
|
request_password (GtkPrintBackend *backend,
|
|
|
|
gpointer auth_info_required,
|
|
|
|
gpointer auth_info_default,
|
|
|
|
gpointer auth_info_display,
|
|
|
|
gpointer auth_info_visible,
|
|
|
|
const gchar *prompt)
|
2009-04-21 12:24:32 +00:00
|
|
|
{
|
|
|
|
GtkPrintBackendPrivate *priv = backend->priv;
|
2009-09-24 13:34:56 +00:00
|
|
|
GtkWidget *dialog, *box, *main_box, *label, *icon, *vbox, *entry;
|
|
|
|
GtkWidget *focus = NULL;
|
2010-06-03 07:36:39 +00:00
|
|
|
GtkWidget *content_area;
|
2009-04-21 12:24:32 +00:00
|
|
|
gchar *markup;
|
2009-09-24 13:34:56 +00:00
|
|
|
gint length;
|
|
|
|
gint i;
|
|
|
|
gchar **ai_required = (gchar **) auth_info_required;
|
|
|
|
gchar **ai_default = (gchar **) auth_info_default;
|
|
|
|
gchar **ai_display = (gchar **) auth_info_display;
|
|
|
|
gboolean *ai_visible = (gboolean *) auth_info_visible;
|
|
|
|
|
|
|
|
priv->auth_info_required = g_strdupv (ai_required);
|
|
|
|
length = g_strv_length (ai_required);
|
|
|
|
priv->auth_info = g_new0 (gchar *, length);
|
2009-04-21 12:24:32 +00:00
|
|
|
|
|
|
|
dialog = gtk_dialog_new_with_buttons ( _("Authentication"), NULL, GTK_DIALOG_MODAL,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
|
|
|
|
2010-10-31 17:07:20 +00:00
|
|
|
main_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2009-04-21 12:24:32 +00:00
|
|
|
|
|
|
|
/* Left */
|
|
|
|
icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG);
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (icon), 0.5, 0.0);
|
|
|
|
gtk_misc_set_padding (GTK_MISC (icon), 6, 6);
|
|
|
|
|
|
|
|
|
|
|
|
/* Right */
|
2010-10-31 17:07:20 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2009-04-21 12:24:32 +00:00
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (vbox), 320, -1);
|
|
|
|
|
|
|
|
/* Right - 1. */
|
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
markup = g_markup_printf_escaped ("<span weight=\"bold\" size=\"large\">%s</span>", prompt);
|
|
|
|
gtk_label_set_markup (GTK_LABEL (label), markup);
|
|
|
|
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (label), 320, -1);
|
|
|
|
g_free (markup);
|
|
|
|
|
|
|
|
|
|
|
|
/* Packing */
|
2010-06-03 07:36:39 +00:00
|
|
|
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
|
|
|
gtk_box_pack_start (GTK_BOX (content_area), main_box, TRUE, FALSE, 0);
|
2009-04-21 12:24:32 +00:00
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_box), icon, FALSE, FALSE, 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_box), vbox, FALSE, FALSE, 6);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 6);
|
2009-09-24 13:34:56 +00:00
|
|
|
|
|
|
|
/* Right - 2. */
|
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
priv->auth_info[i] = g_strdup (ai_default[i]);
|
|
|
|
if (ai_display[i] != NULL)
|
|
|
|
{
|
2010-10-31 17:07:20 +00:00
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
|
|
|
gtk_box_set_homogeneous (GTK_BOX (box), TRUE);
|
2009-09-24 13:34:56 +00:00
|
|
|
|
|
|
|
label = gtk_label_new (ai_display[i]);
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
2009-04-21 12:24:32 +00:00
|
|
|
|
2009-09-24 13:34:56 +00:00
|
|
|
entry = gtk_entry_new ();
|
|
|
|
focus = entry;
|
2009-04-21 12:24:32 +00:00
|
|
|
|
2009-09-24 13:34:56 +00:00
|
|
|
if (ai_default[i] != NULL)
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), ai_default[i]);
|
2009-04-21 12:24:32 +00:00
|
|
|
|
2009-09-24 13:34:56 +00:00
|
|
|
gtk_entry_set_visibility (GTK_ENTRY (entry), ai_visible[i]);
|
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
2009-04-21 12:24:32 +00:00
|
|
|
|
2009-09-24 13:34:56 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, TRUE, 6);
|
2009-04-21 12:24:32 +00:00
|
|
|
|
2009-09-24 13:34:56 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 0);
|
2009-04-21 12:24:32 +00:00
|
|
|
|
2009-09-24 13:34:56 +00:00
|
|
|
g_signal_connect (entry, "changed",
|
|
|
|
G_CALLBACK (store_entry), &(priv->auth_info[i]));
|
|
|
|
}
|
|
|
|
}
|
2009-04-21 12:24:32 +00:00
|
|
|
|
2009-09-24 13:34:56 +00:00
|
|
|
if (focus != NULL)
|
|
|
|
{
|
|
|
|
gtk_widget_grab_focus (focus);
|
|
|
|
focus = NULL;
|
|
|
|
}
|
2009-04-21 12:24:32 +00:00
|
|
|
|
|
|
|
g_object_ref (backend);
|
|
|
|
g_signal_connect (G_OBJECT (dialog), "response",
|
|
|
|
G_CALLBACK (password_dialog_response), backend);
|
|
|
|
|
|
|
|
gtk_widget_show_all (dialog);
|
|
|
|
}
|
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
void
|
|
|
|
gtk_print_backend_destroy (GtkPrintBackend *print_backend)
|
|
|
|
{
|
|
|
|
/* The lifecycle of print backends and printers are tied, such that
|
2006-06-12 04:39:55 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
2006-05-04 13:43:32 +00:00
|
|
|
g_object_run_dispose (G_OBJECT (print_backend));
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|