~audio-recorder/audio-recorder/trunk

« back to all changes in this revision

Viewing changes to src/dconf.c

  • Committer: osmoma at gmail
  • Date: 2012-10-25 15:12:29 UTC
  • Revision ID: osmoma@gmail.com-20121025151229-mi5ejcakq3k2pc6j
A.r will now remember lastly used media-players. New key in data/org.gnome.audio-recorder.gschema.xml.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * Boston, MA 02111-1307, USA.
18
18
*/
19
19
#include <string.h>
 
20
#include <stdlib.h>
20
21
#include "dconf.h"
21
22
#include "support.h"
22
23
#include "utility.h"
23
24
#include "log.h"
24
25
 
25
 
// This module writes and reads values from/to GNOME's configuration registry (dconf registry).
 
26
// This module writes and reads values from/to GNOME's configuration registry (GSettings).
 
27
// DConf is most likely the backend.
26
28
// You can check these values in dconf-editor.
27
29
// Start dconf-editor and browse to /apps/audio-recorder/.
28
30
 
144
146
 
145
147
GSettings *conf_get_base_settings() {
146
148
    // Return GSettings (base) object. This points to /apps/audio-recorder/.
147
 
    GSettings *settings = g_settings_new(APPLICATION_SETTINGS_SCHEMA);
148
 
    if (!G_IS_SETTINGS(settings)) {
149
 
        LOG_ERROR("Cannot find settings for %s\n", APPLICATION_SETTINGS_SCHEMA);
150
 
        return NULL;
 
149
 
 
150
    // Ref: http://developer.gnome.org/gio/2.32/gio-GSettingsSchema-GSettingsSchemaSource.html
 
151
    GSettingsSchemaSource *source = g_settings_schema_source_get_default();
 
152
    GSettingsSchema *schema = g_settings_schema_source_lookup(source, APPLICATION_SETTINGS_SCHEMA, FALSE);
 
153
 
 
154
    // Check if schema has been installed
 
155
    if (!schema) {
 
156
        g_printerr("Error: Cannot find settings for %s in GNOME's registry. " 
 
157
                   "Please run \"make install\" as sudo or root user.\n", "/apps/audio-recorder/");
 
158
 
 
159
        g_printerr("Cannot continue. Terminating this program.\n");
 
160
        exit(1);
151
161
    }
 
162
 
 
163
    GSettings *settings = g_settings_new_full(schema, NULL, NULL);
 
164
    g_settings_schema_unref(schema);
 
165
 
152
166
    return settings;
153
167
}
154
168
 
164
178
 
165
179
    // The main GSettings object
166
180
    GSettings *settings = conf_get_base_settings(); // Points to /apps/audio-recorder/.
167
 
    if (!G_IS_SETTINGS(settings)) {
168
 
        return NULL;
169
 
    }
170
181
 
171
182
    if (*child_path) {
172
183
        // Get GSettings object for child_path
195
206
 
196
207
    // Check if the key is valid. Avoid crash.
197
208
    if (!conf_is_valid_key(settings, k)) {
198
 
        LOG_ERROR("Cannot find configuration key \"%s\".\n", key);
 
209
        LOG_ERROR("Cannot find configuration key \"%s\". Run \"make install\" as sudo or root user.\n", key);
199
210
        goto LBL_1;
200
211
    }
201
212
 
224
235
 
225
236
    // Check if the key is valid. Avoid crash.
226
237
    if (!conf_is_valid_key(settings, k)) {
227
 
        LOG_ERROR("Cannot find configuration key \"%s\".\n", key);
 
238
        LOG_ERROR("Cannot find configuration key \"%s\". Run \"make install\" as sudo or root user.\n", key);
228
239
        goto LBL_1;
229
240
    }
230
241
 
253
264
 
254
265
    // Check if the key is valid. Avoid crash.
255
266
    if (!conf_is_valid_key(settings, k)) {
256
 
        LOG_ERROR("Cannot find configuration key \"%s\".\n", key);
 
267
        LOG_ERROR("Cannot find configuration key \"%s\". Run \"make install\" as sudo or root user.\n", key);
257
268
        goto LBL_1;
258
269
    }
259
270
 
284
295
 
285
296
    // Check if the key is valid. Avoid crash.
286
297
    if (!conf_is_valid_key(settings, k)) {
287
 
        LOG_ERROR("Cannot find configuration key \"%s\".\n", key);
 
298
        LOG_ERROR("Cannot find configuration key \"%s\". Run \"make install\" as sudo or root user.\n", key);
288
299
        goto LBL_1;
289
300
    }
290
301
 
328
339
 
329
340
    // Check if the key is valid. Avoid crash.
330
341
    if (!conf_is_valid_key(settings, k)) {
331
 
        LOG_ERROR("Cannot find configuration key \"%s\".\n", key);
 
342
        LOG_ERROR("Cannot find configuration key \"%s\". Run \"make install\" as sudo or root user.\n", key);
332
343
        goto LBL_1;
333
344
    }
334
345
 
359
370
 
360
371
    // Check if the key is valid. Avoid crash.
361
372
    if (!conf_is_valid_key(settings, k)) {
362
 
        LOG_ERROR("Cannot find configuration key \"%s\".\n", key);
 
373
        LOG_ERROR("Cannot find configuration key \"%s\". Run \"make install\" as sudo or root user.\n", key);
363
374
        goto LBL_1;
364
375
    }
365
376
 
390
401
 
391
402
    // Check if the key is valid. Avoid crash.
392
403
    if (!conf_is_valid_key(settings, k)) {
393
 
        LOG_ERROR("Cannot find configuration key \"%s\".\n", key);
 
404
        LOG_ERROR("Cannot find configuration key \"%s\". Run \"make install\" as sudo or root user.\n", key);
394
405
        goto LBL_1;
395
406
    }
396
407
 
421
432
 
422
433
    // Check if the key is valid. Avoid crash.
423
434
    if (!conf_is_valid_key(settings, k)) {
424
 
        LOG_ERROR("Cannot find configuration key \"%s\".\n", key);
 
435
        LOG_ERROR("Cannot find configuration key \"%s\". Run \"make install\" as sudo or root user.\n", key);
425
436
        goto LBL_1;
426
437
    }
427
438
 
706
717
#endif
707
718
 
708
719
 
709