W Wrapl, The Programming Language

Libraries:Gtk:Gtk:Menu

Types

T

Inherits from:

A T is a Gtk.Gtk.MenuShell.T that implements a drop down menu consisting of a list of Gtk.Gtk.MenuItem.T objects which can be navigated and activated by the user to perform application functions.

A T is most commonly dropped down by activating a Gtk.Gtk.MenuItem.T in a Gtk.Gtk.MenuBar.T or popped up by activating a Gtk.Gtk.MenuItem.T in another T.

A T can also be popped up by activating a Gtk.Gtk.OptionMenu.T. Other composite widgets such as the Gtk.Gtk.Notebook.T can pop up a T as well.

Applications can display a T as a popup menu by calling the Popup function. The example below shows how an application can pop up a menu when the 3rd mouse button is pressed.

Example 31. Connecting the popup signal handler.

1
2
3
/* connect our handler which will popup the menu */
g_signal_connect_swapped (window, "button_press_event",
    G_CALLBACK (my_popup_handler), menu);


Example 32. Signal handler which displays a popup menu.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
static gint
my_popup_handler (GtkWidget *widget, GdkEvent *event)
{
  GtkMenu *menu;
  GdkEventButton *event_button;
  g_return_val_if_fail (widget != NULL, FALSE);
  g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
  g_return_val_if_fail (event != NULL, FALSE);
  /* The "widget" is the menu that was supplied when
   * g_signal_connect_swapped() was called.
   */
  menu = GTK_MENU (widget);
  if (event->type == GDK_BUTTON_PRESS)
    {
      event_button = (GdkEventButton *) event;
      if (event_button->button == 3)
    {
      gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
              event_button->button, event_button->time);
      return TRUE;
    }
    }
  return FALSE;
}




Constants

Nil : T

Functions

GetForAttachWidget(widget @ Gtk.Gtk.Widget.T) : Std.Object.T

Returns a list of the menus which are attached to this widget. This list is owned by GTK+ and must not be modified.

widget a Gtk.Gtk.Widget.T
Returns the list of menus attached to his widget. [element-type GtkWidget][transfer none]


GetType() : Gtk.GObject.Type.T



New() : Gtk.Gtk.Menu.T

Creates a new T.

Returns a new T.


Methods

:Attach(self @ T, child @ Gtk.Gtk.Widget.T, left_attach @ Std.Integer.SmallT, right_attach @ Std.Integer.SmallT, top_attach @ Std.Integer.SmallT, bottom_attach @ Std.Integer.SmallT) : Std.Object.T

Adds a new Gtk.Gtk.MenuItem.T to a (table) menu. The number of 'cells' that an item will occupy is specified by left_attach, right_attach, top_attach and bottom_attach. These each represent the leftmost, rightmost, uppermost and lower column and row numbers of the table. (Columns and rows are indexed from zero).

Note that this function is not related to Detach.

menu a T.
child a Gtk.Gtk.MenuItem.T.
left_attach The column number to attach the left side of the item to.
right_attach The column number to attach the right side of the item to.
top_attach The row number to attach the top of the item to.
bottom_attach The row number to attach the bottom of the item to.


:AttachToWidget(self @ T, attach_widget @ Gtk.Gtk.Widget.T, detacher @ Std.Function.T) : Std.Object.T

Attaches the menu to the widget and provides a callback function that will be invoked when the menu calls Detach during its destruction.

menu a T.
attach_widget the Gtk.Gtk.Widget.T that the menu will be attached to.
detacher the user supplied callback function that will be called when the menu calls Detach.


:Detach(self @ T) : Std.Object.T

Detaches the menu from the widget to which it had been attached. This function will call the callback function, detacher, provided when the AttachToWidget function was called.

menu a T.


:GetAccelGroup(self @ T) : Gtk.Gtk.AccelGroup.T

Gets the Gtk.Gtk.AccelGroup.T which holds global accelerators for the menu. See SetAccelGroup.

Gets the Gtk.Gtk.AccelGroup.T which holds global accelerators for the menu. See SetAccelGroup.

menu a T.
Returns the Gtk.Gtk.AccelGroup.T associated with the menu. [transfer none]


:GetAccelPath(self @ T) : Std.String.T

Retrieves the accelerator path set on the menu.

menu a valid T
Returns the accelerator path set on the menu.


:GetActive(self @ T) : Gtk.Gtk.Widget.T

Returns the selected menu item from the menu. This is used by the Gtk.Gtk.OptionMenu.T.

Returns the selected menu item from the menu. This is used by the Gtk.Gtk.OptionMenu.T.

menu a T
Returns the Gtk.Gtk.MenuItem.T that was last selected in the menu. If a selection has not yet been made, the first menu item is selected. [transfer none]


:GetAttachWidget(self @ T) : Gtk.Gtk.Widget.T

Returns the Gtk.Gtk.Widget.T that the menu is attached to.

Returns the Gtk.Gtk.Widget.T that the menu is attached to.

menu a T
Returns the Gtk.Gtk.Widget.T that the menu is attached to. [transfer none]


:GetMonitor(self @ T) : Std.Integer.SmallT

Retrieves the number of the monitor on which to show the menu.

menu a T
Returns the number of the monitor on which the menu should be popped up or -1, if no monitor has been set


:GetReserveToggleSize(self @ T) : Std.Symbol.T

Returns whether the menu reserves space for toggles and icons, regardless of their actual presence.

menu a T
Returns Whether the menu reserves toggle space


:GetTearoffState(self @ T) : Std.Symbol.T

Returns whether the menu is torn off. See SetTearoffState.

menu a T
Returns TRUE if the menu is currently torn off.


:GetTitle(self @ T) : Std.String.T

Returns the title of the menu. See SetTitle.

menu a T
Returns the title of the menu, or NULL if the menu has no title set on it. This string is owned by the widget and should not be modified or freed.


:Popdown(self @ T) : Std.Object.T

Removes the menu from the screen.

menu a T.


Displays a menu and makes it available for selection. Applications can use this function to display context-sensitive menus, and will typically supply NULL for the parent_menu_shell, parent_menu_item, func and data parameters. The default menu positioning function will position the menu at the current mouse cursor position.

The button parameter should be the mouse button pressed to initiate the menu popup. If the menu popup was initiated by something other than a mouse button press, such as a mouse button release or a keypress, button should be 0.

The activate_time parameter is used to conflict-resolve initiation of concurrent requests for mouse/keyboard grab requests. To function properly, this needs to be the time stamp of the user event (such as a mouse click or key press) that caused the initiation of the popup. Only if no such event is available, Gtk.Gtk.Global.GetCurrentEventTime can be used instead.

menu a T.
parent_menu_shell the menu shell containing the triggering menu item, or NULL. [allow-none]
parent_menu_item the menu item whose activation triggered the popup, or NULL. [allow-none]
func a user supplied function used to position the menu, or NULL. [allow-none]
data user supplied data to be passed to func. [allow-none]
button the mouse button which was pressed to initiate the event.
activate_time the time at which the activation event occurred.


:ReorderChild(self @ T, child @ Gtk.Gtk.Widget.T, position @ Std.Integer.SmallT) : Std.Object.T

Moves a Gtk.Gtk.MenuItem.T to a new position within the T.

menu a T.
child the Gtk.Gtk.MenuItem.T to move.
position the new position to place child. Positions are numbered from 0 to n-1.


:Reposition(self @ T) : Std.Object.T

Repositions the menu according to its position function.

menu a T.


:SetAccelGroup(self @ T, accel_group @ Gtk.Gtk.AccelGroup.T) : Std.Object.T

Set the Gtk.Gtk.AccelGroup.T which holds global accelerators for the menu. This accelerator group needs to also be added to all windows that this menu is being used in with Gtk.Gtk.Window.AddAccelGroup, in order for those windows to support all the accelerators contained in this group.

menu a T.
accel_group . [allow-none]


:SetAccelPath(self @ T, accel_path @ Std.String.T) : Std.Object.T

Sets an accelerator path for this menu from which accelerator paths for its immediate children, its menu items, can be constructed. The main purpose of this function is to spare the programmer the inconvenience of having to call Gtk.Gtk.MenuItem.SetAccelPath on each menu item that should support runtime user changable accelerators. Instead, by just calling SetAccelPath on their parent, each menu item of this menu, that contains a label describing its purpose, automatically gets an accel path assigned. For example, a menu containing menu items "New" and "Exit", will, after gtk_menu_set_accel_path (menu, "<Gnumeric-Sheet>/File"); has been called, assign its items the accel paths: "<Gnumeric-Sheet>/File/New" and "<Gnumeric-Sheet>/File/Exit". Assigning accel paths to menu items then enables the user to change their accelerators at runtime. More details about accelerator paths and their default setups can be found at Gtk.Gtk.AccelMap.AddEntry.

Note that accel_path string will be stored in a GQuark. Therefore, if you pass a static string, you can save some memory by interning it first with g_intern_static_string().

menu a valid T
accel_path a valid accelerator path. [allow-none]


:SetActive(self @ T, index_ @ Std.Integer.SmallT) : Std.Object.T

Selects the specified menu item within the menu. This is used by the Gtk.Gtk.OptionMenu.T and should not be used by anyone else.

menu a T.
index_ the index of the menu item to select. Index values are from 0 to n-1.


:SetMonitor(self @ T, monitor_num @ Std.Integer.SmallT) : Std.Object.T

Informs GTK+ on which monitor a menu should be popped up. See Gtk.Gdk.Screen.GetMonitorGeometry.

This function should be called from a Gtk.Gtk.MenuPositionFunc if the menu should not appear on the same monitor as the pointer. This information can't be reliably inferred from the coordinates returned by a Gtk.Gtk.MenuPositionFunc, since, for very long menus, these coordinates may extend beyond the monitor boundaries or even the screen boundaries.

menu a T
monitor_num the number of the monitor on which the menu should be popped up


:SetReserveToggleSize(self @ T, reserve_toggle_size @ Std.Symbol.T) : Std.Object.T

Sets whether the menu should reserve space for drawing toggles or icons, regardless of their actual presence.

menu a T
reserve_toggle_size whether to reserve size for toggles


:SetScreen(self @ T, screen @ Gtk.Gdk.Screen.T) : Std.Object.T

Sets the Gtk.Gdk.Screen.T on which the menu will be displayed.

menu a T.
screen a Gtk.Gdk.Screen.T, or NULL if the screen should be determined by the widget the menu is attached to. [allow-none]


:SetTearoffState(self @ T, torn_off @ Std.Symbol.T) : Std.Object.T

Changes the tearoff state of the menu. A menu is normally displayed as drop down menu which persists as long as the menu is active. It can also be displayed as a tearoff menu which persists until it is closed or reattached.

menu a T.
torn_off If TRUE, menu is displayed as a tearoff menu.


:SetTitle(self @ T, title @ Std.String.T) : Std.Object.T

Sets the title string for the menu. The title is displayed when the menu is shown as a tearoff menu. If title is NULL, the menu will see if it is attached to a parent menu item, and if so it will try to use the same text as that menu item's label.

menu a T
title a string containing the title for the menu.