[disclaimer]


This is a personal blog. The opinions expressed here represent my own and not those of any of my employers or customers.

Except if stated otherwise, all the code shared is reusable under a MIT/X11 licence. If a picture is missing a copyright notice, it's probably because I'm owning it.
Showing posts with label gtk#beans. Show all posts
Showing posts with label gtk#beans. Show all posts

Friday, August 28, 2009

GtkBuilder on IronPython

Someone asked me if I could add the missing parts of GtkBuilder in Gtk#Beans so he could use it with IronPython on mono.

Hey, it looks there's no missing parts ! It all works fine since day one. Here's the the trick:

import clr
clr.AddReference('glib-sharp')
clr.AddReference('gtk-sharp')
clr.AddReference('gtk-sharp-beans')
import Gtk
import GLib
import GtkBeans
import System.IO

def PyBuilderAutoconnect(builder, target):
def _connect(builder, object, signal_name, handler_name, connect_object, flags):
name = ''.join([frag.title() for frag in signal_name.split('_')])
event = getattr(object, name)
event += getattr(target, handler_name)

for object in builder.Objects:
setattr(target, object.Name, object)
builder.ConnectSignalsFull (_connect)

class Application:
def __init__(self):
builder = GtkBeans.Builder (System.IO.FileStream ('ui.ui', System.IO.FileMode.Open))
#use this ctor if you don't like FileStream
#builder = GtkBeans.Builder ()
#builder.AddFromFile ('./ui.ui')

PyBuilderAutoconnect (builder, self)
self.window1.ShowAll ()

def onbuttonclicked(self, o, args):
Gtk.Application.Quit()

Gtk.Application.Init ()
app = Application ()
Gtk.Application.Run ()
Now your IronPython skills are ready to rock Gnome3!

Saturday, June 20, 2009

Announcing Gio# and Gtk#Beans

For a handful of good reasons (see Mike's mail), gtk-sharp, the gtk bindings for Mono and .NET, lately chose not to follow the hectic 6 months release plan of both gtk and glib teams but leverage on the almost perfect 2.12.x releases we have now (binding gtk 2.12 and glib 2.16) for a few extra months.

F-Spot, that small photo app everyone like, was, in its SVN/git latests versions, using a lot of the new API additions of gtk-sharp. You probably figured that already if you're following its developments.

So I branched out some of the code I needed from Gtk# svn to 2 new standalone projects, Gtk#Beans and Gio#. Both projects aims to fill the gap between the API mapped by Gtk#2.12 and the capabilities provided by gtk 2.14/glib 2.16.

The code is maintained on gitorious http://gitorious.org/gtk-sharp-beans, http://gitorious.org/gio-sharp and is already usable (and used in f-spot). Feel safe to use them as the API introduced over there will be merged with the fewest possible changes to the next Gtk# release.