Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell...

60
Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. [email protected]

Transcript of Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell...

Page 1: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

Mono: Rapid GUI Application Development On Linux

Karl BunnellSoftware Engineer Consultant, Novell Inc. [email protected]

Page 2: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.2

one Net: Information without boundaries…where the right people are connected with the right information at the right time to make the right decisions.

The one Net vision

Novell exteNd™

Novell Nsure™

Novell Nterprise™

Novell NgageSM

:

:

:

:

Page 3: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.3

The one Net vision

Novell Nterprise is an innovative family of products which give you the power to enable and manage the constant interaction of people with your business systems — regardless of who they are or where they are.

Novell Nterprise™

Novell exteNd™

Novell Nsure™

Novell Nterprise™

Novell NgageSM

:

:

:

:

Page 4: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.4

Agenda

• .NET Overview

• Mono Overview

• Lab Exercises that implement simple technologies on Linux Platform

Page 5: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.5

What is .NET?

• Microsoft .NET is a “vision”, or marketing strategy, as well as new technologies

• A brand applied to:• Several new technologies

• .NET Framework – Mono is an implementation of the .NET Framework

• New releases of old technologies • Several old technologies

• Most significant new technologies• Common Language Runtime (CLR) /

Common Language Infrastructure (CLI) • Web Services

Page 6: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.6

.NET Platform

Visual Studio .NET

.NETEnterpris

eServers

.NET Framework.NET

Services

Operating Systems, desktops and devices

Page 7: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.7

The .NET Framework

• Managed, type–safe environment for the development and execution of applications.

• Previously only available on Windows, now available on Linux. The .NET Framework consists of the following two components:

• Common Language Runtime (CLR)• Manages code execution• Provides core services• Enforces safety and security restrictions

• .NET Framework class library• Collection of useful and reusable types that

integrate with CLR

Page 8: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.8

.NET Framework

Web Services Windows Forms

Web Forms

Data and XML Classes

Framework Base Classes

Common Language Runtime

Windows/Linux Platform

Page 9: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.9

The .NET Framework Benefits

• Language Independence• Write an application in any supported language (C#,

Monobasic, etc) and its classes can be shared with an application written in any other supported language.

• Platform Independence• Like Java, .NET code is not compiled to machine code

but to an intermediate byte format (CIL). Hence, anywhere the interpretive engine exists the application can run.

• Class Library• Extensive class library that includes support for

many/most of the tasks needed for application development.

Page 10: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.10

The .NET Framework Benefits (cont.)

• C# Language• Effective language patterned after Java, so it contains

many of the strengths of both Java and C++

• VB.NET Language• More full-featured than previous versions of Basic. Basic

classes can be used from other languages like C#

• Web Applications• ASP.NET delivers on the promise of Web Services with

implementation of technologies such as WSDL, SOAP, etc.

Page 11: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.11

The .NET Framework Class Library

• Object-oriented collection of reusable classes that provide many of the services needed to write an application

• All Framework classes are under the “System” namespace

• System.Collections• System.Data – database access and manipulation• System.Data.SQLClient – MS SQL Server specific• System.IO – File system handling• System.Security – permissions, cryptography, etc.• System.Windows.Forms – types for windows apps.

Page 12: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.12

The .NET Framework Namespace

• Logical, Hierarchical grouping of related classes• Similar to a ‘package’ in Java

• Access namespaces with:• Imports – Visual Basic .NET• using – C#

• using System.Windows.Forms

Page 13: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.13

Assemblies

• Physical packaging of the class libraries• Typically built as a ‘.dll’ file.

• However, don’t confuse them as being a Win32 shared library

• An Assembly Manifest is Metadata that contains information about what an assembly contains

• Assemblies name and version• Types exposed by the assembly• Other assemblies required by the assembly• Security instructions (permissions required and

denied)

• .NET runtime, tools, compilers etc. can all use this ‘Metadata’ to find out all they need to know about .NET resources.

• Used for Reflection

Page 14: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.14

Common Language Runtime (CLR)

• Provides services to .NET applications (similar to JVM in Java)

• A set of libraries available to all .NET applications• Manages memory• Thread execution• Code execution• Type safety verification• Compilation (Just In-time Compiler)

Page 15: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.15

Common Language Infrastructure (CLI)

• Subset of the CLR submitted to the European Computer Manufacturers Association (ECMA) standards organization so that a third-party vendor could implement a CLR for a platform other than Windows.

• Shared Source CLI (SSCLI) is a working implementation of the ECMA CLI.

• Submitted for standardization:• C#• Semantics for metadata• Microsoft Intermediate Language (MSIL)• Parts of the .NET framework class library

Page 16: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.16

Managed Code

Code that is executed by the CLR. Managed code provides information (i.e., metadata) to allow the CLR to locate methods encoded in assembly modules, store and retrieve security information, handle exceptions, and walk the program stack. Managed code can access both managed data and unmanaged data. Managed data—Memory that is allocated and released by the CLR using Garbage Collection. Managed data can only be accessed by managed code.

Web Definition:

Page 17: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.17

.NET Portable Execution File

• Executable files must conform to the publicly available file format called the “PE file format”, which is a derivative of the Microsoft Common Object File Format (COFF), also publicly available.

• .NET extends this file with a CLR Header and Data section that allows the CLR to execute/manage the application.

.NETPE File

Common Language Runtime

.NETPE File

.NETPE File

Page 18: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.18

The Microsoft Intermediate Language (MSIL)

• Intermediate format that runs in the CLR• Not a machine specific binary but an intermediate

representation• Must be converted by a .NET Framework just-in-time

(JIT) compiler to native code

Page 19: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.19

MSIL Tools

• MSIL Assembler (Ilasm.exe) • Generates executable from MSIL

• MSIL Disassembler (Ildasm.exe) • Creates MSIL code from executable

• Native Image Generator Tool (Ngen.exe) • Compiles MSIL to machine code in lieu of JIT compiler

Page 20: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.20

MSIL “Hello World”

• Assembler directives begin with a period

• MSIL instructions: lines 8, 9 and 10

/* This is an MSIL comment */

.assembly extern mscorlib {}

.assembly hello {}

.method static public void main() il managed {

.entrypoint

.maxstack 1

ldstr “Hello World!”

call void [mscorlib]System.Console::WriteLine( class System.String )

ret

}

Page 21: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.21

.NET Application Construction

• Write application in one of the many supported languages (C#, VB, C++, etc).

• All these languages conform to the Common Language Specification (CLS)

• Compile application into Microsoft Intermediate Language (MSIL or IL)

• Execute code within the CLR• Since all compilers, tools and the CLR use the

Common Type System (CTS) data can be transferred between applications developed in different languages.

Page 22: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

22

Unmanaged Component

C++C#VB

Compiler

Compiler

Compiler

Source Code

Managed Code

Assembly Code

Assembly Code

Assembly Code

Common Language Runtime

JIT Compiler

Native Code

Operating System Services

.NET Execution Model

Page 23: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.23

Common Type System (CTS)

• .NET supports language integration, which means that you can inherit classes, catch exceptions, etc. across languages. This is possible because all .NET components must adhere to the CTS standard.

• All objects derive from root object System.Object

• CTS is a type system shared by compilers, tools and the CLR

• CTS supports two different types:• Reference (heap allocation)• Value (stack allocation)

CTS

Page 24: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.24

Common Language Specification (CLS)

• The goal of .NET is to support language integration

• BUT - not all languages are the same• Some are case sensitive, others are not, etc.

• CLS is a specification that identifies a base set of rules that are required for language integration.

• Languages must support CLS to be compliant with the .NET Framework

• Essentially CLS is a contract between language designers and the .NET Framework

CLS

Page 25: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.25

NNET Languages

• The CLR was designed to support multiple languages

C#VBC++J#

Page 26: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.26

Mono

• An Open Source .NET Framework Implementation.

• Effort lead by Ximian®, launched in July 2001• ~100 contributors, ~30 very active

• Status today:• CLI compliant execution system.• Just-in-time compiler on x86 systems.• Multi-platform (Linux, Solaris, BSD, Windows)• C# compiler.• Class Libraries:

• Most core functionality done.• Various degrees of readiness at higher levels.

Page 27: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.27

Project Background

Bring Open Source to the Desktop.The GNOME project:

Unix model vision: CORBA and Bonobo.•Any programming language•Small tools/components

• A desktop for Linux.• A development platform

• A suite of productivity applications• Started in 1997• Mostly developed in C, Python and Perl.• Avoid C++ as much as possible.

Scope:

Page 28: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.28

• We ran into various problems:• Old development tools, C-based

• Learning curve too hard for new programmers.

• Costly to develop.

• Gap between release and support in languages.

Evolving GNOME

Language bindings:•Lag between release and deployment•Good for fine control.•Multiple languages supported

CORBA/Bonobo:•Solves release/deployment•Coarse interfaces.•Bonobo was complicated

Page 29: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.29

• Evolution• Outlook replacement for Linux.

• Multi-threaded, multi-process, multi-component.

• Most standard compliant mailer/calendar/contact system.

• 800k lines of code.• 2 years, 17 programmers & a lot of

money.• Slow to develop, debug, improve,

innovate.

Example Case

• The Future:• Enable scripting, allow

plugins• Reduce cost of

development

Page 30: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.30

The .NET Framework

• What we were looking for• For Gnome, For Ximian

• Core standardized (VES + C# language)• A virtual execution system (VES)

• Multiple language support• Common subset for interop: CTS

• A large class library• A new programming language: C#• VES designed to interoperate with legacy code

Page 31: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.31

Mono Project Scope

• A change of direction• Desktop -> Platform

• Bring the .NET Framework to Unix• Allows easy migration of Windows to Unix.

• Develop with Visual Studio, deploy on Linux.

• Gives us much needed room to breathe.• Goals:

• Virtual Execution System• C# compiler• Class Libraries compatible with .NET Framework

Page 32: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

32

Mono Runtime

Mono Development Tools:C# Compiler, Debugger, Profiling.

.NET Classes:•Core + XML•ADO.NET•ASP.NET

Mono Classes:•Gtk#: Gtk, Gnome, A11n, Media•PEToolkit

JIT, Loader, Verifier Threads, I/O

GC

Native Platform (x86, SPARC, PPC, StrongARM, S390)

Page 33: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.33

Lab: Install Mono Runtime

• Source Install• At minimum you need:

• Pkg-config:• http://www.freedesktop.org/software/pkgconfig

• Glib 1.3: • ftp://ftp.gtk.org/pub/gtk/v1.3/glib-1.3.12.tar.gz

• Source Tarball (e.g. mono-0.28-1.src.rpm )• http://www.go-mono.org/download.html• Then: autogen.sh ; ./configure ; make ; make install

• RPM (Red Hat Package Manager) Install• Binary rpm (e.g. mono-0.28-

1.ximian.6.1.i386.rpm )• http://www.go-mono.org/download.html• rmp -ih mono-0.28-1.ximian.6.1.i386.rpm

• Use RedCarpet

There are a few ways to install the Mono runtime:

Page 34: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.34

Use RedCarpet to Install Mono

1. From the Ximian desktop, selectPrograms|System Tools|Software Update

2. Select the “Available Software” tab

3. In the “All Subscribed Channels” list select“mono”

4. Select all the displayed packages by clicking in the “Action” section beside each package.

5. Click the “Run Now” button. 5a. Click “Continue” when prompted

6. Test mono installation by running mono doc from a terminal window 6a. export MONO_PATH=/opt/gnome2/lib

6b. monodoc

Page 35: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.35

C#.NET Programming Language

An object-oriented and type-safe programming language supported by Microsoft for use with the .NET Framework. C# (pronounced "see-sharp") was created specifically for building enterprise-scale applications using the .NET Framework. It is similar in syntax to both C++ and Java and is considered by Microsoft as the natural evolution of the C and C++ languages. C# was created by Anders Hejlsberg (author of Turbo Pascal and architect of Delphi), Scot Wiltamuth, and Peter Golde. C# is defined by the standard ECMA-334

Web Definition:

Page 36: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.36

C# vs. JavaSimilarities

1. Single rooted class hierarchya) C# - System.Object

b) Java – java.lang.Object

2. Mostly similar keywords

3. Managed Execution Environments (CLR, JVM)

4. Heap based classes and Garbage Collection

5. Subarrays of multi-dimensional arrays can vary in size

6. All methods must be a member of a class (unlike C)

7. Interface support

8. Strings are immutable

9. Unextendable classes (sealed, final)

10. Exceptions are thrown and caught

11. Class member initialization

Page 37: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.37

C# vs. JavaSlight Differences

1. C# - Main vs. Java - main (C# Main can have void parameter)

2. Inheritance (: vs. extends and implements)

3. C#’s ‘is’ vs. Java’s ‘instanceof’

4. Namespaces vs. packages (in C# namespace names do not identify directory

5. Constructors, C# destructors vs. Java finalizers

6. Synchronizations of methods and code blocks (a) Synchronized vs. lock (code blocks) (b) Java – public synchronized void ourMethod(void)

7. C# - [MethodImpl (MethodImplOptions.Synchronized)]

8. Public void OurMethod(void)

9. Access Modifiers: private(default) – private, public – public, internal -protected(default), protected – N/A, internal protected – N/A)

10. Const (compile time), readonly(run time) vs. final(both)

Page 38: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.38

C# vs. JavaSlight Differences (cont.)

1. Array declarations (int iArray[] won’t compile in C#)

2. base vs. super for calling base class constructor

3. C# has static nested class but no inner class equivalent

4. Threads – Exist in both but instantiated and run differently

5. C# has no fall-through in switch statement

6. Assemblies vs. JAR’s

7. Collections (Java is considered to be more sophisticated)

8. Documentation – XML vs. HTML

9. Multiple classes in a single file (multiple public classes)

10. Importing Libraries (import vs. using, -classpath vs. /r)

11. Cross Language Interoperability (JNI vs. CLS)

Page 39: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.39

C# vs. JavaUnique Things in Either C# or Java

C# - System.IDisposable interface

C# - Delegates

C# - Enumerations

C# - Value types (may be stack based in C#)

C# - as operator for dynamic casting

C# - foreach statement

C# - attributes

C# - Pass by reference

• Java – Checked exceptions

• Java - Cross platform portability (mono dealing with this)

Page 40: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.40

Lab: Become Familiar with C#

• Using monodoc read the sections indicated by the red box --->

• What c# construct would you use to organize c# classes? (hint: similar to Java packages)

• When you compile a c# application what does it compile to?

• What tool do you use to compile a c# application?

• What tool do you use to run a c# application?

Page 41: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.41

Lab: Compile a C# Application

• Using monodoc navigate to ->• Read the section on “Using the

C# Compiler” and complete the associated exercise.

• At the cmd prompt type: monodis hellocs.exe --output=hellocs.il

• At the cmd prompt type: vi hellocs.il

• What is the hellocs.il file?

Exercise:

Page 42: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.42

Objective: Compile VBasic Application

• Using monodoc navigate to ->

• Read the section on “Using the VB.NET Compiler” and complete the associated exercise.

• At the cmd prompt type: monodis hellovb.exe - output=hellovb.il

• Compare hellovb.il to hellocs.il from the previous exercise.

• Are they the same? What are the differences?

Exercise:

Page 43: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.43

Objective: Compile IL Code

• Using monodoc read the sections indicated by the red box -->

• At the cmd prompt type: mono/usr/bin/ilasm.exe --help

• Use ilasm.exe to compile hellocs.il & hellovb.il. (hint: ilasm.exe is a .Net application)

• What specification enables the support of multiple programming languages within .Net?

Exercise:

Page 44: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

44

Mono Runtime

Mono Development Tools:C# Compiler, Debugger, Profiling.

.NET Classes:•Core + XML•ADO.NET•ASP.NET

Mono Classes:•Gtk#: Gtk, Gnome, A11n

JIT, Loader, Verifier Threads, I/O

GC

Native Platform (x86, SPARC, PPC, StrongARM, S390)

Media•PEToolkit

Page 45: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.45

GUI classes: Gtk#

• Gtk# is Ximian's main interest

• For Gnome Purposes

• It is also easy, most stuff is already there.

• We have plenty of in-house expertise.

• Benefits our products directly.

• Works on Windows as well.

• Mphoto.

Page 46: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.46

Windows.Forms

• Current strategy:• Use WineLib to implement it.

• Reduces time of development.• Need it to be Wndproc/PInvoke compatible.

• Implement alternate render engines in Wine:• Gtk on X11• Cocoa on MacOS X

• Reasons:• Major interest in getting it done.• Third party developers focused on it.• Second most requested Mono feature.

Page 47: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.47

ASP.NET WebForms

• Component-based Web programming.

• Most requested Mono feature.• Develop on Windows, deploy on Unix.

• ASP.NET: XSP parser.• Finished the HttpRuntime infrastructure recently.• Can run as a cgi-bin in most servers.• Deep integration with Apache coming soon.

• Limited to C# for the server-side-scripts

Page 48: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.48

What is gtk+…

“GTK+ is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets…”

gtk.org

Page 49: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.49

GTK+ Libraries

GTK+ is based on three libraries

1 GLiba. A low-level core library that provides data structure

handling for C, portability wrappers, and interfaces for such runtime activity as an event loop, threads, dynamic loading, etc.

Pangoa. A library for layout and rendering of text

ATKa. A library that provides a set of interfaces for

accessibility. It is used by screen readers, and other devices

2

3

Page 50: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.50

GTK+ Uses Widgets…

Widget is an X Windows term for any user interface element.

• Buttons

• Windows

• Labels

• http://devolper.gnome.org/doc/API/gtk/gtkobj

Page 51: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.51

GTK+ Basics…

• Container Widgets• A widget that can ‘contain’ one other widget. For

example a button can contain a label, a window might contain a button

• Packing Widgets• A widget that can hold more than one other widget.

These are not visible so they are normally placed within another container widget that is visible. These widgets come in three varieties:• Vertical Packing Boxes

• Horizontal Packing Boxes

• Tables (a grid on which to places widgets)

Page 52: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.52

GTK+ Basics… (cont.)

• Properties• Each widget may employ a number of properties

such as the visible property, the size property, etc.

• Signals• A signal occurs whenever something interesting (like

a user clicking a button) happens to a widget. When the signal occurs a callback method is normally called that performs some programmer defined function.

Page 53: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.53

Widget Life-Cycle

• Creation• gtk_button_new

• Add widget to a container• gtk_container_add( window, button )

• Define a signal for the widget• gtk_signal_connect( button, “clicked”, ButtonFunc, NULL )

• Show the widget• gtk_widget_show( button)

• Destroy the widget• gtk_widget_destroy(button)

Page 54: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.54

Objective: Become Familiar with GTK#

• Using monodoc read the sections indicated by the red box -->

• Complete the gtk# Hello World exercise.

• What does 'GTK' represent?

• What is the origin of the GTK?

Exercise:

Page 55: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.55

Objective: Become Familiar with GTK# Samples

Exercises:

Check out the gtk-sharp source from the mono CVS system. Using 'cd' change to the following directory: '/home/<homedir>/mono/gtk-sharp'. Ensure these directories exist. Type the following at the command prompt:

1

– export CVSROOT=:pserver:[email protected]:/mono

– cvs login

– cvs -z3 co gtk-sharp

Change to the 'gtk-sharp/sample' directory.

Review the *.cs files, change some of the samples then run them using the mono runtime.

2

Page 56: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.56

Objective: Become Familiar with GNOME#

• Using monodoc read the sections indicated by the red box -->

• Complete the gnome# Hello World exercise.

• When would you use gnome# vs gtk#?

• Is there any advantage to using one over the other? (hint: read 'Introduction' sections.)

Exercise:

Page 57: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.57

Objective: Become Familiar with Glade#

• Using monodoc read the sections indicated by the red box -->

• Complete the associated Glade# exercise.

• Compile the Glade# sample to include the Glade- xml file as an embedded resource. (hint: read last paragraph in the section)

• Use the Interface Designer to create your own GUI application.

Exercise:

Page 58: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

© January 30, 2004 Novell Inc.58

Resources

• EMCA filing of CLI and C# http://www.ecma.ch/ecma1/STAND/ecma-335.htm

• The Mono Project homepage http://www.go-mono.com/

• The dotGNU hompage http://www.dotgnu.org

• Microsoft's .NET Homepage http://www.microsoft.com/net

Page 59: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.
Page 60: Mono: Rapid GUI Application Development On Linux Karl Bunnell Software Engineer Consultant, Novell Inc. kbunnell@novell.com.

General DisclaimerThis document is not to be construed as a promise by any participating company to develop, deliver, or market a product. Novell, Inc., makes no representations or warranties with respect to the contents of this document, and specifically disclaims any express or implied warranties of merchantability or fitness for any particular purpose. Further, Novell, Inc., reserves the right to revise this document and to make changes to its content, at any time, without obligation to notify any person or entity of such revisions or changes. All Novell marks referenced in this presentation are trademarks or registered trademarks of Novell, Inc. in the United States and other countries. All third-party trademarks are the property of their respective owners.

No part of this work may be practiced, performed, copied, distributed, revised, modified, translated, abridged, condensed, expanded, collected, or adapted without the prior written consent of Novell, Inc. Any use or exploitation of this work without authorization could subject the perpetrator to criminal and civil liability.