Experience from writing a tiny GNOME app in Gjs

Hey hey,

I wrote a tiny app in Gjs yesterday and wanted to share my experience.
It's a wrapper around the Spotify web player to add support for media
keys (play/pause, next, previous). It uses Gtk, WebKitGTK+ 2, and DBus.

I started with the gnome-devel-demos [1], which gives a very nice
introduction. The hello world was running quickly and the edit/run cycle
is of course very fast due to not needing compilation.

For adding media key support, I looked at what totem does [2], and tried
to reproduce it. This is where I hit the first road block, there's no
API reference for JS on developer.gnome.org. But I think this should be
addressed with bug 693378. Through searching I found some documentation
which helped [4] (although some things didn't work as documented).

For the WebKitGTK+ API, I looked at the C API reference and puzzled it
out. This was also kind of hard, but it's the same problem as above.

For making it easy to install this, I experimented with a .desktop file
which references the .js and icon through relative paths, but had no
success. I resorted to having an install.sh that expands the paths and
copies the file to ~/.local/share/applications/. I'm eagerly awaiting
the "app bundles" work, which should improve the situation [5].

All in all, I think the GNOME platform is moving in the right direction
and there's potential in having a good app development story.

Finally, here's the link to the source, if anyone is interested:



[1] https://developer.gnome.org/gnome-devel-demos/unstable/js.html
[2] https://git.gnome.org/browse/totem/tree/src/plugins/media-player-keys
[3] https://bugzilla.gnome.org/show_bug.cgi?id=693378
[4] http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gio.DBusProxy.html
[5] https://mail.gnome.org/archives/gnome-os-list/2012-September/msg00000.html

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]