Class: Gtk::Paned

Inherits:
Widget
  • Object
show all
Extended by:
GLib::Deprecatable
Defined in:
lib/gtk3/paned.rb,
lib/gtk3/deprecated.rb

Overview

A widget with two panes, arranged either horizontally or vertically.

An example GtkPaned

The division between the two panes is adjustable by the user by dragging a handle.

Child widgets are added to the panes of the widget with [methodGtk.Paned.set_start_child] and [methodGtk.Paned.set_end_child]. The division between the two children is set by default from the size requests of the children, but it can be adjusted by the user.

A paned widget draws a separator between the two child widgets and a small handle that the user can drag to adjust the division. It does not draw any relief around the children or around the separator. (The space in which the separator is called the gutter.) Often, it is useful to put each child inside a [classGtk.Frame] so that the gutter appears as a ridge. No separator is drawn if one of the children is missing.

Each child has two options that can be set, "resize" and "shrink". If "resize" is true then, when the GtkPaned is resized, that child will expand or shrink along with the paned widget. If "shrink" is true, then that child can be made smaller than its requisition by the user. Setting "shrink" to false allows the application to set a minimum size. If "resize" is false for both children, then this is treated as if "resize" is true for both children.

The application can set the position of the slider as if it were set by the user, by calling [methodGtk.Paned.set_position].

CSS nodes

paned
├── <child>
├── separator[.wide]
╰── <child>

GtkPaned has a main CSS node with name paned, and a subnode for the separator with name separator. The subnode gets a .wide style class when the paned is supposed to be wide.

In horizontal orientation, the nodes are arranged based on the text direction, so in left-to-right mode, :first-child will select the leftmost child, while it will select the rightmost child in RTL layouts.

Creating a paned widget with minimum sizes.

GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
GtkWidget *frame1 = gtk_frame_new (NULL);
GtkWidget *frame2 = gtk_frame_new (NULL);

gtk_widget_set_size_request (hpaned, 200, -1);

gtk_paned_set_start_child (GTK_PANED (hpaned), frame1);
gtk_paned_set_resize_start_child (GTK_PANED (hpaned), TRUE);
gtk_paned_set_shrink_start_child (GTK_PANED (hpaned), FALSE);
gtk_widget_set_size_request (frame1, 50, -1);

gtk_paned_set_end_child (GTK_PANED (hpaned), frame2);
gtk_paned_set_resize_end_child (GTK_PANED (hpaned), FALSE);
gtk_paned_set_shrink_end_child (GTK_PANED (hpaned), FALSE);
gtk_widget_set_size_request (frame2, 50, -1);

Instance Method Summary collapse

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_events, #add_events_raw, #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=, #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, #drag_dest_set, #drag_dest_set_raw, #drag_source_set, #drag_source_set_raw, #error_bell, #events, #events_raw, #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, #render_icon_pixbuf, #render_icon_pixbuf_raw, #request_mode, #root, #root=, #scale_factor, #scale_factor=, #sensitive, #sensitive=, #sensitive?, #set_allocation, set_connect_func, set_connect_func_raw, #set_events, #set_events_raw, #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, #style_get_property, #style_get_property_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

#initialize(orientation) ⇒ Gtk::Widget

Creates a new GtkPaned widget.

Parameters:

Instance Method Details

#end_childGtk::Widget

The second child.

Returns:

#end_child=(end_child) ⇒ Gtk::Widget

The second child.

Parameters:

Returns:

#max_positionInteger

The largest possible value for the [propertyGtk.Paned:position] property.

This property is derived from the size and shrinkability of the widget's children.

Returns:

  • (Integer)

    max-position

#max_position=(max_position) ⇒ Integer

The largest possible value for the [propertyGtk.Paned:position] property.

This property is derived from the size and shrinkability of the widget's children.

Parameters:

  • max_position (Integer)

Returns:

  • (Integer)

    max-position

  • (Integer)

    max-position

#min_positionInteger

The smallest possible value for the [propertyGtk.Paned:position] property.

This property is derived from the size and shrinkability of the widget's children.

Returns:

  • (Integer)

    min-position

#min_position=(min_position) ⇒ Integer

The smallest possible value for the [propertyGtk.Paned:position] property.

This property is derived from the size and shrinkability of the widget's children.

Parameters:

  • min_position (Integer)

Returns:

  • (Integer)

    min-position

  • (Integer)

    min-position

#pack1(child, options = {}) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/gtk3/paned.rb', line 20

def pack1(child, options={})
  resize = options[:resize]
  resize = false if resize.nil?
  shrink = options[:shrink]
  shrink = true if shrink.nil?
  pack1_raw(child, resize, shrink)
end

#pack1_rawObject



19
# File 'lib/gtk3/paned.rb', line 19

alias_method :pack1_raw, :pack1

#pack2(child, options = {}) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/gtk3/paned.rb', line 29

def pack2(child, options={})
  resize = options[:resize]
  resize = true if resize.nil?
  shrink = options[:shrink]
  shrink = true if shrink.nil?
  pack2_raw(child, resize, shrink)
end

#pack2_rawObject



28
# File 'lib/gtk3/paned.rb', line 28

alias_method :pack2_raw, :pack2

#positionInteger

Position of the separator in pixels, from the left/top.

Returns:

  • (Integer)

    position

#position=(position) ⇒ Integer

Position of the separator in pixels, from the left/top.

Parameters:

  • position (Integer)

Returns:

  • (Integer)

    position

  • (Integer)

    position

#position_set=(position_set) ⇒ Boolean

Whether the [propertyGtk.Paned:position] property has been set.

Parameters:

  • position_set (Boolean)

Returns:

  • (Boolean)

    position-set

  • (Boolean)

    position-set

#position_set?Boolean

Whether the [propertyGtk.Paned:position] property has been set.

Returns:

  • (Boolean)

    position-set

#resize_end_childBoolean

Returns whether the [propertyGtk.Paned:end-child] can be resized.

Returns:

  • (Boolean)

    true if the end child is resizable

#resize_end_child=(resize_end_child) ⇒ Boolean

Determines whether the second child expands and shrinks along with the paned widget.

Parameters:

  • resize_end_child (Boolean)

Returns:

  • (Boolean)

    resize-end-child

  • (Boolean)

    resize-end-child

#resize_end_child?Boolean

Determines whether the second child expands and shrinks along with the paned widget.

Returns:

  • (Boolean)

    resize-end-child

#resize_start_childBoolean

Returns whether the [propertyGtk.Paned:start-child] can be resized.

Returns:

  • (Boolean)

    true if the start child is resizable

#resize_start_child=(resize_start_child) ⇒ Boolean

Determines whether the first child expands and shrinks along with the paned widget.

Parameters:

  • resize_start_child (Boolean)

Returns:

  • (Boolean)

    resize-start-child

  • (Boolean)

    resize-start-child

#resize_start_child?Boolean

Determines whether the first child expands and shrinks along with the paned widget.

Returns:

  • (Boolean)

    resize-start-child

#shrink_end_childBoolean

Returns whether the [propertyGtk.Paned:end-child] can shrink.

Returns:

  • (Boolean)

    true if the end child is shrinkable

#shrink_end_child=(shrink_end_child) ⇒ Boolean

Determines whether the second child can be made smaller than its requisition.

Parameters:

  • shrink_end_child (Boolean)

Returns:

  • (Boolean)

    shrink-end-child

  • (Boolean)

    shrink-end-child

#shrink_end_child?Boolean

Determines whether the second child can be made smaller than its requisition.

Returns:

  • (Boolean)

    shrink-end-child

#shrink_start_childBoolean

Returns whether the [propertyGtk.Paned:start-child] can shrink.

Returns:

  • (Boolean)

    true if the start child is shrinkable

#shrink_start_child=(shrink_start_child) ⇒ Boolean

Determines whether the first child can be made smaller than its requisition.

Parameters:

  • shrink_start_child (Boolean)

Returns:

  • (Boolean)

    shrink-start-child

  • (Boolean)

    shrink-start-child

#shrink_start_child?Boolean

Determines whether the first child can be made smaller than its requisition.

Returns:

  • (Boolean)

    shrink-start-child

#start_childGtk::Widget

The first child.

Returns:

#start_child=(start_child) ⇒ Gtk::Widget

The first child.

Parameters:

Returns:

#wide_handleBoolean

Gets whether the separator should be wide.

Returns:

  • (Boolean)

    true if the paned should have a wide handle

#wide_handle=(wide_handle) ⇒ Boolean

Whether the GtkPaned should provide a stronger visual separation.

For example, this could be set when a paned contains two [classGtk.Notebook]s, whose tab rows would otherwise merge visually.

Parameters:

  • wide_handle (Boolean)

Returns:

  • (Boolean)

    wide-handle

  • (Boolean)

    wide-handle

#wide_handle?Boolean

Whether the GtkPaned should provide a stronger visual separation.

For example, this could be set when a paned contains two [classGtk.Notebook]s, whose tab rows would otherwise merge visually.

Returns:

  • (Boolean)

    wide-handle