Use GtkSourceView widget in Glade

I’m developing an application that uses syntax highlight with PyGObject (Gtk+ 3.0 dynamic python bindings). If like me you need to use the GtkSourceView widget in Glade you need to follow this steps:

  1. Install gtksourceview development package:
    sudo apt-get install libgtksourceview-3.0-dev
    This will install the Glade catalog in /usr/share/glade/catalogs/gtksourceview.xml and the library in /usr/lib/x86_64-linux-gnu/
  2. Link library so Glade can find it:
    Glade will be unabled to find the library to load the catalog because is not in it’s search path with and error:
    (glade:7010): GladeUI-CRITICAL **: Unable to load module 'gtksourceview-3.0' from any search paths
    Solution: sudo ln -s /usr/lib/x86_64-linux-gnu/ /usr/lib/glade/modules/

That’s it, now you have the new widget in your Glade.

GtkSourceView in Glade 3.12.0

If you’re using your Glade file with PyGObject you will need to register the new GtkSourceView type in GObject like this before calling GtkBuilder’s add_from_file():

from gi.repository import Gtk, GtkSource, GObject
from os.path import abspath, dirname, join

WHERE_AM_I = abspath(dirname(__file__))

class MyApp(object):

    def __init__(self):
        self.builder = Gtk.Builder()
        self.glade_file = join(WHERE_AM_I, '')

if __name__ == '__main__':
        gui = MyApp()
    except KeyboardInterrupt:

I’ve found very scarse documentation about this, and most of it is outdated (gtksourceview 2.0, Glade 2, PyGtk, Gtk+ 2.0, etc). So this apply to:

  • Ubuntu Precise 12.04
  • Glade 3.12.0
  • libgtksourceview 3.0
  • Gtk+ 3.0
  • PyGObject

Kind regards

Etiquetado , ,

Un pensamiento en “Use GtkSourceView widget in Glade

  1. […] I’m trying to use a Glade file that has a GtkSourceView widget in PyGObject. I’ve wrote a little guide on how to start using the new GtkSourceView 3.0 in Glade: […]


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )


Conectando a %s

A %d blogueros les gusta esto: