Practical GNOME Programming with Ruby FOSDEM 2004 Tutorial Laurent - - PowerPoint PPT Presentation

practical gnome programming with ruby
SMART_READER_LITE
LIVE PREVIEW

Practical GNOME Programming with Ruby FOSDEM 2004 Tutorial Laurent - - PowerPoint PPT Presentation

Practical GNOME Programming with Ruby FOSDEM 2004 Tutorial Laurent Sansonetti - lrz@gnome.org Nikolai Weibull - pcp@pcppopper.org http://ruby-gnome2.sourceforge.jp Ruby-GNOME2 Tutorial, FOSDEM 2004 p.1/26 Goal Our goal is to demonstrate


slide-1
SLIDE 1

Practical GNOME Programming with Ruby

FOSDEM 2004 Tutorial

Laurent Sansonetti - lrz@gnome.org Nikolai Weibull - pcp@pcppopper.org

http://ruby-gnome2.sourceforge.jp

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.1/26

slide-2
SLIDE 2

Goal

Our goal is to demonstrate that Ruby is Useful to glue complex components together Mature enough for real GNOME development Sexy by developing a very, very simple audio player:

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.2/26

slide-3
SLIDE 3

TOC

Contents: The Ruby-GNOME2 Project User Interface Design Multimedia Design Implementation Questions

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.3/26

slide-4
SLIDE 4

TOC

Contents: The Ruby-GNOME2 Project User Interface Design Multimedia Design Implementation Questions

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.4/26

slide-5
SLIDE 5

The Ruby-GNOME2 Project

Since 2002 Current release: 0.8.1 Has 16 developers worldwide Supports 17 GNOME libraries Resources in English, and i18n in progress (French, Italian, and Japanese)

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.5/26

slide-6
SLIDE 6

The Ruby-GNOME2 Project

Supported libraries:

Name Implementation Status Tutorials? API Reference? Examples? ATK *** No No Yes GConf *** Yes Yes Yes GDK *** No Yes Yes GLib *** No No Yes GStreamer *** No Yes Yes GTK *** Yes Yes Yes GnomeCanvas *** No No Yes GtkGLExt *** No Yes Yes Libgda *** Yes Yes Yes Libglade *** No No Yes Libgnome *** No No Yes GdkPixbuf ** No No Yes GnomeVFS ** No No Yes Libart ** No No Yes Pango ** No No Yes GtkHtml * No No Yes GtkSourceView * No No Yes

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.6/26

slide-7
SLIDE 7

The Ruby-GNOME2 Project

RBBR (RuBy BRowser): Inspects classes/modules: Native stuff: methods, constants, ancestors, . . . GLib stuff: signals, properties, enum/flags, . . . Displays API reference (if exists) Shows GNOME stock items/icons Usable (HIG compliant) i18n (Belarusian, English, French, Japanese)

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.7/26

slide-8
SLIDE 8

TOC

Contents: The Ruby-GNOME2 Project User Interface Design Multimedia Design Implementation Questions

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.8/26

slide-9
SLIDE 9

User Interface Design

Glade is a GTK+/GNOME user interface builder. Glade can: generate source code (C/C++/Perl/.../Ruby) for the user interface: the bad generate an XML file (.glade) loadable by Libglade: the good crash: the ugly

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.9/26

slide-10
SLIDE 10

User Interface Design

Ruby/Libglade in action:

require ’libglade2’ engine = GladeXML.new(’my_project.glade’) do |handler_name| # connect the signal handler somewhere # we need to return a method reference lambda{ puts handler_name + " was called!" } end window = engine[’my_window’] # window is a Gtk::Window window.title = "My Application" button = engine[’my_button’] # button is a Gtk::Button button.text = "My Button" button.sensitive = false : :

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.10/26

slide-11
SLIDE 11

User Interface Design

Let’s play a bit with Glade!

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.11/26

slide-12
SLIDE 12

TOC

Contents: The Ruby-GNOME2 Project User Interface Design Multimedia Design Implementation Questions

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.12/26

slide-13
SLIDE 13

Multimedia Design

GStreamer is A multimedia framework A set of components (plugins) for input codecs (audio, video, . . . ) filters / processors

  • utput

Network transparent Extensible Fast Still under heavy development

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.13/26

slide-14
SLIDE 14

Multimedia Design

GStreamer deals with pipelines. Pipelines are sets of elements Elements are sets of pads Pads are connection points between elements Elements are generally one of the following: A source - provides data A filter - tranforms data A sink - consumes data

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.14/26

slide-15
SLIDE 15

Multimedia Design

GStreamer pipeline overview:

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.15/26

slide-16
SLIDE 16

Multimedia Design

Pipelines are what we get after connecting elements in a sequence, much like connecting commands in a shell. We will discuss three pipelines: filesrc ! mad !

  • sssink

filesrc ! spider !

  • sssink

gnomevfssrc ! spider !

  • sssink

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.16/26

slide-17
SLIDE 17

Multimedia Design

The filesrc ! mad !

  • sssink pipeline consists of:

filesrc - provides data from a file on disk mad - decodes MPEG audio using libmad

  • sssink - sends audio to soundcard using OSS

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.17/26

slide-18
SLIDE 18

Multimedia Design

Positive Simple, works very well Negative Can only decode files on disk Can only decode MPEG audio

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.18/26

slide-19
SLIDE 19

Multimedia Design

We can do better! The filesrc ! spider !

  • sssink pipeline consists
  • f:

filesrc - provides data from a file on disk spider - finds type of data and creates proper decoder

  • sssink - sends audio to soundcard using OSS

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.19/26

slide-20
SLIDE 20

Multimedia Design

Positive Works for any kind of media type with audio data Works well in most cases Simple to set up Negative Can only decode files on disk Can fail to find type Can fail to find decoder Slower than using proper decoder immediately

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.20/26

slide-21
SLIDE 21

Multimedia Design

We can still do better! The gnomevfssrc ! spider !

  • sssink pipeline

consists of: gnomevfssrc - provides data from an URL using GnomeVFS spider - finds type of data and creates proper decoder

  • sssink - sends audio to soundcard using OSS

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.21/26

slide-22
SLIDE 22

Multimedia Design

Positive Works for anything that can be accessed through an URL Works for any kind of media type with audio data Works well in most cases Simple to set up Negative Adds GnomeVFS dependency

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.22/26

slide-23
SLIDE 23

TOC

Contents: The Ruby-GNOME2 Project Multimedia Design User Interface Design Implementation Questions

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.23/26

slide-24
SLIDE 24

User Interface Design

Let’s write some code!

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.24/26

slide-25
SLIDE 25

TOC

Contents: The Ruby-GNOME2 Project Multimedia Design User Interface Design Implementation Questions

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.25/26

slide-26
SLIDE 26

Questions

Ask away!

Ruby-GNOME2 Tutorial, FOSDEM 2004 – p.26/26