| 1 | /* Copyright 2024 Red Hat, Inc. |
| 2 | * |
| 3 | * GTK is free software; you can redistribute it and/or modify it |
| 4 | * under the terms of the GNU Lesser General Public License as |
| 5 | * published by the Free Software Foundation; either version 2 of the |
| 6 | * License, or (at your option) any later version. |
| 7 | * |
| 8 | * GTK is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | * Lesser General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU Lesser General Public |
| 14 | * License along with GTK; see the file COPYING. If not, |
| 15 | * see <http://www.gnu.org/licenses/>. |
| 16 | * |
| 17 | * Author: Matthias Clasen |
| 18 | */ |
| 19 | |
| 20 | #include "config.h"cxx . . $ `<file>/build/config.h`/ |
| 21 | |
| 22 | #include <stdlib.h> |
| 23 | #include <string.h> |
| 24 | #include <errno.h> |
| 25 | |
| 26 | #include <glib/gi18n-lib.h> |
| 27 | #include <glib/gprintf.h> |
| 28 | #include <glib/gstdio.h> |
| 29 | #include <gtk/gtk.h>cxx . . $ `<file>/gtk/gtk.h`/ |
| 30 | #include "gtk-image-tool.h"cxx . . $ `<file>/tools/gtk-image-tool.h`/ |
| 31 | #include "gtk-tool-utils.h"cxx . . $ `<file>/tools/gtk-tool-utils.h`/ |
| 32 | |
| 33 | static const char * |
| 34 | get_format_namecxx . . $ get_format_name(e21a40f2338cd11b). (GdkMemoryFormatcxx . . $ GdkMemoryFormat# format) |
| 35 | { |
| 36 | GEnumClasscxx . . $ GEnumClass# *class; |
| 37 | GEnumValuecxx . . $ GEnumValue# *value; |
| 38 | const char *name; |
| 39 | |
| 40 | class = g_type_class_refcxx . . $ g_type_class_ref(bfcfa4d6b7f7ef64). (GDK_TYPE_MEMORY_FORMATcxx . . $ `build/gdk/gdkenumtypes.h:89:9`!); |
| 41 | value = g_enum_get_valuecxx . . $ g_enum_get_value(d91cd515990c3d81). (class, format); |
| 42 | name = value->value_nickcxx . . $ _GEnumValue#value_nick.; |
| 43 | g_type_class_unrefcxx . . $ g_type_class_unref(5d22bdacc48458e8). (class); |
| 44 | |
| 45 | return name; |
| 46 | } |
| 47 | |
| 48 | static void |
| 49 | file_infocxx . . $ file_info(85c52e162fed56f9). (const char *filename) |
| 50 | { |
| 51 | GdkTexturecxx . . $ GdkTexture# *texture; |
| 52 | char *name; |
| 53 | char *cicp; |
| 54 | |
| 55 | texture = load_image_filecxx . . $ load_image_file(46c69d7b25d8ecce). (filename); |
| 56 | |
| 57 | g_printcxx . . $ g_print(326aeb464d16410c). ("%s %dx%d\n", _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("Size:"), gdk_texture_get_widthcxx . . $ gdk_texture_get_width(84a21f334421d5dd). (texture), gdk_texture_get_heightcxx . . $ gdk_texture_get_height(84a21f334421d5dd). (texture)); |
| 58 | g_printcxx . . $ g_print(326aeb464d16410c). ("%s %s\n", _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("Format:"), get_format_namecxx . . $ get_format_name(e21a40f2338cd11b). (gdk_texture_get_formatcxx . . $ gdk_texture_get_format(1cda2554811ccb0b). (texture))); |
| 59 | |
| 60 | name = get_color_state_namecxx . . $ get_color_state_name(82596d8b7603bb24). (gdk_texture_get_color_statecxx . . $ gdk_texture_get_color_state(f424d3cc1ea19ea3). (texture)); |
| 61 | cicp = get_color_state_cicpcxx . . $ get_color_state_cicp(82596d8b7603bb24). (gdk_texture_get_color_statecxx . . $ gdk_texture_get_color_state(f424d3cc1ea19ea3). (texture)); |
| 62 | |
| 63 | if (name && cicp) |
| 64 | g_printcxx . . $ g_print(326aeb464d16410c). ("%s %s (cicp %s)\n", _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("Color state:"), name, cicp); |
| 65 | else if (cicp) |
| 66 | g_printcxx . . $ g_print(326aeb464d16410c). ("%s cicp %s\n", _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("Color state:"), cicp); |
| 67 | else |
| 68 | g_printcxx . . $ g_print(326aeb464d16410c). ("%s %s\n", _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("Color state:"), _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("unknown")); |
| 69 | |
| 70 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (texture); |
| 71 | } |
| 72 | |
| 73 | void |
| 74 | do_infocxx . . $ do_info(327d1161970d8c3d). (int *argc, |
| 75 | const char ***argv) |
| 76 | { |
| 77 | GOptionContextcxx . . $ GOptionContext# *context; |
| 78 | char **filenames = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 79 | const GOptionEntrycxx . . $ GOptionEntry# entries[] = { |
| 80 | { G_OPTION_REMAININGcxx . . $ `<external>/4822097754611438103/goption.h:312:9`!, 0, 0, G_OPTION_ARG_FILENAME_ARRAYcxx . . $ G_OPTION_ARG_FILENAME_ARRAY., &filenames, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, N_cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:34:9`!("FILE") }, |
| 81 | { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, } |
| 82 | }; |
| 83 | GErrorcxx . . $ GError# *error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 84 | |
| 85 | g_set_prgnamecxx . . $ g_set_prgname(85c52e162fed56f9). ("gtk4-image-tool info"); |
| 86 | context = g_option_context_newcxx . . $ g_option_context_new(a696d53710071c45). (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 87 | g_option_context_set_translation_domaincxx . . $ g_option_context_set_translation_domain(519928be97de28e3). (context, GETTEXT_PACKAGEcxx . . $ `build/config.h:8:9`!); |
| 88 | g_option_context_add_main_entriescxx . . $ g_option_context_add_main_entries(2b8a7b3623c14603). (context, entries, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 89 | g_option_context_set_summarycxx . . $ g_option_context_set_summary(519928be97de28e3). (context, _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("Provide information about the image.")); |
| 90 | |
| 91 | if (!g_option_context_parsecxx . . $ g_option_context_parse(e19b3ba917830101). (context, argc, (char ***)argv, &error)) |
| 92 | { |
| 93 | g_printerrcxx . . $ g_printerr(326aeb464d16410c). ("%s\n", error->messagecxx . . $ _GError#message.); |
| 94 | g_error_freecxx . . $ g_error_free(2ff7d11a2ecc01bd). (error); |
| 95 | exitcxx . . $ exit(3ca292c338df9bb3). (1); |
| 96 | } |
| 97 | |
| 98 | g_option_context_freecxx . . $ g_option_context_free(a7838fb7f565d7ae). (context); |
| 99 | |
| 100 | if (filenames == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 101 | { |
| 102 | g_printerrcxx . . $ g_printerr(326aeb464d16410c). (_cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("No image file specified\n")); |
| 103 | exitcxx . . $ exit(3ca292c338df9bb3). (1); |
| 104 | } |
| 105 | |
| 106 | if (g_strv_lengthcxx . . $ g_strv_length(658e6f1ffe3b2f0c). (filenames) > 1) |
| 107 | { |
| 108 | g_printerrcxx . . $ g_printerr(326aeb464d16410c). (_cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("Can only accept a single image file\n")); |
| 109 | exitcxx . . $ exit(3ca292c338df9bb3). (1); |
| 110 | } |
| 111 | |
| 112 | file_infocxx . . $ file_info(85c52e162fed56f9). (filenames[0]); |
| 113 | |
| 114 | g_strfreevcxx . . $ g_strfreev(3ed91490e421178f). (filenames); |
| 115 | } |