| 1 | /* |
| 2 | * Copyright © 2020 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 | * Authors: Matthias Clasen <[email protected]> |
| 18 | */ |
| 19 | |
| 20 | #include "config.h"cxx . . $ `<file>/build/config.h`/ |
| 21 | |
| 22 | #include "gdkprivate.h"cxx . . $ `<file>/gdk/gdkprivate.h`/ |
| 23 | #include <glib/gi18n-lib.h> |
| 24 | #include "gdkpopupprivate.h"cxx . . $ `<file>/gdk/gdkpopupprivate.h`/ |
| 25 | |
| 26 | /** |
| 27 | * GdkPopup: |
| 28 | * |
| 29 | * A surface that is attached to another surface. |
| 30 | * |
| 31 | * The `GdkPopup` is positioned relative to its parent surface. |
| 32 | * |
| 33 | * `GdkPopup`s are typically used to implement menus and similar popups. |
| 34 | * They can be modal, which is indicated by the [[email protected]:autohide] |
| 35 | * property. |
| 36 | */ |
| 37 | |
| 38 | G_DEFINE_INTERFACEcxx . . $ `<external>/9567554376676449156/gtype.h:2078:9`! (GdkPopup, gdk_popup, GDK_TYPE_SURFACEcxx . . $ `gdk/gdksurface.h:41:9`!) |
| 39 | |
| 40 | static gbooleancxx . . $ gboolean# |
| 41 | gdk_popup_default_presentcxx . . $ gdk_popup_default_present(2326635758c24227). (GdkPopupcxx . . $ GdkPopup# *popup, |
| 42 | int width, |
| 43 | int height, |
| 44 | GdkPopupLayoutcxx . . $ GdkPopupLayout# *layout) |
| 45 | { |
| 46 | return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 47 | } |
| 48 | |
| 49 | static GdkGravitycxx . . $ GdkGravity# |
| 50 | gdk_popup_default_get_surface_anchorcxx . . $ gdk_popup_default_get_surface_anchor(e002f2055c93bb68). (GdkPopupcxx . . $ GdkPopup# *popup) |
| 51 | { |
| 52 | return GDK_GRAVITY_STATICcxx . . $ GDK_GRAVITY_STATIC.; |
| 53 | } |
| 54 | |
| 55 | static GdkGravitycxx . . $ GdkGravity# |
| 56 | gdk_popup_default_get_rect_anchorcxx . . $ gdk_popup_default_get_rect_anchor(e002f2055c93bb68). (GdkPopupcxx . . $ GdkPopup# *popup) |
| 57 | { |
| 58 | return GDK_GRAVITY_STATICcxx . . $ GDK_GRAVITY_STATIC.; |
| 59 | } |
| 60 | |
| 61 | static int |
| 62 | gdk_popup_default_get_position_xcxx . . $ gdk_popup_default_get_position_x(1aa0fce12018a155). (GdkPopupcxx . . $ GdkPopup# *popup) |
| 63 | { |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | static int |
| 68 | gdk_popup_default_get_position_ycxx . . $ gdk_popup_default_get_position_y(1aa0fce12018a155). (GdkPopupcxx . . $ GdkPopup# *popup) |
| 69 | { |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | static void |
| 74 | gdk_popup_default_initcxx . . $ gdk_popup_default_init(cacd94a47c5038e). (GdkPopupInterfacecxx . . $ GdkPopupInterface# *iface) |
| 75 | { |
| 76 | iface->presentcxx . . $ _GdkPopupInterface#present. = gdk_popup_default_presentcxx . . $ gdk_popup_default_present(2326635758c24227).; |
| 77 | iface->get_surface_anchorcxx . . $ _GdkPopupInterface#get_surface_anchor. = gdk_popup_default_get_surface_anchorcxx . . $ gdk_popup_default_get_surface_anchor(e002f2055c93bb68).; |
| 78 | iface->get_rect_anchorcxx . . $ _GdkPopupInterface#get_rect_anchor. = gdk_popup_default_get_rect_anchorcxx . . $ gdk_popup_default_get_rect_anchor(e002f2055c93bb68).; |
| 79 | iface->get_position_xcxx . . $ _GdkPopupInterface#get_position_x. = gdk_popup_default_get_position_xcxx . . $ gdk_popup_default_get_position_x(1aa0fce12018a155).; |
| 80 | iface->get_position_ycxx . . $ _GdkPopupInterface#get_position_y. = gdk_popup_default_get_position_ycxx . . $ gdk_popup_default_get_position_y(1aa0fce12018a155).; |
| 81 | |
| 82 | /** |
| 83 | * GdkPopup:parent: |
| 84 | * |
| 85 | * The parent surface. |
| 86 | */ |
| 87 | g_object_interface_install_propertycxx . . $ g_object_interface_install_property(76e618752abc489). (iface, |
| 88 | g_param_spec_objectcxx . . $ g_param_spec_object(faf99966f027a127). ("parent", 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`!, |
| 89 | GDK_TYPE_SURFACEcxx . . $ `gdk/gdksurface.h:41:9`!, |
| 90 | G_PARAM_READWRITEcxx . . $ G_PARAM_READWRITE. | G_PARAM_CONSTRUCT_ONLYcxx . . $ G_PARAM_CONSTRUCT_ONLY. | G_PARAM_STATIC_STRINGScxx . . $ `<external>/7453068347527694854/gparam.h:187:9`!)); |
| 91 | |
| 92 | /** |
| 93 | * GdkPopup:autohide: |
| 94 | * |
| 95 | * Whether to hide on outside clicks. |
| 96 | */ |
| 97 | g_object_interface_install_propertycxx . . $ g_object_interface_install_property(76e618752abc489). (iface, |
| 98 | g_param_spec_booleancxx . . $ g_param_spec_boolean(315d86b79c0116e0). ("autohide", 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`!, |
| 99 | FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!, |
| 100 | G_PARAM_READWRITEcxx . . $ G_PARAM_READWRITE. | G_PARAM_CONSTRUCT_ONLYcxx . . $ G_PARAM_CONSTRUCT_ONLY. | G_PARAM_STATIC_STRINGScxx . . $ `<external>/7453068347527694854/gparam.h:187:9`!)); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * gdk_popup_present: |
| 105 | * @popup: the `GdkPopup` to show |
| 106 | * @width: the unconstrained popup width to layout |
| 107 | * @height: the unconstrained popup height to layout |
| 108 | * @layout: the `GdkPopupLayout` object used to layout |
| 109 | * |
| 110 | * Present @popup after having processed the `GdkPopupLayout` rules. |
| 111 | * |
| 112 | * If the popup was previously not showing, it will be shown, |
| 113 | * otherwise it will change position according to @layout. |
| 114 | * |
| 115 | * After calling this function, the result should be handled in response |
| 116 | * to the [[email protected]::layout] signal being emitted. The resulting |
| 117 | * popup position can be queried using [[email protected]_position_x], |
| 118 | * [[email protected]_position_y], and the resulting size will be sent as |
| 119 | * parameters in the layout signal. Use [[email protected]_rect_anchor] |
| 120 | * and [[email protected]_surface_anchor] to get the resulting anchors. |
| 121 | * |
| 122 | * Presenting may fail, for example if the @popup is set to autohide |
| 123 | * and is immediately hidden upon being presented. If presenting failed, |
| 124 | * the [[email protected]::layout] signal will not me emitted. |
| 125 | * |
| 126 | * Returns: %FALSE if it failed to be presented, otherwise %TRUE. |
| 127 | */ |
| 128 | gbooleancxx . . $ gboolean# |
| 129 | gdk_popup_presentcxx . . $ gdk_popup_present(2326635758c24227). (GdkPopupcxx . . $ GdkPopup# *popup, |
| 130 | int width, |
| 131 | int height, |
| 132 | GdkPopupLayoutcxx . . $ GdkPopupLayout# *layout) |
| 133 | { |
| 134 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GDK_IS_POPUP (popup), FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!); |
| 135 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (width > 0, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!); |
| 136 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (height > 0, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!); |
| 137 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (layout != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!); |
| 138 | |
| 139 | return GDK_POPUP_GET_IFACEcxx . . $ GDK_POPUP_GET_IFACE(89671cbd74ff43be). (popup)->presentcxx . . $ _GdkPopupInterface#present. (popup, width, height, layout); |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * gdk_popup_get_surface_anchor: |
| 144 | * @popup: a `GdkPopup` |
| 145 | * |
| 146 | * Gets the current popup surface anchor. |
| 147 | * |
| 148 | * The value returned may change after calling [[email protected]], |
| 149 | * or after the [[email protected]::layout] signal is emitted. |
| 150 | * |
| 151 | * Returns: the current surface anchor value of @popup |
| 152 | */ |
| 153 | GdkGravitycxx . . $ GdkGravity# |
| 154 | gdk_popup_get_surface_anchorcxx . . $ gdk_popup_get_surface_anchor(e002f2055c93bb68). (GdkPopupcxx . . $ GdkPopup# *popup) |
| 155 | { |
| 156 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GDK_IS_POPUP (popup), GDK_GRAVITY_STATIC); |
| 157 | |
| 158 | return GDK_POPUP_GET_IFACEcxx . . $ GDK_POPUP_GET_IFACE(89671cbd74ff43be). (popup)->get_surface_anchorcxx . . $ _GdkPopupInterface#get_surface_anchor. (popup); |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * gdk_popup_get_rect_anchor: |
| 163 | * @popup: a `GdkPopup` |
| 164 | * |
| 165 | * Gets the current popup rectangle anchor. |
| 166 | * |
| 167 | * The value returned may change after calling [[email protected]], |
| 168 | * or after the [[email protected]::layout] signal is emitted. |
| 169 | * |
| 170 | * Returns: the current rectangle anchor value of @popup |
| 171 | */ |
| 172 | GdkGravitycxx . . $ GdkGravity# |
| 173 | gdk_popup_get_rect_anchorcxx . . $ gdk_popup_get_rect_anchor(e002f2055c93bb68). (GdkPopupcxx . . $ GdkPopup# *popup) |
| 174 | { |
| 175 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GDK_IS_POPUP (popup), GDK_GRAVITY_STATIC); |
| 176 | |
| 177 | return GDK_POPUP_GET_IFACEcxx . . $ GDK_POPUP_GET_IFACE(89671cbd74ff43be). (popup)->get_rect_anchorcxx . . $ _GdkPopupInterface#get_rect_anchor. (popup); |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * gdk_popup_get_parent: |
| 182 | * @popup: a `GdkPopup` |
| 183 | * |
| 184 | * Returns the parent surface of a popup. |
| 185 | * |
| 186 | * Returns: (transfer none) (nullable): the parent surface |
| 187 | */ |
| 188 | GdkSurfacecxx . . $ GdkSurface# * |
| 189 | gdk_popup_get_parentcxx . . $ gdk_popup_get_parent(fc6c25c41614e764). (GdkPopupcxx . . $ GdkPopup# *popup) |
| 190 | { |
| 191 | GdkSurfacecxx . . $ GdkSurface# *surface; |
| 192 | |
| 193 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GDK_IS_POPUP (popup), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 194 | |
| 195 | g_object_getcxx . . $ g_object_get(1ac911bdc4e9a14d). (popup, "parent", &surface, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 196 | |
| 197 | if (surface) |
| 198 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (surface); |
| 199 | |
| 200 | return surface; |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * gdk_popup_get_position_x: |
| 205 | * @popup: a `GdkPopup` |
| 206 | * |
| 207 | * Obtains the position of the popup relative to its parent. |
| 208 | * |
| 209 | * Returns: the X coordinate of @popup position |
| 210 | */ |
| 211 | int |
| 212 | gdk_popup_get_position_xcxx . . $ gdk_popup_get_position_x(1aa0fce12018a155). (GdkPopupcxx . . $ GdkPopup# *popup) |
| 213 | { |
| 214 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GDK_IS_POPUP (popup), 0); |
| 215 | |
| 216 | return GDK_POPUP_GET_IFACEcxx . . $ GDK_POPUP_GET_IFACE(89671cbd74ff43be). (popup)->get_position_xcxx . . $ _GdkPopupInterface#get_position_x. (popup); |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * gdk_popup_get_position_y: |
| 221 | * @popup: a `GdkPopup` |
| 222 | * |
| 223 | * Obtains the position of the popup relative to its parent. |
| 224 | * |
| 225 | * Returns: the Y coordinate of @popup position |
| 226 | */ |
| 227 | int |
| 228 | gdk_popup_get_position_ycxx . . $ gdk_popup_get_position_y(1aa0fce12018a155). (GdkPopupcxx . . $ GdkPopup# *popup) |
| 229 | { |
| 230 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GDK_IS_POPUP (popup), 0); |
| 231 | |
| 232 | return GDK_POPUP_GET_IFACEcxx . . $ GDK_POPUP_GET_IFACE(89671cbd74ff43be). (popup)->get_position_ycxx . . $ _GdkPopupInterface#get_position_y. (popup); |
| 233 | } |
| 234 | |
| 235 | /** |
| 236 | * gdk_popup_get_autohide: |
| 237 | * @popup: a `GdkPopup` |
| 238 | * |
| 239 | * Returns whether this popup is set to hide on outside clicks. |
| 240 | * |
| 241 | * Returns: %TRUE if @popup will autohide |
| 242 | */ |
| 243 | gbooleancxx . . $ gboolean# |
| 244 | gdk_popup_get_autohidecxx . . $ gdk_popup_get_autohide(1aa0fce12018a155). (GdkPopupcxx . . $ GdkPopup# *popup) |
| 245 | { |
| 246 | gbooleancxx . . $ gboolean# autohide; |
| 247 | |
| 248 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GDK_IS_POPUP (popup), FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!); |
| 249 | |
| 250 | g_object_getcxx . . $ g_object_get(1ac911bdc4e9a14d). (popup, "autohide", &autohide, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 251 | |
| 252 | return autohide; |
| 253 | } |
| 254 | |
| 255 | guintcxx . . $ guint# |
| 256 | gdk_popup_install_propertiescxx . . $ gdk_popup_install_properties(2b432e1cf99b0520). (GObjectClasscxx . . $ GObjectClass# *object_class, |
| 257 | guintcxx . . $ guint# first_prop) |
| 258 | { |
| 259 | /** |
| 260 | * GdkToplevel:parent: |
| 261 | * |
| 262 | * The parent surface of the toplevel. |
| 263 | */ |
| 264 | g_object_class_override_propertycxx . . $ g_object_class_override_property(3aa56717d1bf1f20). (object_class, first_prop + GDK_POPUP_PROP_PARENTcxx . . $ GDK_POPUP_PROP_PARENT., "parent"); |
| 265 | |
| 266 | /** |
| 267 | * GdkToplevel:autohide: |
| 268 | * |
| 269 | * Whether the toplevel should be modal with respect to its parent. |
| 270 | */ |
| 271 | g_object_class_override_propertycxx . . $ g_object_class_override_property(3aa56717d1bf1f20). (object_class, first_prop + GDK_POPUP_PROP_AUTOHIDEcxx . . $ GDK_POPUP_PROP_AUTOHIDE., "autohide"); |
| 272 | |
| 273 | return GDK_POPUP_NUM_PROPERTIEScxx . . $ GDK_POPUP_NUM_PROPERTIES.; |
| 274 | } |