Showing posts with label gobject-introspection. Show all posts
Showing posts with label gobject-introspection. Show all posts

Thursday, 17 April 2014

What is GOM¹

Under that name is a simple idea: making it easier to save, load, update and query objects in an object store.

I'm not the main developer for this piece of code, but contributed a large number of fixes to it, while porting a piece of code to it as a test of the API. Much of the credit for the design of this very useful library goes to Christian Hergert.

The problem

It's possible that you've already implemented a data store inside your application, hiding your complicated SQL queries in a separate file because they contain injection security issues. Or you've used the filesystem as the store and threw away the ability to search particular fields without loading everything in memory first.

Given that SQLite pretty much matches our use case - it offers good search performance, it's a popular thus well-documented project and its files can be manipulated through a number of first-party and third-party tools - wrapping its API to make it easier to use is probably the right solution.

The GOM solution

GOM is a GObject based wrapper around SQLite. It will hide SQL from you, but still allow you to call to it if you have a specific query you want to run. It will also make sure that SQLite queries don't block your main thread, which is pretty useful indeed for UI applications.

For each table, you would have a GObject, a subclass of GomResource, representing a row in that table. Each column is a property on the object. To add a new item to the table, you would simply do:

item = g_object_new (ITEM_TYPE_RESOURCE,
                     "column1", value1,
                     "column2", value2, NULL);
gom_resource_save_sync (item, NULL);

We have a number of features which try to make it as easy as possible for application developers to use gom, such as:
  • Automatic table creation for string, string arrays, and number types as well as GDateTime, and transformation support for complex types (say, colours or images).
  • Automatic database version migration, using annotations on the properties ("new in version")
  • Programmatic API for queries, including deferred fetches for results
Currently, the main net gain in terms of lines of code, when porting SQLite, is the verbosity of declaring properties with GObject. That will hopefully be fixed by the GProperty work planned for the next GLib release.

The future

I'm currently working on some missing features to support a port of the grilo bookmarks plugin (support for column REFERENCES).

I will also be making (small) changes to the API to allow changing the backend from SQLite to a another one, such as XML, or a binary format. Obviously the SQL "escape hatches" wouldn't be available with those backends.

Don't hesitate to file bugs if there are any problems with the API, or its documentation, especially with respect to porting from applications already using SQLite directly. Or if there are bugs (surely, no).

Note that JavaScript support isn't ready yet, due to limitations in gjs.

¹: « SQLite don't hurt me, don't hurt me, no more »

Monday, 8 November 2010

Bluetooth in gnome-shell

Even though I'm still gnome-shell impaired (waiting on 3D support landing for my Radeon video card), I helped out Giovanni Campagna into getting Bluetooth support in the gnome-shell.

My work was to review Giovanni's code for gnome-bluetooth, and making sure that the gnome-shell behaviour matched that of the existing GNOME Bluetooth applet.

A lot of to-and-fro, but the gnome-bluetooth changes are now in, and waiting on sub-menu fixes for gnome-shell itself. Owen was kind enough to provide me with a screenshot for your enjoyment.

Bluetooth in the shell

This wasn't my first interaction with Giovanni, as, in another long-winded bug, we hashed out the volume control shell icon. This work is already merged, and lives in gnome-shell.

Friday, 26 June 2009

DBusGProxy introspection, where art thou?

I tried to beat the wash cycle on my washing machine at doing something useful[1].

Tried to add Introspection support to gnome-bluetooth.

The result nearly works, as it seems that there's no bindings for DBusGProxy in gobject-introspection...
** WARNING **: Entry 'DBusGProxy' not found
If somebody knows...

[1]: I played football twice today, and needed to wash my kit again, as I'll be playing tomorrow, though I hope we'll play better than we did this evening, shrug.