| File: | ctk/ctkprinter.c |
| Warning: | line 1290, column 1 Potential leak of memory pointed to by 'printer_list' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* CtkPrinter | |||
| 2 | * Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com> | |||
| 3 | * | |||
| 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. | |||
| 8 | * | |||
| 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. | |||
| 13 | * | |||
| 14 | * You should have received a copy of the GNU Lesser General Public | |||
| 15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
| 16 | */ | |||
| 17 | ||||
| 18 | #include "config.h" | |||
| 19 | #include <stdlib.h> | |||
| 20 | #include <string.h> | |||
| 21 | #include <stdio.h> | |||
| 22 | ||||
| 23 | #include "ctkintl.h" | |||
| 24 | #include "ctkprivate.h" | |||
| 25 | ||||
| 26 | #include "ctkprinter.h" | |||
| 27 | #include "ctkprinter-private.h" | |||
| 28 | #include "ctkprintbackend.h" | |||
| 29 | #include "ctkprintjob.h" | |||
| 30 | ||||
| 31 | /** | |||
| 32 | * SECTION:ctkprinter | |||
| 33 | * @Short_description: Represents a printer | |||
| 34 | * @Title: CtkPrinter | |||
| 35 | * | |||
| 36 | * A #CtkPrinter object represents a printer. You only need to | |||
| 37 | * deal directly with printers if you use the non-portable | |||
| 38 | * #CtkPrintUnixDialog API. | |||
| 39 | * | |||
| 40 | * A #CtkPrinter allows to get status information about the printer, | |||
| 41 | * such as its description, its location, the number of queued jobs, | |||
| 42 | * etc. Most importantly, a #CtkPrinter object can be used to create | |||
| 43 | * a #CtkPrintJob object, which lets you print to the printer. | |||
| 44 | * | |||
| 45 | * Printing support was added in CTK+ 2.10. | |||
| 46 | */ | |||
| 47 | ||||
| 48 | ||||
| 49 | static void ctk_printer_finalize (GObject *object); | |||
| 50 | ||||
| 51 | struct _CtkPrinterPrivate | |||
| 52 | { | |||
| 53 | gchar *name; | |||
| 54 | gchar *location; | |||
| 55 | gchar *description; | |||
| 56 | gchar *icon_name; | |||
| 57 | ||||
| 58 | guint is_active : 1; | |||
| 59 | guint is_paused : 1; | |||
| 60 | guint is_accepting_jobs : 1; | |||
| 61 | guint is_new : 1; | |||
| 62 | guint is_virtual : 1; | |||
| 63 | guint is_default : 1; | |||
| 64 | guint has_details : 1; | |||
| 65 | guint accepts_pdf : 1; | |||
| 66 | guint accepts_ps : 1; | |||
| 67 | ||||
| 68 | gchar *state_message; | |||
| 69 | gint job_count; | |||
| 70 | ||||
| 71 | CtkPrintBackend *backend; | |||
| 72 | }; | |||
| 73 | ||||
| 74 | enum { | |||
| 75 | DETAILS_ACQUIRED, | |||
| 76 | LAST_SIGNAL | |||
| 77 | }; | |||
| 78 | ||||
| 79 | enum { | |||
| 80 | PROP_0, | |||
| 81 | PROP_NAME, | |||
| 82 | PROP_BACKEND, | |||
| 83 | PROP_IS_VIRTUAL, | |||
| 84 | PROP_STATE_MESSAGE, | |||
| 85 | PROP_LOCATION, | |||
| 86 | PROP_ICON_NAME, | |||
| 87 | PROP_JOB_COUNT, | |||
| 88 | PROP_ACCEPTS_PDF, | |||
| 89 | PROP_ACCEPTS_PS, | |||
| 90 | PROP_PAUSED, | |||
| 91 | PROP_ACCEPTING_JOBS | |||
| 92 | }; | |||
| 93 | ||||
| 94 | static guint signals[LAST_SIGNAL] = { 0 }; | |||
| 95 | ||||
| 96 | static void ctk_printer_set_property (GObject *object, | |||
| 97 | guint prop_id, | |||
| 98 | const GValue *value, | |||
| 99 | GParamSpec *pspec); | |||
| 100 | static void ctk_printer_get_property (GObject *object, | |||
| 101 | guint prop_id, | |||
| 102 | GValue *value, | |||
| 103 | GParamSpec *pspec); | |||
| 104 | ||||
| 105 | G_DEFINE_TYPE_WITH_PRIVATE (CtkPrinter, ctk_printer, G_TYPE_OBJECT)static void ctk_printer_init (CtkPrinter *self); static void ctk_printer_class_init (CtkPrinterClass *klass); static GType ctk_printer_get_type_once (void); static gpointer ctk_printer_parent_class = ((void*)0 ); static gint CtkPrinter_private_offset; static void ctk_printer_class_intern_init (gpointer klass) { ctk_printer_parent_class = g_type_class_peek_parent (klass); if (CtkPrinter_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkPrinter_private_offset); ctk_printer_class_init ((CtkPrinterClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_printer_get_instance_private (CtkPrinter *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkPrinter_private_offset )))); } GType ctk_printer_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); (void ) (0 ? (gpointer) * (&static_g_define_type_id) : ((void*) 0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_printer_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_printer_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((( GType) ((20) << (2))), g_intern_static_string ("CtkPrinter" ), sizeof (CtkPrinterClass), (GClassInitFunc)(void (*)(void)) ctk_printer_class_intern_init, sizeof (CtkPrinter), (GInstanceInitFunc )(void (*)(void)) ctk_printer_init, (GTypeFlags) 0); { {{ CtkPrinter_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkPrinterPrivate )); };} } return g_define_type_id; } | |||
| 106 | ||||
| 107 | static void | |||
| 108 | ctk_printer_class_init (CtkPrinterClass *class) | |||
| 109 | { | |||
| 110 | GObjectClass *object_class; | |||
| 111 | object_class = (GObjectClass *) class; | |||
| 112 | ||||
| 113 | object_class->finalize = ctk_printer_finalize; | |||
| 114 | ||||
| 115 | object_class->set_property = ctk_printer_set_property; | |||
| 116 | object_class->get_property = ctk_printer_get_property; | |||
| 117 | ||||
| 118 | g_object_class_install_property (G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))), | |||
| 119 | PROP_NAME, | |||
| 120 | g_param_spec_string ("name", | |||
| 121 | P_("Name")g_dgettext("ctk30" "-properties","Name"), | |||
| 122 | P_("Name of the printer")g_dgettext("ctk30" "-properties","Name of the printer"), | |||
| 123 | "", | |||
| 124 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY)); | |||
| 125 | g_object_class_install_property (G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))), | |||
| 126 | PROP_BACKEND, | |||
| 127 | g_param_spec_object ("backend", | |||
| 128 | P_("Backend")g_dgettext("ctk30" "-properties","Backend"), | |||
| 129 | P_("Backend for the printer")g_dgettext("ctk30" "-properties","Backend for the printer"), | |||
| 130 | CTK_TYPE_PRINT_BACKEND(ctk_print_backend_get_type ()), | |||
| 131 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY)); | |||
| 132 | g_object_class_install_property (G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))), | |||
| 133 | PROP_IS_VIRTUAL, | |||
| 134 | g_param_spec_boolean ("is-virtual", | |||
| 135 | P_("Is Virtual")g_dgettext("ctk30" "-properties","Is Virtual"), | |||
| 136 | P_("FALSE if this represents a real hardware printer")g_dgettext("ctk30" "-properties","FALSE if this represents a real hardware printer" ), | |||
| 137 | FALSE(0), | |||
| 138 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY)); | |||
| 139 | g_object_class_install_property (G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))), | |||
| 140 | PROP_ACCEPTS_PDF, | |||
| 141 | g_param_spec_boolean ("accepts-pdf", | |||
| 142 | P_("Accepts PDF")g_dgettext("ctk30" "-properties","Accepts PDF"), | |||
| 143 | P_("TRUE if this printer can accept PDF")g_dgettext("ctk30" "-properties","TRUE if this printer can accept PDF" ), | |||
| 144 | FALSE(0), | |||
| 145 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY)); | |||
| 146 | g_object_class_install_property (G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))), | |||
| 147 | PROP_ACCEPTS_PS, | |||
| 148 | g_param_spec_boolean ("accepts-ps", | |||
| 149 | P_("Accepts PostScript")g_dgettext("ctk30" "-properties","Accepts PostScript"), | |||
| 150 | P_("TRUE if this printer can accept PostScript")g_dgettext("ctk30" "-properties","TRUE if this printer can accept PostScript" ), | |||
| 151 | TRUE(!(0)), | |||
| 152 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY)); | |||
| 153 | g_object_class_install_property (G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))), | |||
| 154 | PROP_STATE_MESSAGE, | |||
| 155 | g_param_spec_string ("state-message", | |||
| 156 | P_("State Message")g_dgettext("ctk30" "-properties","State Message"), | |||
| 157 | P_("String giving the current state of the printer")g_dgettext("ctk30" "-properties","String giving the current state of the printer" ), | |||
| 158 | "", | |||
| 159 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
| 160 | g_object_class_install_property (G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))), | |||
| 161 | PROP_LOCATION, | |||
| 162 | g_param_spec_string ("location", | |||
| 163 | P_("Location")g_dgettext("ctk30" "-properties","Location"), | |||
| 164 | P_("The location of the printer")g_dgettext("ctk30" "-properties","The location of the printer" ), | |||
| 165 | "", | |||
| 166 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
| 167 | g_object_class_install_property (G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))), | |||
| 168 | PROP_ICON_NAME, | |||
| 169 | g_param_spec_string ("icon-name", | |||
| 170 | P_("Icon Name")g_dgettext("ctk30" "-properties","Icon Name"), | |||
| 171 | P_("The icon name to use for the printer")g_dgettext("ctk30" "-properties","The icon name to use for the printer" ), | |||
| 172 | "", | |||
| 173 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
| 174 | g_object_class_install_property (G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))), | |||
| 175 | PROP_JOB_COUNT, | |||
| 176 | g_param_spec_int ("job-count", | |||
| 177 | P_("Job Count")g_dgettext("ctk30" "-properties","Job Count"), | |||
| 178 | P_("Number of jobs queued in the printer")g_dgettext("ctk30" "-properties","Number of jobs queued in the printer" ), | |||
| 179 | 0, | |||
| 180 | G_MAXINT2147483647, | |||
| 181 | 0, | |||
| 182 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
| 183 | ||||
| 184 | /** | |||
| 185 | * CtkPrinter:paused: | |||
| 186 | * | |||
| 187 | * This property is %TRUE if this printer is paused. | |||
| 188 | * A paused printer still accepts jobs, but it does | |||
| 189 | * not print them. | |||
| 190 | * | |||
| 191 | * Since: 2.14 | |||
| 192 | */ | |||
| 193 | g_object_class_install_property (G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))), | |||
| 194 | PROP_PAUSED, | |||
| 195 | g_param_spec_boolean ("paused", | |||
| 196 | P_("Paused Printer")g_dgettext("ctk30" "-properties","Paused Printer"), | |||
| 197 | P_("TRUE if this printer is paused")g_dgettext("ctk30" "-properties","TRUE if this printer is paused" ), | |||
| 198 | FALSE(0), | |||
| 199 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
| 200 | /** | |||
| 201 | * CtkPrinter:accepting-jobs: | |||
| 202 | * | |||
| 203 | * This property is %TRUE if the printer is accepting jobs. | |||
| 204 | * | |||
| 205 | * Since: 2.14 | |||
| 206 | */ | |||
| 207 | g_object_class_install_property (G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))), | |||
| 208 | PROP_ACCEPTING_JOBS, | |||
| 209 | g_param_spec_boolean ("accepting-jobs", | |||
| 210 | P_("Accepting Jobs")g_dgettext("ctk30" "-properties","Accepting Jobs"), | |||
| 211 | P_("TRUE if this printer is accepting new jobs")g_dgettext("ctk30" "-properties","TRUE if this printer is accepting new jobs" ), | |||
| 212 | TRUE(!(0)), | |||
| 213 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
| 214 | ||||
| 215 | /** | |||
| 216 | * CtkPrinter::details-acquired: | |||
| 217 | * @printer: the #CtkPrinter on which the signal is emitted | |||
| 218 | * @success: %TRUE if the details were successfully acquired | |||
| 219 | * | |||
| 220 | * Gets emitted in response to a request for detailed information | |||
| 221 | * about a printer from the print backend. The @success parameter | |||
| 222 | * indicates if the information was actually obtained. | |||
| 223 | * | |||
| 224 | * Since: 2.10 | |||
| 225 | */ | |||
| 226 | signals[DETAILS_ACQUIRED] = | |||
| 227 | g_signal_new (I_("details-acquired")g_intern_static_string ("details-acquired"), | |||
| 228 | G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type), | |||
| 229 | G_SIGNAL_RUN_LAST, | |||
| 230 | G_STRUCT_OFFSET (CtkPrinterClass, details_acquired)((glong) __builtin_offsetof(CtkPrinterClass, details_acquired )), | |||
| 231 | NULL((void*)0), NULL((void*)0), | |||
| 232 | NULL((void*)0), | |||
| 233 | G_TYPE_NONE((GType) ((1) << (2))), 1, G_TYPE_BOOLEAN((GType) ((5) << (2)))); | |||
| 234 | } | |||
| 235 | ||||
| 236 | static void | |||
| 237 | ctk_printer_init (CtkPrinter *printer) | |||
| 238 | { | |||
| 239 | CtkPrinterPrivate *priv; | |||
| 240 | ||||
| 241 | priv = printer->priv = ctk_printer_get_instance_private (printer); | |||
| 242 | ||||
| 243 | priv->name = NULL((void*)0); | |||
| 244 | priv->location = NULL((void*)0); | |||
| 245 | priv->description = NULL((void*)0); | |||
| 246 | priv->icon_name = g_strdup ("printer")g_strdup_inline ("printer"); | |||
| 247 | ||||
| 248 | priv->is_active = TRUE(!(0)); | |||
| 249 | priv->is_paused = FALSE(0); | |||
| 250 | priv->is_accepting_jobs = TRUE(!(0)); | |||
| 251 | priv->is_new = TRUE(!(0)); | |||
| 252 | priv->has_details = FALSE(0); | |||
| 253 | priv->accepts_pdf = FALSE(0); | |||
| 254 | priv->accepts_ps = TRUE(!(0)); | |||
| 255 | ||||
| 256 | priv->state_message = NULL((void*)0); | |||
| 257 | priv->job_count = 0; | |||
| 258 | } | |||
| 259 | ||||
| 260 | static void | |||
| 261 | ctk_printer_finalize (GObject *object) | |||
| 262 | { | |||
| 263 | CtkPrinter *printer = CTK_PRINTER (object)((((CtkPrinter*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_printer_get_type ())))))); | |||
| 264 | CtkPrinterPrivate *priv = printer->priv; | |||
| 265 | ||||
| 266 | g_free (priv->name); | |||
| 267 | g_free (priv->location); | |||
| 268 | g_free (priv->description); | |||
| 269 | g_free (priv->state_message); | |||
| 270 | g_free (priv->icon_name); | |||
| 271 | ||||
| 272 | if (priv->backend) | |||
| 273 | g_object_unref (priv->backend); | |||
| 274 | ||||
| 275 | G_OBJECT_CLASS (ctk_printer_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_printer_parent_class)), (((GType) ((20) << (2) )))))))->finalize (object); | |||
| 276 | } | |||
| 277 | ||||
| 278 | static void | |||
| 279 | ctk_printer_set_property (GObject *object, | |||
| 280 | guint prop_id, | |||
| 281 | const GValue *value, | |||
| 282 | GParamSpec *pspec) | |||
| 283 | { | |||
| 284 | CtkPrinter *printer = CTK_PRINTER (object)((((CtkPrinter*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_printer_get_type ())))))); | |||
| 285 | CtkPrinterPrivate *priv = printer->priv; | |||
| 286 | ||||
| 287 | switch (prop_id) | |||
| 288 | { | |||
| 289 | case PROP_NAME: | |||
| 290 | priv->name = g_value_dup_string (value); | |||
| 291 | break; | |||
| 292 | ||||
| 293 | case PROP_BACKEND: | |||
| 294 | priv->backend = CTK_PRINT_BACKEND (g_value_dup_object (value))((((CtkPrintBackend*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g_value_dup_object (value))), ((ctk_print_backend_get_type ())))))); | |||
| 295 | break; | |||
| 296 | ||||
| 297 | case PROP_IS_VIRTUAL: | |||
| 298 | priv->is_virtual = g_value_get_boolean (value); | |||
| 299 | break; | |||
| 300 | ||||
| 301 | case PROP_ACCEPTS_PDF: | |||
| 302 | priv->accepts_pdf = g_value_get_boolean (value); | |||
| 303 | break; | |||
| 304 | ||||
| 305 | case PROP_ACCEPTS_PS: | |||
| 306 | priv->accepts_ps = g_value_get_boolean (value); | |||
| 307 | break; | |||
| 308 | ||||
| 309 | default: | |||
| 310 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkprinter.c", 310, ("property"), _glib__property_id, _glib__pspec ->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) ( _glib__pspec))->g_class))->g_type)))), (g_type_name ((( (((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); | |||
| 311 | break; | |||
| 312 | } | |||
| 313 | } | |||
| 314 | ||||
| 315 | static void | |||
| 316 | ctk_printer_get_property (GObject *object, | |||
| 317 | guint prop_id, | |||
| 318 | GValue *value, | |||
| 319 | GParamSpec *pspec) | |||
| 320 | { | |||
| 321 | CtkPrinter *printer = CTK_PRINTER (object)((((CtkPrinter*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_printer_get_type ())))))); | |||
| 322 | CtkPrinterPrivate *priv = printer->priv; | |||
| 323 | ||||
| 324 | switch (prop_id) | |||
| 325 | { | |||
| 326 | case PROP_NAME: | |||
| 327 | if (priv->name) | |||
| 328 | g_value_set_string (value, priv->name); | |||
| 329 | else | |||
| 330 | g_value_set_static_string (value, ""); | |||
| 331 | break; | |||
| 332 | case PROP_BACKEND: | |||
| 333 | g_value_set_object (value, priv->backend); | |||
| 334 | break; | |||
| 335 | case PROP_STATE_MESSAGE: | |||
| 336 | if (priv->state_message) | |||
| 337 | g_value_set_string (value, priv->state_message); | |||
| 338 | else | |||
| 339 | g_value_set_static_string (value, ""); | |||
| 340 | break; | |||
| 341 | case PROP_LOCATION: | |||
| 342 | if (priv->location) | |||
| 343 | g_value_set_string (value, priv->location); | |||
| 344 | else | |||
| 345 | g_value_set_static_string (value, ""); | |||
| 346 | break; | |||
| 347 | case PROP_ICON_NAME: | |||
| 348 | if (priv->icon_name) | |||
| 349 | g_value_set_string (value, priv->icon_name); | |||
| 350 | else | |||
| 351 | g_value_set_static_string (value, ""); | |||
| 352 | break; | |||
| 353 | case PROP_JOB_COUNT: | |||
| 354 | g_value_set_int (value, priv->job_count); | |||
| 355 | break; | |||
| 356 | case PROP_IS_VIRTUAL: | |||
| 357 | g_value_set_boolean (value, priv->is_virtual); | |||
| 358 | break; | |||
| 359 | case PROP_ACCEPTS_PDF: | |||
| 360 | g_value_set_boolean (value, priv->accepts_pdf); | |||
| 361 | break; | |||
| 362 | case PROP_ACCEPTS_PS: | |||
| 363 | g_value_set_boolean (value, priv->accepts_ps); | |||
| 364 | break; | |||
| 365 | case PROP_PAUSED: | |||
| 366 | g_value_set_boolean (value, priv->is_paused); | |||
| 367 | break; | |||
| 368 | case PROP_ACCEPTING_JOBS: | |||
| 369 | g_value_set_boolean (value, priv->is_accepting_jobs); | |||
| 370 | break; | |||
| 371 | default: | |||
| 372 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkprinter.c", 372, ("property"), _glib__property_id, _glib__pspec ->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) ( _glib__pspec))->g_class))->g_type)))), (g_type_name ((( (((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); | |||
| 373 | break; | |||
| 374 | } | |||
| 375 | } | |||
| 376 | ||||
| 377 | /** | |||
| 378 | * ctk_printer_new: | |||
| 379 | * @name: the name of the printer | |||
| 380 | * @backend: a #CtkPrintBackend | |||
| 381 | * @virtual_: whether the printer is virtual | |||
| 382 | * | |||
| 383 | * Creates a new #CtkPrinter. | |||
| 384 | * | |||
| 385 | * Returns: a new #CtkPrinter | |||
| 386 | * | |||
| 387 | * Since: 2.10 | |||
| 388 | **/ | |||
| 389 | CtkPrinter * | |||
| 390 | ctk_printer_new (const gchar *name, | |||
| 391 | CtkPrintBackend *backend, | |||
| 392 | gboolean virtual_) | |||
| 393 | { | |||
| 394 | GObject *result; | |||
| 395 | ||||
| 396 | result = g_object_new (CTK_TYPE_PRINTER(ctk_printer_get_type ()), | |||
| 397 | "name", name, | |||
| 398 | "backend", backend, | |||
| 399 | "is-virtual", virtual_, | |||
| 400 | NULL((void*)0)); | |||
| 401 | ||||
| 402 | return (CtkPrinter *) result; | |||
| 403 | } | |||
| 404 | ||||
| 405 | /** | |||
| 406 | * ctk_printer_get_backend: | |||
| 407 | * @printer: a #CtkPrinter | |||
| 408 | * | |||
| 409 | * Returns the backend of the printer. | |||
| 410 | * | |||
| 411 | * Returns: (transfer none): the backend of @printer | |||
| 412 | * | |||
| 413 | * Since: 2.10 | |||
| 414 | */ | |||
| 415 | CtkPrintBackend * | |||
| 416 | ctk_printer_get_backend (CtkPrinter *printer) | |||
| 417 | { | |||
| 418 | g_return_val_if_fail (CTK_IS_PRINTER (printer), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return (((void*)0)); } } while (0); | |||
| 419 | ||||
| 420 | return printer->priv->backend; | |||
| 421 | } | |||
| 422 | ||||
| 423 | /** | |||
| 424 | * ctk_printer_get_name: | |||
| 425 | * @printer: a #CtkPrinter | |||
| 426 | * | |||
| 427 | * Returns the name of the printer. | |||
| 428 | * | |||
| 429 | * Returns: the name of @printer | |||
| 430 | * | |||
| 431 | * Since: 2.10 | |||
| 432 | */ | |||
| 433 | const gchar * | |||
| 434 | ctk_printer_get_name (CtkPrinter *printer) | |||
| 435 | { | |||
| 436 | g_return_val_if_fail (CTK_IS_PRINTER (printer), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return (((void*)0)); } } while (0); | |||
| 437 | ||||
| 438 | return printer->priv->name; | |||
| 439 | } | |||
| 440 | ||||
| 441 | /** | |||
| 442 | * ctk_printer_get_description: | |||
| 443 | * @printer: a #CtkPrinter | |||
| 444 | * | |||
| 445 | * Gets the description of the printer. | |||
| 446 | * | |||
| 447 | * Returns: the description of @printer | |||
| 448 | * | |||
| 449 | * Since: 2.10 | |||
| 450 | */ | |||
| 451 | const gchar * | |||
| 452 | ctk_printer_get_description (CtkPrinter *printer) | |||
| 453 | { | |||
| 454 | g_return_val_if_fail (CTK_IS_PRINTER (printer), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return (((void*)0)); } } while (0); | |||
| 455 | ||||
| 456 | return printer->priv->description; | |||
| 457 | } | |||
| 458 | ||||
| 459 | gboolean | |||
| 460 | ctk_printer_set_description (CtkPrinter *printer, | |||
| 461 | const gchar *description) | |||
| 462 | { | |||
| 463 | CtkPrinterPrivate *priv; | |||
| 464 | ||||
| 465 | g_return_val_if_fail (CTK_IS_PRINTER (printer), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((0)); } } while (0); | |||
| 466 | ||||
| 467 | priv = printer->priv; | |||
| 468 | ||||
| 469 | if (g_strcmp0 (priv->description, description) == 0) | |||
| 470 | return FALSE(0); | |||
| 471 | ||||
| 472 | g_free (priv->description); | |||
| 473 | priv->description = g_strdup (description)g_strdup_inline (description); | |||
| 474 | ||||
| 475 | return TRUE(!(0)); | |||
| 476 | } | |||
| 477 | ||||
| 478 | /** | |||
| 479 | * ctk_printer_get_state_message: | |||
| 480 | * @printer: a #CtkPrinter | |||
| 481 | * | |||
| 482 | * Returns the state message describing the current state | |||
| 483 | * of the printer. | |||
| 484 | * | |||
| 485 | * Returns: the state message of @printer | |||
| 486 | * | |||
| 487 | * Since: 2.10 | |||
| 488 | */ | |||
| 489 | const gchar * | |||
| 490 | ctk_printer_get_state_message (CtkPrinter *printer) | |||
| 491 | { | |||
| 492 | g_return_val_if_fail (CTK_IS_PRINTER (printer), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return (((void*)0)); } } while (0); | |||
| 493 | ||||
| 494 | return printer->priv->state_message; | |||
| 495 | } | |||
| 496 | ||||
| 497 | gboolean | |||
| 498 | ctk_printer_set_state_message (CtkPrinter *printer, | |||
| 499 | const gchar *message) | |||
| 500 | { | |||
| 501 | CtkPrinterPrivate *priv; | |||
| 502 | ||||
| 503 | g_return_val_if_fail (CTK_IS_PRINTER (printer), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((0)); } } while (0); | |||
| 504 | ||||
| 505 | priv = printer->priv; | |||
| 506 | ||||
| 507 | if (g_strcmp0 (priv->state_message, message) == 0) | |||
| 508 | return FALSE(0); | |||
| 509 | ||||
| 510 | g_free (priv->state_message); | |||
| 511 | priv->state_message = g_strdup (message)g_strdup_inline (message); | |||
| 512 | g_object_notify (G_OBJECT (printer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((printer)), (((GType) ((20) << (2)))))))), "state-message"); | |||
| 513 | ||||
| 514 | return TRUE(!(0)); | |||
| 515 | } | |||
| 516 | ||||
| 517 | /** | |||
| 518 | * ctk_printer_get_location: | |||
| 519 | * @printer: a #CtkPrinter | |||
| 520 | * | |||
| 521 | * Returns a description of the location of the printer. | |||
| 522 | * | |||
| 523 | * Returns: the location of @printer | |||
| 524 | * | |||
| 525 | * Since: 2.10 | |||
| 526 | */ | |||
| 527 | const gchar * | |||
| 528 | ctk_printer_get_location (CtkPrinter *printer) | |||
| 529 | { | |||
| 530 | g_return_val_if_fail (CTK_IS_PRINTER (printer), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return (((void*)0)); } } while (0); | |||
| 531 | ||||
| 532 | return printer->priv->location; | |||
| 533 | } | |||
| 534 | ||||
| 535 | gboolean | |||
| 536 | ctk_printer_set_location (CtkPrinter *printer, | |||
| 537 | const gchar *location) | |||
| 538 | { | |||
| 539 | CtkPrinterPrivate *priv; | |||
| 540 | ||||
| 541 | g_return_val_if_fail (CTK_IS_PRINTER (printer), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((0)); } } while (0); | |||
| 542 | ||||
| 543 | priv = printer->priv; | |||
| 544 | ||||
| 545 | if (g_strcmp0 (priv->location, location) == 0) | |||
| 546 | return FALSE(0); | |||
| 547 | ||||
| 548 | g_free (priv->location); | |||
| 549 | priv->location = g_strdup (location)g_strdup_inline (location); | |||
| 550 | g_object_notify (G_OBJECT (printer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((printer)), (((GType) ((20) << (2)))))))), "location"); | |||
| 551 | ||||
| 552 | return TRUE(!(0)); | |||
| 553 | } | |||
| 554 | ||||
| 555 | /** | |||
| 556 | * ctk_printer_get_icon_name: | |||
| 557 | * @printer: a #CtkPrinter | |||
| 558 | * | |||
| 559 | * Gets the name of the icon to use for the printer. | |||
| 560 | * | |||
| 561 | * Returns: the icon name for @printer | |||
| 562 | * | |||
| 563 | * Since: 2.10 | |||
| 564 | */ | |||
| 565 | const gchar * | |||
| 566 | ctk_printer_get_icon_name (CtkPrinter *printer) | |||
| 567 | { | |||
| 568 | g_return_val_if_fail (CTK_IS_PRINTER (printer), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return (((void*)0)); } } while (0); | |||
| 569 | ||||
| 570 | return printer->priv->icon_name; | |||
| 571 | } | |||
| 572 | ||||
| 573 | void | |||
| 574 | ctk_printer_set_icon_name (CtkPrinter *printer, | |||
| 575 | const gchar *icon) | |||
| 576 | { | |||
| 577 | CtkPrinterPrivate *priv; | |||
| 578 | ||||
| 579 | g_return_if_fail (CTK_IS_PRINTER (printer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return; } } while (0); | |||
| 580 | ||||
| 581 | priv = printer->priv; | |||
| 582 | ||||
| 583 | g_free (priv->icon_name); | |||
| 584 | priv->icon_name = g_strdup (icon)g_strdup_inline (icon); | |||
| 585 | g_object_notify (G_OBJECT (printer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((printer)), (((GType) ((20) << (2)))))))), "icon-name"); | |||
| 586 | } | |||
| 587 | ||||
| 588 | /** | |||
| 589 | * ctk_printer_get_job_count: | |||
| 590 | * @printer: a #CtkPrinter | |||
| 591 | * | |||
| 592 | * Gets the number of jobs currently queued on the printer. | |||
| 593 | * | |||
| 594 | * Returns: the number of jobs on @printer | |||
| 595 | * | |||
| 596 | * Since: 2.10 | |||
| 597 | */ | |||
| 598 | gint | |||
| 599 | ctk_printer_get_job_count (CtkPrinter *printer) | |||
| 600 | { | |||
| 601 | g_return_val_if_fail (CTK_IS_PRINTER (printer), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return (0); } } while (0); | |||
| 602 | ||||
| 603 | return printer->priv->job_count; | |||
| 604 | } | |||
| 605 | ||||
| 606 | gboolean | |||
| 607 | ctk_printer_set_job_count (CtkPrinter *printer, | |||
| 608 | gint count) | |||
| 609 | { | |||
| 610 | CtkPrinterPrivate *priv; | |||
| 611 | ||||
| 612 | g_return_val_if_fail (CTK_IS_PRINTER (printer), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((0)); } } while (0); | |||
| 613 | ||||
| 614 | priv = printer->priv; | |||
| 615 | ||||
| 616 | if (priv->job_count == count) | |||
| 617 | return FALSE(0); | |||
| 618 | ||||
| 619 | priv->job_count = count; | |||
| 620 | ||||
| 621 | g_object_notify (G_OBJECT (printer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((printer)), (((GType) ((20) << (2)))))))), "job-count"); | |||
| 622 | ||||
| 623 | return TRUE(!(0)); | |||
| 624 | } | |||
| 625 | ||||
| 626 | /** | |||
| 627 | * ctk_printer_has_details: | |||
| 628 | * @printer: a #CtkPrinter | |||
| 629 | * | |||
| 630 | * Returns whether the printer details are available. | |||
| 631 | * | |||
| 632 | * Returns: %TRUE if @printer details are available | |||
| 633 | * | |||
| 634 | * Since: 2.12 | |||
| 635 | */ | |||
| 636 | gboolean | |||
| 637 | ctk_printer_has_details (CtkPrinter *printer) | |||
| 638 | { | |||
| 639 | g_return_val_if_fail (CTK_IS_PRINTER (printer), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((0)); } } while (0); | |||
| 640 | ||||
| 641 | return printer->priv->has_details; | |||
| 642 | } | |||
| 643 | ||||
| 644 | void | |||
| 645 | ctk_printer_set_has_details (CtkPrinter *printer, | |||
| 646 | gboolean val) | |||
| 647 | { | |||
| 648 | printer->priv->has_details = val; | |||
| 649 | } | |||
| 650 | ||||
| 651 | /** | |||
| 652 | * ctk_printer_is_active: | |||
| 653 | * @printer: a #CtkPrinter | |||
| 654 | * | |||
| 655 | * Returns whether the printer is currently active (i.e. | |||
| 656 | * accepts new jobs). | |||
| 657 | * | |||
| 658 | * Returns: %TRUE if @printer is active | |||
| 659 | * | |||
| 660 | * Since: 2.10 | |||
| 661 | */ | |||
| 662 | gboolean | |||
| 663 | ctk_printer_is_active (CtkPrinter *printer) | |||
| 664 | { | |||
| 665 | g_return_val_if_fail (CTK_IS_PRINTER (printer), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((!(0))); } } while ( 0); | |||
| 666 | ||||
| 667 | return printer->priv->is_active; | |||
| 668 | } | |||
| 669 | ||||
| 670 | void | |||
| 671 | ctk_printer_set_is_active (CtkPrinter *printer, | |||
| 672 | gboolean val) | |||
| 673 | { | |||
| 674 | g_return_if_fail (CTK_IS_PRINTER (printer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return; } } while (0); | |||
| 675 | ||||
| 676 | printer->priv->is_active = val; | |||
| 677 | } | |||
| 678 | ||||
| 679 | /** | |||
| 680 | * ctk_printer_is_paused: | |||
| 681 | * @printer: a #CtkPrinter | |||
| 682 | * | |||
| 683 | * Returns whether the printer is currently paused. | |||
| 684 | * A paused printer still accepts jobs, but it is not | |||
| 685 | * printing them. | |||
| 686 | * | |||
| 687 | * Returns: %TRUE if @printer is paused | |||
| 688 | * | |||
| 689 | * Since: 2.14 | |||
| 690 | */ | |||
| 691 | gboolean | |||
| 692 | ctk_printer_is_paused (CtkPrinter *printer) | |||
| 693 | { | |||
| 694 | g_return_val_if_fail (CTK_IS_PRINTER (printer), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((!(0))); } } while ( 0); | |||
| 695 | ||||
| 696 | return printer->priv->is_paused; | |||
| 697 | } | |||
| 698 | ||||
| 699 | gboolean | |||
| 700 | ctk_printer_set_is_paused (CtkPrinter *printer, | |||
| 701 | gboolean val) | |||
| 702 | { | |||
| 703 | CtkPrinterPrivate *priv; | |||
| 704 | ||||
| 705 | g_return_val_if_fail (CTK_IS_PRINTER (printer), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((0)); } } while (0); | |||
| 706 | ||||
| 707 | priv = printer->priv; | |||
| 708 | ||||
| 709 | if (val == priv->is_paused) | |||
| 710 | return FALSE(0); | |||
| 711 | ||||
| 712 | priv->is_paused = val; | |||
| 713 | ||||
| 714 | return TRUE(!(0)); | |||
| 715 | } | |||
| 716 | ||||
| 717 | /** | |||
| 718 | * ctk_printer_is_accepting_jobs: | |||
| 719 | * @printer: a #CtkPrinter | |||
| 720 | * | |||
| 721 | * Returns whether the printer is accepting jobs | |||
| 722 | * | |||
| 723 | * Returns: %TRUE if @printer is accepting jobs | |||
| 724 | * | |||
| 725 | * Since: 2.14 | |||
| 726 | */ | |||
| 727 | gboolean | |||
| 728 | ctk_printer_is_accepting_jobs (CtkPrinter *printer) | |||
| 729 | { | |||
| 730 | g_return_val_if_fail (CTK_IS_PRINTER (printer), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((!(0))); } } while ( 0); | |||
| 731 | ||||
| 732 | return printer->priv->is_accepting_jobs; | |||
| 733 | } | |||
| 734 | ||||
| 735 | gboolean | |||
| 736 | ctk_printer_set_is_accepting_jobs (CtkPrinter *printer, | |||
| 737 | gboolean val) | |||
| 738 | { | |||
| 739 | CtkPrinterPrivate *priv; | |||
| 740 | ||||
| 741 | g_return_val_if_fail (CTK_IS_PRINTER (printer), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((0)); } } while (0); | |||
| 742 | ||||
| 743 | priv = printer->priv; | |||
| 744 | ||||
| 745 | if (val == priv->is_accepting_jobs) | |||
| 746 | return FALSE(0); | |||
| 747 | ||||
| 748 | priv->is_accepting_jobs = val; | |||
| 749 | ||||
| 750 | return TRUE(!(0)); | |||
| 751 | } | |||
| 752 | ||||
| 753 | /** | |||
| 754 | * ctk_printer_is_virtual: | |||
| 755 | * @printer: a #CtkPrinter | |||
| 756 | * | |||
| 757 | * Returns whether the printer is virtual (i.e. does not | |||
| 758 | * represent actual printer hardware, but something like | |||
| 759 | * a CUPS class). | |||
| 760 | * | |||
| 761 | * Returns: %TRUE if @printer is virtual | |||
| 762 | * | |||
| 763 | * Since: 2.10 | |||
| 764 | */ | |||
| 765 | gboolean | |||
| 766 | ctk_printer_is_virtual (CtkPrinter *printer) | |||
| 767 | { | |||
| 768 | g_return_val_if_fail (CTK_IS_PRINTER (printer), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((!(0))); } } while ( 0); | |||
| 769 | ||||
| 770 | return printer->priv->is_virtual; | |||
| 771 | } | |||
| 772 | ||||
| 773 | /** | |||
| 774 | * ctk_printer_accepts_pdf: | |||
| 775 | * @printer: a #CtkPrinter | |||
| 776 | * | |||
| 777 | * Returns whether the printer accepts input in | |||
| 778 | * PDF format. | |||
| 779 | * | |||
| 780 | * Returns: %TRUE if @printer accepts PDF | |||
| 781 | * | |||
| 782 | * Since: 2.10 | |||
| 783 | */ | |||
| 784 | gboolean | |||
| 785 | ctk_printer_accepts_pdf (CtkPrinter *printer) | |||
| 786 | { | |||
| 787 | g_return_val_if_fail (CTK_IS_PRINTER (printer), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((!(0))); } } while ( 0); | |||
| 788 | ||||
| 789 | return printer->priv->accepts_pdf; | |||
| 790 | } | |||
| 791 | ||||
| 792 | void | |||
| 793 | ctk_printer_set_accepts_pdf (CtkPrinter *printer, | |||
| 794 | gboolean val) | |||
| 795 | { | |||
| 796 | g_return_if_fail (CTK_IS_PRINTER (printer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return; } } while (0); | |||
| 797 | ||||
| 798 | printer->priv->accepts_pdf = val; | |||
| 799 | } | |||
| 800 | ||||
| 801 | /** | |||
| 802 | * ctk_printer_accepts_ps: | |||
| 803 | * @printer: a #CtkPrinter | |||
| 804 | * | |||
| 805 | * Returns whether the printer accepts input in | |||
| 806 | * PostScript format. | |||
| 807 | * | |||
| 808 | * Returns: %TRUE if @printer accepts PostScript | |||
| 809 | * | |||
| 810 | * Since: 2.10 | |||
| 811 | */ | |||
| 812 | gboolean | |||
| 813 | ctk_printer_accepts_ps (CtkPrinter *printer) | |||
| 814 | { | |||
| 815 | g_return_val_if_fail (CTK_IS_PRINTER (printer), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((!(0))); } } while ( 0); | |||
| 816 | ||||
| 817 | return printer->priv->accepts_ps; | |||
| 818 | } | |||
| 819 | ||||
| 820 | void | |||
| 821 | ctk_printer_set_accepts_ps (CtkPrinter *printer, | |||
| 822 | gboolean val) | |||
| 823 | { | |||
| 824 | g_return_if_fail (CTK_IS_PRINTER (printer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return; } } while (0); | |||
| 825 | ||||
| 826 | printer->priv->accepts_ps = val; | |||
| 827 | } | |||
| 828 | ||||
| 829 | gboolean | |||
| 830 | ctk_printer_is_new (CtkPrinter *printer) | |||
| 831 | { | |||
| 832 | g_return_val_if_fail (CTK_IS_PRINTER (printer), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((0)); } } while (0); | |||
| 833 | ||||
| 834 | return printer->priv->is_new; | |||
| 835 | } | |||
| 836 | ||||
| 837 | void | |||
| 838 | ctk_printer_set_is_new (CtkPrinter *printer, | |||
| 839 | gboolean val) | |||
| 840 | { | |||
| 841 | g_return_if_fail (CTK_IS_PRINTER (printer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return; } } while (0); | |||
| 842 | ||||
| 843 | printer->priv->is_new = val; | |||
| 844 | } | |||
| 845 | ||||
| 846 | ||||
| 847 | /** | |||
| 848 | * ctk_printer_is_default: | |||
| 849 | * @printer: a #CtkPrinter | |||
| 850 | * | |||
| 851 | * Returns whether the printer is the default printer. | |||
| 852 | * | |||
| 853 | * Returns: %TRUE if @printer is the default | |||
| 854 | * | |||
| 855 | * Since: 2.10 | |||
| 856 | */ | |||
| 857 | gboolean | |||
| 858 | ctk_printer_is_default (CtkPrinter *printer) | |||
| 859 | { | |||
| 860 | g_return_val_if_fail (CTK_IS_PRINTER (printer), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return ((0)); } } while (0); | |||
| 861 | ||||
| 862 | return printer->priv->is_default; | |||
| 863 | } | |||
| 864 | ||||
| 865 | void | |||
| 866 | ctk_printer_set_is_default (CtkPrinter *printer, | |||
| 867 | gboolean val) | |||
| 868 | { | |||
| 869 | g_return_if_fail (CTK_IS_PRINTER (printer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return; } } while (0); | |||
| 870 | ||||
| 871 | printer->priv->is_default = val; | |||
| 872 | } | |||
| 873 | ||||
| 874 | /** | |||
| 875 | * ctk_printer_request_details: | |||
| 876 | * @printer: a #CtkPrinter | |||
| 877 | * | |||
| 878 | * Requests the printer details. When the details are available, | |||
| 879 | * the #CtkPrinter::details-acquired signal will be emitted on @printer. | |||
| 880 | * | |||
| 881 | * Since: 2.12 | |||
| 882 | */ | |||
| 883 | void | |||
| 884 | ctk_printer_request_details (CtkPrinter *printer) | |||
| 885 | { | |||
| 886 | CtkPrintBackendClass *backend_class; | |||
| 887 | ||||
| 888 | g_return_if_fail (CTK_IS_PRINTER (printer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return; } } while (0); | |||
| 889 | ||||
| 890 | backend_class = CTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend)((((CtkPrintBackendClass*) (((GTypeInstance*) ((printer->priv ->backend)))->g_class)))); | |||
| 891 | backend_class->printer_request_details (printer); | |||
| 892 | } | |||
| 893 | ||||
| 894 | CtkPrinterOptionSet * | |||
| 895 | _ctk_printer_get_options (CtkPrinter *printer, | |||
| 896 | CtkPrintSettings *settings, | |||
| 897 | CtkPageSetup *page_setup, | |||
| 898 | CtkPrintCapabilities capabilities) | |||
| 899 | { | |||
| 900 | CtkPrintBackendClass *backend_class = CTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend)((((CtkPrintBackendClass*) (((GTypeInstance*) ((printer->priv ->backend)))->g_class)))); | |||
| 901 | return backend_class->printer_get_options (printer, settings, page_setup, capabilities); | |||
| 902 | } | |||
| 903 | ||||
| 904 | gboolean | |||
| 905 | _ctk_printer_mark_conflicts (CtkPrinter *printer, | |||
| 906 | CtkPrinterOptionSet *options) | |||
| 907 | { | |||
| 908 | CtkPrintBackendClass *backend_class = CTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend)((((CtkPrintBackendClass*) (((GTypeInstance*) ((printer->priv ->backend)))->g_class)))); | |||
| 909 | return backend_class->printer_mark_conflicts (printer, options); | |||
| 910 | } | |||
| 911 | ||||
| 912 | void | |||
| 913 | _ctk_printer_get_settings_from_options (CtkPrinter *printer, | |||
| 914 | CtkPrinterOptionSet *options, | |||
| 915 | CtkPrintSettings *settings) | |||
| 916 | { | |||
| 917 | CtkPrintBackendClass *backend_class = CTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend)((((CtkPrintBackendClass*) (((GTypeInstance*) ((printer->priv ->backend)))->g_class)))); | |||
| 918 | backend_class->printer_get_settings_from_options (printer, options, settings); | |||
| 919 | } | |||
| 920 | ||||
| 921 | void | |||
| 922 | _ctk_printer_prepare_for_print (CtkPrinter *printer, | |||
| 923 | CtkPrintJob *print_job, | |||
| 924 | CtkPrintSettings *settings, | |||
| 925 | CtkPageSetup *page_setup) | |||
| 926 | { | |||
| 927 | CtkPrintBackendClass *backend_class = CTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend)((((CtkPrintBackendClass*) (((GTypeInstance*) ((printer->priv ->backend)))->g_class)))); | |||
| 928 | backend_class->printer_prepare_for_print (printer, print_job, settings, page_setup); | |||
| 929 | } | |||
| 930 | ||||
| 931 | cairo_surface_t * | |||
| 932 | _ctk_printer_create_cairo_surface (CtkPrinter *printer, | |||
| 933 | CtkPrintSettings *settings, | |||
| 934 | gdouble width, | |||
| 935 | gdouble height, | |||
| 936 | GIOChannel *cache_io) | |||
| 937 | { | |||
| 938 | CtkPrintBackendClass *backend_class = CTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend)((((CtkPrintBackendClass*) (((GTypeInstance*) ((printer->priv ->backend)))->g_class)))); | |||
| 939 | ||||
| 940 | return backend_class->printer_create_cairo_surface (printer, settings, | |||
| 941 | width, height, cache_io); | |||
| 942 | } | |||
| 943 | ||||
| 944 | gboolean | |||
| 945 | _ctk_printer_get_hard_margins_for_paper_size (CtkPrinter *printer, | |||
| 946 | CtkPaperSize *paper_size, | |||
| 947 | gdouble *top, | |||
| 948 | gdouble *bottom, | |||
| 949 | gdouble *left, | |||
| 950 | gdouble *right) | |||
| 951 | { | |||
| 952 | CtkPrintBackendClass *backend_class = CTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend)((((CtkPrintBackendClass*) (((GTypeInstance*) ((printer->priv ->backend)))->g_class)))); | |||
| 953 | ||||
| 954 | return backend_class->printer_get_hard_margins_for_paper_size (printer, paper_size, top, bottom, left, right); | |||
| 955 | } | |||
| 956 | ||||
| 957 | /** | |||
| 958 | * ctk_printer_list_papers: | |||
| 959 | * @printer: a #CtkPrinter | |||
| 960 | * | |||
| 961 | * Lists all the paper sizes @printer supports. | |||
| 962 | * This will return and empty list unless the printer’s details are | |||
| 963 | * available, see ctk_printer_has_details() and ctk_printer_request_details(). | |||
| 964 | * | |||
| 965 | * Returns: (element-type CtkPageSetup) (transfer full): a newly allocated list of newly allocated #CtkPageSetup s. | |||
| 966 | * | |||
| 967 | * Since: 2.12 | |||
| 968 | */ | |||
| 969 | GList * | |||
| 970 | ctk_printer_list_papers (CtkPrinter *printer) | |||
| 971 | { | |||
| 972 | CtkPrintBackendClass *backend_class; | |||
| 973 | ||||
| 974 | g_return_val_if_fail (CTK_IS_PRINTER (printer), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return (((void*)0)); } } while (0); | |||
| 975 | ||||
| 976 | backend_class = CTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend)((((CtkPrintBackendClass*) (((GTypeInstance*) ((printer->priv ->backend)))->g_class)))); | |||
| 977 | return backend_class->printer_list_papers (printer); | |||
| 978 | } | |||
| 979 | ||||
| 980 | /** | |||
| 981 | * ctk_printer_get_default_page_size: | |||
| 982 | * @printer: a #CtkPrinter | |||
| 983 | * | |||
| 984 | * Returns default page size of @printer. | |||
| 985 | * | |||
| 986 | * Returns: a newly allocated #CtkPageSetup with default page size of the printer. | |||
| 987 | * | |||
| 988 | * Since: 2.14 | |||
| 989 | */ | |||
| 990 | CtkPageSetup * | |||
| 991 | ctk_printer_get_default_page_size (CtkPrinter *printer) | |||
| 992 | { | |||
| 993 | CtkPrintBackendClass *backend_class; | |||
| 994 | ||||
| 995 | g_return_val_if_fail (CTK_IS_PRINTER (printer), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return (((void*)0)); } } while (0); | |||
| 996 | ||||
| 997 | backend_class = CTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend)((((CtkPrintBackendClass*) (((GTypeInstance*) ((printer->priv ->backend)))->g_class)))); | |||
| 998 | return backend_class->printer_get_default_page_size (printer); | |||
| 999 | } | |||
| 1000 | ||||
| 1001 | /** | |||
| 1002 | * ctk_printer_get_hard_margins: | |||
| 1003 | * @printer: a #CtkPrinter | |||
| 1004 | * @top: (out): a location to store the top margin in | |||
| 1005 | * @bottom: (out): a location to store the bottom margin in | |||
| 1006 | * @left: (out): a location to store the left margin in | |||
| 1007 | * @right: (out): a location to store the right margin in | |||
| 1008 | * | |||
| 1009 | * Retrieve the hard margins of @printer, i.e. the margins that define | |||
| 1010 | * the area at the borders of the paper that the printer cannot print to. | |||
| 1011 | * | |||
| 1012 | * Note: This will not succeed unless the printer’s details are available, | |||
| 1013 | * see ctk_printer_has_details() and ctk_printer_request_details(). | |||
| 1014 | * | |||
| 1015 | * Returns: %TRUE iff the hard margins were retrieved | |||
| 1016 | * | |||
| 1017 | * Since: 2.20 | |||
| 1018 | */ | |||
| 1019 | gboolean | |||
| 1020 | ctk_printer_get_hard_margins (CtkPrinter *printer, | |||
| 1021 | gdouble *top, | |||
| 1022 | gdouble *bottom, | |||
| 1023 | gdouble *left, | |||
| 1024 | gdouble *right) | |||
| 1025 | { | |||
| 1026 | CtkPrintBackendClass *backend_class = CTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend)((((CtkPrintBackendClass*) (((GTypeInstance*) ((printer->priv ->backend)))->g_class)))); | |||
| 1027 | ||||
| 1028 | return backend_class->printer_get_hard_margins (printer, top, bottom, left, right); | |||
| 1029 | } | |||
| 1030 | ||||
| 1031 | /** | |||
| 1032 | * ctk_printer_get_capabilities: | |||
| 1033 | * @printer: a #CtkPrinter | |||
| 1034 | * | |||
| 1035 | * Returns the printer’s capabilities. | |||
| 1036 | * | |||
| 1037 | * This is useful when you’re using #CtkPrintUnixDialog’s manual-capabilities | |||
| 1038 | * setting and need to know which settings the printer can handle and which | |||
| 1039 | * you must handle yourself. | |||
| 1040 | * | |||
| 1041 | * This will return 0 unless the printer’s details are available, see | |||
| 1042 | * ctk_printer_has_details() and ctk_printer_request_details(). | |||
| 1043 | * | |||
| 1044 | * Returns: the printer’s capabilities | |||
| 1045 | * | |||
| 1046 | * Since: 2.12 | |||
| 1047 | */ | |||
| 1048 | CtkPrintCapabilities | |||
| 1049 | ctk_printer_get_capabilities (CtkPrinter *printer) | |||
| 1050 | { | |||
| 1051 | CtkPrintBackendClass *backend_class; | |||
| 1052 | ||||
| 1053 | g_return_val_if_fail (CTK_IS_PRINTER (printer), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((printer)); GType __t = ((ctk_printer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_PRINTER (printer)"); return (0); } } while (0); | |||
| 1054 | ||||
| 1055 | backend_class = CTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend)((((CtkPrintBackendClass*) (((GTypeInstance*) ((printer->priv ->backend)))->g_class)))); | |||
| 1056 | return backend_class->printer_get_capabilities (printer); | |||
| 1057 | } | |||
| 1058 | ||||
| 1059 | /** | |||
| 1060 | * ctk_printer_compare: | |||
| 1061 | * @a: a #CtkPrinter | |||
| 1062 | * @b: another #CtkPrinter | |||
| 1063 | * | |||
| 1064 | * Compares two printers. | |||
| 1065 | * | |||
| 1066 | * Returns: 0 if the printer match, a negative value if @a < @b, | |||
| 1067 | * or a positive value if @a > @b | |||
| 1068 | * | |||
| 1069 | * Since: 2.10 | |||
| 1070 | */ | |||
| 1071 | gint | |||
| 1072 | ctk_printer_compare (CtkPrinter *a, | |||
| 1073 | CtkPrinter *b) | |||
| 1074 | { | |||
| 1075 | const char *name_a, *name_b; | |||
| 1076 | ||||
| 1077 | g_assert (CTK_IS_PRINTER (a) && CTK_IS_PRINTER (b))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((a)); GType __t = ((ctk_printer_get_type ())); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))) && (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((b)); GType __t = ((ctk_printer_get_type ())); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr ("Ctk", "ctkprinter.c", 1077, ((const char*) (__func__)), "CTK_IS_PRINTER (a) && CTK_IS_PRINTER (b)" ); } while (0); | |||
| 1078 | ||||
| 1079 | name_a = ctk_printer_get_name (a); | |||
| 1080 | name_b = ctk_printer_get_name (b); | |||
| 1081 | if (name_a == NULL((void*)0) && name_b == NULL((void*)0)) | |||
| 1082 | return 0; | |||
| 1083 | else if (name_a == NULL((void*)0)) | |||
| 1084 | return G_MAXINT2147483647; | |||
| 1085 | else if (name_b == NULL((void*)0)) | |||
| 1086 | return G_MININT(-2147483647 -1); | |||
| 1087 | else | |||
| 1088 | return g_ascii_strcasecmp (name_a, name_b); | |||
| 1089 | } | |||
| 1090 | ||||
| 1091 | ||||
| 1092 | typedef struct | |||
| 1093 | { | |||
| 1094 | GList *backends; | |||
| 1095 | CtkPrinterFunc func; | |||
| 1096 | gpointer data; | |||
| 1097 | GDestroyNotify destroy; | |||
| 1098 | GMainLoop *loop; | |||
| 1099 | } PrinterList; | |||
| 1100 | ||||
| 1101 | static void list_done_cb (CtkPrintBackend *backend, | |||
| 1102 | PrinterList *printer_list); | |||
| 1103 | ||||
| 1104 | static void | |||
| 1105 | stop_enumeration (PrinterList *printer_list) | |||
| 1106 | { | |||
| 1107 | GList *list, *next; | |||
| 1108 | ||||
| 1109 | for (list = printer_list->backends; list; list = next) | |||
| 1110 | { | |||
| 1111 | CtkPrintBackend *backend; | |||
| 1112 | ||||
| 1113 | next = list->next; | |||
| 1114 | backend = CTK_PRINT_BACKEND (list->data)((((CtkPrintBackend*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list->data)), ((ctk_print_backend_get_type ())))))); | |||
| 1115 | list_done_cb (backend, printer_list); | |||
| 1116 | } | |||
| 1117 | } | |||
| 1118 | ||||
| 1119 | static void | |||
| 1120 | free_printer_list (PrinterList *printer_list) | |||
| 1121 | { | |||
| 1122 | if (printer_list->destroy) | |||
| 1123 | printer_list->destroy (printer_list->data); | |||
| 1124 | ||||
| 1125 | if (printer_list->loop) | |||
| 1126 | { | |||
| 1127 | g_main_loop_quit (printer_list->loop); | |||
| 1128 | g_main_loop_unref (printer_list->loop); | |||
| 1129 | } | |||
| 1130 | ||||
| 1131 | g_free (printer_list); | |||
| 1132 | } | |||
| 1133 | ||||
| 1134 | static gboolean | |||
| 1135 | list_added_cb (CtkPrintBackend *backend G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 1136 | CtkPrinter *printer, | |||
| 1137 | PrinterList *printer_list) | |||
| 1138 | { | |||
| 1139 | if (printer_list->func (printer, printer_list->data)) | |||
| 1140 | { | |||
| 1141 | stop_enumeration (printer_list); | |||
| 1142 | return TRUE(!(0)); | |||
| 1143 | } | |||
| 1144 | ||||
| 1145 | return FALSE(0); | |||
| 1146 | } | |||
| 1147 | ||||
| 1148 | static void | |||
| 1149 | backend_status_changed (GObject *object, | |||
| 1150 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
| 1151 | gpointer data) | |||
| 1152 | { | |||
| 1153 | CtkPrintBackend *backend = CTK_PRINT_BACKEND (object)((((CtkPrintBackend*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_print_backend_get_type ())))))); | |||
| 1154 | PrinterList *printer_list = data; | |||
| 1155 | CtkPrintBackendStatus status; | |||
| 1156 | ||||
| 1157 | g_object_get (backend, "status", &status, NULL((void*)0)); | |||
| 1158 | ||||
| 1159 | if (status == CTK_PRINT_BACKEND_STATUS_UNAVAILABLE) | |||
| 1160 | list_done_cb (backend, printer_list); | |||
| 1161 | } | |||
| 1162 | ||||
| 1163 | static gboolean | |||
| 1164 | list_printers_remove_backend (PrinterList *printer_list, | |||
| 1165 | CtkPrintBackend *backend) | |||
| 1166 | { | |||
| 1167 | printer_list->backends = g_list_remove (printer_list->backends, backend); | |||
| 1168 | ctk_print_backend_destroy (backend); | |||
| 1169 | g_object_unref (backend); | |||
| 1170 | ||||
| 1171 | if (printer_list->backends == NULL((void*)0)) | |||
| 1172 | { | |||
| 1173 | free_printer_list (printer_list); | |||
| 1174 | return TRUE(!(0)); | |||
| 1175 | } | |||
| 1176 | ||||
| 1177 | return FALSE(0); | |||
| 1178 | } | |||
| 1179 | ||||
| 1180 | static void | |||
| 1181 | list_done_cb (CtkPrintBackend *backend, | |||
| 1182 | PrinterList *printer_list) | |||
| 1183 | { | |||
| 1184 | g_signal_handlers_disconnect_by_func (backend, list_added_cb, printer_list)g_signal_handlers_disconnect_matched ((backend), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (list_added_cb), (printer_list)); | |||
| 1185 | g_signal_handlers_disconnect_by_func (backend, list_done_cb, printer_list)g_signal_handlers_disconnect_matched ((backend), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (list_done_cb), (printer_list)); | |||
| 1186 | g_signal_handlers_disconnect_by_func (backend, backend_status_changed, printer_list)g_signal_handlers_disconnect_matched ((backend), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (backend_status_changed), (printer_list)); | |||
| 1187 | ||||
| 1188 | list_printers_remove_backend(printer_list, backend); | |||
| 1189 | } | |||
| 1190 | ||||
| 1191 | static gboolean | |||
| 1192 | list_printers_init (PrinterList *printer_list, | |||
| 1193 | CtkPrintBackend *backend) | |||
| 1194 | { | |||
| 1195 | GList *list, *node; | |||
| 1196 | CtkPrintBackendStatus status; | |||
| 1197 | ||||
| 1198 | list = ctk_print_backend_get_printer_list (backend); | |||
| 1199 | ||||
| 1200 | for (node = list; node != NULL((void*)0); node = node->next) | |||
| 1201 | { | |||
| 1202 | if (list_added_cb (backend, node->data, printer_list)) | |||
| 1203 | { | |||
| 1204 | g_list_free (list); | |||
| 1205 | return TRUE(!(0)); | |||
| 1206 | } | |||
| 1207 | } | |||
| 1208 | ||||
| 1209 | g_list_free (list); | |||
| 1210 | ||||
| 1211 | g_object_get (backend, "status", &status, NULL((void*)0)); | |||
| 1212 | ||||
| 1213 | if (status == CTK_PRINT_BACKEND_STATUS_UNAVAILABLE || | |||
| 1214 | ctk_print_backend_printer_list_is_done (backend)) | |||
| 1215 | { | |||
| 1216 | if (list_printers_remove_backend (printer_list, backend)) | |||
| 1217 | return TRUE(!(0)); | |||
| 1218 | } | |||
| 1219 | else | |||
| 1220 | { | |||
| 1221 | g_signal_connect (backend, "printer-added",g_signal_connect_data ((backend), ("printer-added"), ((GCallback ) list_added_cb), (printer_list), ((void*)0), (GConnectFlags) 0) | |||
| 1222 | (GCallback) list_added_cb,g_signal_connect_data ((backend), ("printer-added"), ((GCallback ) list_added_cb), (printer_list), ((void*)0), (GConnectFlags) 0) | |||
| 1223 | printer_list)g_signal_connect_data ((backend), ("printer-added"), ((GCallback ) list_added_cb), (printer_list), ((void*)0), (GConnectFlags) 0); | |||
| 1224 | g_signal_connect (backend, "printer-list-done",g_signal_connect_data ((backend), ("printer-list-done"), ((GCallback ) list_done_cb), (printer_list), ((void*)0), (GConnectFlags) 0 ) | |||
| 1225 | (GCallback) list_done_cb,g_signal_connect_data ((backend), ("printer-list-done"), ((GCallback ) list_done_cb), (printer_list), ((void*)0), (GConnectFlags) 0 ) | |||
| 1226 | printer_list)g_signal_connect_data ((backend), ("printer-list-done"), ((GCallback ) list_done_cb), (printer_list), ((void*)0), (GConnectFlags) 0 ); | |||
| 1227 | g_signal_connect (backend, "notify::status",g_signal_connect_data ((backend), ("notify::status"), ((GCallback ) backend_status_changed), (printer_list), ((void*)0), (GConnectFlags ) 0) | |||
| 1228 | (GCallback) backend_status_changed,g_signal_connect_data ((backend), ("notify::status"), ((GCallback ) backend_status_changed), (printer_list), ((void*)0), (GConnectFlags ) 0) | |||
| 1229 | printer_list)g_signal_connect_data ((backend), ("notify::status"), ((GCallback ) backend_status_changed), (printer_list), ((void*)0), (GConnectFlags ) 0); | |||
| 1230 | } | |||
| 1231 | ||||
| 1232 | return FALSE(0); | |||
| 1233 | } | |||
| 1234 | ||||
| 1235 | /** | |||
| 1236 | * ctk_enumerate_printers: | |||
| 1237 | * @func: a function to call for each printer | |||
| 1238 | * @data: user data to pass to @func | |||
| 1239 | * @destroy: function to call if @data is no longer needed | |||
| 1240 | * @wait: if %TRUE, wait in a recursive mainloop until | |||
| 1241 | * all printers are enumerated; otherwise return early | |||
| 1242 | * | |||
| 1243 | * Calls a function for all #CtkPrinters. | |||
| 1244 | * If @func returns %TRUE, the enumeration is stopped. | |||
| 1245 | * | |||
| 1246 | * Since: 2.10 | |||
| 1247 | */ | |||
| 1248 | void | |||
| 1249 | ctk_enumerate_printers (CtkPrinterFunc func, | |||
| 1250 | gpointer data, | |||
| 1251 | GDestroyNotify destroy, | |||
| 1252 | gboolean wait) | |||
| 1253 | { | |||
| 1254 | PrinterList *printer_list; | |||
| 1255 | GList *node, *next; | |||
| 1256 | ||||
| 1257 | printer_list = g_new0 (PrinterList, 1)((PrinterList *) g_malloc0_n ((1), sizeof (PrinterList))); | |||
| ||||
| 1258 | ||||
| 1259 | printer_list->func = func; | |||
| 1260 | printer_list->data = data; | |||
| 1261 | printer_list->destroy = destroy; | |||
| 1262 | ||||
| 1263 | if (g_module_supported ()) | |||
| 1264 | printer_list->backends = ctk_print_backend_load_modules (); | |||
| 1265 | ||||
| 1266 | if (printer_list->backends == NULL((void*)0)) | |||
| 1267 | { | |||
| 1268 | free_printer_list (printer_list); | |||
| 1269 | return; | |||
| 1270 | } | |||
| 1271 | ||||
| 1272 | for (node = printer_list->backends; node
| |||
| 1273 | { | |||
| 1274 | CtkPrintBackend *backend; | |||
| 1275 | ||||
| 1276 | next = node->next; | |||
| 1277 | backend = CTK_PRINT_BACKEND (node->data)((((CtkPrintBackend*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((node->data)), ((ctk_print_backend_get_type ())))))); | |||
| 1278 | if (list_printers_init (printer_list, backend)) | |||
| 1279 | return; | |||
| 1280 | } | |||
| 1281 | ||||
| 1282 | if (wait && printer_list->backends) | |||
| 1283 | { | |||
| 1284 | printer_list->loop = g_main_loop_new (NULL((void*)0), FALSE(0)); | |||
| 1285 | ||||
| 1286 | cdk_threads_leave (); | |||
| 1287 | g_main_loop_run (printer_list->loop); | |||
| 1288 | cdk_threads_enter (); | |||
| 1289 | } | |||
| 1290 | } | |||
| ||||
| 1291 | ||||
| 1292 | GType | |||
| 1293 | ctk_print_capabilities_get_type (void) | |||
| 1294 | { | |||
| 1295 | static GType etype = 0; | |||
| 1296 | ||||
| 1297 | if (G_UNLIKELY (etype == 0)(etype == 0)) | |||
| 1298 | { | |||
| 1299 | static const GFlagsValue values[] = { | |||
| 1300 | { CTK_PRINT_CAPABILITY_PAGE_SET, "CTK_PRINT_CAPABILITY_PAGE_SET", "page-set" }, | |||
| 1301 | { CTK_PRINT_CAPABILITY_COPIES, "CTK_PRINT_CAPABILITY_COPIES", "copies" }, | |||
| 1302 | { CTK_PRINT_CAPABILITY_COLLATE, "CTK_PRINT_CAPABILITY_COLLATE", "collate" }, | |||
| 1303 | { CTK_PRINT_CAPABILITY_REVERSE, "CTK_PRINT_CAPABILITY_REVERSE", "reverse" }, | |||
| 1304 | { CTK_PRINT_CAPABILITY_SCALE, "CTK_PRINT_CAPABILITY_SCALE", "scale" }, | |||
| 1305 | { CTK_PRINT_CAPABILITY_GENERATE_PDF, "CTK_PRINT_CAPABILITY_GENERATE_PDF", "generate-pdf" }, | |||
| 1306 | { CTK_PRINT_CAPABILITY_GENERATE_PS, "CTK_PRINT_CAPABILITY_GENERATE_PS", "generate-ps" }, | |||
| 1307 | { CTK_PRINT_CAPABILITY_PREVIEW, "CTK_PRINT_CAPABILITY_PREVIEW", "preview" }, | |||
| 1308 | { CTK_PRINT_CAPABILITY_NUMBER_UP, "CTK_PRINT_CAPABILITY_NUMBER_UP", "number-up"}, | |||
| 1309 | { CTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT, "CTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT", "number-up-layout" }, | |||
| 1310 | { 0, NULL((void*)0), NULL((void*)0) } | |||
| 1311 | }; | |||
| 1312 | ||||
| 1313 | etype = g_flags_register_static (I_("CtkPrintCapabilities")g_intern_static_string ("CtkPrintCapabilities"), values); | |||
| 1314 | } | |||
| 1315 | ||||
| 1316 | return etype; | |||
| 1317 | } |