[gnome-db] mono problems



Hi

I'm trying to get libgnomedb working with mono.
I've attached what I did so far, based on examples from gtk#/libgnomedb
and mergeant.

The code compiles, but it crashes on 
db_browser.Connection = dbc;
I don't know why. I've commented other problems inside the code.

Any help appreciated. I can get monodoc to compile, online doc for
gnomedb# API doesn't work,
I only have gtk#/gnomedb-api.xml, which doesn't work too, e.g.
db_browser.SetConnection(dbc);

I'm quite lost. Is mono-list a better place to pos this?
-- 
Marius Andreiana
Galuna - Solutii Linux in Romania
http://www.galuna.ro
using System;
using Gtk;
using GtkSharp;
using Gnome;
using Glade;
using GnomeDb;
using Gda;


namespace GnomeDbSample {

	public class GnomeDbSample {
		Gnome.Program program;
		Gda.Client client;
		Gda.Connection dbc;
		Gda.DataModel gdm;
		Gda.Command gc;
		
		[Glade.Widget] Gnome.App app;
		[Glade.Widget] GnomeDb.Browser db_browser;
		[Glade.Widget] GnomeDb.List db_list;
		
		public static void Main( string[] args )
		{
			new GnomeDbSample( args );
		}

		public GnomeDbSample( string[] args ) 
		{
			program = new Program( "gnomedb-sample", "1.0", Modules.UI , args );
			XML ui = new Glade.XML( "gnomedb-sample.glade", "app", null );
			ui.Autoconnect( this );
			app.ShowAll ();
			
			program.Run ();
		}


		public void on_app_delete_event (object o, DeleteEventArgs args) 
		{
			program.Quit ();
			args.RetVal = true;
		}
		
		public void on_menu_quit_activate (object o, EventArgs args) 
		{
			program.Quit ();
			//args.RetVal = true;
		}
		/*
		EventNotificationArgs doesn't exist??
		static void Client_Event (object o, EventNotificationArgs args)
		{
			switch (args.Event) {
			case ClientEvent.Error :
				System.Console.WriteLine ("There's been an error");
				break;
			}
		}*/
    
		public void on_connect_clicked (System.Object obj, EventArgs e) 
		{
			GnomeDb.LoginDialog dialog;
			dialog = new GnomeDb.LoginDialog ("Select data source");
				
			if (dialog.Run () == true) {
				if (client == null) {
					client = new Gda.Client ();
					//client.EventNotification += new GdaSharp.EventNotificationHandler (Client_Event);
				}
				
				Console.WriteLine ("trying");
				dbc = client.OpenConnection (dialog.Dsn, dialog.Username, dialog.Password,
							     Gda.ConnectionOptions.ReadOnly);
				if (dbc != null) {
					Console.WriteLine ("Connected");
					//gc = new Gda.Command();
					//gc.SetText( "SELECT * FROM apartamente" );
					
					//not necesary, it's taken from glade
					//db_browser = new GnomeDb.Browser ();
					
					// method doesn't exist, but it's in gnomedb-api.xml
					//db_browser.SetConnection(dbc);
					
					// crashes, why? looks like db_browser it's null
					db_browser.Connection = dbc;
					
				}
			}
			dialog.Destroy ();
		
		}
	}
}
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd";>

<glade-interface>
<requires lib="gnome"/>
<requires lib="gnomedb"/>
<requires lib="bonobo"/>

<widget class="GnomeApp" id="app">
  <property name="visible">True</property>
  <property name="title" translatable="yes">Gnomedb-sample</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>
  <property name="enable_layout_config">True</property>
  <signal name="delete_event" handler="on_app_delete_event" last_modification_time="Thu, 20 Nov 2003 09:52:55 GMT"/>

  <child internal-child="dock">
    <widget class="BonoboDock" id="bonobodock1">
      <property name="visible">True</property>
      <property name="allow_floating">True</property>

      <child>
	<widget class="BonoboDockItem" id="bonobodockitem1">
	  <property name="visible">True</property>
	  <property name="shadow_type">GTK_SHADOW_NONE</property>

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

	      <child>
		<widget class="GtkMenuItem" id="file1">
		  <property name="visible">True</property>
		  <property name="stock_item">GNOMEUIINFO_MENU_FILE_TREE</property>

		  <child>
		    <widget class="GtkMenu" id="file1_menu">

		      <child>
			<widget class="GtkMenuItem" id="separator1">
			  <property name="visible">True</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkImageMenuItem" id="quit1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_EXIT_ITEM</property>
			  <signal name="activate" handler="on_menu_quit_activate" last_modification_time="Thu, 20 Nov 2003 10:00:44 GMT"/>
			</widget>
		      </child>
		    </widget>
		  </child>
		</widget>
	      </child>

	      <child>
		<widget class="GtkMenuItem" id="edit1">
		  <property name="visible">True</property>
		  <property name="stock_item">GNOMEUIINFO_MENU_EDIT_TREE</property>

		  <child>
		    <widget class="GtkMenu" id="edit1_menu">

		      <child>
			<widget class="GtkMenuItem" id="separator2">
			  <property name="visible">True</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkImageMenuItem" id="properties1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_PROPERTIES_ITEM</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkMenuItem" id="separator3">
			  <property name="visible">True</property>
			</widget>
		      </child>

		      <child>
			<widget class="GtkImageMenuItem" id="preferences1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_PREFERENCES_ITEM</property>
			</widget>
		      </child>
		    </widget>
		  </child>
		</widget>
	      </child>

	      <child>
		<widget class="GtkMenuItem" id="help1">
		  <property name="visible">True</property>
		  <property name="stock_item">GNOMEUIINFO_MENU_HELP_TREE</property>

		  <child>
		    <widget class="GtkMenu" id="help1_menu">

		      <child>
			<widget class="GtkImageMenuItem" id="about1">
			  <property name="visible">True</property>
			  <property name="stock_item">GNOMEUIINFO_MENU_ABOUT_ITEM</property>
			</widget>
		      </child>
		    </widget>
		  </child>
		</widget>
	      </child>
	    </widget>
	  </child>
	</widget>
	<packing>
	  <property name="placement">BONOBO_DOCK_TOP</property>
	  <property name="band">0</property>
	  <property name="position">0</property>
	  <property name="offset">0</property>
	  <property name="behavior">BONOBO_DOCK_ITEM_BEH_EXCLUSIVE|BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL|BONOBO_DOCK_ITEM_BEH_LOCKED</property>
	</packing>
      </child>

      <child>
	<widget class="BonoboDockItem" id="bonobodockitem2">
	  <property name="visible">True</property>
	  <property name="shadow_type">GTK_SHADOW_OUT</property>

	  <child>
	    <widget class="GtkToolbar" id="toolbar1">
	      <property name="visible">True</property>
	      <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
	      <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
	      <property name="tooltips">True</property>

	      <child>
		<widget class="button" id="button1">
		  <property name="visible">True</property>
		  <property name="tooltip" translatable="yes">Fişier nou</property>
		  <property name="label">gtk-new</property>
		  <property name="use_stock">True</property>
		</widget>
	      </child>

	      <child>
		<widget class="button" id="button2">
		  <property name="visible">True</property>
		  <property name="tooltip" translatable="yes">Deschide fişier</property>
		  <property name="label">gtk-open</property>
		  <property name="use_stock">True</property>
		</widget>
	      </child>

	      <child>
		<widget class="button" id="button3">
		  <property name="visible">True</property>
		  <property name="tooltip" translatable="yes">Salvează fişier</property>
		  <property name="label" translatable="yes">_Connect</property>
		  <property name="use_underline">True</property>
		  <signal name="clicked" handler="on_connect_clicked" last_modification_time="Thu, 20 Nov 2003 22:35:37 GMT"/>
		</widget>
	      </child>
	    </widget>
	  </child>
	</widget>
	<packing>
	  <property name="placement">BONOBO_DOCK_TOP</property>
	  <property name="band">1</property>
	  <property name="position">0</property>
	  <property name="offset">0</property>
	  <property name="behavior">BONOBO_DOCK_ITEM_BEH_EXCLUSIVE</property>
	</packing>
      </child>

      <child>
	<widget class="GtkVBox" id="vbox1">
	  <property name="visible">True</property>
	  <property name="homogeneous">False</property>
	  <property name="spacing">0</property>

	  <child>
	    <widget class="GnomeDbBrowser" id="db_browser">
	      <property name="visible">True</property>
	    </widget>
	    <packing>
	      <property name="padding">0</property>
	      <property name="expand">True</property>
	      <property name="fill">True</property>
	    </packing>
	  </child>

	  <child>
	    <widget class="GnomeDbList" id="db_list">
	      <property name="visible">True</property>
	    </widget>
	    <packing>
	      <property name="padding">0</property>
	      <property name="expand">True</property>
	      <property name="fill">True</property>
	    </packing>
	  </child>

	  <child>
	    <placeholder/>
	  </child>

	  <child>
	    <placeholder/>
	  </child>

	  <child>
	    <placeholder/>
	  </child>

	  <child>
	    <placeholder/>
	  </child>
	</widget>
      </child>
    </widget>
    <packing>
      <property name="padding">0</property>
      <property name="expand">True</property>
      <property name="fill">True</property>
    </packing>
  </child>

  <child internal-child="appbar">
    <widget class="GnomeAppBar" id="appbar1">
      <property name="visible">True</property>
      <property name="has_progress">True</property>
      <property name="has_status">True</property>
    </widget>
    <packing>
      <property name="padding">0</property>
      <property name="expand">True</property>
      <property name="fill">True</property>
    </packing>
  </child>
</widget>

<widget class="GnomeDbLoginDialog" id="dblogindialog1">
  <property name="border_width">6</property>
  <property name="visible">True</property>
  <property name="title" translatable="yes">Login</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">False</property>
  <property name="destroy_with_parent">False</property>
</widget>

</glade-interface>
MCS=mcs
REFERENCES= glib-sharp gdk-sharp gtk-sharp gnome-sharp gda-sharp glade-sharp gnomedb-sharp System.Data System.Drawing

###

REFS= $(addprefix /r:, $(REFERENCES))

all:
	$(MCS) $(REFS) gnomedb-sample.cs

clean:
	rm -f *.exe *.pdb


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]