2 * Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 #include "gtkprintercups.h"
23 static void gtk_printer_cups_init (GtkPrinterCups *printer);
24 static void gtk_printer_cups_class_init (GtkPrinterCupsClass *class);
25 static void gtk_printer_cups_finalize (GObject *object);
27 static GtkPrinterClass *gtk_printer_cups_parent_class;
28 static GType gtk_printer_cups_type = 0;
31 gtk_printer_cups_register_type (GTypeModule *module)
33 const GTypeInfo object_info =
35 sizeof (GtkPrinterCupsClass),
37 (GBaseFinalizeFunc) NULL,
38 (GClassInitFunc) gtk_printer_cups_class_init,
39 NULL, /* class_finalize */
40 NULL, /* class_data */
41 sizeof (GtkPrinterCups),
43 (GInstanceInitFunc) gtk_printer_cups_init,
46 gtk_printer_cups_type = g_type_module_register_type (module,
53 gtk_printer_cups_get_type (void)
55 return gtk_printer_cups_type;
59 gtk_printer_cups_class_init (GtkPrinterCupsClass *class)
61 GObjectClass *object_class = (GObjectClass *) class;
63 gtk_printer_cups_parent_class = g_type_class_peek_parent (class);
65 object_class->finalize = gtk_printer_cups_finalize;
69 gtk_printer_cups_init (GtkPrinterCups *printer)
71 printer->device_uri = NULL;
72 printer->printer_uri = NULL;
74 printer->hostname = NULL;
76 printer->ppd_name = NULL;
77 printer->ppd_file = NULL;
78 printer->default_cover_before = NULL;
79 printer->default_cover_after = NULL;
80 printer->remote = FALSE;
81 printer->get_remote_ppd_poll = 0;
82 printer->get_remote_ppd_attempts = 0;
83 printer->remote_cups_connection_test = NULL;
84 printer->auth_info_required = NULL;
88 gtk_printer_cups_finalize (GObject *object)
90 GtkPrinterCups *printer;
92 g_return_if_fail (object != NULL);
94 printer = GTK_PRINTER_CUPS (object);
96 g_free (printer->device_uri);
97 g_free (printer->printer_uri);
98 g_free (printer->hostname);
99 g_free (printer->ppd_name);
100 g_free (printer->default_cover_before);
101 g_free (printer->default_cover_after);
102 g_strfreev (printer->auth_info_required);
104 if (printer->ppd_file)
105 ppdClose (printer->ppd_file);
107 if (printer->get_remote_ppd_poll > 0)
108 g_source_remove (printer->get_remote_ppd_poll);
109 printer->get_remote_ppd_attempts = 0;
111 gtk_cups_connection_test_free (printer->remote_cups_connection_test);
113 G_OBJECT_CLASS (gtk_printer_cups_parent_class)->finalize (object);
117 * gtk_printer_cups_new:
119 * Creates a new #GtkPrinterCups.
121 * Return value: a new #GtkPrinterCups
126 gtk_printer_cups_new (const char *name,
127 GtkPrintBackend *backend)
131 result = g_object_new (GTK_TYPE_PRINTER_CUPS,
137 return (GtkPrinterCups *) result;
141 gtk_printer_cups_get_ppd (GtkPrinterCups *printer)
143 return printer->ppd_file;
147 gtk_printer_cups_get_ppd_name (GtkPrinterCups *printer)
151 result = printer->ppd_name;
154 result = gtk_printer_get_name (GTK_PRINTER (printer));