/gpump/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/gpump/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil
 * vi: set shiftwidth=2 tabstop=2 expandtab:
 * :indentSize=2:tabSize=2:noTabs=true:
 */

#ifndef __H_GPUMP_SETTINGS_DATA__
#define __H_GPUMP_SETTINGS_DATA__

/**
 * If this is set, it will use GSettings, otherwise it will use GKeyFile
 * and store store the data in a .ini format conf file in the configuration
 * directory.
 */
#define GPUMP_USE_GSETTINGS 0

#include <gtk/gtk.h>
#include <gio/gio.h>
#include <rest/oauth2-proxy.h>
#include <rest/rest-proxy-call.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n.h>

#define GPUMP_TYPE_SETTINGS_DATA              (gpump_settings_data_get_type ())
#define GPUMP_SETTINGS_DATA(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj), GPUMP_TYPE_SETTINGS_DATA, GPumpSettingsData))
#define GPUMP_SETTINGS_DATA_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), GPUMP_TYPE_SETTINGS_DATA, GPumpSettingsDataClass))
#define GPUMP_IS_SETTINGS_DATA(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj), GPUMP_TYPE_SETTINGS_DATA))
#define GPUMP_IS_SETTINGS_DATA_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GPUMP_TYPE_SETTINGS_DATA))
#define GPUMP_SETTINGS_DATA_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS((obj), GPUMP_TYPE_SETTINGS_DATA, GPumpSettingsDataClass))

typedef struct GPumpSettingsData GPumpSettingsData;
typedef struct GPumpSettingsDataClass GPumpSettingsDataClass;
typedef struct GPumpSettingsDataPrivate GPumpSettingsDataPrivate;

/* 
 * NAMESPACE: gpump_*
 *
 * CLASS NAMESPACE: gpump_settings_data_*
 */

/**
 * A class that holds the settings data.
 *
 * the reason for this is to split data and wiev, simplefying the data modle
 * and what not.
 *
 * This is a singletonian class, to get the instance use the provided
 * gpump_settings_data_get_default () function.
 *
 * Pleace note that this is not thread safe, and should be used with care.
 */
struct GPumpSettingsData {
  GObject parent;
  
  /* Private data is defined in the C file. */
  GPumpSettingsDataPrivate * priv;
};

struct GPumpSettingsDataClass {
  GObjectClass parent;
};


/**
 * Create a GPumpSettingsData instance if it does not already exist,
 * if it exists return a pointer to the object.
 *
 * The object's reference count is increased every time this is called, so
 * you need to unref it whet you are done with it.
 */
GPumpSettingsData * gpump_settings_data_get_default ();

/**
 * Sets a value in the.
 *
 * valid names are:
 * - ui-x
 * - ui-y
 * - ui-h
 * - ui-w
 * - main-use-dark
 * 
 * if the app is compiled in non-gsettings mode, you will have to use
 * gpump_settings_data_commit ()  whet to commit the changes.
 *
 * @param self the object to perform the operation on.
 * @param name the name of the setting to change.
 * @param data the a GVariant that contains the data that should be set.
 *
 * If the data type in the data does not match the expected value type, the
 * value will not be set.
 */
void gpump_settings_data_set (GPumpSettingsData * self,
                              gchar * name,
                              GVariant * data);


/**
 * Gets the data given a name, see gpump_settings_data_set's documentation
 * for more information.
 *
 * @param self the object to get the data from.
 * @param name the name of the value to be returned
 *
 * @returns a GValiant containing the value of that was requested.
 */
GVariant * gpump_settings_data_get (GPumpSettingsData * self,
                                    gchar * name);

/**
 * Commit the the changes to file, only usefile when using compiled in
 * non-GSettings mode. In GSettings mode this will do nothing.
 *
 * @param self the object to perform the operation on
 * @param err returns on error if an error happens, should be NULL.
 *
 * @returns TRUE if no error occurred, FALSE otherwise
 *
 * @warning This operation may be relatively I/O intensive, because the file
 * is rewritten.
 */
gboolean gpump_settings_data_commit (GPumpSettingsData * self,
                                     GError * err);

#endif /* #ifndef __H_GPUMP_SETTINGS_DATA__*/