| 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 void |
| 34 | quit_cbcxx . . $ quit_cb(c2a8b32df5332c4b). (GtkWidgetcxx . . $ GtkWidget# *widget, |
| 35 | gpointercxx . . $ gpointer# user_data) |
| 36 | { |
| 37 | gbooleancxx . . $ gboolean# *is_done = user_data; |
| 38 | |
| 39 | *is_done = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!; |
| 40 | |
| 41 | g_main_context_wakeupcxx . . $ g_main_context_wakeup(2c4f9bc69c34eb5d). (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 42 | } |
| 43 | |
| 44 | static void |
| 45 | show_filescxx . . $ show_files(a50bc8ce1fe710a2). (char **filenames, |
| 46 | gbooleancxx . . $ gboolean# decorated) |
| 47 | { |
| 48 | GtkWidgetcxx . . $ GtkWidget# *sw; |
| 49 | GtkWidgetcxx . . $ GtkWidget# *window; |
| 50 | gbooleancxx . . $ gboolean# done = FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 51 | GStringcxx . . $ GString# *title; |
| 52 | GtkWidgetcxx . . $ GtkWidget# *box; |
| 53 | |
| 54 | window = gtk_window_newcxx . . $ gtk_window_new(2369ce5e9f2c7dfd). (); |
| 55 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (window, "destroy", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (quit_cb), &done); |
| 56 | |
| 57 | title = g_string_newcxx . . $ g_string_new(e8737c02110bb79b). (""); |
| 58 | for (int i = 0; i < g_strv_lengthcxx . . $ g_strv_length(658e6f1ffe3b2f0c). (filenames); i++) |
| 59 | { |
| 60 | char *name = g_path_get_basenamecxx . . $ g_path_get_basename(a8b8e32347182212). (filenames[i]); |
| 61 | |
| 62 | if (title->lencxx . . $ _GString#len. > 0) |
| 63 | g_string_appendcxx . . $ `<external>/2906017559248664336/gstring.h:270:9`! (title, " / "); |
| 64 | g_string_appendcxx . . $ `<external>/2906017559248664336/gstring.h:270:9`! (title, name); |
| 65 | |
| 66 | g_freecxx . . $ g_free(5d22bdacc48458e8). (name); |
| 67 | } |
| 68 | |
| 69 | gtk_window_set_decoratedcxx . . $ gtk_window_set_decorated(3adb53e0a0f76453). (GTK_WINDOWcxx . . $ `gtk/gtkwindow.h:39:9`! (window), decorated); |
| 70 | gtk_window_set_resizablecxx . . $ gtk_window_set_resizable(3adb53e0a0f76453). (GTK_WINDOWcxx . . $ `gtk/gtkwindow.h:39:9`! (window), decorated); |
| 71 | |
| 72 | gtk_window_set_titlecxx . . $ gtk_window_set_title(3b72ed0988310abf). (GTK_WINDOWcxx . . $ `gtk/gtkwindow.h:39:9`! (window), title->strcxx . . $ _GString#str.); |
| 73 | g_string_freecxx . . $ `<external>/2906017559248664336/gstring.h:73:9`! (title, TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!); |
| 74 | |
| 75 | sw = gtk_scrolled_window_newcxx . . $ gtk_scrolled_window_new(2369ce5e9f2c7dfd). (); |
| 76 | gtk_scrolled_window_set_propagate_natural_widthcxx . . $ gtk_scrolled_window_set_propagate_natural_width(ac8ce4b30c63c143). (GTK_SCROLLED_WINDOWcxx . . $ `gtk/gtkscrolledwindow.h:37:9`! (sw), TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!); |
| 77 | gtk_scrolled_window_set_propagate_natural_heightcxx . . $ gtk_scrolled_window_set_propagate_natural_height(ac8ce4b30c63c143). (GTK_SCROLLED_WINDOWcxx . . $ `gtk/gtkscrolledwindow.h:37:9`! (sw), TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!); |
| 78 | |
| 79 | gtk_window_set_childcxx . . $ gtk_window_set_child(59a2a0eb4c9edf98). (GTK_WINDOWcxx . . $ `gtk/gtkwindow.h:39:9`! (window), sw); |
| 80 | |
| 81 | box = gtk_box_newcxx . . $ gtk_box_new(b19e0ce02196028e). (GTK_ORIENTATION_HORIZONTALcxx . . $ GTK_ORIENTATION_HORIZONTAL., 0); |
| 82 | |
| 83 | gtk_scrolled_window_set_childcxx . . $ gtk_scrolled_window_set_child(7cd145ba722b1a61). (GTK_SCROLLED_WINDOWcxx . . $ `gtk/gtkscrolledwindow.h:37:9`! (sw), box); |
| 84 | |
| 85 | for (int i = 0; i < g_strv_lengthcxx . . $ g_strv_length(658e6f1ffe3b2f0c). (filenames); i++) |
| 86 | { |
| 87 | GdkTexturecxx . . $ GdkTexture# *texture; |
| 88 | GtkWidgetcxx . . $ GtkWidget# *picture; |
| 89 | |
| 90 | texture = load_image_filecxx . . $ load_image_file(46c69d7b25d8ecce). (filenames[i]); |
| 91 | |
| 92 | picture = gtk_picture_new_for_paintablecxx . . $ gtk_picture_new_for_paintable(71b006fd44067db0). (GDK_PAINTABLEcxx . . $ GDK_PAINTABLE(2d62fee13419e51d). (texture)); |
| 93 | gtk_picture_set_can_shrinkcxx . . $ gtk_picture_set_can_shrink(e7c105470a48d1e9). (GTK_PICTUREcxx . . $ GTK_PICTURE(d0a1ffb7aecf6658). (picture), FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!); |
| 94 | gtk_picture_set_content_fitcxx . . $ gtk_picture_set_content_fit(839b70bfd1806b4d). (GTK_PICTUREcxx . . $ GTK_PICTURE(d0a1ffb7aecf6658). (picture), GTK_CONTENT_FIT_SCALE_DOWNcxx . . $ GTK_CONTENT_FIT_SCALE_DOWN.); |
| 95 | |
| 96 | if (i > 0) |
| 97 | gtk_box_appendcxx . . $ gtk_box_append(72f3a0256788ecaf). (GTK_BOXcxx . . $ `gtk/gtkbox.h:39:9`! (box), gtk_separator_newcxx . . $ gtk_separator_new(a67c098c83382a30). (GTK_ORIENTATION_VERTICALcxx . . $ GTK_ORIENTATION_VERTICAL.)); |
| 98 | |
| 99 | gtk_box_appendcxx . . $ gtk_box_append(72f3a0256788ecaf). (GTK_BOXcxx . . $ `gtk/gtkbox.h:39:9`! (box), picture); |
| 100 | |
| 101 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (texture); |
| 102 | } |
| 103 | |
| 104 | gtk_window_presentcxx . . $ gtk_window_present(f2417dd135ed86f3). (GTK_WINDOWcxx . . $ `gtk/gtkwindow.h:39:9`! (window)); |
| 105 | |
| 106 | while (!done) |
| 107 | g_main_context_iterationcxx . . $ g_main_context_iteration(53f508c65b8b33ab). (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!); |
| 108 | } |
| 109 | |
| 110 | void |
| 111 | do_showcxx . . $ do_show(327d1161970d8c3d). (int *argc, |
| 112 | const char ***argv) |
| 113 | { |
| 114 | GOptionContextcxx . . $ GOptionContext# *context; |
| 115 | char **filenames = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 116 | gbooleancxx . . $ gboolean# decorated = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!; |
| 117 | const GOptionEntrycxx . . $ GOptionEntry# entries[] = { |
| 118 | { "undecorated", 0, G_OPTION_FLAG_REVERSEcxx . . $ G_OPTION_FLAG_REVERSE., G_OPTION_ARG_NONEcxx . . $ G_OPTION_ARG_NONE., &decorated, N_cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:34:9`!("Don't add a titlebar"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! }, |
| 119 | |
| 120 | { 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…") }, |
| 121 | { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, } |
| 122 | }; |
| 123 | GErrorcxx . . $ GError# *error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 124 | |
| 125 | g_set_prgnamecxx . . $ g_set_prgname(85c52e162fed56f9). ("gtk4-image-tool show"); |
| 126 | context = g_option_context_newcxx . . $ g_option_context_new(a696d53710071c45). (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 127 | g_option_context_set_translation_domaincxx . . $ g_option_context_set_translation_domain(519928be97de28e3). (context, GETTEXT_PACKAGEcxx . . $ `build/config.h:8:9`!); |
| 128 | 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`!); |
| 129 | g_option_context_set_summarycxx . . $ g_option_context_set_summary(519928be97de28e3). (context, _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("Show one or more images.")); |
| 130 | |
| 131 | if (!g_option_context_parsecxx . . $ g_option_context_parse(e19b3ba917830101). (context, argc, (char ***)argv, &error)) |
| 132 | { |
| 133 | g_printerrcxx . . $ g_printerr(326aeb464d16410c). ("%s\n", error->messagecxx . . $ _GError#message.); |
| 134 | g_error_freecxx . . $ g_error_free(2ff7d11a2ecc01bd). (error); |
| 135 | exitcxx . . $ exit(3ca292c338df9bb3). (1); |
| 136 | } |
| 137 | |
| 138 | g_option_context_freecxx . . $ g_option_context_free(a7838fb7f565d7ae). (context); |
| 139 | |
| 140 | if (filenames == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 141 | { |
| 142 | g_printerrcxx . . $ g_printerr(326aeb464d16410c). (_cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("No image file specified\n")); |
| 143 | exitcxx . . $ exit(3ca292c338df9bb3). (1); |
| 144 | } |
| 145 | |
| 146 | show_filescxx . . $ show_files(a50bc8ce1fe710a2). (filenames, decorated); |
| 147 | |
| 148 | g_strfreevcxx . . $ g_strfreev(3ed91490e421178f). (filenames); |
| 149 | } |