mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-23 15:45:28 +00:00
2004-12-17 Mike Kestner <mkestner@novell.com>
* gtk/Makefile.am : add new file. * gtk/glue/makefile.win32 : add missing file. * gtk/NodeCellDataFunc.cs : new callback delegate type and marshaler for NodeStore tree views using GtkTreeCellDataFuncs. * gtk/NodeStore.cs : add internal GetNode overload by TreeIter. * gtk/NodeView.cs : add AppendColumn overload that uses data funcs. * gtk/TreeViewColumn.custom : manual implementation for SetCellDataFunc to support both TreeIter and ITreeNode models. We need to hold a ref to a delegate for each cell renderer on a column. [Fixes #63062] * sample/NodeViewDemo.cs : use a NodeCellDataFunc for one of the cell renderers in the tree. svn path=/trunk/gtk-sharp/; revision=37904
This commit is contained in:
parent
8457bacdc9
commit
59faab866e
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2004-12-17 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* gtk/Makefile.am : add new file.
|
||||
* gtk/glue/makefile.win32 : add missing file.
|
||||
* gtk/NodeCellDataFunc.cs : new callback delegate type and marshaler
|
||||
for NodeStore tree views using GtkTreeCellDataFuncs.
|
||||
* gtk/NodeStore.cs : add internal GetNode overload by TreeIter.
|
||||
* gtk/NodeView.cs : add AppendColumn overload that uses data funcs.
|
||||
* gtk/TreeViewColumn.custom : manual implementation for SetCellDataFunc
|
||||
to support both TreeIter and ITreeNode models. We need to hold a ref
|
||||
to a delegate for each cell renderer on a column. [Fixes #63062]
|
||||
* sample/NodeViewDemo.cs : use a NodeCellDataFunc for one of the
|
||||
cell renderers in the tree.
|
||||
|
||||
2004-12-17 Dan Winship <danw@novell.com>
|
||||
|
||||
* generator/Field.cs (StudlyName): Fall back to using "cname" if
|
||||
|
|
|
@ -68,5 +68,25 @@
|
|||
<remarks />
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="AppendColumn">
|
||||
<MemberSignature Language="C#" Value="public Gtk.TreeViewColumn AppendColumn (string title, Gtk.CellRenderer cell, Gtk.NodeCellDataFunc cell_data);" />
|
||||
<MemberType>Method</MemberType>
|
||||
<ReturnValue>
|
||||
<ReturnType>Gtk.TreeViewColumn</ReturnType>
|
||||
</ReturnValue>
|
||||
<Parameters>
|
||||
<Parameter Name="title" Type="System.String" />
|
||||
<Parameter Name="cell" Type="Gtk.CellRenderer" />
|
||||
<Parameter Name="cell_data" Type="Gtk.NodeCellDataFunc" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Adds a column to the view using a data callback delegate.</summary>
|
||||
<param name="title">a <see cref="T:System.String" /></param>
|
||||
<param name="cell">a <see cref="T:Gtk.CellRenderer" /></param>
|
||||
<param name="cell_data">a <see cref="T:Gtk.NodeCellDataFunc" /></param>
|
||||
<returns>a <see cref="T:Gtk.TreeViewColumn" /></returns>
|
||||
<remarks />
|
||||
</Docs>
|
||||
</Member>
|
||||
</Members>
|
||||
</Type>
|
||||
|
|
|
@ -701,5 +701,22 @@
|
|||
<remarks>To be added</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="SetCellDataFunc">
|
||||
<MemberSignature Language="C#" Value="public void SetCellDataFunc (Gtk.CellRenderer cell_renderer, Gtk.NodeCellDataFunc func);" />
|
||||
<MemberType>Method</MemberType>
|
||||
<ReturnValue>
|
||||
<ReturnType>System.Void</ReturnType>
|
||||
</ReturnValue>
|
||||
<Parameters>
|
||||
<Parameter Name="cell_renderer" Type="Gtk.CellRenderer" />
|
||||
<Parameter Name="func" Type="Gtk.NodeCellDataFunc" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Set the data func used to set cell renderer attributes.</summary>
|
||||
<param name="cell_renderer">a <see cref="T:Gtk.CellRenderer" /></param>
|
||||
<param name="func">a <see cref="T:Gtk.NodeCellDataFunc" /></param>
|
||||
<remarks />
|
||||
</Docs>
|
||||
</Member>
|
||||
</Members>
|
||||
</Type>
|
||||
</Type>
|
||||
|
|
|
@ -21,6 +21,7 @@ sources = \
|
|||
Application.cs \
|
||||
ChildPropertyAttribute.cs \
|
||||
ITreeNode.cs \
|
||||
NodeCellDataFunc.cs \
|
||||
NodeSelection.cs \
|
||||
NodeStore.cs \
|
||||
NodeView.cs \
|
||||
|
|
48
gtk/NodeCellDataFunc.cs
Normal file
48
gtk/NodeCellDataFunc.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
// NodeCellDataFunc.cs - a TreeCellDataFunc marshaler for ITreeNodes
|
||||
//
|
||||
// Author: Mike Kestner (mkestner@novell.com)
|
||||
//
|
||||
// Copyright (c) 2004 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
|
||||
// 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.
|
||||
|
||||
|
||||
namespace Gtk {
|
||||
|
||||
using System;
|
||||
|
||||
public delegate void NodeCellDataFunc (TreeViewColumn tree_column, CellRenderer cell, ITreeNode node);
|
||||
|
||||
|
||||
internal class NodeCellDataFuncWrapper : GLib.DelegateWrapper {
|
||||
|
||||
public void NativeCallback (IntPtr tree_column, IntPtr cell, IntPtr tree_model, ref Gtk.TreeIter iter, IntPtr data)
|
||||
{
|
||||
TreeViewColumn col = (Gtk.TreeViewColumn) GLib.Object.GetObject(tree_column);
|
||||
CellRenderer renderer = (Gtk.CellRenderer) GLib.Object.GetObject(cell);
|
||||
NodeStore store = (NodeStore) GLib.Object.GetObject(tree_model);
|
||||
managed (col, renderer, store.GetNode (iter));
|
||||
}
|
||||
|
||||
internal GtkSharp.TreeCellDataFuncNative NativeDelegate;
|
||||
protected NodeCellDataFunc managed;
|
||||
|
||||
public NodeCellDataFuncWrapper (NodeCellDataFunc managed, object o) : base (o)
|
||||
{
|
||||
NativeDelegate = new GtkSharp.TreeCellDataFuncNative (NativeCallback);
|
||||
this.managed = managed;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -399,13 +399,19 @@ namespace Gtk {
|
|||
return node;
|
||||
}
|
||||
|
||||
public ITreeNode GetNode (TreePath path) {
|
||||
public ITreeNode GetNode (TreePath path)
|
||||
{
|
||||
if (path == null)
|
||||
throw new ArgumentNullException ();
|
||||
|
||||
return GetNodeAtPath (path);
|
||||
}
|
||||
|
||||
internal ITreeNode GetNode (TreeIter iter)
|
||||
{
|
||||
return node_hash [(int) iter.UserData] as ITreeNode;
|
||||
}
|
||||
|
||||
internal TreePath GetPath (ITreeNode node)
|
||||
{
|
||||
TreePath path = new TreePath ();
|
||||
|
|
|
@ -60,5 +60,17 @@ namespace Gtk {
|
|||
return new NodeSelection (Selection);
|
||||
}
|
||||
}
|
||||
|
||||
public Gtk.TreeViewColumn AppendColumn (string title, Gtk.CellRenderer cell, Gtk.NodeCellDataFunc cell_data)
|
||||
{
|
||||
Gtk.TreeViewColumn col = new Gtk.TreeViewColumn ();
|
||||
col.Title = title;
|
||||
col.PackStart (cell, true);
|
||||
col.SetCellDataFunc (cell, cell_data);
|
||||
|
||||
AppendColumn (col);
|
||||
return col;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,6 @@
|
|||
|
||||
|
||||
|
||||
public void SetCellDataFunc(Gtk.CellRenderer cell_renderer, Gtk.TreeCellDataFunc func) {
|
||||
GtkSharp.TreeCellDataFuncWrapper func_wrapper = null;
|
||||
func_wrapper = new GtkSharp.TreeCellDataFuncWrapper (func, this);
|
||||
gtk_tree_view_column_set_cell_data_func(Handle, cell_renderer.Handle, func_wrapper.NativeDelegate, IntPtr.Zero, null);
|
||||
}
|
||||
|
||||
private void _NewWithAttributes (string title, Gtk.CellRenderer cell, Array attrs) {
|
||||
Title = title;
|
||||
PackStart (cell, true);
|
||||
|
@ -62,3 +56,49 @@
|
|||
}
|
||||
}
|
||||
|
||||
Hashtable cell_data_funcs;
|
||||
|
||||
Hashtable CellDataFuncs {
|
||||
get {
|
||||
if (cell_data_funcs == null)
|
||||
cell_data_funcs = new Hashtable ();
|
||||
return cell_data_funcs;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libgtk-win32-2.0-0.dll")]
|
||||
static extern void gtk_tree_view_column_set_cell_data_func(IntPtr raw, IntPtr cell_renderer, IntPtr func, IntPtr func_data, IntPtr destroy);
|
||||
|
||||
private void ReleaseDataFunc (CellRenderer cell)
|
||||
{
|
||||
CellDataFuncs [cell.Handle] = null;
|
||||
gtk_tree_view_column_set_cell_data_func(Handle, cell.Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
|
||||
[DllImport("libgtk-win32-2.0-0.dll")]
|
||||
static extern void gtk_tree_view_column_set_cell_data_func(IntPtr raw, IntPtr cell_renderer, GtkSharp.TreeCellDataFuncNative func, IntPtr func_data, IntPtr destroy);
|
||||
|
||||
public void SetCellDataFunc (CellRenderer cell_renderer, TreeCellDataFunc func)
|
||||
{
|
||||
if (func == null) {
|
||||
ReleaseDataFunc (cell_renderer);
|
||||
return;
|
||||
}
|
||||
;
|
||||
GtkSharp.TreeCellDataFuncWrapper wrapper = new GtkSharp.TreeCellDataFuncWrapper (func, this);
|
||||
CellDataFuncs [cell_renderer.Handle] = wrapper;
|
||||
gtk_tree_view_column_set_cell_data_func(Handle, cell_renderer.Handle, wrapper.NativeDelegate, IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
|
||||
public void SetCellDataFunc (CellRenderer cell_renderer, NodeCellDataFunc func)
|
||||
{
|
||||
if (func == null) {
|
||||
ReleaseDataFunc (cell_renderer);
|
||||
return;
|
||||
}
|
||||
;
|
||||
NodeCellDataFuncWrapper wrapper = new NodeCellDataFuncWrapper (func, this);
|
||||
CellDataFuncs [cell_renderer.Handle] = wrapper;
|
||||
gtk_tree_view_column_set_cell_data_func(Handle, cell_renderer.Handle, wrapper.NativeDelegate, IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ DLLWRAP=dllwrap -mno-cygwin -mms-bitfields --target i386-mingw32 --export-all-sy
|
|||
GLUE_OBJS = \
|
||||
adjustment.o \
|
||||
button.o \
|
||||
cellrenderer.o \
|
||||
clipboard.o \
|
||||
colorseldialog.o \
|
||||
combo.o \
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace GtkSamples {
|
|||
NodeView view = new NodeView (Store);
|
||||
view.HeadersVisible = true;
|
||||
view.AppendColumn ("Name", new CellRendererText (), "text", 0);
|
||||
view.AppendColumn ("Type", new CellRendererText (), "text", 1);
|
||||
view.AppendColumn ("Type", new CellRendererText (), new NodeCellDataFunc (DataCallback));
|
||||
|
||||
sw.Add (view);
|
||||
|
||||
|
@ -65,6 +65,11 @@ namespace GtkSamples {
|
|||
dialog = null;
|
||||
}
|
||||
|
||||
private void DataCallback (TreeViewColumn col, CellRenderer cell, ITreeNode node)
|
||||
{
|
||||
(cell as CellRendererText).Text = (node as DemoTreeNode).Description;
|
||||
}
|
||||
|
||||
StatusDialog Dialog {
|
||||
get {
|
||||
if (dialog == null)
|
||||
|
|
Loading…
Reference in a new issue