IconView
Object Hierarchy:
Description:
[ CCode ( type_id = "gtk_icon_view_get_type ()" ) ]
public class IconView : Container, Implementor, Buildable, CellLayout, Scrollable
public class IconView : Container, Implementor, Buildable, CellLayout, Scrollable
IconView provides an alternative view on a TreeModel.
It displays the model as a grid of icons with labels. Like TreeView, it allows to select one or multiple items (depending on the selection mode, see set_selection_mode). In addition to selection with the arrow keys, IconView 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), IconView will only display the first level of the tree and ignore the tree’s branches.
CSS nodes
iconview.view
╰── [rubberband]
conView has a single CSS node with name iconview and style
class .view. For rubberband selection, a subnode with name rubberband is used.
Example: IconView:
public class Application : Gtk.Window {
public Application () {
// Prepare Gtk.Window:
this.title = "My Gtk.IconView";
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);
this.set_default_size (400, 400);
// The Model:
Gtk.ListStore model = new Gtk.ListStore (2, typeof (Gdk.Pixbuf), typeof (string));
Gtk.TreeIter iter;
// The IconView:
Gtk.IconView view = new Gtk.IconView.with_model (model);
view.set_pixbuf_column (0);
view.set_text_column (1);
this.add (view);
// Data:
Gtk.IconTheme icon_theme = Gtk.IconTheme.get_default ();
try {
model.append (out iter);
Gdk.Pixbuf pixbuf = icon_theme.load_icon ("help-about", 20, 0);
model.set (iter, 0, pixbuf, 1, "Dialog");
model.append (out iter);
pixbuf = icon_theme.load_icon ("document-print", 20, 0);
model.set (iter, 0, pixbuf, 1, "Print");
model.append (out iter);
pixbuf = icon_theme.load_icon ("help-about", 20, 0);
model.set (iter, 0, pixbuf, 1, "Help");
} catch (Error e) {
// TODO
assert_not_reached ();
}
view.selection_changed.connect (() => {
List<Gtk.TreePath> paths = view.get_selected_items ();
Value title;
Value icon;
foreach (Gtk.TreePath path in paths) {
bool tmp = model.get_iter (out iter, path);
assert (tmp == true);
model.get_value (iter, 0, out icon);
model.get_value (iter, 1, out title);
print ("%s: %p\n", (string) title, ((Gdk.Pixbuf) icon));
}
});
}
public static int main (string[] args) {
Gtk.init (ref args);
Application app = new Application ();
app.show_all ();
Gtk.main ();
return 0;
}
}
valac --pkg gtk+-3.0 Gtk.IconView.vala
Namespace: Gtk
Package: gtk+-3.0
Content:
Properties:
- public bool activate_on_single_click { get; set; }
The activate-on-single-click property specifies whether the "item-activated" signal will be emitted after a single click.
- public CellArea cell_area { owned get; construct; }
The CellArea used to layout cell renderers for this view.
- public int column_spacing { get; set; }
The column-spacing property specifies the space which is inserted between the columns of the icon view.
- public int columns { get; set; }
The columns property contains the number of the columns in which the items should be displayed.
- public Orientation item_orientation { get; set; }
The item-orientation property specifies how the cells (i.
- public int item_padding { get; set; }
The item-padding property specifies the padding around each of the icon view's item.
- public int item_width { get; set; }
The item-width property specifies the width to use for each item.
- public int margin { get; set; }
- public int markup_column { get; set; }
The
GtkIconView::markup-column
property contains the number of the model column containing markup information to be displayed. - public TreeModel model { get; set; }
- public int pixbuf_column { get; set; }
The
GtkIconView::pixbuf-column
property contains the number of the model column containing the pixbufs which are displayed. - public bool reorderable { get; set; }
The reorderable property specifies if the items can be reordered by DND.
- public int row_spacing { get; set; }
The row-spacing property specifies the space which is inserted between the rows of the icon view.
- public SelectionMode selection_mode { get; set; }
The
GtkIconView::selection-mode
property specifies the selection mode of icon view. - public int spacing { get; set; }
The spacing property specifies the space which is inserted between the cells (i.
- public int text_column { get; set; }
The
GtkIconView::text-column
property contains the number of the model column containing the texts which are displayed. - public int tooltip_column { get; set; }
Creation methods:
- public IconView ()
Creates a new IconView widget
- public IconView.with_area (CellArea area)
Creates a new IconView widget using the specified
area
to layout cells inside the icons. - public IconView.with_model (TreeModel model)
Creates a new IconView widget with the model
model
.
Methods:
- public void convert_widget_to_bin_window_coords (int wx, int wy, out int bx, out int by)
Converts widget coordinates to coordinates for the bin_window, as expected by e.
- public Surface create_drag_icon (TreePath path)
Creates a XlibSurface representation of the item at
path
. - public void enable_model_drag_dest (TargetEntry[] targets, DragAction actions)
Turns this into a drop destination for automatic DND.
- public void enable_model_drag_source (ModifierType start_button_mask, TargetEntry[] targets, DragAction actions)
Turns this into a drag source for automatic DND.
- public bool get_activate_on_single_click ()
Gets the setting set by set_activate_on_single_click.
- public bool get_cell_rect (TreePath path, CellRenderer? cell, out Rectangle rect)
Fills the bounding rectangle in widget coordinates for the cell specified by
path
andcell
. - public int get_column_spacing ()
Returns the value of the
GtkIconView::column-spacing
property. - public int get_columns ()
Returns the value of the
GtkIconView::columns
s property. - public bool get_cursor (out TreePath path, out unowned CellRenderer cell)
Fills in
path
andcell
with the current cursor path and cell. - public bool get_dest_item_at_pos (int drag_x, int drag_y, out TreePath path, out IconViewDropPosition pos)
Determines the destination item for a given position.
- public void get_drag_dest_item (out TreePath path, out IconViewDropPosition pos)
Gets information about the item that is highlighted for feedback.
- public bool get_item_at_pos (int x, int y, out TreePath path, out unowned CellRenderer cell)
Finds the path at the point (
x
,y
), relative to bin_window coordinates. - public int get_item_column (TreePath path)
Gets the column in which the item
path
is currently displayed. - public Orientation get_item_orientation ()
Returns the value of the
GtkIconView::item-orientation
property which determines whether the labels are drawn beside the icons instead of below. - public int get_item_padding ()
Returns the value of the
GtkIconView::item-padding
property. - public int get_item_row (TreePath path)
Gets the row in which the item
path
is currently displayed. - public int get_item_width ()
Returns the value of the
GtkIconView::item-width
property. - public int get_margin ()
Returns the value of the
GtkIconView::margin
property. - public int get_markup_column ()
Returns the column with markup text for this .
- public unowned TreeModel? get_model ()
Returns the model the IconView is based on.
- public TreePath? get_path_at_pos (int x, int y)
Finds the path at the point (
x
,y
), relative to bin_window coordinates. - public int get_pixbuf_column ()
Returns the column with pixbufs for this.
- public bool get_reorderable ()
Retrieves whether the user can reorder the list via drag-and-drop.
- public int get_row_spacing ()
Returns the value of the
GtkIconView::row-spacing
property. - public List<TreePath> get_selected_items ()
Creates a list of paths of all selected items.
- public SelectionMode get_selection_mode ()
Gets the selection mode of the this.
- public int get_spacing ()
Returns the value of the
GtkIconView::spacing
property. - public int get_text_column ()
Returns the column with text for this.
- public int get_tooltip_column ()
Returns the column of this’s model which is being used for displaying tooltips on this’s rows.
- public bool get_tooltip_context (ref int x, ref int y, bool keyboard_tip, out unowned TreeModel model, out TreePath path, out TreeIter iter)
This function is supposed to be used in a query_tooltip signal handler for IconView.
- public bool get_visible_range (out TreePath start_path, out TreePath end_path)
Sets
start_path
andend_path
to be the first and last visible path. - public bool path_is_selected (TreePath path)
Returns true if the icon pointed to by
path
is currently selected. - public void scroll_to_path (TreePath path, bool use_align, float row_align, float col_align)
Moves the alignments of this to the position specified by
path
. - public void select_path (TreePath path)
Selects the row at
path
. - public void selected_foreach (IconViewForeachFunc func)
Calls a function for each selected icon.
- public void set_activate_on_single_click (bool single)
Causes the item_activated signal to be emitted on a single click instead of a double click.
- public void set_column_spacing (int column_spacing)
Sets the
GtkIconView::column-spacing
property which specifies the space which is inserted between the columns of the icon view. - public void set_columns (int columns)
Sets the
GtkIconView::columns
s property which determines in how many columns the icons are arranged. - public void set_cursor (TreePath path, CellRenderer? cell, bool start_editing)
Sets the current keyboard focus to be at
path
, and selects it. - public void set_drag_dest_item (TreePath? path, IconViewDropPosition pos)
Sets the item that is highlighted for feedback.
- public void set_item_orientation (Orientation orientation)
Sets the
GtkIconView::item-orientation
property which determines whether the labels are drawn beside the icons instead of below. - public void set_item_padding (int item_padding)
Sets the item_padding property which specifies the padding around each of the icon view’s items.
- public void set_item_width (int item_width)
Sets the
GtkIconView::item-width
property which specifies the width to use for each item. - public void set_margin (int margin)
Sets the
GtkIconView::margin
property which specifies the space which is inserted at the top, bottom, left and right of the icon view. - public void set_markup_column (int column)
Sets the column with markup information for this to be
column
. - public void set_model (TreeModel? model)
Sets the model for a IconView.
- public void set_pixbuf_column (int column)
Sets the column with pixbufs for this to be
column
. - public void set_reorderable (bool reorderable)
This function is a convenience function to allow you to reorder models that support the TreeDragSource and the TreeDragDest.
- public void set_row_spacing (int row_spacing)
Sets the
GtkIconView::row-spacing
property which specifies the space which is inserted between the rows of the icon view. - public void set_selection_mode (SelectionMode mode)
Sets the selection mode of the this.
- public void set_spacing (int spacing)
Sets the
GtkIconView::spacing
property which specifies the space which is inserted between the cells (i. - public void set_text_column (int column)
Sets the column with text for this to be
column
. - public void set_tooltip_cell (Tooltip tooltip, TreePath path, CellRenderer? cell)
Sets the tip area of
tooltip
to the area whichcell
occupies in the item pointed to bypath
. - public void set_tooltip_column (int column)
If you only plan to have simple (text-only) tooltips on full items, you can use this function to have IconView handle these automatically for you.
- public void set_tooltip_item (Tooltip tooltip, TreePath path)
Sets the tip area of
tooltip
to be the area covered by the item atpath
. - public void unselect_path (TreePath path)
Unselects the row at
path
. - public void unset_model_drag_dest ()
Undoes the effect of enable_model_drag_dest.
- public void unset_model_drag_source ()
Undoes the effect of enable_model_drag_source.
Signals:
- public virtual signal bool activate_cursor_item ()
A keybinding signal which gets emitted when the user activates the currently focused item.
- public virtual signal void item_activated (TreePath path)
The item_activated signal is emitted when the method item_activated is called, when the user double clicks an item with the "activate-on-single-click" property set to false, or when the user single clicks an item when the "activate-on-single-click" property set to true.
- public virtual signal bool move_cursor (MovementStep step, int count)
The move_cursor signal is a keybinding signal which gets emitted when the user initiates a cursor movement.
- public virtual signal void select_all ()
A keybinding signal which gets emitted when the user selects all items.
- public virtual signal void select_cursor_item ()
A keybinding signal which gets emitted when the user selects the item that is currently focused.
- public virtual signal void selection_changed ()
The selection_changed signal is emitted when the selection (i.
- public virtual signal void toggle_cursor_item ()
A keybinding signal which gets emitted when the user toggles whether the currently focused item is selected or not.
- public virtual signal void unselect_all ()
A keybinding signal which gets emitted when the user unselects all items.
Inherited Members:
All known members inherited from class Gtk.Container
All known members inherited from class Gtk.Widget
- accel_closures_changed
- activate
- add_accelerator
- add_device_events
- add_events
- add_mnemonic_label
- add_tick_callback
- adjust_baseline_allocation
- adjust_baseline_request
- adjust_size_allocation
- adjust_size_request
- app_paintable
- bind_template_callback_full
- bind_template_child_full
- button_press_event
- button_release_event
- can_activate_accel
- can_default
- can_focus
- child_focus
- child_notify
- class_path
- composite_child
- composited_changed
- compute_expand
- compute_expand_internal
- configure_event
- create_pango_context
- create_pango_layout
- damage_event
- delete_event
- destroy
- destroy_event
- destroyed
- device_is_shadowed
- direction_changed
- dispatch_child_properties_changed
- double_buffered
- drag_begin
- drag_data_delete
- drag_data_get
- drag_data_received
- drag_drop
- drag_end
- drag_failed
- drag_leave
- drag_motion
- draw
- draw_to_cairo_context
- ensure_style
- enter_notify_event
- error_bell
- event
- event_after
- events
- expand
- find_style_property
- focus
- focus_in_event
- focus_on_click
- focus_out_event
- freeze_child_notify
- get_accessible
- get_action_group
- get_allocated_baseline
- get_allocated_height
- get_allocated_size
- get_allocated_width
- get_allocation
- get_ancestor
- get_app_paintable
- get_can_default
- get_can_focus
- get_child_requisition
- get_child_visible
- get_clip
- get_clipboard
- get_composite_name
- get_css_name
- get_default_direction
- get_default_style
- get_device_enabled
- get_device_events
- get_direction
- get_display
- get_double_buffered
- get_events
- get_focus_on_click
- get_font_map
- get_font_options
- get_frame_clock
- get_halign
- get_has_tooltip
- get_has_window
- get_hexpand
- get_hexpand_set
- get_mapped
- get_margin_bottom
- get_margin_end
- get_margin_left
- get_margin_right
- get_margin_start
- get_margin_top
- get_modifier_mask
- get_modifier_style
- get_no_show_all
- get_opacity
- get_pango_context
- get_parent
- get_parent_window
- get_path
- get_pointer
- get_preferred_height
- get_preferred_height_and_baseline_for_width
- get_preferred_height_for_width
- get_preferred_height_for_width_internal
- get_preferred_height_internal
- get_preferred_size
- get_preferred_width
- get_preferred_width_for_height
- get_preferred_width_for_height_internal
- get_preferred_width_internal
- get_realized
- get_receives_default
- get_request_mode
- get_requisition
- get_root_window
- get_scale_factor
- get_screen
- get_sensitive
- get_settings
- get_size_request
- get_state
- get_state_flags
- get_style
- get_style_context
- get_support_multidevice
- get_template_child
- get_tooltip_markup
- get_tooltip_text
- get_tooltip_window
- get_toplevel
- get_valign
- get_valign_with_baseline
- get_vexpand
- get_vexpand_set
- get_visible
- get_visual
- get_window
- grab_broken_event
- grab_default
- grab_focus
- grab_notify
- halign
- has_default
- has_focus
- has_grab
- has_rc_style
- has_screen
- has_tooltip
- has_visible_focus
- height_request
- hexpand
- hexpand_set
- hide
- hide_on_delete
- hierarchy_changed
- in_destruction
- init_template
- input_shape_combine_region
- insert_action_group
- install_style_property
- install_style_property_parser
- intersect
- is_ancestor
- is_composited
- is_drawable
- is_focus
- is_sensitive
- is_toplevel
- is_visible
- key_press_event
- key_release_event
- keynav_failed
- leave_notify_event
- list_accel_closures
- list_action_prefixes
- list_mnemonic_labels
- list_style_properties
- map
- map_event
- margin
- margin_bottom
- margin_end
- margin_left
- margin_right
- margin_start
- margin_top
- mnemonic_activate
- modify_base
- modify_bg
- modify_cursor
- modify_fg
- modify_font
- modify_style
- modify_text
- motion_notify_event
- move_focus
- name
- no_show_all
- opacity
- override_background_color
- override_color
- override_cursor
- override_font
- override_symbolic_color
- parent
- parent_set
- path
- pop_composite_child
- popup_menu
- property_notify_event
- proximity_in_event
- proximity_out_event
- push_composite_child
- query_tooltip
- queue_allocate
- queue_compute_expand
- queue_draw
- queue_draw_area
- queue_draw_region
- queue_resize
- queue_resize_no_redraw
- realize
- receives_default
- region_intersect
- register_window
- remove_accelerator
- remove_mnemonic_label
- remove_tick_callback
- render_icon
- render_icon_pixbuf
- reparent
- reset_rc_styles
- reset_style
- scale_factor
- screen_changed
- scroll_event
- selection_clear_event
- selection_get
- selection_notify_event
- selection_received
- selection_request_event
- send_expose
- send_focus_change
- sensitive
- set_accel_path
- set_accessible_role
- set_accessible_type
- set_allocation
- set_app_paintable
- set_can_default
- set_can_focus
- set_child_visible
- set_clip
- set_composite_name
- set_connect_func
- set_css_name
- set_default_direction
- set_device_enabled
- set_device_events
- set_direction
- set_double_buffered
- set_events
- set_focus_on_click
- set_font_map
- set_font_options
- set_halign
- set_has_tooltip
- set_has_window
- set_hexpand
- set_hexpand_set
- set_mapped
- set_margin_bottom
- set_margin_end
- set_margin_left
- set_margin_right
- set_margin_start
- set_margin_top
- set_no_show_all
- set_opacity
- set_parent
- set_parent_window
- set_realized
- set_receives_default
- set_redraw_on_allocate
- set_sensitive
- set_size_request
- set_state
- set_state_flags
- set_style
- set_support_multidevice
- set_template
- set_template_from_resource
- set_tooltip_markup
- set_tooltip_text
- set_tooltip_window
- set_valign
- set_vexpand
- set_vexpand_set
- set_visible
- set_visual
- set_window
- shape_combine_region
- show
- show_all
- show_help
- show_now
- size_allocate
- size_allocate_with_baseline
- size_request
- state_changed
- state_flags_changed
- style
- style_attach
- style_get
- style_get_property
- style_get_valist
- style_set
- style_updated
- thaw_child_notify
- tooltip_markup
- tooltip_text
- touch_event
- translate_coordinates
- trigger_tooltip_query
- unmap
- unmap_event
- unparent
- unrealize
- unregister_window
- unset_state_flags
- valign
- vexpand
- vexpand_set
- visibility_notify_event
- visible
- width_request
- window_state_event
All known members inherited from class GLib.Object
All known members inherited from interface Atk.Implementor
All known members inherited from interface Gtk.Buildable
All known members inherited from interface Gtk.CellLayout
All known members inherited from interface Gtk.Scrollable