2 * Copyright © 2010 Codethink Limited
3 * Copyright © 2012 Canonical Limited
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the licence, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Ryan Lortie <desrt@desrt.ca>
23 #include "dconf-engine-source-private.h"
25 #include "../shm/dconf-shm.h"
32 DConfEngineSource source
;
35 } DConfEngineSourceUser
;
38 dconf_engine_source_user_open_gvdb (const gchar
*name
)
43 /* This can fail in the normal case of the user not having any
44 * settings. That's OK and it shouldn't be considered as an error.
46 filename
= g_build_filename (g_get_user_config_dir (), "dconf", name
, NULL
);
47 table
= gvdb_table_new (filename
, FALSE
, NULL
);
54 dconf_engine_source_user_init (DConfEngineSource
*source
)
56 source
->bus_type
= G_BUS_TYPE_SESSION
;
57 source
->bus_name
= g_strdup ("ca.desrt.dconf");
58 source
->object_path
= g_strdup_printf ("/ca/desrt/dconf/Writer/%s", source
->name
);
59 source
->writable
= TRUE
;
63 dconf_engine_source_user_needs_reopen (DConfEngineSource
*source
)
65 DConfEngineSourceUser
*user_source
= (DConfEngineSourceUser
*) source
;
67 return dconf_shm_is_flagged (user_source
->shm
);
71 dconf_engine_source_user_reopen (DConfEngineSource
*source
)
73 DConfEngineSourceUser
*user_source
= (DConfEngineSourceUser
*) source
;
75 dconf_shm_close (user_source
->shm
);
76 user_source
->shm
= dconf_shm_open (source
->name
);
78 return dconf_engine_source_user_open_gvdb (source
->name
);
82 dconf_engine_source_user_finalize (DConfEngineSource
*source
)
84 DConfEngineSourceUser
*user_source
= (DConfEngineSourceUser
*) source
;
86 dconf_shm_close (user_source
->shm
);
90 const DConfEngineSourceVTable dconf_engine_source_user_vtable
= {
91 .instance_size
= sizeof (DConfEngineSourceUser
),
92 .init
= dconf_engine_source_user_init
,
93 .finalize
= dconf_engine_source_user_finalize
,
94 .needs_reopen
= dconf_engine_source_user_needs_reopen
,
95 .reopen
= dconf_engine_source_user_reopen