~ubuntu-branches/ubuntu/hardy/gnome-applets/hardy-updates

« back to all changes in this revision

Viewing changes to libgweather/gweather-gconf.c

  • Committer: Bazaar Package Importer
  • Author(s): Loic Minier
  • Date: 2008-01-15 15:16:45 UTC
  • mfrom: (1.1.25 upstream)
  • Revision ID: james.westby@ubuntu.com-20080115151645-7adqdys4ovi43xqs
Tags: 2.21.4-0ubuntu1
* New upstream development release.
  - Upstream news:
    . libgweather has been moved off to it's own module.
    . Accessx Status Applet:
       - Make bug buddy work for this applet (Kjartan Maraas).
    . Character Picker:
       - Documentation fixes.
    . CPU Frequency Monitor:
       - Fix memory leaks (kripkensteiner@gmail.com).
    . Keyboard Indicator:
       - The layout can now be printed from the preview (Sergey Udaltsov).
       - Require libgnomekbd 2.21.4.1 or later (Sergey Udaltsov).
    . Mixer:
       - Accelerators have been removed from the menu since they were.
         virtually never usable and now you won't be tempted to type Ctrl-T.
         in an unfortunate context. The normal under-score style menu.
         sortcuts are still available (Ted Gould).
    . Null Applet:
       - Make sure our example doesn't crash (Ray Strode).
    . Sticky Notes:
       - Better alignment in the UI (Christian Rose, Andrew Burton).
    . General:
       - Don't install documentation from obsolete applets (Kjartan Maraas).
    . Translations:
      ar, ca, es, et, eu, ga, he, nb, nn, oc, vi, sk, sv
    . Documentation Translations:
      ca, sv
  - Add a libgweather-dev (>= 2.21.1) build-dep.
  - Bump up libgnomekbdui-dev build-dep to >= 2.21.4.1.
  - Drop patches 05_gweather-dist-fixes, 06_gweather-dist-files,
    08_gweather_locations: the files which these patches used to dist and
    fix are now in libgweather.
  - Update autoreconf patch, 98_autoreconf.
  - Drop now useless gnome-applets-dev package.
  - Update gnome-applets' install file.
  - Drop DEB_DH_MAKESHLIBS_ARGS_gnome-applets.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * gweather-gconf.c: GConf interaction methods for gweather.
3
 
 *
4
 
 * Copyright (C) 2005 Philip Langdale, Papadimitriou Spiros
5
 
 *
6
 
 * This library is free software; you can redistribute it and/or
7
 
 * modify it under the terms of the GNU General Public
8
 
 * License as published by the Free Software Foundation; either
9
 
 * version 2 of the License, or (at your option) any later version.
10
 
 *
11
 
 * This library is distributed in the hope that it will be useful,
12
 
 * but 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
17
 
 * License along with this library; if not, write to the
18
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
 
 * Boston, MA 02111-1307, USA.
20
 
 *
21
 
 * Authors:
22
 
 *     Philip Langdale <philipl@mail.utexas.edu>
23
 
 *     Papadimitriou Spiros <spapadim+@cs.cmu.edu>
24
 
 */
25
 
 
26
 
#ifdef HAVE_CONFIG_H
27
 
#  include <config.h>
28
 
#endif
29
 
 
30
 
#include <string.h>
31
 
#include <glib/gi18n-lib.h>
32
 
#include <libgweather/gweather-gconf.h>
33
 
 
34
 
struct _GWeatherGConf
35
 
{
36
 
        GConfClient *gconf;
37
 
        char *prefix;
38
 
};
39
 
 
40
 
 
41
 
GWeatherGConf *
42
 
gweather_gconf_new(const char *prefix)
43
 
{
44
 
        GWeatherGConf *ctx = g_new0(GWeatherGConf, 1);
45
 
        ctx->gconf = gconf_client_get_default();
46
 
        ctx->prefix = g_strdup(prefix);
47
 
 
48
 
        return ctx;
49
 
}
50
 
 
51
 
 
52
 
void
53
 
gweather_gconf_free(GWeatherGConf *ctx)
54
 
{
55
 
        g_object_unref(ctx->gconf);
56
 
        g_free(ctx->prefix);
57
 
        g_free(ctx);
58
 
}
59
 
 
60
 
 
61
 
GConfClient *
62
 
gweather_gconf_get_client(GWeatherGConf *ctx)
63
 
{
64
 
        return ctx->gconf;
65
 
}
66
 
 
67
 
 
68
 
gchar *
69
 
gweather_gconf_get_full_key (GWeatherGConf *ctx,
70
 
                             const gchar     *key)
71
 
{
72
 
        return g_strdup_printf ("%s/%s", ctx->prefix, key);
73
 
}
74
 
 
75
 
void
76
 
gweather_gconf_set_bool (GWeatherGConf *ctx,
77
 
                         const gchar     *key,
78
 
                         gboolean         the_bool,
79
 
                         GError         **opt_error)
80
 
{
81
 
        gchar *full_key = gweather_gconf_get_full_key (ctx, key);
82
 
        gconf_client_set_bool (ctx->gconf, full_key, the_bool, opt_error);
83
 
        g_free (full_key);
84
 
}
85
 
 
86
 
void
87
 
gweather_gconf_set_int (GWeatherGConf *ctx,
88
 
                        const gchar     *key,
89
 
                        gint             the_int,
90
 
                        GError         **opt_error)
91
 
{
92
 
        gchar *full_key = gweather_gconf_get_full_key (ctx, key);
93
 
        gconf_client_set_int (ctx->gconf, full_key, the_int, opt_error);
94
 
        g_free (full_key);
95
 
}
96
 
 
97
 
void
98
 
gweather_gconf_set_string (GWeatherGConf *ctx,
99
 
                           const gchar     *key,
100
 
                           const gchar     *the_string,
101
 
                           GError         **opt_error)
102
 
{
103
 
        gchar *full_key = gweather_gconf_get_full_key (ctx, key);
104
 
        gconf_client_set_string (ctx->gconf, full_key, the_string, opt_error);
105
 
        g_free (full_key);
106
 
}
107
 
 
108
 
gboolean
109
 
gweather_gconf_get_bool (GWeatherGConf *ctx,
110
 
                         const gchar     *key,
111
 
                         GError         **opt_error)
112
 
{
113
 
        gchar *full_key = gweather_gconf_get_full_key (ctx, key);
114
 
        gboolean ret = gconf_client_get_bool (ctx->gconf, full_key, opt_error);
115
 
        g_free (full_key);
116
 
        return ret;
117
 
}
118
 
 
119
 
gint
120
 
gweather_gconf_get_int (GWeatherGConf *ctx,
121
 
                        const gchar     *key,
122
 
                        GError         **opt_error)
123
 
{
124
 
        gchar *full_key = gweather_gconf_get_full_key (ctx, key);
125
 
        gint ret = gconf_client_get_int (ctx->gconf, full_key, opt_error);
126
 
        g_free (full_key);
127
 
        return ret;
128
 
}
129
 
 
130
 
gchar *
131
 
gweather_gconf_get_string (GWeatherGConf *ctx,
132
 
                           const gchar     *key,
133
 
                           GError         **opt_error)
134
 
{
135
 
        gchar *full_key = gweather_gconf_get_full_key (ctx, key);
136
 
        gchar *ret = gconf_client_get_string (ctx->gconf, full_key, opt_error);
137
 
        g_free (full_key);
138
 
        return ret;
139
 
}
140
 
 
141
 
 
142
 
WeatherLocation *
143
 
gweather_gconf_get_location(GWeatherGConf *ctx)
144
 
{
145
 
    WeatherLocation *location;
146
 
    gchar *name, *code, *zone, *radar, *coordinates;
147
 
    
148
 
    name = gweather_gconf_get_string (ctx, "location4", NULL);
149
 
    if (!name)
150
 
    {
151
 
        /* TRANSLATOR: Change this to the default location name,
152
 
         * used when you first start the Weather Applet. This is
153
 
         * the common localised name that corresponds to
154
 
         * the location code (DEFAULT_CODE) you will put on the next message
155
 
         * For example, for the Greek locale, we set this to "Athens", the
156
 
         * capital city and we write it in Greek. It's important to translate
157
 
         * this name.
158
 
         *
159
 
         * If you do not require a DEFAULT_LOCATION, set this to
160
 
         * "DEFAULT_LOCATION".
161
 
         */
162
 
        if (strcmp ("DEFAULT_LOCATION", _("DEFAULT_LOCATION")))
163
 
            name = g_strdup (_("DEFAULT_LOCATION"));
164
 
        else
165
 
            name = g_strdup ("Pittsburgh");
166
 
    }
167
 
 
168
 
    code = gweather_gconf_get_string (ctx, "location1", NULL);
169
 
    if (!code) 
170
 
    {
171
 
        /* TRANSLATOR: Change this to the code of your default location that
172
 
         * corresponds to the DEFAULT_LOCATION name you put above. This is
173
 
         * normally a four-letter (ICAO) code and can be found in
174
 
         * http://cvs.gnome.org/viewcvs/gnome-applets/gweather/Locations.xml.in
175
 
         * NB. The web page is over 1.7MB in size.
176
 
         * Pick a default location like a capital city so that it would be ok
177
 
         * for more of your users. For example, for Greek, we use "LGAV" for
178
 
         * the capital city, Athens.
179
 
         * 
180
 
         * If you do not require a DEFAULT_CODE, set this to "DEFAULT_CODE".
181
 
         */
182
 
        if (strcmp ("DEFAULT_CODE", _("DEFAULT_CODE")))
183
 
            code = g_strdup (_("DEFAULT_CODE"));
184
 
        else
185
 
            code = g_strdup ("KPIT");
186
 
    }
187
 
 
188
 
    zone = gweather_gconf_get_string (ctx, "location2", NULL);
189
 
    if (!zone)
190
 
    {
191
 
        /* TRANSLATOR: Change this to the zone of your default location that
192
 
         * corresponds to the DEFAULT_LOCATION and DEFAULT_CODE you put above.
193
 
         * Normally, US and Canada locations have zones while the rest do not.
194
 
         * Check
195
 
         * http://cvs.gnome.org/viewcvs/gnome-applets/gweather/Locations.xml.in
196
 
         * as any zone you put here must also be present in the Locations.xml
197
 
         * file.
198
 
         * 
199
 
         * If your default location does not have a zone, set this to
200
 
         * "DEFAULT_ZONE".
201
 
         */
202
 
        if (strcmp ("DEFAULT_ZONE", _("DEFAULT_ZONE")))
203
 
            zone = g_strdup (_("DEFAULT_ZONE" ));
204
 
        else
205
 
            zone = g_strdup ("PAZ021");
206
 
    }
207
 
 
208
 
    radar = gweather_gconf_get_string(ctx, "location3", NULL);
209
 
    if (!radar)
210
 
    {
211
 
        /* TRANSLATOR: Change this to the radar of your default location that
212
 
         * corresponds to the DEFAULT_LOCATION and DEFAULT_CODE you put above.
213
 
         * Normally, US and Canada locations have radar names while the rest do
214
 
         * not. Check
215
 
         * http://cvs.gnome.org/viewcvs/gnome-applets/gweather/Locations.xml.in
216
 
         * as any radar you put here must also be present in the Locations.xml
217
 
         * file.
218
 
         * 
219
 
         * If your default location does not have a radar, set this to " "
220
 
         * (or space).
221
 
         * If you do not have a default location, set this to DEFAULT_RADAR.
222
 
         */
223
 
        if (strcmp ("DEFAULT_RADAR", _("DEFAULT_RADAR")))
224
 
            radar = g_strdup (_("DEFAULT_RADAR"));
225
 
        else
226
 
            radar = g_strdup ("pit");
227
 
    }
228
 
 
229
 
    coordinates = gweather_gconf_get_string (ctx, "coordinates", NULL);
230
 
    if (!coordinates)
231
 
    {
232
 
        /* TRANSLATOR: Change this to the coordinates of your default location
233
 
         * that corresponds to the DEFAULT_LOCATION and DEFAULT_CODE you put
234
 
         * above. Check
235
 
         * http://cvs.gnome.org/viewcvs/gnome-applets/gweather/Locations.xml.in
236
 
         * as any coordinates you put here must also be present in the
237
 
         * Locations.xml file.
238
 
         * 
239
 
         * If your default location does not have known coordinates, set this
240
 
         * to " " (or space).
241
 
         * If you do not have a default location, set this to
242
 
         * DEFAULT_COORDINATES.
243
 
         */
244
 
        if (strcmp ("DEFAULT_COORDINATES", _("DEFAULT_COORDINATES")))
245
 
            coordinates = g_strdup (_("DEFAULT_COORDINATES"));
246
 
        else 
247
 
            coordinates = g_strdup ("40-32N 080-13W");
248
 
    }
249
 
    
250
 
    location = weather_location_new (name, code, zone, radar, coordinates);
251
 
    
252
 
    g_free (name);
253
 
    g_free (code);
254
 
    g_free (zone);
255
 
    g_free (radar);
256
 
    g_free (coordinates);
257
 
    
258
 
    return location;
259
 
}