/gpump/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/gpump/trunk

« back to all changes in this revision

Viewing changes to src/GPumpSettingsData.h

  • Committer: Gustav Hartvigsson
  • Date: 2014-06-09 11:24:17 UTC
  • mfrom: (38 GPump_GJS_Port)
  • mto: This revision was merged to the branch mainline in revision 40.
  • Revision ID: gustav.hartvigsson@gmail.com-20140609112417-ri0kau9elg4y8vnh
* Merged gjs port

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil
2
 
 * vi: set shiftwidth=2 tabstop=2 expandtab:
3
 
 * :indentSize=2:tabSize=2:noTabs=true:
4
 
 */
5
 
 
6
 
#ifndef __H_GPUMP_SETTINGS_DATA__
7
 
#define __H_GPUMP_SETTINGS_DATA__
8
 
 
9
 
/**
10
 
 * If this is set, it will use GSettings, otherwise it will use GKeyFile
11
 
 * and store store the data in a .ini format conf file in the configuration
12
 
 * directory.
13
 
 */
14
 
#define GPUMP_USE_GSETTINGS 0
15
 
 
16
 
#include <gtk/gtk.h>
17
 
#include <gio/gio.h>
18
 
#include <rest/oauth2-proxy.h>
19
 
#include <rest/rest-proxy-call.h>
20
 
#include <stdlib.h>
21
 
#include <string.h>
22
 
#include <glib/gi18n.h>
23
 
 
24
 
#define GPUMP_TYPE_SETTINGS_DATA              (gpump_settings_data_get_type ())
25
 
#define GPUMP_SETTINGS_DATA(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj), GPUMP_TYPE_SETTINGS_DATA, GPumpSettingsData))
26
 
#define GPUMP_SETTINGS_DATA_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), GPUMP_TYPE_SETTINGS_DATA, GPumpSettingsDataClass))
27
 
#define GPUMP_IS_SETTINGS_DATA(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj), GPUMP_TYPE_SETTINGS_DATA))
28
 
#define GPUMP_IS_SETTINGS_DATA_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GPUMP_TYPE_SETTINGS_DATA))
29
 
#define GPUMP_SETTINGS_DATA_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS((obj), GPUMP_TYPE_SETTINGS_DATA, GPumpSettingsDataClass))
30
 
 
31
 
typedef struct GPumpSettingsData GPumpSettingsData;
32
 
typedef struct GPumpSettingsDataClass GPumpSettingsDataClass;
33
 
typedef struct GPumpSettingsDataPrivate GPumpSettingsDataPrivate;
34
 
 
35
 
/* 
36
 
 * NAMESPACE: gpump_*
37
 
 *
38
 
 * CLASS NAMESPACE: gpump_settings_data_*
39
 
 */
40
 
 
41
 
/**
42
 
 * A class that holds the settings data.
43
 
 *
44
 
 * the reason for this is to split data and wiev, simplefying the data modle
45
 
 * and what not.
46
 
 *
47
 
 * This is a singletonian class, to get the instance use the provided
48
 
 * gpump_settings_data_get_default () function.
49
 
 *
50
 
 * Pleace note that this is not thread safe, and should be used with care.
51
 
 */
52
 
struct GPumpSettingsData {
53
 
  GObject parent;
54
 
  
55
 
  /* Private data is defined in the C file. */
56
 
  GPumpSettingsDataPrivate * priv;
57
 
};
58
 
 
59
 
struct GPumpSettingsDataClass {
60
 
  GObjectClass parent;
61
 
};
62
 
 
63
 
void g_pump_settings_data_get_type (void) G_GNUC_CONST;
64
 
 
65
 
/**
66
 
 * Create a GPumpSettingsData instance if it does not already exist,
67
 
 * if it exists return a pointer to the object.
68
 
 *
69
 
 * The object's reference count is increased every time this is called, so
70
 
 * you need to unref it whet you are done with it.
71
 
 */
72
 
GPumpSettingsData * gpump_settings_data_get_default ();
73
 
 
74
 
/**
75
 
 * Sets a value in the.
76
 
 *
77
 
 * valid names are:
78
 
 * - ui-x
79
 
 * - ui-y
80
 
 * - ui-h
81
 
 * - ui-w
82
 
 * - main-use-dark
83
 
 * - main-first-run
84
 
 * 
85
 
 * if the app is compiled in non-gsettings mode, you will have to use
86
 
 * gpump_settings_data_commit ()  whet to commit the changes.
87
 
 *
88
 
 * @param self the object to perform the operation on.
89
 
 * @param name the name of the setting to change.
90
 
 * @param data the a GValue that contains the data that should be set.
91
 
 *
92
 
 * If the data type in the data does not match the expected value type, the
93
 
 * value will not be set.
94
 
 */
95
 
void gpump_settings_data_set (GPumpSettingsData * self,
96
 
                              gchar * name,
97
 
                              GValue * data);
98
 
 
99
 
 
100
 
/**
101
 
 * Gets the data given a name, see gpump_settings_data_set's documentation
102
 
 * for more information.
103
 
 *
104
 
 * @param self the object to get the data from.
105
 
 * @param name the name of the value to be returned
106
 
 *
107
 
 * @returns a GValue containing the value of that was requested.
108
 
 */
109
 
GValue * gpump_settings_data_get (GPumpSettingsData * self,
110
 
                                    gchar * name);
111
 
 
112
 
/**
113
 
 * Commit the the changes to file, only useful when using compiled in
114
 
 * non-GSettings mode. In GSettings mode this will do nothing.
115
 
 *
116
 
 * @param self the object to perform the operation on
117
 
 * @param err returns on error if an error happens, should be NULL.
118
 
 *
119
 
 * @returns TRUE if no error occurred, FALSE otherwise
120
 
 *
121
 
 * @warning This operation may be relatively I/O intensive, because the file
122
 
 * is rewritten.
123
 
 */
124
 
gboolean gpump_settings_data_commit (GPumpSettingsData * self,
125
 
                                     GError ** err);
126
 
 
127
 
#endif /* #ifndef __H_GPUMP_SETTINGS_DATA__*/