| 1 | /* GTK - The GIMP Toolkit |
| 2 | * gtkprinteroption.c: Handling possible settings for a specific printer setting |
| 3 | * Copyright (C) 2006, Red Hat, Inc. |
| 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, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "config.h"cxx . . $ `<file>/build/config.h`/ |
| 20 | #include <string.h> |
| 21 | |
| 22 | #include "gtkprinteroptionprivate.h"cxx . . $ `<file>/gtk/print/gtkprinteroptionprivate.h`/ |
| 23 | |
| 24 | /***************************************** |
| 25 | * GtkPrinterOption * |
| 26 | *****************************************/ |
| 27 | |
| 28 | enumcxx . . $ $anonymous_type_4f29034dfa140f84_0# { |
| 29 | CHANGEDcxx . . $ CHANGED., |
| 30 | LAST_SIGNALcxx . . $ LAST_SIGNAL. |
| 31 | }; |
| 32 | |
| 33 | enumcxx . . $ $anonymous_type_4f29034dfa140f84_1# { |
| 34 | PROP_0cxx . . $ PROP_0., |
| 35 | PROP_VALUEcxx . . $ PROP_VALUE. |
| 36 | }; |
| 37 | |
| 38 | static guintcxx . . $ guint# signalscxx . . $ signals.[LAST_SIGNALcxx . . $ LAST_SIGNAL.] = { 0 }; |
| 39 | |
| 40 | static void gtk_printer_option_set_propertycxx . . $ gtk_printer_option_set_property(d7c4bb29f36c0dc4). (GObjectcxx . . $ GObject# *object, |
| 41 | guintcxx . . $ guint# prop_id, |
| 42 | const GValuecxx . . $ GValue# *value, |
| 43 | GParamSpeccxx . . $ GParamSpec# *pspec); |
| 44 | static void gtk_printer_option_get_propertycxx . . $ gtk_printer_option_get_property(cee2c52f22407c66). (GObjectcxx . . $ GObject# *object, |
| 45 | guintcxx . . $ guint# prop_id, |
| 46 | GValuecxx . . $ GValue# *value, |
| 47 | GParamSpeccxx . . $ GParamSpec# *pspec); |
| 48 | |
| 49 | G_DEFINE_TYPEcxx . . $ `<external>/9567554376676449156/gtype.h:1834:9`! (GtkPrinterOption, gtk_printer_option, G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!) |
| 50 | |
| 51 | static void |
| 52 | gtk_printer_option_finalizecxx . . $ gtk_printer_option_finalize(6087475fa43034d3). (GObjectcxx . . $ GObject# *object) |
| 53 | { |
| 54 | GtkPrinterOptioncxx . . $ GtkPrinterOption# *option = GTK_PRINTER_OPTIONcxx . . $ `gtk/print/gtkprinteroptionprivate.h:35:9`! (object); |
| 55 | int i; |
| 56 | |
| 57 | g_freecxx . . $ g_free(5d22bdacc48458e8). (option->namecxx . . $ _GtkPrinterOption#name.); |
| 58 | g_freecxx . . $ g_free(5d22bdacc48458e8). (option->display_textcxx . . $ _GtkPrinterOption#display_text.); |
| 59 | g_freecxx . . $ g_free(5d22bdacc48458e8). (option->valuecxx . . $ _GtkPrinterOption#value.); |
| 60 | for (i = 0; i < option->num_choicescxx . . $ _GtkPrinterOption#num_choices.; i++) |
| 61 | { |
| 62 | g_freecxx . . $ g_free(5d22bdacc48458e8). (option->choicescxx . . $ _GtkPrinterOption#choices.[i]); |
| 63 | g_freecxx . . $ g_free(5d22bdacc48458e8). (option->choices_displaycxx . . $ _GtkPrinterOption#choices_display.[i]); |
| 64 | } |
| 65 | g_freecxx . . $ g_free(5d22bdacc48458e8). (option->choicescxx . . $ _GtkPrinterOption#choices.); |
| 66 | g_freecxx . . $ g_free(5d22bdacc48458e8). (option->choices_displaycxx . . $ _GtkPrinterOption#choices_display.); |
| 67 | g_freecxx . . $ g_free(5d22bdacc48458e8). (option->groupcxx . . $ _GtkPrinterOption#group.); |
| 68 | |
| 69 | G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (gtk_printer_option_parent_class)->finalizecxx . . $ _GObjectClass#finalize. (object); |
| 70 | } |
| 71 | |
| 72 | static void |
| 73 | gtk_printer_option_initcxx . . $ gtk_printer_option_init(edefb8f20fe88fd9). (GtkPrinterOptioncxx . . $ GtkPrinterOption# *option) |
| 74 | { |
| 75 | option->valuecxx . . $ _GtkPrinterOption#value. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (""); |
| 76 | option->activates_defaultcxx . . $ _GtkPrinterOption#activates_default. = FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 77 | } |
| 78 | |
| 79 | static void |
| 80 | gtk_printer_option_class_initcxx . . $ gtk_printer_option_class_init(1411532969a7dda2). (GtkPrinterOptionClasscxx . . $ GtkPrinterOptionClass# *class) |
| 81 | { |
| 82 | GObjectClasscxx . . $ GObjectClass# *gobject_class = (GObjectClasscxx . . $ GObjectClass# *)class; |
| 83 | |
| 84 | gobject_class->finalizecxx . . $ _GObjectClass#finalize. = gtk_printer_option_finalizecxx . . $ gtk_printer_option_finalize(6087475fa43034d3).; |
| 85 | gobject_class->set_propertycxx . . $ _GObjectClass#set_property. = gtk_printer_option_set_propertycxx . . $ gtk_printer_option_set_property(d7c4bb29f36c0dc4).; |
| 86 | gobject_class->get_propertycxx . . $ _GObjectClass#get_property. = gtk_printer_option_get_propertycxx . . $ gtk_printer_option_get_property(cee2c52f22407c66).; |
| 87 | |
| 88 | signalscxx . . $ signals.[CHANGEDcxx . . $ CHANGED.] = |
| 89 | g_signal_newcxx . . $ g_signal_new(b0aa5e8090fb95c0). ("changed", |
| 90 | G_TYPE_FROM_CLASScxx . . $ `<external>/9567554376676449156/gtype.h:657:9`! (class), |
| 91 | G_SIGNAL_RUN_LASTcxx . . $ G_SIGNAL_RUN_LAST., |
| 92 | G_STRUCT_OFFSETcxx . . $ `<external>/12741050725406041920/gmacros.h:1005:9`! (GtkPrinterOptionClass, changed), |
| 93 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 94 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 95 | G_TYPE_NONEcxx . . $ `<external>/9567554376676449156/gtype.h:72:9`!, 0); |
| 96 | |
| 97 | g_object_class_install_propertycxx . . $ g_object_class_install_property(9c80cb614dbe5a26). (G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (class), |
| 98 | PROP_VALUEcxx . . $ PROP_VALUE., |
| 99 | g_param_spec_stringcxx . . $ g_param_spec_string(378e8746be5cd899). ("value", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 100 | "", |
| 101 | G_PARAM_READWRITEcxx . . $ G_PARAM_READWRITE.)); |
| 102 | } |
| 103 | |
| 104 | GtkPrinterOptioncxx . . $ GtkPrinterOption# * |
| 105 | gtk_printer_option_newcxx . . $ gtk_printer_option_new(b7efae70e5d40141). (const char *name, const char *display_text, |
| 106 | GtkPrinterOptionTypecxx . . $ GtkPrinterOptionType# type) |
| 107 | { |
| 108 | GtkPrinterOptioncxx . . $ GtkPrinterOption# *option; |
| 109 | |
| 110 | option = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (GTK_TYPE_PRINTER_OPTIONcxx . . $ `gtk/print/gtkprinteroptionprivate.h:34:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 111 | |
| 112 | option->namecxx . . $ _GtkPrinterOption#name. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (name); |
| 113 | option->display_textcxx . . $ _GtkPrinterOption#display_text. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (display_text); |
| 114 | option->typecxx . . $ _GtkPrinterOption#type. = type; |
| 115 | |
| 116 | return option; |
| 117 | } |
| 118 | |
| 119 | static void |
| 120 | gtk_printer_option_set_propertycxx . . $ gtk_printer_option_set_property(d7c4bb29f36c0dc4). (GObjectcxx . . $ GObject# *object, |
| 121 | guintcxx . . $ guint# prop_id, |
| 122 | const GValuecxx . . $ GValue# *value, |
| 123 | GParamSpeccxx . . $ GParamSpec# *pspec) |
| 124 | { |
| 125 | GtkPrinterOptioncxx . . $ GtkPrinterOption# *option = GTK_PRINTER_OPTIONcxx . . $ `gtk/print/gtkprinteroptionprivate.h:35:9`! (object); |
| 126 | |
| 127 | switch (prop_id) |
| 128 | { |
| 129 | case PROP_VALUEcxx . . $ PROP_VALUE.: |
| 130 | gtk_printer_option_setcxx . . $ gtk_printer_option_set(25f3c7ce40a8bef4). (option, g_value_get_stringcxx . . $ g_value_get_string(cc0a2be2b8f7bdc8). (value)); |
| 131 | break; |
| 132 | default: |
| 133 | G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (object, prop_id, pspec); |
| 134 | break; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | static void |
| 139 | gtk_printer_option_get_propertycxx . . $ gtk_printer_option_get_property(cee2c52f22407c66). (GObjectcxx . . $ GObject# *object, |
| 140 | guintcxx . . $ guint# prop_id, |
| 141 | GValuecxx . . $ GValue# *value, |
| 142 | GParamSpeccxx . . $ GParamSpec# *pspec) |
| 143 | { |
| 144 | GtkPrinterOptioncxx . . $ GtkPrinterOption# *option = GTK_PRINTER_OPTIONcxx . . $ `gtk/print/gtkprinteroptionprivate.h:35:9`! (object); |
| 145 | |
| 146 | switch (prop_id) |
| 147 | { |
| 148 | case PROP_VALUEcxx . . $ PROP_VALUE.: |
| 149 | g_value_set_stringcxx . . $ g_value_set_string(65b9ea7708b82b9b). (value, option->valuecxx . . $ _GtkPrinterOption#value.); |
| 150 | break; |
| 151 | default: |
| 152 | G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (object, prop_id, pspec); |
| 153 | break; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | static void |
| 158 | emit_changedcxx . . $ emit_changed(edefb8f20fe88fd9). (GtkPrinterOptioncxx . . $ GtkPrinterOption# *option) |
| 159 | { |
| 160 | g_signal_emitcxx . . $ g_signal_emit(cc3f7c2ba1c6a182). (option, signalscxx . . $ signals.[CHANGEDcxx . . $ CHANGED.], 0); |
| 161 | } |
| 162 | |
| 163 | void |
| 164 | gtk_printer_option_setcxx . . $ gtk_printer_option_set(25f3c7ce40a8bef4). (GtkPrinterOptioncxx . . $ GtkPrinterOption# *option, |
| 165 | const char *value) |
| 166 | { |
| 167 | if (value == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 168 | value = ""; |
| 169 | |
| 170 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88). (option->valuecxx . . $ _GtkPrinterOption#value., value) == 0) |
| 171 | return; |
| 172 | |
| 173 | if ((option->typecxx . . $ _GtkPrinterOption#type. == GTK_PRINTER_OPTION_TYPE_PICKONEcxx . . $ GTK_PRINTER_OPTION_TYPE_PICKONE. || |
| 174 | option->typecxx . . $ _GtkPrinterOption#type. == GTK_PRINTER_OPTION_TYPE_ALTERNATIVEcxx . . $ GTK_PRINTER_OPTION_TYPE_ALTERNATIVE.)) |
| 175 | { |
| 176 | int i; |
| 177 | |
| 178 | for (i = 0; i < option->num_choicescxx . . $ _GtkPrinterOption#num_choices.; i++) |
| 179 | { |
| 180 | if (g_ascii_strcasecmpcxx . . $ g_ascii_strcasecmp(5ae29d726ae57f88). (value, option->choicescxx . . $ _GtkPrinterOption#choices.[i]) == 0) |
| 181 | { |
| 182 | value = option->choicescxx . . $ _GtkPrinterOption#choices.[i]; |
| 183 | break; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | if (i == option->num_choicescxx . . $ _GtkPrinterOption#num_choices.) |
| 188 | return; /* Not found in available choices */ |
| 189 | } |
| 190 | |
| 191 | g_freecxx . . $ g_free(5d22bdacc48458e8). (option->valuecxx . . $ _GtkPrinterOption#value.); |
| 192 | option->valuecxx . . $ _GtkPrinterOption#value. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (value); |
| 193 | |
| 194 | emit_changedcxx . . $ emit_changed(edefb8f20fe88fd9). (option); |
| 195 | } |
| 196 | |
| 197 | void |
| 198 | gtk_printer_option_set_booleancxx . . $ gtk_printer_option_set_boolean(c44804cfbea906f8). (GtkPrinterOptioncxx . . $ GtkPrinterOption# *option, |
| 199 | gbooleancxx . . $ gboolean# value) |
| 200 | { |
| 201 | gtk_printer_option_setcxx . . $ gtk_printer_option_set(25f3c7ce40a8bef4). (option, value ? "True" : "False"); |
| 202 | } |
| 203 | |
| 204 | void |
| 205 | gtk_printer_option_set_has_conflictcxx . . $ gtk_printer_option_set_has_conflict(c44804cfbea906f8). (GtkPrinterOptioncxx . . $ GtkPrinterOption# *option, |
| 206 | gbooleancxx . . $ gboolean# has_conflict) |
| 207 | { |
| 208 | has_conflict = has_conflict != 0; |
| 209 | |
| 210 | if (option->has_conflictcxx . . $ _GtkPrinterOption#has_conflict. == has_conflict) |
| 211 | return; |
| 212 | |
| 213 | option->has_conflictcxx . . $ _GtkPrinterOption#has_conflict. = has_conflict; |
| 214 | emit_changedcxx . . $ emit_changed(edefb8f20fe88fd9). (option); |
| 215 | } |
| 216 | |
| 217 | void |
| 218 | gtk_printer_option_clear_has_conflictcxx . . $ gtk_printer_option_clear_has_conflict(edefb8f20fe88fd9). (GtkPrinterOptioncxx . . $ GtkPrinterOption# *option) |
| 219 | { |
| 220 | gtk_printer_option_set_has_conflictcxx . . $ gtk_printer_option_set_has_conflict(c44804cfbea906f8). (option, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!); |
| 221 | } |
| 222 | |
| 223 | void |
| 224 | gtk_printer_option_allocate_choicescxx . . $ gtk_printer_option_allocate_choices(c44804cfbea906f8). (GtkPrinterOptioncxx . . $ GtkPrinterOption# *option, |
| 225 | int num) |
| 226 | { |
| 227 | g_freecxx . . $ g_free(5d22bdacc48458e8). (option->choicescxx . . $ _GtkPrinterOption#choices.); |
| 228 | g_freecxx . . $ g_free(5d22bdacc48458e8). (option->choices_displaycxx . . $ _GtkPrinterOption#choices_display.); |
| 229 | |
| 230 | option->num_choicescxx . . $ _GtkPrinterOption#num_choices. = num; |
| 231 | if (num == 0) |
| 232 | { |
| 233 | option->choicescxx . . $ _GtkPrinterOption#choices. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 234 | option->choices_displaycxx . . $ _GtkPrinterOption#choices_display. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 235 | } |
| 236 | else |
| 237 | { |
| 238 | option->choicescxx . . $ _GtkPrinterOption#choices. = g_new0cxx . . $ `<external>/1123956534522462559/gmem.h:335:9`! (char *, num); |
| 239 | option->choices_displaycxx . . $ _GtkPrinterOption#choices_display. = g_new0cxx . . $ `<external>/1123956534522462559/gmem.h:335:9`! (char *, num); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | void |
| 244 | gtk_printer_option_choices_from_arraycxx . . $ gtk_printer_option_choices_from_array(6bf87c44250afb12). (GtkPrinterOptioncxx . . $ GtkPrinterOption# *option, |
| 245 | int num_choices, |
| 246 | const char **choices, |
| 247 | const char **choices_display) |
| 248 | { |
| 249 | int i; |
| 250 | |
| 251 | gtk_printer_option_allocate_choicescxx . . $ gtk_printer_option_allocate_choices(c44804cfbea906f8). (option, num_choices); |
| 252 | for (i = 0; i < num_choices; i++) |
| 253 | { |
| 254 | option->choicescxx . . $ _GtkPrinterOption#choices.[i] = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (choices[i]); |
| 255 | option->choices_displaycxx . . $ _GtkPrinterOption#choices_display.[i] = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (choices_display[i]); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | gbooleancxx . . $ gboolean# |
| 260 | gtk_printer_option_has_choicecxx . . $ gtk_printer_option_has_choice(36553636b51e29c2). (GtkPrinterOptioncxx . . $ GtkPrinterOption# *option, |
| 261 | const char *choice) |
| 262 | { |
| 263 | int i; |
| 264 | |
| 265 | for (i = 0; i < option->num_choicescxx . . $ _GtkPrinterOption#num_choices.; i++) |
| 266 | { |
| 267 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88). (option->choicescxx . . $ _GtkPrinterOption#choices.[i], choice) == 0) |
| 268 | return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!; |
| 269 | } |
| 270 | |
| 271 | return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 272 | } |
| 273 | |
| 274 | void |
| 275 | gtk_printer_option_set_activates_defaultcxx . . $ gtk_printer_option_set_activates_default(c44804cfbea906f8). (GtkPrinterOptioncxx . . $ GtkPrinterOption# *option, |
| 276 | gbooleancxx . . $ gboolean# activates) |
| 277 | { |
| 278 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_PRINTER_OPTIONcxx . . $ `gtk/print/gtkprinteroptionprivate.h:36:9`! (option)); |
| 279 | |
| 280 | option->activates_defaultcxx . . $ _GtkPrinterOption#activates_default. = activates; |
| 281 | } |
| 282 | |
| 283 | gbooleancxx . . $ gboolean# |
| 284 | gtk_printer_option_get_activates_defaultcxx . . $ gtk_printer_option_get_activates_default(68406e0aa737fb3d). (GtkPrinterOptioncxx . . $ GtkPrinterOption# *option) |
| 285 | { |
| 286 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_PRINTER_OPTIONcxx . . $ `gtk/print/gtkprinteroptionprivate.h:36:9`! (option), FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!); |
| 287 | |
| 288 | return option->activates_defaultcxx . . $ _GtkPrinterOption#activates_default.; |
| 289 | } |