~seb128/unity-settings-daemon/battery-info-key

« back to all changes in this revision

Viewing changes to plugins/xsettings/gnome-xsettings-plugin.c

  • Committer: William Jon McCann
  • Author(s): William Jon McCann
  • Date: 2007-12-14 05:06:55 UTC
  • Revision ID: git-v1:b7f5d9895c19338f10b0bdd494b221b13b540d9d
Initial checkin. Previously lived in gdm module.

2007-12-14  William Jon McCann  <mccann@jhu.edu>

        * configure.ac, etc: Initial checkin.  Previously
        lived in gdm module.


svn path=/trunk/; revision=2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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, or (at your option)
 
8
 * 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 <glib/gi18n-lib.h>
 
24
#include <gmodule.h>
 
25
 
 
26
#include "gnome-settings-plugin.h"
 
27
#include "gnome-xsettings-plugin.h"
 
28
#include "gnome-xsettings-manager.h"
 
29
 
 
30
struct GnomeXSettingsPluginPrivate {
 
31
        GnomeXSettingsManager *manager;
 
32
};
 
33
 
 
34
#define GNOME_XSETTINGS_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GNOME_TYPE_XSETTINGS_PLUGIN, GnomeXSettingsPluginPrivate))
 
35
 
 
36
GNOME_SETTINGS_PLUGIN_REGISTER (GnomeXSettingsPlugin, gnome_xsettings_plugin)
 
37
 
 
38
static void
 
39
gnome_xsettings_plugin_init (GnomeXSettingsPlugin *plugin)
 
40
{
 
41
        plugin->priv = GNOME_XSETTINGS_PLUGIN_GET_PRIVATE (plugin);
 
42
 
 
43
        g_debug ("GnomeXSettingsPlugin initializing");
 
44
 
 
45
        plugin->priv->manager = gnome_xsettings_manager_new ();
 
46
}
 
47
 
 
48
static void
 
49
gnome_xsettings_plugin_finalize (GObject *object)
 
50
{
 
51
        GnomeXSettingsPlugin *plugin;
 
52
 
 
53
        g_return_if_fail (object != NULL);
 
54
        g_return_if_fail (GNOME_IS_XSETTINGS_PLUGIN (object));
 
55
 
 
56
        g_debug ("GnomeXSettingsPlugin finalizing");
 
57
 
 
58
        plugin = GNOME_XSETTINGS_PLUGIN (object);
 
59
 
 
60
        g_return_if_fail (plugin->priv != NULL);
 
61
 
 
62
        if (plugin->priv->manager != NULL) {
 
63
                g_object_unref (plugin->priv->manager);
 
64
        }
 
65
 
 
66
        G_OBJECT_CLASS (gnome_xsettings_plugin_parent_class)->finalize (object);
 
67
}
 
68
 
 
69
static void
 
70
impl_activate (GnomeSettingsPlugin *plugin)
 
71
{
 
72
        gboolean res;
 
73
        GError  *error;
 
74
 
 
75
        g_debug ("Activating xsettings plugin");
 
76
 
 
77
        error = NULL;
 
78
        res = gnome_xsettings_manager_start (GNOME_XSETTINGS_PLUGIN (plugin)->priv->manager, &error);
 
79
        if (! res) {
 
80
                g_warning ("Unable to start xsettings manager: %s", error->message);
 
81
                g_error_free (error);
 
82
        }
 
83
}
 
84
 
 
85
static void
 
86
impl_deactivate (GnomeSettingsPlugin *plugin)
 
87
{
 
88
        g_debug ("Deactivating xsettings plugin");
 
89
}
 
90
 
 
91
static void
 
92
gnome_xsettings_plugin_class_init (GnomeXSettingsPluginClass *klass)
 
93
{
 
94
        GObjectClass             *object_class = G_OBJECT_CLASS (klass);
 
95
        GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass);
 
96
 
 
97
        object_class->finalize = gnome_xsettings_plugin_finalize;
 
98
 
 
99
        plugin_class->activate = impl_activate;
 
100
        plugin_class->deactivate = impl_deactivate;
 
101
 
 
102
        g_type_class_add_private (klass, sizeof (GnomeXSettingsPluginPrivate));
 
103
}