Archivo de la etiqueta: Glade

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 , ,

Videotutorial RAD

Hice un pequeño videotutorial que explica cómo configurar un entorno de desarrollo rápido de aplicaciones con Software Libre para la Comunidad de Software Libre del ITCR. Les recomiendo que lo vean directamente en Vimeo, donde está en resolución 1440×900, si no tiene buena conexión apaguen el HD.

Se utiliza Eclipse Galileo, Java, GTK+ y Glade.

Espero que les guste!

Etiquetado , , , , ,