Trait gtk4::prelude::WidgetExt

source ·
pub trait WidgetExt: 'static {
Show 206 methods fn action_set_enabled(&self, action_name: &str, enabled: bool); fn activate(&self) -> bool; fn activate_action(
        &self,
        name: &str,
        args: Option<&Variant>
    ) -> Result<(), BoolError>; fn activate_default(&self); fn add_controller(&self, controller: impl IsA<EventController>); fn add_css_class(&self, css_class: &str); fn add_mnemonic_label(&self, label: &impl IsA<Widget>); fn allocate(
        &self,
        width: i32,
        height: i32,
        baseline: i32,
        transform: Option<Transform>
    ); fn child_focus(&self, direction: DirectionType) -> bool; fn compute_bounds(&self, target: &impl IsA<Widget>) -> Option<Rect>; fn compute_expand(&self, orientation: Orientation) -> bool; fn compute_point(
        &self,
        target: &impl IsA<Widget>,
        point: &Point
    ) -> Option<Point>; fn compute_transform(&self, target: &impl IsA<Widget>) -> Option<Matrix>; fn contains(&self, x: f64, y: f64) -> bool; fn create_pango_context(&self) -> Context; fn create_pango_layout(&self, text: Option<&str>) -> Layout; fn drag_check_threshold(
        &self,
        start_x: i32,
        start_y: i32,
        current_x: i32,
        current_y: i32
    ) -> bool; fn error_bell(&self); fn allocated_baseline(&self) -> i32; fn allocated_height(&self) -> i32; fn allocated_width(&self) -> i32; fn allocation(&self) -> Allocation; fn ancestor(&self, widget_type: Type) -> Option<Widget>; fn can_focus(&self) -> bool; fn can_target(&self) -> bool; fn is_child_visible(&self) -> bool; fn clipboard(&self) -> Clipboard; fn color(&self) -> RGBA; fn css_classes(&self) -> Vec<GString>; fn css_name(&self) -> GString; fn cursor(&self) -> Option<Cursor>; fn direction(&self) -> TextDirection; fn display(&self) -> Display; fn first_child(&self) -> Option<Widget>; fn focus_child(&self) -> Option<Widget>; fn gets_focus_on_click(&self) -> bool; fn is_focusable(&self) -> bool; fn font_map(&self) -> Option<FontMap>; fn font_options(&self) -> Option<FontOptions>; fn frame_clock(&self) -> Option<FrameClock>; fn halign(&self) -> Align; fn has_tooltip(&self) -> bool; fn height(&self) -> i32; fn hexpands(&self) -> bool; fn is_hexpand_set(&self) -> bool; fn last_child(&self) -> Option<Widget>; fn layout_manager(&self) -> Option<LayoutManager>; fn is_mapped(&self) -> bool; fn margin_bottom(&self) -> i32; fn margin_end(&self) -> i32; fn margin_start(&self) -> i32; fn margin_top(&self) -> i32; fn widget_name(&self) -> GString; fn native(&self) -> Option<Native>; fn next_sibling(&self) -> Option<Widget>; fn opacity(&self) -> f64; fn overflow(&self) -> Overflow; fn pango_context(&self) -> Context; fn parent(&self) -> Option<Widget>; fn preferred_size(&self) -> (Requisition, Requisition); fn prev_sibling(&self) -> Option<Widget>; fn primary_clipboard(&self) -> Clipboard; fn is_realized(&self) -> bool; fn receives_default(&self) -> bool; fn request_mode(&self) -> SizeRequestMode; fn root(&self) -> Option<Root>; fn scale_factor(&self) -> i32; fn get_sensitive(&self) -> bool; fn settings(&self) -> Settings; fn size(&self, orientation: Orientation) -> i32; fn size_request(&self) -> (i32, i32); fn state_flags(&self) -> StateFlags; fn style_context(&self) -> StyleContext; fn tooltip_markup(&self) -> Option<GString>; fn tooltip_text(&self) -> Option<GString>; fn valign(&self) -> Align; fn vexpands(&self) -> bool; fn is_vexpand_set(&self) -> bool; fn get_visible(&self) -> bool; fn width(&self) -> i32; fn grab_focus(&self) -> bool; fn has_css_class(&self, css_class: &str) -> bool; fn has_default(&self) -> bool; fn has_focus(&self) -> bool; fn has_visible_focus(&self) -> bool; fn hide(&self); fn in_destruction(&self) -> bool; fn insert_action_group(
        &self,
        name: &str,
        group: Option<&impl IsA<ActionGroup>>
    ); fn insert_after(
        &self,
        parent: &impl IsA<Widget>,
        previous_sibling: Option<&impl IsA<Widget>>
    ); fn insert_before(
        &self,
        parent: &impl IsA<Widget>,
        next_sibling: Option<&impl IsA<Widget>>
    ); fn is_ancestor(&self, ancestor: &impl IsA<Widget>) -> bool; fn is_drawable(&self) -> bool; fn is_focus(&self) -> bool; fn is_sensitive(&self) -> bool; fn is_visible(&self) -> bool; fn keynav_failed(&self, direction: DirectionType) -> bool; fn list_mnemonic_labels(&self) -> Vec<Widget>; fn map(&self); fn measure(
        &self,
        orientation: Orientation,
        for_size: i32
    ) -> (i32, i32, i32, i32); fn mnemonic_activate(&self, group_cycling: bool) -> bool; fn observe_children(&self) -> ListModel; fn observe_controllers(&self) -> ListModel; fn pick(&self, x: f64, y: f64, flags: PickFlags) -> Option<Widget>; fn queue_allocate(&self); fn queue_draw(&self); fn queue_resize(&self); fn realize(&self); fn remove_controller(&self, controller: &impl IsA<EventController>); fn remove_css_class(&self, css_class: &str); fn remove_mnemonic_label(&self, label: &impl IsA<Widget>); fn set_can_focus(&self, can_focus: bool); fn set_can_target(&self, can_target: bool); fn set_child_visible(&self, child_visible: bool); fn set_css_classes(&self, classes: &[&str]); fn set_cursor(&self, cursor: Option<&Cursor>); fn set_cursor_from_name(&self, name: Option<&str>); fn set_direction(&self, dir: TextDirection); fn set_focus_child(&self, child: Option<&impl IsA<Widget>>); fn set_focus_on_click(&self, focus_on_click: bool); fn set_focusable(&self, focusable: bool); fn set_font_map(&self, font_map: Option<&impl IsA<FontMap>>); fn set_font_options(&self, options: Option<&FontOptions>); fn set_halign(&self, align: Align); fn set_has_tooltip(&self, has_tooltip: bool); fn set_hexpand(&self, expand: bool); fn set_hexpand_set(&self, set: bool); fn set_layout_manager(&self, layout_manager: Option<impl IsA<LayoutManager>>); fn set_margin_bottom(&self, margin: i32); fn set_margin_end(&self, margin: i32); fn set_margin_start(&self, margin: i32); fn set_margin_top(&self, margin: i32); fn set_widget_name(&self, name: &str); fn set_opacity(&self, opacity: f64); fn set_overflow(&self, overflow: Overflow); fn set_parent(&self, parent: &impl IsA<Widget>); fn set_receives_default(&self, receives_default: bool); fn set_sensitive(&self, sensitive: bool); fn set_size_request(&self, width: i32, height: i32); fn set_state_flags(&self, flags: StateFlags, clear: bool); fn set_tooltip_markup(&self, markup: Option<&str>); fn set_tooltip_text(&self, text: Option<&str>); fn set_valign(&self, align: Align); fn set_vexpand(&self, expand: bool); fn set_vexpand_set(&self, set: bool); fn set_visible(&self, visible: bool); fn should_layout(&self) -> bool; fn show(&self); fn size_allocate(&self, allocation: &Allocation, baseline: i32); fn snapshot_child(
        &self,
        child: &impl IsA<Widget>,
        snapshot: &impl IsA<Snapshot>
    ); fn translate_coordinates(
        &self,
        dest_widget: &impl IsA<Widget>,
        src_x: f64,
        src_y: f64
    ) -> Option<(f64, f64)>; fn trigger_tooltip_query(&self); fn unmap(&self); fn unparent(&self); fn unrealize(&self); fn unset_state_flags(&self, flags: StateFlags); fn height_request(&self) -> i32; fn set_height_request(&self, height_request: i32); fn width_request(&self) -> i32; fn set_width_request(&self, width_request: i32); fn connect_destroy<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_direction_changed<F: Fn(&Self, TextDirection) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_hide<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_keynav_failed<F: Fn(&Self, DirectionType) -> Inhibit + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_map<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_mnemonic_activate<F: Fn(&Self, bool) -> Inhibit + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_move_focus<F: Fn(&Self, DirectionType) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn emit_move_focus(&self, direction: DirectionType); fn connect_query_tooltip<F: Fn(&Self, i32, i32, bool, &Tooltip) -> bool + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_realize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_show<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_state_flags_changed<F: Fn(&Self, StateFlags) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_unmap<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_unrealize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_can_focus_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_can_target_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_css_classes_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_cursor_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_focus_on_click_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_focusable_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_halign_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_has_default_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_has_focus_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_has_tooltip_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_height_request_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_hexpand_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_hexpand_set_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_layout_manager_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_margin_bottom_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_margin_end_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_margin_start_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_margin_top_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_name_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_opacity_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_overflow_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_parent_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_receives_default_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_root_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_scale_factor_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_sensitive_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_tooltip_markup_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_tooltip_text_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_valign_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_vexpand_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_vexpand_set_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_visible_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_width_request_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
}
Expand description

Required Methods§

Enable or disable an action installed with gtk_widget_class_install_action().

action_name

action name, such as “clipboard.paste”

enabled

whether the action is now enabled

For widgets that can be “activated” (buttons, menu items, etc.), this function activates them.

The activation will emit the signal set using Gtk::WidgetClass::set_activate_signal() during class initialization.

Activation is what happens when you press Enter on a widget during key navigation.

If you wish to handle the activation keybinding yourself, it is recommended to use Gtk::WidgetClass::add_shortcut() with an action created with SignalAction::new().

If @self isn’t activatable, the function returns false.

Returns

true if the widget was activatable

Looks up the action in the action groups associated with @self and its ancestors, and activates it.

If the action is in an action group added with insert_action_group(), the @name is expected to be prefixed with the prefix that was used when the group was inserted.

The arguments must match the actions expected parameter type, as returned by g_action_get_parameter_type().

name

the name of the action to activate

args

parameters to use

Returns

true if the action was activated, false if the action does not exist.

Activates the default.activate action from @self.

Adds @controller to @self so that it will receive events.

You will usually want to call this function right after creating any kind of EventController.

controller

a EventController that hasn’t been added to a widget yet

Available on crate feature v4_10 only.

Implementors§