[Gtk-sharp-list] Gtk: TreeView and

andreas.weiss3@epost.de andreas.weiss3@epost.de
Sun, 1 Jun 2003 16:47:48 +0200





Hi List,

my little program with a treeview throws an exception on that point where=

I try to append some data to a Treestore.

	...
	store =3D new Gtk.TreeStore((int)TypeFundamentals.TypeString);
	TreeIter iter =3D new TreeIter ();
	store.Append(out iter);	//<- Here comes the exception.



Unhandled Exception: System.DllNotFoundException: Unable to load DLL (gtk=
-x11-2.0).
   at Gtk.TreeStore.gtk_tree_store_append(IntPtr raw, TreeIter& iter, Int=
Ptr
par
ent)
   at Gtk.TreeStore.Append(TreeIter& iter)
   at GladeTest.on_open2_activate(Object obj, EventArgs e)
   at GtkSharp.voidObjectSignal.voidObjectCallback(IntPtr arg0, Int32 key=
)
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at GladeTest..ctor(String[] args)
   at GladeTest.Main(String[] args)


I don't have that gtk-x11-2.0.dll on my Win 2003 Srv with mono-023 and Gt=
k-2.0.

Regards,
Andreas





--- code ---

using Gtk;
using GtkSharp;
using Glade;
using GLib;			
using System;
using System.IO;


public class GladeTest{
	//Gtk.Window window1;
	Gtk.Statusbar statusbar1;
	Gtk.Statusbar statusbar2;
	Gtk.Entry entry1;
	Gtk.Entry entry2;
	Gtk.Entry entry3;
	Gtk.Entry entry4;
	private static Gtk.TreeStore store;
	Gtk.TreeView treeview1;
	Gtk.TreeView treeview2;
	
	Glade.XML gxml;
	public static void Main(string[]args)
	{
		new GladeTest(args);
	}

public GladeTest(string[]args)
{
	Application.Init();
	gxml =3D new Glade.XML("gtk2.glade","window1",null);
	gxml.Autoconnect(this);
// Was bedeutet die unterschiedliche Art der Instanzierung???	
	statusbar1 =3D gxml.GetWidget("statusbar1") as Gtk.Statusbar;
	statusbar2 =3D gxml.GetWidget("statusbar2") as Gtk.Statusbar;
	entry1 =3D gxml.GetWidget("entry1") as Gtk.Entry;
	entry2 =3D gxml.GetWidget("entry2") as Gtk.Entry;
	entry3 =3D gxml.GetWidget("entry3") as Gtk.Entry;
	entry4 =3D gxml.GetWidget("entry4") as Gtk.Entry;
	treeview1 =3D gxml.GetWidget("treeview1") as Gtk.TreeView;
	treeview2 =3D gxml.GetWidget("treeview2") as Gtk.TreeView;
//	Gtk.Entry entry1 =3D (Gtk.Entry)gxml["entry1"];
//	Gtk.Entry entry2 =3D (Gtk.Entry)gxml["entry2"];
//	Gtk.Entry entry3 =3D (Gtk.Entry)gxml["entry3"];
//	Gtk.Entry entry4 =3D (Gtk.Entry)gxml["entry4"];
	Gtk.Window window1 =3D (Gtk.Window)gxml["window1"];
	window1.Title =3D "DM-Tool developed by";
	Application.Run();
}

public void on_window1_delete_event(object obj, DeleteEventArgs args)
{
	Application.Quit ();
	System.Environment.Exit (0);
}

public void on_quit1_activate(System.Object obj, EventArgs e)
{
	Application.Quit ();
	System.Environment.Exit (0);
}

public void on_about1_activate(System.Object obj, EventArgs e)
{
	
}

public void on_open1_activate(System.Object obj, EventArgs e)
{
	FileOpen();
}

public void on_open2_activate(System.Object obj, EventArgs e)
{
	store =3D new Gtk.TreeStore((int)TypeFundamentals.TypeString);
	TreeIter iter =3D new TreeIter ();
	store.Append(out iter);
	//store.SetValue(iter,0,new GLib.Value("-myString-"));
	
	
	
	treeview1.Model =3D store;
	
	Gtk.TreeViewColumn treeview1column1 =3D new TreeViewColumn();
	Gtk.CellRenderer treeview1column1Renderer =3D new CellRendererText();
	treeview1column1.Title =3D "Tagname";
	treeview1column1.PackStart(treeview1column1Renderer, true);
	treeview1column1.AddAttribute(treeview1column1Renderer, "text", 0);
	
	treeview1.AppendColumn(treeview1column1);
//	store =3D new TreeStore ((int)TypeFundamentals.TypeString,(int)TypeFun=
damentals.TypeString);
//	store.Append (out iter, parent);
//	store.SetValue (iter, 0, Name);


//
//	TreeView treeview1 =3D new TreeView (store);
//	treeview1.HeadersVisible =3D true;
//
//	TreeViewColumn NameCol =3D new TreeViewColumn ();
//	CellRenderer NameRenderer =3D new CellRendererText ();
//	NameCol.Title =3D "Name";
//	NameCol.PackStart (NameRenderer, true);
//	NameCol.AddAttribute (NameRenderer, "text", 0);
//	treeview1.AppendColumn (NameCol);

}



public void FileOpen()
{
	string strPathFile =3D "";
	string strFile =3D "";
	//if (Path.DirectorySeparatorChar.ToString() =3D=3D "\")
	strPathFile =3D entry1.Text;
	
	//Ueberpruefung, auf gueltige Pfad-Angabe
	if (strPathFile.Length > 3)
	{
		FileInfo FileInfo1 =3D new FileInfo(strPathFile);
		if (FileInfo1.Exists)
		{ 
			statusbar1.Push(0, FileInfo1.Name);
			try
			{
			FileStream FileStream1 =3D new FileStream(strPathFile, System.IO.FileM=
ode.Open,
System.IO.FileAccess.Read);
			StreamReader StreamReader1 =3D new StreamReader(FileStream1);
			strFile =3D StreamReader1.ReadToEnd();
			StreamReader1.Close();
			FileStream1.Close();
			}
			catch (Exception e1)
			{
				statusbar1.Push(0, "errors encounterd during file handling");
				Console.WriteLine("Error: " + e1.Message + " ; on_open1_activate: fil=
e
handling");
			}
			try
			{

			}
			catch (Exception e2)
			{
				statusbar1.Push(0, "error encounterd during string manipulation");
				Console.WriteLine("Error: " + e2.Message + " ; on_open1_activate: str=
ing
manipulation");
			}
		}
		else
		{
			statusbar1.Push(0, "file doesn't exists");
		}	//if (FileInfo1.Exists)
	}
	else
		{
			statusbar1.Push(0, "Please provide a valid file name");
		}	//if (strPathFile.Length > 3)
		
}	//public void FileOpen()




}


---
csc -r:gtk-sharp.dll -r:gdk-sharp.dll -r:glib-sharp.dll -r:atk-sharp.dll
-r:glade-sharp.dll  DM-Tool1.cs

---

gtk2.glade

<?xml version=3D"1.0" standalone=3D"no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>

<widget class=3D"GtkWindow" id=3D"window1">
  <property name=3D"visible">True</property>
  <property name=3D"title" translatable=3D"yes">window1</property>
  <property name=3D"type">GTK_WINDOW_TOPLEVEL</property>
  <property name=3D"window_position">GTK_WIN_POS_NONE</property>
  <property name=3D"modal">False</property>
  <property name=3D"default_width">640</property>
  <property name=3D"default_height">480</property>
  <property name=3D"resizable">True</property>
  <property name=3D"destroy_with_parent">False</property>
  <signal name=3D"delete_event" handler=3D"on_window1_delete_event" last_=
modification_time=3D"Sun,
01 Jun 2003 14:08:51 GMT"/>

  <child>
    <widget class=3D"GtkTable" id=3D"table1">
      <property name=3D"visible">True</property>
      <property name=3D"n_rows">6</property>
      <property name=3D"n_columns">3</property>
      <property name=3D"homogeneous">False</property>
      <property name=3D"row_spacing">0</property>
      <property name=3D"column_spacing">0</property>

      <child>
	<widget class=3D"GtkMenuBar" id=3D"menubar1">
	  <property name=3D"visible">True</property>

	  <child>
	    <widget class=3D"GtkMenuItem" id=3D"menuitem1">
	      <property name=3D"visible">True</property>
	      <property name=3D"label" translatable=3D"yes">_File</property>
	      <property name=3D"use_underline">True</property>

	      <child>
		<widget class=3D"GtkMenu" id=3D"menuitem1_menu">

		  <child>
		    <widget class=3D"GtkMenuItem" id=3D"open1">
		      <property name=3D"visible">True</property>
		      <property name=3D"label" translatable=3D"yes">Open1</property>
		      <property name=3D"use_underline">True</property>
		      <signal name=3D"activate" handler=3D"on_open1_activate" last_modi=
fication_time=3D"Sun,
01 Jun 2003 13:13:59 GMT"/>
		    </widget>
		  </child>

		  <child>
		    <widget class=3D"GtkMenuItem" id=3D"open2">
		      <property name=3D"visible">True</property>
		      <property name=3D"label" translatable=3D"yes">Open2</property>
		      <property name=3D"use_underline">True</property>
		      <signal name=3D"activate" handler=3D"on_open2_activate" last_modi=
fication_time=3D"Sun,
01 Jun 2003 13:17:21 GMT"/>
		    </widget>
		  </child>

		  <child>
		    <widget class=3D"GtkMenuItem" id=3D"separatormenuitem1">
		      <property name=3D"visible">True</property>
		    </widget>
		  </child>

		  <child>
		    <widget class=3D"GtkImageMenuItem" id=3D"quit1">
		      <property name=3D"visible">True</property>
		      <property name=3D"label">gtk-quit</property>
		      <property name=3D"use_stock">True</property>
		      <signal name=3D"activate" handler=3D"on_quit1_activate" last_modi=
fication_time=3D"Sun,
01 Jun 2003 13:13:59 GMT"/>
		    </widget>
		  </child>
		</widget>
	      </child>
	    </widget>
	  </child>

	  <child>
	    <widget class=3D"GtkMenuItem" id=3D"menuitem4">
	      <property name=3D"visible">True</property>
	      <property name=3D"label" translatable=3D"yes">_Help</property>
	      <property name=3D"use_underline">True</property>

	      <child>
		<widget class=3D"GtkMenu" id=3D"menuitem4_menu">

		  <child>
		    <widget class=3D"GtkMenuItem" id=3D"about1">
		      <property name=3D"visible">True</property>
		      <property name=3D"label" translatable=3D"yes">_About</property>
		      <property name=3D"use_underline">True</property>
		      <signal name=3D"activate" handler=3D"on_about1_activate" last_mod=
ification_time=3D"Sun,
01 Jun 2003 13:13:59 GMT"/>
		    </widget>
		  </child>
		</widget>
	      </child>
	    </widget>
	  </child>
	</widget>
	<packing>
	  <property name=3D"left_attach">0</property>
	  <property name=3D"right_attach">1</property>
	  <property name=3D"top_attach">0</property>
	  <property name=3D"bottom_attach">1</property>
	  <property name=3D"x_options">fill</property>
	  <property name=3D"y_options"></property>
	</packing>
      </child>

      <child>
	<widget class=3D"GtkScrolledWindow" id=3D"scrolledwindow1">
	  <property name=3D"visible">True</property>
	  <property name=3D"can_focus">True</property>
	  <property name=3D"hscrollbar_policy">GTK_POLICY_ALWAYS</property>
	  <property name=3D"vscrollbar_policy">GTK_POLICY_ALWAYS</property>
	  <property name=3D"shadow_type">GTK_SHADOW_NONE</property>
	  <property name=3D"window_placement">GTK_CORNER_TOP_LEFT</property>

	  <child>
	    <widget class=3D"GtkTreeView" id=3D"treeview1">
	      <property name=3D"visible">True</property>
	      <property name=3D"can_focus">True</property>
	      <property name=3D"headers_visible">True</property>
	      <property name=3D"rules_hint">False</property>
	      <property name=3D"reorderable">False</property>
	      <property name=3D"enable_search">True</property>
	    </widget>
	  </child>
	</widget>
	<packing>
	  <property name=3D"left_attach">1</property>
	  <property name=3D"right_attach">2</property>
	  <property name=3D"top_attach">2</property>
	  <property name=3D"bottom_attach">3</property>
	</packing>
      </child>

      <child>
	<widget class=3D"GtkScrolledWindow" id=3D"scrolledwindow2">
	  <property name=3D"visible">True</property>
	  <property name=3D"can_focus">True</property>
	  <property name=3D"hscrollbar_policy">GTK_POLICY_ALWAYS</property>
	  <property name=3D"vscrollbar_policy">GTK_POLICY_ALWAYS</property>
	  <property name=3D"shadow_type">GTK_SHADOW_NONE</property>
	  <property name=3D"window_placement">GTK_CORNER_TOP_LEFT</property>

	  <child>
	    <widget class=3D"GtkTreeView" id=3D"treeview2">
	      <property name=3D"visible">True</property>
	      <property name=3D"can_focus">True</property>
	      <property name=3D"headers_visible">True</property>
	      <property name=3D"rules_hint">False</property>
	      <property name=3D"reorderable">False</property>
	      <property name=3D"enable_search">True</property>
	    </widget>
	  </child>
	</widget>
	<packing>
	  <property name=3D"left_attach">2</property>
	  <property name=3D"right_attach">3</property>
	  <property name=3D"top_attach">2</property>
	  <property name=3D"bottom_attach">3</property>
	  <property name=3D"y_options">fill</property>
	</packing>
      </child>

      <child>
	<widget class=3D"GtkEntry" id=3D"entry1">
	  <property name=3D"visible">True</property>
	  <property name=3D"can_focus">True</property>
	  <property name=3D"editable">True</property>
	  <property name=3D"visibility">True</property>
	  <property name=3D"max_length">0</property>
	  <property name=3D"text" translatable=3D"yes">C:\Documents and Settings=
\Administrator\My
Documents\Projekte\mono\dm-tool1.txt</property>
	  <property name=3D"has_frame">True</property>
	  <property name=3D"invisible_char" translatable=3D"yes">*</property>
	  <property name=3D"activates_default">False</property>
	</widget>
	<packing>
	  <property name=3D"left_attach">1</property>
	  <property name=3D"right_attach">2</property>
	  <property name=3D"top_attach">1</property>
	  <property name=3D"bottom_attach">2</property>
	  <property name=3D"y_options"></property>
	</packing>
      </child>

      <child>
	<widget class=3D"GtkEntry" id=3D"entry2">
	  <property name=3D"visible">True</property>
	  <property name=3D"can_focus">True</property>
	  <property name=3D"editable">True</property>
	  <property name=3D"visibility">True</property>
	  <property name=3D"max_length">0</property>
	  <property name=3D"text" translatable=3D"yes"></property>
	  <property name=3D"has_frame">True</property>
	  <property name=3D"invisible_char" translatable=3D"yes">*</property>
	  <property name=3D"activates_default">False</property>
	</widget>
	<packing>
	  <property name=3D"left_attach">2</property>
	  <property name=3D"right_attach">3</property>
	  <property name=3D"top_attach">1</property>
	  <property name=3D"bottom_attach">2</property>
	  <property name=3D"y_options"></property>
	</packing>
      </child>

      <child>
	<widget class=3D"GtkStatusbar" id=3D"statusbar1">
	  <property name=3D"visible">True</property>
	  <property name=3D"has_resize_grip">True</property>
	</widget>
	<packing>
	  <property name=3D"left_attach">1</property>
	  <property name=3D"right_attach">2</property>
	  <property name=3D"top_attach">5</property>
	  <property name=3D"bottom_attach">6</property>
	  <property name=3D"x_options">fill</property>
	  <property name=3D"y_options"></property>
	</packing>
      </child>

      <child>
	<widget class=3D"GtkEntry" id=3D"entry3">
	  <property name=3D"visible">True</property>
	  <property name=3D"can_focus">True</property>
	  <property name=3D"editable">True</property>
	  <property name=3D"visibility">True</property>
	  <property name=3D"max_length">0</property>
	  <property name=3D"text" translatable=3D"yes"></property>
	  <property name=3D"has_frame">True</property>
	  <property name=3D"invisible_char" translatable=3D"yes">*</property>
	  <property name=3D"activates_default">False</property>
	</widget>
	<packing>
	  <property name=3D"left_attach">1</property>
	  <property name=3D"right_attach">2</property>
	  <property name=3D"top_attach">3</property>
	  <property name=3D"bottom_attach">4</property>
	  <property name=3D"y_options"></property>
	</packing>
      </child>

      <child>
	<widget class=3D"GtkEntry" id=3D"entry4">
	  <property name=3D"visible">True</property>
	  <property name=3D"can_focus">True</property>
	  <property name=3D"editable">True</property>
	  <property name=3D"visibility">True</property>
	  <property name=3D"max_length">0</property>
	  <property name=3D"text" translatable=3D"yes"></property>
	  <property name=3D"has_frame">True</property>
	  <property name=3D"invisible_char" translatable=3D"yes">*</property>
	  <property name=3D"activates_default">False</property>
	</widget>
	<packing>
	  <property name=3D"left_attach">2</property>
	  <property name=3D"right_attach">3</property>
	  <property name=3D"top_attach">3</property>
	  <property name=3D"bottom_attach">4</property>
	  <property name=3D"y_options"></property>
	</packing>
      </child>

      <child>
	<widget class=3D"GtkStatusbar" id=3D"statusbar2">
	  <property name=3D"visible">True</property>
	  <property name=3D"has_resize_grip">True</property>
	</widget>
	<packing>
	  <property name=3D"left_attach">2</property>
	  <property name=3D"right_attach">3</property>
	  <property name=3D"top_attach">5</property>
	  <property name=3D"bottom_attach">6</property>
	  <property name=3D"x_options">fill</property>
	  <property name=3D"y_options"></property>
	</packing>
      </child>

      <child>
	<widget class=3D"GtkButton" id=3D"button1">
	  <property name=3D"visible">True</property>
	  <property name=3D"can_focus">True</property>
	  <property name=3D"label" translatable=3D"yes">button1</property>
	  <property name=3D"use_underline">True</property>
	  <property name=3D"relief">GTK_RELIEF_NORMAL</property>
	</widget>
	<packing>
	  <property name=3D"left_attach">1</property>
	  <property name=3D"right_attach">2</property>
	  <property name=3D"top_attach">4</property>
	  <property name=3D"bottom_attach">5</property>
	  <property name=3D"x_options">fill</property>
	  <property name=3D"y_options"></property>
	</packing>
      </child>

      <child>
	<widget class=3D"GtkButton" id=3D"button2">
	  <property name=3D"visible">True</property>
	  <property name=3D"can_focus">True</property>
	  <property name=3D"label" translatable=3D"yes">button2</property>
	  <property name=3D"use_underline">True</property>
	  <property name=3D"relief">GTK_RELIEF_NORMAL</property>
	</widget>
	<packing>
	  <property name=3D"left_attach">2</property>
	  <property name=3D"right_attach">3</property>
	  <property name=3D"top_attach">4</property>
	  <property name=3D"bottom_attach">5</property>
	  <property name=3D"x_options">fill</property>
	  <property name=3D"y_options"></property>
	</packing>
      </child>

      <child>
	<widget class=3D"GtkButton" id=3D"button3">
	  <property name=3D"visible">True</property>
	  <property name=3D"can_focus">True</property>
	  <property name=3D"label" translatable=3D"yes">button3</property>
	  <property name=3D"use_underline">True</property>
	  <property name=3D"relief">GTK_RELIEF_NORMAL</property>
	</widget>
	<packing>
	  <property name=3D"left_attach">0</property>
	  <property name=3D"right_attach">1</property>
	  <property name=3D"top_attach">2</property>
	  <property name=3D"bottom_attach">3</property>
	  <property name=3D"x_options">fill</property>
	  <property name=3D"y_options"></property>
	</packing>
      </child>
    </widget>
  </child>
</widget>

</glade-interface>



________________________________________
Mehr Power f=FCr Ihre eMail - mit den neuen Leistungspaketen bei http://w=
ww.epost.de