mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-24 00:35:36 +00:00
2005-05-11 Eric Butler <eric@extremeboredom.net>
* gtk/Gtk.metadata : add IEnumerable iface to ListStore. * gtk/ListStore.cs : add GetEnumerator. * gtk/Makefile.am : add file. * gtk/TreeEnumerator.cs : root node enumerator for a TreeModel. svn path=/trunk/gtk-sharp/; revision=44409
This commit is contained in:
parent
a900916eab
commit
caec90e311
|
@ -1,3 +1,10 @@
|
|||
2005-05-11 Eric Butler <eric@extremeboredom.net>
|
||||
|
||||
* gtk/Gtk.metadata : add IEnumerable iface to ListStore.
|
||||
* gtk/ListStore.cs : add GetEnumerator.
|
||||
* gtk/Makefile.am : add file.
|
||||
* gtk/TreeEnumerator.cs : root node enumerator for a TreeModel.
|
||||
|
||||
2005-05-11 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* gtk/Widget.custom : manual ListMnemonicLabels implementation to
|
||||
|
|
|
@ -1497,5 +1497,23 @@ The above example creates a new three columns list store. The types of the colum
|
|||
<remarks>To be added</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="GetEnumerator">
|
||||
<MemberSignature Language="C#" Value="public virtual System.Collections.IEnumerator GetEnumerator ();" />
|
||||
<MemberType>Method</MemberType>
|
||||
<ReturnValue>
|
||||
<ReturnType>System.Collections.IEnumerator</ReturnType>
|
||||
</ReturnValue>
|
||||
<Parameters />
|
||||
<Docs>
|
||||
<summary>
|
||||
<para>Returns a <see cref="T:System.Collections.IEnumerator" /> for the current instance.</para>
|
||||
</summary>
|
||||
<returns>a <see cref="T:System.Collections.IEnumerator" /></returns>
|
||||
<remarks>
|
||||
<para> If the elements of the current instance are modified while an enumeration is in progress, a call to <see cref="M:System.Collections.IEnumerator.MoveNext" /> or <see cref="P:System.Collections.IEnumerator.Current" /> throws <see cref="T:System.InvalidOperationException" />.</para>
|
||||
</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
</Members>
|
||||
</Type>
|
||||
|
||||
|
|
|
@ -249,6 +249,7 @@
|
|||
<attr path="/api/namespace/object[@cname='GtkLabel']/constructor[@cname='gtk_label_new_with_mnemonic']" name="preferred">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkLabel']/constructor[@cname='gtk_label_new_with_mnemonic']/*/*[@name='str']" name="property_name">label</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkLayout']/signal[@name='SetScrollAdjustments']" name="name">ScrollAdjustmentsSet</attr>
|
||||
<add-node path="/api/namespace/object[@name='ListStore']"><implements><interface name="IEnumerable" /></implements></add-node>
|
||||
<attr path="/api/namespace/object[@cname='GtkListStore']/constructor[@cname='gtk_list_store_new']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkListStore']/constructor[@cname='gtk_list_store_newv']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkListStore']/method[@name='Append']/*/*[@name='iter']" name="pass_as">out</attr>
|
||||
|
|
|
@ -164,3 +164,9 @@
|
|||
{
|
||||
DefaultSortFunc = sort_func;
|
||||
}
|
||||
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return new TreeEnumerator(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ sources = \
|
|||
ThreadNotify.cs \
|
||||
ToggleActionEntry.cs \
|
||||
Timeout.cs \
|
||||
TreeEnumerator.cs \
|
||||
TreeNodeAttribute.cs \
|
||||
TreeNode.cs \
|
||||
TreeNodeValueAttribute.cs
|
||||
|
|
85
gtk/TreeEnumerator.cs
Normal file
85
gtk/TreeEnumerator.cs
Normal file
|
@ -0,0 +1,85 @@
|
|||
// TreeEnumerator.cs - .NET-style Enumerator for TreeModel classes
|
||||
//
|
||||
// Author: Eric Butler <eric@extremeboredom.net>
|
||||
//
|
||||
// Copyright (c) 2005 Eric Butler
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the Lesser GNU General
|
||||
// Public License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Gtk
|
||||
{
|
||||
internal class TreeEnumerator : IEnumerator
|
||||
{
|
||||
private Gtk.TreeIter iter;
|
||||
private Gtk.TreeModel model;
|
||||
private bool reset = true;
|
||||
private bool changed = false;
|
||||
|
||||
public TreeEnumerator (TreeModel model)
|
||||
{
|
||||
this.model = model;
|
||||
|
||||
model.RowChanged += model_changed;
|
||||
model.RowDeleted += model_changed;
|
||||
model.RowInserted += model_changed;
|
||||
model.RowsReordered += model_changed;
|
||||
}
|
||||
|
||||
public object Current
|
||||
{
|
||||
get {
|
||||
if (reset == false) {
|
||||
object[] row = new object[model.NColumns];
|
||||
for (int x = 0; x < model.NColumns; x++) {
|
||||
row[x] = model.GetValue(iter, x);
|
||||
}
|
||||
return row;
|
||||
} else {
|
||||
throw new InvalidOperationException("Enumerator not started.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (changed == false) {
|
||||
if (reset == true) {
|
||||
reset = false;
|
||||
return model.GetIterFirst(out iter);
|
||||
} else {
|
||||
return model.IterNext(ref iter);
|
||||
}
|
||||
} else {
|
||||
throw new InvalidOperationException("List has changed.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
reset = true;
|
||||
changed = false;
|
||||
}
|
||||
|
||||
private void model_changed(object o, EventArgs args)
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue