]> Pileus Git - ~andy/gtk/blob - modules/printbackends/papi/gtkprinterpapi.c
979c42877c627e2a4c3542a7f02122b9830595a3
[~andy/gtk] / modules / printbackends / papi / gtkprinterpapi.c
1 /* GtkPrinterPapi
2  * Copyright (C) 2006 John (J5) Palmieri  <johnp@redhat.com>
3  * Copyright (C) 2009 Ghee Teo <ghee.teo@sun.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #include "config.h"
22 #include "gtkprinterpapi.h"
23
24 static void gtk_printer_papi_init       (GtkPrinterPapi      *printer);
25 static void gtk_printer_papi_class_init (GtkPrinterPapiClass *class);
26 static void gtk_printer_papi_finalize   (GObject             *object);
27
28 static GtkPrinterClass *gtk_printer_papi_parent_class;
29 static GType gtk_printer_papi_type = 0;
30
31 void 
32 gtk_printer_papi_register_type (GTypeModule *module)
33 {
34   const GTypeInfo object_info =
35   {
36     sizeof (GtkPrinterPapiClass),
37     (GBaseInitFunc) NULL,
38     (GBaseFinalizeFunc) NULL,
39     (GClassInitFunc) gtk_printer_papi_class_init,
40     NULL,           /* class_finalize */
41     NULL,           /* class_data */
42     sizeof (GtkPrinterPapi),
43     0,              /* n_preallocs */
44     (GInstanceInitFunc) gtk_printer_papi_init,
45   };
46
47  gtk_printer_papi_type = g_type_module_register_type (module,
48                                                       GTK_TYPE_PRINTER,
49                                                       "GtkPrinterPapi",
50                                                       &object_info, 0);
51 }
52
53 GType
54 gtk_printer_papi_get_type (void)
55 {
56   return gtk_printer_papi_type;
57 }
58
59 static void
60 gtk_printer_papi_class_init (GtkPrinterPapiClass *class)
61 {
62   GObjectClass *object_class = (GObjectClass *) class;
63         
64   gtk_printer_papi_parent_class = g_type_class_peek_parent (class);
65
66   object_class->finalize = gtk_printer_papi_finalize;
67 }
68
69 static void
70 gtk_printer_papi_init (GtkPrinterPapi *printer)
71 {
72   printer->printer_name = NULL;
73 }
74
75 static void
76 gtk_printer_papi_finalize (GObject *object)
77 {
78   GtkPrinterPapi *printer;
79
80   g_return_if_fail (object != NULL);
81
82   printer = GTK_PRINTER_PAPI (object);
83
84   g_free(printer->printer_name);
85
86   G_OBJECT_CLASS (gtk_printer_papi_parent_class)->finalize (object);
87 }
88
89 /**
90  * gtk_printer_papi_new:
91  *
92  * Creates a new #GtkPrinterPapi.
93  *
94  * Return value: a new #GtkPrinterPapi
95  *
96  * Since: 2.10
97  **/
98 GtkPrinterPapi *
99 gtk_printer_papi_new (const char      *name,
100                       GtkPrintBackend *backend)
101 {
102   GObject *result;
103   GtkPrinterPapi *pp;
104   
105   result = g_object_new (GTK_TYPE_PRINTER_PAPI,
106                          "name", name,
107                          "backend", backend,
108                          "is-virtual", TRUE,
109                          NULL);
110   pp = GTK_PRINTER_PAPI(result);
111
112   pp->printer_name = g_strdup (name);
113
114   return (GtkPrinterPapi *) pp;
115 }
116