[Gtk-sharp-list] diff: gnome/Program.custom

Charles Iliya Krempeaux charles@reptile.ca
13 Feb 2003 12:06:40 -0800


--=-hJtoxqd8emw5MlxHGKT+
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hello,

Here's an update for the "gnome/Program.custom" file.  It
makes "Run()" and "Quit()" virtual methods (so that you
can override them).

(You many or may not want to commit it to the Gtk# CVS repository.)

This is useful for doing object oriented development.  By making
those methods virtual, you can override them, and make "drop in"
replacements for Gnome.Program.  (I.e., you get polymorphism.)

I ran it through "diff" and a diff file, for "gnome/Program.custom"
is attached to this message, and named "Program.custom.diff".  And,
for your convenience, the whole (updated) file is attached to this
message too.  (And, of course, has been named "Program.custom".)


See ya

-- 
     Charles Iliya Krempeaux, BSc
     charles@reptile.ca

________________________________________________________________________
 Reptile Consulting & Services    604-REPTILE    http://www.reptile.ca/

--=-hJtoxqd8emw5MlxHGKT+
Content-Disposition: attachment; filename=Program.custom.diff
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-diff; name=Program.custom.diff; charset=ISO-8859-1

69c69
< public void Run ()
---
> public virtual void Run ()
74c74
< public void Quit ()
---
> public virtual void Quit ()

--=-hJtoxqd8emw5MlxHGKT+
Content-Disposition: attachment; filename=Program.custom
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=Program.custom; charset=ISO-8859-1

//
// Gnome.Program.custom - Gnome Program class customizations
//
// Author: Rachel Hestilow <hestilow@ximian.com>
//
// Copyright (C) 2002 Rachel Hestilow
//
// This code is inserted after the automatically generated code.
//
       =20
[DllImport("gobject-2.0")]
static extern void g_type_init ();

[StructLayout(LayoutKind.Sequential)]
struct PropertyArg {
        public string name;
        public IntPtr value;
}

[DllImport("gtksharpglue")]
static extern System.IntPtr
gtksharp_gnome_program_init (string app_id, string app_version, ref ModuleI=
nfo module, int argc, string[] argv, int
nargs, PropertyArg[] args);

public Program (string app_id, string app_version, ModuleInfo module,
                string[] argv, params object[] props)
{
        int nargs =3D props.Length / 2;
        PropertyArg[] args =3D new PropertyArg[nargs];
        GLib.Value[] vals =3D new GLib.Value[nargs];
        string[] new_argv =3D new string[argv.Length + 1];
       =20
        g_type_init ();

        for (int i =3D 0; i < nargs; i++)
        {
                args[i].name =3D (string) props[i * 2];
                GLib.Value value;
                // FIXME: handle more types
                object prop =3D props[i * 2 + 1];
                Type type =3D prop.GetType ();
                if (type =3D=3D "hello".GetType ())
                        value =3D new GLib.Value ((string) prop);
                else if (type =3D=3D true.GetType ())
                        value =3D new GLib.Value ((bool) prop);
                else
                        value =3D null;
                vals[i] =3D value;
                args[i].value =3D value.Handle;=20
        }
       =20
        /* FIXME: Is there a way to access this in .NET? */=20
        new_argv[0] =3D app_id;
        Array.Copy (argv, 0, new_argv, 1, argv.Length);
        Raw =3D gtksharp_gnome_program_init (app_id, app_version, ref modul=
e, new_argv.Length, new_argv, nargs, args);

        //
        // Dynamically reset the signal handlers, because Gnome overwrites =
them
        //
        Type mono_runtime_type =3D Type.GetType ("Mono.Runtime");
        if (mono_runtime_type !=3D null){
                object [] iargs =3D new object [0];
                System.Reflection.MethodInfo mi =3D mono_runtime_type.GetMe=
thod ("InstallSignalHandlers");
       =20
                mi.Invoke (null, iargs);
        }
}

public virtual void Run ()
{
        Gtk.Application.Run ();
}

public virtual void Quit ()
{
        Gtk.Application.Quit ();
}




--=-hJtoxqd8emw5MlxHGKT+--