gtk-sharp[00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00 71 EB 6C 55 75 52 9C BF 72 44 F7 A6 EA 05 62 84 F9 EA E0 3B CF F2 CC 13 2C 9C 49 0A B3 09 EA B0 B5 6B CE 44 9D F5 03 D9 C0 A8 1E 52 05 85 CD BE 70 E2 FB 90 43 4B AC 04 FA 62 22 A8 00 98 B7 A1 A7 B3 AF 99 1A 41 23 24 BB 43 25 F6 B8 65 BB 64 EB F6 D1 C2 06 D5 73 2D DF BC 70 A7 38 9E E5 3E 0C 24 6E 32 79 74 1A D0 05 03 E4 98 42 E1 9B F3 7B 19 8B 40 21 26 CB 36 89 C2 EA 64 96 A4 7C B4]Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details.Gtk.ContainerGtk.CellLayoutGtk.ScrollableA widget which displays a list of icons in a grid provides an alternative view on a list model. It displays the model as a grid of icons with labels. Like , it allows to select one or multiple items (depending on the selection mode, see ). In addition to selection with the arrow keys, supports rubberband selection, which is controlled by dragging the pointer.
using System;
using System.IO;
using Gtk;
public class DemoIconView : Window
{
const int COL_PATH = 0;
const int COL_DISPLAY_NAME = 1;
const int COL_PIXBUF = 2;
const int COL_IS_DIRECTORY = 3;
DirectoryInfo parent = new DirectoryInfo ("/");
Gdk.Pixbuf dirIcon, fileIcon;
ListStore store;
ToolButton upButton;
static void Main ()
{
Application.Init ();
new DemoIconView ();
Application.Run ();
}
public DemoIconView () : base ("Gtk.IconView demo")
{
SetDefaultSize (650, 400);
DeleteEvent += new DeleteEventHandler (OnWinDelete);
VBox vbox = new VBox (false, 0);
Add (vbox);
Toolbar toolbar = new Toolbar ();
vbox.PackStart (toolbar, false, false, 0);
upButton = new ToolButton (Stock.GoUp);
upButton.IsImportant = true;
upButton.Sensitive = false;
toolbar.Insert (upButton, -1);
ToolButton homeButton = new ToolButton (Stock.Home);
homeButton.IsImportant = true;
toolbar.Insert (homeButton, -1);
fileIcon = GetIcon ("gnome-fs-regular");
dirIcon = GetIcon ("gnome-fs-directory");
ScrolledWindow sw = new ScrolledWindow ();
sw.ShadowType = ShadowType.EtchedIn;
sw.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
vbox.PackStart (sw, true, true, 0);
// Create the store and fill it with the contents of '/'
store = CreateStore ();
FillStore ();
IconView iconView = new IconView (store);
iconView.SelectionMode = SelectionMode.Multiple;
upButton.Clicked += OnUpClicked;
homeButton.Clicked += OnHomeClicked;
iconView.TextColumn = COL_DISPLAY_NAME;
iconView.PixbufColumn = COL_PIXBUF;
iconView.ItemActivated += new ItemActivatedHandler (OnItemActivated);
sw.Add (iconView);
iconView.GrabFocus ();
ShowAll ();
}
Gdk.Pixbuf GetIcon (string name)
{
return Gtk.IconTheme.Default.LoadIcon (name, 48, (IconLookupFlags) 0);
}
ListStore CreateStore ()
{
// path, name, pixbuf, is_dir
ListStore store = new ListStore (typeof (string), typeof (string), typeof (Gdk.Pixbuf), typeof (bool));
// Set sort column and function
store.DefaultSortFunc = SortFunc;
store.SetSortColumnId (COL_DISPLAY_NAME, SortType.Ascending);
return store;
}
void FillStore ()
{
// first clear the store
store.Clear ();
// Now go through the directory and extract all the file information
if (!parent.Exists)
return;
foreach (DirectoryInfo di in parent.GetDirectories ())
{
if (!di.Name.StartsWith ("."))
store.AppendValues (di.FullName, di.Name, dirIcon, true);
}
foreach (FileInfo file in parent.GetFiles ())
{
if (!file.Name.StartsWith ("."))
store.AppendValues (file.FullName, file.Name, fileIcon, false);
}
}
int SortFunc (TreeModel model, TreeIter a, TreeIter b)
{
// sorts folders before files
bool a_is_dir = (bool) model.GetValue (a, COL_IS_DIRECTORY);
bool b_is_dir = (bool) model.GetValue (b, COL_IS_DIRECTORY);
string a_name = (string) model.GetValue (a, COL_DISPLAY_NAME);
string b_name = (string) model.GetValue (b, COL_DISPLAY_NAME);
if (!a_is_dir && b_is_dir)
return 1;
else if (a_is_dir && !b_is_dir)
return -1;
else
return String.Compare (a_name, b_name);
}
void OnHomeClicked (object sender, EventArgs a)
{
parent = new DirectoryInfo (Environment.GetFolderPath (Environment.SpecialFolder.Personal));
FillStore ();
upButton.Sensitive = true;
}
void OnItemActivated (object sender, ItemActivatedArgs a)
{
TreeIter iter;
store.GetIter (out iter, a.Path);
string path = (string) store.GetValue (iter, COL_PATH);
bool isDir = (bool) store.GetValue (iter, COL_IS_DIRECTORY);
if (!isDir)
return;
// Replace parent with path and re-fill the model
parent = new DirectoryInfo (path);
FillStore ();
// Sensitize the up button
upButton.Sensitive = true;
}
void OnUpClicked (object sender, EventArgs a)
{
parent = parent.Parent;
FillStore ();
upButton.Sensitive = (parent.FullName == "/" ? false : true);
}
void OnWinDelete (object sender, DeleteEventArgs a)
{
Application.Quit ();
a.RetVal = true;
}
}
ConstructorDefault constructorConstructor
To be added.
To be added.To be added.Constructor
a Create a new IconView with a model.Constructor
a Internal constructorThis is not typically used by C# code.EventGLib.Signal("activate-cursor-item")Gtk.ActivateCursorItemHandlerTo be addedTo be addedMethodSystem.Void
a of the view.
an attribute name on .
the model column index to bind to .
Binds a model column to an Attribute of a Cell Renderer.EventGLib.Signal("select-all")System.EventHandlerEmitted when SelectAll () is called.EventGLib.Signal("unselect-all")System.EventHandlerEmitted when UnselectAll () is called.PropertyGtk.CellAreaTo be added.To be added.To be added.PropertyGLib.Property("cell-area")Gtk.CellAreaTo be added.To be added.To be added.PropertyGtk.CellRenderer[]To be added.To be added.To be added.MethodSystem.VoidClears attribute bindings and removes all renderers.MethodSystem.Void
a of the view.
Clears attribute bindings for a cell renderer.PropertyGLib.Property("columns")System.Int32The columns property contains the number of the columns in which the items should be displayed.a If it is -1, the number of columns will be chosen automatically to fill the available area.PropertyGLib.Property("column-spacing")System.Int32Space which is inserted between grid column.a Default value is 6.MethodSystem.Void
To be added.
To be added.
To be added.
To be added.
To be added.To be added.MethodCairo.Surface
To be added.
To be added.To be added.To be added.MethodSystem.Void
an array of items supported.
drop actions supported by the view.
Enables the view as a Drop destination.MethodSystem.Void
buttons allowed to start drag.
an array of items supported.
drag actions supported from the view.
Enables the view as a Drag source.MethodSystem.Boolean
The cursor path.
The currently focused cell.
Gets the path and cell of the current cursor location.if the cursor is set.The will be if the cursor is not currently set. The will be if no cell has focus.MethodSystem.Boolean
x coordinate of position.
y coordinate of position.
returns a for the item.
returns a .
Determines the destination item at a position. if there is an item at the position.MethodSystem.Void
returns a for the highlighted item, or .
returns the relative drop information for the highlighted item.
Gets Drag information for the currently highlighted item.MethodSystem.Boolean
x position in widget coordinates.
y position in widget coordinates.
returns a representing the item at the position.
returns a representing the cell at the position.
Obtains the item and cell at a given position. if there is an item at the position.Extends on by additionally returning a cell renderer at the specified position.MethodSystem.Int32
To be added.
To be added.To be added.To be added.MethodSystem.Int32
To be added.
To be added.To be added.To be added.MethodGtk.TreePath
a
a To be addeda To be addedMethodSystem.Boolean
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.To be added.To be added.MethodSystem.Boolean
The first visible item.
The last visible item.
Gets the visible range of items in the view. if the start and end paths were set.There may be invisible paths between the start and end paths.PropertyGLib.GTypeGType Property.a Returns the native value for .PropertyGLib.Property("hadjustment")Gtk.AdjustmentTo be added.To be added.To be added.PropertyGLib.Property("hscroll-policy")Gtk.ScrollablePolicyTo be added.To be added.To be added.EventGLib.Signal("item-activated")Gtk.ItemActivatedHandlerEmitted when an item is activated.PropertyGLib.Property("item-orientation")Gtk.OrientationTo be added.To be added.To be added.PropertyGLib.Property("item-padding")System.Int32To be added.To be added.To be added.PropertyGLib.Property("item-width")System.Int32The width used for each item.a PropertyGLib.Property("margin")System.Int32Space which is inserted at the edges of the icon view.a Default value is 6.PropertyGLib.Property("markup-column")System.Int32Contains the number of the model column containing markup information to be displayed.a The markup column must be of type . If this property and the TextColumn property are both set to column numbers, it overrides the text column. If both are set to -1, no texts are displayed.PropertyGLib.Property("model")Gtk.TreeModelThe model for the icon view.a EventGLib.Signal("move-cursor")Gtk.MoveCursorHandlerTo be addedMethodGLib.DefaultSignalHandler(ConnectionMethod="OverrideActivateCursorItem", Type=typeof(Gtk.IconView))System.BooleanDefault handler for the event.a Override this method in a subclass to provide a default handler for the event.MethodGLib.DefaultSignalHandler(ConnectionMethod="OverrideAllSelected", Type=typeof(Gtk.IconView))System.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodGLib.DefaultSignalHandler(ConnectionMethod="OverrideAllUnselected", Type=typeof(Gtk.IconView))System.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodGLib.DefaultSignalHandler(ConnectionMethod="OverrideItemActivated", Type=typeof(Gtk.IconView))System.Void
a Default handler for the event.Override this method in a subclass to provide a default handler for the event.MethodGLib.DefaultSignalHandler(ConnectionMethod="OverrideMoveCursor", Type=typeof(Gtk.IconView))System.Boolean
a
a Default handler for the event.a Override this method in a subclass to provide a default handler for the event.MethodGLib.DefaultSignalHandler(ConnectionMethod="OverrideSelectCursorItem", Type=typeof(Gtk.IconView))System.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodGLib.DefaultSignalHandler(ConnectionMethod="OverrideSelectionChanged", Type=typeof(Gtk.IconView))System.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodGLib.DefaultSignalHandler(ConnectionMethod="OverrideToggleCursorItem", Type=typeof(Gtk.IconView))System.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.Void
a to add to the view.
indicates if the should expand to available space.
Packs a renderer at the end of a cell.MethodSystem.Void
a to add to the view.
indicates if the should expand to available space.
Packs a renderer to the beginning of the cell.MethodSystem.Boolean
a Returns if the icon pointed to by is currently selected.a If does not point to a valid location, is returned.PropertyGLib.Property("pixbuf-column")System.Int32Contains the number of the model column containing the pixbufs which are displayeda The pixbuf column must be of type . Setting this property to -1 turns off the display of pixbufs.MethodSystem.Void
a of the view.
desired index within the list of renderers.
Moves a renderer to a position in the list of renderers.PropertyGLib.Property("reorderable")System.BooleanIndicates whether the list can be reordered via Drag and Drop. to allow reordering.PropertyGLib.Property("row-spacing")System.Int32Space which is inserted between grid rows.a Default value is 6.MethodSystem.Void
a of the item to be made visible by scrolling.
Scrolls the view to make an item visible.The minimum amount of scrolling will be done to make the item visible. To control the item's final position within the visible part of the widget, use the other overload of this method.MethodSystem.Void
a of the item to be made visible by scrolling.
a value between 0.0 and 1.0.
a value between 0.0 and 1.0.
Scrolls the view to make an item visible.Using row_align of 0.5 and col_align of 0.5 will try to center the item in the visible part of the widget.MethodSystem.VoidSelects all the icons.The IconView must has its selection mode set to .EventGLib.Signal("select-cursor-item")System.EventHandlerTo be addedMethodSystem.Void
a Calls a function for each selected icon.Note that the model or selection cannot be modified from within this function.PropertyGtk.TreePath[]Creates a list of paths of all selected items.a EventGLib.Signal("selection-changed")System.EventHandlerEmitted when the current selection changes.To be addedPropertyGLib.Property("selection-mode")Gtk.SelectionModeSpecifies the selection mode of icon view.a If the mode is , rubberband selection is enabled, for the other modes, only keyboard selection is possible.MethodSystem.Void
a Selects the row at .MethodSystem.VoidSystem.ParamArray
a of the view.
an array of name/value pairs.
Set the attributes of a given Cell Renderer.MethodSystem.Void
a of the view.
a , or to remove an existing delegate.
Sets the Cell Data delegate for a renderer.The Cell data func is an alternative to binding attributes to model columns. The delegate is invoked any time the cell is renderer and it should set up all the appropriate renderer information.MethodSystem.Void
the item to select.
the cell to focus, or .
indicates if the cell should be placed in edit mode.
Selects an item and sets keyboard focus to a cell.Normally followed by a call to .MethodSystem.Void
The item to highlight, or .
Indicates where to drop relative to the item.
Sets up drag feedback for an item.MethodSystem.Void
To be added.
To be added.
To be added.
To be added.To be added.MethodSystem.Void
To be added.
To be added.
To be added.To be added.PropertyGLib.Property("spacing")System.Int32Space which is inserted between cells of an item.a To be addedPropertyGLib.Property("text-column")System.Int32Contains the number of the model column containing the texts which are displayed.a The text column must be of type . If this property and the MarkupColumn property are both set to -1, no text is displayed.EventGLib.Signal("toggle-cursor-item")System.EventHandlerTo be addedPropertyGLib.Property("tooltip-column")System.Int32To be added.To be added.To be added.MethodSystem.VoidUnselects all the icons.MethodSystem.Void
a Unselects the row at .MethodSystem.VoidUnsets the view as a Drag destination.Reverses the effects of .MethodSystem.VoidUnsets the view as a drag source.Reverses the effects of .PropertyGLib.Property("vadjustment")Gtk.AdjustmentTo be added.To be added.To be added.PropertyGLib.Property("vscroll-policy")Gtk.ScrollablePolicyTo be added.To be added.To be added.