~ubuntu-branches/ubuntu/oneiric/gnome-panel/oneiric

« back to all changes in this revision

Viewing changes to gnome-panel/panel-config-global.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-05-30 11:04:49 UTC
  • mfrom: (1.3.4 upstream)
  • mto: This revision was merged to the branch mainline in revision 204.
  • Revision ID: james.westby@ubuntu.com-20110530110449-ut1tc5t61rpvf9e3
Tags: upstream-3.0.2
ImportĀ upstreamĀ versionĀ 3.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * panel-config-global.c: panel global configuration module
3
 
 *
4
 
 * Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or
7
 
 * modify it under the terms of the GNU General Public License as
8
 
 * published by the Free Software Foundation; either version 2 of the
9
 
 * License, or (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful, but
12
 
 * WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 
 * General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19
 
 * 02111-1307, USA.
20
 
 *
21
 
 * Authors:
22
 
 *      Mark McLoughlin <mark@skynet.ie>
23
 
 *      Glynn Foster <glynn.foster@sun.com>
24
 
 */
25
 
 
26
 
#include <config.h>
27
 
 
28
 
#include "panel-config-global.h"
29
 
 
30
 
#include <string.h>
31
 
#include <gconf/gconf.h>
32
 
 
33
 
#include "panel-globals.h"
34
 
#include "panel-gconf.h"
35
 
 
36
 
typedef struct {
37
 
        guint               tooltips_enabled : 1;
38
 
        guint               enable_animations : 1;
39
 
        guint               drawer_auto_close : 1;
40
 
        guint               confirm_panel_remove : 1;
41
 
        guint               highlight_when_over : 1;
42
 
} GlobalConfig;
43
 
 
44
 
static GlobalConfig global_config = { 0, };
45
 
static gboolean global_config_initialised = FALSE;
46
 
 
47
 
gboolean
48
 
panel_global_config_get_highlight_when_over (void)
49
 
{
50
 
        g_assert (global_config_initialised == TRUE);
51
 
 
52
 
        return global_config.highlight_when_over;
53
 
}
54
 
 
55
 
gboolean
56
 
panel_global_config_get_enable_animations (void)
57
 
{
58
 
        g_assert (global_config_initialised == TRUE);
59
 
 
60
 
        return global_config.enable_animations;
61
 
}
62
 
 
63
 
gboolean
64
 
panel_global_config_get_drawer_auto_close (void)
65
 
{
66
 
        g_assert (global_config_initialised == TRUE);
67
 
 
68
 
        return global_config.drawer_auto_close;
69
 
}
70
 
 
71
 
gboolean
72
 
panel_global_config_get_tooltips_enabled (void)
73
 
{
74
 
        g_assert (global_config_initialised == TRUE);
75
 
 
76
 
        return global_config.tooltips_enabled;
77
 
}
78
 
 
79
 
gboolean
80
 
panel_global_config_get_confirm_panel_remove (void)
81
 
{
82
 
        g_assert (global_config_initialised == TRUE);
83
 
 
84
 
        return global_config.confirm_panel_remove;
85
 
}
86
 
 
87
 
static void
88
 
panel_global_config_set_entry (GConfEntry *entry)
89
 
{
90
 
        GConfValue *value;
91
 
        const char *key;
92
 
 
93
 
        g_return_if_fail (entry != NULL);
94
 
 
95
 
        value = gconf_entry_get_value (entry);
96
 
        key   = panel_gconf_basename (gconf_entry_get_key (entry));
97
 
 
98
 
        if (!value || !key)
99
 
                return;
100
 
 
101
 
        if (strcmp (key, "tooltips_enabled") == 0)
102
 
                global_config.tooltips_enabled =
103
 
                                gconf_value_get_bool (value);
104
 
 
105
 
        else if (strcmp (key, "enable_animations") == 0)
106
 
                global_config.enable_animations =
107
 
                                gconf_value_get_bool (value);
108
 
 
109
 
        else if (strcmp (key, "drawer_autoclose") == 0)
110
 
                global_config.drawer_auto_close =
111
 
                        gconf_value_get_bool (value);
112
 
 
113
 
        else if (strcmp (key, "confirm_panel_remove") == 0)
114
 
                global_config.confirm_panel_remove =
115
 
                        gconf_value_get_bool (value);
116
 
 
117
 
        else if (strcmp (key, "highlight_launchers_on_mouseover") == 0)
118
 
                global_config.highlight_when_over =
119
 
                        gconf_value_get_bool (value);
120
 
}
121
 
 
122
 
static void
123
 
panel_global_config_notify (GConfClient *client,
124
 
                            guint        cnxn_id,
125
 
                            GConfEntry  *entry,
126
 
                            gpointer     user_data)
127
 
{
128
 
        panel_global_config_set_entry (entry);
129
 
}
130
 
 
131
 
void
132
 
panel_global_config_load (void)
133
 
{
134
 
        GConfClient *client;
135
 
        GSList      *l, *entries;
136
 
        const char  *key = "/apps/panel/global";
137
 
 
138
 
        client = panel_gconf_get_client ();
139
 
 
140
 
        gconf_client_add_dir (client, key, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
141
 
 
142
 
        entries = gconf_client_all_entries (client, key, NULL);
143
 
 
144
 
        for (l = entries; l; l = l->next) {
145
 
                panel_global_config_set_entry (l->data);
146
 
                gconf_entry_unref (l->data);
147
 
        }
148
 
        g_slist_free (entries);
149
 
 
150
 
        gconf_client_notify_add (client, key, panel_global_config_notify, NULL, NULL, NULL);
151
 
 
152
 
        global_config_initialised = TRUE;
153
 
}