| 1 | /* |
| 2 | * Copyright © 2025 Red Hat, Inc |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Lesser General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2.1 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
| 15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 | * |
| 17 | * SPDX-License-Identifier: LGPL-2.1-or-later |
| 18 | * |
| 19 | * Authors: Matthias Clasen <[email protected]> |
| 20 | */ |
| 21 | |
| 22 | #include "alpha-editor.h"cxx . . $ `<file>/demos/icon-editor/alpha-editor.h`/ |
| 23 | #include "color-editor.h"cxx . . $ `<file>/demos/icon-editor/color-editor.h`/ |
| 24 | #include "color-paintable.h"cxx . . $ `<file>/demos/icon-editor/color-paintable.h`/ |
| 25 | |
| 26 | struct _ColorEditorcxx . . $ _ColorEditor# |
| 27 | { |
| 28 | GtkWidgetcxx . . $ GtkWidget# parent_instancecxx . . $ _ColorEditor#parent_instance.; |
| 29 | |
| 30 | unsigned int color_typecxx . . $ _ColorEditor#color_type.; |
| 31 | GdkRGBAcxx . . $ GdkRGBA# colorcxx . . $ _ColorEditor#color.; |
| 32 | |
| 33 | GtkDropDowncxx . . $ GtkDropDown# *paintcxx . . $ _ColorEditor#paint.; |
| 34 | GtkStackcxx . . $ GtkStack# *stackcxx . . $ _ColorEditor#stack.; |
| 35 | ColorPaintablecxx . . $ ColorPaintable# *indicatorcxx . . $ _ColorEditor#indicator.; |
| 36 | GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *customcxx . . $ _ColorEditor#custom.; |
| 37 | }; |
| 38 | |
| 39 | enumcxx . . $ $anonymous_type_60420981c9fa3416_0# |
| 40 | { |
| 41 | PROP_COLOR_TYPEcxx . . $ PROP_COLOR_TYPE. = 1, |
| 42 | PROP_SYMBOLICcxx . . $ PROP_SYMBOLIC., |
| 43 | PROP_COLORcxx . . $ PROP_COLOR., |
| 44 | PROP_ALPHAcxx . . $ PROP_ALPHA., |
| 45 | NUM_PROPERTIEScxx . . $ NUM_PROPERTIES., |
| 46 | }; |
| 47 | |
| 48 | static GParamSpeccxx . . $ GParamSpec# *propertiescxx . . $ properties.[NUM_PROPERTIEScxx . . $ NUM_PROPERTIES.]; |
| 49 | |
| 50 | /* {{{ Callbacks */ |
| 51 | |
| 52 | |
| 53 | /* }}} */ |
| 54 | /* {{{ GObject boilerplate */ |
| 55 | |
| 56 | struct _ColorEditorClasscxx . . $ _ColorEditorClass# |
| 57 | { |
| 58 | GtkWidgetClasscxx . . $ GtkWidgetClass# parent_classcxx . . $ _ColorEditorClass#parent_class.; |
| 59 | }; |
| 60 | |
| 61 | G_DEFINE_TYPEcxx . . $ `<external>/9567554376676449156/gtype.h:1834:9`! (ColorEditor, color_editor, GTK_TYPE_WIDGETcxx . . $ `gtk/gtkwidget.h:43:9`!) |
| 62 | |
| 63 | static void |
| 64 | color_editor_initcxx . . $ color_editor_init(7f2834a06cfdf7fa). (ColorEditorcxx . . $ ColorEditor# *self) |
| 65 | { |
| 66 | gtk_widget_init_templatecxx . . $ gtk_widget_init_template(d7cf858254b37903). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self)); |
| 67 | } |
| 68 | |
| 69 | static void |
| 70 | color_editor_set_propertycxx . . $ color_editor_set_property(d7c4bb29f36c0dc4). (GObjectcxx . . $ GObject# *object, |
| 71 | unsigned int prop_id, |
| 72 | const GValuecxx . . $ GValue# *value, |
| 73 | GParamSpeccxx . . $ GParamSpec# *pspec) |
| 74 | { |
| 75 | ColorEditorcxx . . $ ColorEditor# *self = COLOR_EDITORcxx . . $ COLOR_EDITOR(a78073d1627cd8d4). (object); |
| 76 | |
| 77 | switch (prop_id) |
| 78 | { |
| 79 | case PROP_COLOR_TYPEcxx . . $ PROP_COLOR_TYPE.: |
| 80 | color_editor_set_color_typecxx . . $ color_editor_set_color_type(8ba77d75b393685a). (self, g_value_get_uintcxx . . $ g_value_get_uint(1e175b1568bd83e1). (value)); |
| 81 | break; |
| 82 | |
| 83 | case PROP_COLORcxx . . $ PROP_COLOR.: |
| 84 | color_editor_set_colorcxx . . $ color_editor_set_color(eb6ffb3f21aa7815). (self, g_value_get_boxedcxx . . $ g_value_get_boxed(e12dff36056c2cce). (value)); |
| 85 | break; |
| 86 | |
| 87 | case PROP_ALPHAcxx . . $ PROP_ALPHA.: |
| 88 | color_editor_set_alphacxx . . $ color_editor_set_alpha(c360379a3c0c71f3). (self, g_value_get_floatcxx . . $ g_value_get_float(19582a908f876f88). (value)); |
| 89 | break; |
| 90 | |
| 91 | default: |
| 92 | G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (object, prop_id, pspec); |
| 93 | break; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | static void |
| 98 | color_editor_get_propertycxx . . $ color_editor_get_property(cee2c52f22407c66). (GObjectcxx . . $ GObject# *object, |
| 99 | unsigned int prop_id, |
| 100 | GValuecxx . . $ GValue# *value, |
| 101 | GParamSpeccxx . . $ GParamSpec# *pspec) |
| 102 | { |
| 103 | ColorEditorcxx . . $ ColorEditor# *self = COLOR_EDITORcxx . . $ COLOR_EDITOR(a78073d1627cd8d4). (object); |
| 104 | |
| 105 | switch (prop_id) |
| 106 | { |
| 107 | case PROP_COLOR_TYPEcxx . . $ PROP_COLOR_TYPE.: |
| 108 | g_value_set_uintcxx . . $ g_value_set_uint(f81c5c84daf56975). (value, self->color_typecxx . . $ _ColorEditor#color_type.); |
| 109 | break; |
| 110 | |
| 111 | case PROP_SYMBOLICcxx . . $ PROP_SYMBOLIC.: |
| 112 | g_value_set_enumcxx . . $ g_value_set_enum(b698c61e8e30c4ea). (value, CLAMPcxx . . $ `<external>/12741050725406041920/gmacros.h:984:9`! (self->color_type - 1, GTK_SYMBOLIC_COLOR_FOREGROUND, GTK_SYMBOLIC_COLOR_ACCENT)); |
| 113 | break; |
| 114 | |
| 115 | case PROP_COLORcxx . . $ PROP_COLOR.: |
| 116 | g_value_set_boxedcxx . . $ g_value_set_boxed(806599f585dac18b). (value, &self->colorcxx . . $ _ColorEditor#color.); |
| 117 | break; |
| 118 | |
| 119 | case PROP_ALPHAcxx . . $ PROP_ALPHA.: |
| 120 | g_value_set_floatcxx . . $ g_value_set_float(b22d5fe81e4f0ffb). (value, self->colorcxx . . $ _ColorEditor#color..alphacxx . . $ _GdkRGBA#alpha.); |
| 121 | break; |
| 122 | |
| 123 | default: |
| 124 | G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (object, prop_id, pspec); |
| 125 | break; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | static void |
| 130 | color_editor_disposecxx . . $ color_editor_dispose(6087475fa43034d3). (GObjectcxx . . $ GObject# *object) |
| 131 | { |
| 132 | gtk_widget_dispose_templatecxx . . $ gtk_widget_dispose_template(5521378f274ca76e). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (object), COLOR_EDITOR_TYPEcxx . . $ `demos/icon-editor/color-editor.h:27:9`!); |
| 133 | |
| 134 | G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (color_editor_parent_class)->disposecxx . . $ _GObjectClass#dispose. (object); |
| 135 | } |
| 136 | |
| 137 | static void |
| 138 | color_editor_finalizecxx . . $ color_editor_finalize(6087475fa43034d3). (GObjectcxx . . $ GObject# *object) |
| 139 | { |
| 140 | //ColorEditor *self = COLOR_EDITOR (object); |
| 141 | |
| 142 | G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (color_editor_parent_class)->finalizecxx . . $ _GObjectClass#finalize. (object); |
| 143 | } |
| 144 | |
| 145 | static void |
| 146 | color_editor_class_initcxx . . $ color_editor_class_init(9fcab717ec5cf5f9). (ColorEditorClasscxx . . $ ColorEditorClass# *class) |
| 147 | { |
| 148 | GObjectClasscxx . . $ GObjectClass# *object_class = G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (class); |
| 149 | GtkWidgetClasscxx . . $ GtkWidgetClass# *widget_class = GTK_WIDGET_CLASScxx . . $ `gtk/gtkwidget.h:45:9`! (class); |
| 150 | |
| 151 | g_type_ensurecxx . . $ g_type_ensure(2c44cd906ae4e829). (color_paintable_get_typecxx . . $ color_paintable_get_type(f708dce9a8856c70). ()); |
| 152 | g_type_ensurecxx . . $ g_type_ensure(2c44cd906ae4e829). (alpha_editor_get_typecxx . . $ alpha_editor_get_type(f708dce9a8856c70). ()); |
| 153 | |
| 154 | object_class->set_propertycxx . . $ _GObjectClass#set_property. = color_editor_set_propertycxx . . $ color_editor_set_property(d7c4bb29f36c0dc4).; |
| 155 | object_class->get_propertycxx . . $ _GObjectClass#get_property. = color_editor_get_propertycxx . . $ color_editor_get_property(cee2c52f22407c66).; |
| 156 | object_class->disposecxx . . $ _GObjectClass#dispose. = color_editor_disposecxx . . $ color_editor_dispose(6087475fa43034d3).; |
| 157 | object_class->finalizecxx . . $ _GObjectClass#finalize. = color_editor_finalizecxx . . $ color_editor_finalize(6087475fa43034d3).; |
| 158 | |
| 159 | propertiescxx . . $ properties.[PROP_COLOR_TYPEcxx . . $ PROP_COLOR_TYPE.] = |
| 160 | g_param_spec_uintcxx . . $ g_param_spec_uint(503a1013c8de17d5). ("color-type", 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`!, |
| 161 | 0, G_MAXUINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:40:9`!, 0, |
| 162 | G_PARAM_READWRITEcxx . . $ G_PARAM_READWRITE. | G_PARAM_STATIC_NAMEcxx . . $ G_PARAM_STATIC_NAME.); |
| 163 | |
| 164 | propertiescxx . . $ properties.[PROP_SYMBOLICcxx . . $ PROP_SYMBOLIC.] = |
| 165 | g_param_spec_enumcxx . . $ g_param_spec_enum(bfeb217b5dc6c0ac). ("symbolic", 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`!, |
| 166 | GTK_TYPE_SYMBOLIC_COLORcxx . . $ `build/gtk/gtktypebuiltins.h:222:9`!, GTK_SYMBOLIC_COLOR_FOREGROUNDcxx . . $ GTK_SYMBOLIC_COLOR_FOREGROUND., |
| 167 | G_PARAM_READABLEcxx . . $ G_PARAM_READABLE. | G_PARAM_STATIC_NAMEcxx . . $ G_PARAM_STATIC_NAME.); |
| 168 | |
| 169 | propertiescxx . . $ properties.[PROP_COLORcxx . . $ PROP_COLOR.] = |
| 170 | g_param_spec_boxedcxx . . $ g_param_spec_boxed(faf99966f027a127). ("color", 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`!, |
| 171 | GDK_TYPE_RGBAcxx . . $ `gdk/gdkrgba.h:43:9`!, |
| 172 | G_PARAM_READWRITEcxx . . $ G_PARAM_READWRITE. | G_PARAM_STATIC_NAMEcxx . . $ G_PARAM_STATIC_NAME.); |
| 173 | |
| 174 | propertiescxx . . $ properties.[PROP_ALPHAcxx . . $ PROP_ALPHA.] = |
| 175 | g_param_spec_floatcxx . . $ g_param_spec_float(62471560c2840e09). ("alpha", 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`!, |
| 176 | 0, 1, 1, |
| 177 | G_PARAM_READWRITEcxx . . $ G_PARAM_READWRITE. | G_PARAM_STATIC_NAMEcxx . . $ G_PARAM_STATIC_NAME.); |
| 178 | |
| 179 | g_object_class_install_propertiescxx . . $ g_object_class_install_properties(569d03e6a4088541). (object_class, NUM_PROPERTIEScxx . . $ NUM_PROPERTIES., propertiescxx . . $ properties.); |
| 180 | |
| 181 | gtk_widget_class_set_template_from_resourcecxx . . $ gtk_widget_class_set_template_from_resource(6333614c746ab65a). (widget_class, "/org/gtk/Shaper/color-editor.ui"); |
| 182 | |
| 183 | gtk_widget_class_bind_template_childcxx . . $ `gtk/gtkwidget.h:762:9`! (widget_class, ColorEditor, paint); |
| 184 | gtk_widget_class_bind_template_childcxx . . $ `gtk/gtkwidget.h:762:9`! (widget_class, ColorEditor, stack); |
| 185 | gtk_widget_class_bind_template_childcxx . . $ `gtk/gtkwidget.h:762:9`! (widget_class, ColorEditor, indicator); |
| 186 | gtk_widget_class_bind_template_childcxx . . $ `gtk/gtkwidget.h:762:9`! (widget_class, ColorEditor, custom); |
| 187 | |
| 188 | gtk_widget_class_set_css_namecxx . . $ gtk_widget_class_set_css_name(6333614c746ab65a). (widget_class, "ColorEditor"); |
| 189 | gtk_widget_class_set_layout_manager_typecxx . . $ gtk_widget_class_set_layout_manager_type(2a839cbf4b1b4191). (widget_class, GTK_TYPE_BOX_LAYOUTcxx . . $ `gtk/gtkboxlayout.h:30:9`!); |
| 190 | } |
| 191 | |
| 192 | /* }}} */ |
| 193 | /* {{{ Public API */ |
| 194 | |
| 195 | ColorEditorcxx . . $ ColorEditor# * |
| 196 | color_editor_newcxx . . $ color_editor_new(6d954c37e85cceef). (void) |
| 197 | { |
| 198 | return g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (COLOR_EDITOR_TYPEcxx . . $ `demos/icon-editor/color-editor.h:27:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 199 | } |
| 200 | |
| 201 | void |
| 202 | color_editor_set_color_typecxx . . $ color_editor_set_color_type(8ba77d75b393685a). (ColorEditorcxx . . $ ColorEditor# *self, |
| 203 | unsigned int color_type) |
| 204 | { |
| 205 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (COLOR_IS_EDITOR (self)); |
| 206 | |
| 207 | if (self->color_typecxx . . $ _ColorEditor#color_type. == color_type) |
| 208 | return; |
| 209 | |
| 210 | self->color_typecxx . . $ _ColorEditor#color_type. = color_type; |
| 211 | |
| 212 | gtk_drop_down_set_selectedcxx . . $ gtk_drop_down_set_selected(f3a2ae3789ff48db). (self->paintcxx . . $ _ColorEditor#paint., color_type); |
| 213 | |
| 214 | if (color_type == 0) |
| 215 | gtk_stack_set_visible_child_namecxx . . $ gtk_stack_set_visible_child_name(1f0a433b96d04ad5). (self->stackcxx . . $ _ColorEditor#stack., "none"); |
| 216 | else if (color_type - 1 <= GTK_SYMBOLIC_COLOR_ACCENTcxx . . $ GTK_SYMBOLIC_COLOR_ACCENT.) |
| 217 | gtk_stack_set_visible_child_namecxx . . $ gtk_stack_set_visible_child_name(1f0a433b96d04ad5). (self->stackcxx . . $ _ColorEditor#stack., "indicator"); |
| 218 | else |
| 219 | gtk_stack_set_visible_child_namecxx . . $ gtk_stack_set_visible_child_name(1f0a433b96d04ad5). (self->stackcxx . . $ _ColorEditor#stack., "custom"); |
| 220 | |
| 221 | g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_COLOR_TYPEcxx . . $ PROP_COLOR_TYPE.]); |
| 222 | g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_SYMBOLICcxx . . $ PROP_SYMBOLIC.]); |
| 223 | } |
| 224 | |
| 225 | unsigned int |
| 226 | color_editor_get_color_typecxx . . $ color_editor_get_color_type(693c556a03ef8e23). (ColorEditorcxx . . $ ColorEditor# *self) |
| 227 | { |
| 228 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (COLOR_IS_EDITOR (self), 0); |
| 229 | |
| 230 | return self->color_typecxx . . $ _ColorEditor#color_type.; |
| 231 | } |
| 232 | |
| 233 | void |
| 234 | color_editor_set_colorcxx . . $ color_editor_set_color(eb6ffb3f21aa7815). (ColorEditorcxx . . $ ColorEditor# *self, |
| 235 | const GdkRGBAcxx . . $ GdkRGBA# *color) |
| 236 | { |
| 237 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (COLOR_IS_EDITOR (self)); |
| 238 | |
| 239 | self->colorcxx . . $ _ColorEditor#color. = *color; |
| 240 | |
| 241 | gtk_color_dialog_button_set_rgbacxx . . $ gtk_color_dialog_button_set_rgba(3eb6e496fea7be80). (self->customcxx . . $ _ColorEditor#custom., &self->colorcxx . . $ _ColorEditor#color.); |
| 242 | |
| 243 | g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_COLORcxx . . $ PROP_COLOR.]); |
| 244 | g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_ALPHAcxx . . $ PROP_ALPHA.]); |
| 245 | } |
| 246 | |
| 247 | const GdkRGBAcxx . . $ GdkRGBA# * |
| 248 | color_editor_get_colorcxx . . $ color_editor_get_color(a93462a5084be9b8). (ColorEditorcxx . . $ ColorEditor# *self) |
| 249 | { |
| 250 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (COLOR_IS_EDITOR (self), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 251 | |
| 252 | return &self->colorcxx . . $ _ColorEditor#color.; |
| 253 | } |
| 254 | |
| 255 | void |
| 256 | color_editor_set_alphacxx . . $ color_editor_set_alpha(c360379a3c0c71f3). (ColorEditorcxx . . $ ColorEditor# *self, |
| 257 | float alpha) |
| 258 | { |
| 259 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (COLOR_IS_EDITOR (self)); |
| 260 | |
| 261 | if (self->colorcxx . . $ _ColorEditor#color..alphacxx . . $ _GdkRGBA#alpha. == alpha) |
| 262 | return; |
| 263 | |
| 264 | self->colorcxx . . $ _ColorEditor#color..alphacxx . . $ _GdkRGBA#alpha. = alpha; |
| 265 | |
| 266 | g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_ALPHAcxx . . $ PROP_ALPHA.]); |
| 267 | g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_COLORcxx . . $ PROP_COLOR.]); |
| 268 | } |
| 269 | |
| 270 | float |
| 271 | color_editor_get_alphacxx . . $ color_editor_get_alpha(1beb84a4b41b4fd2). (ColorEditorcxx . . $ ColorEditor# *self) |
| 272 | { |
| 273 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (COLOR_IS_EDITOR (self), 1); |
| 274 | |
| 275 | return self->colorcxx . . $ _ColorEditor#color..alphacxx . . $ _GdkRGBA#alpha.; |
| 276 | } |
| 277 | |
| 278 | /* }}} */ |
| 279 | |
| 280 | /* vim:set foldmethod=marker: */ |