Class: Gtk::Assistant

Inherits:
Window
  • Object
show all
Extended by:
GLib::Deprecatable
Defined in:
lib/gtk4/deprecated.rb

Overview

GtkAssistant is used to represent a complex as a series of steps.

An example GtkAssistant

Each step consists of one or more pages. GtkAssistant guides the user through the pages, and controls the page flow to collect the data needed for the operation.

GtkAssistant handles which buttons to show and to make sensitive based on page sequence knowledge and the [enumGtk.AssistantPageType] of each page in addition to state information like the completed and committed page statuses.

If you have a case that doesn’t quite fit in GtkAssistants way of handling buttons, you can use the %GTK_ASSISTANT_PAGE_CUSTOM page type and handle buttons yourself.

GtkAssistant maintains a GtkAssistantPage object for each added child, which holds additional per-child properties. You obtain the GtkAssistantPage for a child with [methodGtk.Assistant.get_page].

GtkAssistant as GtkBuildable

The GtkAssistant implementation of the GtkBuildable interface exposes the action_area as internal children with the name “action_area”.

To add pages to an assistant in GtkBuilder, simply add it as a child to the GtkAssistant object. If you need to set per-object properties, create a GtkAssistantPage object explicitly, and set the child widget as a property on it.

CSS nodes

GtkAssistant has a single CSS node with the name window and style class .assistant.

Instance Method Summary collapse

Methods inherited from Window

#application, #application=, auto_startup_notification=, #child, #child=, #close, #decorated, #decorated=, #decorated?, #default_height, #default_height=, default_icon_name, default_icon_name=, #default_widget, #default_widget=, #default_width, #default_width=, #deletable, #deletable=, #deletable?, #destroy, #destroy_with_parent, #destroy_with_parent=, #destroy_with_parent?, #display, #display=, #focus, #focus=, #focus_visible, #focus_visible=, #focus_visible?, #focus_widget, #focus_widget=, #fullscreen, #fullscreen_on_monitor, #fullscreened=, #fullscreened?, #get_default_size, #group, #handle_menubar_accel, #handle_menubar_accel=, #handle_menubar_accel?, #has_group, #hide_on_close, #hide_on_close=, #hide_on_close?, #icon_name, #icon_name=, interactive_debugging=, #is_active, #is_active=, #is_active?, #is_fullscreen, #is_maximized, #is_suspended, list_toplevels, #maximize, #maximized=, #maximized?, #minimize, #mnemonics_visible, #mnemonics_visible=, #mnemonics_visible?, #modal, #modal=, #modal?, #present, #present_with_time, #resizable, #resizable=, #resizable?, #set_default_size, #startup_id=, #suspended=, #suspended?, #title, #title=, #titlebar, #titlebar=, toplevels, #transient_for, #transient_for=, #unfullscreen, #unmaximize, #unminimize

Methods inherited from Widget

#accessible_role, #accessible_role=, #action_set_enabled, #activate, #activate_action, #activate_action_variant, #activate_default, #activate_signal, #activate_signal=, #activate_signal_from_name=, #add_binding, #add_binding_action, #add_binding_signal, #add_controller, #add_css_class, #add_mnemonic_label, #add_shortcut, #add_tick_callback, #allocate, #allocated_baseline, #allocated_height, #allocated_width, #baseline, #bind_template_callback_full, #bind_template_child, #bind_template_child_full, #can_focus, #can_focus=, #can_focus?, #can_target, #can_target=, #can_target?, #child_focus, #child_visible, #child_visible=, #children, #clipboard, #compute_bounds, #compute_expand, #compute_point, #compute_transform, #contains, #create_pango_context, #create_pango_layout, #css_classes, #css_classes=, #css_name, #css_name=, #cursor, #cursor=, #cursor_from_name=, default_direction, default_direction=, #direction, #direction=, #display, #dispose_template, #drag_check_threshold, #error_bell, #first_child, #focus_child, #focus_child=, #focus_on_click, #focus_on_click=, #focus_on_click?, #focusable, #focusable=, #focusable?, #font_map, #font_map=, #font_options, #font_options=, #frame_clock, #get_allocation, #get_ancestor, #get_color, #get_preferred_size, #get_size, #get_size_request, #get_template_child, #grab_focus, #halign, #halign=, #has_css_class, #has_default, #has_default=, #has_default?, #has_focus, #has_focus=, #has_focus?, #has_tooltip, #has_tooltip=, #has_tooltip?, #has_visible_focus, have_template?, #height, #height_request, #height_request=, #hexpand, #hexpand=, #hexpand?, #hexpand_set, #hexpand_set=, #hexpand_set?, #hide, #in_destruction, #init_template, #insert_action_group, #insert_action_group_raw, #insert_after, #insert_before, #install_action, #install_property_action, #is_ancestor, #is_drawable, #is_focus, #is_sensitive, #is_visible, #keynav_failed, #last_child, #layout_manager, #layout_manager=, #layout_manager_type, #layout_manager_type=, #list_mnemonic_labels, #map, #mapped, #margin_bottom, #margin_bottom=, #margin_end, #margin_end=, #margin_start, #margin_start=, #margin_top, #margin_top=, #measure, #mnemonic_activate, #name, #name=, #native, #next_sibling, #observe_children, #observe_controllers, #opacity, #opacity=, #overflow, #overflow=, #pango_context, #parent, #parent=, #pick, #prev_sibling, #primary_clipboard, #query_action, #queue_allocate, #queue_draw, #queue_resize, #realize, #realized, #receives_default, #receives_default=, #receives_default?, #remove_controller, #remove_css_class, #remove_mnemonic_label, #remove_tick_callback, #request_mode, #root, #root=, #scale_factor, #scale_factor=, #sensitive, #sensitive=, #sensitive?, #set_size_request, #set_size_request_raw, #set_state_flags, #set_template, #set_template_raw, #settings, #should_layout, #show, #size_allocate, #snapshot_child, #state_flags, #style_context, #style_context_raw, #template=, template_children, #template_from_resource=, #template_scope=, #tooltip_markup, #tooltip_markup=, #tooltip_text, #tooltip_text=, #translate_coordinates, #translate_coordinates_raw, #trigger_tooltip_query, #unmap, #unparent, #unrealize, #unset_state_flags, #valign, #valign=, #vexpand, #vexpand=, #vexpand?, #vexpand_set, #vexpand_set=, #vexpand_set?, #visible, #visible=, #visible?, #width, #width_request, #width_request=

Constructor Details

#initializeGtk::Widget

Creates a new GtkAssistant.

Instance Method Details

#add_action_widget(child) ⇒ nil

Adds a widget to the action area of a GtkAssistant.

Parameters:

Returns:

  • (nil)

#append_page(page) ⇒ Integer

Appends a page to the assistant.

Parameters:

Returns:

  • (Integer)

    the index (starting at 0) of the inserted page

#commitnil

Erases the visited page history.

GTK will then hide the back button on the current page, and removes the cancel button from subsequent pages.

Use this when the information provided up to the current page is hereafter deemed permanent and cannot be modified or undone. For example, showing a progress page to track a long-running, unreversible operation after the user has clicked apply on a confirmation page.

Returns:

  • (nil)

#current_pageInteger

Returns the page number of the current page.

Returns:

  • (Integer)

    The index (starting from 0) of the current page in the assistant, or -1 if the assistant has no pages, or no current page

#current_page=(page_num) ⇒ nil

Switches the page to page_num.

Note that this will only be necessary in custom buttons, as the assistant flow can be set with gtk_assistant_set_forward_page_func().

Parameters:

  • page_num (Integer)

    index of the page to switch to, starting from 0. If negative, the last page will be used. If greater than the number of pages in the assistant, nothing will be done.

Returns:

  • (nil)

#get_nth_page(page_num) ⇒ Gtk::Widget

Returns the child widget contained in page number page_num.

Parameters:

  • page_num (Integer)

    the index of a page in the assistant, or -1 to get the last page

Returns:

  • (Gtk::Widget)

    the child widget, or nil if page_num is out of bounds

#get_page(child) ⇒ Gtk::AssistantPage

Returns the GtkAssistantPage object for child.

Parameters:

Returns:

#get_page_complete(page) ⇒ Boolean

Gets whether page is complete.

Parameters:

Returns:

  • (Boolean)

    true if page is complete.

#get_page_title(page) ⇒ String

Gets the title for page.

Parameters:

Returns:

  • (String)

    the title for page

#get_page_type(page) ⇒ Gtk::AssistantPageType

Gets the page type of page.

Parameters:

Returns:

#insert_page(page, position) ⇒ Integer

Inserts a page in the assistant at a given position.

Parameters:

  • page (Gtk::Widget)

    a GtkWidget

  • position (Integer)

    the index (starting at 0) at which to insert the page, or -1 to append the page to the assistant

Returns:

  • (Integer)

    the index (starting from 0) of the inserted page

#n_pagesInteger

Returns the number of pages in the assistant

Returns:

  • (Integer)

    the number of pages in the assistant

#next_pagenil

Navigate to the next page.

It is a programming error to call this function when there is no next page.

This function is for use when creating pages of the %GTK_ASSISTANT_PAGE_CUSTOM type.

Returns:

  • (nil)

#pagesGio::ListModel

GListModel containing the pages.

Returns:

  • (Gio::ListModel)

    pages

#pages=(pages) ⇒ Gio::ListModel

GListModel containing the pages.

Parameters:

  • pages (Gio::ListModel)

Returns:

  • (Gio::ListModel)

    pages

  • (Gio::ListModel)

    pages

#prepend_page(page) ⇒ Integer

Prepends a page to the assistant.

Parameters:

Returns:

  • (Integer)

    the index (starting at 0) of the inserted page

#previous_pagenil

Navigate to the previous visited page.

It is a programming error to call this function when no previous page is available.

This function is for use when creating pages of the %GTK_ASSISTANT_PAGE_CUSTOM type.

Returns:

  • (nil)

#remove_action_widget(child) ⇒ nil

Removes a widget from the action area of a GtkAssistant.

Parameters:

Returns:

  • (nil)

#remove_page(page_num) ⇒ nil

Removes the page_num’s page from assistant.

Parameters:

  • page_num (Integer)

    the index of a page in the assistant, or -1 to remove the last page

Returns:

  • (nil)

#set_forward_page_func(page_func, data, destroy) ⇒ nil

Sets the page forwarding function to be page_func.

This function will be used to determine what will be the next page when the user presses the forward button. Setting page_func to nil will make the assistant to use the default forward function, which just goes to the next visible page.

Parameters:

  • page_func (Gtk::AssistantPageFunc)

    the GtkAssistantPageFunc, or nil to use the default one

  • data (GObject)

    user data for page_func

  • destroy (GLib::DestroyNotify)

    destroy notifier for data

Returns:

  • (nil)

#set_page_complete(page, complete) ⇒ nil

Sets whether page contents are complete.

This will make assistant update the buttons state to be able to continue the task.

Parameters:

  • page (Gtk::Widget)

    a page of assistant

  • complete (Boolean)

    the completeness status of the page

Returns:

  • (nil)

#set_page_title(page, title) ⇒ nil

Sets a title for page.

The title is displayed in the header area of the assistant when page is the current page.

Parameters:

  • page (Gtk::Widget)

    a page of assistant

  • title (String)

    the new title for page

Returns:

  • (nil)

#set_page_type(page, type) ⇒ nil

Sets the page type for page.

The page type determines the page behavior in the assistant.

Parameters:

Returns:

  • (nil)

#update_buttons_statenil

Forces assistant to recompute the buttons state.

GTK automatically takes care of this in most situations, e.g. when the user goes to a different page, or when the visibility or completeness of a page changes.

One situation where it can be necessary to call this function is when changing a value on the current page affects the future page flow of the assistant.

Returns:

  • (nil)

#use_header_barInteger

true if the assistant uses a GtkHeaderBar for action buttons instead of the action-area.

For technical reasons, this property is declared as an integer property, but you should only set it to true or false.

Returns:

  • (Integer)

    use-header-bar

#use_header_bar=(use_header_bar) ⇒ Integer

true if the assistant uses a GtkHeaderBar for action buttons instead of the action-area.

For technical reasons, this property is declared as an integer property, but you should only set it to true or false.

Parameters:

  • use_header_bar (Integer)

Returns:

  • (Integer)

    use-header-bar

  • (Integer)

    use-header-bar