diff --git a/ChangeLog b/ChangeLog index 6409455cd..046e012ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-01-03 Mike Kestner + + * gtk/NodeStore.cs : expose TreeModelFlags.ListOnly if the TreeNode + has ListOnly set. + * gtk/TreeNodeAttribute.cs : add ListOnly named value. + 2004-12-30 Mike Kestner * glib/Object.cs : mark the Data hashtable obsolete. diff --git a/doc/ChangeLog b/doc/ChangeLog index e18530a18..975707ebd 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2005-01-03 Mike Kestner + + * en/Gtk/TreeNodeAttribute.xml : document ListOnly and add example. + 2005-01-03 Shane Landrum * en/Gtk/DrawingArea.xml diff --git a/doc/en/Gtk/TreeNodeAttribute.xml b/doc/en/Gtk/TreeNodeAttribute.xml index 680f4abad..0c344cd59 100644 --- a/doc/en/Gtk/TreeNodeAttribute.xml +++ b/doc/en/Gtk/TreeNodeAttribute.xml @@ -30,7 +30,22 @@ } - + + + + In the following example, the class MyListNode is tagged as + a node with 2 columns and no child nodes: + + + [TreeNode(ColumnCount=2, ListOnly=true)] + public class MyListNode : ITreeNode { + + ... + + } + + + @@ -72,5 +87,22 @@ + + + Property + + System.Boolean + + + + ListOnly named value. + a + + Specifies if the node can have children. For list views, this tells the + NodeStore that it is non-hierarchical and it can expose flags so that the + NodeView doesn't include space for expanders in the column layout. + + + - \ No newline at end of file + diff --git a/gtk/NodeStore.cs b/gtk/NodeStore.cs index 7bc99ec3b..e6714d07c 100644 --- a/gtk/NodeStore.cs +++ b/gtk/NodeStore.cs @@ -1,8 +1,8 @@ // NodeStore.cs - Tree store implementation for TreeView. // -// Author: Mike Kestner +// Author: Mike Kestner // -// Copyright (c) 2003 Novell, Inc. +// Copyright (c) 2003-2005 Novell, Inc. // // This program is free software; you can redistribute it and/or // modify it under the terms of version 2 of the Lesser GNU General @@ -83,12 +83,16 @@ namespace Gtk { GLib.GType[] ctypes; PropertyInfo[] getters; int n_cols = 1; + bool list_only = false; ArrayList nodes = new ArrayList (); TreeModelIfaceDelegates tree_model_iface; int get_flags_cb () { - return (int) TreeModelFlags.ItersPersist; + TreeModelFlags result = TreeModelFlags.ItersPersist; + if (list_only) + result |= TreeModelFlags.ListOnly; + return (int) result; } int get_n_columns_cb () @@ -281,8 +285,10 @@ namespace Gtk { void ScanType (Type type) { - foreach (TreeNodeAttribute attr in type.GetCustomAttributes (typeof (TreeNodeAttribute), false)) + foreach (TreeNodeAttribute attr in type.GetCustomAttributes (typeof (TreeNodeAttribute), false)) { n_cols = attr.ColumnCount; + list_only = attr.ListOnly; + } ctypes = new GLib.GType [n_cols]; getters = new PropertyInfo [n_cols]; diff --git a/gtk/TreeNodeAttribute.cs b/gtk/TreeNodeAttribute.cs index 1fd25f21e..656ac51cc 100644 --- a/gtk/TreeNodeAttribute.cs +++ b/gtk/TreeNodeAttribute.cs @@ -1,8 +1,8 @@ // TreeNodeAttribute.cs - Attribute to specify TreeNode information for a class // -// Author: Mike Kestner +// Author: Mike Kestner // -// Copyright (c) 2003 Novell, Inc. +// Copyright (c) 2003-2005 Novell, Inc. // // This program is free software; you can redistribute it and/or // modify it under the terms of version 2 of the Lesser GNU General @@ -26,6 +26,7 @@ namespace Gtk { [AttributeUsage(AttributeTargets.Class)] public sealed class TreeNodeAttribute : Attribute { int col_count; + bool list_only; public int ColumnCount { get { @@ -35,6 +36,15 @@ namespace Gtk { col_count = value; } } + + public bool ListOnly { + get { + return list_only; + } + set { + list_only = value; + } + } } }