Trait gtk::prelude::GtkMenuExt [−][src]
pub trait GtkMenuExt: 'static {}Show methods
fn attach<P: IsA<Widget>>(
&self,
child: &P,
left_attach: u32,
right_attach: u32,
top_attach: u32,
bottom_attach: u32
); fn detach(&self); fn accel_group(&self) -> Option<AccelGroup>; fn accel_path(&self) -> Option<GString>; fn active(&self) -> Option<Widget>; fn attach_widget(&self) -> Option<Widget>; fn monitor(&self) -> i32; fn must_reserve_toggle_size(&self) -> bool; fn place_on_monitor(&self, monitor: &Monitor); fn popdown(&self); fn popup_at_pointer(&self, trigger_event: Option<&Event>); fn popup_at_rect(
&self,
rect_window: &Window,
rect: &Rectangle,
rect_anchor: Gravity,
menu_anchor: Gravity,
trigger_event: Option<&Event>
); fn popup_at_widget<P: IsA<Widget>>(
&self,
widget: &P,
widget_anchor: Gravity,
menu_anchor: Gravity,
trigger_event: Option<&Event>
); fn reorder_child<P: IsA<Widget>>(&self, child: &P, position: i32); fn reposition(&self); fn set_accel_group<P: IsA<AccelGroup>>(&self, accel_group: Option<&P>); fn set_accel_path(&self, accel_path: Option<&str>); fn set_active(&self, index: u32); fn set_monitor(&self, monitor_num: i32); fn set_reserve_toggle_size(&self, reserve_toggle_size: bool); fn set_screen(&self, screen: Option<&Screen>); fn anchor_hints(&self) -> AnchorHints; fn set_anchor_hints(&self, anchor_hints: AnchorHints); fn set_attach_widget<P: IsA<Widget>>(&self, attach_widget: Option<&P>); fn menu_type_hint(&self) -> WindowTypeHint; fn set_menu_type_hint(&self, menu_type_hint: WindowTypeHint); fn rect_anchor_dx(&self) -> i32; fn set_rect_anchor_dx(&self, rect_anchor_dx: i32); fn rect_anchor_dy(&self) -> i32; fn set_rect_anchor_dy(&self, rect_anchor_dy: i32); fn item_bottom_attach<T: IsA<MenuItem>>(&self, item: &T) -> i32; fn set_item_bottom_attach<T: IsA<MenuItem>>(
&self,
item: &T,
bottom_attach: i32
); fn item_left_attach<T: IsA<MenuItem>>(&self, item: &T) -> i32; fn set_item_left_attach<T: IsA<MenuItem>>(&self, item: &T, left_attach: i32); fn item_right_attach<T: IsA<MenuItem>>(&self, item: &T) -> i32; fn set_item_right_attach<T: IsA<MenuItem>>(
&self,
item: &T,
right_attach: i32
); fn item_top_attach<T: IsA<MenuItem>>(&self, item: &T) -> i32; fn set_item_top_attach<T: IsA<MenuItem>>(&self, item: &T, top_attach: i32); fn connect_move_scroll<F: Fn(&Self, ScrollType) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn emit_move_scroll(&self, scroll_type: ScrollType); fn connect_accel_group_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_accel_path_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_active_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_anchor_hints_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_attach_widget_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_menu_type_hint_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_monitor_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_rect_anchor_dx_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_rect_anchor_dy_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_reserve_toggle_size_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
Expand description
Required methods
Adds a new MenuItem
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()
.
child
a MenuItem
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
Detaches the menu from the widget to which it had been attached.
This function will call the callback function, detacher
, provided
when the gtk_menu_attach_to_widget()
function was called.
fn accel_group(&self) -> Option<AccelGroup>
fn accel_group(&self) -> Option<AccelGroup>
Gets the AccelGroup
which holds global accelerators for the
menu. See set_accel_group()
.
Returns
the AccelGroup
associated with the menu
fn accel_path(&self) -> Option<GString>
fn accel_path(&self) -> Option<GString>
fn attach_widget(&self) -> Option<Widget>
fn attach_widget(&self) -> Option<Widget>
Retrieves the number of the monitor on which to show the menu.
Returns
the number of the monitor on which the menu should be popped up or -1, if no monitor has been set
fn must_reserve_toggle_size(&self) -> bool
fn must_reserve_toggle_size(&self) -> bool
Returns whether the menu reserves space for toggles and icons, regardless of their actual presence.
Returns
Whether the menu reserves toggle space
fn place_on_monitor(&self, monitor: &Monitor)
fn place_on_monitor(&self, monitor: &Monitor)
v3_22
only.fn popup_at_pointer(&self, trigger_event: Option<&Event>)
fn popup_at_pointer(&self, trigger_event: Option<&Event>)
v3_22
only.Displays self
and makes it available for selection.
See gtk_menu_popup_at_widget () to pop up a menu at a widget. gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary rectangle.
self
will be positioned at the pointer associated with trigger_event
.
Properties that influence the behaviour of this function are
property::Menu::anchor-hints
, property::Menu::rect-anchor-dx
, property::Menu::rect-anchor-dy
, and
property::Menu::menu-type-hint
. Connect to the signal::Menu::popped-up
signal to find
out how it was actually positioned.
trigger_event
the GdkEvent
that initiated this request or
None
if it’s the current event
v3_22
only.Displays self
and makes it available for selection.
See gtk_menu_popup_at_widget () and gtk_menu_popup_at_pointer (), which handle more common cases for popping up menus.
self
will be positioned at rect
, aligning their anchor points. rect
is
relative to the top-left corner of rect_window
. rect_anchor
and
menu_anchor
determine anchor points on rect
and self
to pin together.
self
can optionally be offset by property::Menu::rect-anchor-dx
and
property::Menu::rect-anchor-dy
.
Anchors should be specified under the assumption that the text direction is left-to-right; they will be flipped horizontally automatically if the text direction is right-to-left.
Other properties that influence the behaviour of this function are
property::Menu::anchor-hints
and property::Menu::menu-type-hint
. Connect to the
signal::Menu::popped-up
signal to find out how it was actually positioned.
rect_window
the gdk::Window
rect
is relative to
rect
the gdk::Rectangle
to align self
with
rect_anchor
the point on rect
to align with self
’s anchor point
menu_anchor
the point on self
to align with rect
’s anchor point
trigger_event
the GdkEvent
that initiated this request or
None
if it’s the current event
v3_22
only.Displays self
and makes it available for selection.
See gtk_menu_popup_at_pointer () to pop up a menu at the master pointer. gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary rectangle.
self
will be positioned at widget
, aligning their anchor points.
widget_anchor
and menu_anchor
determine anchor points on widget
and self
to pin together. self
can optionally be offset by property::Menu::rect-anchor-dx
and property::Menu::rect-anchor-dy
.
Anchors should be specified under the assumption that the text direction is left-to-right; they will be flipped horizontally automatically if the text direction is right-to-left.
Other properties that influence the behaviour of this function are
property::Menu::anchor-hints
and property::Menu::menu-type-hint
. Connect to the
signal::Menu::popped-up
signal to find out how it was actually positioned.
widget
the Widget
to align self
with
widget_anchor
the point on widget
to align with self
’s anchor point
menu_anchor
the point on self
to align with widget
’s anchor point
trigger_event
the GdkEvent
that initiated this request or
None
if it’s the current event
fn reposition(&self)
fn reposition(&self)
Repositions the menu according to its position function.
fn set_accel_group<P: IsA<AccelGroup>>(&self, accel_group: Option<&P>)
fn set_accel_group<P: IsA<AccelGroup>>(&self, accel_group: Option<&P>)
Set the AccelGroup
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 GtkWindowExt::add_accel_group()
,
in order for those windows to support all the accelerators
contained in this group.
accel_group
the AccelGroup
to be associated
with the menu.
fn set_accel_path(&self, accel_path: Option<&str>)
fn set_accel_path(&self, accel_path: Option<&str>)
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 GtkMenuItemExt::set_accel_path()
on
each menu item that should support runtime user changable accelerators.
Instead, by just calling set_accel_path()
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, "
/File");
has been
called, assign its items the accel paths: "
/File/New"
and "
/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_accel_map_add_entry()
.
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()
.
accel_path
a valid accelerator path, or None
to unset the path
fn set_active(&self, index: u32)
fn set_active(&self, index: u32)
fn set_monitor(&self, monitor_num: i32)
fn set_monitor(&self, monitor_num: i32)
Informs GTK+ on which monitor a menu should be popped up.
See Monitor::geometry()
.
This function should be called from a GtkMenuPositionFunc
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 GtkMenuPositionFunc
, since, for very long menus,
these coordinates may extend beyond the monitor boundaries or even
the screen boundaries.
monitor_num
the number of the monitor on which the menu should be popped up
fn set_reserve_toggle_size(&self, reserve_toggle_size: bool)
fn set_reserve_toggle_size(&self, reserve_toggle_size: bool)
Sets whether the menu should reserve space for drawing toggles or icons, regardless of their actual presence.
reserve_toggle_size
whether to reserve size for toggles
fn set_screen(&self, screen: Option<&Screen>)
fn set_screen(&self, screen: Option<&Screen>)
Sets the gdk::Screen
on which the menu will be displayed.
screen
a gdk::Screen
, or None
if the screen should be
determined by the widget the menu is attached to
fn anchor_hints(&self) -> AnchorHints
fn anchor_hints(&self) -> AnchorHints
v3_22
only.Positioning hints for aligning the menu relative to a rectangle.
These hints determine how the menu should be positioned in the case that the menu would fall off-screen if placed in its ideal position.
For example, gdk::AnchorHints::FLIP_Y
will replace gdk::Gravity::NorthWest
with
gdk::Gravity::SouthWest
and vice versa if the menu extends beyond the
bottom edge of the monitor.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
gtk_menu_popup_at_pointer (), property::Menu::rect-anchor-dx
,
property::Menu::rect-anchor-dy
, property::Menu::menu-type-hint
, and signal::Menu::popped-up
.
fn set_anchor_hints(&self, anchor_hints: AnchorHints)
fn set_anchor_hints(&self, anchor_hints: AnchorHints)
v3_22
only.Positioning hints for aligning the menu relative to a rectangle.
These hints determine how the menu should be positioned in the case that the menu would fall off-screen if placed in its ideal position.
For example, gdk::AnchorHints::FLIP_Y
will replace gdk::Gravity::NorthWest
with
gdk::Gravity::SouthWest
and vice versa if the menu extends beyond the
bottom edge of the monitor.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
gtk_menu_popup_at_pointer (), property::Menu::rect-anchor-dx
,
property::Menu::rect-anchor-dy
, property::Menu::menu-type-hint
, and signal::Menu::popped-up
.
The widget the menu is attached to. Setting this property attaches
the menu without a GtkMenuDetachFunc
. If you need to use a detacher,
use gtk_menu_attach_to_widget()
directly.
v3_22
only.The gdk::WindowTypeHint
to use for the menu’s gdk::Window
.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
gtk_menu_popup_at_pointer (), property::Menu::anchor-hints
,
property::Menu::rect-anchor-dx
, property::Menu::rect-anchor-dy
, and signal::Menu::popped-up
.
v3_22
only.The gdk::WindowTypeHint
to use for the menu’s gdk::Window
.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
gtk_menu_popup_at_pointer (), property::Menu::anchor-hints
,
property::Menu::rect-anchor-dx
, property::Menu::rect-anchor-dy
, and signal::Menu::popped-up
.
fn rect_anchor_dx(&self) -> i32
fn rect_anchor_dx(&self) -> i32
v3_22
only.Horizontal offset to apply to the menu, i.e. the rectangle or widget anchor.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
gtk_menu_popup_at_pointer (), property::Menu::anchor-hints
,
property::Menu::rect-anchor-dy
, property::Menu::menu-type-hint
, and signal::Menu::popped-up
.
fn set_rect_anchor_dx(&self, rect_anchor_dx: i32)
fn set_rect_anchor_dx(&self, rect_anchor_dx: i32)
v3_22
only.Horizontal offset to apply to the menu, i.e. the rectangle or widget anchor.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
gtk_menu_popup_at_pointer (), property::Menu::anchor-hints
,
property::Menu::rect-anchor-dy
, property::Menu::menu-type-hint
, and signal::Menu::popped-up
.
fn rect_anchor_dy(&self) -> i32
fn rect_anchor_dy(&self) -> i32
v3_22
only.Vertical offset to apply to the menu, i.e. the rectangle or widget anchor.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
gtk_menu_popup_at_pointer (), property::Menu::anchor-hints
,
property::Menu::rect-anchor-dx
, property::Menu::menu-type-hint
, and signal::Menu::popped-up
.
fn set_rect_anchor_dy(&self, rect_anchor_dy: i32)
fn set_rect_anchor_dy(&self, rect_anchor_dy: i32)
v3_22
only.Vertical offset to apply to the menu, i.e. the rectangle or widget anchor.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
gtk_menu_popup_at_pointer (), property::Menu::anchor-hints
,
property::Menu::rect-anchor-dx
, property::Menu::menu-type-hint
, and signal::Menu::popped-up
.
fn connect_move_scroll<F: Fn(&Self, ScrollType) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_move_scroll<F: Fn(&Self, ScrollType) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn emit_move_scroll(&self, scroll_type: ScrollType)
fn connect_accel_group_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_accel_path_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_anchor_hints_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_anchor_hints_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
v3_22
only.fn connect_attach_widget_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
v3_22
only.fn connect_monitor_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_rect_anchor_dx_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_rect_anchor_dx_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
v3_22
only.fn connect_rect_anchor_dy_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_rect_anchor_dy_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
v3_22
only.fn connect_reserve_toggle_size_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId