Writing Really Rad GTK+ & GNOME Applications in C, Python or Java

Slides:



Advertisements
Similar presentations
The Free Software Desktop Project By: Joshua Anglero
Advertisements

What is an operating system? Is it software?
1 Chapter 5 Threads 2 Contents  Overview  Benefits  User and Kernel Threads  Multithreading Models  Solaris 2 Threads  Java Threads.
PaperCut NG Chris Dance. Copyright © PaperCut Software Pty. Ltd. 2 Overview Overview of PaperCut NG Why we offer a Mac Version The story of our.
Client-side Applications with PHP Andrei Zmievski & Frank M. Kromann Track: PHP Conference Date: Friday, July 27 Time: 3:45pm – 4:30pm Location: Fairbanks.
Unit Six Assignment 1 Chris Boardley.
Octave-GTK 24/02/05 © Octave-GTK Team 24/02/05 Octave-GTK Team Octave-GTK, a language bindings project Hemant Muthu Rams Manik {gnufied, gnumuthu,
FLTK Tutorial.
GUIs for Applets Introduction Applets and Swing/JFC Alternatives to Swing Look-and-Feel issues Example applet graphical user interfaces.
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 15: GUIs 1.
Dale Roberts Introduction to Visual Programming Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
GUI With GTK+ Under Linux Fanfan Xiong. Introduction GTK+ (GIMP toolkit) : A library for creating graphical user interfaces(GUI) Two examples developed.
MIT 6.893; SMA 5508 Spring 2004 Larry Rudolph Lecture 4: Graphic User Interface Graphical User Interface Larry Rudolph MIT 6.893; SMA 5508 Spring 2004.
Overview GUI Programming with GTK+ and GLADE 장정철.
GUIs Basic Concepts. GUI GUI : Graphical User Interface Window/Frame : a window on the screen Controls/Widgets : GUI components.
Introduction to Node.js® Jitendra Kumar Patel Saturday, January 31, 2015.
Javascript in Linux Desktop Yuren Ju ● Use Linux: 10 years ● For Desktop: 7-8 years Red Hat Debian Gentoo Debian Ubuntu Arch Linux Debian.
GUI and Web Programming CSE 403 (based on a lecture by James Fogarty)
Gtk2 GTK+ (the GIMP ToolKit) Bratislava, Gtk2 - Overview Graphical toolkit native to X11 (Linux, Unix) Ported to Windows and OS X Written in C,
Getting Started NX Journaling Jeff Roark Yanfeng Automotive Interiors.
CSC 108H: Introduction to Computer Programming Summer 2011 Marek Janicki.
Building GUI applications with Python, GTK and Glade
Intro To Android Programming
Progress Apama Fundamentals
Python Programming Unit -1.
Yochay Kiriaty Senior Technical Evangelist Microsoft® Corporation
CST 1101 Problem Solving Using Computers
Node.Js Server Side Javascript
Content Programming Overview The JVM A brief look at Structure
Event Loops and GUI Intro2CS – weeks
Obtaining the Required Tools
Fedora Project / Red Hat
Chapter 2: Operating-System Structures
Understanding SOAP and REST calls The types of web service requests
CSE 333 – Section 4 HW3, MVC, GTK+.
Lecture 8: Graphics By: Eliav Menachi.
Goals Give student some idea what this class is about
Java Look-and-Feel Design Guidelines
Review: Java GUI Programming
Chapter 4: Multithreaded Programming
MVC and other n-tier Architectures
Development-Introduction
Event Driven Programming Dick Steflik
Understanding an App’s Architecture
Introduction to Operating System (OS)
Application Development Theory
GNOME/GTK+ Introduction
Developing applications using Chromium
Ellen Walker Hiram College
Node.Js Server Side Javascript
Fundamentals of Python: From First Programs Through Data Structures
Chapter 2: Operating-System Structures
Event Driven Programming
EE 422C Java FX.
Tkinter GUIs Computer Science and Software Engineering
Chapter 2: Operating-System Structures
Chapter 2: System Structures
GTK + Programming.
Development The Foundation Window.
The Basic Usage and The Event Handling in Glade.
CMSC 331 Howdy, Ruby GUI !! Akshay Peshave
WPS - your story so far Seems incredible complicated, already
Chapter 2: Operating-System Structures
Lecture 8: Graphics By: Eliav Menachi.
Model, View, Controller design pattern
Presented By: Kwangsung Oh
• Every signal is uniquely identified by a name,
UFCEUS-20-2 Web Programming
CMPE 135: Object-Oriented Analysis and Design March 14 Class Meeting
Web Application Development Using PHP
Presentation transcript:

Writing Really Rad GTK+ & GNOME Applications in C, Python or Java Andrew Cowie Operational Dynamics Davyd Madeley Fugro Seismic Imaging

Who Are We? Andrew Cowie spends an awful lot of time programming for someone who is actually a suit. He started with C in the early 80s, picked up Java in 1997, and now, 10 years later, is the maintainer of the java-gnome project. Davyd Madeley is a professional software engineer and electronic engineering student. By night he is the gnome- applets maintainer and a contributor to GNOME. He plays the tenor saxophone.

An Overview Why choose GTK+ for your application? GTK+ Fundamentals Building a UI Box packing The main loop & signals Getting started (in C) Window tricks (in Java) Complex data models (in Python)

Why Would You Choose GTK+? Fast, flexible, ubiquitous Multi-platform Linux, Unix, Mac OS, Win32, and more Many languages C, Python and Java Perl, C++, Ruby, Haskell, C#, PHP, OCml, Eiffel, Erlang, Guile/Scheme/Lisp, Lua, Octave, D, TCL, Smalltalk, and more! LGPL

A Word on Versions Today we're using the following: gcc 4.1.x GTK+ 2.10.x Python 2.4 pyGTK 2.10 Sun Java 1.5 (& Free Java too!) Eclipse 3.2.x java-gnome 4.0 Glade 3.1.x

Widgets 'n stuff all displayed items are a GtkWidget; all interfaces are built down from a “top level”, inevitably GtkWindow

Building a UI You can write code ... Programmatically create elaborate custom content, dynamic layouts, and smaller Widgets

A GtkWindow with a GtkButton in it! C Demo! A GtkWindow with a GtkButton in it!

gcc -o demo \ `pkg-config --cflags --libs \ gtk+-2.0` demo.c Compiling gcc -o demo \ `pkg-config --cflags --libs \ gtk+-2.0` demo.c

Building a UI You can write code ... Programmatically create elaborate custom content, dynamic layouts, and smaller Widgets or use Glade ... Great for big, complex windows with lots of Layout

A GtkWindow with a GtkButton with Glade! C Demo! A GtkWindow with a GtkButton with Glade!

Building a UI You can write code ... Programmatically create elaborate custom content, dynamic layouts, and smaller Widgets or use Glade ... Great for big, complex windows with lots of Layout or do both simultaneously! no point using Glade if coding it directly is less lines of code Use Glade for most of Window (ie, Labels) and code for the dynamically generated bits

GTK+ uses a “box packing” model.

Box Packing Start a GtkWindow Pack a GtkVBox into the Window Pack a GtkLabel into the VBox Pack a GtkScrolledWindow into the VBox Pack a GtkTreeView into the ScrolledWindow

Glade Demo! Using Glade to do complex Box packing layouts

The Main Loop GUI programming is event driven programming The main loop polls sources for events events include user activity (keyboard or mouse), I/O, or a timeout events issued as named signals; register callbacks for signals you want to react to

DON'T BLOCK THE MAIN LOOP! Callbacks for events are issued from the main loop... ... one at a time ... and it's single threaded! DON'T BLOCK THE MAIN LOOP!

Signals Signals are connected to GObjects Often you pass 4 things: signal name callback function optional free-form “user data” Prototype for each callback in API docs Some callbacks return information to GTK+ (eg a gboolean)

Signals – C g_signal_connect(my_gobject, “notify::parent”, G_CALLBACK(notify_parent_cb), NULL); void notify_parent_cb(GObject *my_gobject, GParamSpec arg1, gpointer user_data) { ... }

C Demo! Hooking up a signal

Signals Some signals already have handlers registered eg. expose-event Some signals are passed up the widget tree from your widget all the way to the toplevel eg. expose-event, enter-notify-event You can choose whether or not to stop these in your signal handler by returning True or False

Same code, different language: Java Demo! Same code, different language: Java

Terminating application delete-event Closing a Window != Terminating application Beware the main loop!

GtkFileChooser Choose a file, any file

Same code, different language: Python Demo! Same code, different language: Python

GtkTreeView Can display trees or lists of data Uses an model, view, control (MVC) paradigm You need three things: a GtkTreeView a GtkTreeModel (GtkTreeStore, GtkListStore or write your own) GtkCellRenderers You can store more data in a row than you display (handy!)

See the gtk.TreeView for the Forrest Python Demo! See the gtk.TreeView for the Forrest

Getting More Out of GTK+/GNOME GConf – store configuration data GNOME-VFS – access data over networks Cairo – antialiased vector graphics GooCanvas – Cairo based canvas widget D-BUS – cross-desktop IPC with GLib tie-in Soup – HTTP, XML-RPC and SOAP libraries libwnck – Access window information libnotify – Popup balloons

Would Ye Like To Know More? In C: http://www.gtk.org/tutorial/ Matthias Warkus, The Official GNOME 2 Developer's Guide (No Starch Press, 2004) Devhelp In Java: http://java-gnome.sourceforge.net/4.0/doc/ In Python: http://www.pygtk.org/pygtk2tutorial/index.html

operationaldynamics.com/talks Fin ;) Questions? www.davyd.id.au/articles.shtml operationaldynamics.com/talks