Class: Gtk::Widget
- Inherits:
-
Object
- Object
- Gtk::Widget
- Defined in:
- (unknown)
Instance Method Summary collapse
-
#accessible ⇒ Atk::Object
Returns the accessible object that describes the widget to an assistive technology.
-
#accessible_role=(role) ⇒ nil
Sets the default Atk::Role to be set on accessibles created for widgets of widget_class.
-
#accessible_type=(type) ⇒ nil
Sets the type to be used for creating accessibles for widgets of widget_class.
-
#activate ⇒ TrueClass
For widgets that can be “activated” (buttons, menu items, etc.) this function activates them.
-
#add_accelerator(accel_signal, accel_group, accel_key, accel_mods, accel_flags) ⇒ nil
Installs an accelerator for this widget in accel_group that causes accel_signal to be emitted if the accelerator is activated.
-
#add_device_events(device, events) ⇒ nil
Adds the device events in the bitfield events to the event mask for widget.
-
#add_events(events) ⇒ nil
Adds the events in the bitfield events to the event mask for widget.
-
#add_mnemonic_label(label) ⇒ nil
Adds a widget to the list of mnemonic labels for this widget.
-
#add_tick_callback(callback, user_data, notify) ⇒ Integer
Queues an animation frame update and adds a callback to be called before each frame.
-
#allocated_baseline ⇒ Integer
Returns the baseline that has currently been allocated to widget.
-
#allocated_height ⇒ Integer
Returns the height that has currently been allocated to widget.
-
#allocated_width ⇒ Integer
Returns the width that has currently been allocated to widget.
-
#allocation=(allocation) ⇒ nil
Sets the widget’s allocation.
-
#app_paintable ⇒ TrueClass
Determines whether the application intends to draw on the widget in an Gtk::Widget::draw handler.
- #app_paintable=(app_paintable) ⇒ TrueClass
-
#app_paintable? ⇒ TrueClass
App-paintable.
-
#bind_template_callback_full(callback_name, callback_symbol) ⇒ nil
Declares a callback_symbol to handle callback_name from the template XML defined for widget_type.
-
#bind_template_child_full(name, internal_child, struct_offset) ⇒ nil
Automatically assign an object declared in the class template XML to be set to a location on a freshly built instance’s private data, or alternatively accessible via gtk_widget_get_template_child().
-
#can_activate_accel(signal_id) ⇒ TrueClass
Determines whether an accelerator that activates the signal identified by signal_id can currently be activated.
-
#can_default ⇒ TrueClass
Determines whether widget can be a default widget.
- #can_default=(can_default) ⇒ TrueClass
-
#can_default? ⇒ TrueClass
Can-default.
-
#can_focus ⇒ TrueClass
Determines whether widget can own the input focus.
- #can_focus=(can_focus) ⇒ TrueClass
-
#can_focus? ⇒ TrueClass
Can-focus.
-
#child_focus(direction) ⇒ TrueClass
This function is used by custom widget implementations; if you’re writing an app, you’d use gtk_widget_grab_focus() to move the focus to a particular widget, and gtk_container_set_focus_chain() to change the focus tab order.
-
#child_notify(child_property) ⇒ nil
Emits a Gtk::Widget::child-notify signal for the [child property] child_property on widget.
-
#child_visible ⇒ TrueClass
Gets the value set with gtk_widget_set_child_visible().
-
#child_visible=(is_visible) ⇒ nil
Sets whether widget should be mapped along with its when its parent is mapped and widget has been shown with gtk_widget_show().
-
#class_path(path_length, path, path_reversed) ⇒ nil
Same as gtk_widget_path(), but always uses the name of a widget’s type, never uses a custom name set with gtk_widget_set_name().
-
#clip=(clip) ⇒ nil
Sets the widget’s clip.
- #composite_child=(composite_child) ⇒ TrueClass
-
#composite_child? ⇒ TrueClass
Composite-child.
-
#composite_name ⇒ String
Obtains the composite name of a widget.
-
#composite_name=(name) ⇒ nil
Sets a widgets composite name.
-
#compute_expand(orientation) ⇒ TrueClass
Computes whether a container should give this widget extra space when possible.
-
#create_pango_context ⇒ Pango::Context
Creates a new Pango::Context with the appropriate font map, font options, font description, and base direction for drawing text for this widget.
-
#create_pango_layout(text) ⇒ Pango::Layout
Creates a new Pango::Layout with the appropriate font map, font description, and base direction for drawing text for this widget.
-
#css_name ⇒ String
Gets the name used by this class for matching in CSS code.
-
#css_name=(name) ⇒ nil
Sets the name to be used for CSS matching of widgets.
-
#destroy ⇒ nil
Destroys a widget.
-
#destroyed(widget_pointer) ⇒ nil
This function sets *widget_pointer to nil if widget_pointer != nil.
-
#device_is_shadowed(device) ⇒ TrueClass
Returns true if device has been shadowed by a GTK+ device grab on another widget, so it would stop sending events to widget.
-
#direction ⇒ Gtk::TextDirection
Gets the reading direction for a particular widget.
-
#direction=(dir) ⇒ nil
Sets the reading direction on a particular widget.
-
#display ⇒ Gdk::Display
Get the Gdk::Display for the toplevel window associated with this widget.
-
#double_buffered ⇒ TrueClass
Determines whether the widget is double buffered.
-
#double_buffered=(double_buffered) ⇒ TrueClass
Whether the widget is double buffered.
-
#double_buffered? ⇒ TrueClass
Whether the widget is double buffered.
-
#drag_begin(targets, actions, button, event) ⇒ Gdk::DragContext
This function is equivalent to gtk_drag_begin_with_coordinates(), passing -1, -1 as coordinates.
-
#drag_begin_with_coordinates(targets, actions, button, event, x, y) ⇒ Gdk::DragContext
Initiates a drag on the source side.
-
#drag_check_threshold(start_x, start_y, current_x, current_y) ⇒ TrueClass
Checks to see if a mouse drag starting at (start_x, start_y) and ending at (current_x, current_y) has passed the GTK+ drag threshold, and thus should trigger the beginning of a drag-and-drop operation.
-
#drag_dest_add_image_targets ⇒ nil
Add the image targets supported by Gtk::SelectionData to the target list of the drag destination.
-
#drag_dest_add_text_targets ⇒ nil
Add the text targets supported by Gtk::SelectionData to the target list of the drag destination.
-
#drag_dest_add_uri_targets ⇒ nil
Add the URI targets supported by Gtk::SelectionData to the target list of the drag destination.
-
#drag_dest_find_target(context, target_list) ⇒ Gdk::Atom
Looks for a match between the supported targets of context and the dest_target_list, returning the first matching target, otherwise returning %GDK_NONE.
-
#drag_dest_get_target_list ⇒ Gtk::TargetList
Returns the list of targets this widget can accept from drag-and-drop.
-
#drag_dest_get_track_motion ⇒ TrueClass
Returns whether the widget has been configured to always emit Gtk::Widget::drag-motion signals.
-
#drag_dest_set(flags, targets, n_targets, actions) ⇒ nil
Sets a widget as a potential drop destination, and adds default behaviors.
-
#drag_dest_set_proxy(proxy_window, protocol, use_coordinates) ⇒ nil
Sets this widget as a proxy for drops to another window.
-
#drag_dest_set_target_list(target_list) ⇒ nil
Sets the target types that this widget can accept from drag-and-drop.
-
#drag_dest_set_track_motion(track_motion) ⇒ nil
Tells the widget to emit Gtk::Widget::drag-motion and Gtk::Widget::drag-leave events regardless of the targets and the %GTK_DEST_DEFAULT_MOTION flag.
-
#drag_dest_unset ⇒ nil
Clears information about a drop destination set with gtk_drag_dest_set().
-
#drag_get_data(context, target, time_) ⇒ nil
Gets the data associated with a drag.
-
#drag_highlight ⇒ nil
Highlights a widget as a currently hovered drop target.
-
#drag_source_add_image_targets ⇒ nil
Add the writable image targets supported by Gtk::SelectionData to the target list of the drag source.
-
#drag_source_add_text_targets ⇒ nil
Add the text targets supported by Gtk::SelectionData to the target list of the drag source.
-
#drag_source_add_uri_targets ⇒ nil
Add the URI targets supported by Gtk::SelectionData to the target list of the drag source.
-
#drag_source_get_target_list ⇒ Gtk::TargetList
Gets the list of targets this widget can provide for drag-and-drop.
-
#drag_source_set(start_button_mask, targets, n_targets, actions) ⇒ nil
Sets up a widget so that GTK+ will start a drag operation when the user clicks and drags on the widget.
-
#drag_source_set_icon_gicon(icon) ⇒ nil
Sets the icon that will be used for drags from a particular source to icon.
-
#drag_source_set_icon_name(icon_name) ⇒ nil
Sets the icon that will be used for drags from a particular source to a themed icon.
-
#drag_source_set_icon_pixbuf(pixbuf) ⇒ nil
Sets the icon that will be used for drags from a particular widget from a Gdk::Pixbuf.
-
#drag_source_set_icon_stock(stock_id) ⇒ nil
Sets the icon that will be used for drags from a particular source to a stock icon.
-
#drag_source_set_target_list(target_list) ⇒ nil
Changes the target types that this widget offers for drag-and-drop.
-
#drag_source_unset ⇒ nil
Undoes the effects of gtk_drag_source_set().
-
#drag_unhighlight ⇒ nil
Removes a highlight set by gtk_drag_highlight() from a widget.
-
#draw(cr) ⇒ nil
Draws widget to cr.
-
#ensure_style ⇒ nil
Ensures that widget has a style (widget->style).
-
#error_bell ⇒ nil
Notifies the user about an input-related error on this widget.
-
#event(event) ⇒ TrueClass
Rarely-used function.
-
#events ⇒ Gdk::EventMask
Events.
- #events=(events) ⇒ Gdk::EventMask
-
#expand=(expand) ⇒ TrueClass
Whether to expand in both directions.
-
#expand? ⇒ TrueClass
Whether to expand in both directions.
-
#find_style_property(property_name) ⇒ GObject::ParamSpec
Finds a style property of a widget class by name.
-
#focus_on_click ⇒ TrueClass
Returns whether the widget should grab focus when it is clicked with the mouse.
-
#focus_on_click=(focus_on_click) ⇒ TrueClass
Whether the widget should grab focus when it is clicked with the mouse.
-
#focus_on_click? ⇒ TrueClass
Whether the widget should grab focus when it is clicked with the mouse.
-
#font_map ⇒ Pango::FontMap
Gets the font map that has been set with gtk_widget_set_font_map().
-
#font_map=(font_map) ⇒ nil
Sets the font map to use for Pango rendering.
-
#font_options ⇒ cairo::FontOptions
Returns the #cairo_font_options_t used for Pango rendering.
-
#font_options=(options) ⇒ nil
Sets the #cairo_font_options_t used for Pango rendering in this widget.
-
#frame_clock ⇒ Gdk::FrameClock
Obtains the frame clock for a widget.
-
#freeze_child_notify ⇒ nil
Stops emission of Gtk::Widget::child-notify signals on widget.
-
#get_action_group(prefix) ⇒ Gio::ActionGroup
Retrieves the GAction::Group that was registered using prefix.
-
#get_allocated_size(allocation, baseline) ⇒ nil
Retrieves the widget’s allocated size.
-
#get_allocation(allocation) ⇒ nil
Retrieves the widget’s allocation.
-
#get_ancestor(widget_type) ⇒ Gtk::Widget
Gets the first ancestor of widget with type widget_type.
-
#get_child_requisition(requisition) ⇒ nil
This function is only for use in widget implementations.
-
#get_clip(clip) ⇒ nil
Retrieves the widget’s clip area.
-
#get_clipboard(selection) ⇒ Gtk::Clipboard
Returns the clipboard object for the given selection to be used with widget.
-
#get_device_enabled(device) ⇒ TrueClass
Returns whether device can interact with widget and its children.
-
#get_device_events(device) ⇒ Gdk::EventMask
Returns the events mask for the widget corresponding to an specific device.
-
#get_modifier_mask(intent) ⇒ Gdk::ModifierType
Returns the modifier mask the widget’s windowing system backend uses for a particular purpose.
-
#get_pointer(x, y) ⇒ nil
Obtains the location of the mouse pointer in widget coordinates.
-
#get_preferred_height(minimum_height, natural_height) ⇒ nil
Retrieves a widget’s initial minimum and natural height.
-
#get_preferred_height_and_baseline_for_width(width, minimum_height, natural_height, minimum_baseline, natural_baseline) ⇒ nil
Retrieves a widget’s minimum and natural height and the corresponding baselines if it would be given the specified width, or the default height if width is -1.
-
#get_preferred_height_for_width(width, minimum_height, natural_height) ⇒ nil
Retrieves a widget’s minimum and natural height if it would be given the specified width.
-
#get_preferred_size(minimum_size, natural_size) ⇒ nil
Retrieves the minimum and natural size of a widget, taking into account the widget’s preference for height-for-width management.
-
#get_preferred_width(minimum_width, natural_width) ⇒ nil
Retrieves a widget’s initial minimum and natural width.
-
#get_preferred_width_for_height(height, minimum_width, natural_width) ⇒ nil
Retrieves a widget’s minimum and natural width if it would be given the specified height.
-
#get_requisition(requisition) ⇒ nil
Retrieves the widget’s requisition.
-
#get_size_request(width, height) ⇒ nil
Gets the size request that was explicitly set for the widget using gtk_widget_set_size_request().
-
#get_template_child(widget_type, name) ⇒ GObject::Object
Fetch an object build from the template XML for widget_type in this widget instance.
-
#grab_add ⇒ nil
Makes widget the current grabbed widget.
-
#grab_default ⇒ nil
Causes widget to become the default widget.
-
#grab_focus ⇒ nil
Causes widget to have the keyboard focus for the Gtk::Window it’s inside.
-
#grab_remove ⇒ nil
Removes the grab from the given widget.
-
#halign ⇒ Gtk::Align
How to distribute horizontal space if widget gets extra space, see Gtk::Align.
-
#halign=(halign) ⇒ Gtk::Align
How to distribute horizontal space if widget gets extra space, see Gtk::Align.
-
#has_default ⇒ TrueClass
Determines whether widget is the current default widget within its toplevel.
- #has_default=(has_default) ⇒ TrueClass
-
#has_default? ⇒ TrueClass
Has-default.
-
#has_focus ⇒ TrueClass
Determines if the widget has the global input focus.
- #has_focus=(has_focus) ⇒ TrueClass
-
#has_focus? ⇒ TrueClass
Has-focus.
-
#has_grab ⇒ TrueClass
Determines whether the widget is currently grabbing events, so it is the only widget receiving input events (keyboard and mouse).
-
#has_rc_style ⇒ TrueClass
Determines if the widget style has been looked up through the rc mechanism.
-
#has_screen ⇒ TrueClass
Checks whether there is a Gdk::Screen is associated with this widget.
-
#has_tooltip ⇒ TrueClass
Returns the current value of the has-tooltip property.
-
#has_tooltip=(has_tooltip) ⇒ TrueClass
Enables or disables the emission of Gtk::Widget::query-tooltip on widget.
-
#has_tooltip? ⇒ TrueClass
Enables or disables the emission of Gtk::Widget::query-tooltip on widget.
-
#has_visible_focus ⇒ TrueClass
Determines if the widget should show a visible indication that it has the global input focus.
-
#has_window ⇒ TrueClass
Determines whether widget has a Gdk::Window of its own.
-
#has_window=(has_window) ⇒ nil
Specifies whether widget has a Gdk::Window of its own.
-
#height_request ⇒ Integer
Height-request.
- #height_request=(height_request) ⇒ Integer
-
#hexpand ⇒ TrueClass
Gets whether the widget would like any available extra horizontal space.
-
#hexpand=(hexpand) ⇒ TrueClass
Whether to expand horizontally.
-
#hexpand? ⇒ TrueClass
Whether to expand horizontally.
-
#hexpand_set ⇒ TrueClass
Gets whether gtk_widget_set_hexpand() has been used to explicitly set the expand flag on this widget.
-
#hexpand_set=(hexpand_set) ⇒ TrueClass
Whether to use the Gtk::Widget:hexpand property.
-
#hexpand_set? ⇒ TrueClass
Whether to use the Gtk::Widget:hexpand property.
-
#hide ⇒ nil
Reverses the effects of gtk_widget_show(), causing the widget to be hidden (invisible to the user).
-
#hide_on_delete ⇒ TrueClass
Utility function; intended to be connected to the Gtk::Widget::delete-event signal on a Gtk::Window.
-
#in_destruction ⇒ TrueClass
Returns whether the widget is currently being destroyed.
-
#init_template ⇒ nil
Creates and initializes child widgets defined in templates.
-
#input_shape_combine_region(region) ⇒ nil
Sets an input shape for this widget’s GDK window.
-
#insert_action_group(name, group) ⇒ nil
Inserts group into widget.
-
#install_style_property(pspec) ⇒ nil
Installs a style property on a widget class.
-
#install_style_property_parser(pspec, parser) ⇒ nil
Installs a style property on a widget class.
-
#intersect(area, intersection) ⇒ TrueClass
Computes the intersection of a widget’s area and area, storing the intersection in intersection, and returns true if there was an intersection.
-
#is_ancestor(ancestor) ⇒ TrueClass
Determines whether widget is somewhere inside ancestor, possibly with intermediate containers.
-
#is_composited ⇒ TrueClass
Whether widget can rely on having its alpha channel drawn correctly.
-
#is_drawable ⇒ TrueClass
Determines whether widget can be drawn to.
-
#is_focus ⇒ TrueClass
Determines if the widget is the focus widget within its toplevel.
- #is_focus=(is_focus) ⇒ TrueClass
-
#is_focus? ⇒ TrueClass
Is-focus.
-
#is_sensitive ⇒ TrueClass
Returns the widget’s effective sensitivity, which means it is sensitive itself and also its parent widget is sensitive.
-
#is_toplevel ⇒ TrueClass
Determines whether widget is a toplevel widget.
-
#is_visible ⇒ TrueClass
Determines whether the widget and all its parents are marked as visible.
-
#keynav_failed(direction) ⇒ TrueClass
This function should be called whenever keyboard navigation within a single widget hits a boundary.
-
#list_accel_closures ⇒ GLib::List
Lists the closures used by widget for accelerator group connections with gtk_accel_group_connect_by_path() or gtk_accel_group_connect().
-
#list_action_prefixes ⇒ Array<String>
Retrieves an array of strings containing the prefixes of GAction::Group’s available to widget.
-
#list_mnemonic_labels ⇒ GLib::List
Returns a newly allocated list of the widgets, normally labels, for which this widget is the target of a mnemonic (see for example, gtk_label_set_mnemonic_widget()).
-
#list_style_properties(n_properties) ⇒ Array<GObject::ParamSpec>
Returns all style properties of a widget class.
-
#map ⇒ nil
This function is only for use in widget implementations.
-
#mapped ⇒ TrueClass
Whether the widget is mapped.
-
#mapped=(mapped) ⇒ nil
Marks the widget as being mapped.
-
#margin ⇒ Integer
Sets all four sides’ margin at once.
-
#margin=(margin) ⇒ Integer
Sets all four sides’ margin at once.
-
#margin_bottom ⇒ Integer
Margin on bottom side of widget.
-
#margin_bottom=(margin_bottom) ⇒ Integer
Margin on bottom side of widget.
-
#margin_end ⇒ Integer
Margin on end of widget, horizontally.
-
#margin_end=(margin_end) ⇒ Integer
Margin on end of widget, horizontally.
-
#margin_left ⇒ Integer
Margin on left side of widget.
-
#margin_left=(margin_left) ⇒ Integer
Margin on left side of widget.
-
#margin_right ⇒ Integer
Margin on right side of widget.
-
#margin_right=(margin_right) ⇒ Integer
Margin on right side of widget.
-
#margin_start ⇒ Integer
Margin on start of widget, horizontally.
-
#margin_start=(margin_start) ⇒ Integer
Margin on start of widget, horizontally.
-
#margin_top ⇒ Integer
Margin on top side of widget.
-
#margin_top=(margin_top) ⇒ Integer
Margin on top side of widget.
-
#mnemonic_activate(group_cycling) ⇒ TrueClass
Emits the Gtk::Widget::mnemonic-activate signal.
-
#modifier_style ⇒ Gtk::RcStyle
Returns the current modifier style for the widget.
-
#modify_base(state, color) ⇒ nil
Sets the base color for a widget in a particular state.
-
#modify_bg(state, color) ⇒ nil
Sets the background color for a widget in a particular state.
-
#modify_cursor(primary, secondary) ⇒ nil
Sets the cursor color to use in a widget, overriding the Gtk::Widget cursor-color and secondary-cursor-color style properties.
-
#modify_fg(state, color) ⇒ nil
Sets the foreground color for a widget in a particular state.
-
#modify_font(font_desc) ⇒ nil
Sets the font to use for a widget.
-
#modify_style(style) ⇒ nil
Modifies style values on the widget.
-
#modify_text(state, color) ⇒ nil
Sets the text color for a widget in a particular state.
-
#name ⇒ String
Name.
- #name=(name) ⇒ String
-
#new(type, first_property_name, array) ⇒ Gtk::Widget
This is a convenience function for creating a widget and setting its properties in one go.
-
#no_show_all ⇒ TrueClass
Returns the current value of the Gtk::Widget:no-show-all property, which determines whether calls to gtk_widget_show_all() will affect this widget.
- #no_show_all=(no_show_all) ⇒ TrueClass
-
#no_show_all? ⇒ TrueClass
No-show-all.
-
#opacity ⇒ Float
The requested opacity of the widget.
-
#opacity=(opacity) ⇒ Float
The requested opacity of the widget.
-
#override_background_color(state, color) ⇒ nil
Sets the background color to use for a widget.
-
#override_color(state, color) ⇒ nil
Sets the color to use for a widget.
-
#override_cursor(cursor, secondary_cursor) ⇒ nil
Sets the cursor color to use in a widget, overriding the cursor-color and secondary-cursor-color style properties.
-
#override_font(font_desc) ⇒ nil
Sets the font to use for a widget.
-
#override_symbolic_color(name, color) ⇒ nil
Sets a symbolic color for a widget.
-
#pango_context ⇒ Pango::Context
Gets a Pango::Context with the appropriate font map, font description, and base direction for this widget.
-
#parent ⇒ Gtk::Container
Parent.
- #parent=(parent) ⇒ Gtk::Container
-
#parent_window ⇒ Gdk::Window
Gets widget’s parent window, or nil if it does not have one.
-
#parent_window=(parent_window) ⇒ nil
Sets a non default parent window for widget.
-
#path(path_length, path, path_reversed) ⇒ nil
Obtains the full path to widget.
-
#queue_allocate ⇒ nil
This function is only for use in widget implementations.
-
#queue_compute_expand ⇒ nil
Mark widget as needing to recompute its expand flags.
-
#queue_draw ⇒ nil
Equivalent to calling gtk_widget_queue_draw_area() for the entire area of a widget.
-
#queue_draw_area(x, y, width, height) ⇒ nil
Convenience function that calls gtk_widget_queue_draw_region() on the region created from the given coordinates.
-
#queue_draw_region(region) ⇒ nil
Invalidates the area of widget defined by region by calling gdk_window_invalidate_region() on the widget’s window and all its child windows.
-
#queue_resize ⇒ nil
This function is only for use in widget implementations.
-
#queue_resize_no_redraw ⇒ nil
This function works like gtk_widget_queue_resize(), except that the widget is not invalidated.
-
#realize ⇒ nil
Creates the GDK (windowing system) resources associated with a widget.
-
#realized ⇒ TrueClass
Determines whether widget is realized.
-
#realized=(realized) ⇒ nil
Marks the widget as being realized.
-
#receives_default ⇒ TrueClass
Determines whether widget is always treated as the default widget within its toplevel when it has the focus, even if another widget is the default.
- #receives_default=(receives_default) ⇒ TrueClass
-
#receives_default? ⇒ TrueClass
Receives-default.
-
#redraw_on_allocate=(redraw_on_allocate) ⇒ nil
Sets whether the entire widget is queued for drawing when its size allocation changes.
-
#region_intersect(region) ⇒ cairo::Region
Computes the intersection of a widget’s area and region, returning the intersection.
-
#register_window(window) ⇒ nil
Registers a Gdk::Window with the widget and sets it up so that the widget receives events for it.
-
#remove_accelerator(accel_group, accel_key, accel_mods) ⇒ TrueClass
Removes an accelerator from widget, previously installed with gtk_widget_add_accelerator().
-
#remove_mnemonic_label(label) ⇒ nil
Removes a widget from the list of mnemonic labels for this widget.
-
#remove_tick_callback(id) ⇒ nil
Removes a tick callback previously registered with gtk_widget_add_tick_callback().
-
#render_icon(stock_id, size, detail) ⇒ GdkPixbuf::Pixbuf
A convenience function that uses the theme settings for widget to look up stock_id and render it to a pixbuf.
-
#render_icon_pixbuf(stock_id, size) ⇒ GdkPixbuf::Pixbuf
A convenience function that uses the theme engine and style settings for widget to look up stock_id and render it to a pixbuf.
-
#reparent(new_parent) ⇒ nil
Moves a widget from one Gtk::Container to another, handling reference count issues to avoid destroying the widget.
-
#request_mode ⇒ Gtk::SizeRequestMode
Gets whether the widget prefers a height-for-width layout or a width-for-height layout.
-
#reset_rc_styles ⇒ nil
Reset the styles of widget and all descendents, so when they are looked up again, they get the correct values for the currently loaded RC file settings.
-
#reset_style ⇒ nil
Updates the style context of widget and all descendants by updating its widget path.
-
#root_window ⇒ Gdk::Window
Get the root window where this widget is located.
-
#scale_factor ⇒ Integer
The scale factor of the widget.
-
#scale_factor=(scale_factor) ⇒ Integer
The scale factor of the widget.
-
#screen ⇒ Gdk::Screen
Get the Gdk::Screen from the toplevel window associated with this widget.
-
#send_expose(event) ⇒ Integer
Very rarely-used function.
-
#send_focus_change(event) ⇒ TrueClass
Sends the focus change event to widget.
-
#sensitive ⇒ TrueClass
Returns the widget’s sensitivity (in the sense of returning the value that has been set using gtk_widget_set_sensitive()).
- #sensitive=(sensitive) ⇒ TrueClass
-
#sensitive? ⇒ TrueClass
Sensitive.
-
#set_accel_path(accel_path, accel_group) ⇒ nil
Given an accelerator group, accel_group, and an accelerator path, accel_path, sets up an accelerator in accel_group so whenever the key binding that is defined for accel_path is pressed, widget will be activated.
-
#set_connect_func(connect_func, connect_data, connect_data_destroy) ⇒ nil
For use in language bindings, this will override the default Gtk::BuilderConnectFunc to be used when parsing GtkBuilder XML from this class’s template data.
-
#set_device_enabled(device, enabled) ⇒ nil
Enables or disables a Gdk::Device to interact with widget and all its children.
-
#set_device_events(device, events) ⇒ nil
Sets the device event mask (see Gdk::EventMask) for a widget.
-
#set_size_request(width, height) ⇒ nil
Sets the minimum size of a widget; that is, the widget’s size request will be at least width by height.
-
#set_state_flags(flags, clear) ⇒ nil
This function is for use in widget implementations.
-
#settings ⇒ Gtk::Settings
Gets the settings object holding the settings used for this widget.
-
#shape_combine_region(region) ⇒ nil
Sets a shape for this widget’s GDK window.
-
#show ⇒ nil
Flags a widget to be displayed.
-
#show_all ⇒ nil
Recursively shows a widget, and any child widgets (if the widget is a container).
-
#show_now ⇒ nil
Shows a widget.
-
#size_allocate(allocation) ⇒ nil
This function is only used by Gtk::Container subclasses, to assign a size and position to their child widgets.
-
#size_allocate_with_baseline(allocation, baseline) ⇒ nil
This function is only used by Gtk::Container subclasses, to assign a size, position and (optionally) baseline to their child widgets.
-
#size_request(requisition) ⇒ nil
This function is typically used when implementing a Gtk::Container subclass.
-
#state ⇒ Gtk::StateType
Returns the widget’s state.
-
#state=(state) ⇒ nil
This function is for use in widget implementations.
-
#state_flags ⇒ Gtk::StateFlags
Returns the widget state as a flag set.
-
#style ⇒ Gtk::Style
The style of the widget, which contains information about how it will look (colors, etc).
-
#style=(style) ⇒ Gtk::Style
The style of the widget, which contains information about how it will look (colors, etc).
-
#style_attach ⇒ nil
This function attaches the widget’s Gtk::Style to the widget’s Gdk::Window.
-
#style_context ⇒ Gtk::StyleContext
Returns the style context associated to widget.
-
#style_get(first_property_name, array) ⇒ nil
Gets the values of a multiple style properties of widget.
-
#style_get_property(property_name, value) ⇒ nil
Gets the value of a style property of widget.
-
#style_get_valist(first_property_name, var_args) ⇒ nil
Non-vararg variant of gtk_widget_style_get().
-
#support_multidevice ⇒ TrueClass
Returns true if widget is multiple pointer aware.
-
#support_multidevice=(support_multidevice) ⇒ nil
Enables or disables multiple pointer awareness.
-
#template=(template_bytes) ⇒ nil
This should be called at class initialization time to specify the GtkBuilder XML to be used to extend a widget.
-
#template_from_resource=(resource_name) ⇒ nil
A convenience function to call gtk_widget_class_set_template().
-
#thaw_child_notify ⇒ nil
Reverts the effect of a previous call to gtk_widget_freeze_child_notify().
-
#tooltip_markup ⇒ String
Sets the text of tooltip to be the given string, which is marked up with the [Pango text markup language].
-
#tooltip_markup=(tooltip_markup) ⇒ String
Sets the text of tooltip to be the given string, which is marked up with the [Pango text markup language].
-
#tooltip_text ⇒ String
Sets the text of tooltip to be the given string.
-
#tooltip_text=(tooltip_text) ⇒ String
Sets the text of tooltip to be the given string.
-
#tooltip_window ⇒ Gtk::Window
Returns the Gtk::Window of the current tooltip.
-
#tooltip_window=(custom_window) ⇒ nil
Replaces the default window used for displaying tooltips with custom_window.
-
#toplevel ⇒ Gtk::Widget
This function returns the topmost widget in the container hierarchy widget is a part of.
-
#translate_coordinates(dest_widget, src_x, src_y, dest_x, dest_y) ⇒ TrueClass
Translate coordinates relative to src_widget’s allocation to coordinates relative to dest_widget’s allocations.
-
#trigger_tooltip_query ⇒ nil
Triggers a tooltip query on the display where the toplevel of widget is located.
-
#unmap ⇒ nil
This function is only for use in widget implementations.
-
#unparent ⇒ nil
This function is only for use in widget implementations.
-
#unrealize ⇒ nil
This function is only useful in widget implementations.
-
#unregister_window(window) ⇒ nil
Unregisters a Gdk::Window from the widget that was previously set up with gtk_widget_register_window().
-
#unset_state_flags(flags) ⇒ nil
This function is for use in widget implementations.
-
#valign ⇒ Gtk::Align
How to distribute vertical space if widget gets extra space, see Gtk::Align.
-
#valign=(valign) ⇒ Gtk::Align
How to distribute vertical space if widget gets extra space, see Gtk::Align.
-
#valign_with_baseline ⇒ Gtk::Align
Gets the value of the Gtk::Widget:valign property, including %GTK_ALIGN_BASELINE.
-
#vexpand ⇒ TrueClass
Gets whether the widget would like any available extra vertical space.
-
#vexpand=(vexpand) ⇒ TrueClass
Whether to expand vertically.
-
#vexpand? ⇒ TrueClass
Whether to expand vertically.
-
#vexpand_set ⇒ TrueClass
Gets whether gtk_widget_set_vexpand() has been used to explicitly set the expand flag on this widget.
-
#vexpand_set=(vexpand_set) ⇒ TrueClass
Whether to use the Gtk::Widget:vexpand property.
-
#vexpand_set? ⇒ TrueClass
Whether to use the Gtk::Widget:vexpand property.
-
#visible ⇒ TrueClass
Determines whether the widget is visible.
- #visible=(visible) ⇒ TrueClass
-
#visible? ⇒ TrueClass
Visible.
-
#visual ⇒ Gdk::Visual
Gets the visual that will be used to render widget.
-
#visual=(visual) ⇒ nil
Sets the visual that should be used for by widget and its children for creating Gdk::Windows.
-
#width_request ⇒ Integer
Width-request.
- #width_request=(width_request) ⇒ Integer
-
#window ⇒ Gdk::Window
The widget’s window if it is realized, nil otherwise.
-
#window=(window) ⇒ Gdk::Window
The widget’s window if it is realized, nil otherwise.
Instance Method Details
#accessible ⇒ Atk::Object
Returns the accessible object that describes the widget to an assistive technology.
If accessibility support is not available, this Atk::Object instance may be a no-op. Likewise, if no class-specific Atk::Object implementation is available for the widget instance in question, it will inherit an Atk::Object implementation from the first ancestor class for which such an implementation is defined.
The documentation of the [ATK](developer.gnome.org/atk/stable/) library contains more information about accessible objects and their uses.
#accessible_role=(role) ⇒ nil
Sets the default Atk::Role to be set on accessibles created for widgets of widget_class. Accessibles may decide to not honor this setting if their role reporting is more refined. Calls to gtk_widget_class_set_accessible_type() will reset this value.
In cases where you want more fine-grained control over the role of accessibles created for widget_class, you should provide your own accessible type and use gtk_widget_class_set_accessible_type() instead.
If role is #ATK_ROLE_INVALID, the default role will not be changed and the accessible’s default role will be used instead.
This function should only be called from class init functions of widgets.
#accessible_type=(type) ⇒ nil
Sets the type to be used for creating accessibles for widgets of widget_class. The given type must be a subtype of the type used for accessibles of the parent class.
This function should only be called from class init functions of widgets.
#activate ⇒ TrueClass
For widgets that can be “activated” (buttons, menu items, etc.) this function activates them. Activation is what happens when you press Enter on a widget during key navigation. If widget isn’t activatable, the function returns false.
#add_accelerator(accel_signal, accel_group, accel_key, accel_mods, accel_flags) ⇒ nil
Installs an accelerator for this widget in accel_group that causes accel_signal to be emitted if the accelerator is activated. The accel_group needs to be added to the widget’s toplevel via gtk_window_add_accel_group(), and the signal must be of type %G_SIGNAL_ACTION. Accelerators added through this function are not user changeable during runtime. If you want to support accelerators that can be changed by the user, use gtk_accel_map_add_entry() and gtk_widget_set_accel_path() or gtk_menu_item_set_accel_path() instead.
#add_device_events(device, events) ⇒ nil
Adds the device events in the bitfield events to the event mask for widget. See gtk_widget_set_device_events() for details.
#add_events(events) ⇒ nil
Adds the events in the bitfield events to the event mask for widget. See gtk_widget_set_events() and the
- input handling overview][event-masks
-
for details.
#add_mnemonic_label(label) ⇒ nil
Adds a widget to the list of mnemonic labels for this widget. (See gtk_widget_list_mnemonic_labels()). Note the list of mnemonic labels for the widget is cleared when the widget is destroyed, so the caller must make sure to update its internal state at this point as well, by using a connection to the Gtk::Widget::destroy signal or a weak notifier.
#add_tick_callback(callback, user_data, notify) ⇒ Integer
Queues an animation frame update and adds a callback to be called before each frame. Until the tick callback is removed, it will be called frequently (usually at the frame rate of the output device or as quickly as the application can be repainted, whichever is slower). For this reason, is most suitable for handling graphics that change every frame or every few frames. The tick callback does not automatically imply a relayout or repaint. If you want a repaint or relayout, and aren’t changing widget properties that would trigger that (for example, changing the text of a Gtk::Label), then you will have to call gtk_widget_queue_resize() or gtk_widget_queue_draw_area() yourself.
gdk_frame_clock_get_frame_time() should generally be used for timing continuous animations and gdk_frame_timings_get_predicted_presentation_time() if you are trying to display isolated frames at particular times.
This is a more convenient alternative to connecting directly to the Gdk::FrameClock::update signal of #GdkFrameClock, since you don’t have to worry about when a Gdk::FrameClock is assigned to a widget.
#allocated_baseline ⇒ Integer
Returns the baseline that has currently been allocated to widget. This function is intended to be used when implementing handlers for the Gtk::Widget::draw function, and when allocating child widgets in Gtk::Widget::size_allocate.
#allocated_height ⇒ Integer
Returns the height that has currently been allocated to widget. This function is intended to be used when implementing handlers for the Gtk::Widget::draw function.
#allocated_width ⇒ Integer
Returns the width that has currently been allocated to widget. This function is intended to be used when implementing handlers for the Gtk::Widget::draw function.
#allocation=(allocation) ⇒ nil
Sets the widget’s allocation. This should not be used directly, but from within a widget’s size_allocate method.
The allocation set should be the “adjusted” or actual allocation. If you’re implementing a Gtk::Container, you want to use gtk_widget_size_allocate() instead of gtk_widget_set_allocation(). The GtkWidgetClass::adjust_size_allocation virtual method adjusts the allocation inside gtk_widget_size_allocate() to create an adjusted allocation.
#app_paintable ⇒ TrueClass
Determines whether the application intends to draw on the widget in an Gtk::Widget::draw handler.
See gtk_widget_set_app_paintable()
#app_paintable=(app_paintable) ⇒ TrueClass
#app_paintable? ⇒ TrueClass
Returns app-paintable.
#bind_template_callback_full(callback_name, callback_symbol) ⇒ nil
Declares a callback_symbol to handle callback_name from the template XML defined for widget_type. See gtk_builder_add_callback_symbol().
Note that this must be called from a composite widget classes class initializer after calling gtk_widget_class_set_template().
#bind_template_child_full(name, internal_child, struct_offset) ⇒ nil
Automatically assign an object declared in the class template XML to be set to a location on a freshly built instance’s private data, or alternatively accessible via gtk_widget_get_template_child().
The struct can point either into the public instance, then you should use G_STRUCT_OFFSET(WidgetType, member) for struct_offset, or in the private struct, then you should use G_PRIVATE_OFFSET(WidgetType, member).
An explicit strong reference will be held automatically for the duration of your instance’s life cycle, it will be released automatically when GObject::Class.dispose() runs on your instance and if a struct_offset that is != 0 is specified, then the automatic location in your instance public or private data will be set to nil. You can however access an automated child pointer the first time your classes GObject::Class.dispose() runs, or alternatively in Gtk::WidgetClass.destroy().
If internal_child is specified, Gtk::BuildableIface.get_internal_child() will be automatically implemented by the Gtk::Widget class so there is no need to implement it manually.
The wrapper macros gtk_widget_class_bind_template_child(), gtk_widget_class_bind_template_child_internal(), gtk_widget_class_bind_template_child_private() and gtk_widget_class_bind_template_child_internal_private() might be more convenient to use.
Note that this must be called from a composite widget classes class initializer after calling gtk_widget_class_set_template().
#can_activate_accel(signal_id) ⇒ TrueClass
Determines whether an accelerator that activates the signal identified by signal_id can currently be activated. This is done by emitting the Gtk::Widget::can-activate-accel signal on widget; if the signal isn’t overridden by a handler or in a derived widget, then the default check is that the widget must be sensitive, and the widget and all its ancestors mapped.
#can_default ⇒ TrueClass
Determines whether widget can be a default widget. See gtk_widget_set_can_default().
#can_default=(can_default) ⇒ TrueClass
#can_default? ⇒ TrueClass
Returns can-default.
#can_focus ⇒ TrueClass
Determines whether widget can own the input focus. See gtk_widget_set_can_focus().
#can_focus=(can_focus) ⇒ TrueClass
#can_focus? ⇒ TrueClass
Returns can-focus.
#child_focus(direction) ⇒ TrueClass
This function is used by custom widget implementations; if you’re writing an app, you’d use gtk_widget_grab_focus() to move the focus to a particular widget, and gtk_container_set_focus_chain() to change the focus tab order. So you may want to investigate those functions instead.
gtk_widget_child_focus() is called by containers as the user moves around the window using keyboard shortcuts. direction indicates what kind of motion is taking place (up, down, left, right, tab forward, tab backward). gtk_widget_child_focus() emits the Gtk::Widget::focus signal; widgets override the default handler for this signal in order to implement appropriate focus behavior.
The default ::focus handler for a widget should return true if moving in direction left the focus on a focusable location inside that widget, and false if moving in direction moved the focus outside the widget. If returning true, widgets normally call gtk_widget_grab_focus() to place the focus accordingly; if returning false, they don’t modify the current focus location.
#child_notify(child_property) ⇒ nil
Emits a Gtk::Widget::child-notify signal for the
- child property][child-properties
-
child_property
on widget.
This is the analogue of g_object_notify() for child properties.
Also see gtk_container_child_notify().
#child_visible ⇒ TrueClass
Gets the value set with gtk_widget_set_child_visible(). If you feel a need to use this function, your code probably needs reorganization.
This function is only useful for container implementations and never should be called by an application.
#child_visible=(is_visible) ⇒ nil
Sets whether widget should be mapped along with its when its parent is mapped and widget has been shown with gtk_widget_show().
The child visibility can be set for widget before it is added to a container with gtk_widget_set_parent(), to avoid mapping children unnecessary before immediately unmapping them. However it will be reset to its default state of true when the widget is removed from a container.
Note that changing the child visibility of a widget does not queue a resize on the widget. Most of the time, the size of a widget is computed from all visible children, whether or not they are mapped. If this is not the case, the container can queue a resize itself.
This function is only useful for container implementations and never should be called by an application.
#class_path(path_length, path, path_reversed) ⇒ nil
Same as gtk_widget_path(), but always uses the name of a widget’s type, never uses a custom name set with gtk_widget_set_name().
#clip=(clip) ⇒ nil
Sets the widget’s clip. This must not be used directly, but from within a widget’s size_allocate method. It must be called after gtk_widget_set_allocation() (or after chaining up to the parent class), because that function resets the clip.
The clip set should be the area that widget draws on. If widget is a Gtk::Container, the area must contain all children’s clips.
If this function is not called by widget during a ::size-allocate handler, the clip will be set to widget’s allocation.
#composite_child=(composite_child) ⇒ TrueClass
#composite_child? ⇒ TrueClass
Returns composite-child.
#composite_name ⇒ String
Obtains the composite name of a widget.
#composite_name=(name) ⇒ nil
Sets a widgets composite name. The widget must be a composite child of its parent; see gtk_widget_push_composite_child().
#compute_expand(orientation) ⇒ TrueClass
Computes whether a container should give this widget extra space when possible. Containers should check this, rather than looking at gtk_widget_get_hexpand() or gtk_widget_get_vexpand().
This function already checks whether the widget is visible, so visibility does not need to be checked separately. Non-visible widgets are not expanded.
The computed expand value uses either the expand setting explicitly set on the widget itself, or, if none has been explicitly set, the widget may expand if some of its children do.
#create_pango_context ⇒ Pango::Context
Creates a new Pango::Context with the appropriate font map, font options, font description, and base direction for drawing text for this widget. See also gtk_widget_get_pango_context().
#create_pango_layout(text) ⇒ Pango::Layout
Creates a new Pango::Layout with the appropriate font map, font description, and base direction for drawing text for this widget.
If you keep a Pango::Layout created in this way around, you need to re-create it when the widget Pango::Context is replaced. This can be tracked by using the Gtk::Widget::screen-changed signal on the widget.
#css_name ⇒ String
Gets the name used by this class for matching in CSS code. See gtk_widget_class_set_css_name() for details.
#css_name=(name) ⇒ nil
Sets the name to be used for CSS matching of widgets.
If this function is not called for a given class, the name of the parent class is used.
#destroy ⇒ nil
Destroys a widget.
When a widget is destroyed all references it holds on other objects will be released:
- if the widget is inside a container, it will be removed from its
parent
- if the widget is a container, all its children will be destroyed,
recursively
- if the widget is a top level, it will be removed from the list
of top level widgets that GTK+ maintains internally
It’s expected that all references held on the widget will also be released; you should connect to the Gtk::Widget::destroy signal if you hold a reference to widget and you wish to remove it when this function is called. It is not necessary to do so if you are implementing a Gtk::Container, as you’ll be able to use the Gtk::ContainerClass.remove() virtual function for that.
It’s important to notice that gtk_widget_destroy() will only cause the widget to be finalized if no additional references, acquired using g_object_ref(), are held on it. In case additional references are in place, the widget will be in an “inert” state after calling this function; widget will still point to valid memory, allowing you to release the references you hold, but you may not query the widget’s own state.
You should typically call this function on top level widgets, and rarely on child widgets.
See also: gtk_container_remove()
#destroyed(widget_pointer) ⇒ nil
This function sets *widget_pointer to nil if widget_pointer != nil. It’s intended to be used as a callback connected to the “destroy” signal of a widget. You connect gtk_widget_destroyed() as a signal handler, and pass the address of your widget variable as user data. Then when the widget is destroyed, the variable will be set to nil. Useful for example to avoid multiple copies of the same dialog.
#device_is_shadowed(device) ⇒ TrueClass
Returns true if device has been shadowed by a GTK+ device grab on another widget, so it would stop sending events to widget. This may be used in the Gtk::Widget::grab-notify signal to check for specific devices. See gtk_device_grab_add().
#direction ⇒ Gtk::TextDirection
Gets the reading direction for a particular widget. See gtk_widget_set_direction().
#direction=(dir) ⇒ nil
Sets the reading direction on a particular widget. This direction controls the primary direction for widgets containing text, and also the direction in which the children of a container are packed. The ability to set the direction is present in order so that correct localization into languages with right-to-left reading directions can be done. Generally, applications will let the default reading direction present, except for containers where the containers are arranged in an order that is explicitly visual rather than logical (such as buttons for text justification).
If the direction is set to %GTK_TEXT_DIR_NONE, then the value set by gtk_widget_set_default_direction() will be used.
#display ⇒ Gdk::Display
Get the Gdk::Display for the toplevel window associated with this widget. This function can only be called after the widget has been added to a widget hierarchy with a Gtk::Window at the top.
In general, you should only create display specific resources when a widget has been realized, and you should free those resources when the widget is unrealized.
#double_buffered ⇒ TrueClass
Determines whether the widget is double buffered.
See gtk_widget_set_double_buffered()
#double_buffered=(double_buffered) ⇒ TrueClass
Whether the widget is double buffered.
#double_buffered? ⇒ TrueClass
Whether the widget is double buffered.
#drag_begin(targets, actions, button, event) ⇒ Gdk::DragContext
This function is equivalent to gtk_drag_begin_with_coordinates(), passing -1, -1 as coordinates.
#drag_begin_with_coordinates(targets, actions, button, event, x, y) ⇒ Gdk::DragContext
Initiates a drag on the source side. The function only needs to be used when the application is starting drags itself, and is not needed when gtk_drag_source_set() is used.
The event is used to retrieve the timestamp that will be used internally to grab the pointer. If event is nil, then %GDK_CURRENT_TIME will be used. However, you should try to pass a real event in all cases, since that can be used to get information about the drag.
Generally there are three cases when you want to start a drag by hand by calling this function:
-
During a Gtk::Widget::button-press-event handler, if you want to start a drag
immediately when the user presses the mouse button. Pass the event that you have in your Gtk::Widget::button-press-event handler.
-
During a Gtk::Widget::motion-notify-event handler, if you want to start a drag
when the mouse moves past a certain threshold distance after a button-press. Pass the event that you have in your Gtk::Widget::motion-notify-event handler.
-
During a timeout handler, if you want to start a drag after the mouse
button is held down for some time. Try to save the last event that you got from the mouse, using gdk_event_copy(), and pass it to this function (remember to free the event with gdk_event_free() when you are done). If you really cannot pass a real event, pass nil instead.
#drag_check_threshold(start_x, start_y, current_x, current_y) ⇒ TrueClass
Checks to see if a mouse drag starting at (start_x, start_y) and ending at (current_x, current_y) has passed the GTK+ drag threshold, and thus should trigger the beginning of a drag-and-drop operation.
#drag_dest_add_image_targets ⇒ nil
Add the image targets supported by Gtk::SelectionData to the target list of the drag destination. The targets are added with info = 0. If you need another value, use gtk_target_list_add_image_targets() and gtk_drag_dest_set_target_list().
#drag_dest_add_text_targets ⇒ nil
Add the text targets supported by Gtk::SelectionData to the target list of the drag destination. The targets are added with info = 0. If you need another value, use gtk_target_list_add_text_targets() and gtk_drag_dest_set_target_list().
#drag_dest_add_uri_targets ⇒ nil
Add the URI targets supported by Gtk::SelectionData to the target list of the drag destination. The targets are added with info = 0. If you need another value, use gtk_target_list_add_uri_targets() and gtk_drag_dest_set_target_list().
#drag_dest_find_target(context, target_list) ⇒ Gdk::Atom
Looks for a match between the supported targets of context and the dest_target_list, returning the first matching target, otherwise returning %GDK_NONE. dest_target_list should usually be the return value from gtk_drag_dest_get_target_list(), but some widgets may have different valid targets for different parts of the widget; in that case, they will have to implement a drag_motion handler that passes the correct target list to this function.
#drag_dest_get_target_list ⇒ Gtk::TargetList
Returns the list of targets this widget can accept from drag-and-drop.
#drag_dest_get_track_motion ⇒ TrueClass
Returns whether the widget has been configured to always emit Gtk::Widget::drag-motion signals.
#drag_dest_set(flags, targets, n_targets, actions) ⇒ nil
Sets a widget as a potential drop destination, and adds default behaviors.
The default behaviors listed in flags have an effect similar to installing default handlers for the widget’s drag-and-drop signals (Gtk::Widget::drag-motion, #GtkWidget::drag-drop, …). They all exist for convenience. When passing #GTK_DEST_DEFAULT_ALL for instance it is sufficient to connect to the widget’s Gtk::Widget::drag-data-received signal to get primitive, but consistent drag-and-drop support.
Things become more complicated when you try to preview the dragged data, as described in the documentation for Gtk::Widget::drag-motion. The default behaviors described by flags make some assumptions, that can conflict with your own signal handlers. For instance #GTK_DEST_DEFAULT_DROP causes invokations of gdk_drag_status() in the context of Gtk::Widget::drag-motion, and invokations of gtk_drag_finish() in Gtk::Widget::drag-data-received. Especially the later is dramatic, when your own Gtk::Widget::drag-motion handler calls gtk_drag_get_data() to inspect the dragged data.
There’s no way to set a default action here, you can use the Gtk::Widget::drag-motion callback for that. Here’s an example which selects the action to use depending on whether the control key is pressed or not:
static void
drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GdkModifierType mask;
gdk_window_get_pointer (gtk_widget_get_window (widget),
NULL, NULL, &mask);
if (mask & GDK_CONTROL_MASK)
gdk_drag_status (context, GDK_ACTION_COPY, time);
else
gdk_drag_status (context, GDK_ACTION_MOVE, time);
}
#drag_dest_set_proxy(proxy_window, protocol, use_coordinates) ⇒ nil
Sets this widget as a proxy for drops to another window.
#drag_dest_set_target_list(target_list) ⇒ nil
Sets the target types that this widget can accept from drag-and-drop. The widget must first be made into a drag destination with gtk_drag_dest_set().
#drag_dest_set_track_motion(track_motion) ⇒ nil
Tells the widget to emit Gtk::Widget::drag-motion and Gtk::Widget::drag-leave events regardless of the targets and the %GTK_DEST_DEFAULT_MOTION flag.
This may be used when a widget wants to do generic actions regardless of the targets that the source offers.
#drag_dest_unset ⇒ nil
Clears information about a drop destination set with gtk_drag_dest_set(). The widget will no longer receive notification of drags.
#drag_get_data(context, target, time_) ⇒ nil
Gets the data associated with a drag. When the data is received or the retrieval fails, GTK+ will emit a Gtk::Widget::drag-data-received signal. Failure of the retrieval is indicated by the length field of the selection_data signal parameter being negative. However, when gtk_drag_get_data() is called implicitely because the %GTK_DEST_DEFAULT_DROP was set, then the widget will not receive notification of failed drops.
#drag_highlight ⇒ nil
Highlights a widget as a currently hovered drop target. To end the highlight, call gtk_drag_unhighlight(). GTK+ calls this automatically if %GTK_DEST_DEFAULT_HIGHLIGHT is set.
#drag_source_add_image_targets ⇒ nil
Add the writable image targets supported by Gtk::SelectionData to the target list of the drag source. The targets are added with info = 0. If you need another value, use gtk_target_list_add_image_targets() and gtk_drag_source_set_target_list().
#drag_source_add_text_targets ⇒ nil
Add the text targets supported by Gtk::SelectionData to the target list of the drag source. The targets are added with info = 0. If you need another value, use gtk_target_list_add_text_targets() and gtk_drag_source_set_target_list().
#drag_source_add_uri_targets ⇒ nil
Add the URI targets supported by Gtk::SelectionData to the target list of the drag source. The targets are added with info = 0. If you need another value, use gtk_target_list_add_uri_targets() and gtk_drag_source_set_target_list().
#drag_source_get_target_list ⇒ Gtk::TargetList
Gets the list of targets this widget can provide for drag-and-drop.
#drag_source_set(start_button_mask, targets, n_targets, actions) ⇒ nil
Sets up a widget so that GTK+ will start a drag operation when the user clicks and drags on the widget. The widget must have a window.
#drag_source_set_icon_gicon(icon) ⇒ nil
Sets the icon that will be used for drags from a particular source to icon. See the docs for Gtk::IconTheme for more details.
#drag_source_set_icon_name(icon_name) ⇒ nil
Sets the icon that will be used for drags from a particular source to a themed icon. See the docs for Gtk::IconTheme for more details.
#drag_source_set_icon_pixbuf(pixbuf) ⇒ nil
Sets the icon that will be used for drags from a particular widget from a Gdk::Pixbuf. GTK+ retains a reference for pixbuf and will release it when it is no longer needed.
#drag_source_set_icon_stock(stock_id) ⇒ nil
Sets the icon that will be used for drags from a particular source to a stock icon.
#drag_source_set_target_list(target_list) ⇒ nil
Changes the target types that this widget offers for drag-and-drop. The widget must first be made into a drag source with gtk_drag_source_set().
#drag_source_unset ⇒ nil
Undoes the effects of gtk_drag_source_set().
#drag_unhighlight ⇒ nil
Removes a highlight set by gtk_drag_highlight() from a widget.
#draw(cr) ⇒ nil
Draws widget to cr. The top left corner of the widget will be drawn to the currently set origin point of cr.
You should pass a cairo context as cr argument that is in an original state. Otherwise the resulting drawing is undefined. For example changing the operator using cairo_set_operator() or the line width using cairo_set_line_width() might have unwanted side effects. You may however change the context’s transform matrix - like with cairo_scale(), cairo_translate() or cairo_set_matrix() and clip region with cairo_clip() prior to calling this function. Also, it is fine to modify the context with cairo_save() and cairo_push_group() prior to calling this function.
Note that special-purpose widgets may contain special code for rendering to the screen and might appear differently on screen and when rendered using gtk_widget_draw().
#ensure_style ⇒ nil
Ensures that widget has a style (widget->style).
Not a very useful function; most of the time, if you want the style, the widget is realized, and realized widgets are guaranteed to have a style already.
#error_bell ⇒ nil
Notifies the user about an input-related error on this widget. If the Gtk::Settings:gtk-error-bell setting is true, it calls gdk_window_beep(), otherwise it does nothing.
Note that the effect of gdk_window_beep() can be configured in many ways, depending on the windowing backend and the desktop environment or window manager that is used.
#event(event) ⇒ TrueClass
Rarely-used function. This function is used to emit the event signals on a widget (those signals should never be emitted without using this function to do so). If you want to synthesize an event though, don’t use this function; instead, use gtk_main_do_event() so the event will behave as if it were in the event queue. Don’t synthesize expose events; instead, use gdk_window_invalidate_rect() to invalidate a region of the window.
#events ⇒ Gdk::EventMask
Returns events.
#events=(events) ⇒ Gdk::EventMask
#expand=(expand) ⇒ TrueClass
Whether to expand in both directions. Setting this sets both Gtk::Widget:hexpand and #GtkWidget:vexpand
#expand? ⇒ TrueClass
Whether to expand in both directions. Setting this sets both Gtk::Widget:hexpand and #GtkWidget:vexpand
#find_style_property(property_name) ⇒ GObject::ParamSpec
Finds a style property of a widget class by name.
#focus_on_click ⇒ TrueClass
Returns whether the widget should grab focus when it is clicked with the mouse. See gtk_widget_set_focus_on_click().
#focus_on_click=(focus_on_click) ⇒ TrueClass
Whether the widget should grab focus when it is clicked with the mouse.
This property is only relevant for widgets that can take focus.
Before 3.20, several widgets (GtkButton, GtkFileChooserButton, GtkComboBox) implemented this property individually.
#focus_on_click? ⇒ TrueClass
Whether the widget should grab focus when it is clicked with the mouse.
This property is only relevant for widgets that can take focus.
Before 3.20, several widgets (GtkButton, GtkFileChooserButton, GtkComboBox) implemented this property individually.
#font_map ⇒ Pango::FontMap
Gets the font map that has been set with gtk_widget_set_font_map().
#font_map=(font_map) ⇒ nil
Sets the font map to use for Pango rendering. When not set, the widget will inherit the font map from its parent.
#font_options ⇒ cairo::FontOptions
Returns the #cairo_font_options_t used for Pango rendering. When not set, the defaults font options for the Gdk::Screen will be used.
#font_options=(options) ⇒ nil
Sets the #cairo_font_options_t used for Pango rendering in this widget. When not set, the default font options for the Gdk::Screen will be used.
#frame_clock ⇒ Gdk::FrameClock
Obtains the frame clock for a widget. The frame clock is a global “ticker” that can be used to drive animations and repaints. The most common reason to get the frame clock is to call gdk_frame_clock_get_frame_time(), in order to get a time to use for animating. For example you might record the start of the animation with an initial value from gdk_frame_clock_get_frame_time(), and then update the animation by calling gdk_frame_clock_get_frame_time() again during each repaint.
gdk_frame_clock_request_phase() will result in a new frame on the clock, but won’t necessarily repaint any widgets. To repaint a widget, you have to use gtk_widget_queue_draw() which invalidates the widget (thus scheduling it to receive a draw on the next frame). gtk_widget_queue_draw() will also end up requesting a frame on the appropriate frame clock.
A widget’s frame clock will not change while the widget is mapped. Reparenting a widget (which implies a temporary unmap) can change the widget’s frame clock.
Unrealized widgets do not have a frame clock. or nil if widget is unrealized
#freeze_child_notify ⇒ nil
Stops emission of Gtk::Widget::child-notify signals on widget. The signals are queued until gtk_widget_thaw_child_notify() is called on widget.
This is the analogue of g_object_freeze_notify() for child properties.
#get_action_group(prefix) ⇒ Gio::ActionGroup
Retrieves the GAction::Group that was registered using prefix. The resulting GAction::Group may have been registered to widget or any #GtkWidget in its ancestry.
If no action group was found matching prefix, then nil is returned.
#get_allocated_size(allocation, baseline) ⇒ nil
Retrieves the widget’s allocated size.
This function returns the last values passed to gtk_widget_size_allocate_with_baseline(). The value differs from the size returned in gtk_widget_get_allocation() in that functions like gtk_widget_set_halign() can adjust the allocation, but not the value returned by this function.
If a widget is not visible, its allocated size is 0.
#get_allocation(allocation) ⇒ nil
Retrieves the widget’s allocation.
Note, when implementing a Gtk::Container: a widget’s allocation will be its “adjusted” allocation, that is, the widget’s parent container typically calls gtk_widget_size_allocate() with an allocation, and that allocation is then adjusted (to handle margin and alignment for example) before assignment to the widget. gtk_widget_get_allocation() returns the adjusted allocation that was actually assigned to the widget. The adjusted allocation is guaranteed to be completely contained within the gtk_widget_size_allocate() allocation, however. So a Gtk::Container is guaranteed that its children stay inside the assigned bounds, but not that they have exactly the bounds the container assigned. There is no way to get the original allocation assigned by gtk_widget_size_allocate(), since it isn’t stored; if a container implementation needs that information it will have to track it itself.
#get_ancestor(widget_type) ⇒ Gtk::Widget
Gets the first ancestor of widget with type widget_type. For example, ‘gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)` gets the first Gtk::Box that’s an ancestor of widget. No reference will be added to the returned widget; it should not be unreferenced. See note about checking for a toplevel Gtk::Window in the docs for gtk_widget_get_toplevel().
Note that unlike gtk_widget_is_ancestor(), gtk_widget_get_ancestor() considers widget to be an ancestor of itself.
#get_child_requisition(requisition) ⇒ nil
This function is only for use in widget implementations. Obtains widget->requisition, unless someone has forced a particular geometry on the widget (e.g. with gtk_widget_set_size_request()), in which case it returns that geometry instead of the widget’s requisition.
This function differs from gtk_widget_size_request() in that it retrieves the last size request value from widget->requisition, while gtk_widget_size_request() actually calls the “size_request” method on widget to compute the size request and fill in widget->requisition, and only then returns widget->requisition.
Because this function does not call the “size_request” method, it can only be used when you know that widget->requisition is up-to-date, that is, gtk_widget_size_request() has been called since the last time a resize was queued. In general, only container implementations have this information; applications should use gtk_widget_size_request().
#get_clip(clip) ⇒ nil
Retrieves the widget’s clip area.
The clip area is the area in which all of widget’s drawing will happen. Other toolkits call it the bounding box.
Historically, in GTK+ the clip area has been equal to the allocation retrieved via gtk_widget_get_allocation().
#get_clipboard(selection) ⇒ Gtk::Clipboard
Returns the clipboard object for the given selection to be used with widget. widget must have a Gdk::Display associated with it, so must be attached to a toplevel window.
#get_device_enabled(device) ⇒ TrueClass
Returns whether device can interact with widget and its children. See gtk_widget_set_device_enabled().
#get_device_events(device) ⇒ Gdk::EventMask
Returns the events mask for the widget corresponding to an specific device. These are the events that the widget will receive when device operates on it.
#get_modifier_mask(intent) ⇒ Gdk::ModifierType
Returns the modifier mask the widget’s windowing system backend uses for a particular purpose.
See gdk_keymap_get_modifier_mask().
#get_pointer(x, y) ⇒ nil
Obtains the location of the mouse pointer in widget coordinates. Widget coordinates are a bit odd; for historical reasons, they are defined as widget->window coordinates for widgets that return true for gtk_widget_get_has_window(); and are relative to widget->allocation.x, widget->allocation.y otherwise.
#get_preferred_height(minimum_height, natural_height) ⇒ nil
Retrieves a widget’s initial minimum and natural height.
This call is specific to width-for-height requests.
The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any Gtk::SizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.
#get_preferred_height_and_baseline_for_width(width, minimum_height, natural_height, minimum_baseline, natural_baseline) ⇒ nil
Retrieves a widget’s minimum and natural height and the corresponding baselines if it would be given the specified width, or the default height if width is -1. The baselines may be -1 which means that no baseline is requested for this widget.
The returned request will be modified by the GtkWidgetClass::adjust_size_request and GtkWidgetClass::adjust_baseline_request virtual methods and by any Gtk::SizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.
#get_preferred_height_for_width(width, minimum_height, natural_height) ⇒ nil
Retrieves a widget’s minimum and natural height if it would be given the specified width.
The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any Gtk::SizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.
#get_preferred_size(minimum_size, natural_size) ⇒ nil
Retrieves the minimum and natural size of a widget, taking into account the widget’s preference for height-for-width management.
This is used to retrieve a suitable size by container widgets which do not impose any restrictions on the child placement. It can be used to deduce toplevel window and menu sizes as well as child widgets in free-form containers such as GtkLayout.
Handle with care. Note that the natural height of a height-for-width widget will generally be a smaller size than the minimum height, since the required height for the natural width is generally smaller than the required height for the minimum width.
Use gtk_widget_get_preferred_height_and_baseline_for_width() if you want to support baseline alignment.
#get_preferred_width(minimum_width, natural_width) ⇒ nil
Retrieves a widget’s initial minimum and natural width.
This call is specific to height-for-width requests.
The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any Gtk::SizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.
#get_preferred_width_for_height(height, minimum_width, natural_width) ⇒ nil
Retrieves a widget’s minimum and natural width if it would be given the specified height.
The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any Gtk::SizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.
#get_requisition(requisition) ⇒ nil
Retrieves the widget’s requisition.
This function should only be used by widget implementations in order to figure whether the widget’s requisition has actually changed after some internal state change (so that they can call gtk_widget_queue_resize() instead of gtk_widget_queue_draw()).
Normally, gtk_widget_size_request() should be used.
#get_size_request(width, height) ⇒ nil
Gets the size request that was explicitly set for the widget using gtk_widget_set_size_request(). A value of -1 stored in width or height indicates that that dimension has not been set explicitly and the natural requisition of the widget will be used instead. See gtk_widget_set_size_request(). To get the size a widget will actually request, call gtk_widget_get_preferred_size() instead of this function.
#get_template_child(widget_type, name) ⇒ GObject::Object
Fetch an object build from the template XML for widget_type in this widget instance.
This will only report children which were previously declared with gtk_widget_class_bind_template_child_full() or one of its variants.
This function is only meant to be called for code which is private to the widget_type which declared the child and is meant for language bindings which cannot easily make use of the GObject structure offsets.
#grab_add ⇒ nil
Makes widget the current grabbed widget.
This means that interaction with other widgets in the same application is blocked and mouse as well as keyboard events are delivered to this widget.
If widget is not sensitive, it is not set as the current grabbed widget and this function does nothing.
#grab_default ⇒ nil
Causes widget to become the default widget. widget must be able to be a default widget; typically you would ensure this yourself by calling gtk_widget_set_can_default() with a true value. The default widget is activated when the user presses Enter in a window. Default widgets must be activatable, that is, gtk_widget_activate() should affect them. Note that Gtk::Entry widgets require the “activates-default” property set to true before they activate the default widget when Enter is pressed and the Gtk::Entry is focused.
#grab_focus ⇒ nil
Causes widget to have the keyboard focus for the Gtk::Window it’s inside. widget must be a focusable widget, such as a Gtk::Entry; something like Gtk::Frame won’t work.
More precisely, it must have the %GTK_CAN_FOCUS flag set. Use gtk_widget_set_can_focus() to modify that flag.
The widget also needs to be realized and mapped. This is indicated by the related signals. Grabbing the focus immediately after creating the widget will likely fail and cause critical warnings.
#grab_remove ⇒ nil
Removes the grab from the given widget.
You have to pair calls to gtk_grab_add() and gtk_grab_remove().
If widget does not have the grab, this function does nothing.
#halign ⇒ Gtk::Align
How to distribute horizontal space if widget gets extra space, see Gtk::Align
#halign=(halign) ⇒ Gtk::Align
How to distribute horizontal space if widget gets extra space, see Gtk::Align
#has_default ⇒ TrueClass
Determines whether widget is the current default widget within its toplevel. See gtk_widget_set_can_default().
#has_default=(has_default) ⇒ TrueClass
#has_default? ⇒ TrueClass
Returns has-default.
#has_focus ⇒ TrueClass
Determines if the widget has the global input focus. See gtk_widget_is_focus() for the difference between having the global input focus, and only having the focus within a toplevel.
#has_focus=(has_focus) ⇒ TrueClass
#has_focus? ⇒ TrueClass
Returns has-focus.
#has_grab ⇒ TrueClass
Determines whether the widget is currently grabbing events, so it is the only widget receiving input events (keyboard and mouse).
See also gtk_grab_add().
#has_rc_style ⇒ TrueClass
Determines if the widget style has been looked up through the rc mechanism.
#has_screen ⇒ TrueClass
Checks whether there is a Gdk::Screen is associated with this widget. All toplevel widgets have an associated screen, and all widgets added into a hierarchy with a toplevel window at the top.
#has_tooltip ⇒ TrueClass
Returns the current value of the has-tooltip property. See Gtk::Widget:has-tooltip for more information.
#has_tooltip=(has_tooltip) ⇒ TrueClass
Enables or disables the emission of Gtk::Widget::query-tooltip on widget. A value of true indicates that widget can have a tooltip, in this case the widget will be queried using Gtk::Widget::query-tooltip to determine whether it will provide a tooltip or not.
Note that setting this property to true for the first time will change the event masks of the GdkWindows of this widget to include leave-notify and motion-notify events. This cannot and will not be undone when the property is set to false again.
#has_tooltip? ⇒ TrueClass
Enables or disables the emission of Gtk::Widget::query-tooltip on widget. A value of true indicates that widget can have a tooltip, in this case the widget will be queried using Gtk::Widget::query-tooltip to determine whether it will provide a tooltip or not.
Note that setting this property to true for the first time will change the event masks of the GdkWindows of this widget to include leave-notify and motion-notify events. This cannot and will not be undone when the property is set to false again.
#has_visible_focus ⇒ TrueClass
Determines if the widget should show a visible indication that it has the global input focus. This is a convenience function for use in ::draw handlers that takes into account whether focus indication should currently be shown in the toplevel window of widget. See gtk_window_get_focus_visible() for more information about focus indication.
To find out if the widget has the global input focus, use gtk_widget_has_focus().
#has_window ⇒ TrueClass
Determines whether widget has a Gdk::Window of its own. See gtk_widget_set_has_window().
#has_window=(has_window) ⇒ nil
Specifies whether widget has a Gdk::Window of its own. Note that all realized widgets have a non-nil “window” pointer (gtk_widget_get_window() never returns a nil window when a widget is realized), but for many of them it’s actually the Gdk::Window of one of its parent widgets. Widgets that do not create a %window for themselves in Gtk::Widget::realize must announce this by calling this function with has_window = false.
This function should only be called by widget implementations, and they should call it in their init() function.
#height_request ⇒ Integer
Returns height-request.
#height_request=(height_request) ⇒ Integer
#hexpand ⇒ TrueClass
Gets whether the widget would like any available extra horizontal space. When a user resizes a Gtk::Window, widgets with expand=TRUE generally receive the extra space. For example, a list or scrollable area or document in your window would often be set to expand.
Containers should use gtk_widget_compute_expand() rather than this function, to see whether a widget, or any of its children, has the expand flag set. If any child of a widget wants to expand, the parent may ask to expand also.
This function only looks at the widget’s own hexpand flag, rather than computing whether the entire widget tree rooted at this widget wants to expand.
#hexpand=(hexpand) ⇒ TrueClass
Whether to expand horizontally. See gtk_widget_set_hexpand().
#hexpand? ⇒ TrueClass
Whether to expand horizontally. See gtk_widget_set_hexpand().
#hexpand_set ⇒ TrueClass
Gets whether gtk_widget_set_hexpand() has been used to explicitly set the expand flag on this widget.
If hexpand is set, then it overrides any computed expand value based on child widgets. If hexpand is not set, then the expand value depends on whether any children of the widget would like to expand.
There are few reasons to use this function, but it’s here for completeness and consistency.
#hexpand_set=(hexpand_set) ⇒ TrueClass
Whether to use the Gtk::Widget:hexpand property. See gtk_widget_get_hexpand_set().
#hexpand_set? ⇒ TrueClass
Whether to use the Gtk::Widget:hexpand property. See gtk_widget_get_hexpand_set().
#hide ⇒ nil
Reverses the effects of gtk_widget_show(), causing the widget to be hidden (invisible to the user).
#hide_on_delete ⇒ TrueClass
Utility function; intended to be connected to the Gtk::Widget::delete-event signal on a Gtk::Window. The function calls gtk_widget_hide() on its argument, then returns true. If connected to ::delete-event, the result is that clicking the close button for a window (on the window frame, top right corner usually) will hide but not destroy the window. By default, GTK+ destroys windows when ::delete-event is received.
#in_destruction ⇒ TrueClass
Returns whether the widget is currently being destroyed. This information can sometimes be used to avoid doing unnecessary work.
#init_template ⇒ nil
Creates and initializes child widgets defined in templates. This function must be called in the instance initializer for any class which assigned itself a template using gtk_widget_class_set_template()
It is important to call this function in the instance initializer of a Gtk::Widget subclass and not in #GObject.constructed() or #GObject.constructor() for two reasons.
One reason is that generally derived widgets will assume that parent class composite widgets have been created in their instance initializers.
Another reason is that when calling g_object_new() on a widget with composite templates, it’s important to build the composite widgets before the construct properties are set. Properties passed to g_object_new() should take precedence over properties set in the private template XML.
#input_shape_combine_region(region) ⇒ nil
Sets an input shape for this widget’s GDK window. This allows for windows which react to mouse click in a nonrectangular region, see gdk_window_input_shape_combine_region() for more information.
#insert_action_group(name, group) ⇒ nil
Inserts group into widget. Children of widget that implement Gtk::Actionable can then be associated with actions in group by setting their “action-name” to prefix.‘action-name`.
If group is nil, a previously inserted group for name is removed from widget.
#install_style_property(pspec) ⇒ nil
Installs a style property on a widget class. The parser for the style property is determined by the value type of pspec.
#install_style_property_parser(pspec, parser) ⇒ nil
Installs a style property on a widget class.
#intersect(area, intersection) ⇒ TrueClass
Computes the intersection of a widget’s area and area, storing the intersection in intersection, and returns true if there was an intersection. intersection may be nil if you’re only interested in whether there was an intersection.
#is_ancestor(ancestor) ⇒ TrueClass
Determines whether widget is somewhere inside ancestor, possibly with intermediate containers.
#is_composited ⇒ TrueClass
Whether widget can rely on having its alpha channel drawn correctly. On X11 this function returns whether a compositing manager is running for widget’s screen.
Please note that the semantics of this call will change in the future if used on a widget that has a composited window in its hierarchy (as set by gdk_window_set_composited()). channel being drawn correctly.
#is_drawable ⇒ TrueClass
Determines whether widget can be drawn to. A widget can be drawn to if it is mapped and visible.
#is_focus ⇒ TrueClass
Determines if the widget is the focus widget within its toplevel. (This does not mean that the Gtk::Widget:has-focus property is necessarily set; Gtk::Widget:has-focus will only be set if the toplevel widget additionally has the global input focus.)
#is_focus=(is_focus) ⇒ TrueClass
#is_focus? ⇒ TrueClass
Returns is-focus.
#is_sensitive ⇒ TrueClass
Returns the widget’s effective sensitivity, which means it is sensitive itself and also its parent widget is sensitive
#is_toplevel ⇒ TrueClass
Determines whether widget is a toplevel widget.
Currently only Gtk::Window and #GtkInvisible (and out-of-process Gtk::Plugs) are toplevel widgets. Toplevel widgets have no parent widget.
#is_visible ⇒ TrueClass
Determines whether the widget and all its parents are marked as visible.
This function does not check if the widget is obscured in any way.
See also gtk_widget_get_visible() and gtk_widget_set_visible()
#keynav_failed(direction) ⇒ TrueClass
This function should be called whenever keyboard navigation within a single widget hits a boundary. The function emits the Gtk::Widget::keynav-failed signal on the widget and its return value should be interpreted in a way similar to the return value of gtk_widget_child_focus():
When true is returned, stay in the widget, the failed keyboard navigation is OK and/or there is nowhere we can/should move the focus to.
When false is returned, the caller should continue with keyboard navigation outside the widget, e.g. by calling gtk_widget_child_focus() on the widget’s toplevel.
The default ::keynav-failed handler returns false for %GTK_DIR_TAB_FORWARD and %GTK_DIR_TAB_BACKWARD. For the other values of Gtk::DirectionType it returns true.
Whenever the default handler returns true, it also calls gtk_widget_error_bell() to notify the user of the failed keyboard navigation.
A use case for providing an own implementation of ::keynav-failed (either by connecting to it or by overriding it) would be a row of Gtk::Entry widgets where the user should be able to navigate the entire row with the cursor keys, as e.g. known from user interfaces that require entering license keys.
#list_accel_closures ⇒ GLib::List
Lists the closures used by widget for accelerator group connections with gtk_accel_group_connect_by_path() or gtk_accel_group_connect(). The closures can be used to monitor accelerator changes on widget, by connecting to the GtkAccelGroup::accel-changed signal of the Gtk::AccelGroup of a closure which can be found out with gtk_accel_group_from_accel_closure().
#list_action_prefixes ⇒ Array<String>
Retrieves an array of strings containing the prefixes of GAction::Group’s available to widget.
#list_mnemonic_labels ⇒ GLib::List
Returns a newly allocated list of the widgets, normally labels, for which this widget is the target of a mnemonic (see for example, gtk_label_set_mnemonic_widget()).
The widgets in the list are not individually referenced. If you want to iterate through the list and perform actions involving callbacks that might destroy the widgets, you must call ‘g_list_foreach (result, (GFunc)g_object_ref, NULL)` first, and then unref all the widgets afterwards.
#list_style_properties(n_properties) ⇒ Array<GObject::ParamSpec>
Returns all style properties of a widget class.
#map ⇒ nil
This function is only for use in widget implementations. Causes a widget to be mapped if it isn’t already.
#mapped ⇒ TrueClass
Whether the widget is mapped.
#mapped=(mapped) ⇒ nil
Marks the widget as being mapped.
This function should only ever be called in a derived widget’s “map” or “unmap” implementation.
#margin ⇒ Integer
Sets all four sides’ margin at once. If read, returns max margin on any side.
#margin=(margin) ⇒ Integer
Sets all four sides’ margin at once. If read, returns max margin on any side.
#margin_bottom ⇒ Integer
Margin on bottom side of widget.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from gtk_widget_set_size_request() for example.
#margin_bottom=(margin_bottom) ⇒ Integer
Margin on bottom side of widget.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from gtk_widget_set_size_request() for example.
#margin_end ⇒ Integer
Margin on end of widget, horizontally. This property supports left-to-right and right-to-left text directions.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from gtk_widget_set_size_request() for example.
#margin_end=(margin_end) ⇒ Integer
Margin on end of widget, horizontally. This property supports left-to-right and right-to-left text directions.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from gtk_widget_set_size_request() for example.
#margin_left ⇒ Integer
Margin on left side of widget.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from gtk_widget_set_size_request() for example.
#margin_left=(margin_left) ⇒ Integer
Margin on left side of widget.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from gtk_widget_set_size_request() for example.
#margin_right ⇒ Integer
Margin on right side of widget.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from gtk_widget_set_size_request() for example.
#margin_right=(margin_right) ⇒ Integer
Margin on right side of widget.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from gtk_widget_set_size_request() for example.
#margin_start ⇒ Integer
Margin on start of widget, horizontally. This property supports left-to-right and right-to-left text directions.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from gtk_widget_set_size_request() for example.
#margin_start=(margin_start) ⇒ Integer
Margin on start of widget, horizontally. This property supports left-to-right and right-to-left text directions.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from gtk_widget_set_size_request() for example.
#margin_top ⇒ Integer
Margin on top side of widget.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from gtk_widget_set_size_request() for example.
#margin_top=(margin_top) ⇒ Integer
Margin on top side of widget.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from gtk_widget_set_size_request() for example.
#mnemonic_activate(group_cycling) ⇒ TrueClass
Emits the Gtk::Widget::mnemonic-activate signal.
#modifier_style ⇒ Gtk::RcStyle
Returns the current modifier style for the widget. (As set by gtk_widget_modify_style().) If no style has previously set, a new Gtk::RcStyle will be created with all values unset, and set as the modifier style for the widget. If you make changes to this rc style, you must call gtk_widget_modify_style(), passing in the returned rc style, to make sure that your changes take effect.
Caution: passing the style back to gtk_widget_modify_style() will normally end up destroying it, because gtk_widget_modify_style() copies the passed-in style and sets the copy as the new modifier style, thus dropping any reference to the old modifier style. Add a reference to the modifier style if you want to keep it alive.
#modify_base(state, color) ⇒ nil
Sets the base color for a widget in a particular state. All other style values are left untouched. The base color is the background color used along with the text color (see gtk_widget_modify_text()) for widgets such as Gtk::Entry and Gtk::TextView. See also gtk_widget_modify_style().
> Note that “no window” widgets (which have the %GTK_NO_WINDOW > flag set) draw on their parent container’s window and thus may > not draw any background themselves. This is the case for e.g. > Gtk::Label. > > To modify the background of such widgets, you have to set the > base color on their parent; if you want to set the background > of a rectangular area around a label, try placing the label in > a Gtk::EventBox widget and setting the base color on that.
#modify_bg(state, color) ⇒ nil
Sets the background color for a widget in a particular state.
All other style values are left untouched. See also gtk_widget_modify_style().
> Note that “no window” widgets (which have the %GTK_NO_WINDOW > flag set) draw on their parent container’s window and thus may > not draw any background themselves. This is the case for e.g. > Gtk::Label. > > To modify the background of such widgets, you have to set the > background color on their parent; if you want to set the background > of a rectangular area around a label, try placing the label in > a Gtk::EventBox widget and setting the background color on that.
#modify_cursor(primary, secondary) ⇒ nil
Sets the cursor color to use in a widget, overriding the Gtk::Widget cursor-color and secondary-cursor-color style properties.
All other style values are left untouched. See also gtk_widget_modify_style().
#modify_fg(state, color) ⇒ nil
Sets the foreground color for a widget in a particular state.
All other style values are left untouched. See also gtk_widget_modify_style().
#modify_font(font_desc) ⇒ nil
Sets the font to use for a widget.
All other style values are left untouched. See also gtk_widget_modify_style().
#modify_style(style) ⇒ nil
Modifies style values on the widget.
Modifications made using this technique take precedence over style values set via an RC file, however, they will be overridden if a style is explicitly set on the widget using gtk_widget_set_style(). The Gtk::RcStyle-struct is designed so each field can either be set or unset, so it is possible, using this function, to modify some style values and leave the others unchanged.
Note that modifications made with this function are not cumulative with previous calls to gtk_widget_modify_style() or with such functions as gtk_widget_modify_fg(). If you wish to retain previous values, you must first call gtk_widget_get_modifier_style(), make your modifications to the returned style, then call gtk_widget_modify_style() with that style. On the other hand, if you first call gtk_widget_modify_style(), subsequent calls to such functions gtk_widget_modify_fg() will have a cumulative effect with the initial modifications.
#modify_text(state, color) ⇒ nil
Sets the text color for a widget in a particular state.
All other style values are left untouched. The text color is the foreground color used along with the base color (see gtk_widget_modify_base()) for widgets such as Gtk::Entry and #GtkTextView. See also gtk_widget_modify_style().
#name ⇒ String
Returns name.
#name=(name) ⇒ String
#new(type, first_property_name, array) ⇒ Gtk::Widget
This is a convenience function for creating a widget and setting its properties in one go. For example you might write: ‘gtk_widget_new (GTK_TYPE_LABEL, “label”, “Hello World”, “xalign”, 0.0, NULL)` to create a left-aligned label. Equivalent to g_object_new(), but returns a widget so you don’t have to cast the object yourself.
#no_show_all ⇒ TrueClass
Returns the current value of the Gtk::Widget:no-show-all property, which determines whether calls to gtk_widget_show_all() will affect this widget.
#no_show_all=(no_show_all) ⇒ TrueClass
#no_show_all? ⇒ TrueClass
Returns no-show-all.
#opacity ⇒ Float
The requested opacity of the widget. See gtk_widget_set_opacity() for more details about window opacity.
Before 3.8 this was only available in GtkWindow
#opacity=(opacity) ⇒ Float
The requested opacity of the widget. See gtk_widget_set_opacity() for more details about window opacity.
Before 3.8 this was only available in GtkWindow
#override_background_color(state, color) ⇒ nil
Sets the background color to use for a widget.
All other style values are left untouched. See gtk_widget_override_color().
#override_color(state, color) ⇒ nil
Sets the color to use for a widget.
All other style values are left untouched.
This function does not act recursively. Setting the color of a container does not affect its children. Note that some widgets that you may not think of as containers, for instance Gtk::Buttons, are actually containers.
This API is mostly meant as a quick way for applications to change a widget appearance. If you are developing a widgets library and intend this change to be themeable, it is better done by setting meaningful CSS classes in your widget/container implementation through gtk_style_context_add_class().
This way, your widget library can install a Gtk::CssProvider with the %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK priority in order to provide a default styling for those widgets that need so, and this theming may fully overridden by the user’s theme.
Note that for complex widgets this may bring in undesired results (such as uniform background color everywhere), in these cases it is better to fully style such widgets through a Gtk::CssProvider with the %GTK_STYLE_PROVIDER_PRIORITY_APPLICATION priority.
#override_cursor(cursor, secondary_cursor) ⇒ nil
Sets the cursor color to use in a widget, overriding the cursor-color and secondary-cursor-color style properties. All other style values are left untouched. See also gtk_widget_modify_style().
Note that the underlying properties have the Gdk::Color type, so the alpha value in primary and secondary will be ignored.
#override_font(font_desc) ⇒ nil
Sets the font to use for a widget. All other style values are left untouched. See gtk_widget_override_color().
#override_symbolic_color(name, color) ⇒ nil
Sets a symbolic color for a widget.
All other style values are left untouched. See gtk_widget_override_color() for overriding the foreground or background color.
#pango_context ⇒ Pango::Context
Gets a Pango::Context with the appropriate font map, font description, and base direction for this widget. Unlike the context returned by gtk_widget_create_pango_context(), this context is owned by the widget (it can be used until the screen for the widget changes or the widget is removed from its toplevel), and will be updated to match any changes to the widget’s attributes. This can be tracked by using the Gtk::Widget::screen-changed signal on the widget.
#parent ⇒ Gtk::Container
Returns parent.
#parent=(parent) ⇒ Gtk::Container
#parent_window ⇒ Gdk::Window
Gets widget’s parent window, or nil if it does not have one. if it does not have a parent window.
#parent_window=(parent_window) ⇒ nil
Sets a non default parent window for widget.
For Gtk::Window classes, setting a parent_window effects whether the window is a toplevel window or can be embedded into other widgets.
For Gtk::Window classes, this needs to be called before the window is realized.
#path(path_length, path, path_reversed) ⇒ nil
Obtains the full path to widget. The path is simply the name of a widget and all its parents in the container hierarchy, separated by periods. The name of a widget comes from gtk_widget_get_name(). Paths are used to apply styles to a widget in gtkrc configuration files. Widget names are the type of the widget by default (e.g. “GtkButton”) or can be set to an application-specific value with gtk_widget_set_name(). By setting the name of a widget, you allow users or theme authors to apply styles to that specific widget in their gtkrc file. path_reversed_p fills in the path in reverse order, i.e. starting with widget’s name instead of starting with the name of widget’s outermost ancestor.
#queue_allocate ⇒ nil
This function is only for use in widget implementations.
Flags the widget for a rerun of the GtkWidgetClass::size_allocate function. Use this function instead of gtk_widget_queue_resize() when the widget’s size request didn’t change but it wants to reposition its contents.
An example user of this function is gtk_widget_set_halign().
#queue_compute_expand ⇒ nil
Mark widget as needing to recompute its expand flags. Call this function when setting legacy expand child properties on the child of a container.
See gtk_widget_compute_expand().
#queue_draw ⇒ nil
Equivalent to calling gtk_widget_queue_draw_area() for the entire area of a widget.
#queue_draw_area(x, y, width, height) ⇒ nil
Convenience function that calls gtk_widget_queue_draw_region() on the region created from the given coordinates.
The region here is specified in widget coordinates. Widget coordinates are a bit odd; for historical reasons, they are defined as widget->window coordinates for widgets that return true for gtk_widget_get_has_window(), and are relative to widget->allocation.x, widget->allocation.y otherwise.
width or height may be 0, in this case this function does nothing. Negative values for width and height are not allowed.
#queue_draw_region(region) ⇒ nil
Invalidates the area of widget defined by region by calling gdk_window_invalidate_region() on the widget’s window and all its child windows. Once the main loop becomes idle (after the current batch of events has been processed, roughly), the window will receive expose events for the union of all regions that have been invalidated.
Normally you would only use this function in widget implementations. You might also use it to schedule a redraw of a Gtk::DrawingArea or some portion thereof.
#queue_resize ⇒ nil
This function is only for use in widget implementations. Flags a widget to have its size renegotiated; should be called when a widget for some reason has a new size request. For example, when you change the text in a Gtk::Label, #GtkLabel queues a resize to ensure there’s enough space for the new text.
Note that you cannot call gtk_widget_queue_resize() on a widget from inside its implementation of the GtkWidgetClass::size_allocate virtual method. Calls to gtk_widget_queue_resize() from inside GtkWidgetClass::size_allocate will be silently ignored.
#queue_resize_no_redraw ⇒ nil
This function works like gtk_widget_queue_resize(), except that the widget is not invalidated.
#realize ⇒ nil
Creates the GDK (windowing system) resources associated with a widget. For example, widget->window will be created when a widget is realized. Normally realization happens implicitly; if you show a widget and all its parent containers, then the widget will be realized and mapped automatically.
Realizing a widget requires all the widget’s parent widgets to be realized; calling gtk_widget_realize() realizes the widget’s parents in addition to widget itself. If a widget is not yet inside a toplevel window when you realize it, bad things will happen.
This function is primarily used in widget implementations, and isn’t very useful otherwise. Many times when you think you might need it, a better approach is to connect to a signal that will be called after the widget is realized automatically, such as Gtk::Widget::draw. Or simply g_signal_connect () to the Gtk::Widget::realize signal.
#realized ⇒ TrueClass
Determines whether widget is realized.
#realized=(realized) ⇒ nil
Marks the widget as being realized. This function must only be called after all Gdk::Windows for the widget have been created and registered.
This function should only ever be called in a derived widget’s “realize” or “unrealize” implementation.
#receives_default ⇒ TrueClass
Determines whether widget is always treated as the default widget within its toplevel when it has the focus, even if another widget is the default.
See gtk_widget_set_receives_default().
#receives_default=(receives_default) ⇒ TrueClass
#receives_default? ⇒ TrueClass
Returns receives-default.
#redraw_on_allocate=(redraw_on_allocate) ⇒ nil
Sets whether the entire widget is queued for drawing when its size allocation changes. By default, this setting is true and the entire widget is redrawn on every size change. If your widget leaves the upper left unchanged when made bigger, turning this setting off will improve performance.
Note that for widgets where gtk_widget_get_has_window() is false setting this flag to false turns off all allocation on resizing: the widget will not even redraw if its position changes; this is to allow containers that don’t draw anything to avoid excess invalidations. If you set this flag on a widget with no window that does draw on widget->window, you are responsible for invalidating both the old and new allocation of the widget when the widget is moved and responsible for invalidating regions newly when the widget increases size.
#region_intersect(region) ⇒ cairo::Region
Computes the intersection of a widget’s area and region, returning the intersection. The result may be empty, use cairo_region_is_empty() to check.
#register_window(window) ⇒ nil
Registers a Gdk::Window with the widget and sets it up so that the widget receives events for it. Call gtk_widget_unregister_window() when destroying the window.
Before 3.8 you needed to call gdk_window_set_user_data() directly to set this up. This is now deprecated and you should use gtk_widget_register_window() instead. Old code will keep working as is, although some new features like transparency might not work perfectly.
#remove_accelerator(accel_group, accel_key, accel_mods) ⇒ TrueClass
Removes an accelerator from widget, previously installed with gtk_widget_add_accelerator().
#remove_mnemonic_label(label) ⇒ nil
Removes a widget from the list of mnemonic labels for this widget. (See gtk_widget_list_mnemonic_labels()). The widget must have previously been added to the list with gtk_widget_add_mnemonic_label().
#remove_tick_callback(id) ⇒ nil
Removes a tick callback previously registered with gtk_widget_add_tick_callback().
#render_icon(stock_id, size, detail) ⇒ GdkPixbuf::Pixbuf
A convenience function that uses the theme settings for widget to look up stock_id and render it to a pixbuf. stock_id should be a stock icon ID such as #GTK_STOCK_OPEN or #GTK_STOCK_OK. size should be a size such as #GTK_ICON_SIZE_MENU. detail should be a string that identifies the widget or code doing the rendering, so that theme engines can special-case rendering for that widget or code.
The pixels in the returned Gdk::Pixbuf are shared with the rest of the application and should not be modified. The pixbuf should be freed after use with g_object_unref().
#render_icon_pixbuf(stock_id, size) ⇒ GdkPixbuf::Pixbuf
A convenience function that uses the theme engine and style settings for widget to look up stock_id and render it to a pixbuf. stock_id should be a stock icon ID such as #GTK_STOCK_OPEN or #GTK_STOCK_OK. size should be a size such as #GTK_ICON_SIZE_MENU.
The pixels in the returned Gdk::Pixbuf are shared with the rest of the application and should not be modified. The pixbuf should be freed after use with g_object_unref().
#reparent(new_parent) ⇒ nil
Moves a widget from one Gtk::Container to another, handling reference count issues to avoid destroying the widget.
#request_mode ⇒ Gtk::SizeRequestMode
Gets whether the widget prefers a height-for-width layout or a width-for-height layout.
Gtk::Bin widgets generally propagate the preference of their child, container widgets need to request something either in context of their children or in context of their allocation capabilities.
#reset_rc_styles ⇒ nil
Reset the styles of widget and all descendents, so when they are looked up again, they get the correct values for the currently loaded RC file settings.
This function is not useful for applications.
#reset_style ⇒ nil
Updates the style context of widget and all descendants by updating its widget path. Gtk::Containers may want to use this on a child when reordering it in a way that a different style might apply to it. See also gtk_container_get_path_for_child().
#root_window ⇒ Gdk::Window
Get the root window where this widget is located. This function can only be called after the widget has been added to a widget hierarchy with Gtk::Window at the top.
The root window is useful for such purposes as creating a popup Gdk::Window associated with the window. In general, you should only create display specific resources when a widget has been realized, and you should free those resources when the widget is unrealized.
#scale_factor ⇒ Integer
The scale factor of the widget. See gtk_widget_get_scale_factor() for more details about widget scaling.
#scale_factor=(scale_factor) ⇒ Integer
The scale factor of the widget. See gtk_widget_get_scale_factor() for more details about widget scaling.
#screen ⇒ Gdk::Screen
Get the Gdk::Screen from the toplevel window associated with this widget. This function can only be called after the widget has been added to a widget hierarchy with a Gtk::Window at the top.
In general, you should only create screen specific resources when a widget has been realized, and you should free those resources when the widget is unrealized.
#send_expose(event) ⇒ Integer
Very rarely-used function. This function is used to emit an expose event on a widget. This function is not normally used directly. The only time it is used is when propagating an expose event to a windowless child widget (gtk_widget_get_has_window() is false), and that is normally done using gtk_container_propagate_draw().
If you want to force an area of a window to be redrawn, use gdk_window_invalidate_rect() or gdk_window_invalidate_region(). To cause the redraw to be done immediately, follow that call with a call to gdk_window_process_updates().
#send_focus_change(event) ⇒ TrueClass
Sends the focus change event to widget
This function is not meant to be used by applications. The only time it should be used is when it is necessary for a Gtk::Widget to assign focus to a widget that is semantically owned by the first widget even though it’s not a direct child - for instance, a search entry in a floating window similar to the quick search in Gtk::TreeView.
An example of its usage is:
GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE);
fevent->focus_change.type = GDK_FOCUS_CHANGE;
fevent->focus_change.in = TRUE;
fevent->focus_change.window = _gtk_widget_get_window (widget);
if (fevent->focus_change.window != NULL)
g_object_ref (fevent->focus_change.window);
gtk_widget_send_focus_change (widget, fevent);
gdk_event_free (event);
#sensitive ⇒ TrueClass
Returns the widget’s sensitivity (in the sense of returning the value that has been set using gtk_widget_set_sensitive()).
The effective sensitivity of a widget is however determined by both its own and its parent widget’s sensitivity. See gtk_widget_is_sensitive().
#sensitive=(sensitive) ⇒ TrueClass
#sensitive? ⇒ TrueClass
Returns sensitive.
#set_accel_path(accel_path, accel_group) ⇒ nil
Given an accelerator group, accel_group, and an accelerator path, accel_path, sets up an accelerator in accel_group so whenever the key binding that is defined for accel_path is pressed, widget will be activated. This removes any accelerators (for any accelerator group) installed by previous calls to gtk_widget_set_accel_path(). Associating accelerators with paths allows them to be modified by the user and the modifications to be saved for future use. (See gtk_accel_map_save().)
This function is a low level function that would most likely be used by a menu creation system like Gtk::UIManager. If you use Gtk::UIManager, setting up accelerator paths will be done automatically.
Even when you you aren’t using Gtk::UIManager, if you only want to set up accelerators on menu items gtk_menu_item_set_accel_path() provides a somewhat more convenient interface.
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().
#set_connect_func(connect_func, connect_data, connect_data_destroy) ⇒ nil
For use in language bindings, this will override the default Gtk::BuilderConnectFunc to be used when parsing GtkBuilder XML from this class’s template data.
Note that this must be called from a composite widget classes class initializer after calling gtk_widget_class_set_template().
#set_device_enabled(device, enabled) ⇒ nil
Enables or disables a Gdk::Device to interact with widget and all its children.
It does so by descending through the Gdk::Window hierarchy and enabling the same mask that is has for core events (i.e. the one that gdk_window_get_events() returns).
#set_device_events(device, events) ⇒ nil
Sets the device event mask (see Gdk::EventMask) for a widget. The event mask determines which events a widget will receive from device. Keep in mind that different widgets have different default event masks, and by changing the event mask you may disrupt a widget’s functionality, so be careful. This function must be called while a widget is unrealized. Consider gtk_widget_add_device_events() for widgets that are already realized, or if you want to preserve the existing event mask. This function can’t be used with windowless widgets (which return false from gtk_widget_get_has_window()); to get events on those widgets, place them inside a Gtk::EventBox and receive events on the event box.
#set_size_request(width, height) ⇒ nil
Sets the minimum size of a widget; that is, the widget’s size request will be at least width by height. You can use this function to force a widget to be larger than it normally would be.
In most cases, gtk_window_set_default_size() is a better choice for toplevel windows than this function; setting the default size will still allow users to shrink the window. Setting the size request will force them to leave the window at least as large as the size request. When dealing with window sizes, gtk_window_set_geometry_hints() can be a useful function as well.
Note the inherent danger of setting any fixed size - themes, translations into other languages, different fonts, and user action can all change the appropriate size for a given widget. So, it’s basically impossible to hardcode a size that will always be correct.
The size request of a widget is the smallest size a widget can accept while still functioning well and drawing itself correctly. However in some strange cases a widget may be allocated less than its requested size, and in many cases a widget may be allocated more space than it requested.
If the size request in a given direction is -1 (unset), then the “natural” size request of the widget will be used instead.
The size request set here does not include any margin from the Gtk::Widget properties margin-left, margin-right, margin-top, and margin-bottom, but it does include pretty much all other padding or border properties set by any subclass of Gtk::Widget.
#set_state_flags(flags, clear) ⇒ nil
This function is for use in widget implementations. Turns on flag values in the current widget state (insensitive, prelighted, etc.).
This function accepts the values %GTK_STATE_FLAG_DIR_LTR and %GTK_STATE_FLAG_DIR_RTL but ignores them. If you want to set the widget’s direction, use gtk_widget_set_direction().
It is worth mentioning that any other state than %GTK_STATE_FLAG_INSENSITIVE, will be propagated down to all non-internal children if widget is a Gtk::Container, while %GTK_STATE_FLAG_INSENSITIVE itself will be propagated down to all Gtk::Container children by different means than turning on the state flag down the hierarchy, both gtk_widget_get_state_flags() and gtk_widget_is_sensitive() will make use of these.
#settings ⇒ Gtk::Settings
Gets the settings object holding the settings used for this widget.
Note that this function can only be called when the Gtk::Widget is attached to a toplevel, since the settings object is specific to a particular Gdk::Screen.
#shape_combine_region(region) ⇒ nil
Sets a shape for this widget’s GDK window. This allows for transparent windows etc., see gdk_window_shape_combine_region() for more information.
#show ⇒ nil
Flags a widget to be displayed. Any widget that isn’t shown will not appear on the screen. If you want to show all the widgets in a container, it’s easier to call gtk_widget_show_all() on the container, instead of individually showing the widgets.
Remember that you have to show the containers containing a widget, in addition to the widget itself, before it will appear onscreen.
When a toplevel container is shown, it is immediately realized and mapped; other shown widgets are realized and mapped when their toplevel container is realized and mapped.
#show_all ⇒ nil
Recursively shows a widget, and any child widgets (if the widget is a container).
#show_now ⇒ nil
Shows a widget. If the widget is an unmapped toplevel widget (i.e. a Gtk::Window that has not yet been shown), enter the main loop and wait for the window to actually be mapped. Be careful; because the main loop is running, anything can happen during this function.
#size_allocate(allocation) ⇒ nil
This function is only used by Gtk::Container subclasses, to assign a size and position to their child widgets.
In this function, the allocation may be adjusted. It will be forced to a 1x1 minimum size, and the adjust_size_allocation virtual method on the child will be used to adjust the allocation. Standard adjustments include removing the widget’s margins, and applying the widget’s Gtk::Widget:halign and #GtkWidget:valign properties.
For baseline support in containers you need to use gtk_widget_size_allocate_with_baseline() instead.
#size_allocate_with_baseline(allocation, baseline) ⇒ nil
This function is only used by Gtk::Container subclasses, to assign a size, position and (optionally) baseline to their child widgets.
In this function, the allocation and baseline may be adjusted. It will be forced to a 1x1 minimum size, and the adjust_size_allocation virtual and adjust_baseline_allocation methods on the child will be used to adjust the allocation and baseline. Standard adjustments include removing the widget’s margins, and applying the widget’s Gtk::Widget:halign and Gtk::Widget:valign properties.
If the child widget does not have a valign of %GTK_ALIGN_BASELINE the baseline argument is ignored and -1 is used instead.
#size_request(requisition) ⇒ nil
This function is typically used when implementing a Gtk::Container subclass. Obtains the preferred size of a widget. The container uses this information to arrange its child widgets and decide what size allocations to give them with gtk_widget_size_allocate().
You can also call this function from an application, with some caveats. Most notably, getting a size request requires the widget to be associated with a screen, because font information may be needed. Multihead-aware applications should keep this in mind.
Also remember that the size request is not necessarily the size a widget will actually be allocated.
#state ⇒ Gtk::StateType
Returns the widget’s state. See gtk_widget_set_state().
#state=(state) ⇒ nil
This function is for use in widget implementations. Sets the state of a widget (insensitive, prelighted, etc.) Usually you should set the state using wrapper functions such as gtk_widget_set_sensitive().
#state_flags ⇒ Gtk::StateFlags
Returns the widget state as a flag set. It is worth mentioning that the effective %GTK_STATE_FLAG_INSENSITIVE state will be returned, that is, also based on parent insensitivity, even if widget itself is sensitive.
Also note that if you are looking for a way to obtain the Gtk::StateFlags to pass to a #GtkStyleContext method, you should look at gtk_style_context_get_state().
#style ⇒ Gtk::Style
The style of the widget, which contains information about how it will look (colors, etc).
#style=(style) ⇒ Gtk::Style
The style of the widget, which contains information about how it will look (colors, etc).
#style_attach ⇒ nil
This function attaches the widget’s Gtk::Style to the widget’s Gdk::Window. It is a replacement for
|[ widget->style = gtk_style_attach (widget->style, widget->window); ]|
and should only ever be called in a derived widget’s “realize” implementation which does not chain up to its parent class’ “realize” implementation, because one of the parent classes (finally Gtk::Widget) would attach the style itself.
#style_context ⇒ Gtk::StyleContext
Returns the style context associated to widget. The returned object is guaranteed to be the same for the lifetime of widget.
#style_get(first_property_name, array) ⇒ nil
Gets the values of a multiple style properties of widget.
#style_get_property(property_name, value) ⇒ nil
Gets the value of a style property of widget.
#style_get_valist(first_property_name, var_args) ⇒ nil
Non-vararg variant of gtk_widget_style_get(). Used primarily by language bindings.
#support_multidevice ⇒ TrueClass
Returns true if widget is multiple pointer aware. See gtk_widget_set_support_multidevice() for more information.
#support_multidevice=(support_multidevice) ⇒ nil
Enables or disables multiple pointer awareness. If this setting is true, widget will start receiving multiple, per device enter/leave events. Note that if custom Gdk::Windows are created in #GtkWidget::realize, gdk_window_set_support_multidevice() will have to be called manually on them.
#template=(template_bytes) ⇒ nil
This should be called at class initialization time to specify the GtkBuilder XML to be used to extend a widget.
For convenience, gtk_widget_class_set_template_from_resource() is also provided.
Note that any class that installs templates must call gtk_widget_init_template() in the widget’s instance initializer.
#template_from_resource=(resource_name) ⇒ nil
A convenience function to call gtk_widget_class_set_template().
Note that any class that installs templates must call gtk_widget_init_template() in the widget’s instance initializer.
#thaw_child_notify ⇒ nil
Reverts the effect of a previous call to gtk_widget_freeze_child_notify(). This causes all queued Gtk::Widget::child-notify signals on widget to be emitted.
#tooltip_markup ⇒ String
Sets the text of tooltip to be the given string, which is marked up with the [Pango text markup language]. Also see gtk_tooltip_set_markup().
This is a convenience property which will take care of getting the tooltip shown if the given string is not nil: Gtk::Widget:has-tooltip will automatically be set to true and there will be taken care of Gtk::Widget::query-tooltip in the default signal handler.
Note that if both Gtk::Widget:tooltip-text and #GtkWidget:tooltip-markup are set, the last one wins.
#tooltip_markup=(tooltip_markup) ⇒ String
Sets the text of tooltip to be the given string, which is marked up with the [Pango text markup language]. Also see gtk_tooltip_set_markup().
This is a convenience property which will take care of getting the tooltip shown if the given string is not nil: Gtk::Widget:has-tooltip will automatically be set to true and there will be taken care of Gtk::Widget::query-tooltip in the default signal handler.
Note that if both Gtk::Widget:tooltip-text and #GtkWidget:tooltip-markup are set, the last one wins.
#tooltip_text ⇒ String
Sets the text of tooltip to be the given string.
Also see gtk_tooltip_set_text().
This is a convenience property which will take care of getting the tooltip shown if the given string is not nil: Gtk::Widget:has-tooltip will automatically be set to true and there will be taken care of Gtk::Widget::query-tooltip in the default signal handler.
Note that if both Gtk::Widget:tooltip-text and #GtkWidget:tooltip-markup are set, the last one wins.
#tooltip_text=(tooltip_text) ⇒ String
Sets the text of tooltip to be the given string.
Also see gtk_tooltip_set_text().
This is a convenience property which will take care of getting the tooltip shown if the given string is not nil: Gtk::Widget:has-tooltip will automatically be set to true and there will be taken care of Gtk::Widget::query-tooltip in the default signal handler.
Note that if both Gtk::Widget:tooltip-text and #GtkWidget:tooltip-markup are set, the last one wins.
#tooltip_window ⇒ Gtk::Window
Returns the Gtk::Window of the current tooltip. This can be the GtkWindow created by default, or the custom tooltip window set using gtk_widget_set_tooltip_window().
#tooltip_window=(custom_window) ⇒ nil
Replaces the default window used for displaying tooltips with custom_window. GTK+ will take care of showing and hiding custom_window at the right moment, to behave likewise as the default tooltip window. If custom_window is nil, the default tooltip window will be used.
#toplevel ⇒ Gtk::Widget
This function returns the topmost widget in the container hierarchy widget is a part of. If widget has no parent widgets, it will be returned as the topmost widget. No reference will be added to the returned widget; it should not be unreferenced.
Note the difference in behavior vs. gtk_widget_get_ancestor(); ‘gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW)` would return nil if widget wasn’t inside a toplevel window, and if the window was inside a Gtk::Window-derived widget which was in turn inside the toplevel Gtk::Window. While the second case may seem unlikely, it actually happens when a Gtk::Plug is embedded inside a Gtk::Socket within the same application.
To reliably find the toplevel Gtk::Window, use gtk_widget_get_toplevel() and call GTK_IS_WINDOW() on the result. For instance, to get the title of a widget’s toplevel window, one might use:
static const char *
get_widget_toplevel_title (GtkWidget *widget)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
if (GTK_IS_WINDOW (toplevel))
{
return gtk_window_get_title (GTK_WINDOW (toplevel));
}
return NULL;
}
#translate_coordinates(dest_widget, src_x, src_y, dest_x, dest_y) ⇒ TrueClass
Translate coordinates relative to src_widget’s allocation to coordinates relative to dest_widget’s allocations. In order to perform this operation, both widgets must be realized, and must share a common toplevel.
#trigger_tooltip_query ⇒ nil
Triggers a tooltip query on the display where the toplevel of widget is located. See gtk_tooltip_trigger_tooltip_query() for more information.
#unmap ⇒ nil
This function is only for use in widget implementations. Causes a widget to be unmapped if it’s currently mapped.
#unparent ⇒ nil
This function is only for use in widget implementations. Should be called by implementations of the remove method on Gtk::Container, to dissociate a child from the container.
#unrealize ⇒ nil
This function is only useful in widget implementations. Causes a widget to be unrealized (frees all GDK resources associated with the widget, such as widget->window).
#unregister_window(window) ⇒ nil
Unregisters a Gdk::Window from the widget that was previously set up with gtk_widget_register_window(). You need to call this when the window is no longer used by the widget, such as when you destroy it.
#unset_state_flags(flags) ⇒ nil
This function is for use in widget implementations. Turns off flag values for the current widget state (insensitive, prelighted, etc.). See gtk_widget_set_state_flags().
#valign ⇒ Gtk::Align
How to distribute vertical space if widget gets extra space, see Gtk::Align
#valign=(valign) ⇒ Gtk::Align
How to distribute vertical space if widget gets extra space, see Gtk::Align
#valign_with_baseline ⇒ Gtk::Align
Gets the value of the Gtk::Widget:valign property, including %GTK_ALIGN_BASELINE.
#vexpand ⇒ TrueClass
Gets whether the widget would like any available extra vertical space.
See gtk_widget_get_hexpand() for more detail.
#vexpand=(vexpand) ⇒ TrueClass
Whether to expand vertically. See gtk_widget_set_vexpand().
#vexpand? ⇒ TrueClass
Whether to expand vertically. See gtk_widget_set_vexpand().
#vexpand_set ⇒ TrueClass
Gets whether gtk_widget_set_vexpand() has been used to explicitly set the expand flag on this widget.
See gtk_widget_get_hexpand_set() for more detail.
#vexpand_set=(vexpand_set) ⇒ TrueClass
Whether to use the Gtk::Widget:vexpand property. See gtk_widget_get_vexpand_set().
#vexpand_set? ⇒ TrueClass
Whether to use the Gtk::Widget:vexpand property. See gtk_widget_get_vexpand_set().
#visible ⇒ TrueClass
Determines whether the widget is visible. If you want to take into account whether the widget’s parent is also marked as visible, use gtk_widget_is_visible() instead.
This function does not check if the widget is obscured in any way.
See gtk_widget_set_visible().
#visible=(visible) ⇒ TrueClass
#visible? ⇒ TrueClass
Returns visible.
#visual ⇒ Gdk::Visual
Gets the visual that will be used to render widget.
#visual=(visual) ⇒ nil
Sets the visual that should be used for by widget and its children for creating Gdk::Windows. The visual must be on the same #GdkScreen as returned by gtk_widget_get_screen(), so handling the Gtk::Widget::screen-changed signal is necessary.
Setting a new visual will not cause widget to recreate its windows, so you should call this function before widget is realized.
#width_request ⇒ Integer
Returns width-request.
#width_request=(width_request) ⇒ Integer
#window ⇒ Gdk::Window
The widget’s window if it is realized, nil otherwise.
#window=(window) ⇒ Gdk::Window
The widget’s window if it is realized, nil otherwise.