| 1 | /* GTK - The GIMP Toolkit |
| 2 | * gtkpapersize.c: Paper Size |
| 3 | * Copyright (C) 2006, Red Hat, Inc. |
| 4 | * Copyright © 2006, 2007 Christian Persch |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #include "config.h"cxx . . $ `<file>/build/config.h`/ |
| 21 | #include <string.h> |
| 22 | #include <stdlib.h> |
| 23 | #include <locale.h> |
| 24 | #if defined(HAVE__NL_PAPER_HEIGHTcxx . . $ `build/config.h:112:9`!) && defined(HAVE__NL_PAPER_WIDTHcxx . . $ `build/config.h:114:9`!) |
| 25 | #include <langinfo.h> |
| 26 | #endif |
| 27 | #include <math.h> |
| 28 | |
| 29 | #include <glib/gi18n-lib.h> |
| 30 | |
| 31 | #include "gtkpapersize.h"cxx . . $ `<file>/gtk/print/gtkpapersize.h`/ |
| 32 | #include "gtkprintutilsprivate.h"cxx . . $ `<file>/gtk/print/gtkprintutilsprivate.h`/ |
| 33 | #include "gtkprintoperation.h"cxx . . $ `<file>/gtk/print/gtkprintoperation.h`/ /* for GtkPrintError */ |
| 34 | |
| 35 | /* _gtk_load_custom_papers() only on Unix so far */ |
| 36 | #ifdef G_OS_UNIXcxx . . $ `<external>/10505296616216143549/glibconfig.h:120:9`! |
| 37 | #include "gtkcustompaperunixdialog.h"cxx . . $ `<file>/gtk/print/gtkcustompaperunixdialog.h`/ |
| 38 | #endif |
| 39 | |
| 40 | #include "paper_names_offsets.c"cxx . . $ `<file>/gtk/print/paper_names_offsets.c`/ |
| 41 | |
| 42 | |
| 43 | /** |
| 44 | * GtkPaperSize: |
| 45 | * |
| 46 | * `GtkPaperSize` handles paper sizes. |
| 47 | * |
| 48 | * It uses the standard called |
| 49 | * [PWG 5101.1-2002 PWG: Standard for Media Standardized Names](http://www.pwg.org/standards.html) |
| 50 | * to name the paper sizes (and to get the data for the page sizes). |
| 51 | * In addition to standard paper sizes, `GtkPaperSize` allows to |
| 52 | * construct custom paper sizes with arbitrary dimensions. |
| 53 | * |
| 54 | * The `GtkPaperSize` object stores not only the dimensions (width |
| 55 | * and height) of a paper size and its name, it also provides |
| 56 | * default print margins. |
| 57 | */ |
| 58 | |
| 59 | |
| 60 | struct _GtkPaperSizecxx . . $ _GtkPaperSize# |
| 61 | { |
| 62 | const PaperInfocxx . . $ PaperInfo# *infocxx . . $ _GtkPaperSize#info.; |
| 63 | |
| 64 | /* If these are not set we fall back to info */ |
| 65 | char *namecxx . . $ _GtkPaperSize#name.; |
| 66 | char *display_namecxx . . $ _GtkPaperSize#display_name.; |
| 67 | char *ppd_namecxx . . $ _GtkPaperSize#ppd_name.; |
| 68 | |
| 69 | double widthcxx . . $ _GtkPaperSize#width., heightcxx . . $ _GtkPaperSize#height.; /* Stored in mm */ |
| 70 | gbooleancxx . . $ gboolean# is_customcxx . . $ _GtkPaperSize#is_custom.; |
| 71 | gbooleancxx . . $ gboolean# is_ippcxx . . $ _GtkPaperSize#is_ipp.; |
| 72 | }; |
| 73 | |
| 74 | G_DEFINE_BOXED_TYPEcxx . . $ `<external>/9567554376676449156/gtype.h:2440:9`! (GtkPaperSize, gtk_paper_size, |
| 75 | gtk_paper_size_copy, |
| 76 | gtk_paper_size_free) |
| 77 | |
| 78 | static const PaperInfocxx . . $ PaperInfo# * |
| 79 | lookup_paper_infocxx . . $ lookup_paper_info(9582662d58586ffc). (const char *name) |
| 80 | { |
| 81 | int lower = 0; |
| 82 | int upper = G_N_ELEMENTScxx . . $ `<external>/12741050725406041920/gmacros.h:993:9`! (standard_names_offsets) - 1; |
| 83 | int mid; |
| 84 | int cmp; |
| 85 | |
| 86 | do |
| 87 | { |
| 88 | mid = (lower + upper) / 2; |
| 89 | cmp = strcmpcxx . . $ strcmp(5ae29d726ae57f88). (name, paper_namescxx . . $ paper_names. + standard_names_offsetscxx . . $ standard_names_offsets.[mid].namecxx . . $ $anonymous_type_7a75e11dea50c228_0#name.); |
| 90 | if (cmp < 0) |
| 91 | upper = mid - 1; |
| 92 | else if (cmp > 0) |
| 93 | lower = mid + 1; |
| 94 | else |
| 95 | return &standard_names_offsetscxx . . $ standard_names_offsets.[mid]; |
| 96 | } |
| 97 | while (lower <= upper); |
| 98 | |
| 99 | return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 100 | } |
| 101 | |
| 102 | static gbooleancxx . . $ gboolean# |
| 103 | parse_media_sizecxx . . $ parse_media_size(63bc5dc12a25a55). (const char *size, |
| 104 | double *width_mm, |
| 105 | double *height_mm) |
| 106 | { |
| 107 | const char *p; |
| 108 | char *e; |
| 109 | double short_dim, long_dim; |
| 110 | |
| 111 | p = size; |
| 112 | |
| 113 | short_dim = g_ascii_strtodcxx . . $ g_ascii_strtod(3dfe5620a0d3160e). (p, &e); |
| 114 | |
| 115 | if (p == e || *e != 'x') |
| 116 | return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 117 | |
| 118 | p = e + 1; /* Skip x */ |
| 119 | |
| 120 | long_dim = g_ascii_strtodcxx . . $ g_ascii_strtod(3dfe5620a0d3160e). (p, &e); |
| 121 | |
| 122 | if (p == e) |
| 123 | return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 124 | |
| 125 | p = e; |
| 126 | |
| 127 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88). (p, "in") == 0) |
| 128 | { |
| 129 | short_dim = short_dim * MM_PER_INCHcxx . . $ `gtk/print/gtkprintutilsprivate.h:26:9`!; |
| 130 | long_dim = long_dim * MM_PER_INCHcxx . . $ `gtk/print/gtkprintutilsprivate.h:26:9`!; |
| 131 | } |
| 132 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88). (p, "mm") != 0) |
| 133 | return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 134 | |
| 135 | if (width_mm) |
| 136 | *width_mm = short_dim; |
| 137 | if (height_mm) |
| 138 | *height_mm = long_dim; |
| 139 | |
| 140 | return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!; |
| 141 | } |
| 142 | |
| 143 | static gbooleancxx . . $ gboolean# |
| 144 | parse_full_media_size_namecxx . . $ parse_full_media_size_name(d5d3fdeaf20195b8). (const char *full_name, |
| 145 | char **name, |
| 146 | double *width_mm, |
| 147 | double *height_mm) |
| 148 | { |
| 149 | const char *p; |
| 150 | const char *end_of_name; |
| 151 | |
| 152 | /* From the spec: |
| 153 | media-size-self-describing-name = |
| 154 | ( class-in "_" size-name "_" short-dim "x" long-dim "in" ) | |
| 155 | ( class-mm "_" size-name "_" short-dim "x" long-dim "mm" ) |
| 156 | class-in = "custom" | "na" | "asme" | "roc" | "oe" |
| 157 | class-mm = "custom" | "iso" | "jis" | "jpn" | "prc" | "om" |
| 158 | size-name = ( lowalpha | digit ) *( lowalpha | digit | "-" ) |
| 159 | short-dim = dim |
| 160 | long-dim = dim |
| 161 | dim = integer-part [fraction-part] | "0" fraction-part |
| 162 | integer-part = non-zero-digit *digit |
| 163 | fraction-part = "." *digit non-zero-digit |
| 164 | lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | |
| 165 | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | |
| 166 | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" |
| 167 | non-zero-digit = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" |
| 168 | digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" |
| 169 | */ |
| 170 | |
| 171 | p = strchrcxx . . $ strchr(2050848944e00d54). (full_name, '_'); |
| 172 | if (p == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 173 | return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 174 | |
| 175 | p++; /* Skip _ */ |
| 176 | |
| 177 | p = strchrcxx . . $ strchr(2050848944e00d54). (p, '_'); |
| 178 | if (p == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 179 | return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 180 | |
| 181 | end_of_name = p; |
| 182 | |
| 183 | p++; /* Skip _ */ |
| 184 | |
| 185 | if (!parse_media_sizecxx . . $ parse_media_size(63bc5dc12a25a55). (p, width_mm, height_mm)) |
| 186 | return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 187 | |
| 188 | if (name) |
| 189 | *name = g_strndupcxx . . $ g_strndup(eabdfdef77619b3d). (full_name, end_of_name - full_name); |
| 190 | |
| 191 | return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!; |
| 192 | } |
| 193 | |
| 194 | static GtkPaperSizecxx . . $ GtkPaperSize# * |
| 195 | gtk_paper_size_new_from_infocxx . . $ gtk_paper_size_new_from_info(b5626b4d3a152e35). (const PaperInfocxx . . $ PaperInfo# *info) |
| 196 | { |
| 197 | GtkPaperSizecxx . . $ GtkPaperSize# *size; |
| 198 | |
| 199 | size = g_new0cxx . . $ `<external>/1123956534522462559/gmem.h:335:9`! (GtkPaperSize, 1); |
| 200 | size->infocxx . . $ _GtkPaperSize#info. = info; |
| 201 | size->widthcxx . . $ _GtkPaperSize#width. = info->widthcxx . . $ $anonymous_type_7a75e11dea50c228_0#width.; |
| 202 | size->heightcxx . . $ _GtkPaperSize#height. = info->heightcxx . . $ $anonymous_type_7a75e11dea50c228_0#height.; |
| 203 | |
| 204 | return size; |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * gtk_paper_size_new: |
| 209 | * @name: (nullable): a paper size name |
| 210 | * |
| 211 | * Creates a new `GtkPaperSize` object by parsing a |
| 212 | * [PWG 5101.1-2002](ftp://ftp.pwg.org/pub/pwg/candidates/cs-pwgmsn10-20020226-5101.1.pdf) |
| 213 | * paper name. |
| 214 | * |
| 215 | * If @name is %NULL, the default paper size is returned, |
| 216 | * see [[email protected]_default]. |
| 217 | * |
| 218 | * Returns: a new `GtkPaperSize`, use [[email protected]] |
| 219 | * to free it |
| 220 | */ |
| 221 | GtkPaperSizecxx . . $ GtkPaperSize# * |
| 222 | gtk_paper_size_newcxx . . $ gtk_paper_size_new(f8919256739e09e9). (const char *name) |
| 223 | { |
| 224 | GtkPaperSizecxx . . $ GtkPaperSize# *size; |
| 225 | char *short_name; |
| 226 | double width, height; |
| 227 | const PaperInfocxx . . $ PaperInfo# *info; |
| 228 | |
| 229 | if (name == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 230 | name = gtk_paper_size_get_defaultcxx . . $ gtk_paper_size_get_default(33a1f659e94feb42). (); |
| 231 | |
| 232 | if (parse_full_media_size_namecxx . . $ parse_full_media_size_name(d5d3fdeaf20195b8). (name, &short_name, &width, &height)) |
| 233 | { |
| 234 | info = lookup_paper_infocxx . . $ lookup_paper_info(9582662d58586ffc). (short_name); |
| 235 | if (info != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! && info->widthcxx . . $ $anonymous_type_7a75e11dea50c228_0#width. == width && info->heightcxx . . $ $anonymous_type_7a75e11dea50c228_0#height. == height) |
| 236 | { |
| 237 | size = gtk_paper_size_new_from_infocxx . . $ gtk_paper_size_new_from_info(b5626b4d3a152e35). (info); |
| 238 | g_freecxx . . $ g_free(5d22bdacc48458e8). (short_name); |
| 239 | } |
| 240 | else |
| 241 | { |
| 242 | size = g_new0cxx . . $ `<external>/1123956534522462559/gmem.h:335:9`! (GtkPaperSize, 1); |
| 243 | |
| 244 | size->widthcxx . . $ _GtkPaperSize#width. = width; |
| 245 | size->heightcxx . . $ _GtkPaperSize#height. = height; |
| 246 | size->namecxx . . $ _GtkPaperSize#name. = short_name; |
| 247 | size->display_namecxx . . $ _GtkPaperSize#display_name. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (short_name); |
| 248 | if (strncmpcxx . . $ strncmp(fd278af2f295fa2e). (short_name, "custom", 6) == 0) |
| 249 | size->is_customcxx . . $ _GtkPaperSize#is_custom. = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!; |
| 250 | } |
| 251 | } |
| 252 | else |
| 253 | { |
| 254 | info = lookup_paper_infocxx . . $ lookup_paper_info(9582662d58586ffc). (name); |
| 255 | if (info != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 256 | size = gtk_paper_size_new_from_infocxx . . $ gtk_paper_size_new_from_info(b5626b4d3a152e35). (info); |
| 257 | else |
| 258 | { |
| 259 | g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:340:9`! ("Unknown paper size %s", name); |
| 260 | size = g_new0cxx . . $ `<external>/1123956534522462559/gmem.h:335:9`! (GtkPaperSize, 1); |
| 261 | size->namecxx . . $ _GtkPaperSize#name. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (name); |
| 262 | size->display_namecxx . . $ _GtkPaperSize#display_name. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (name); |
| 263 | /* Default to A4 size */ |
| 264 | size->widthcxx . . $ _GtkPaperSize#width. = 210; |
| 265 | size->heightcxx . . $ _GtkPaperSize#height. = 297; |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | return size; |
| 270 | } |
| 271 | |
| 272 | static char * |
| 273 | improve_displaynamecxx . . $ improve_displayname(a8b8e32347182212). (const char *name) |
| 274 | { |
| 275 | char *p1, *p2, *s; |
| 276 | const char *p; |
| 277 | |
| 278 | p = strrchrcxx . . $ strrchr(2050848944e00d54). (name, 'x'); |
| 279 | if (p && p != name && |
| 280 | g_ascii_isdigitcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:70:9`! (*(p - 1)) && |
| 281 | g_ascii_isdigitcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:70:9`! (*(p + 1))) |
| 282 | { |
| 283 | p1 = g_strndupcxx . . $ g_strndup(eabdfdef77619b3d). (name, p - name); |
| 284 | p2 = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (p + 1); |
| 285 | s = g_strconcatcxx . . $ g_strconcat(a849077ff1b8d812). (p1, "×", p2, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 286 | g_freecxx . . $ g_free(5d22bdacc48458e8). (p1); |
| 287 | g_freecxx . . $ g_free(5d22bdacc48458e8). (p2); |
| 288 | } |
| 289 | else |
| 290 | s = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (name); |
| 291 | |
| 292 | return s; |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * gtk_paper_size_new_from_ppd: |
| 297 | * @ppd_name: a PPD paper name |
| 298 | * @ppd_display_name: the corresponding human-readable name |
| 299 | * @width: the paper width, in points |
| 300 | * @height: the paper height in points |
| 301 | * |
| 302 | * Creates a new `GtkPaperSize` object by using |
| 303 | * PPD information. |
| 304 | * |
| 305 | * If @ppd_name is not a recognized PPD paper name, |
| 306 | * @ppd_display_name, @width and @height are used to |
| 307 | * construct a custom `GtkPaperSize` object. |
| 308 | * |
| 309 | * Returns: a new `GtkPaperSize`, use [[email protected]] |
| 310 | * to free it |
| 311 | */ |
| 312 | GtkPaperSizecxx . . $ GtkPaperSize# * |
| 313 | gtk_paper_size_new_from_ppdcxx . . $ gtk_paper_size_new_from_ppd(ecab97cd4d05cd32). (const char *ppd_name, |
| 314 | const char *ppd_display_name, |
| 315 | double width, |
| 316 | double height) |
| 317 | { |
| 318 | char *name; |
| 319 | const char *lookup_ppd_name; |
| 320 | char *freeme; |
| 321 | GtkPaperSizecxx . . $ GtkPaperSize# *size; |
| 322 | int i; |
| 323 | char *display_name; |
| 324 | |
| 325 | lookup_ppd_name = ppd_name; |
| 326 | |
| 327 | freeme = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 328 | /* Strip out Traverse suffix in matching. */ |
| 329 | if (g_str_has_suffixcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:183:9`! (ppd_name, ".Transverse")) |
| 330 | { |
| 331 | lookup_ppd_name = freeme = |
| 332 | g_strndupcxx . . $ g_strndup(eabdfdef77619b3d). (ppd_name, strlencxx . . $ strlen(751346f8406fd082). (ppd_name) - strlencxx . . $ strlen(751346f8406fd082). (".Transverse")); |
| 333 | } |
| 334 | |
| 335 | for (i = 0; i < G_N_ELEMENTScxx . . $ `<external>/12741050725406041920/gmacros.h:993:9`! (standard_names_offsets); i++) |
| 336 | { |
| 337 | if (standard_names_offsetscxx . . $ standard_names_offsets.[i].ppd_namecxx . . $ $anonymous_type_7a75e11dea50c228_0#ppd_name. != -1 && |
| 338 | strcmpcxx . . $ strcmp(5ae29d726ae57f88). (paper_namescxx . . $ paper_names. + standard_names_offsetscxx . . $ standard_names_offsets.[i].ppd_namecxx . . $ $anonymous_type_7a75e11dea50c228_0#ppd_name., lookup_ppd_name) == 0) |
| 339 | { |
| 340 | size = gtk_paper_size_new_from_infocxx . . $ gtk_paper_size_new_from_info(b5626b4d3a152e35). (&standard_names_offsetscxx . . $ standard_names_offsets.[i]); |
| 341 | goto out; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | for (i = 0; i < G_N_ELEMENTScxx . . $ `<external>/12741050725406041920/gmacros.h:993:9`! (extra_ppd_names_offsets); i++) |
| 346 | { |
| 347 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88). (paper_namescxx . . $ paper_names. + extra_ppd_names_offsetscxx . . $ extra_ppd_names_offsets.[i].ppd_namecxx . . $ $anonymous_type_7a75e11dea50c228_1#ppd_name., lookup_ppd_name) == 0) |
| 348 | { |
| 349 | size = gtk_paper_size_newcxx . . $ gtk_paper_size_new(f8919256739e09e9). (paper_namescxx . . $ paper_names. + extra_ppd_names_offsetscxx . . $ extra_ppd_names_offsets.[i].standard_namecxx . . $ $anonymous_type_7a75e11dea50c228_1#standard_name.); |
| 350 | goto out; |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | name = g_strconcatcxx . . $ g_strconcat(a849077ff1b8d812). ("ppd_", ppd_name, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 355 | display_name = improve_displaynamecxx . . $ improve_displayname(a8b8e32347182212). (ppd_display_name); |
| 356 | size = gtk_paper_size_new_customcxx . . $ gtk_paper_size_new_custom(5f9034f12a6d1f1e). (name, display_name, width, height, GTK_UNIT_POINTScxx . . $ GTK_UNIT_POINTS.); |
| 357 | g_freecxx . . $ g_free(5d22bdacc48458e8). (display_name); |
| 358 | g_freecxx . . $ g_free(5d22bdacc48458e8). (name); |
| 359 | |
| 360 | out: |
| 361 | |
| 362 | if (size->infocxx . . $ _GtkPaperSize#info. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! || |
| 363 | size->infocxx . . $ _GtkPaperSize#info.->ppd_namecxx . . $ $anonymous_type_7a75e11dea50c228_0#ppd_name. == -1 || |
| 364 | strcmpcxx . . $ strcmp(5ae29d726ae57f88). (paper_namescxx . . $ paper_names. + size->infocxx . . $ _GtkPaperSize#info.->ppd_namecxx . . $ $anonymous_type_7a75e11dea50c228_0#ppd_name., ppd_name) != 0) |
| 365 | size->ppd_namecxx . . $ _GtkPaperSize#ppd_name. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (ppd_name); |
| 366 | |
| 367 | g_freecxx . . $ g_free(5d22bdacc48458e8). (freeme); |
| 368 | |
| 369 | return size; |
| 370 | } |
| 371 | |
| 372 | /* Tolerance of paper size in points according to PostScript Language Reference */ |
| 373 | #define PAPER_SIZE_TOLERANCEcxx . . $ `gtk/print/gtkpapersize.c:373:9`! 5 |
| 374 | |
| 375 | /** |
| 376 | * gtk_paper_size_new_from_ipp: |
| 377 | * @ipp_name: an IPP paper name |
| 378 | * @width: the paper width, in points |
| 379 | * @height: the paper height in points |
| 380 | * |
| 381 | * Creates a new `GtkPaperSize` object by using |
| 382 | * IPP information. |
| 383 | * |
| 384 | * If @ipp_name is not a recognized paper name, |
| 385 | * @width and @height are used to |
| 386 | * construct a custom `GtkPaperSize` object. |
| 387 | * |
| 388 | * Returns: a new `GtkPaperSize`, use [[email protected]] |
| 389 | * to free it |
| 390 | */ |
| 391 | GtkPaperSizecxx . . $ GtkPaperSize# * |
| 392 | gtk_paper_size_new_from_ippcxx . . $ gtk_paper_size_new_from_ipp(8bae5a206f4a931f). (const char *ipp_name, |
| 393 | double width, |
| 394 | double height) |
| 395 | { |
| 396 | GtkPaperSizecxx . . $ GtkPaperSize# *size; |
| 397 | const char *name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 398 | gbooleancxx . . $ gboolean# found = FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 399 | float x_dimension; |
| 400 | float y_dimension; |
| 401 | char *display_name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 402 | int i; |
| 403 | |
| 404 | /* Find paper size according to its name */ |
| 405 | for (i = 0; i < G_N_ELEMENTScxx . . $ `<external>/12741050725406041920/gmacros.h:993:9`! (standard_names_offsets); i++) |
| 406 | { |
| 407 | if (standard_names_offsetscxx . . $ standard_names_offsets.[i].namecxx . . $ $anonymous_type_7a75e11dea50c228_0#name. != -1) |
| 408 | name = paper_namescxx . . $ paper_names. + standard_names_offsetscxx . . $ standard_names_offsets.[i].namecxx . . $ $anonymous_type_7a75e11dea50c228_0#name.; |
| 409 | if (name != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! && |
| 410 | /* Given paper size name is equal to a name |
| 411 | from the standard paper size names list. */ |
| 412 | ((g_strcmp0cxx . . $ g_strcmp0(5ae29d726ae57f88). (ipp_name, name) == 0) || |
| 413 | /* Given paper size name is prefixed by a name |
| 414 | from the standard paper size names list + |
| 415 | it consists of size in its name (e.g. iso_a4_210x297mm). */ |
| 416 | (g_str_has_prefixcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:159:9`! (ipp_name, name) && |
| 417 | strlencxx . . $ strlen(751346f8406fd082). (ipp_name) > strlencxx . . $ strlen(751346f8406fd082). (name) + 2 && |
| 418 | ipp_name[strlencxx . . $ strlen(751346f8406fd082). (ipp_name)] == '_' && |
| 419 | g_ascii_isdigitcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:70:9`! (ipp_name[strlen (ipp_name) + 1]) && |
| 420 | (g_str_has_suffixcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:183:9`! (ipp_name, "mm") || |
| 421 | g_str_has_suffixcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:183:9`! (ipp_name, "in"))))) |
| 422 | { |
| 423 | display_name = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (g_dpgettext2 (GETTEXT_PACKAGEcxx . . $ `build/config.h:8:9`!, |
| 424 | "paper size", |
| 425 | paper_names + standard_names_offsets[i].display_name)); |
| 426 | found = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!; |
| 427 | break; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | /* Find paper size according to its size */ |
| 432 | if (display_name == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 433 | { |
| 434 | for (i = 0; i < G_N_ELEMENTScxx . . $ `<external>/12741050725406041920/gmacros.h:993:9`! (standard_names_offsets); i++) |
| 435 | { |
| 436 | x_dimension = _gtk_print_convert_from_mmcxx . . $ _gtk_print_convert_from_mm(22115c009b206bef). (standard_names_offsetscxx . . $ standard_names_offsets.[i].widthcxx . . $ $anonymous_type_7a75e11dea50c228_0#width., GTK_UNIT_POINTScxx . . $ GTK_UNIT_POINTS.); |
| 437 | y_dimension = _gtk_print_convert_from_mmcxx . . $ _gtk_print_convert_from_mm(22115c009b206bef). (standard_names_offsetscxx . . $ standard_names_offsets.[i].heightcxx . . $ $anonymous_type_7a75e11dea50c228_0#height., GTK_UNIT_POINTScxx . . $ GTK_UNIT_POINTS.); |
| 438 | |
| 439 | if (fabscxx . . $ fabs(447c67c6676f75c3). (x_dimension - width) <= PAPER_SIZE_TOLERANCEcxx . . $ `gtk/print/gtkpapersize.c:373:9`! && |
| 440 | fabscxx . . $ fabs(447c67c6676f75c3). (y_dimension - height) <= PAPER_SIZE_TOLERANCEcxx . . $ `gtk/print/gtkpapersize.c:373:9`!) |
| 441 | { |
| 442 | display_name = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (g_dpgettext2 (GETTEXT_PACKAGEcxx . . $ `build/config.h:8:9`!, |
| 443 | "paper size", |
| 444 | paper_names + standard_names_offsets[i].display_name)); |
| 445 | found = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!; |
| 446 | break; |
| 447 | } |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | /* Fallback to name of the paper size as given in "ipp_name" parameter */ |
| 452 | if (display_name == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 453 | display_name = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (ipp_name); |
| 454 | |
| 455 | size = gtk_paper_size_new_customcxx . . $ gtk_paper_size_new_custom(5f9034f12a6d1f1e). (ipp_name, display_name, width, height, GTK_UNIT_POINTScxx . . $ GTK_UNIT_POINTS.); |
| 456 | size->is_customcxx . . $ _GtkPaperSize#is_custom. = !found; |
| 457 | size->is_ippcxx . . $ _GtkPaperSize#is_ipp. = found; |
| 458 | |
| 459 | g_freecxx . . $ g_free(5d22bdacc48458e8). (display_name); |
| 460 | |
| 461 | return size; |
| 462 | } |
| 463 | |
| 464 | /** |
| 465 | * gtk_paper_size_new_custom: |
| 466 | * @name: the paper name |
| 467 | * @display_name: the human-readable name |
| 468 | * @width: the paper width, in units of @unit |
| 469 | * @height: the paper height, in units of @unit |
| 470 | * @unit: the unit for @width and @height. not %GTK_UNIT_NONE. |
| 471 | * |
| 472 | * Creates a new `GtkPaperSize` object with the |
| 473 | * given parameters. |
| 474 | * |
| 475 | * Returns: a new `GtkPaperSize` object, use [[email protected]] |
| 476 | * to free it |
| 477 | */ |
| 478 | GtkPaperSizecxx . . $ GtkPaperSize# * |
| 479 | gtk_paper_size_new_customcxx . . $ gtk_paper_size_new_custom(5f9034f12a6d1f1e). (const char *name, |
| 480 | const char *display_name, |
| 481 | double width, |
| 482 | double height, |
| 483 | GtkUnitcxx . . $ GtkUnit# unit) |
| 484 | { |
| 485 | GtkPaperSizecxx . . $ GtkPaperSize# *size; |
| 486 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (name != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 487 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (unit != GTK_UNIT_NONE, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 488 | |
| 489 | size = g_new0cxx . . $ `<external>/1123956534522462559/gmem.h:335:9`! (GtkPaperSize, 1); |
| 490 | |
| 491 | size->namecxx . . $ _GtkPaperSize#name. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (name); |
| 492 | size->display_namecxx . . $ _GtkPaperSize#display_name. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (display_name); |
| 493 | size->is_customcxx . . $ _GtkPaperSize#is_custom. = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!; |
| 494 | |
| 495 | size->widthcxx . . $ _GtkPaperSize#width. = _gtk_print_convert_to_mmcxx . . $ _gtk_print_convert_to_mm(22115c009b206bef). (width, unit); |
| 496 | size->heightcxx . . $ _GtkPaperSize#height. = _gtk_print_convert_to_mmcxx . . $ _gtk_print_convert_to_mm(22115c009b206bef). (height, unit); |
| 497 | |
| 498 | return size; |
| 499 | } |
| 500 | |
| 501 | /** |
| 502 | * gtk_paper_size_copy: |
| 503 | * @other: a `GtkPaperSize` |
| 504 | * |
| 505 | * Copies an existing `GtkPaperSize`. |
| 506 | * |
| 507 | * Returns: a copy of @other |
| 508 | */ |
| 509 | GtkPaperSizecxx . . $ GtkPaperSize# * |
| 510 | gtk_paper_size_copycxx . . $ gtk_paper_size_copy(47709f078c18783c). (GtkPaperSizecxx . . $ GtkPaperSize# *other) |
| 511 | { |
| 512 | GtkPaperSizecxx . . $ GtkPaperSize# *size; |
| 513 | |
| 514 | size = g_new0cxx . . $ `<external>/1123956534522462559/gmem.h:335:9`! (GtkPaperSize, 1); |
| 515 | |
| 516 | size->infocxx . . $ _GtkPaperSize#info. = other->infocxx . . $ _GtkPaperSize#info.; |
| 517 | if (other->namecxx . . $ _GtkPaperSize#name.) |
| 518 | size->namecxx . . $ _GtkPaperSize#name. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (other->name); |
| 519 | if (other->display_namecxx . . $ _GtkPaperSize#display_name.) |
| 520 | size->display_namecxx . . $ _GtkPaperSize#display_name. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (other->display_name); |
| 521 | if (other->ppd_namecxx . . $ _GtkPaperSize#ppd_name.) |
| 522 | size->ppd_namecxx . . $ _GtkPaperSize#ppd_name. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (other->ppd_name); |
| 523 | |
| 524 | size->widthcxx . . $ _GtkPaperSize#width. = other->widthcxx . . $ _GtkPaperSize#width.; |
| 525 | size->heightcxx . . $ _GtkPaperSize#height. = other->heightcxx . . $ _GtkPaperSize#height.; |
| 526 | size->is_customcxx . . $ _GtkPaperSize#is_custom. = other->is_customcxx . . $ _GtkPaperSize#is_custom.; |
| 527 | size->is_ippcxx . . $ _GtkPaperSize#is_ipp. = other->is_ippcxx . . $ _GtkPaperSize#is_ipp.; |
| 528 | |
| 529 | return size; |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * gtk_paper_size_free: |
| 534 | * @size: a `GtkPaperSize` |
| 535 | * |
| 536 | * Free the given `GtkPaperSize` object. |
| 537 | */ |
| 538 | void |
| 539 | gtk_paper_size_freecxx . . $ gtk_paper_size_free(315f71d1df3820d8). (GtkPaperSizecxx . . $ GtkPaperSize# *size) |
| 540 | { |
| 541 | g_freecxx . . $ g_free(5d22bdacc48458e8). (size->namecxx . . $ _GtkPaperSize#name.); |
| 542 | g_freecxx . . $ g_free(5d22bdacc48458e8). (size->display_namecxx . . $ _GtkPaperSize#display_name.); |
| 543 | g_freecxx . . $ g_free(5d22bdacc48458e8). (size->ppd_namecxx . . $ _GtkPaperSize#ppd_name.); |
| 544 | g_freecxx . . $ g_free(5d22bdacc48458e8). (size); |
| 545 | } |
| 546 | |
| 547 | /** |
| 548 | * gtk_paper_size_is_equal: |
| 549 | * @size1: a `GtkPaperSize` object |
| 550 | * @size2: another `GtkPaperSize` object |
| 551 | * |
| 552 | * Compares two `GtkPaperSize` objects. |
| 553 | * |
| 554 | * Returns: %TRUE, if @size1 and @size2 |
| 555 | * represent the same paper size |
| 556 | */ |
| 557 | gbooleancxx . . $ gboolean# |
| 558 | gtk_paper_size_is_equalcxx . . $ gtk_paper_size_is_equal(99b448b3c59a0bb7). (GtkPaperSizecxx . . $ GtkPaperSize# *size1, |
| 559 | GtkPaperSizecxx . . $ GtkPaperSize# *size2) |
| 560 | { |
| 561 | if (size1->infocxx . . $ _GtkPaperSize#info. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! && size2->infocxx . . $ _GtkPaperSize#info. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 562 | return size1->infocxx . . $ _GtkPaperSize#info. == size2->infocxx . . $ _GtkPaperSize#info.; |
| 563 | |
| 564 | return strcmpcxx . . $ strcmp(5ae29d726ae57f88). (gtk_paper_size_get_namecxx . . $ gtk_paper_size_get_name(987e11576a2cd2b3). (size1), |
| 565 | gtk_paper_size_get_namecxx . . $ gtk_paper_size_get_name(987e11576a2cd2b3). (size2)) == 0; |
| 566 | } |
| 567 | |
| 568 | /** |
| 569 | * gtk_paper_size_get_paper_sizes: |
| 570 | * @include_custom: whether to include custom paper sizes |
| 571 | * as defined in the page setup dialog |
| 572 | * |
| 573 | * Creates a list of known paper sizes. |
| 574 | * |
| 575 | * Returns: (element-type GtkPaperSize) (transfer full): a newly allocated list of newly |
| 576 | * allocated `GtkPaperSize` objects |
| 577 | */ |
| 578 | GListcxx . . $ GList# * |
| 579 | gtk_paper_size_get_paper_sizescxx . . $ gtk_paper_size_get_paper_sizes(ec8500643c2d9f78). (gbooleancxx . . $ gboolean# include_custom) |
| 580 | { |
| 581 | GListcxx . . $ GList# *list = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 582 | guintcxx . . $ guint# i; |
| 583 | /* _gtk_load_custom_papers() only on Unix so far */ |
| 584 | #ifdef G_OS_UNIXcxx . . $ `<external>/10505296616216143549/glibconfig.h:120:9`! |
| 585 | if (include_custom) |
| 586 | { |
| 587 | GListcxx . . $ GList# *page_setups, *l; |
| 588 | |
| 589 | page_setups = _gtk_load_custom_paperscxx . . $ _gtk_load_custom_papers(56e46de9ce394279). (); |
| 590 | for (l = page_setups; l != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; l = l->nextcxx . . $ _GList#next.) |
| 591 | { |
| 592 | GtkPageSetupcxx . . $ GtkPageSetup# *setup = (GtkPageSetupcxx . . $ GtkPageSetup# *) l->datacxx . . $ _GList#data.; |
| 593 | GtkPaperSizecxx . . $ GtkPaperSize# *size; |
| 594 | |
| 595 | size = gtk_page_setup_get_paper_sizecxx . . $ gtk_page_setup_get_paper_size(ff688a64e10ca9f0). (setup); |
| 596 | list = g_list_prependcxx . . $ g_list_prepend(35007086a6b2ba1c). (list, gtk_paper_size_copycxx . . $ gtk_paper_size_copy(47709f078c18783c). (size)); |
| 597 | } |
| 598 | |
| 599 | g_list_free_fullcxx . . $ g_list_free_full(5ba5b0738c7ed753). (page_setups, g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8).); |
| 600 | } |
| 601 | #endif |
| 602 | for (i = 0; i < G_N_ELEMENTScxx . . $ `<external>/12741050725406041920/gmacros.h:993:9`! (standard_names_offsets); ++i) |
| 603 | { |
| 604 | GtkPaperSizecxx . . $ GtkPaperSize# *size; |
| 605 | |
| 606 | size = gtk_paper_size_new_from_infocxx . . $ gtk_paper_size_new_from_info(b5626b4d3a152e35). (&standard_names_offsetscxx . . $ standard_names_offsets.[i]); |
| 607 | list = g_list_prependcxx . . $ g_list_prepend(35007086a6b2ba1c). (list, size); |
| 608 | } |
| 609 | |
| 610 | return g_list_reversecxx . . $ g_list_reverse(e31b64636014b719). (list); |
| 611 | } |
| 612 | |
| 613 | |
| 614 | /** |
| 615 | * gtk_paper_size_get_name: |
| 616 | * @size: a `GtkPaperSize` object |
| 617 | * |
| 618 | * Gets the name of the `GtkPaperSize`. |
| 619 | * |
| 620 | * Returns: the name of @size |
| 621 | */ |
| 622 | const char * |
| 623 | gtk_paper_size_get_namecxx . . $ gtk_paper_size_get_name(987e11576a2cd2b3). (GtkPaperSizecxx . . $ GtkPaperSize# *size) |
| 624 | { |
| 625 | if (size->namecxx . . $ _GtkPaperSize#name.) |
| 626 | return size->namecxx . . $ _GtkPaperSize#name.; |
| 627 | g_assertcxx . . $ `<external>/15287032793271088244/gtestutils.h:275:9`! (size->info != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 628 | return paper_namescxx . . $ paper_names. + size->infocxx . . $ _GtkPaperSize#info.->namecxx . . $ $anonymous_type_7a75e11dea50c228_0#name.; |
| 629 | } |
| 630 | |
| 631 | /** |
| 632 | * gtk_paper_size_get_display_name: |
| 633 | * @size: a `GtkPaperSize` object |
| 634 | * |
| 635 | * Gets the human-readable name of the `GtkPaperSize`. |
| 636 | * |
| 637 | * Returns: the human-readable name of @size |
| 638 | */ |
| 639 | const char * |
| 640 | gtk_paper_size_get_display_namecxx . . $ gtk_paper_size_get_display_name(987e11576a2cd2b3). (GtkPaperSizecxx . . $ GtkPaperSize# *size) |
| 641 | { |
| 642 | const char *display_name; |
| 643 | |
| 644 | if (size->display_namecxx . . $ _GtkPaperSize#display_name.) |
| 645 | return size->display_namecxx . . $ _GtkPaperSize#display_name.; |
| 646 | |
| 647 | g_assertcxx . . $ `<external>/15287032793271088244/gtestutils.h:275:9`! (size->info != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 648 | |
| 649 | display_name = paper_namescxx . . $ paper_names. + size->infocxx . . $ _GtkPaperSize#info.->display_namecxx . . $ $anonymous_type_7a75e11dea50c228_0#display_name.; |
| 650 | return g_dpgettext2cxx . . $ g_dpgettext2(9e72f0106375db22). (GETTEXT_PACKAGEcxx . . $ `build/config.h:8:9`!, "paper size", display_name); |
| 651 | } |
| 652 | |
| 653 | /** |
| 654 | * gtk_paper_size_get_ppd_name: |
| 655 | * @size: a `GtkPaperSize` object |
| 656 | * |
| 657 | * Gets the PPD name of the `GtkPaperSize`, which |
| 658 | * may be %NULL. |
| 659 | * |
| 660 | * Returns: the PPD name of @size |
| 661 | */ |
| 662 | const char * |
| 663 | gtk_paper_size_get_ppd_namecxx . . $ gtk_paper_size_get_ppd_name(987e11576a2cd2b3). (GtkPaperSizecxx . . $ GtkPaperSize# *size) |
| 664 | { |
| 665 | if (size->ppd_namecxx . . $ _GtkPaperSize#ppd_name.) |
| 666 | return size->ppd_namecxx . . $ _GtkPaperSize#ppd_name.; |
| 667 | if (size->infocxx . . $ _GtkPaperSize#info.) |
| 668 | return paper_namescxx . . $ paper_names. + size->infocxx . . $ _GtkPaperSize#info.->ppd_namecxx . . $ $anonymous_type_7a75e11dea50c228_0#ppd_name.; |
| 669 | return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 670 | } |
| 671 | |
| 672 | /** |
| 673 | * gtk_paper_size_get_width: |
| 674 | * @size: a `GtkPaperSize` object |
| 675 | * @unit: the unit for the return value, not %GTK_UNIT_NONE |
| 676 | * |
| 677 | * Gets the paper width of the `GtkPaperSize`, in |
| 678 | * units of @unit. |
| 679 | * |
| 680 | * Returns: the paper width |
| 681 | */ |
| 682 | double |
| 683 | gtk_paper_size_get_widthcxx . . $ gtk_paper_size_get_width(b08cd94bdb6d8de0). (GtkPaperSizecxx . . $ GtkPaperSize# *size, |
| 684 | GtkUnitcxx . . $ GtkUnit# unit) |
| 685 | { |
| 686 | return _gtk_print_convert_from_mmcxx . . $ _gtk_print_convert_from_mm(22115c009b206bef). (size->widthcxx . . $ _GtkPaperSize#width., unit); |
| 687 | } |
| 688 | |
| 689 | /** |
| 690 | * gtk_paper_size_get_height: |
| 691 | * @size: a `GtkPaperSize` object |
| 692 | * @unit: the unit for the return value, not %GTK_UNIT_NONE |
| 693 | * |
| 694 | * Gets the paper height of the `GtkPaperSize`, in |
| 695 | * units of @unit. |
| 696 | * |
| 697 | * Returns: the paper height |
| 698 | */ |
| 699 | double |
| 700 | gtk_paper_size_get_heightcxx . . $ gtk_paper_size_get_height(b08cd94bdb6d8de0). (GtkPaperSizecxx . . $ GtkPaperSize# *size, |
| 701 | GtkUnitcxx . . $ GtkUnit# unit) |
| 702 | { |
| 703 | return _gtk_print_convert_from_mmcxx . . $ _gtk_print_convert_from_mm(22115c009b206bef). (size->heightcxx . . $ _GtkPaperSize#height., unit); |
| 704 | } |
| 705 | |
| 706 | /** |
| 707 | * gtk_paper_size_is_custom: |
| 708 | * @size: a `GtkPaperSize` object |
| 709 | * |
| 710 | * Returns %TRUE if @size is not a standard paper size. |
| 711 | * |
| 712 | * Returns: whether @size is a custom paper size. |
| 713 | **/ |
| 714 | gbooleancxx . . $ gboolean# |
| 715 | gtk_paper_size_is_customcxx . . $ gtk_paper_size_is_custom(6478976a97bbf7ba). (GtkPaperSizecxx . . $ GtkPaperSize# *size) |
| 716 | { |
| 717 | return size->is_customcxx . . $ _GtkPaperSize#is_custom.; |
| 718 | } |
| 719 | |
| 720 | /** |
| 721 | * gtk_paper_size_is_ipp: |
| 722 | * @size: a `GtkPaperSize` object |
| 723 | * |
| 724 | * Returns %TRUE if @size is an IPP standard paper size. |
| 725 | * |
| 726 | * Returns: whether @size is not an IPP custom paper size. |
| 727 | **/ |
| 728 | gbooleancxx . . $ gboolean# |
| 729 | gtk_paper_size_is_ippcxx . . $ gtk_paper_size_is_ipp(6478976a97bbf7ba). (GtkPaperSizecxx . . $ GtkPaperSize# *size) |
| 730 | { |
| 731 | return size->is_ippcxx . . $ _GtkPaperSize#is_ipp.; |
| 732 | } |
| 733 | |
| 734 | /** |
| 735 | * gtk_paper_size_set_size: |
| 736 | * @size: a custom `GtkPaperSize` object |
| 737 | * @width: the new width in units of @unit |
| 738 | * @height: the new height in units of @unit |
| 739 | * @unit: the unit for @width and @height |
| 740 | * |
| 741 | * Changes the dimensions of a @size to @width x @height. |
| 742 | */ |
| 743 | void |
| 744 | gtk_paper_size_set_sizecxx . . $ gtk_paper_size_set_size(f06bf8d300474899). (GtkPaperSizecxx . . $ GtkPaperSize# *size, |
| 745 | double width, |
| 746 | double height, |
| 747 | GtkUnitcxx . . $ GtkUnit# unit) |
| 748 | { |
| 749 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (size != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 750 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (size->is_custom); |
| 751 | |
| 752 | size->widthcxx . . $ _GtkPaperSize#width. = _gtk_print_convert_to_mmcxx . . $ _gtk_print_convert_to_mm(22115c009b206bef). (width, unit); |
| 753 | size->heightcxx . . $ _GtkPaperSize#height. = _gtk_print_convert_to_mmcxx . . $ _gtk_print_convert_to_mm(22115c009b206bef). (height, unit); |
| 754 | } |
| 755 | |
| 756 | #define NL_PAPER_GETcxx . . $ `gtk/print/gtkpapersize.c:756:9`!(x) \ |
| 757 | ((union { char *string; unsigned int word; })nl_langinfo(x)).word |
| 758 | |
| 759 | /** |
| 760 | * gtk_paper_size_get_default: |
| 761 | * |
| 762 | * Returns the name of the default paper size, which |
| 763 | * depends on the current locale. |
| 764 | * |
| 765 | * Returns: the name of the default paper size. The string |
| 766 | * is owned by GTK and should not be modified. |
| 767 | */ |
| 768 | const char * |
| 769 | gtk_paper_size_get_defaultcxx . . $ gtk_paper_size_get_default(33a1f659e94feb42). (void) |
| 770 | { |
| 771 | char *locale, *freeme = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 772 | const char *paper_size; |
| 773 | |
| 774 | #if defined(HAVE__NL_PAPER_HEIGHTcxx . . $ `build/config.h:112:9`!) && defined(HAVE__NL_PAPER_WIDTHcxx . . $ `build/config.h:114:9`!) |
| 775 | { |
| 776 | int width = NL_PAPER_GETcxx . . $ `gtk/print/gtkpapersize.c:756:9`! (_NL_PAPER_WIDTH); |
| 777 | int height = NL_PAPER_GETcxx . . $ `gtk/print/gtkpapersize.c:756:9`! (_NL_PAPER_HEIGHT); |
| 778 | |
| 779 | if (width == 210 && height == 297) |
| 780 | return GTK_PAPER_NAME_A4cxx . . $ `gtk/print/gtkpapersize.h:49:9`!; |
| 781 | |
| 782 | if (width == 216 && height == 279) |
| 783 | return GTK_PAPER_NAME_LETTERcxx . . $ `gtk/print/gtkpapersize.h:70:9`!; |
| 784 | } |
| 785 | #endif |
| 786 | |
| 787 | #ifdef G_OS_WIN32 |
| 788 | freeme = locale = g_win32_getlocale (); |
| 789 | #elif defined(LC_PAPERcxx . . $ `<external>/3736975272097309885/locale.h:42:9`!) |
| 790 | locale = setlocalecxx . . $ setlocale(10ed28bce9115888).(LC_PAPERcxx . . $ `<external>/3736975272097309885/locale.h:42:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 791 | #else |
| 792 | locale = setlocale(LC_MESSAGES, NULL); |
| 793 | #endif |
| 794 | |
| 795 | if (!locale) |
| 796 | return GTK_PAPER_NAME_A4cxx . . $ `gtk/print/gtkpapersize.h:49:9`!; |
| 797 | |
| 798 | /* CLDR 1.8.1 |
| 799 | * http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/territory_language_information.html |
| 800 | */ |
| 801 | if (g_regex_match_simplecxx . . $ g_regex_match_simple(eef8024bfe6c84b0).("[^_.@]{2,3}_(BZ|CA|CL|CO|CR|GT|MX|NI|PA|PH|PR|SV|US|VE)", |
| 802 | locale, G_REGEX_ANCHOREDcxx . . $ G_REGEX_ANCHORED., G_REGEX_MATCH_ANCHOREDcxx . . $ G_REGEX_MATCH_ANCHORED.)) |
| 803 | paper_size = GTK_PAPER_NAME_LETTERcxx . . $ `gtk/print/gtkpapersize.h:70:9`!; |
| 804 | else |
| 805 | paper_size = GTK_PAPER_NAME_A4cxx . . $ `gtk/print/gtkpapersize.h:49:9`!; |
| 806 | |
| 807 | g_freecxx . . $ g_free(5d22bdacc48458e8). (freeme); |
| 808 | return paper_size; |
| 809 | } |
| 810 | |
| 811 | /* These get the default margins used for the paper size. Its |
| 812 | * larger than most printers margins, so that it will be within |
| 813 | * the imageble area on any printer. |
| 814 | * |
| 815 | * I’ve taken the actual values used from the OSX page setup dialog. |
| 816 | * I’m not sure exactly where they got these values for, but might |
| 817 | * correspond to this (from ghostscript docs): |
| 818 | * |
| 819 | * All DeskJets have 0.5 inches (1.27cm) of unprintable bottom margin, |
| 820 | * due to the mechanical arrangement used to grab the paper. Side margins |
| 821 | * are approximately 0.25 inches (0.64cm) for U.S. letter paper, and 0.15 |
| 822 | * inches (0.38cm) for A4. |
| 823 | */ |
| 824 | |
| 825 | /** |
| 826 | * gtk_paper_size_get_default_top_margin: |
| 827 | * @size: a `GtkPaperSize` object |
| 828 | * @unit: the unit for the return value, not %GTK_UNIT_NONE |
| 829 | * |
| 830 | * Gets the default top margin for the `GtkPaperSize`. |
| 831 | * |
| 832 | * Returns: the default top margin |
| 833 | */ |
| 834 | double |
| 835 | gtk_paper_size_get_default_top_margincxx . . $ gtk_paper_size_get_default_top_margin(b08cd94bdb6d8de0). (GtkPaperSizecxx . . $ GtkPaperSize# *size, |
| 836 | GtkUnitcxx . . $ GtkUnit# unit) |
| 837 | { |
| 838 | double margin; |
| 839 | |
| 840 | margin = _gtk_print_convert_to_mmcxx . . $ _gtk_print_convert_to_mm(22115c009b206bef). (0.25, GTK_UNIT_INCHcxx . . $ GTK_UNIT_INCH.); |
| 841 | return _gtk_print_convert_from_mmcxx . . $ _gtk_print_convert_from_mm(22115c009b206bef). (margin, unit); |
| 842 | } |
| 843 | |
| 844 | /** |
| 845 | * gtk_paper_size_get_default_bottom_margin: |
| 846 | * @size: a `GtkPaperSize` object |
| 847 | * @unit: the unit for the return value, not %GTK_UNIT_NONE |
| 848 | * |
| 849 | * Gets the default bottom margin for the `GtkPaperSize`. |
| 850 | * |
| 851 | * Returns: the default bottom margin |
| 852 | */ |
| 853 | double |
| 854 | gtk_paper_size_get_default_bottom_margincxx . . $ gtk_paper_size_get_default_bottom_margin(b08cd94bdb6d8de0). (GtkPaperSizecxx . . $ GtkPaperSize# *size, |
| 855 | GtkUnitcxx . . $ GtkUnit# unit) |
| 856 | { |
| 857 | double margin; |
| 858 | const char *name; |
| 859 | |
| 860 | margin = _gtk_print_convert_to_mmcxx . . $ _gtk_print_convert_to_mm(22115c009b206bef). (0.25, GTK_UNIT_INCHcxx . . $ GTK_UNIT_INCH.); |
| 861 | |
| 862 | name = gtk_paper_size_get_namecxx . . $ gtk_paper_size_get_name(987e11576a2cd2b3). (size); |
| 863 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88). (name, "na_letter") == 0 || |
| 864 | strcmpcxx . . $ strcmp(5ae29d726ae57f88). (name, "na_legal") == 0 || |
| 865 | strcmpcxx . . $ strcmp(5ae29d726ae57f88). (name, "iso_a4") == 0) |
| 866 | margin = _gtk_print_convert_to_mmcxx . . $ _gtk_print_convert_to_mm(22115c009b206bef). (0.56, GTK_UNIT_INCHcxx . . $ GTK_UNIT_INCH.); |
| 867 | |
| 868 | return _gtk_print_convert_from_mmcxx . . $ _gtk_print_convert_from_mm(22115c009b206bef). (margin, unit); |
| 869 | } |
| 870 | |
| 871 | /** |
| 872 | * gtk_paper_size_get_default_left_margin: |
| 873 | * @size: a `GtkPaperSize` object |
| 874 | * @unit: the unit for the return value, not %GTK_UNIT_NONE |
| 875 | * |
| 876 | * Gets the default left margin for the `GtkPaperSize`. |
| 877 | * |
| 878 | * Returns: the default left margin |
| 879 | */ |
| 880 | double |
| 881 | gtk_paper_size_get_default_left_margincxx . . $ gtk_paper_size_get_default_left_margin(b08cd94bdb6d8de0). (GtkPaperSizecxx . . $ GtkPaperSize# *size, |
| 882 | GtkUnitcxx . . $ GtkUnit# unit) |
| 883 | { |
| 884 | double margin; |
| 885 | |
| 886 | margin = _gtk_print_convert_to_mmcxx . . $ _gtk_print_convert_to_mm(22115c009b206bef). (0.25, GTK_UNIT_INCHcxx . . $ GTK_UNIT_INCH.); |
| 887 | return _gtk_print_convert_from_mmcxx . . $ _gtk_print_convert_from_mm(22115c009b206bef). (margin, unit); |
| 888 | } |
| 889 | |
| 890 | /** |
| 891 | * gtk_paper_size_get_default_right_margin: |
| 892 | * @size: a `GtkPaperSize` object |
| 893 | * @unit: the unit for the return value, not %GTK_UNIT_NONE |
| 894 | * |
| 895 | * Gets the default right margin for the `GtkPaperSize`. |
| 896 | * |
| 897 | * Returns: the default right margin |
| 898 | */ |
| 899 | double |
| 900 | gtk_paper_size_get_default_right_margincxx . . $ gtk_paper_size_get_default_right_margin(b08cd94bdb6d8de0). (GtkPaperSizecxx . . $ GtkPaperSize# *size, |
| 901 | GtkUnitcxx . . $ GtkUnit# unit) |
| 902 | { |
| 903 | double margin; |
| 904 | |
| 905 | margin = _gtk_print_convert_to_mmcxx . . $ _gtk_print_convert_to_mm(22115c009b206bef). (0.25, GTK_UNIT_INCHcxx . . $ GTK_UNIT_INCH.); |
| 906 | return _gtk_print_convert_from_mmcxx . . $ _gtk_print_convert_from_mm(22115c009b206bef). (margin, unit); |
| 907 | } |
| 908 | |
| 909 | /** |
| 910 | * gtk_paper_size_new_from_key_file: |
| 911 | * @key_file: the `GKeyFile` to retrieve the papersize from |
| 912 | * @group_name: (nullable): the name of the group in the key file to read, |
| 913 | * or %NULL to read the first group |
| 914 | * @error: (nullable): return location for an error |
| 915 | * |
| 916 | * Reads a paper size from the group @group_name in the key file |
| 917 | * @key_file. |
| 918 | * |
| 919 | * Returns: a new `GtkPaperSize` object with the restored paper size |
| 920 | */ |
| 921 | GtkPaperSizecxx . . $ GtkPaperSize# * |
| 922 | gtk_paper_size_new_from_key_filecxx . . $ gtk_paper_size_new_from_key_file(5d60e5b5a4649df0). (GKeyFilecxx . . $ GKeyFile# *key_file, |
| 923 | const char *group_name, |
| 924 | GErrorcxx . . $ GError# **error) |
| 925 | { |
| 926 | GtkPaperSizecxx . . $ GtkPaperSize# *paper_size = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 927 | char *name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 928 | char *ppd_name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 929 | char *display_name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 930 | char *freeme = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 931 | double width, height; |
| 932 | GErrorcxx . . $ GError# *err = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 933 | |
| 934 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (key_file != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 935 | |
| 936 | if (!group_name) |
| 937 | group_name = freeme = g_key_file_get_start_groupcxx . . $ g_key_file_get_start_group(8d2a0b702222111d). (key_file); |
| 938 | if (!group_name || !g_key_file_has_groupcxx . . $ g_key_file_has_group(59495d022e83e9e2). (key_file, group_name)) |
| 939 | { |
| 940 | g_set_error_literalcxx . . $ g_set_error_literal(af35e45b47ff535e). (error, |
| 941 | GTK_PRINT_ERRORcxx . . $ `gtk/print/gtkprintoperation.h:200:9`!, |
| 942 | GTK_PRINT_ERROR_INVALID_FILEcxx . . $ GTK_PRINT_ERROR_INVALID_FILE., |
| 943 | _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("Not a valid page setup file")); |
| 944 | goto out; |
| 945 | } |
| 946 | |
| 947 | #define GET_DOUBLEcxx . . $ `gtk/print/gtkpapersize.c:947:9`!(kf, group, name, v) \ |
| 948 | v = g_key_file_get_double (kf, group, name, &err); \ |
| 949 | if (err != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) \ |
| 950 | {\ |
| 951 | g_propagate_error (error, err);\ |
| 952 | goto out;\ |
| 953 | } |
| 954 | |
| 955 | GET_DOUBLEcxx . . $ `gtk/print/gtkpapersize.c:947:9`! (key_file, group_name, "Width", width); |
| 956 | GET_DOUBLEcxx . . $ `gtk/print/gtkpapersize.c:947:9`! (key_file, group_name, "Height", height); |
| 957 | |
| 958 | #undef GET_DOUBLEcxx . . $ `gtk/print/gtkpapersize.c:947:9`! |
| 959 | |
| 960 | name = g_key_file_get_stringcxx . . $ g_key_file_get_string(30132561f3054bb4). (key_file, group_name, |
| 961 | "Name", NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 962 | ppd_name = g_key_file_get_stringcxx . . $ g_key_file_get_string(30132561f3054bb4). (key_file, group_name, |
| 963 | "PPDName", NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 964 | display_name = g_key_file_get_stringcxx . . $ g_key_file_get_string(30132561f3054bb4). (key_file, group_name, |
| 965 | "DisplayName", NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 966 | /* Fallback for old ~/.gtk-custom-paper entries */ |
| 967 | if (!display_name) |
| 968 | display_name = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (name); |
| 969 | |
| 970 | if (ppd_name != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 971 | paper_size = gtk_paper_size_new_from_ppdcxx . . $ gtk_paper_size_new_from_ppd(ecab97cd4d05cd32). (ppd_name, |
| 972 | display_name, |
| 973 | _gtk_print_convert_from_mmcxx . . $ _gtk_print_convert_from_mm(22115c009b206bef). (width, GTK_UNIT_POINTScxx . . $ GTK_UNIT_POINTS.), |
| 974 | _gtk_print_convert_from_mmcxx . . $ _gtk_print_convert_from_mm(22115c009b206bef). (height, GTK_UNIT_POINTScxx . . $ GTK_UNIT_POINTS.)); |
| 975 | else if (name != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 976 | paper_size = gtk_paper_size_new_customcxx . . $ gtk_paper_size_new_custom(5f9034f12a6d1f1e). (name, display_name, |
| 977 | width, height, GTK_UNIT_MMcxx . . $ GTK_UNIT_MM.); |
| 978 | else |
| 979 | { |
| 980 | g_set_error_literalcxx . . $ g_set_error_literal(af35e45b47ff535e). (error, |
| 981 | GTK_PRINT_ERRORcxx . . $ `gtk/print/gtkprintoperation.h:200:9`!, |
| 982 | GTK_PRINT_ERROR_INVALID_FILEcxx . . $ GTK_PRINT_ERROR_INVALID_FILE., |
| 983 | _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("Not a valid page setup file")); |
| 984 | goto out; |
| 985 | } |
| 986 | |
| 987 | g_assertcxx . . $ `<external>/15287032793271088244/gtestutils.h:275:9`! (paper_size != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 988 | |
| 989 | out: |
| 990 | g_freecxx . . $ g_free(5d22bdacc48458e8). (ppd_name); |
| 991 | g_freecxx . . $ g_free(5d22bdacc48458e8). (name); |
| 992 | g_freecxx . . $ g_free(5d22bdacc48458e8). (display_name); |
| 993 | g_freecxx . . $ g_free(5d22bdacc48458e8). (freeme); |
| 994 | |
| 995 | return paper_size; |
| 996 | } |
| 997 | |
| 998 | /** |
| 999 | * gtk_paper_size_to_key_file: |
| 1000 | * @size: a `GtkPaperSize` |
| 1001 | * @key_file: the `GKeyFile` to save the paper size to |
| 1002 | * @group_name: the group to add the settings to in @key_file |
| 1003 | * |
| 1004 | * This function adds the paper size from @size to @key_file. |
| 1005 | */ |
| 1006 | void |
| 1007 | gtk_paper_size_to_key_filecxx . . $ gtk_paper_size_to_key_file(8334f48786e27f79). (GtkPaperSizecxx . . $ GtkPaperSize# *size, |
| 1008 | GKeyFilecxx . . $ GKeyFile# *key_file, |
| 1009 | const char *group_name) |
| 1010 | { |
| 1011 | const char *name, *ppd_name, *display_name; |
| 1012 | |
| 1013 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (size != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 1014 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (key_file != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 1015 | |
| 1016 | name = gtk_paper_size_get_namecxx . . $ gtk_paper_size_get_name(987e11576a2cd2b3). (size); |
| 1017 | display_name = gtk_paper_size_get_display_namecxx . . $ gtk_paper_size_get_display_name(987e11576a2cd2b3). (size); |
| 1018 | ppd_name = gtk_paper_size_get_ppd_namecxx . . $ gtk_paper_size_get_ppd_name(987e11576a2cd2b3). (size); |
| 1019 | |
| 1020 | if (ppd_name != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 1021 | g_key_file_set_stringcxx . . $ g_key_file_set_string(c55395ecd37921cb). (key_file, group_name, |
| 1022 | "PPDName", ppd_name); |
| 1023 | else |
| 1024 | g_key_file_set_stringcxx . . $ g_key_file_set_string(c55395ecd37921cb). (key_file, group_name, |
| 1025 | "Name", name); |
| 1026 | |
| 1027 | if (display_name) |
| 1028 | g_key_file_set_stringcxx . . $ g_key_file_set_string(c55395ecd37921cb). (key_file, group_name, |
| 1029 | "DisplayName", display_name); |
| 1030 | |
| 1031 | g_key_file_set_doublecxx . . $ g_key_file_set_double(829828794bf632e9). (key_file, group_name, |
| 1032 | "Width", gtk_paper_size_get_widthcxx . . $ gtk_paper_size_get_width(b08cd94bdb6d8de0). (size, GTK_UNIT_MMcxx . . $ GTK_UNIT_MM.)); |
| 1033 | g_key_file_set_doublecxx . . $ g_key_file_set_double(829828794bf632e9). (key_file, group_name, |
| 1034 | "Height", gtk_paper_size_get_heightcxx . . $ gtk_paper_size_get_height(b08cd94bdb6d8de0). (size, GTK_UNIT_MMcxx . . $ GTK_UNIT_MM.)); |
| 1035 | } |
| 1036 | |
| 1037 | /** |
| 1038 | * gtk_paper_size_to_gvariant: |
| 1039 | * @paper_size: a `GtkPaperSize` |
| 1040 | * |
| 1041 | * Serialize a paper size to an `a{sv}` variant. |
| 1042 | * |
| 1043 | * Returns: (transfer none): a new, floating, `GVariant` |
| 1044 | */ |
| 1045 | GVariantcxx . . $ GVariant# * |
| 1046 | gtk_paper_size_to_gvariantcxx . . $ gtk_paper_size_to_gvariant(c570d33f6d915754). (GtkPaperSizecxx . . $ GtkPaperSize# *paper_size) |
| 1047 | { |
| 1048 | const char *name; |
| 1049 | const char *ppd_name; |
| 1050 | const char *display_name; |
| 1051 | GVariantBuildercxx . . $ GVariantBuilder# builder; |
| 1052 | |
| 1053 | g_variant_builder_initcxx . . $ g_variant_builder_init(b7f11988e84a5f70). (&builder, G_VARIANT_TYPE_VARDICTcxx . . $ `<external>/14064154155447831270/gvarianttype.h:279:9`!); |
| 1054 | |
| 1055 | name = gtk_paper_size_get_namecxx . . $ gtk_paper_size_get_name(987e11576a2cd2b3). (paper_size); |
| 1056 | ppd_name = gtk_paper_size_get_ppd_namecxx . . $ gtk_paper_size_get_ppd_name(987e11576a2cd2b3). (paper_size); |
| 1057 | display_name = gtk_paper_size_get_display_namecxx . . $ gtk_paper_size_get_display_name(987e11576a2cd2b3). (paper_size); |
| 1058 | |
| 1059 | if (ppd_name != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 1060 | g_variant_builder_addcxx . . $ g_variant_builder_add(a422658e2ec2035a). (&builder, "{sv}", "PPDName", g_variant_new_stringcxx . . $ g_variant_new_string(8d35775da1697fc2). (ppd_name)); |
| 1061 | else |
| 1062 | g_variant_builder_addcxx . . $ g_variant_builder_add(a422658e2ec2035a). (&builder, "{sv}", "Name", g_variant_new_stringcxx . . $ g_variant_new_string(8d35775da1697fc2). (name)); |
| 1063 | |
| 1064 | if (display_name != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 1065 | g_variant_builder_addcxx . . $ g_variant_builder_add(a422658e2ec2035a). (&builder, "{sv}", "DisplayName", g_variant_new_stringcxx . . $ g_variant_new_string(8d35775da1697fc2). (display_name)); |
| 1066 | |
| 1067 | g_variant_builder_addcxx . . $ g_variant_builder_add(a422658e2ec2035a). (&builder, "{sv}", "Width", g_variant_new_doublecxx . . $ g_variant_new_double(e1eb538fbb0277a6). (gtk_paper_size_get_widthcxx . . $ gtk_paper_size_get_width(b08cd94bdb6d8de0). (paper_size, GTK_UNIT_MMcxx . . $ GTK_UNIT_MM.))); |
| 1068 | g_variant_builder_addcxx . . $ g_variant_builder_add(a422658e2ec2035a). (&builder, "{sv}", "Height", g_variant_new_doublecxx . . $ g_variant_new_double(e1eb538fbb0277a6). (gtk_paper_size_get_heightcxx . . $ gtk_paper_size_get_height(b08cd94bdb6d8de0). (paper_size, GTK_UNIT_MMcxx . . $ GTK_UNIT_MM.))); |
| 1069 | |
| 1070 | return g_variant_builder_endcxx . . $ g_variant_builder_end(6d60952e65fc2b86). (&builder); |
| 1071 | } |
| 1072 | |
| 1073 | /** |
| 1074 | * gtk_paper_size_new_from_gvariant: |
| 1075 | * @variant: an a{sv} `GVariant` |
| 1076 | * |
| 1077 | * Deserialize a paper size from a `GVariant`. |
| 1078 | * |
| 1079 | * The `GVariant must be in the format produced by |
| 1080 | * [[email protected]_gvariant]. |
| 1081 | * |
| 1082 | * Returns: (transfer full): a new `GtkPaperSize` object |
| 1083 | */ |
| 1084 | GtkPaperSizecxx . . $ GtkPaperSize# * |
| 1085 | gtk_paper_size_new_from_gvariantcxx . . $ gtk_paper_size_new_from_gvariant(8dd6d0d482f95e2d). (GVariantcxx . . $ GVariant# *variant) |
| 1086 | { |
| 1087 | GtkPaperSizecxx . . $ GtkPaperSize# *paper_size; |
| 1088 | const char *name; |
| 1089 | const char *ppd_name; |
| 1090 | const char *display_name; |
| 1091 | double width, height; |
| 1092 | |
| 1093 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (g_variant_is_of_type (variant, G_VARIANT_TYPE_VARDICTcxx . . $ `<external>/14064154155447831270/gvarianttype.h:279:9`!), NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 1094 | |
| 1095 | if (!g_variant_lookupcxx . . $ g_variant_lookup(7f27c6838ade8909). (variant, "Width", "d", &width) || |
| 1096 | !g_variant_lookupcxx . . $ g_variant_lookup(7f27c6838ade8909). (variant, "Height", "d", &height)) |
| 1097 | return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1098 | |
| 1099 | if (!g_variant_lookupcxx . . $ g_variant_lookup(7f27c6838ade8909). (variant, "Name", "&s", &name)) |
| 1100 | name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1101 | |
| 1102 | if (!g_variant_lookupcxx . . $ g_variant_lookup(7f27c6838ade8909). (variant, "PPDName", "&s", &ppd_name)) |
| 1103 | ppd_name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1104 | |
| 1105 | if (!g_variant_lookupcxx . . $ g_variant_lookup(7f27c6838ade8909). (variant, "DisplayName", "&s", &display_name)) |
| 1106 | display_name = name; |
| 1107 | |
| 1108 | if (ppd_name != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 1109 | paper_size = gtk_paper_size_new_from_ppdcxx . . $ gtk_paper_size_new_from_ppd(ecab97cd4d05cd32). (ppd_name, |
| 1110 | display_name, |
| 1111 | _gtk_print_convert_from_mmcxx . . $ _gtk_print_convert_from_mm(22115c009b206bef). (width, GTK_UNIT_POINTScxx . . $ GTK_UNIT_POINTS.), |
| 1112 | _gtk_print_convert_from_mmcxx . . $ _gtk_print_convert_from_mm(22115c009b206bef). (height, GTK_UNIT_POINTScxx . . $ GTK_UNIT_POINTS.)); |
| 1113 | else if (name != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 1114 | paper_size = gtk_paper_size_new_customcxx . . $ gtk_paper_size_new_custom(5f9034f12a6d1f1e). (name, display_name, |
| 1115 | width, height, GTK_UNIT_MMcxx . . $ GTK_UNIT_MM.); |
| 1116 | else |
| 1117 | paper_size = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1118 | |
| 1119 | return paper_size; |
| 1120 | } |