summaryrefslogtreecommitdiff
path: root/service/dconf-writer.c
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2013-01-07 22:20:55 -0500
committerRyan Lortie <desrt@desrt.ca>2013-01-08 13:19:33 -0500
commit9ebbf9ba1854932b61c4c49b0a4d24132532d492 (patch)
treebbba6a982ea7cf10c9e1ec108f3df3e51406bc7f /service/dconf-writer.c
parent2ec6269534cbf310dbd81e700e9860bf91cf8bfe (diff)
downloaddconf-9ebbf9ba1854932b61c4c49b0a4d24132532d492.tar.gz
writer: add list class virtual method
This populates a set with the names of databases available for a given writer class.
Diffstat (limited to 'service/dconf-writer.c')
-rw-r--r--service/dconf-writer.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/service/dconf-writer.c b/service/dconf-writer.c
index 46aaf2d..fb3589a 100644
--- a/service/dconf-writer.c
+++ b/service/dconf-writer.c
@@ -58,6 +58,25 @@ static void dconf_writer_iface_init (DConfDBusWriterIface *iface);
G_DEFINE_TYPE_WITH_CODE (DConfWriter, dconf_writer, DCONF_DBUS_TYPE_WRITER_SKELETON,
G_IMPLEMENT_INTERFACE (DCONF_DBUS_TYPE_WRITER, dconf_writer_iface_init))
+static void
+dconf_writer_real_list (GHashTable *set)
+{
+ const gchar *name;
+ gchar *dirname;
+ GDir *dir;
+
+ dirname = g_build_filename (g_get_user_config_dir (), "dconf", NULL);
+ dir = g_dir_open (dirname, 0, NULL);
+
+ if (!dir)
+ return;
+
+ while (name = g_dir_read_name (dir))
+ g_hash_table_add (set, g_strdup (name));
+
+ g_dir_close (dir);
+}
+
static gchar *
dconf_writer_get_tag (DConfWriter *writer)
{
@@ -309,6 +328,7 @@ dconf_writer_class_init (DConfWriterClass *class)
class->change = dconf_writer_real_change;
class->commit = dconf_writer_real_commit;
class->end = dconf_writer_real_end;
+ class->list = dconf_writer_real_list;
g_object_class_install_property (object_class, 1,
g_param_spec_string ("name", "name", "name", NULL,
@@ -324,6 +344,19 @@ dconf_writer_get_name (DConfWriter *writer)
return writer->priv->name;
}
+void
+dconf_writer_list (GType type,
+ GHashTable *set)
+{
+ DConfWriterClass *class;
+
+ g_return_if_fail (g_type_is_a (type, DCONF_TYPE_WRITER));
+
+ class = g_type_class_ref (type);
+ class->list (set);
+ g_type_class_unref (class);
+}
+
GDBusInterfaceSkeleton *
dconf_writer_new (GType type,
const gchar *name)