1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.Menu;
26 
27 private import gdk.Device;
28 private import gdk.Event;
29 private import gdk.MonitorG;
30 private import gdk.Screen;
31 private import gdk.Window;
32 private import gio.MenuModel;
33 private import glib.ConstructionException;
34 private import glib.ListG;
35 private import glib.Str;
36 private import gobject.ObjectG;
37 private import gobject.Signals;
38 private import gtk.AccelGroup;
39 private import gtk.MenuItem;
40 private import gtk.MenuShell;
41 private import gtk.Widget;
42 public  import gtkc.gdktypes;
43 private import gtkc.gtk;
44 public  import gtkc.gtktypes;
45 
46 
47 /**
48  * A #GtkMenu is a #GtkMenuShell that implements a drop down menu
49  * consisting of a list of #GtkMenuItem objects which can be navigated
50  * and activated by the user to perform application functions.
51  * 
52  * A #GtkMenu is most commonly dropped down by activating a
53  * #GtkMenuItem in a #GtkMenuBar or popped up by activating a
54  * #GtkMenuItem in another #GtkMenu.
55  * 
56  * A #GtkMenu can also be popped up by activating a #GtkComboBox.
57  * Other composite widgets such as the #GtkNotebook can pop up a
58  * #GtkMenu as well.
59  * 
60  * Applications can display a #GtkMenu as a popup menu by calling the
61  * gtk_menu_popup() function.  The example below shows how an application
62  * can pop up a menu when the 3rd mouse button is pressed.
63  * 
64  * ## Connecting the popup signal handler.
65  * 
66  * |[<!-- language="C" -->
67  * // connect our handler which will popup the menu
68  * g_signal_connect_swapped (window, "button_press_event",
69  * G_CALLBACK (my_popup_handler), menu);
70  * ]|
71  * 
72  * ## Signal handler which displays a popup menu.
73  * 
74  * |[<!-- language="C" -->
75  * static gint
76  * my_popup_handler (GtkWidget *widget, GdkEvent *event)
77  * {
78  * GtkMenu *menu;
79  * GdkEventButton *event_button;
80  * 
81  * g_return_val_if_fail (widget != NULL, FALSE);
82  * g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
83  * g_return_val_if_fail (event != NULL, FALSE);
84  * 
85  * // The "widget" is the menu that was supplied when
86  * // g_signal_connect_swapped() was called.
87  * menu = GTK_MENU (widget);
88  * 
89  * if (event->type == GDK_BUTTON_PRESS)
90  * {
91  * event_button = (GdkEventButton *) event;
92  * if (event_button->button == GDK_BUTTON_SECONDARY)
93  * {
94  * gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
95  * event_button->button, event_button->time);
96  * return TRUE;
97  * }
98  * }
99  * 
100  * return FALSE;
101  * }
102  * ]|
103  * 
104  * # CSS nodes
105  * 
106  * |[<!-- language="plain" -->
107  * menu
108  * ├── arrow.top
109  * ├── <child>
110  * ┊
111  * ├── <child>
112  * ╰── arrow.bottom
113  * ]|
114  * 
115  * The main CSS node of GtkMenu has name menu, and there are two subnodes
116  * with name arrow, for scrolling menu arrows. These subnodes get the
117  * .top and .bottom style classes.
118  */
119 public class Menu : MenuShell
120 {
121 	/** the main Gtk struct */
122 	protected GtkMenu* gtkMenu;
123 
124 	/** Get the main Gtk struct */
125 	public GtkMenu* getMenuStruct()
126 	{
127 		return gtkMenu;
128 	}
129 
130 	/** the main Gtk struct as a void* */
131 	protected override void* getStruct()
132 	{
133 		return cast(void*)gtkMenu;
134 	}
135 
136 	protected override void setStruct(GObject* obj)
137 	{
138 		gtkMenu = cast(GtkMenu*)obj;
139 		super.setStruct(obj);
140 	}
141 
142 	/**
143 	 * Sets our main struct and passes it to the parent class.
144 	 */
145 	public this (GtkMenu* gtkMenu, bool ownedRef = false)
146 	{
147 		this.gtkMenu = gtkMenu;
148 		super(cast(GtkMenuShell*)gtkMenu, ownedRef);
149 	}
150 
151 	/**
152 	 * Popups up this menu
153 	 * Params:
154 	 *  button = you can pass a button number here
155 	 *  activateTime = you can pass the time from an event here
156 	 */
157 	void popup(uint button, uint activateTime)
158 	{
159 		popup(null, null, null, null, button, activateTime);
160 	}
161 	
162 	/**
163 	 * Creates and append a submenu to this menu.
164 	 * This menu item that actualy has the sub menu is also created.
165 	 * Params:
166 	 *  label = the sub menu item label
167 	 * Returns: the new menu
168 	 */
169 	Menu appendSubmenu(string label)
170 	{
171 		MenuItem item = new MenuItem(label);
172 		append(item);
173 		Menu submenu = new Menu();
174 		item.setSubmenu(submenu);
175 		return submenu;
176 	}
177 	
178 	/** */
179 	void appendSubmenu(string label, Menu submenu)
180 	{
181 		MenuItem item = new MenuItem(label);
182 		append(item);
183 		item.setSubmenu(submenu);
184 	}
185 	
186 	/** */
187 	Menu prependSubmenu(string label)
188 	{
189 		MenuItem item = new MenuItem(label);
190 		prepend(item);
191 		Menu submenu = new Menu();
192 		item.setSubmenu(submenu);
193 		return submenu;
194 	}
195 
196 	/**
197 	 */
198 
199 	/** */
200 	public static GType getType()
201 	{
202 		return gtk_menu_get_type();
203 	}
204 
205 	/**
206 	 * Creates a new #GtkMenu
207 	 *
208 	 * Return: a new #GtkMenu
209 	 *
210 	 * Throws: ConstructionException GTK+ fails to create the object.
211 	 */
212 	public this()
213 	{
214 		auto p = gtk_menu_new();
215 		
216 		if(p is null)
217 		{
218 			throw new ConstructionException("null returned by new");
219 		}
220 		
221 		this(cast(GtkMenu*) p);
222 	}
223 
224 	/**
225 	 * Creates a #GtkMenu and populates it with menu items and
226 	 * submenus according to @model.
227 	 *
228 	 * The created menu items are connected to actions found in the
229 	 * #GtkApplicationWindow to which the menu belongs - typically
230 	 * by means of being attached to a widget (see gtk_menu_attach_to_widget())
231 	 * that is contained within the #GtkApplicationWindows widget hierarchy.
232 	 *
233 	 * Actions can also be added using gtk_widget_insert_action_group() on the menu's
234 	 * attach widget or on any of its parent widgets.
235 	 *
236 	 * Params:
237 	 *     model = a #GMenuModel
238 	 *
239 	 * Return: a new #GtkMenu
240 	 *
241 	 * Since: 3.4
242 	 *
243 	 * Throws: ConstructionException GTK+ fails to create the object.
244 	 */
245 	public this(MenuModel model)
246 	{
247 		auto p = gtk_menu_new_from_model((model is null) ? null : model.getMenuModelStruct());
248 		
249 		if(p is null)
250 		{
251 			throw new ConstructionException("null returned by new_from_model");
252 		}
253 		
254 		this(cast(GtkMenu*) p);
255 	}
256 
257 	/**
258 	 * Returns a list of the menus which are attached to this widget.
259 	 * This list is owned by GTK+ and must not be modified.
260 	 *
261 	 * Params:
262 	 *     widget = a #GtkWidget
263 	 *
264 	 * Return: the list
265 	 *     of menus attached to his widget.
266 	 *
267 	 * Since: 2.6
268 	 */
269 	public static ListG getForAttachWidget(Widget widget)
270 	{
271 		auto p = gtk_menu_get_for_attach_widget((widget is null) ? null : widget.getWidgetStruct());
272 		
273 		if(p is null)
274 		{
275 			return null;
276 		}
277 		
278 		return new ListG(cast(GList*) p);
279 	}
280 
281 	/**
282 	 * Adds a new #GtkMenuItem to a (table) menu. The number of “cells” that
283 	 * an item will occupy is specified by @left_attach, @right_attach,
284 	 * @top_attach and @bottom_attach. These each represent the leftmost,
285 	 * rightmost, uppermost and lower column and row numbers of the table.
286 	 * (Columns and rows are indexed from zero).
287 	 *
288 	 * Note that this function is not related to gtk_menu_detach().
289 	 *
290 	 * Params:
291 	 *     child = a #GtkMenuItem
292 	 *     leftAttach = The column number to attach the left side of the item to
293 	 *     rightAttach = The column number to attach the right side of the item to
294 	 *     topAttach = The row number to attach the top of the item to
295 	 *     bottomAttach = The row number to attach the bottom of the item to
296 	 *
297 	 * Since: 2.4
298 	 */
299 	public void attach(Widget child, uint leftAttach, uint rightAttach, uint topAttach, uint bottomAttach)
300 	{
301 		gtk_menu_attach(gtkMenu, (child is null) ? null : child.getWidgetStruct(), leftAttach, rightAttach, topAttach, bottomAttach);
302 	}
303 
304 	/**
305 	 * Attaches the menu to the widget and provides a callback function
306 	 * that will be invoked when the menu calls gtk_menu_detach() during
307 	 * its destruction.
308 	 *
309 	 * If the menu is attached to the widget then it will be destroyed
310 	 * when the widget is destroyed, as if it was a child widget.
311 	 * An attached menu will also move between screens correctly if the
312 	 * widgets moves between screens.
313 	 *
314 	 * Params:
315 	 *     attachWidget = the #GtkWidget that the menu will be attached to
316 	 *     detacher = the user supplied callback function
317 	 *         that will be called when the menu calls gtk_menu_detach()
318 	 */
319 	public void attachToWidget(Widget attachWidget, GtkMenuDetachFunc detacher)
320 	{
321 		gtk_menu_attach_to_widget(gtkMenu, (attachWidget is null) ? null : attachWidget.getWidgetStruct(), detacher);
322 	}
323 
324 	/**
325 	 * Detaches the menu from the widget to which it had been attached.
326 	 * This function will call the callback function, @detacher, provided
327 	 * when the gtk_menu_attach_to_widget() function was called.
328 	 */
329 	public void detach()
330 	{
331 		gtk_menu_detach(gtkMenu);
332 	}
333 
334 	/**
335 	 * Gets the #GtkAccelGroup which holds global accelerators for the
336 	 * menu. See gtk_menu_set_accel_group().
337 	 *
338 	 * Return: the #GtkAccelGroup associated with the menu
339 	 */
340 	public AccelGroup getAccelGroup()
341 	{
342 		auto p = gtk_menu_get_accel_group(gtkMenu);
343 		
344 		if(p is null)
345 		{
346 			return null;
347 		}
348 		
349 		return ObjectG.getDObject!(AccelGroup)(cast(GtkAccelGroup*) p);
350 	}
351 
352 	/**
353 	 * Retrieves the accelerator path set on the menu.
354 	 *
355 	 * Return: the accelerator path set on the menu.
356 	 *
357 	 * Since: 2.14
358 	 */
359 	public string getAccelPath()
360 	{
361 		return Str.toString(gtk_menu_get_accel_path(gtkMenu));
362 	}
363 
364 	/**
365 	 * Returns the selected menu item from the menu.  This is used by the
366 	 * #GtkComboBox.
367 	 *
368 	 * Return: the #GtkMenuItem that was last selected
369 	 *     in the menu.  If a selection has not yet been made, the
370 	 *     first menu item is selected.
371 	 */
372 	public Widget getActive()
373 	{
374 		auto p = gtk_menu_get_active(gtkMenu);
375 		
376 		if(p is null)
377 		{
378 			return null;
379 		}
380 		
381 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
382 	}
383 
384 	/**
385 	 * Returns the #GtkWidget that the menu is attached to.
386 	 *
387 	 * Return: the #GtkWidget that the menu is attached to
388 	 */
389 	public Widget getAttachWidget()
390 	{
391 		auto p = gtk_menu_get_attach_widget(gtkMenu);
392 		
393 		if(p is null)
394 		{
395 			return null;
396 		}
397 		
398 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
399 	}
400 
401 	/**
402 	 * Retrieves the number of the monitor on which to show the menu.
403 	 *
404 	 * Return: the number of the monitor on which the menu should
405 	 *     be popped up or -1, if no monitor has been set
406 	 *
407 	 * Since: 2.14
408 	 */
409 	public int getMonitor()
410 	{
411 		return gtk_menu_get_monitor(gtkMenu);
412 	}
413 
414 	/**
415 	 * Returns whether the menu reserves space for toggles and
416 	 * icons, regardless of their actual presence.
417 	 *
418 	 * Return: Whether the menu reserves toggle space
419 	 *
420 	 * Since: 2.18
421 	 */
422 	public bool getReserveToggleSize()
423 	{
424 		return gtk_menu_get_reserve_toggle_size(gtkMenu) != 0;
425 	}
426 
427 	/**
428 	 * Returns whether the menu is torn off.
429 	 * See gtk_menu_set_tearoff_state().
430 	 *
431 	 * Return: %TRUE if the menu is currently torn off.
432 	 */
433 	public bool getTearoffState()
434 	{
435 		return gtk_menu_get_tearoff_state(gtkMenu) != 0;
436 	}
437 
438 	/**
439 	 * Returns the title of the menu. See gtk_menu_set_title().
440 	 *
441 	 * Return: the title of the menu, or %NULL if the menu
442 	 *     has no title set on it. This string is owned by GTK+
443 	 *     and should not be modified or freed.
444 	 */
445 	public string getTitle()
446 	{
447 		return Str.toString(gtk_menu_get_title(gtkMenu));
448 	}
449 
450 	/** */
451 	public void placeOnMonitor(MonitorG monitor)
452 	{
453 		gtk_menu_place_on_monitor(gtkMenu, (monitor is null) ? null : monitor.getMonitorGStruct());
454 	}
455 
456 	/**
457 	 * Removes the menu from the screen.
458 	 */
459 	public void popdown()
460 	{
461 		gtk_menu_popdown(gtkMenu);
462 	}
463 
464 	/**
465 	 * Displays a menu and makes it available for selection.
466 	 *
467 	 * Applications can use this function to display context-sensitive
468 	 * menus, and will typically supply %NULL for the @parent_menu_shell,
469 	 * @parent_menu_item, @func and @data parameters. The default menu
470 	 * positioning function will position the menu at the current mouse
471 	 * cursor position.
472 	 *
473 	 * The @button parameter should be the mouse button pressed to initiate
474 	 * the menu popup. If the menu popup was initiated by something other
475 	 * than a mouse button press, such as a mouse button release or a keypress,
476 	 * @button should be 0.
477 	 *
478 	 * The @activate_time parameter is used to conflict-resolve initiation
479 	 * of concurrent requests for mouse/keyboard grab requests. To function
480 	 * properly, this needs to be the timestamp of the user event (such as
481 	 * a mouse click or key press) that caused the initiation of the popup.
482 	 * Only if no such event is available, gtk_get_current_event_time() can
483 	 * be used instead.
484 	 *
485 	 * Note that this function does not work very well on GDK backends that
486 	 * do not have global coordinates, such as Wayland or Mir. You should
487 	 * probably use one of the gtk_menu_popup_at_ variants, which do not
488 	 * have this problem.
489 	 *
490 	 * Deprecated: Please use gtk_menu_popup_at_widget(),
491 	 * gtk_menu_popup_at_pointer(). or gtk_menu_popup_at_rect() instead
492 	 *
493 	 * Params:
494 	 *     parentMenuShell = the menu shell containing the
495 	 *         triggering menu item, or %NULL
496 	 *     parentMenuItem = the menu item whose activation
497 	 *         triggered the popup, or %NULL
498 	 *     func = a user supplied function used to position
499 	 *         the menu, or %NULL
500 	 *     data = user supplied data to be passed to @func.
501 	 *     button = the mouse button which was pressed to initiate the event.
502 	 *     activateTime = the time at which the activation event occurred.
503 	 */
504 	public void popup(Widget parentMenuShell, Widget parentMenuItem, GtkMenuPositionFunc func, void* data, uint button, uint activateTime)
505 	{
506 		gtk_menu_popup(gtkMenu, (parentMenuShell is null) ? null : parentMenuShell.getWidgetStruct(), (parentMenuItem is null) ? null : parentMenuItem.getWidgetStruct(), func, data, button, activateTime);
507 	}
508 
509 	/**
510 	 * Displays @menu and makes it available for selection.
511 	 *
512 	 * See gtk_menu_popup_at_widget () to pop up a menu at a widget.
513 	 * gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary
514 	 * rectangle.
515 	 *
516 	 * @menu will be positioned at the pointer associated with @trigger_event.
517 	 *
518 	 * Properties that influence the behaviour of this function are
519 	 * #GtkMenu:anchor-hints, #GtkMenu:rect-anchor-dx, #GtkMenu:rect-anchor-dy, and
520 	 * #GtkMenu:menu-type-hint. Connect to the #GtkMenu::popped-up signal to find
521 	 * out how it was actually positioned.
522 	 *
523 	 * Params:
524 	 *     triggerEvent = the #GdkEvent that initiated this request or
525 	 *         %NULL if it's the current event
526 	 *
527 	 * Since: 3.22
528 	 */
529 	public void popupAtPointer(Event triggerEvent)
530 	{
531 		gtk_menu_popup_at_pointer(gtkMenu, (triggerEvent is null) ? null : triggerEvent.getEventStruct());
532 	}
533 
534 	/**
535 	 * Displays @menu and makes it available for selection.
536 	 *
537 	 * See gtk_menu_popup_at_widget () and gtk_menu_popup_at_pointer (), which
538 	 * handle more common cases for popping up menus.
539 	 *
540 	 * @menu will be positioned at @rect, aligning their anchor points. @rect is
541 	 * relative to the top-left corner of @rect_window. @rect_anchor and
542 	 * @menu_anchor determine anchor points on @rect and @menu to pin together.
543 	 * @menu can optionally be offset by #GtkMenu:rect-anchor-dx and
544 	 * #GtkMenu:rect-anchor-dy.
545 	 *
546 	 * Anchors should be specified under the assumption that the text direction is
547 	 * left-to-right; they will be flipped horizontally automatically if the text
548 	 * direction is right-to-left.
549 	 *
550 	 * Other properties that influence the behaviour of this function are
551 	 * #GtkMenu:anchor-hints and #GtkMenu:menu-type-hint. Connect to the
552 	 * #GtkMenu::popped-up signal to find out how it was actually positioned.
553 	 *
554 	 * Params:
555 	 *     rectWindow = the #GdkWindow @rect is relative to
556 	 *     rect = the #GdkRectangle to align @menu with
557 	 *     rectAnchor = the point on @rect to align with @menu's anchor point
558 	 *     menuAnchor = the point on @menu to align with @rect's anchor point
559 	 *     triggerEvent = the #GdkEvent that initiated this request or
560 	 *         %NULL if it's the current event
561 	 *
562 	 * Since: 3.22
563 	 */
564 	public void popupAtRect(Window rectWindow, GdkRectangle* rect, GdkGravity rectAnchor, GdkGravity menuAnchor, Event triggerEvent)
565 	{
566 		gtk_menu_popup_at_rect(gtkMenu, (rectWindow is null) ? null : rectWindow.getWindowStruct(), rect, rectAnchor, menuAnchor, (triggerEvent is null) ? null : triggerEvent.getEventStruct());
567 	}
568 
569 	/**
570 	 * Displays @menu and makes it available for selection.
571 	 *
572 	 * See gtk_menu_popup_at_pointer () to pop up a menu at the master pointer.
573 	 * gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary
574 	 * rectangle.
575 	 *
576 	 * ![](popup-anchors.png)
577 	 *
578 	 * @menu will be positioned at @widget, aligning their anchor points.
579 	 * @widget_anchor and @menu_anchor determine anchor points on @widget and @menu
580 	 * to pin together. @menu can optionally be offset by #GtkMenu:rect-anchor-dx
581 	 * and #GtkMenu:rect-anchor-dy.
582 	 *
583 	 * Anchors should be specified under the assumption that the text direction is
584 	 * left-to-right; they will be flipped horizontally automatically if the text
585 	 * direction is right-to-left.
586 	 *
587 	 * Other properties that influence the behaviour of this function are
588 	 * #GtkMenu:anchor-hints and #GtkMenu:menu-type-hint. Connect to the
589 	 * #GtkMenu::popped-up signal to find out how it was actually positioned.
590 	 *
591 	 * Params:
592 	 *     widget = the #GtkWidget to align @menu with
593 	 *     widgetAnchor = the point on @widget to align with @menu's anchor point
594 	 *     menuAnchor = the point on @menu to align with @widget's anchor point
595 	 *     triggerEvent = the #GdkEvent that initiated this request or
596 	 *         %NULL if it's the current event
597 	 *
598 	 * Since: 3.22
599 	 */
600 	public void popupAtWidget(Widget widget, GdkGravity widgetAnchor, GdkGravity menuAnchor, Event triggerEvent)
601 	{
602 		gtk_menu_popup_at_widget(gtkMenu, (widget is null) ? null : widget.getWidgetStruct(), widgetAnchor, menuAnchor, (triggerEvent is null) ? null : triggerEvent.getEventStruct());
603 	}
604 
605 	/**
606 	 * Displays a menu and makes it available for selection.
607 	 *
608 	 * Applications can use this function to display context-sensitive menus,
609 	 * and will typically supply %NULL for the @parent_menu_shell,
610 	 * @parent_menu_item, @func, @data and @destroy parameters. The default
611 	 * menu positioning function will position the menu at the current position
612 	 * of @device (or its corresponding pointer).
613 	 *
614 	 * The @button parameter should be the mouse button pressed to initiate
615 	 * the menu popup. If the menu popup was initiated by something other than
616 	 * a mouse button press, such as a mouse button release or a keypress,
617 	 * @button should be 0.
618 	 *
619 	 * The @activate_time parameter is used to conflict-resolve initiation of
620 	 * concurrent requests for mouse/keyboard grab requests. To function
621 	 * properly, this needs to be the time stamp of the user event (such as
622 	 * a mouse click or key press) that caused the initiation of the popup.
623 	 * Only if no such event is available, gtk_get_current_event_time() can
624 	 * be used instead.
625 	 *
626 	 * Note that this function does not work very well on GDK backends that
627 	 * do not have global coordinates, such as Wayland or Mir. You should
628 	 * probably use one of the gtk_menu_popup_at_ variants, which do not
629 	 * have this problem.
630 	 *
631 	 * Deprecated: Please use gtk_menu_popup_at_widget(),
632 	 * gtk_menu_popup_at_pointer(). or gtk_menu_popup_at_rect() instead
633 	 *
634 	 * Params:
635 	 *     device = a #GdkDevice
636 	 *     parentMenuShell = the menu shell containing the triggering
637 	 *         menu item, or %NULL
638 	 *     parentMenuItem = the menu item whose activation triggered
639 	 *         the popup, or %NULL
640 	 *     func = a user supplied function used to position the menu,
641 	 *         or %NULL
642 	 *     data = user supplied data to be passed to @func
643 	 *     destroy = destroy notify for @data
644 	 *     button = the mouse button which was pressed to initiate the event
645 	 *     activateTime = the time at which the activation event occurred
646 	 *
647 	 * Since: 3.0
648 	 */
649 	public void popupForDevice(Device device, Widget parentMenuShell, Widget parentMenuItem, GtkMenuPositionFunc func, void* data, GDestroyNotify destroy, uint button, uint activateTime)
650 	{
651 		gtk_menu_popup_for_device(gtkMenu, (device is null) ? null : device.getDeviceStruct(), (parentMenuShell is null) ? null : parentMenuShell.getWidgetStruct(), (parentMenuItem is null) ? null : parentMenuItem.getWidgetStruct(), func, data, destroy, button, activateTime);
652 	}
653 
654 	/**
655 	 * Moves @child to a new @position in the list of @menu
656 	 * children.
657 	 *
658 	 * Params:
659 	 *     child = the #GtkMenuItem to move
660 	 *     position = the new position to place @child.
661 	 *         Positions are numbered from 0 to n - 1
662 	 */
663 	public void reorderChild(Widget child, int position)
664 	{
665 		gtk_menu_reorder_child(gtkMenu, (child is null) ? null : child.getWidgetStruct(), position);
666 	}
667 
668 	/**
669 	 * Repositions the menu according to its position function.
670 	 */
671 	public void reposition()
672 	{
673 		gtk_menu_reposition(gtkMenu);
674 	}
675 
676 	/**
677 	 * Set the #GtkAccelGroup which holds global accelerators for the
678 	 * menu.  This accelerator group needs to also be added to all windows
679 	 * that this menu is being used in with gtk_window_add_accel_group(),
680 	 * in order for those windows to support all the accelerators
681 	 * contained in this group.
682 	 *
683 	 * Params:
684 	 *     accelGroup = the #GtkAccelGroup to be associated
685 	 *         with the menu.
686 	 */
687 	public void setAccelGroup(AccelGroup accelGroup)
688 	{
689 		gtk_menu_set_accel_group(gtkMenu, (accelGroup is null) ? null : accelGroup.getAccelGroupStruct());
690 	}
691 
692 	/**
693 	 * Sets an accelerator path for this menu from which accelerator paths
694 	 * for its immediate children, its menu items, can be constructed.
695 	 * The main purpose of this function is to spare the programmer the
696 	 * inconvenience of having to call gtk_menu_item_set_accel_path() on
697 	 * each menu item that should support runtime user changable accelerators.
698 	 * Instead, by just calling gtk_menu_set_accel_path() on their parent,
699 	 * each menu item of this menu, that contains a label describing its
700 	 * purpose, automatically gets an accel path assigned.
701 	 *
702 	 * For example, a menu containing menu items “New” and “Exit”, will, after
703 	 * `gtk_menu_set_accel_path (menu, "<Gnumeric-Sheet>/File");` has been
704 	 * called, assign its items the accel paths: `"<Gnumeric-Sheet>/File/New"`
705 	 * and `"<Gnumeric-Sheet>/File/Exit"`.
706 	 *
707 	 * Assigning accel paths to menu items then enables the user to change
708 	 * their accelerators at runtime. More details about accelerator paths
709 	 * and their default setups can be found at gtk_accel_map_add_entry().
710 	 *
711 	 * Note that @accel_path string will be stored in a #GQuark. Therefore,
712 	 * if you pass a static string, you can save some memory by interning
713 	 * it first with g_intern_static_string().
714 	 *
715 	 * Params:
716 	 *     accelPath = a valid accelerator path
717 	 */
718 	public void setAccelPath(string accelPath)
719 	{
720 		gtk_menu_set_accel_path(gtkMenu, Str.toStringz(accelPath));
721 	}
722 
723 	/**
724 	 * Selects the specified menu item within the menu.  This is used by
725 	 * the #GtkComboBox and should not be used by anyone else.
726 	 *
727 	 * Params:
728 	 *     index = the index of the menu item to select.  Index values are
729 	 *         from 0 to n-1
730 	 */
731 	public void setActive(uint index)
732 	{
733 		gtk_menu_set_active(gtkMenu, index);
734 	}
735 
736 	/**
737 	 * Informs GTK+ on which monitor a menu should be popped up.
738 	 * See gdk_monitor_get_geometry().
739 	 *
740 	 * This function should be called from a #GtkMenuPositionFunc
741 	 * if the menu should not appear on the same monitor as the pointer.
742 	 * This information can’t be reliably inferred from the coordinates
743 	 * returned by a #GtkMenuPositionFunc, since, for very long menus,
744 	 * these coordinates may extend beyond the monitor boundaries or even
745 	 * the screen boundaries.
746 	 *
747 	 * Params:
748 	 *     monitorNum = the number of the monitor on which the menu should
749 	 *         be popped up
750 	 *
751 	 * Since: 2.4
752 	 */
753 	public void setMonitor(int monitorNum)
754 	{
755 		gtk_menu_set_monitor(gtkMenu, monitorNum);
756 	}
757 
758 	/**
759 	 * Sets whether the menu should reserve space for drawing toggles
760 	 * or icons, regardless of their actual presence.
761 	 *
762 	 * Params:
763 	 *     reserveToggleSize = whether to reserve size for toggles
764 	 *
765 	 * Since: 2.18
766 	 */
767 	public void setReserveToggleSize(bool reserveToggleSize)
768 	{
769 		gtk_menu_set_reserve_toggle_size(gtkMenu, reserveToggleSize);
770 	}
771 
772 	/**
773 	 * Sets the #GdkScreen on which the menu will be displayed.
774 	 *
775 	 * Params:
776 	 *     screen = a #GdkScreen, or %NULL if the screen should be
777 	 *         determined by the widget the menu is attached to
778 	 *
779 	 * Since: 2.2
780 	 */
781 	public void setScreen(Screen screen)
782 	{
783 		gtk_menu_set_screen(gtkMenu, (screen is null) ? null : screen.getScreenStruct());
784 	}
785 
786 	/**
787 	 * Changes the tearoff state of the menu.  A menu is normally
788 	 * displayed as drop down menu which persists as long as the menu is
789 	 * active.  It can also be displayed as a tearoff menu which persists
790 	 * until it is closed or reattached.
791 	 *
792 	 * Params:
793 	 *     tornOff = If %TRUE, menu is displayed as a tearoff menu.
794 	 */
795 	public void setTearoffState(bool tornOff)
796 	{
797 		gtk_menu_set_tearoff_state(gtkMenu, tornOff);
798 	}
799 
800 	/**
801 	 * Sets the title string for the menu.
802 	 *
803 	 * The title is displayed when the menu is shown as a tearoff
804 	 * menu. If @title is %NULL, the menu will see if it is attached
805 	 * to a parent menu item, and if so it will try to use the same
806 	 * text as that menu item’s label.
807 	 *
808 	 * Params:
809 	 *     title = a string containing the title for the menu
810 	 */
811 	public void setTitle(string title)
812 	{
813 		gtk_menu_set_title(gtkMenu, Str.toStringz(title));
814 	}
815 
816 	int[string] connectedSignals;
817 
818 	void delegate(GtkScrollType, Menu)[] onMoveScrollListeners;
819 	/** */
820 	void addOnMoveScroll(void delegate(GtkScrollType, Menu) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
821 	{
822 		if ( "move-scroll" !in connectedSignals )
823 		{
824 			Signals.connectData(
825 				this,
826 				"move-scroll",
827 				cast(GCallback)&callBackMoveScroll,
828 				cast(void*)this,
829 				null,
830 				connectFlags);
831 			connectedSignals["move-scroll"] = 1;
832 		}
833 		onMoveScrollListeners ~= dlg;
834 	}
835 	extern(C) static void callBackMoveScroll(GtkMenu* menuStruct, GtkScrollType scrollType, Menu _menu)
836 	{
837 		foreach ( void delegate(GtkScrollType, Menu) dlg; _menu.onMoveScrollListeners )
838 		{
839 			dlg(scrollType, _menu);
840 		}
841 	}
842 
843 	void delegate(void*, void*, bool, bool, Menu)[] onPoppedUpListeners;
844 	/**
845 	 * Emitted when the position of @menu is finalized after being popped up
846 	 * using gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), or
847 	 * gtk_menu_popup_at_pointer ().
848 	 *
849 	 * @menu might be flipped over the anchor rectangle in order to keep it
850 	 * on-screen, in which case @flipped_x and @flipped_y will be set to %TRUE
851 	 * accordingly.
852 	 *
853 	 * @flipped_rect is the ideal position of @menu after any possible flipping,
854 	 * but before any possible sliding. @final_rect is @flipped_rect, but possibly
855 	 * translated in the case that flipping is still ineffective in keeping @menu
856 	 * on-screen.
857 	 *
858 	 * ![](popup-slide.png)
859 	 *
860 	 * The blue menu is @menu's ideal position, the green menu is @flipped_rect,
861 	 * and the red menu is @final_rect.
862 	 *
863 	 * See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
864 	 * gtk_menu_popup_at_pointer (), #GtkMenu:anchor-hints,
865 	 * #GtkMenu:rect-anchor-dx, #GtkMenu:rect-anchor-dy, and
866 	 * #GtkMenu:menu-type-hint.
867 	 *
868 	 * Params:
869 	 *     flippedRect = the position of @menu after any possible
870 	 *         flipping or %NULL if the backend can't obtain it
871 	 *     finalRect = the final position of @menu or %NULL if the
872 	 *         backend can't obtain it
873 	 *     flippedX = %TRUE if the anchors were flipped horizontally
874 	 *     flippedY = %TRUE if the anchors were flipped vertically
875 	 *
876 	 * Since: 3.22
877 	 */
878 	void addOnPoppedUp(void delegate(void*, void*, bool, bool, Menu) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
879 	{
880 		if ( "popped-up" !in connectedSignals )
881 		{
882 			Signals.connectData(
883 				this,
884 				"popped-up",
885 				cast(GCallback)&callBackPoppedUp,
886 				cast(void*)this,
887 				null,
888 				connectFlags);
889 			connectedSignals["popped-up"] = 1;
890 		}
891 		onPoppedUpListeners ~= dlg;
892 	}
893 	extern(C) static void callBackPoppedUp(GtkMenu* menuStruct, void* flippedRect, void* finalRect, bool flippedX, bool flippedY, Menu _menu)
894 	{
895 		foreach ( void delegate(void*, void*, bool, bool, Menu) dlg; _menu.onPoppedUpListeners )
896 		{
897 			dlg(flippedRect, finalRect, flippedX, flippedY, _menu);
898 		}
899 	}
900 }