Class: Gtk::IconView
- Extended by:
- GLib::Deprecatable
- Defined in:
- lib/gtk4/icon-view.rb,
lib/gtk4/deprecated.rb
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
-
#activate_on_single_click ⇒ Boolean
Gets the setting set by gtk_icon_view_set_activate_on_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.
-
#activate_on_single_click? ⇒ Boolean
The activate-on-single-click property specifies whether the "item-activated" signal will be emitted after a single click.
-
#cell_area ⇒ Gtk::CellArea
The
GtkCellAreaused to layout cell renderers for this view. -
#cell_area=(cell_area) ⇒ Gtk::CellArea
The
GtkCellAreaused to layout cell renderers for this view. -
#column_spacing ⇒ Integer
The column-spacing property specifies the space which is inserted between the columns of the icon view.
-
#column_spacing=(column_spacing) ⇒ Integer
The column-spacing property specifies the space which is inserted between the columns of the icon view.
-
#columns ⇒ Integer
The columns property contains the number of the columns in which the items should be displayed.
-
#columns=(columns) ⇒ Integer
The columns property contains the number of the columns in which the items should be displayed.
-
#create_drag_icon(path) ⇒ Gdk::Paintable
Creates a
GdkPaintablerepresentation of the item at path. -
#enable_model_drag_dest(formats, actions) ⇒ nil
Turns icon_view into a drop destination for automatic DND.
-
#enable_model_drag_source(start_button_mask, formats, actions) ⇒ nil
Turns icon_view into a drag source for automatic DND.
-
#get_cell_rect(path, cell = nil) ⇒ Boolean
Fills the bounding rectangle in widget coordinates for the cell specified by path and cell.
-
#get_cell_rect_raw ⇒ Boolean
Fills the bounding rectangle in widget coordinates for the cell specified by path and cell.
-
#get_cursor(path, cell) ⇒ Boolean
Fills in path and cell with the current cursor path and cell.
-
#get_dest_item_at_pos(drag_x, drag_y, path, pos) ⇒ Boolean
Determines the destination item for a given position.
-
#get_drag_dest_item(path, pos) ⇒ nil
Gets information about the item that is highlighted for feedback.
-
#get_item_at_pos(x, y, path, cell) ⇒ Boolean
Gets the path and cell for the icon at the given position.
-
#get_item_column(path) ⇒ Integer
Gets the column in which the item path is currently displayed.
-
#get_item_row(path) ⇒ Integer
Gets the row in which the item path is currently displayed.
-
#get_path_at_pos(x, y) ⇒ Gtk::TreePath
Gets the path for the icon at the given position.
-
#get_tooltip_context(x, y, keyboard_tip, model, path, iter) ⇒ Boolean
This function is supposed to be used in a
GtkWidget::query-tooltipsignal handler forGtkIconView. -
#get_visible_range(start_path, end_path) ⇒ Boolean
Sets start_path and end_path to be the first and last visible path.
-
#initialize(options = {}) ⇒ Gtk::Widget
constructor
Creates a new
GtkIconViewwidget with the model model. -
#initialize_raw ⇒ Gtk::Widget
Creates a new
GtkIconViewwidget with the model model. -
#item_activated(path) ⇒ nil
Activates the item determined by path.
-
#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.
-
#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.
-
#item_padding ⇒ Integer
The item-padding property specifies the padding around each of the icon view's item.
-
#item_padding=(item_padding) ⇒ Integer
The item-padding property specifies the padding around each of the icon view's item.
-
#item_width ⇒ Integer
The item-width property specifies the width to use for each item.
-
#item_width=(item_width) ⇒ Integer
The item-width property specifies the width to use for each item.
-
#margin ⇒ Integer
The margin property specifies the space which is inserted at the edges of the icon view.
-
#margin=(margin) ⇒ Integer
The margin property specifies the space which is inserted at the edges of the icon view.
-
#markup_column ⇒ Integer
The ::markup-column property contains the number of the model column containing markup information to be displayed.
-
#markup_column=(markup_column) ⇒ Integer
The ::markup-column property contains the number of the model column containing markup information to be displayed.
-
#model ⇒ Gtk::TreeModel
Model.
- #model=(model) ⇒ Gtk::TreeModel
-
#path_is_selected(path) ⇒ Boolean
Returns true if the icon pointed to by path is currently selected.
-
#pixbuf_column ⇒ Integer
The ::pixbuf-column property contains the number of the model column containing the pixbufs which are displayed.
-
#pixbuf_column=(pixbuf_column) ⇒ Integer
The ::pixbuf-column property contains the number of the model column containing the pixbufs which are displayed.
-
#reorderable ⇒ Boolean
Retrieves whether the user can reorder the list via drag-and-drop.
-
#reorderable=(reorderable) ⇒ Boolean
The reorderable property specifies if the items can be reordered by DND.
-
#reorderable? ⇒ Boolean
The reorderable property specifies if the items can be reordered by DND.
-
#row_spacing ⇒ Integer
The row-spacing property specifies the space which is inserted between the rows of the icon view.
-
#row_spacing=(row_spacing) ⇒ Integer
The row-spacing property specifies the space which is inserted between the rows of the icon view.
-
#scroll_to_path(path, use_align, row_align, col_align) ⇒ nil
Moves the alignments of icon_view to the position specified by path.
-
#select_all ⇒ nil
Selects all the icons.
-
#select_path(path) ⇒ nil
Selects the row at path.
-
#selected_foreach(func, data) ⇒ nil
Calls a function for each selected icon.
-
#selected_items ⇒ GLib::List<Gtk::TreePath>
Creates a list of paths of all selected items.
-
#selection_mode ⇒ Gtk::SelectionMode
The ::selection-mode property specifies the selection mode of icon view.
-
#selection_mode=(selection_mode) ⇒ Gtk::SelectionMode
The ::selection-mode property specifies the selection mode of icon view.
-
#set_cursor(path, cell, start_editing) ⇒ nil
Sets the current keyboard focus to be at path, and selects it.
-
#set_drag_dest_item(path, pos) ⇒ nil
Sets the item that is highlighted for feedback.
-
#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.
-
#set_tooltip_item(tooltip, path) ⇒ nil
Sets the tip area of tooltip to be the area covered by the item at path.
-
#spacing ⇒ Integer
The spacing property specifies the space which is inserted between the cells (i.e. the icon and the text) of an item.
-
#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.
-
#text_column ⇒ Integer
The ::text-column property contains the number of the model column containing the texts which are displayed.
-
#text_column=(text_column) ⇒ Integer
The ::text-column property contains the number of the model column containing the texts which are displayed.
-
#tooltip_column ⇒ Integer
Tooltip-column.
- #tooltip_column=(tooltip_column) ⇒ Integer
-
#unselect_all ⇒ nil
Unselects all the icons.
-
#unselect_path(path) ⇒ nil
Unselects the row at path.
-
#unset_model_drag_dest ⇒ nil
Undoes the effect of gtk_icon_view_enable_model_drag_dest().
-
#unset_model_drag_source ⇒ nil
Undoes the effect of gtk_icon_view_enable_model_drag_source().
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
#initialize(options = {}) ⇒ Gtk::Widget
Creates a new GtkIconView widget with the model model.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gtk4/icon-view.rb', line 20 def initialize(={}) model = [:model] area = [:area] if model initialize_new_with_model(model) elsif area initialize_new_with_area(area) else initialize_new end end |
Instance Method Details
#activate_on_single_click ⇒ Boolean
Gets the setting set by gtk_icon_view_set_activate_on_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.
#activate_on_single_click? ⇒ Boolean
The activate-on-single-click property specifies whether the "item-activated" signal will be emitted after a single click.
#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.
#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.
#column_spacing ⇒ Integer
The column-spacing property specifies the space which is inserted between the columns of the icon view.
#column_spacing=(column_spacing) ⇒ Integer
The column-spacing property specifies the space which is inserted between the columns of the icon view.
#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.
#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.
#create_drag_icon(path) ⇒ Gdk::Paintable
Creates a GdkPaintable representation of the item at path.
This image is used for a 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.
#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.
#get_cell_rect(path, cell = nil) ⇒ 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.
35 36 37 38 39 40 41 42 |
# File 'lib/gtk4/icon-view.rb', line 35 def get_cell_rect(path, cell=nil) exist, rect = get_cell_rect_raw(path, cell) if exist rect else nil end end |
#get_cell_rect_raw ⇒ 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.
|
|
# File 'lib/gtk4/icon-view.rb', line 34
|
#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().
#get_dest_item_at_pos(drag_x, drag_y, path, pos) ⇒ Boolean
Determines the destination item for a given position.
#get_drag_dest_item(path, pos) ⇒ nil
Gets information about the item that is highlighted for feedback.
#get_item_at_pos(x, y, path, cell) ⇒ Boolean
Gets the path and cell for the icon at the given position.
#get_item_column(path) ⇒ Integer
Gets the column in which the item path is currently displayed. Column numbers start at 0.
#get_item_row(path) ⇒ Integer
Gets the row in which the item path is currently displayed. Row numbers start at 0.
#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.
#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.
#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.
#initialize_raw ⇒ Gtk::Widget
Creates a new GtkIconView widget with the model model.
|
|
# File 'lib/gtk4/icon-view.rb', line 19
|
#item_activated(path) ⇒ nil
Activates the item determined by path.
#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.
#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.
#item_padding ⇒ Integer
The item-padding property specifies the padding around each of the icon view's item.
#item_padding=(item_padding) ⇒ Integer
The item-padding property specifies the padding around each of the icon view's item.
#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.
#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.
#margin ⇒ Integer
The margin property specifies the space which is inserted at the edges of the icon view.
#margin=(margin) ⇒ Integer
The margin property specifies the space which is inserted at the edges of the icon view.
#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.
#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.
#model ⇒ Gtk::TreeModel
Returns model.
#model=(model) ⇒ Gtk::TreeModel
#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.
#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.
#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.
#reorderable ⇒ Boolean
Retrieves whether the user can reorder the list via drag-and-drop. See gtk_icon_view_set_reorderable().
#reorderable=(reorderable) ⇒ Boolean
The reorderable property specifies if the items can be reordered by DND.
#reorderable? ⇒ Boolean
The reorderable property specifies if the items can be reordered by DND.
#row_spacing ⇒ Integer
The row-spacing property specifies the space which is inserted between the rows of the icon view.
#row_spacing=(row_spacing) ⇒ Integer
The row-spacing property specifies the space which is inserted between the rows of the icon view.
#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.
#select_all ⇒ nil
Selects all the icons. icon_view must has its selection mode set to %GTK_SELECTION_MULTIPLE.
#select_path(path) ⇒ nil
Selects the row at path.
#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.
#selected_items ⇒ GLib::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);
#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.
#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.
#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.
#set_drag_dest_item(path, pos) ⇒ nil
Sets the item that is highlighted for feedback.
#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.
#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().
#spacing ⇒ Integer
The spacing property specifies the space which is inserted between the cells (i.e. the icon and the text) of an item.
#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.
#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.
#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.
#tooltip_column ⇒ Integer
Returns tooltip-column.
#tooltip_column=(tooltip_column) ⇒ Integer
#unselect_all ⇒ nil
Unselects all the icons.
#unselect_path(path) ⇒ nil
Unselects the row at path.
#unset_model_drag_dest ⇒ nil
Undoes the effect of gtk_icon_view_enable_model_drag_dest(). Calling this
method sets GtkIconView:reorderable to false.
#unset_model_drag_source ⇒ nil
Undoes the effect of gtk_icon_view_enable_model_drag_source(). Calling this
method sets GtkIconView:reorderable to false.