2002-09-11 Rodrigo Moya <rodrigo@gnome-db.org>
* gnomedb/Makefile.in: * gnomedb/Application.cs: added class for libgnomedb initialization. * sample/DbClient/GnomeDbClient.cs: new test file for libgnomedb. svn path=/trunk/gtk-sharp/; revision=7373
This commit is contained in:
parent
8b9ee5b8e1
commit
e59f626a81
5 changed files with 148 additions and 2 deletions
|
@ -1,3 +1,10 @@
|
|||
2002-09-11 Rodrigo Moya <rodrigo@gnome-db.org>
|
||||
|
||||
* gnomedb/Makefile.in:
|
||||
* gnomedb/Application.cs: added class for libgnomedb initialization.
|
||||
|
||||
* sample/DbClient/GnomeDbClient.cs: new test file for libgnomedb.
|
||||
|
||||
2002-09-08 Rodrigo Moya <rodrigo@gnome-db.org>
|
||||
|
||||
* makefile:
|
||||
|
|
68
gnomedb/Application.cs
Normal file
68
gnomedb/Application.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
//
|
||||
// GnomeDb.Application.cs - libgnomedb initialization and event loop
|
||||
//
|
||||
// Author: Rodrigo Moya <rodrigo@ximian.com>
|
||||
//
|
||||
// (c) 2002 Rodrigo Moya
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace GnomeDb
|
||||
{
|
||||
/// <summary>
|
||||
/// GnomeDb Application class
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Provides the initialization and event loop iteration related
|
||||
/// methods for the libgnomedb library.
|
||||
/// </remarks>
|
||||
|
||||
public class Application
|
||||
{
|
||||
[DllImport("gnomedb-2")]
|
||||
static extern void gnome_db_init (string app_id, string version, int nargs, IntPtr args);
|
||||
|
||||
public static void Init ()
|
||||
{
|
||||
gnome_db_init ("GnomeDb#", "0.4", 0, new IntPtr(0));
|
||||
}
|
||||
|
||||
public static void Init (string app_id, string version)
|
||||
{
|
||||
gnome_db_init (app_id, version, 0, new IntPtr(0));
|
||||
}
|
||||
|
||||
static extern void gnome_db_init (string app_id, string version, ref int nargs, ref String [] args);
|
||||
|
||||
public static void Init (ref string [] args)
|
||||
{
|
||||
int argc = args.Length;
|
||||
gnome_db_init ("GnomeDb#", "0.4", ref argc, ref args);
|
||||
}
|
||||
|
||||
public static void Init (string app_id, string version, ref string [] args)
|
||||
{
|
||||
int argc = args.Length;
|
||||
gnome_db_init (app_id, version, ref argc, ref args);
|
||||
}
|
||||
|
||||
[DllImport("gnomedb-2")]
|
||||
static extern void gnome_db_main_run (IntPtr init_func, IntPtr user_data);
|
||||
|
||||
public static void Run ()
|
||||
{
|
||||
gnome_db_main_run (IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
|
||||
[DllImport("gnomedb-2")]
|
||||
static extern void gnome_db_main_quit ();
|
||||
|
||||
public static void Quit ()
|
||||
{
|
||||
gnome_db_main_quit ();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ windows:
|
|||
|
||||
linux: gnomedb-sharp.dll
|
||||
|
||||
gnomedb-sharp.dll: generated/*.cs
|
||||
gnomedb-sharp.dll: Application.cs generated/*.cs
|
||||
$(MCS) --unsafe --target library -L ../glib -r glib-sharp.dll -r gtk-sharp.dll -r gnome-sharp.dll -r gda-sharp.dll -o gnomedb-sharp.dll --recurse '*.cs'
|
||||
|
||||
clean:
|
||||
|
|
70
sample/DbClient/GnomeDbClient.cs
Normal file
70
sample/DbClient/GnomeDbClient.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
using Gda;
|
||||
using GnomeDb;
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
|
||||
class GnomeDbClient {
|
||||
|
||||
static Gtk.Window window;
|
||||
static Toolbar toolbar;
|
||||
static Browser browser;
|
||||
static VBox box;
|
||||
static Gda.Client client = null;
|
||||
static Gda.Connection cnc = null;
|
||||
|
||||
static void Main (string [] args)
|
||||
{
|
||||
Gtk.Application.Init ();
|
||||
GnomeDb.Application.Init ("GnomeDbClient", "0.1", ref args);
|
||||
|
||||
/* create the UI */
|
||||
window = new Gtk.Window ("GNOME-DB client");
|
||||
window.DeleteEvent += new DeleteEventHandler (Window_Delete);
|
||||
box = new VBox (false, 0);
|
||||
window.Add (box);
|
||||
|
||||
toolbar = new Toolbar ();
|
||||
toolbar.ToolbarStyle = ToolbarStyle.BothHoriz;
|
||||
toolbar.AppendItem ("Change database", "Select another database to browse", String.Empty,
|
||||
new Gtk.Image (Gtk.Stock.Add, IconSize.LargeToolbar),
|
||||
new SignalFunc (DB_connect));
|
||||
box.PackStart (toolbar, false, false, 0);
|
||||
|
||||
browser = new GnomeDb.Browser ();
|
||||
box.PackStart (browser, true, true, 0);
|
||||
|
||||
window.ShowAll ();
|
||||
GnomeDb.Application.Run ();
|
||||
}
|
||||
|
||||
static void Client_Error (object o, ErrorArgs args)
|
||||
{
|
||||
System.Console.WriteLine ("There's been an error");
|
||||
}
|
||||
|
||||
static void Window_Delete (object o, DeleteEventArgs args)
|
||||
{
|
||||
GnomeDb.Application.Quit ();
|
||||
args.RetVal = true;
|
||||
}
|
||||
|
||||
static void DB_connect (Gtk.Object o)
|
||||
{
|
||||
GnomeDb.LoginDialog dialog;
|
||||
|
||||
dialog = new GnomeDb.LoginDialog ("Select data source");
|
||||
if (dialog.Run () == true) {
|
||||
if (client == null) {
|
||||
client = new Gda.Client ();
|
||||
client.Error += new GtkSharp.ErrorHandler (Client_Error);
|
||||
}
|
||||
|
||||
cnc = client.OpenConnection (dialog.Dsn, dialog.Username, dialog.Password);
|
||||
if (cnc != null)
|
||||
browser.Connection = cnc;
|
||||
}
|
||||
dialog.Destroy ();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
MCS=mcs
|
||||
REFERENCES= glib-sharp gdk-sharp gtk-sharp gnome-sharp System.Data System.Drawing
|
||||
REFERENCES= glib-sharp gdk-sharp gtk-sharp gnome-sharp gda-sharp gnomedb-sharp System.Data System.Drawing
|
||||
|
||||
###
|
||||
|
||||
|
@ -7,6 +7,7 @@ REFS= $(addprefix /r:, $(REFERENCES))
|
|||
|
||||
all:
|
||||
$(MCS) $(REFS) client.cs
|
||||
$(MCS) $(REFS) GnomeDbClient.cs
|
||||
|
||||
clean:
|
||||
rm -f *.exe *.pdb
|
||||
|
|
Loading…
Reference in a new issue