Bonobo

Peace, Love and Components

George Lebl

Crazy Czech Hacker

Eazel, Inc.

Maciej Stachowiak

Hacker

Eazel,Inc.


What is Bonobo?

Bonobo is a Component model

Created for GNOME

Designed to be toolkit-independent

Layered on top of CORBA

This provides many technical advantages

Inspired by Microsoft's COM

Most successful component model ever


What is a component model?

A component model provides a way to

Activate objects dynamically

Write objects in a uniform way

Make objects reusable

Use common interfaces to manipulate objects


History of components in GNOME

GNOME Panel, Control Center

Specialized embedding interfaces

Different for each app

MICO (MICO Is CORBA)

Original GNOME ORB (Object Request Broker)

Slow, bloated, hard to compile

ORBit

Replacement for MICO

Very fast and lightweight

Written in C


History of components in GNOME

GNORBA (GNOME CORBA)

Simplifying wrappers for CORBA

Faint beginning of a component model

GOAD - GNOME Object Activation Directory

BABOON

BABOON Allows BABOON Objects Over Networks

Never finished

Bonobo

Evolved from BABOON

Current GNOME component model

All-singing, all-dancing

OAF

Better activation system


CORBA

Common Object Request Broker Architecture

An object model with many advantages,

which Bonobo benefits from

Transparent cross-process objects

Transparent network objects

Language-independent

Portable, vendor-independent

Separates interface and implementation (IDL)


CORBA

Common Object Request Broker Architecture

Has some gaps, which Bonobo tries to fill in

Hard to use

leaves many things unspecified (activation)

not in itself a component model


IDL

Interface Definition Language

Modules

Basic types

string

char

byte, short, long, long long

float, double


IDL

Interface Definition Language

Interfaces

methods

attributes

Other

typedefs

structs

enums

sequences

unions

any


Translator Component Step 1

Interface Definition Language

Basic IDL file

step1/translator.idl


IDL

What happens to IDL?

Stubs

Called by client

marshalls parameters

unmarshalls return value

Can send IIOP (Internet Inter ORB Protocol) messages

Fast bypass in local case

Skeletons

Handle incoming messages

Call the server code

marshalls parameters

unmarshalls return value


How stubs and skeletons work


CORBA::Object

Fundamental object interface

IORs identify active objects

CORBA_ORB_object_to_string

CORBA_ORB_string_to_object

Reference semantics

CORBA_Object_duplicate

CORBA_Object_release


C Language mapping

How to use CORBA from C

Calling a method

Module_Interface_method (arg1, arg2, &ev);

Mappings for types

int --> CORBA_int

string --> CORBA_char *

POA - framework for creating servers

Portable Object Adapter


Component model - recap

A component model provides a way to

Activate objects dynamically

Write objects in a uniform way

Make objects reusable

Use common interfaces to manipulate objects


Bonobo::Unknown interface

Based on IUnknown, (modelled after COM)

Three basic methods:

ref

unref

queryInterface


Bonobo::Unknown - memory management

Refcounting

Allows easier resource management

Familiar to GTK+/GNOME programmers

Simple to use

Not perfect


Bonobo::Unknown - object aggregation

Makes reuse simpler

Implementation is split into more logical units

Aggregating an interface is often simpler than inheriting

Clients can only use interfaces they understand

Avoids pitfalls of inheritance (especially MI)

Name collision

Binary compatibility

Separation between interfaces

Avoids problems with deep inheritance trees


Translator Component Step 2

GNOME::Example::Translator inheriting from Bonobo::Unknown

step2/translator.idl


Activation

Objects are implemented by servers

Three kinds of servers

Executable ("exe") - one process, one object

Factory ("factory") - one process, many objects

Based on an executable server

Uses GNOME::ObjectFactory interface

Shared Library ("shlib") - dynamicly loaded


OAF

Object Activation Framework

Describe components with XML

Select by ID

oaf_activate_from_id

uses OAFIID

Select by query

oaf_activate

(slightly) SQL-like query language


Translator Component Step 3

OAF component description XML file

step3/GNOME_Example_translator.oaf


Putting it all together

Simple non-gui Translator component

Provides translation service

translate

reverseTranslation


Translator Component Step 4

Basic translator component and client

step4/main.c

step4/gnome-example-translator.c

step4/gnome-example-translator-client.c

Demo


Putting it all together

More advanced version

rot13

swap-caps

Demonstrates using multiple interfaces

Uses Bonobo::PropertyBag

"translation-type" property

shows the power of the Bonobo standard interfaces


Translator Component Step 5

Spiffier translator component and client

step5/gnome-example-translator.c

step5/gnome-example-translator-client.c

Demo


Bonobo Controls

Visual embedding of components

A powerful way to package high-level widgets

Pluggable and interchangable

Similar to ActiveX controls

Used for pluggable apps like Nautilus, Evolution


Bonobo controls

Bonobo::Control

A widget-like interface

An object implementing this interface can be embedded as a widget

Bonobo::ControlFrame

A container interface

An object wanting to embed a control needs to implement this interface


libbonobo control interface

BonoboWidget

Provides a ControlFrame for you

Single function call

bonobo_widget_new_control or

bonobo_widget_new_control_from_objref

BonoboControl

A wrapper object for controls

Use:

control = bonobo_control_new (some_gtk_widget);


BonoboWindow

BonoboWindow

Similar to GnomeApp or GtkWindow

Provides UI merging

Menu merging

Merge both whole toolbars or toolbar items

Menu into popup menus

UI definitions are done using XML


The Thunder presentation component

Similar to GnomeApp or GtkWindow


Thunder presentation component

Spiffier translator component and client

Thunder_nautilus-view.oaf

main.c

thunder-nautilus-view.h

thunder-nautilus-view.c

thunder.mime

thunder.keys


Applications using Bonobo now or in the future

Gnumeric

Original bonobo testbed

Nautilus

Evolution

EOG

Vertigo (code name for GNOME 2.0 panel)

GNOME 2.0 Control Center

Grapevine

StarOffice (for GNOME 2.0)

GIMP 2.0 (GEGL)

And many more...


Advanced topics

Compound documents

Embed documents inside other documents

Handle printing, saving, and linking

Monikers

A path to object, somewhat like a URI

Each object parses as much of the moniker as it needs

Allows advanced linking and simple activation


Advanced topics

Mango

GObject based corba C binding

Even lighter weight shared library use

Memory management done in GLib style

Much simpler to use

Using and creating Bonobo components basically the same as using and creating GTK+ (GObject) objects