source: proiecte/PPPP/gdm/common/gdm-settings-backend.c @ 134

Last change on this file since 134 was 134, checked in by (none), 14 years ago

gdm sources with the modifications for webcam

File size: 5.9 KB
Line 
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program 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
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 */
20
21#include "config.h"
22
23#include <stdlib.h>
24#include <stdio.h>
25#include <fcntl.h>
26#include <unistd.h>
27#include <string.h>
28#include <signal.h>
29#include <sys/stat.h>
30#include <sys/types.h>
31
32#include <glib.h>
33#include <glib/gi18n.h>
34#include <glib-object.h>
35
36#include "gdm-settings-backend.h"
37
38#include "gdm-marshal.h"
39
40#define GDM_SETTINGS_BACKEND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SETTINGS_BACKEND, GdmSettingsBackendPrivate))
41
42struct GdmSettingsBackendPrivate
43{
44        gpointer dummy;
45};
46
47enum {
48        VALUE_CHANGED,
49        LAST_SIGNAL
50};
51
52static guint signals [LAST_SIGNAL] = { 0, };
53
54static void     gdm_settings_backend_class_init (GdmSettingsBackendClass *klass);
55static void     gdm_settings_backend_init       (GdmSettingsBackend      *settings_backend);
56static void     gdm_settings_backend_finalize   (GObject                 *object);
57
58G_DEFINE_ABSTRACT_TYPE (GdmSettingsBackend, gdm_settings_backend, G_TYPE_OBJECT)
59
60GQuark
61gdm_settings_backend_error_quark (void)
62{
63        static GQuark ret = 0;
64        if (ret == 0) {
65                ret = g_quark_from_static_string ("gdm_settings_backend_error");
66        }
67
68        return ret;
69}
70
71static gboolean
72gdm_settings_backend_real_get_value (GdmSettingsBackend *settings_backend,
73                                     const char         *key,
74                                     char              **value,
75                                     GError            **error)
76{
77        g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend), FALSE);
78
79        return FALSE;
80}
81
82static gboolean
83gdm_settings_backend_real_set_value (GdmSettingsBackend *settings_backend,
84                                     const char         *key,
85                                     const char         *value,
86                                     GError            **error)
87{
88        g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend), FALSE);
89
90        return FALSE;
91}
92
93gboolean
94gdm_settings_backend_get_value (GdmSettingsBackend *settings_backend,
95                                const char         *key,
96                                char              **value,
97                                GError            **error)
98{
99        gboolean ret;
100
101        g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend), FALSE);
102
103        g_object_ref (settings_backend);
104        ret = GDM_SETTINGS_BACKEND_GET_CLASS (settings_backend)->get_value (settings_backend, key, value, error);
105        g_object_unref (settings_backend);
106
107        return ret;
108}
109
110gboolean
111gdm_settings_backend_set_value (GdmSettingsBackend *settings_backend,
112                                const char         *key,
113                                const char         *value,
114                                GError            **error)
115{
116        gboolean ret;
117
118        g_return_val_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend), FALSE);
119
120        g_object_ref (settings_backend);
121        ret = GDM_SETTINGS_BACKEND_GET_CLASS (settings_backend)->set_value (settings_backend, key, value, error);
122        g_object_unref (settings_backend);
123
124        return ret;
125}
126
127void
128gdm_settings_backend_value_changed (GdmSettingsBackend *settings_backend,
129                                    const char         *key,
130                                    const char         *old_value,
131                                    const char         *new_value)
132{
133        g_return_if_fail (GDM_IS_SETTINGS_BACKEND (settings_backend));
134
135        g_signal_emit (settings_backend, signals[VALUE_CHANGED], 0, key, old_value, new_value);
136}
137
138static void
139gdm_settings_backend_class_init (GdmSettingsBackendClass *klass)
140{
141        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
142
143        object_class->finalize = gdm_settings_backend_finalize;
144
145        klass->get_value = gdm_settings_backend_real_get_value;
146        klass->set_value = gdm_settings_backend_real_set_value;
147
148        signals [VALUE_CHANGED] =
149                g_signal_new ("value-changed",
150                              G_TYPE_FROM_CLASS (object_class),
151                              G_SIGNAL_RUN_LAST,
152                              G_STRUCT_OFFSET (GdmSettingsBackendClass, value_changed),
153                              NULL,
154                              NULL,
155                              gdm_marshal_VOID__STRING_STRING_STRING,
156                              G_TYPE_NONE,
157                              3,
158                              G_TYPE_STRING,
159                              G_TYPE_STRING,
160                              G_TYPE_STRING);
161
162        g_type_class_add_private (klass, sizeof (GdmSettingsBackendPrivate));
163}
164
165static void
166gdm_settings_backend_init (GdmSettingsBackend *settings_backend)
167{
168        settings_backend->priv = GDM_SETTINGS_BACKEND_GET_PRIVATE (settings_backend);
169}
170
171static void
172gdm_settings_backend_finalize (GObject *object)
173{
174        GdmSettingsBackend *settings_backend;
175
176        g_return_if_fail (object != NULL);
177        g_return_if_fail (GDM_IS_SETTINGS_BACKEND (object));
178
179        settings_backend = GDM_SETTINGS_BACKEND (object);
180
181        g_return_if_fail (settings_backend->priv != NULL);
182
183        G_OBJECT_CLASS (gdm_settings_backend_parent_class)->finalize (object);
184}
Note: See TracBrowser for help on using the repository browser.