Class: Gtk::IconView

Inherits:
Widget
  • Object
show all
Defined in:
(unknown)

Overview

GtkIconView is a widget which displays data in a grid of icons.

GtkIconView provides an alternative view on a GtkTreeModel. It displays the model as a grid of icons with labels. Like [classGtk.TreeView], it allows to select one or multiple items (depending on the selection mode, see [methodGtk.IconView.set_selection_mode]). In addition to selection with the arrow keys, GtkIconView supports rubberband selection, which is controlled by dragging the pointer.

Note that if the tree model is backed by an actual tree store (as opposed to a flat list where the mapping to icons is obvious), GtkIconView will only display the first level of the tree and ignore the tree’s branches.

CSS nodes

iconview.view
╰── [rubberband]

GtkIconView has a single CSS node with name iconview and style class .view. For rubberband selection, a subnode with name rubberband is used.

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_mnemonic_label, #add_shortcut, #add_tick_callback, #allocate, #allocated_baseline, #allocated_height, #allocated_width, #baseline, #bind_template_callback_full, #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, #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, #height, #height_request, #height_request=, #hexpand, #hexpand=, #hexpand?, #hexpand_set, #hexpand_set=, #hexpand_set?, #hide, #in_destruction, #init_template, #insert_action_group, #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_state_flags, #settings, #should_layout, #show, #size_allocate, #snapshot_child, #state_flags, #style_context, #template=, #template_from_resource=, #template_scope=, #tooltip_markup, #tooltip_markup=, #tooltip_text, #tooltip_text=, #translate_coordinates, #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(model) ⇒ Gtk::Widget

Creates a new GtkIconView widget with the model model.

Parameters:

Instance Method Details

#activate_on_single_clickBoolean

Gets the setting set by gtk_icon_view_set_activate_on_single_click().

Returns:

  • (Boolean)

    true if item-activated will be emitted on a single click

#activate_on_single_click=(activate_on_single_click) ⇒ Boolean

The activate-on-single-click property specifies whether the "item-activated" signal will be emitted after a single click.

Parameters:

  • activate_on_single_click (Boolean)

Returns:

  • (Boolean)

    activate-on-single-click

  • (Boolean)

    activate-on-single-click

#activate_on_single_click?Boolean

The activate-on-single-click property specifies whether the "item-activated" signal will be emitted after a single click.

Returns:

  • (Boolean)

    activate-on-single-click

#cell_areaGtk::CellArea

The GtkCellArea used to layout cell renderers for this view.

If no area is specified when creating the icon view with gtk_icon_view_new_with_area() a GtkCellAreaBox will be used.

Returns:

#cell_area=(cell_area) ⇒ Gtk::CellArea

The GtkCellArea used to layout cell renderers for this view.

If no area is specified when creating the icon view with gtk_icon_view_new_with_area() a GtkCellAreaBox will be used.

Parameters:

Returns:

#column_spacingInteger

The column-spacing property specifies the space which is inserted between the columns of the icon view.

Returns:

  • (Integer)

    column-spacing

#column_spacing=(column_spacing) ⇒ Integer

The column-spacing property specifies the space which is inserted between the columns of the icon view.

Parameters:

  • column_spacing (Integer)

Returns:

  • (Integer)

    column-spacing

  • (Integer)

    column-spacing

#columnsInteger

The columns property contains the number of the columns in which the items should be displayed. If it is -1, the number of columns will be chosen automatically to fill the available area.

Returns:

  • (Integer)

    columns

#columns=(columns) ⇒ Integer

The columns property contains the number of the columns in which the items should be displayed. If it is -1, the number of columns will be chosen automatically to fill the available area.

Parameters:

  • columns (Integer)

Returns:

  • (Integer)

    columns

  • (Integer)

    columns

#create_drag_icon(path) ⇒ Gdk::Paintable

Creates a GdkPaintable representation of the item at path. This image is used for a drag icon.

Parameters:

  • path (Gtk::TreePath)

    a GtkTreePath in icon_view

Returns:

  • (Gdk::Paintable)

    a newly-allocated GdkPaintable of the drag icon.

#enable_model_drag_dest(formats, actions) ⇒ nil

Turns icon_view into a drop destination for automatic DND. Calling this method sets GtkIconView:reorderable to false.

Parameters:

  • formats (Gdk::ContentFormats)

    the formats that the drag will support

  • actions (Gdk::DragAction)

    the bitmask of possible actions for a drag to this widget

Returns:

  • (nil)

#enable_model_drag_source(start_button_mask, formats, actions) ⇒ nil

Turns icon_view into a drag source for automatic DND. Calling this method sets GtkIconView:reorderable to false.

Parameters:

  • start_button_mask (Gdk::ModifierType)

    Mask of allowed buttons to start drag

  • formats (Gdk::ContentFormats)

    the formats that the drag will support

  • actions (Gdk::DragAction)

    the bitmask of possible actions for a drag from this widget

Returns:

  • (nil)

#get_cell_rect(path, cell, rect) ⇒ Boolean

Fills the bounding rectangle in widget coordinates for the cell specified by path and cell. If cell is nil the main cell area is used.

This function is only valid if icon_view is realized.

Parameters:

  • path (Gtk::TreePath)

    a GtkTreePath

  • cell (Gtk::CellRenderer)

    a GtkCellRenderer

  • rect (Gdk::Rectangle)

    rectangle to fill with cell rect

Returns:

  • (Boolean)

    false if there is no such item, true otherwise

#get_cursor(path, cell) ⇒ Boolean

Fills in path and cell with the current cursor path and cell. If the cursor isn’t currently set, then *path will be nil. If no cell currently has focus, then *cell will be nil.

The returned GtkTreePath must be freed with gtk_tree_path_free().

Parameters:

  • path (Gtk::TreePath)

    Return location for the current cursor path

  • cell (Gtk::CellRenderer)

    Return location the current focus cell

Returns:

  • (Boolean)

    true if the cursor is set.

#get_dest_item_at_pos(drag_x, drag_y, path, pos) ⇒ Boolean

Determines the destination item for a given position.

Parameters:

  • drag_x (Integer)

    the position to determine the destination item for

  • drag_y (Integer)

    the position to determine the destination item for

  • path (Gtk::TreePath)

    Return location for the path of the item

  • pos (Gtk::IconViewDropPosition)

    Return location for the drop position

Returns:

  • (Boolean)

    whether there is an item at the given position.

#get_drag_dest_item(path, pos) ⇒ nil

Gets information about the item that is highlighted for feedback.

Parameters:

  • path (Gtk::TreePath)

    Return location for the path of the highlighted item

  • pos (Gtk::IconViewDropPosition)

    Return location for the drop position

Returns:

  • (nil)

#get_item_at_pos(x, y, path, cell) ⇒ Boolean

Gets the path and cell for the icon at the given position.

Parameters:

  • x (Integer)

    The x position to be identified

  • y (Integer)

    The y position to be identified

  • path (Gtk::TreePath)

    Return location for the path

  • cell (Gtk::CellRenderer)

    Return location for the renderer responsible for the cell at (x, y)

Returns:

  • (Boolean)

    true if an item exists at the specified position

#get_item_column(path) ⇒ Integer

Gets the column in which the item path is currently displayed. Column numbers start at 0.

Parameters:

  • path (Gtk::TreePath)

    the GtkTreePath of the item

Returns:

  • (Integer)

    The column in which the item is displayed

#get_item_row(path) ⇒ Integer

Gets the row in which the item path is currently displayed. Row numbers start at 0.

Parameters:

  • path (Gtk::TreePath)

    the GtkTreePath of the item

Returns:

  • (Integer)

    The row in which the item is displayed

#get_path_at_pos(x, y) ⇒ Gtk::TreePath

Gets the path for the icon at the given position. to the icon or nil if no icon exists at that position.

Parameters:

  • x (Integer)

    The x position to be identified

  • y (Integer)

    The y position to be identified

Returns:

  • (Gtk::TreePath)

    The GtkTreePath corresponding

#get_tooltip_context(x, y, keyboard_tip, model, path, iter) ⇒ Boolean

This function is supposed to be used in a GtkWidget::query-tooltip signal handler for GtkIconView. The x, y and keyboard_tip values which are received in the signal handler, should be passed to this function without modification.

The return value indicates whether there is an icon view item at the given coordinates (true) or not (false) for mouse tooltips. For keyboard tooltips the item returned will be the cursor item. When true, then any of model, path and iter which have been provided will be set to point to that row and the corresponding model.

Parameters:

  • x (Integer)

    the x coordinate (relative to widget coordinates)

  • y (Integer)

    the y coordinate (relative to widget coordinates)

  • keyboard_tip (Boolean)

    whether this is a keyboard tooltip or not

  • model (Gtk::TreeModel)

    a pointer to receive a GtkTreeModel

  • path (Gtk::TreePath)

    a pointer to receive a GtkTreePath

  • iter (Gtk::TreeIter)

    a pointer to receive a GtkTreeIter

Returns:

  • (Boolean)

    whether or not the given tooltip context points to an item

#get_visible_range(start_path, end_path) ⇒ Boolean

Sets start_path and end_path to be the first and last visible path. Note that there may be invisible paths in between.

Both paths should be freed with gtk_tree_path_free() after use.

Parameters:

  • start_path (Gtk::TreePath)

    Return location for start of region

  • end_path (Gtk::TreePath)

    Return location for end of region

Returns:

  • (Boolean)

    true, if valid paths were placed in start_path and end_path

#item_activated(path) ⇒ nil

Activates the item determined by path.

Parameters:

  • path (Gtk::TreePath)

    The GtkTreePath to be activated

Returns:

  • (nil)

#item_orientationGtk::Orientation

The item-orientation property specifies how the cells (i.e. the icon and the text) of the item are positioned relative to each other.

Returns:

#item_orientation=(item_orientation) ⇒ Gtk::Orientation

The item-orientation property specifies how the cells (i.e. the icon and the text) of the item are positioned relative to each other.

Parameters:

Returns:

#item_paddingInteger

The item-padding property specifies the padding around each of the icon view's item.

Returns:

  • (Integer)

    item-padding

#item_padding=(item_padding) ⇒ Integer

The item-padding property specifies the padding around each of the icon view's item.

Parameters:

  • item_padding (Integer)

Returns:

  • (Integer)

    item-padding

  • (Integer)

    item-padding

#item_widthInteger

The item-width property specifies the width to use for each item. If it is set to -1, the icon view will automatically determine a suitable item size.

Returns:

  • (Integer)

    item-width

#item_width=(item_width) ⇒ Integer

The item-width property specifies the width to use for each item. If it is set to -1, the icon view will automatically determine a suitable item size.

Parameters:

  • item_width (Integer)

Returns:

  • (Integer)

    item-width

  • (Integer)

    item-width

#marginInteger

The margin property specifies the space which is inserted at the edges of the icon view.

Returns:

  • (Integer)

    margin

#margin=(margin) ⇒ Integer

The margin property specifies the space which is inserted at the edges of the icon view.

Parameters:

  • margin (Integer)

Returns:

  • (Integer)

    margin

  • (Integer)

    margin

#markup_columnInteger

The ::markup-column property contains the number of the model column containing markup information to be displayed. The markup column must be of type G_TYPE_STRING. If this property and the :text-column property are both set to column numbers, it overrides the text column. If both are set to -1, no texts are displayed.

Returns:

  • (Integer)

    markup-column

#markup_column=(markup_column) ⇒ Integer

The ::markup-column property contains the number of the model column containing markup information to be displayed. The markup column must be of type G_TYPE_STRING. If this property and the :text-column property are both set to column numbers, it overrides the text column. If both are set to -1, no texts are displayed.

Parameters:

  • markup_column (Integer)

Returns:

  • (Integer)

    markup-column

  • (Integer)

    markup-column

#modelGtk::TreeModel

Returns model.

Returns:

#model=(model) ⇒ Gtk::TreeModel

Parameters:

Returns:

#path_is_selected(path) ⇒ Boolean

Returns true if the icon pointed to by path is currently selected. If path does not point to a valid location, false is returned.

Parameters:

  • path (Gtk::TreePath)

    A GtkTreePath to check selection on.

Returns:

  • (Boolean)

    true if path is selected.

#pixbuf_columnInteger

The ::pixbuf-column property contains the number of the model column containing the pixbufs which are displayed. The pixbuf column must be of type GDK_TYPE_PIXBUF. Setting this property to -1 turns off the display of pixbufs.

Returns:

  • (Integer)

    pixbuf-column

#pixbuf_column=(pixbuf_column) ⇒ Integer

The ::pixbuf-column property contains the number of the model column containing the pixbufs which are displayed. The pixbuf column must be of type GDK_TYPE_PIXBUF. Setting this property to -1 turns off the display of pixbufs.

Parameters:

  • pixbuf_column (Integer)

Returns:

  • (Integer)

    pixbuf-column

  • (Integer)

    pixbuf-column

#reorderableBoolean

Retrieves whether the user can reorder the list via drag-and-drop. See gtk_icon_view_set_reorderable().

Returns:

  • (Boolean)

    true if the list can be reordered.

#reorderable=(reorderable) ⇒ Boolean

The reorderable property specifies if the items can be reordered by DND.

Parameters:

  • reorderable (Boolean)

Returns:

  • (Boolean)

    reorderable

  • (Boolean)

    reorderable

#reorderable?Boolean

The reorderable property specifies if the items can be reordered by DND.

Returns:

  • (Boolean)

    reorderable

#row_spacingInteger

The row-spacing property specifies the space which is inserted between the rows of the icon view.

Returns:

  • (Integer)

    row-spacing

#row_spacing=(row_spacing) ⇒ Integer

The row-spacing property specifies the space which is inserted between the rows of the icon view.

Parameters:

  • row_spacing (Integer)

Returns:

  • (Integer)

    row-spacing

  • (Integer)

    row-spacing

#scroll_to_path(path, use_align, row_align, col_align) ⇒ nil

Moves the alignments of icon_view to the position specified by path. row_align determines where the row is placed, and col_align determines where column is placed. Both are expected to be between 0.0 and 1.0. 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means center.

If use_align is false, then the alignment arguments are ignored, and the tree does the minimum amount of work to scroll the item onto the screen. This means that the item will be scrolled to the edge closest to its current position. If the item is currently visible on the screen, nothing is done.

This function only works if the model is set, and path is a valid row on the model. If the model changes before the icon_view is realized, the centered path will be modified to reflect this change.

Parameters:

  • path (Gtk::TreePath)

    The path of the item to move to.

  • use_align (Boolean)

    whether to use alignment arguments, or false.

  • row_align (Gtk::gfloat)

    The vertical alignment of the item specified by path.

  • col_align (Gtk::gfloat)

    The horizontal alignment of the item specified by path.

Returns:

  • (nil)

#select_allnil

Selects all the icons. icon_view must has its selection mode set to %GTK_SELECTION_MULTIPLE.

Returns:

  • (nil)

#select_path(path) ⇒ nil

Selects the row at path.

Parameters:

  • path (Gtk::TreePath)

    The GtkTreePath to be selected.

Returns:

  • (nil)

#selected_foreach(func, data) ⇒ nil

Calls a function for each selected icon. Note that the model or selection cannot be modified from within this function.

Parameters:

  • func (Gtk::IconViewForeachFunc)

    The function to call for each selected icon.

  • data (GObject)

    User data to pass to the function.

Returns:

  • (nil)

#selected_itemsGLib::List<Gtk::TreePath>

Creates a list of paths of all selected items. Additionally, if you are planning on modifying the model after calling this function, you may want to convert the returned list into a list of GtkTreeRowReferences. To do this, you can use gtk_tree_row_reference_new().

To free the return value, use g_list_free_full:

GtkWidget *icon_view = gtk_icon_view_new ();
// Use icon_view

GList *list = gtk_icon_view_get_selected_items (GTK_ICON_VIEW (icon_view));

// use list

g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);

Returns:

  • (GLib::List<Gtk::TreePath>)

    A GList containing a GtkTreePath for each selected row.

#selection_modeGtk::SelectionMode

The ::selection-mode property specifies the selection mode of icon view. If the mode is %GTK_SELECTION_MULTIPLE, rubberband selection is enabled, for the other modes, only keyboard selection is possible.

Returns:

#selection_mode=(selection_mode) ⇒ Gtk::SelectionMode

The ::selection-mode property specifies the selection mode of icon view. If the mode is %GTK_SELECTION_MULTIPLE, rubberband selection is enabled, for the other modes, only keyboard selection is possible.

Parameters:

Returns:

#set_cursor(path, cell, start_editing) ⇒ nil

Sets the current keyboard focus to be at path, and selects it. This is useful when you want to focus the user’s attention on a particular item. If cell is not nil, then focus is given to the cell specified by it. Additionally, if start_editing is true, then editing should be started in the specified cell.

This function is often followed by gtk_widget_grab_focus (icon_view) in order to give keyboard focus to the widget. Please note that editing can only happen when the widget is realized.

Parameters:

  • path (Gtk::TreePath)

    A GtkTreePath

  • cell (Gtk::CellRenderer)

    One of the cell renderers of icon_view

  • start_editing (Boolean)

    true if the specified cell should start being edited.

Returns:

  • (nil)

#set_drag_dest_item(path, pos) ⇒ nil

Sets the item that is highlighted for feedback.

Parameters:

  • path (Gtk::TreePath)

    The path of the item to highlight

  • pos (Gtk::IconViewDropPosition)

    Specifies where to drop, relative to the item

Returns:

  • (nil)

#set_tooltip_cell(tooltip, path, cell) ⇒ nil

Sets the tip area of tooltip to the area which cell occupies in the item pointed to by path. See also gtk_tooltip_set_tip_area().

See also gtk_icon_view_set_tooltip_column() for a simpler alternative.

Parameters:

Returns:

  • (nil)

#set_tooltip_item(tooltip, path) ⇒ nil

Sets the tip area of tooltip to be the area covered by the item at path. See also gtk_icon_view_set_tooltip_column() for a simpler alternative. See also gtk_tooltip_set_tip_area().

Parameters:

  • tooltip (Gtk::Tooltip)

    a GtkTooltip

  • path (Gtk::TreePath)

    a GtkTreePath

Returns:

  • (nil)

#spacingInteger

The spacing property specifies the space which is inserted between the cells (i.e. the icon and the text) of an item.

Returns:

  • (Integer)

    spacing

#spacing=(spacing) ⇒ Integer

The spacing property specifies the space which is inserted between the cells (i.e. the icon and the text) of an item.

Parameters:

  • spacing (Integer)

Returns:

  • (Integer)

    spacing

  • (Integer)

    spacing

#text_columnInteger

The ::text-column property contains the number of the model column containing the texts which are displayed. The text column must be of type G_TYPE_STRING. If this property and the :markup-column property are both set to -1, no texts are displayed.

Returns:

  • (Integer)

    text-column

#text_column=(text_column) ⇒ Integer

The ::text-column property contains the number of the model column containing the texts which are displayed. The text column must be of type G_TYPE_STRING. If this property and the :markup-column property are both set to -1, no texts are displayed.

Parameters:

  • text_column (Integer)

Returns:

  • (Integer)

    text-column

  • (Integer)

    text-column

#tooltip_columnInteger

Returns tooltip-column.

Returns:

  • (Integer)

    tooltip-column

#tooltip_column=(tooltip_column) ⇒ Integer

Parameters:

  • tooltip_column (Integer)

Returns:

  • (Integer)

    tooltip-column

  • (Integer)

    tooltip-column

#unselect_allnil

Unselects all the icons.

Returns:

  • (nil)

#unselect_path(path) ⇒ nil

Unselects the row at path.

Parameters:

  • path (Gtk::TreePath)

    The GtkTreePath to be unselected.

Returns:

  • (nil)

#unset_model_drag_destnil

Undoes the effect of gtk_icon_view_enable_model_drag_dest(). Calling this method sets GtkIconView:reorderable to false.

Returns:

  • (nil)

#unset_model_drag_sourcenil

Undoes the effect of gtk_icon_view_enable_model_drag_source(). Calling this method sets GtkIconView:reorderable to false.

Returns:

  • (nil)