Logo Search packages:      
Sourcecode: libdesktop-agnostic version File versions  Download package

config-iface.h

/* 
 * Interface for the configuration implementations.
 *
 * Copyright (C) 2008, 2009 Mark Lee <libdesktop-agnostic@lazymalevolence.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 *
 * Author : Mark Lee <libdesktop-agnostic@lazymalevolence.com>
 */

#ifndef __LIBDESKTOP_AGNOSTIC_CONFIG_IFACE_H__
#define __LIBDESKTOP_AGNOSTIC_CONFIG_IFACE_H__

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>

G_BEGIN_DECLS

typedef struct _DesktopAgnosticConfigNotifyEntry DesktopAgnosticConfigNotifyEntry;
typedef struct _DesktopAgnosticConfigBackend DesktopAgnosticConfigBackend;
typedef struct _DesktopAgnosticConfigBackendClass DesktopAgnosticConfigBackendClass;
typedef struct _DesktopAgnosticConfigSchema DesktopAgnosticConfigSchema;
typedef struct _DesktopAgnosticConfigSchemaClass DesktopAgnosticConfigSchemaClass;

#define DESKTOP_AGNOSTIC_CONFIG_TYPE_NOTIFY_ENTRY (desktop_agnostic_config_notify_entry_get_type ())
/**
   * The callback prototype used for notifications when configuration values
   * change.
   */
typedef void (*DesktopAgnosticConfigNotifyFunc) (const DesktopAgnosticConfigNotifyEntry* entry, void* user_data);

#define DESKTOP_AGNOSTIC_CONFIG_TYPE_BACKEND (desktop_agnostic_config_backend_get_type ())
#define DESKTOP_AGNOSTIC_CONFIG_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DESKTOP_AGNOSTIC_CONFIG_TYPE_BACKEND, DesktopAgnosticConfigBackend))
#define DESKTOP_AGNOSTIC_CONFIG_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DESKTOP_AGNOSTIC_CONFIG_TYPE_BACKEND, DesktopAgnosticConfigBackendClass))
#define DESKTOP_AGNOSTIC_CONFIG_IS_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DESKTOP_AGNOSTIC_CONFIG_TYPE_BACKEND))
#define DESKTOP_AGNOSTIC_CONFIG_IS_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DESKTOP_AGNOSTIC_CONFIG_TYPE_BACKEND))
#define DESKTOP_AGNOSTIC_CONFIG_BACKEND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DESKTOP_AGNOSTIC_CONFIG_TYPE_BACKEND, DesktopAgnosticConfigBackendClass))

typedef struct _DesktopAgnosticConfigBackendPrivate DesktopAgnosticConfigBackendPrivate;

/**
   * Errors which occur when setting/retrieving configuration options.
   */
typedef enum  {
      DESKTOP_AGNOSTIC_CONFIG_CONFIG_ERROR_INVALID_TYPE,
      DESKTOP_AGNOSTIC_CONFIG_CONFIG_ERROR_KEY_NOT_FOUND
} DesktopAgnosticConfigConfigError;
#define DESKTOP_AGNOSTIC_CONFIG_CONFIG_ERROR desktop_agnostic_config_config_error_quark ()
struct _DesktopAgnosticConfigNotifyEntry {
      char* group;
      char* key;
      GValue value;
};

/**
   * The abstract base class that defines what a configuration backend should
   * look like.
   */
00075 struct _DesktopAgnosticConfigBackend {
      GObject parent_instance;
      DesktopAgnosticConfigBackendPrivate * priv;
};

struct _DesktopAgnosticConfigBackendClass {
      GObjectClass parent_class;
      void (*reset) (DesktopAgnosticConfigBackend* self, GError** error);
      void (*remove) (DesktopAgnosticConfigBackend* self, GError** error);
      void (*notify_add) (DesktopAgnosticConfigBackend* self, const char* group, const char* key, DesktopAgnosticConfigNotifyFunc callback, void* callback_target);
      void (*notify) (DesktopAgnosticConfigBackend* self, const char* group, const char* key);
      void (*notify_remove) (DesktopAgnosticConfigBackend* self, const char* group, const char* key, DesktopAgnosticConfigNotifyFunc callback, void* callback_target, GError** error);
      GValue (*get_value) (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GError** error);
      gboolean (*get_bool) (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GError** error);
      void (*set_bool) (DesktopAgnosticConfigBackend* self, const char* group, const char* key, gboolean value, GError** error);
      float (*get_float) (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GError** error);
      void (*set_float) (DesktopAgnosticConfigBackend* self, const char* group, const char* key, float value, GError** error);
      gint (*get_int) (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GError** error);
      void (*set_int) (DesktopAgnosticConfigBackend* self, const char* group, const char* key, gint value, GError** error);
      char* (*get_string) (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GError** error);
      void (*set_string) (DesktopAgnosticConfigBackend* self, const char* group, const char* key, const char* value, GError** error);
      GValueArray* (*get_list) (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GError** error);
      void (*set_list) (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GValueArray* value, GError** error);
      char* (*get_name) (DesktopAgnosticConfigBackend* self);
};


GQuark desktop_agnostic_config_config_error_quark (void);
#define DESKTOP_AGNOSTIC_CONFIG_GROUP_DEFAULT "DEFAULT"
void desktop_agnostic_config_notify_entry_copy (const DesktopAgnosticConfigNotifyEntry* self, DesktopAgnosticConfigNotifyEntry* dest);
void desktop_agnostic_config_notify_entry_destroy (DesktopAgnosticConfigNotifyEntry* self);
DesktopAgnosticConfigNotifyEntry* desktop_agnostic_config_notify_entry_dup (const DesktopAgnosticConfigNotifyEntry* self);
void desktop_agnostic_config_notify_entry_free (DesktopAgnosticConfigNotifyEntry* self);
GType desktop_agnostic_config_notify_entry_get_type (void);
GHashTable* desktop_agnostic_config_backend_get_backend_metadata_keys (void);
void desktop_agnostic_config_backend_reset (DesktopAgnosticConfigBackend* self, GError** error);
void desktop_agnostic_config_backend_remove (DesktopAgnosticConfigBackend* self, GError** error);
void desktop_agnostic_config_backend_notify_add (DesktopAgnosticConfigBackend* self, const char* group, const char* key, DesktopAgnosticConfigNotifyFunc callback, void* callback_target);
void desktop_agnostic_config_backend_notify (DesktopAgnosticConfigBackend* self, const char* group, const char* key);
void desktop_agnostic_config_backend_notify_remove (DesktopAgnosticConfigBackend* self, const char* group, const char* key, DesktopAgnosticConfigNotifyFunc callback, void* callback_target, GError** error);
GValue desktop_agnostic_config_backend_get_value (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GError** error);
void desktop_agnostic_config_backend_set_value (DesktopAgnosticConfigBackend* self, const char* group, const char* key, const GValue* value, GError** error);
gboolean desktop_agnostic_config_backend_get_bool (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GError** error);
void desktop_agnostic_config_backend_set_bool (DesktopAgnosticConfigBackend* self, const char* group, const char* key, gboolean value, GError** error);
float desktop_agnostic_config_backend_get_float (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GError** error);
void desktop_agnostic_config_backend_set_float (DesktopAgnosticConfigBackend* self, const char* group, const char* key, float value, GError** error);
gint desktop_agnostic_config_backend_get_int (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GError** error);
void desktop_agnostic_config_backend_set_int (DesktopAgnosticConfigBackend* self, const char* group, const char* key, gint value, GError** error);
char* desktop_agnostic_config_backend_get_string (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GError** error);
void desktop_agnostic_config_backend_set_string (DesktopAgnosticConfigBackend* self, const char* group, const char* key, const char* value, GError** error);
GValueArray* desktop_agnostic_config_backend_get_list (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GError** error);
void desktop_agnostic_config_backend_set_list (DesktopAgnosticConfigBackend* self, const char* group, const char* key, GValueArray* value, GError** error);
char* desktop_agnostic_config_backend_get_name (DesktopAgnosticConfigBackend* self);
DesktopAgnosticConfigSchema* desktop_agnostic_config_backend_get_schema (DesktopAgnosticConfigBackend* self);
const char* desktop_agnostic_config_backend_get_instance_id (DesktopAgnosticConfigBackend* self);
GType desktop_agnostic_config_backend_get_type (void);


G_END_DECLS

#endif

Generated by  Doxygen 1.6.0   Back to index