| 1 | /* |
| 2 | * GTK - The GIMP Toolkit |
| 3 | * Copyright (C) 2022 Red Hat, Inc. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * This Library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Library General Public License as |
| 8 | * published by the Free Software Foundation; either version 2 of the |
| 9 | * 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 | * Library General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Library 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 | |
| 22 | #include "gtkcolordialogbutton.h"cxx . . $ `<file>/gtk/gtkcolordialogbutton.h`/ |
| 23 | |
| 24 | #include "gtkbinlayout.h"cxx . . $ `<file>/gtk/gtkbinlayout.h`/ |
| 25 | #include "gtkbutton.h"cxx . . $ `<file>/gtk/gtkbutton.h`/ |
| 26 | #include "gtkcolorswatchprivate.h"cxx . . $ `<file>/gtk/gtkcolorswatchprivate.h`/ |
| 27 | #include "gtkdragsource.h"cxx . . $ `<file>/gtk/gtkdragsource.h`/ |
| 28 | #include "gtkdroptarget.h"cxx . . $ `<file>/gtk/gtkdroptarget.h`/ |
| 29 | #include <glib/gi18n-lib.h> |
| 30 | #include "gtkmain.h"cxx . . $ `<file>/gtk/gtkmain.h`/ |
| 31 | #include "gtkmarshalers.h"cxx . . $ `<file>/build/gtk/gtkmarshalers.h`/ |
| 32 | #include "gtkprivate.h"cxx . . $ `<file>/gtk/gtkprivate.h`/ |
| 33 | #include "gtksnapshot.h"cxx . . $ `<file>/gtk/gtksnapshot.h`/ |
| 34 | #include "gtkwidgetprivate.h"cxx . . $ `<file>/gtk/gtkwidgetprivate.h`/ |
| 35 | #include "gdk/gdkrgbaprivate.h"cxx . . $ `<file>/gdk/gdkrgbaprivate.h`/ |
| 36 | |
| 37 | |
| 38 | static gbooleancxx . . $ gboolean# dropcxx . . $ drop(b11ba3571ef33166). (GtkDropTargetcxx . . $ GtkDropTarget# *dest, |
| 39 | const GValuecxx . . $ GValue# *value, |
| 40 | double x, |
| 41 | double y, |
| 42 | GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self); |
| 43 | static GdkContentProvidercxx . . $ GdkContentProvider# * |
| 44 | drag_preparecxx . . $ drag_prepare(766df736ea33daa4). (GtkDragSourcecxx . . $ GtkDragSource# *source, |
| 45 | double x, |
| 46 | double y, |
| 47 | GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self); |
| 48 | static void activatedcxx . . $ activated(7352c7f531dca0ee). (GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self); |
| 49 | static void button_clickedcxx . . $ button_clicked(7352c7f531dca0ee). (GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self); |
| 50 | static void update_button_sensitivitycxx . . $ update_button_sensitivity(7352c7f531dca0ee). |
| 51 | (GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self); |
| 52 | |
| 53 | /** |
| 54 | * GtkColorDialogButton: |
| 55 | * |
| 56 | * Opens a color chooser dialog to select a color. |
| 57 | * |
| 58 | * <picture> |
| 59 | * <source srcset="color-button-dark.png" media="(prefers-color-scheme: dark)"> |
| 60 | * <img alt="An example GtkColorDialogButton" src="color-button.png"> |
| 61 | * </picture> |
| 62 | * |
| 63 | * It is suitable widget for selecting a color in a preference dialog. |
| 64 | * |
| 65 | * # CSS nodes |
| 66 | * |
| 67 | * ``` |
| 68 | * colorbutton |
| 69 | * ╰── button.color |
| 70 | * ╰── [content] |
| 71 | * ``` |
| 72 | * |
| 73 | * `GtkColorDialogButton` has a single CSS node with name colorbutton which |
| 74 | * contains a button node. To differentiate it from a plain `GtkButton`, |
| 75 | * it gets the .color style class. |
| 76 | * |
| 77 | * Since: 4.10 |
| 78 | */ |
| 79 | |
| 80 | /* {{{ GObject implementation */ |
| 81 | |
| 82 | struct _GtkColorDialogButtoncxx . . $ _GtkColorDialogButton# |
| 83 | { |
| 84 | GtkWidgetcxx . . $ GtkWidget# parent_instancecxx . . $ _GtkColorDialogButton#parent_instance.; |
| 85 | |
| 86 | GtkWidgetcxx . . $ GtkWidget# *buttoncxx . . $ _GtkColorDialogButton#button.; |
| 87 | GtkWidgetcxx . . $ GtkWidget# *swatchcxx . . $ _GtkColorDialogButton#swatch.; |
| 88 | |
| 89 | GtkColorDialogcxx . . $ GtkColorDialog# *dialogcxx . . $ _GtkColorDialogButton#dialog.; |
| 90 | GCancellablecxx . . $ GCancellable# *cancellablecxx . . $ _GtkColorDialogButton#cancellable.; |
| 91 | GdkRGBAcxx . . $ GdkRGBA# colorcxx . . $ _GtkColorDialogButton#color.; |
| 92 | }; |
| 93 | |
| 94 | /* Properties */ |
| 95 | enumcxx . . $ $anonymous_type_e0b1b4f183c3cf87_0# |
| 96 | { |
| 97 | PROP_DIALOGcxx . . $ PROP_DIALOG. = 1, |
| 98 | PROP_RGBAcxx . . $ PROP_RGBA., |
| 99 | NUM_PROPERTIEScxx . . $ NUM_PROPERTIES. |
| 100 | }; |
| 101 | |
| 102 | /* Signals */ |
| 103 | enumcxx . . $ $anonymous_type_e0b1b4f183c3cf87_1# |
| 104 | { |
| 105 | SIGNAL_ACTIVATEcxx . . $ SIGNAL_ACTIVATE. = 1, |
| 106 | NUM_SIGNALScxx . . $ NUM_SIGNALS. |
| 107 | }; |
| 108 | |
| 109 | static GParamSpeccxx . . $ GParamSpec# *propertiescxx . . $ properties.[NUM_PROPERTIEScxx . . $ NUM_PROPERTIES.]; |
| 110 | |
| 111 | static unsigned int color_dialog_button_signalscxx . . $ color_dialog_button_signals.[NUM_SIGNALScxx . . $ NUM_SIGNALS.] = { 0 }; |
| 112 | |
| 113 | G_DEFINE_TYPEcxx . . $ `<external>/9567554376676449156/gtype.h:1834:9`! (GtkColorDialogButton, gtk_color_dialog_button, GTK_TYPE_WIDGETcxx . . $ `gtk/gtkwidget.h:43:9`!) |
| 114 | |
| 115 | static void |
| 116 | gtk_color_dialog_button_initcxx . . $ gtk_color_dialog_button_init(7352c7f531dca0ee). (GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self) |
| 117 | { |
| 118 | PangoLayoutcxx . . $ PangoLayout# *layout; |
| 119 | PangoRectanglecxx . . $ PangoRectangle# rect; |
| 120 | GtkDragSourcecxx . . $ GtkDragSource# *source; |
| 121 | GtkDropTargetcxx . . $ GtkDropTarget# *dest; |
| 122 | |
| 123 | g_signal_connect_swappedcxx . . $ `<external>/15952772511652638895/gsignal.h:617:9`! (self, "activate", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (activated), self); |
| 124 | |
| 125 | self->colorcxx . . $ _GtkColorDialogButton#color. = GDK_RGBAcxx . . $ `gdk/gdkrgbaprivate.h:31:9`! ("00000000"); |
| 126 | |
| 127 | self->buttoncxx . . $ _GtkColorDialogButton#button. = gtk_button_newcxx . . $ gtk_button_new(2369ce5e9f2c7dfd). (); |
| 128 | g_signal_connect_swappedcxx . . $ `<external>/15952772511652638895/gsignal.h:617:9`! (self->button, "clicked", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (button_clicked), self); |
| 129 | gtk_widget_set_parentcxx . . $ gtk_widget_set_parent(4f261c0971c30e7). (self->buttoncxx . . $ _GtkColorDialogButton#button., GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self)); |
| 130 | |
| 131 | self->swatchcxx . . $ _GtkColorDialogButton#swatch. = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (GTK_TYPE_COLOR_SWATCHcxx . . $ `gtk/gtkcolorswatchprivate.h:24:9`!, |
| 132 | "accessible-role", GTK_ACCESSIBLE_ROLE_IMGcxx . . $ GTK_ACCESSIBLE_ROLE_IMG., |
| 133 | "selectable", FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!, |
| 134 | "has-menu", FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!, |
| 135 | "can-drag", FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!, |
| 136 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 137 | gtk_widget_set_can_focuscxx . . $ gtk_widget_set_can_focus(81f145f668a0074f). (self->swatchcxx . . $ _GtkColorDialogButton#swatch., FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!); |
| 138 | gtk_widget_remove_css_classcxx . . $ gtk_widget_remove_css_class(3e0616a87a6c51e5). (self->swatchcxx . . $ _GtkColorDialogButton#swatch., "activatable"); |
| 139 | |
| 140 | layout = gtk_widget_create_pango_layoutcxx . . $ gtk_widget_create_pango_layout(e1804973e9b72966). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self), "Black"); |
| 141 | pango_layout_get_pixel_extentscxx . . $ pango_layout_get_pixel_extents(387377cd6f424af2). (layout, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &rect); |
| 142 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (layout); |
| 143 | |
| 144 | gtk_widget_set_size_requestcxx . . $ gtk_widget_set_size_request(f5b8e75990cfac4b). (self->swatchcxx . . $ _GtkColorDialogButton#swatch., rect.widthcxx . . $ _PangoRectangle#width., rect.heightcxx . . $ _PangoRectangle#height.); |
| 145 | |
| 146 | gtk_button_set_childcxx . . $ gtk_button_set_child(8c03878ed7d55c1e). (GTK_BUTTONcxx . . $ `gtk/gtkbutton.h:37:9`! (self->button), self->swatchcxx . . $ _GtkColorDialogButton#swatch.); |
| 147 | |
| 148 | dest = gtk_drop_target_newcxx . . $ gtk_drop_target_new(15dfc0c8d9a4951a). (GDK_TYPE_RGBAcxx . . $ `gdk/gdkrgba.h:43:9`!, GDK_ACTION_COPYcxx . . $ GDK_ACTION_COPY.); |
| 149 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (dest, "drop", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (drop), self); |
| 150 | gtk_widget_add_controllercxx . . $ gtk_widget_add_controller(6d1262f1b7c2f702). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self->button), GTK_EVENT_CONTROLLERcxx . . $ `gtk/gtkeventcontroller.h:35:9`! (dest)); |
| 151 | |
| 152 | source = gtk_drag_source_newcxx . . $ gtk_drag_source_new(77897cffe031c7d7). (); |
| 153 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (source, "prepare", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (drag_prepare), self); |
| 154 | gtk_event_controller_set_propagation_phasecxx . . $ gtk_event_controller_set_propagation_phase(c64e5c05e4165a3c). (GTK_EVENT_CONTROLLERcxx . . $ `gtk/gtkeventcontroller.h:35:9`! (source), |
| 155 | GTK_PHASE_CAPTUREcxx . . $ GTK_PHASE_CAPTURE.); |
| 156 | gtk_widget_add_controllercxx . . $ gtk_widget_add_controller(6d1262f1b7c2f702). (self->buttoncxx . . $ _GtkColorDialogButton#button., GTK_EVENT_CONTROLLERcxx . . $ `gtk/gtkeventcontroller.h:35:9`! (source)); |
| 157 | gtk_widget_add_css_classcxx . . $ gtk_widget_add_css_class(3e0616a87a6c51e5). (self->buttoncxx . . $ _GtkColorDialogButton#button., "color"); |
| 158 | |
| 159 | gtk_color_dialog_button_set_rgbacxx . . $ gtk_color_dialog_button_set_rgba(3eb6e496fea7be80). (self, &(GdkRGBAcxx . . $ GdkRGBA#) { 0.75, 0.25, 0.25, 1.0 }); |
| 160 | |
| 161 | gtk_accessible_update_propertycxx . . $ gtk_accessible_update_property(7f02be67e42032aa). (GTK_ACCESSIBLEcxx . . $ GTK_ACCESSIBLE(4ecffd44f086533a). (self->buttoncxx . . $ _GtkColorDialogButton#button.), |
| 162 | GTK_ACCESSIBLE_PROPERTY_HAS_POPUPcxx . . $ GTK_ACCESSIBLE_PROPERTY_HAS_POPUP., TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!, |
| 163 | -1); |
| 164 | } |
| 165 | |
| 166 | static void |
| 167 | gtk_color_dialog_button_unrootcxx . . $ gtk_color_dialog_button_unroot(d7cf858254b37903). (GtkWidgetcxx . . $ GtkWidget# *widget) |
| 168 | { |
| 169 | GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self = GTK_COLOR_DIALOG_BUTTONcxx . . $ GTK_COLOR_DIALOG_BUTTON(f6c7ea2b58b6c0a0). (widget); |
| 170 | |
| 171 | if (self->cancellablecxx . . $ _GtkColorDialogButton#cancellable.) |
| 172 | { |
| 173 | g_cancellable_cancelcxx . . $ g_cancellable_cancel(ff72ec99b913803a). (self->cancellablecxx . . $ _GtkColorDialogButton#cancellable.); |
| 174 | g_clear_objectcxx . . $ `<external>/1341695927569185362/gobject.h:695:9`! (&self->cancellable); |
| 175 | update_button_sensitivitycxx . . $ update_button_sensitivity(7352c7f531dca0ee). (self); |
| 176 | } |
| 177 | |
| 178 | GTK_WIDGET_CLASScxx . . $ `gtk/gtkwidget.h:45:9`! (gtk_color_dialog_button_parent_class)->unrootcxx . . $ _GtkWidgetClass#unroot. (widget); |
| 179 | } |
| 180 | |
| 181 | static void |
| 182 | gtk_color_dialog_button_set_propertycxx . . $ gtk_color_dialog_button_set_property(d7c4bb29f36c0dc4). (GObjectcxx . . $ GObject# *object, |
| 183 | unsigned int param_id, |
| 184 | const GValuecxx . . $ GValue# *value, |
| 185 | GParamSpeccxx . . $ GParamSpec# *pspec) |
| 186 | { |
| 187 | GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self = GTK_COLOR_DIALOG_BUTTONcxx . . $ GTK_COLOR_DIALOG_BUTTON(f6c7ea2b58b6c0a0). (object); |
| 188 | |
| 189 | switch (param_id) |
| 190 | { |
| 191 | case PROP_DIALOGcxx . . $ PROP_DIALOG.: |
| 192 | gtk_color_dialog_button_set_dialogcxx . . $ gtk_color_dialog_button_set_dialog(76b7f0348448e7a0). (self, g_value_get_objectcxx . . $ g_value_get_object(e12dff36056c2cce). (value)); |
| 193 | break; |
| 194 | |
| 195 | case PROP_RGBAcxx . . $ PROP_RGBA.: |
| 196 | gtk_color_dialog_button_set_rgbacxx . . $ gtk_color_dialog_button_set_rgba(3eb6e496fea7be80). (self, g_value_get_boxedcxx . . $ g_value_get_boxed(e12dff36056c2cce). (value)); |
| 197 | break; |
| 198 | |
| 199 | default: |
| 200 | G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (object, param_id, pspec); |
| 201 | break; |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | static void |
| 206 | gtk_color_dialog_button_get_propertycxx . . $ gtk_color_dialog_button_get_property(cee2c52f22407c66). (GObjectcxx . . $ GObject# *object, |
| 207 | unsigned int param_id, |
| 208 | GValuecxx . . $ GValue# *value, |
| 209 | GParamSpeccxx . . $ GParamSpec# *pspec) |
| 210 | { |
| 211 | GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self = GTK_COLOR_DIALOG_BUTTONcxx . . $ GTK_COLOR_DIALOG_BUTTON(f6c7ea2b58b6c0a0). (object); |
| 212 | |
| 213 | switch (param_id) |
| 214 | { |
| 215 | case PROP_DIALOGcxx . . $ PROP_DIALOG.: |
| 216 | g_value_set_objectcxx . . $ g_value_set_object(e945b84c1e9702f). (value, self->dialogcxx . . $ _GtkColorDialogButton#dialog.); |
| 217 | break; |
| 218 | |
| 219 | case PROP_RGBAcxx . . $ PROP_RGBA.: |
| 220 | g_value_set_boxedcxx . . $ g_value_set_boxed(806599f585dac18b). (value, &self->colorcxx . . $ _GtkColorDialogButton#color.); |
| 221 | break; |
| 222 | |
| 223 | default: |
| 224 | G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (object, param_id, pspec); |
| 225 | break; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | static void |
| 230 | gtk_color_dialog_button_disposecxx . . $ gtk_color_dialog_button_dispose(6087475fa43034d3). (GObjectcxx . . $ GObject# *object) |
| 231 | { |
| 232 | GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self = GTK_COLOR_DIALOG_BUTTONcxx . . $ GTK_COLOR_DIALOG_BUTTON(f6c7ea2b58b6c0a0). (object); |
| 233 | |
| 234 | g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`! (&self->button, gtk_widget_unparent); |
| 235 | |
| 236 | G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (gtk_color_dialog_button_parent_class)->disposecxx . . $ _GObjectClass#dispose. (object); |
| 237 | } |
| 238 | |
| 239 | static void |
| 240 | gtk_color_dialog_button_finalizecxx . . $ gtk_color_dialog_button_finalize(6087475fa43034d3). (GObjectcxx . . $ GObject# *object) |
| 241 | { |
| 242 | GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self = GTK_COLOR_DIALOG_BUTTONcxx . . $ GTK_COLOR_DIALOG_BUTTON(f6c7ea2b58b6c0a0). (object); |
| 243 | |
| 244 | g_assertcxx . . $ `<external>/15287032793271088244/gtestutils.h:275:9`! (self->cancellable == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 245 | g_clear_objectcxx . . $ `<external>/1341695927569185362/gobject.h:695:9`! (&self->dialog); |
| 246 | |
| 247 | G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (gtk_color_dialog_button_parent_class)->finalizecxx . . $ _GObjectClass#finalize. (object); |
| 248 | } |
| 249 | |
| 250 | static void |
| 251 | gtk_color_dialog_button_class_initcxx . . $ gtk_color_dialog_button_class_init(c0de4dfef5d9cd3c). (GtkColorDialogButtonClasscxx . . $ GtkColorDialogButtonClass# *class) |
| 252 | { |
| 253 | GObjectClasscxx . . $ GObjectClass# *object_class = G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (class); |
| 254 | GtkWidgetClasscxx . . $ GtkWidgetClass# *widget_class = GTK_WIDGET_CLASScxx . . $ `gtk/gtkwidget.h:45:9`! (class); |
| 255 | |
| 256 | object_class->get_propertycxx . . $ _GObjectClass#get_property. = gtk_color_dialog_button_get_propertycxx . . $ gtk_color_dialog_button_get_property(cee2c52f22407c66).; |
| 257 | object_class->set_propertycxx . . $ _GObjectClass#set_property. = gtk_color_dialog_button_set_propertycxx . . $ gtk_color_dialog_button_set_property(d7c4bb29f36c0dc4).; |
| 258 | object_class->disposecxx . . $ _GObjectClass#dispose. = gtk_color_dialog_button_disposecxx . . $ gtk_color_dialog_button_dispose(6087475fa43034d3).; |
| 259 | object_class->finalizecxx . . $ _GObjectClass#finalize. = gtk_color_dialog_button_finalizecxx . . $ gtk_color_dialog_button_finalize(6087475fa43034d3).; |
| 260 | |
| 261 | widget_class->grab_focuscxx . . $ _GtkWidgetClass#grab_focus. = gtk_widget_grab_focus_childcxx . . $ gtk_widget_grab_focus_child(9247ef2dc26c5426).; |
| 262 | widget_class->focuscxx . . $ _GtkWidgetClass#focus. = gtk_widget_focus_childcxx . . $ gtk_widget_focus_child(8bb1c65c821a69cd).; |
| 263 | widget_class->unrootcxx . . $ _GtkWidgetClass#unroot. = gtk_color_dialog_button_unrootcxx . . $ gtk_color_dialog_button_unroot(d7cf858254b37903).; |
| 264 | |
| 265 | /** |
| 266 | * GtkColorDialogButton:dialog: |
| 267 | * |
| 268 | * The `GtkColorDialog` that contains parameters for |
| 269 | * the color chooser dialog. |
| 270 | * |
| 271 | * Since: 4.10 |
| 272 | */ |
| 273 | propertiescxx . . $ properties.[PROP_DIALOGcxx . . $ PROP_DIALOG.] = |
| 274 | g_param_spec_objectcxx . . $ g_param_spec_object(faf99966f027a127). ("dialog", 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`!, |
| 275 | GTK_TYPE_COLOR_DIALOGcxx . . $ `gtk/gtkcolordialog.h:30:9`!, |
| 276 | G_PARAM_READWRITEcxx . . $ G_PARAM_READWRITE.|G_PARAM_STATIC_STRINGScxx . . $ `<external>/7453068347527694854/gparam.h:187:9`!|G_PARAM_EXPLICIT_NOTIFYcxx . . $ G_PARAM_EXPLICIT_NOTIFY.); |
| 277 | |
| 278 | /** |
| 279 | * GtkColorDialogButton:rgba: |
| 280 | * |
| 281 | * The selected color. |
| 282 | * |
| 283 | * This property can be set to give the button its initial |
| 284 | * color, and it will be updated to reflect the users choice |
| 285 | * in the color chooser dialog. |
| 286 | * |
| 287 | * Listen to `notify::rgba` to get informed about changes |
| 288 | * to the buttons color. |
| 289 | * |
| 290 | * Since: 4.10 |
| 291 | */ |
| 292 | propertiescxx . . $ properties.[PROP_RGBAcxx . . $ PROP_RGBA.] = |
| 293 | g_param_spec_boxedcxx . . $ g_param_spec_boxed(faf99966f027a127). ("rgba", 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`!, |
| 294 | GDK_TYPE_RGBAcxx . . $ `gdk/gdkrgba.h:43:9`!, |
| 295 | G_PARAM_READWRITEcxx . . $ G_PARAM_READWRITE.|G_PARAM_STATIC_STRINGScxx . . $ `<external>/7453068347527694854/gparam.h:187:9`!|G_PARAM_EXPLICIT_NOTIFYcxx . . $ G_PARAM_EXPLICIT_NOTIFY.); |
| 296 | |
| 297 | g_object_class_install_propertiescxx . . $ g_object_class_install_properties(569d03e6a4088541). (object_class, NUM_PROPERTIEScxx . . $ NUM_PROPERTIES., propertiescxx . . $ properties.); |
| 298 | |
| 299 | /** |
| 300 | * GtkColorDialogButton::activate: |
| 301 | * @widget: the object which received the signal |
| 302 | * |
| 303 | * Emitted when the color dialog button is activated. |
| 304 | * |
| 305 | * The `::activate` signal on `GtkColorDialogButton` is an action signal |
| 306 | * and emitting it causes the button to pop up its dialog. |
| 307 | * |
| 308 | * Since: 4.14 |
| 309 | */ |
| 310 | color_dialog_button_signalscxx . . $ color_dialog_button_signals.[SIGNAL_ACTIVATEcxx . . $ SIGNAL_ACTIVATE.] = |
| 311 | g_signal_newcxx . . $ g_signal_new(b0aa5e8090fb95c0). (I_cxx . . $ `gdk/gdkprivate.h:35:9`! ("activate"), |
| 312 | G_TYPE_FROM_CLASScxx . . $ `<external>/9567554376676449156/gtype.h:657:9`! (class), |
| 313 | G_SIGNAL_RUN_FIRSTcxx . . $ G_SIGNAL_RUN_FIRST. | G_SIGNAL_ACTIONcxx . . $ G_SIGNAL_ACTION., |
| 314 | 0, |
| 315 | 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`!, |
| 316 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 317 | G_TYPE_NONEcxx . . $ `<external>/9567554376676449156/gtype.h:72:9`!, 0); |
| 318 | |
| 319 | gtk_widget_class_set_activate_signalcxx . . $ gtk_widget_class_set_activate_signal(53d965ee418c3db). (widget_class, color_dialog_button_signalscxx . . $ color_dialog_button_signals.[SIGNAL_ACTIVATEcxx . . $ SIGNAL_ACTIVATE.]); |
| 320 | gtk_widget_class_set_layout_manager_typecxx . . $ gtk_widget_class_set_layout_manager_type(2a839cbf4b1b4191). (widget_class, GTK_TYPE_BIN_LAYOUTcxx . . $ `gtk/gtkbinlayout.h:23:9`!); |
| 321 | gtk_widget_class_set_css_namecxx . . $ gtk_widget_class_set_css_name(6333614c746ab65a). (widget_class, "colorbutton"); |
| 322 | gtk_widget_class_set_accessible_rolecxx . . $ gtk_widget_class_set_accessible_role(a3df1a29abf28273). (widget_class, GTK_ACCESSIBLE_ROLE_GROUPcxx . . $ GTK_ACCESSIBLE_ROLE_GROUP.); |
| 323 | } |
| 324 | |
| 325 | /* }}} */ |
| 326 | /* {{{ Private API, callbacks */ |
| 327 | |
| 328 | static guintcxx . . $ guint# |
| 329 | scale_roundcxx . . $ scale_round(bbe5647f7328e4ca). (double value, |
| 330 | double scale) |
| 331 | { |
| 332 | value = floor (value * scale + 0.5); |
| 333 | value = CLAMPcxx . . $ `<external>/12741050725406041920/gmacros.h:984:9`! (value, 0, scale); |
| 334 | return (guintcxx . . $ guint#)value; |
| 335 | } |
| 336 | |
| 337 | static char * |
| 338 | accessible_color_namecxx . . $ accessible_color_name(48aa22ea2de6087c). (const GdkRGBAcxx . . $ GdkRGBA# *color) |
| 339 | { |
| 340 | if (color->alphacxx . . $ _GdkRGBA#alpha. < 1.0) |
| 341 | return g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). (_cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("Red %d%%, Green %d%%, Blue %d%%, Alpha %d%%"), |
| 342 | scale_roundcxx . . $ scale_round(bbe5647f7328e4ca). (color->redcxx . . $ _GdkRGBA#red., 100), |
| 343 | scale_roundcxx . . $ scale_round(bbe5647f7328e4ca). (color->greencxx . . $ _GdkRGBA#green., 100), |
| 344 | scale_roundcxx . . $ scale_round(bbe5647f7328e4ca). (color->bluecxx . . $ _GdkRGBA#blue., 100), |
| 345 | scale_roundcxx . . $ scale_round(bbe5647f7328e4ca). (color->alphacxx . . $ _GdkRGBA#alpha., 100)); |
| 346 | else |
| 347 | return g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). (_cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("Red %d%%, Green %d%%, Blue %d%%"), |
| 348 | scale_roundcxx . . $ scale_round(bbe5647f7328e4ca). (color->redcxx . . $ _GdkRGBA#red., 100), |
| 349 | scale_roundcxx . . $ scale_round(bbe5647f7328e4ca). (color->greencxx . . $ _GdkRGBA#green., 100), |
| 350 | scale_roundcxx . . $ scale_round(bbe5647f7328e4ca). (color->bluecxx . . $ _GdkRGBA#blue., 100)); |
| 351 | } |
| 352 | |
| 353 | static gbooleancxx . . $ gboolean# |
| 354 | dropcxx . . $ drop(b11ba3571ef33166). (GtkDropTargetcxx . . $ GtkDropTarget# *dest, |
| 355 | const GValuecxx . . $ GValue# *value, |
| 356 | double x, |
| 357 | double y, |
| 358 | GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self) |
| 359 | { |
| 360 | GdkRGBAcxx . . $ GdkRGBA# *color = g_value_get_boxedcxx . . $ g_value_get_boxed(e12dff36056c2cce). (value); |
| 361 | |
| 362 | gtk_color_dialog_button_set_rgbacxx . . $ gtk_color_dialog_button_set_rgba(3eb6e496fea7be80). (self, color); |
| 363 | |
| 364 | return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!; |
| 365 | } |
| 366 | |
| 367 | static GdkContentProvidercxx . . $ GdkContentProvider# * |
| 368 | drag_preparecxx . . $ drag_prepare(766df736ea33daa4). (GtkDragSourcecxx . . $ GtkDragSource# *source, |
| 369 | double x, |
| 370 | double y, |
| 371 | GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self) |
| 372 | { |
| 373 | GdkRGBAcxx . . $ GdkRGBA# color; |
| 374 | |
| 375 | gtk_color_swatch_get_rgbacxx . . $ gtk_color_swatch_get_rgba(9ec6de64b16db87d). (GTK_COLOR_SWATCHcxx . . $ `gtk/gtkcolorswatchprivate.h:25:9`! (self->swatch), &color); |
| 376 | |
| 377 | return gdk_content_provider_new_typedcxx . . $ gdk_content_provider_new_typed(79390b36b894833d). (GDK_TYPE_RGBAcxx . . $ `gdk/gdkrgba.h:43:9`!, &color); |
| 378 | } |
| 379 | |
| 380 | static void |
| 381 | update_button_sensitivitycxx . . $ update_button_sensitivity(7352c7f531dca0ee). (GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self) |
| 382 | { |
| 383 | if (self->buttoncxx . . $ _GtkColorDialogButton#button.) |
| 384 | gtk_widget_set_sensitivecxx . . $ gtk_widget_set_sensitive(81f145f668a0074f). (self->buttoncxx . . $ _GtkColorDialogButton#button., |
| 385 | self->dialogcxx . . $ _GtkColorDialogButton#dialog. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && self->cancellablecxx . . $ _GtkColorDialogButton#cancellable. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 386 | } |
| 387 | |
| 388 | static void |
| 389 | color_chosencxx . . $ color_chosen(aa1d200d824d915d). (GObjectcxx . . $ GObject# *source, |
| 390 | GAsyncResultcxx . . $ GAsyncResult# *result, |
| 391 | gpointercxx . . $ gpointer# data) |
| 392 | { |
| 393 | GtkColorDialogcxx . . $ GtkColorDialog# *dialog = GTK_COLOR_DIALOGcxx . . $ GTK_COLOR_DIALOG(8867a3132c971136). (source); |
| 394 | GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self = data; |
| 395 | GdkRGBAcxx . . $ GdkRGBA# *color; |
| 396 | |
| 397 | color = gtk_color_dialog_choose_rgba_finishcxx . . $ gtk_color_dialog_choose_rgba_finish(427baec8a2b0ccfd). (dialog, result, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 398 | if (color) |
| 399 | { |
| 400 | gtk_color_dialog_button_set_rgbacxx . . $ gtk_color_dialog_button_set_rgba(3eb6e496fea7be80). (self, color); |
| 401 | gdk_rgba_freecxx . . $ gdk_rgba_free(3f3ea8ff31dcaa39). (color); |
| 402 | } |
| 403 | |
| 404 | g_clear_objectcxx . . $ `<external>/1341695927569185362/gobject.h:695:9`! (&self->cancellable); |
| 405 | update_button_sensitivitycxx . . $ update_button_sensitivity(7352c7f531dca0ee). (self); |
| 406 | } |
| 407 | |
| 408 | static void |
| 409 | activatedcxx . . $ activated(7352c7f531dca0ee). (GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self) |
| 410 | { |
| 411 | gtk_widget_activatecxx . . $ gtk_widget_activate(9247ef2dc26c5426). (self->buttoncxx . . $ _GtkColorDialogButton#button.); |
| 412 | } |
| 413 | |
| 414 | static void |
| 415 | button_clickedcxx . . $ button_clicked(7352c7f531dca0ee). (GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self) |
| 416 | { |
| 417 | GtkRootcxx . . $ GtkRoot# *root = gtk_widget_get_rootcxx . . $ gtk_widget_get_root(978ce13b0a79da4). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self)); |
| 418 | GtkWindowcxx . . $ GtkWindow# *parent = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 419 | |
| 420 | g_assertcxx . . $ `<external>/15287032793271088244/gtestutils.h:275:9`! (self->cancellable == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 421 | self->cancellablecxx . . $ _GtkColorDialogButton#cancellable. = g_cancellable_newcxx . . $ g_cancellable_new(decaddcb7afe0309). (); |
| 422 | |
| 423 | update_button_sensitivitycxx . . $ update_button_sensitivity(7352c7f531dca0ee). (self); |
| 424 | |
| 425 | if (GTK_IS_WINDOWcxx . . $ `gtk/gtkwindow.h:41:9`! (root)) |
| 426 | parent = GTK_WINDOWcxx . . $ `gtk/gtkwindow.h:39:9`! (root); |
| 427 | |
| 428 | gtk_color_dialog_choose_rgbacxx . . $ gtk_color_dialog_choose_rgba(637e01c49235d7d8). (self->dialogcxx . . $ _GtkColorDialogButton#dialog., parent, &self->colorcxx . . $ _GtkColorDialogButton#color., |
| 429 | self->cancellablecxx . . $ _GtkColorDialogButton#cancellable., color_chosencxx . . $ color_chosen(aa1d200d824d915d)., self); |
| 430 | } |
| 431 | |
| 432 | /* }}} */ |
| 433 | /* {{{ Constructor */ |
| 434 | |
| 435 | /** |
| 436 | * gtk_color_dialog_button_new: |
| 437 | * @dialog: (nullable) (transfer full): the `GtkColorDialog` to use |
| 438 | * |
| 439 | * Creates a new `GtkColorDialogButton` with the |
| 440 | * given `GtkColorDialog`. |
| 441 | * |
| 442 | * You can pass `NULL` to this function and set a `GtkColorDialog` |
| 443 | * later. The button will be insensitive until that happens. |
| 444 | * |
| 445 | * Returns: the new `GtkColorDialogButton` |
| 446 | * |
| 447 | * Since: 4.10 |
| 448 | */ |
| 449 | GtkWidgetcxx . . $ GtkWidget# * |
| 450 | gtk_color_dialog_button_newcxx . . $ gtk_color_dialog_button_new(f703020d398176e4). (GtkColorDialogcxx . . $ GtkColorDialog# *dialog) |
| 451 | { |
| 452 | GtkWidgetcxx . . $ GtkWidget# *self; |
| 453 | |
| 454 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (dialog == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || GTK_IS_COLOR_DIALOG (dialog), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 455 | |
| 456 | self = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (GTK_TYPE_COLOR_DIALOG_BUTTONcxx . . $ `gtk/gtkcolordialogbutton.h:31:9`!, |
| 457 | "dialog", dialog, |
| 458 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 459 | |
| 460 | g_clear_objectcxx . . $ `<external>/1341695927569185362/gobject.h:695:9`! (&dialog); |
| 461 | |
| 462 | return self; |
| 463 | } |
| 464 | |
| 465 | /* }}} */ |
| 466 | /* {{{ Getters and setters */ |
| 467 | |
| 468 | /** |
| 469 | * gtk_color_dialog_button_get_dialog: |
| 470 | * @self: a `GtkColorDialogButton` |
| 471 | * |
| 472 | * Returns the `GtkColorDialog` of @self. |
| 473 | * |
| 474 | * Returns: (transfer none) (nullable): the `GtkColorDialog` |
| 475 | * |
| 476 | * Since: 4.10 |
| 477 | */ |
| 478 | GtkColorDialogcxx . . $ GtkColorDialog# * |
| 479 | gtk_color_dialog_button_get_dialogcxx . . $ gtk_color_dialog_button_get_dialog(3c96932a4dfd210b). (GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self) |
| 480 | { |
| 481 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_COLOR_DIALOG_BUTTON (self), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 482 | |
| 483 | return self->dialogcxx . . $ _GtkColorDialogButton#dialog.; |
| 484 | } |
| 485 | |
| 486 | /** |
| 487 | * gtk_color_dialog_button_set_dialog: |
| 488 | * @self: a `GtkColorDialogButton` |
| 489 | * @dialog: the new `GtkColorDialog` |
| 490 | * |
| 491 | * Sets a `GtkColorDialog` object to use for |
| 492 | * creating the color chooser dialog that is |
| 493 | * presented when the user clicks the button. |
| 494 | * |
| 495 | * Since: 4.10 |
| 496 | */ |
| 497 | void |
| 498 | gtk_color_dialog_button_set_dialogcxx . . $ gtk_color_dialog_button_set_dialog(76b7f0348448e7a0). (GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self, |
| 499 | GtkColorDialogcxx . . $ GtkColorDialog# *dialog) |
| 500 | { |
| 501 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_COLOR_DIALOG_BUTTON (self)); |
| 502 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (dialog == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || GTK_IS_COLOR_DIALOG (dialog)); |
| 503 | |
| 504 | if (!g_set_objectcxx . . $ `<external>/1341695927569185362/gobject.h:762:9`! (&self->dialog, dialog)) |
| 505 | return; |
| 506 | |
| 507 | update_button_sensitivitycxx . . $ update_button_sensitivity(7352c7f531dca0ee). (self); |
| 508 | |
| 509 | g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_DIALOGcxx . . $ PROP_DIALOG.]); |
| 510 | } |
| 511 | |
| 512 | /** |
| 513 | * gtk_color_dialog_button_get_rgba: |
| 514 | * @self: a `GtkColorDialogButton` |
| 515 | * |
| 516 | * Returns the color of the button. |
| 517 | * |
| 518 | * This function is what should be used to obtain |
| 519 | * the color that was chosen by the user. To get |
| 520 | * informed about changes, listen to "notify::rgba". |
| 521 | * |
| 522 | * Returns: the color |
| 523 | * |
| 524 | * Since: 4.10 |
| 525 | */ |
| 526 | const GdkRGBAcxx . . $ GdkRGBA# * |
| 527 | gtk_color_dialog_button_get_rgbacxx . . $ gtk_color_dialog_button_get_rgba(d95fd806c84476a5). (GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self) |
| 528 | { |
| 529 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_COLOR_DIALOG_BUTTON (self), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 530 | |
| 531 | return &self->colorcxx . . $ _GtkColorDialogButton#color.; |
| 532 | } |
| 533 | |
| 534 | /** |
| 535 | * gtk_color_dialog_button_set_rgba: |
| 536 | * @self: a `GtkColorDialogButton` |
| 537 | * @color: the new color |
| 538 | * |
| 539 | * Sets the color of the button. |
| 540 | * |
| 541 | * Since: 4.10 |
| 542 | */ |
| 543 | void |
| 544 | gtk_color_dialog_button_set_rgbacxx . . $ gtk_color_dialog_button_set_rgba(3eb6e496fea7be80). (GtkColorDialogButtoncxx . . $ GtkColorDialogButton# *self, |
| 545 | const GdkRGBAcxx . . $ GdkRGBA# *color) |
| 546 | { |
| 547 | char *text; |
| 548 | |
| 549 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_COLOR_DIALOG_BUTTON (self)); |
| 550 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (color != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 551 | |
| 552 | if (gdk_rgba_equalcxx . . $ `gdk/gdkrgbaprivate.h:48:9`! (&self->color, color)) |
| 553 | return; |
| 554 | |
| 555 | self->colorcxx . . $ _GtkColorDialogButton#color. = *color; |
| 556 | gtk_color_swatch_set_rgbacxx . . $ gtk_color_swatch_set_rgba(aa0255c71717be61). (GTK_COLOR_SWATCHcxx . . $ `gtk/gtkcolorswatchprivate.h:25:9`! (self->swatch), color); |
| 557 | |
| 558 | text = accessible_color_namecxx . . $ accessible_color_name(48aa22ea2de6087c). (color); |
| 559 | gtk_accessible_update_propertycxx . . $ gtk_accessible_update_property(7f02be67e42032aa). (GTK_ACCESSIBLEcxx . . $ GTK_ACCESSIBLE(4ecffd44f086533a). (self->swatchcxx . . $ _GtkColorDialogButton#swatch.), |
| 560 | GTK_ACCESSIBLE_PROPERTY_LABELcxx . . $ GTK_ACCESSIBLE_PROPERTY_LABEL., text, |
| 561 | -1); |
| 562 | g_freecxx . . $ g_free(5d22bdacc48458e8). (text); |
| 563 | |
| 564 | g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_RGBAcxx . . $ PROP_RGBA.]); |
| 565 | } |
| 566 | |
| 567 | /* }}} */ |
| 568 | |
| 569 | /* vim:set foldmethod=marker: */ |