[Mono-docs-list] [Patch] Various GNOME.NET Stuff

Charles Iliya Krempeaux charles@reptile.ca
22 Feb 2003 21:43:12 -0800


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

Hello,

Here's a Patch for:

    monkeyguide/Changelog
    monkeyguide/html/en/gnome/bindings/gnome/hello_world.html
    monkeyguide/html/en/cross_platform/gui.html
    monkeyguide/html/en/gnome/bindings/gnome/gnome.html

(The ChangeLog update is included in the Patch, so you can
see what's been done there.)

I've also attached a GNOME.NET "Adding Contents" tutorial.  This
should be placed at:

    monkeyguide/html/en/gnome/bindings/gnome/adding_contents.html

Could someone submit all this.


See ya

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

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

--=-kx9H3BwjSVTK90SUI23D
Content-Disposition: attachment; filename=MonkeyGuide.diff
Content-Type: text/x-diff; name=MonkeyGuide.diff; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

? html/en/gnome/bindings/gnome/adding_contents.html
Index: Changelog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/monkeyguide/Changelog,v
retrieving revision 1.27
diff -u -r1.27 Changelog
--- Changelog	13 Feb 2003 21:02:49 -0000	1.27
+++ Changelog	23 Feb 2003 05:31:00 -0000
@@ -1,3 +1,14 @@
+2003-02-22  Charles Iliya Krempeaux <charles@reptile.ca>
+	* monkeyguide/html/en/gnome/bindings/gnome/hello_world.html :
+	  Updated it to my latest draft of this tutorial.
+	* html/en/cross_platform/gui.html : It previously called
+	  the GNOME.NET chapter to be chapter 12.  Corrected this
+	  to say Chapter 18.
+	* html/en/gnome/bindings/gnome/gnome.html : Added a link for
+	  "Adding Contents" tutorial, to the tables of contents.
+	* html/en/gnome/bindings/gnome/adding_contents.html : Created
+	  the GNOME.NET "Adding Contents" tutorial.
+
 2003-02-13  Martin Willemoes Hansen
 	* Corrected a bug using [GladeWidget] in=20
           /gnome/bindings/glade/glade.html
@@ -166,4 +177,4 @@
 2002-11-09  Johannes Roith <johannes@jroith.de>
=20
 	* Initial import Martin Willemoes Hansen's tutorial and move
-	  stylesheets to an separate file
\ No newline at end of file
+	  stylesheets to an separate file
Index: html/en/cross_platform/gui.html
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/monkeyguide/html/en/cross_platform/gui.html,v
retrieving revision 1.3
diff -u -r1.3 gui.html
--- html/en/cross_platform/gui.html	19 Feb 2003 19:09:11 -0000	1.3
+++ html/en/cross_platform/gui.html	23 Feb 2003 05:31:01 -0000
@@ -47,9 +47,9 @@
 <li>Glade - Forms, based on XML, that can be changed dynamically
 <li>Glade Interface Builder - Tools to easily create those XML files.=20
 </ul>
-The next step is, to learn about these in <a href=3D"../index.html#gnome">=
chapter 12</a>.
+The next step is, to learn about these in <a href=3D"../index.html#gnome">=
chapter 18</a>.
 <p>
 <div class=3D"copyright">The Mono Handbook - <a href=3D"http://www.go-mono=
.org">&copy; Copyright 2003 by Johannes Roith</a></div>
=20
 </body>
-</html>
\ No newline at end of file
+</html>
Index: html/en/gnome/bindings/gnome/gnome.html
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/monkeyguide/html/en/gnome/bindings/gnome/gnome.html,v
retrieving revision 1.3
diff -u -r1.3 gnome.html
--- html/en/gnome/bindings/gnome/gnome.html	19 Feb 2003 19:09:12 -0000	1.3
+++ html/en/gnome/bindings/gnome/gnome.html	23 Feb 2003 05:31:01 -0000
@@ -21,6 +21,7 @@
 <ul>
=20
 	<li>2.1. <a href=3D"hello_world.html">Hello World in Gnome#</a>
+	<li>2.2. <a href=3D"adding_contents.html">Adding Contents</a>
 </ul>
=20
 </ul>
@@ -45,4 +46,4 @@
=20
 <div class=3D"copyright">The Mono Handbook - <a href=3D"http://www.go-mono=
.org">&copy; Copyright 2002 by Johannes Roith & Martin Willemoes Hansen</a>=
</div>
 </body>
-</html>
\ No newline at end of file
+</html>
Index: html/en/gnome/bindings/gnome/hello_world.html
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/monkeyguide/html/en/gnome/bindings/gnome/hello_world.html,v
retrieving revision 1.3
diff -u -r1.3 hello_world.html
--- html/en/gnome/bindings/gnome/hello_world.html	19 Feb 2003 19:09:12 -000=
0	1.3
+++ html/en/gnome/bindings/gnome/hello_world.html	23 Feb 2003 05:31:01 -000=
0
@@ -1,209 +1,271 @@
-<html>
-<head>
-<title>The Mono Handbook - GNOME.NET - GTK#</title>
-
-<link rel=3D"stylesheet" type=3D"text/css" href=3D"../../../style.css" />
-
-</head>
-<body>
-
-<div class=3D"topframe" width=3D"100%"><a href=3D"../../../index.html"><im=
g src=3D"../../../mg.png" border=3D0></a><a href=3D"../../index.html"><img =
src=3D"../../gn.png" border=3D0></a></div>
-<div class=3D"navbar" width=3D"100%"><a href=3D"../../../index.html">The M=
ono Handbook</a> &gt; <a href=3D"../../index.html">GNOME.NET</a> &gt; C# bi=
ndings &gt; <b>GTK#</b></div>
-<p>
-
-<h1>GNOME#</h1>
-
-<h2>HelloWorld, first try</h2>
-
-HelloWorld in Gnome#:
-
-<pre class=3D"code">
-
-    class Hello
-    {
-        static void Main(string[] args)
-        {
-            Gnome.Program program =3D
-            new Gnome.Program("Hello World", "1.0", Gnome.Modules.UI,
-args);
-
-            Gnome.App app =3D new Gnome.App("Hello World", "Hello World");
-            app.Show();
-=20
-            program.Run();
-        }
-    }
-</pre>
-compile:
-
-<pre class=3D"console">
-mcs helloworld.cs -r gnome-sharp.dll
-</pre>
-It's a bit longer than console hello world and needs some explanation.
-
-In Main() at first you see:
-
-<pre class=3D"code">
-            Gnome.Program program =3D
-            new Gnome.Program("Hello World", "1.0", Gnome.Modules.UI,args)=
;
-</pre>
-This initializes GNOME and is needed in every GNOME Application.  Here
-we are creating a variable of type Gnome.Program, called program.  This
-variable, program, is used to control the GNOME program, as we'll see
-later.
-
-Next we see:
-<pre class=3D"code">
-            Gnome.App app =3D new Gnome.App("Hello World", "Hello World");
-</pre>
-This creates our GNOME Application Window.  (That's what you see on the
-screen.)
-
-We then see:
-<pre class=3D"code">
-           app.Show();
-</pre>
-This makes the GNOME Application Window (that you created with the
-previous line on code) visible on the screen.  With GNOME, things don't
-automatically display themselves unless you explicitly tell them too.
-
-And finally we see:
-<pre class=3D"code">
-            program.Run();
-</pre>
-This make your GNOME program run.  It makes all the magic happen, that
-you don't need to worry about at this moment.  Needless to say though,
-you need to do this to make your GNOME Application work.
-
-
-<h2>HelloWorld, second try</h2>
-
-While the above program compiles and runs, it's doesn't quit, properly.
-You have to exit with CTRL+C.  (Ideally, we want the program to close
-when you press the "X" on the title bar.  Which is what this next
-example does.)
-
-
-<pre class=3D"code">
-
-    class Hello
-    {
-        static Gnome.Program program;
-
-        static void Main(string[] args)
-        {
-            program =3D
-            new Gnome.Program("Hello World", "1.0", Gnome.Modules.UI,
-args);
-
-            Gnome.App app =3D new Gnome.App("Hello World", "Hello World");
-            app.DeleteEvent +=3D new
-GtkSharp.DeleteEventHandler(delete_event);
-            app.Show();
-=20
-            program.Run();
-        }
-
-        static void delete_event(object obj, GtkSharp.DeleteEventArgs
-args)
-        {
-            program.Quit();
-        }
-    }
-
-</pre>
-compile:
-<pre class=3D"console">
-mcs helloworld.cs -r gnome-sharp.dll -r gtk-sharp.dll
-</pre>
-The first change to notice is that the variable program has been moved
-out of Main() and made a (static) class variable.  We see this in the
-line:
-<pre class=3D"code">
-        static Gnome.Program program;
-</pre>
-This was done so we could access it from the delete_event function,
-which we will talk about later.
-<p>
-The next difference we is in the Main() method, and is:
-<pre class=3D"code">
-            app.DeleteEvent +=3D new
-GtkSharp.DeleteEventHandler(delete_event);
-</pre>
-This makes it so that when the "X" button on the title bar is pressed,
-the function delete_event is called.  Technically, when the "X" button
-is pressed, the program receives a DeleteEvent, which is what you see in
-the code above.
-<p>
-The final difference that you see is:
-<pre class=3D"code">
-        static void delete_event(object obj, GtkSharp.DeleteEventArgs
-args)
-        {
-            program.Quit();
-        }
-</pre>
-This is the function that is called when the application receives a
-DeleteEvent.  I.e., when the user clicks the "X" button on the title
-bar.  As you can hopefully see, when this function is called, the
-program will quit.
-
-<p>
-
-<h2>HelloWorld, third try</h2>
-
-While the above code functioned properly, and did what we wanted, it was
-kind of sloppy.  The sloppyness came from having to make the program
-variable a (static) class variable.  A much more elegant way of doing
-the same thing involves using subclassing (also called inheritance) to
-accomplish the same thing.  Which can be seen in the example below.
-<pre class=3D"code">
-    class Hello
-        : Gnome.Program
-    {
-        Hello(string[] args)
-            : base("Hello World", "1.0", Gnome.Modules.UI, args)
-        {=20
-            // Nothing here.
-        }
-
-        static void Main(string[] args)
-        {
-
-            Hello hello =3D new Hello(args);
-
-            hello.run();
-        }
-
-        void delete_event(object obj, GtkSharp.DeleteEventArgs args)
-        {
-            this.Quit();
-        }
-
-        void run()
-        {
-            Gnome.App app =3D new Gnome.App("Hello World", "Hello World");
-            app.DeleteEvent +=3D new
-GtkSharp.DeleteEventHandler(delete_event);
-            app.Show();
-=20
-            this.Run();
-        }
-    }
-</pre>
-
-compile:
-<pre class=3D"console">
-mcs helloworld.cs -r gnome-sharp.dll -r gtk-sharp.dll
-</pre>
-#### I'll add an explanation of this later today.
-
-
-
-
-<p>
-
-<div class=3D"copyright">The Mono Handbook - <a href=3D"http://www.go-mono=
.org">&copy; Copyright 2002 by Johannes Roith & Martin Willemoes Hansen</a>=
</div>
-
-</body>
-</html>
+<html>
+
+    <head>
+        <title>The Mono Handbook - GNOME.NET - GNOME#</title>
+        <link rel=3D"stylesheet" type=3D"text/css" href=3D"../../../style.=
css" />
+    </head>
+
+
+    <body>
+
+        <div class=3D"topframe" width=3D"100%"><a href=3D"../../../index.h=
tml"><img src=3D"../../../mg.png" border=3D0></a><a href=3D"../../index.htm=
l"><img src=3D"../../gn.png" border=3D0></a></div>
+        <div class=3D"navbar" width=3D"100%"><a href=3D"../../../index.htm=
l">The Mono Handbook</a> &gt; <a href=3D"../../index.html">GNOME.NET</a> &g=
t; C# bindings &gt; <b>GNOME#</b></div>
+
+        <p></p>
+
+        <h1>GNOME.NET</h1>
+
+        <p>
+            This tutorial gets you started with writing GNOME.NET programs=
.=20
+        </p>
+
+        <h2>HelloWorld, first try</h2>
+
+        <p>
+            <code>helloworld1.cs</code>:
+        </p>
+
+<pre class=3D"code">
+    class HelloWorld
+    {
+            static void Main(string[] args)
+            {
+                    Gnome.Program program =3D
+                    new Gnome.Program("Hello World", "1.0", Gnome.Modules.=
UI, args);
+
+                    Gnome.App app =3D new Gnome.App("Hello World", "Hello =
World");
+                    app.Show();
+=20
+                    program.Run();
+            }
+    }
+</pre>
+
+        <p>
+            compile:
+        </p>
+
+<pre class=3D"console">
+mcs helloworld.cs -r gnome-sharp.dll
+</pre>
+
+        <p>
+            run:
+        </p>
+
+<pre class=3D"console">
+mono helloworld1.exe
+</pre>
+
+
+        <p>
+            It's a bit longer than console Hello World and needs some expl=
anation.
+        </p>
+
+        <p>
+            In <code>Main()</code> at first you see:
+        </p>
+
+
+<pre class=3D"code">
+                    Gnome.Program program =3D
+                    new Gnome.Program("Hello World", "1.0", Gnome.Modules.=
UI, args);
+</pre>
+
+
+        <p>
+            This initializes GNOME and is needed in every GNOME applicatio=
n.  Here we are
+            creating a variable of type <code>Gnome.Program</code>, called=
 <code>program</code>.
+            This variable, <code>program</code>, is used to control the GN=
OME program, as we'll see later.
+        </p>
+
+        <p>
+            Next we see:
+        </p>
+
+<pre class=3D"code">
+                    Gnome.App app =3D new Gnome.App("Hello World", "Hello =
World");
+</pre>
+
+
+        <p>
+            This creates our GNOME application window.  (That's what you s=
ee on the screen.)
+        </p>
+
+        <p>
+            We then see:
+        </p>
+
+<pre class=3D"code">
+                    app.Show();
+</pre>
+
+        <p>
+           This makes the GNOME Application Window (that you created with =
the previous line of code)
+           visible on the screen.  With GNOME, things don't automatically =
display themselves unless
+           you explicitly tell them too.
+        </p>
+
+        <p>
+            And finally we see:
+        </p>
+
+<pre class=3D"code">
+                    program.Run();
+</pre>
+
+        <p>
+            This make your GNOME program <i>run</i>.  It makes all the mag=
ic happen, that you don't
+            need to worry about at this moment.  Needless to say though, y=
ou need to do this to make
+            your GNOME Application work.
+        </p>
+
+
+
+        <h2>HelloWorld, second try</h2>
+
+        <p>
+            While the above program compiles and runs, it's doesn't quit, =
properly. You have to exit
+            by pressing CTRL+C.  (Ideally, we want the program to close wh=
en you press the "X" on the
+            title bar.  Which is what this next example does.)
+        </p>
+
+        <p>
+            <code>helloworld2.cs</code>:
+        </p>
+
+<pre class=3D"code">
+    class HelloWorld
+    {
+            static void Main(string[] args)
+            {
+                    Gnome.Program program =3D
+                    new Gnome.Program("Hello World", "1.0", Gnome.Modules.=
UI, args);
+
+                    MyMainWindow app =3D new MyMainWindow(program);
+                    app.Show();
+=20
+                    program.Run();
+            }
+    }
+
+
+
+    class MyMainWindow
+            : Gnome.App
+    {
+            Gnome.Program program;
+
+            public MyMainWindow(Gnome.Program gnome_program)
+                    : base("Hello World", "Hello World")
+            {
+                    this.program =3D gnome_program;
+
+                    this.DeleteEvent +=3D new GtkSharp.DeleteEventHandler(=
delete_event);
+            }
+
+            private void delete_event(object obj, GtkSharp.DeleteEventArgs=
 args)
+            {
+                    this.program.Quit();
+            }
+    }
+</pre>
+
+
+        <p>
+            compile:
+        </p>
+
+<pre class=3D"console">
+mcs helloworld2.cs -r gnome-sharp.dll -r gtk-sharp.dll
+</pre>
+
+        <p>
+            run:
+        </p>
+
+<pre class=3D"console">
+mono helloworld2.exe
+</pre>
+
+        <p>
+            The first thing you probably have noticed is that there are no=
w two classes.
+            The first class -- <code>HelloWorld</code> -- is almost identi=
cal to the version
+            in the previous example.  Except for the following line:
+        </p>
+
+<pre class=3D"code">
+                    MyMainWindow app =3D new MyMainWindow(program);
+</pre>
+
+        <p>
+            You can compare this to the equivalent line in the previous co=
de:
+        </p>
+
+<pre class=3D"code">
+                    Gnome.App app =3D new Gnome.App("Hello World", "Hello =
World");
+</pre>
+
+        <p>
+            The difference is that app is no longer an instance of <code>G=
nome.App</code>,
+            as it was in the first example <code>helloworld.cs</code>. But=
 is now an instance
+            of a new class that we just created: <code>MyMainWindow</code>=
.  (Also, what we
+            pass to the constructor of <code>MyMainWindow</code> is differ=
ent from what we
+            passed to the constructor of <code>Gnome.App</code>.)
+        </p>
+
+        <p>
+            In other words, the only difference (in this class) is that we=
 are using a different
+            class for our window.
+        </p>
+
+        <p>
+            Now let us take a look at our <code>MyMainWindow</code> class.
+        </p>
+
+        <p>
+            We created this new class because Gnome.App did not do exactly=
 what we wanted it to.
+            We want our application window to close when the "X" on the ti=
tle bar is pressed.
+            Which is what the code in the <code>MyMainWindow</code> class =
accomplishes.
+        </p>
+
+        <p>
+            The important thing to focus on is this line:
+        </p>
+
+<pre class=3D"code">
+                    this.DeleteEvent +=3D new GtkSharp.DeleteEventHandler(=
delete_event);
+</pre>
+
+        <p>
+            This makes it so that when the "X" button on the title bar is =
pressed, the
+            function <code>delete_event</code> is called.  Technically, wh=
en the "X" button is pressed,
+            the program receives a <code>DeleteEvent</code>, which is what=
 you see in the code above.
+        </p>
+
+        <p>
+            The next thing to focus on is the definition of <code>delete_e=
vent</code>:
+        </p>
+
+<pre class=3D"code">
+            private void delete_event(object obj, GtkSharp.DeleteEventArgs=
 args)
+            {
+                    this.program.Quit();
+            }
+</pre>
+
+        <p>
+            This is the function that is called when the application recei=
ves a <code>DeleteEvent</code>.
+            I.e., when the user clicks the "X" button on the title bar.  A=
s you can hopefully see, when
+            this function is called, the program will quit.
+        </p>
+
+        <p>
+            Which is what we wanted.
+        </p>
+
+
+    </body>
+
+</html>
+

--=-kx9H3BwjSVTK90SUI23D
Content-Disposition: attachment; filename=adding_contents.html
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; name=adding_contents.html; charset=ISO-8859-1

<html>

    <head>
        <title>The Mono Handbook - GNOME.NET - GNOME#</title>
        <link rel=3D"stylesheet" type=3D"text/css" href=3D"../../../style.c=
ss" />
    </head>


    <body>

        <div class=3D"topframe" width=3D"100%"><a href=3D"../../../index.ht=
ml"><img src=3D"../../../mg.png" border=3D0></a><a href=3D"../../index.html=
"><img src=3D"../../gn.png" border=3D0></a></div>
        <div class=3D"navbar" width=3D"100%"><a href=3D"../../../index.html=
">The Mono Handbook</a> &gt; <a href=3D"../../index.html">GNOME.NET</a> &gt=
; C# bindings &gt; <b>GNOME#</b></div>

        <p></p>

        <h1>GNOME.NET</h1>

        <p>
            In the previous GNOME.NET tutorial, we learnt how to make a GNO=
ME application window.
            However, other than being a good example to teach us GNOME.NET,=
  that window was pretty
            useless, considering it didn't really do anything.
        </p>

        <p>
            Any real application will have stuff inside the window.  In thi=
s tutorial, we will show
            you how to give your window some contents.=20
        </p>

        <h2>Adding Contents</h2>

        <p>
            <code>button.cs</code>:
        </p>

<pre class=3D"code">
    class MainClass
    {
            static void Main(string[] args)
            {
                    Gnome.Program program =3D
                    new Gnome.Program("Hello World", "1.0", Gnome.Modules.U=
I, args);

                    MyMainWindow app =3D new MyMainWindow(program);
                    app.Show();
=20
                    program.Run();
            }
    }



    class MyMainWindow
            : Gnome.App
    {
            Gnome.Program program;

            public MyMainWindow(Gnome.Program gnome_program)
                    : base("Hello World", "Hello World")
            {
                    this.program =3D gnome_program;

                    this.DeleteEvent +=3D new GtkSharp.DeleteEventHandler(d=
elete_event);

                    this.Contents =3D new Gtk.Button("Hello World");
            }

            private void delete_event(object obj, GtkSharp.DeleteEventArgs =
args)
            {
                    this.program.Quit();
            }
    }
</pre>

        <p>
            compile:
        </p>

<pre class=3D"console">
mcs button.cs -r gnome-sharp.dll
</pre>

        <p>
            run:
        </p>

<pre class=3D"console">
mono button.exe
</pre>

        <p>
            Except for one line, this code is virtually exactly like the <c=
ode>helloworld2.cs</code>
            source code from the previous tutorial.  The line that adds the=
 button is:
        </p>

<pre class=3D"code">
                    this.Contents =3D new Gtk.Button("Hello World");
</pre>


        <p>
            The magic comes from the <code>Contents</code> property of <cod=
e>Gnome.App</code>
            (and all of <code>Gnome.App</code>'s subclasses, like <code>MyM=
ainWindow</code>).
        </p>

        <p>
            What you assign to this goes inside the window.  For example, I=
 could put an image in there with:
        </p>

<pre class=3D"code">
                    Gtk.Image image =3D new Gtk.Image();

                    // put something in the image here.

                    this.Contents =3D image;
</pre>

        <p>
            I could put in a <code>Gnome.Canvas</code> with.
        </p>

<pre class=3D"code">
                    this.Contents =3D new Gnome.Canvas();
</pre>

        <p>
            (Hopefully you get the idea.)  If you want to put something ins=
ide of
            a <code>Gnome.App</code> (or one of its subclasses), then assig=
n it to
            its <code>Contents</code> property.
        </p>


    </body>

</html>


--=-kx9H3BwjSVTK90SUI23D--