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]2.12.0.0Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details.A 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;
}
}
Gtk.ContainerGtk.CellLayoutMethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.
a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.BooleanDefault handler for the event.
a
a a Override this method in a subclass to provide a default handler for the event.MethodSystem.BooleanDefault handler for the event.a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidUnselects all the icons.MethodSystem.VoidCalls a function for each selected icon.
a Note that the model or selection cannot be modified from within this function.MethodSystem.VoidUnselects the row at .
a MethodSystem.VoidSelects all the icons.The IconView must has its selection mode set to .MethodSystem.BooleanReturns if the icon pointed to by is currently selected.
a a If does not point to a valid location, is returned.MethodGtk.TreePathTo be added
a
a a To be addedMethodSystem.VoidActivates the item determined by .
a MethodSystem.VoidSelects the row at .
a ConstructorProtected Constructor.
a Chain to this constructor if you have manually registered a native value for your subclass.System.ObsoleteConstructorInternal constructor
a This is not typically used by C# code.ConstructorDefault constructorConstructorCreate a new IconView with a model.
a PropertyGLib.GTypeGType Property.a Returns the native value for .PropertyGtk.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.GLib.Property("selection-mode")PropertySystem.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.GLib.Property("columns")PropertySystem.Int32Space which is inserted at the edges of the icon view.a Default value is 6.GLib.Property("margin")PropertyGtk.OrientationHow the text and icon of each item are positioned relative to each other.
a Default value is GLib.Property("orientation")PropertySystem.Int32The width used for each item.a GLib.Property("item-width")PropertySystem.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.GLib.Property("text-column")PropertySystem.Int32Space which is inserted between cells of an item.a To be addedGLib.Property("spacing")PropertySystem.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.GLib.Property("pixbuf-column")PropertySystem.Int32Space which is inserted between grid rows.a Default value is 6.GLib.Property("row-spacing")PropertySystem.Int32Space which is inserted between grid column.a Default value is 6.GLib.Property("column-spacing")PropertySystem.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.GLib.Property("markup-column")PropertyGtk.TreeModelThe model for the icon view.a GLib.Property("model")PropertyGtk.TreePath[]Creates a list of paths of all selected items.a EventSystem.EventHandlerEmitted when the current selection changes.To be addedGLib.Signal("selection-changed")EventSystem.EventHandlerEmitted when UnselectAll () is called.GLib.Signal("unselect_all")EventGtk.ItemActivatedHandlerEmitted when an item is activated.GLib.Signal("item_activated")EventSystem.EventHandlerEmitted when SelectAll () is called.GLib.Signal("select_all")EventSystem.EventHandlerTo be addedGLib.Signal("toggle_cursor_item")EventGtk.MoveCursorHandlerTo be addedGLib.Signal("move_cursor")EventGtk.ActivateCursorItemHandlerTo be addedTo be addedGLib.Signal("activate_cursor_item")EventSystem.EventHandlerTo be addedGLib.Signal("select_cursor_item")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.MethodGdk.Pixmap
a to an item in the view.
Creates a pixmap representation of an item.a representation of the item at .MethodSystem.VoidUnsets the view as a Drag destination.Reverses the effects of .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.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.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.Void
The item to highlight, or .
Indicates where to drop relative to the item.
Sets up drag feedback for an item.MethodSystem.VoidUnsets the view as a drag source.Reverses the effects of .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 .PropertyGLib.Property("reorderable")System.BooleanIndicates whether the list can be reordered via Drag and Drop. to allow reordering.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.Void
an array of items supported.
drop actions supported by the view.
Enables the view as a Drop destination.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.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.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
a of the view.
Clears attribute bindings for a cell renderer.MethodSystem.VoidClears attribute bindings and removes all renderers.MethodSystem.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.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 of the view.
desired index within the list of renderers.
Moves a renderer to a position in the list of renderers.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.VoidSystem.ParamArray
a of the view.
an array of name/value pairs.
Set the attributes of a given Cell Renderer.PropertyGtk.CellRenderer[]To be added.To be added.To be added.MethodSystem.Void
To be added.
To be added.
To be added.
To be added.
To be added.To be added.MethodSystem.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.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("tooltip-column")System.Int32To be added.To be added.To be added.