~ubuntu-branches/ubuntu/wily/alarm-clock-applet/wily

« back to all changes in this revision

Viewing changes to src/alarm-gconf.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2010-03-17 09:02:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100317090244-ni0ye04mva2hxe10
Tags: 0.3.0-1
* New upstream release
* debian/control:
  + No change bump of Standards-Version to 3.8.4
  + Update build-deps:
    - Drop libglade, libpanel-applet, libgnomevfs2, libgnome{2,ui}
    - Add libxml2-dev and libunique-dev, intltool
* debian/patches/01_update-alarms-eta,patch:
  + Dropped, applied upstream
* debian/(alarm-clock-applet.1, alarm-clock-applet.manpages):
  + Add manpage for alarm-clock-applet, now that the binary is moved to
    /usr/bin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 */
23
23
 
24
24
#include <time.h>
25
 
#include <panel-applet-gconf.h>
26
25
 
27
26
#include "alarm-applet.h"
28
27
#include "alarm-gconf.h"
29
 
#include "edit-alarm.h"
 
28
#include "alarm-settings.h"
30
29
#include "alarm.h"
31
30
 
32
31
/*
41
40
/*
42
41
 * GCONF CALLBACKS {{
43
42
 */
44
 
 
 
43
/*
45
44
void
46
45
alarm_applet_gconf_show_label_changed (GConfClient  *client,
47
46
                                                                           guint         cnxn_id,
89
88
                pref_update_label_type (applet);
90
89
        }
91
90
}
92
 
 
93
 
 
94
 
/*
 
91
*/
 
92
 
 
93
/**
95
94
 * Triggered on global changes to our gconf preference dir.
96
95
 * We do this because we're interested in the events where
97
96
 * an alarm directory is either added or deleted externally.
98
97
 * 
99
98
 * When this happens we update our list of alarms.
100
99
 */
101
 
void
 
100
static void
102
101
alarm_applet_gconf_global_change (GConfClient  *client,
103
102
                                                                  guint         cnxn_id,
104
103
                                                                  GConfEntry   *entry,
111
110
        gint id, i, len;
112
111
        gboolean found = FALSE;
113
112
        
114
 
        //g_debug ("GLOBAL_change: %s", entry->key);
 
113
        g_debug ("GLOBAL_change: %s", entry->key);
115
114
        
116
115
        /*
117
116
         * We're only interested in the first part of the key matching
138
137
        if (id >= 0) {
139
138
                // Valid, probably an alarm which has been removed
140
139
                g_debug ("GLOBAL change ON alarm #%d", id);
141
 
                
142
 
                // Check if the alarm exists in our alarms list
 
140
        
 
141
        // Check if the alarm exists in our alarms list
143
142
                for (l = applet->alarms; l != NULL; l = l->next) {
144
143
                        a = ALARM (l->data);
145
144
                        if (a->id == id) {
154
153
                        g_debug ("\tDELETE alarm #%d %p", id, a);
155
154
                        
156
155
                        /* If there's a settings dialog open for this
157
 
                         * alarm, destroy it.
 
156
                         * alarm, close it.
158
157
                         */
159
 
                        AlarmSettingsDialog *sdialog = g_hash_table_lookup (applet->edit_alarm_dialogs, (gconstpointer)a->id);
160
 
                        if (sdialog) {
161
 
                                alarm_settings_dialog_close (sdialog);
 
158
            if (applet->settings_dialog->alarm == a) {
 
159
                                alarm_settings_dialog_close (applet->settings_dialog);
162
160
                        }
163
161
                        
164
162
                        /*
166
164
                         */
167
165
                        alarm_applet_alarms_remove (applet, a);
168
166
                        
169
 
                        // Update view
170
 
                        if (applet->list_alarms_dialog)
171
 
                                list_alarms_update (applet);
172
 
                        
173
167
                } else if (!found && entry->value != NULL) {
174
168
                        // ADDED ALARM
175
169
                        /*
180
174
                        g_debug ("\tADD alarm #%d %p", id, a);
181
175
                        
182
176
                        alarm_applet_alarms_add (applet, a);
183
 
                        
184
 
                        // Update view
185
 
                        if (applet->list_alarms_dialog)
186
 
                                list_alarms_update (applet);
187
 
                }
 
177
            
 
178
                } else if (found) {
 
179
            //alarm_list_window_alarm_update (applet->list_window, a);
 
180
        }
188
181
        }
189
182
        
190
183
        g_string_free (str, TRUE);
202
195
alarm_applet_gconf_init (AlarmApplet *applet)
203
196
{
204
197
        GConfClient *client;
205
 
        gchar       *key;
206
198
 
207
199
        client = gconf_client_get_default ();
 
200
 
 
201
    
208
202
        
209
 
        key = panel_applet_gconf_get_full_key (PANEL_APPLET (applet->parent), KEY_SHOW_LABEL);
 
203
        /*key = panel_applet_gconf_get_full_key (PANEL_APPLET (applet->parent), KEY_SHOW_LABEL);
210
204
        applet->listeners [0] =
211
205
                gconf_client_notify_add (
212
206
                                client, key,
221
215
                                (GConfClientNotifyFunc) alarm_applet_gconf_label_type_changed,
222
216
                                applet, NULL, NULL);
223
217
        g_free (key);
224
 
        
 
218
        */
225
219
        /*
226
220
         * Listen for changes to the alarms.
227
221
         * We want to know when an alarm is added and removed.
243
237
void
244
238
alarm_applet_gconf_load (AlarmApplet *applet)
245
239
{
246
 
        GConfClient *client;
247
 
        GConfValue      *value;
248
 
        gchar       *key;
249
 
        gchar           *tmp;
250
 
        
251
 
        client = gconf_client_get_default ();
252
 
        
253
 
        // SHOW_LABEL:
254
 
        key = panel_applet_gconf_get_full_key (PANEL_APPLET (applet->parent), KEY_SHOW_LABEL);
255
 
        value = gconf_client_get (client, key, NULL);
256
 
        if (value == NULL) {
257
 
                // Schema defaults not found
258
 
                applet->show_label = DEF_SHOW_LABEL;
259
 
                panel_applet_gconf_set_bool (applet->parent, KEY_SHOW_LABEL, DEF_SHOW_LABEL, NULL);
260
 
        } else {
261
 
                applet->show_label = gconf_value_get_bool (value);
262
 
                gconf_value_free (value);
263
 
        }
264
 
        g_free (key);
265
 
        
266
 
        
267
 
        // LABEL_TYPE:
268
 
        tmp = panel_applet_gconf_get_string (applet->parent, KEY_LABEL_TYPE, NULL);
269
 
        if (tmp == NULL || !gconf_string_to_enum (label_type_enum_map, tmp, (gint *)&(applet->label_type))) {
270
 
                // Schema defaults not found or unable to map
271
 
                applet->label_type = DEF_LABEL_TYPE;
272
 
                panel_applet_gconf_set_string (applet->parent, KEY_LABEL_TYPE, gconf_enum_to_string (label_type_enum_map, DEF_LABEL_TYPE), NULL);
273
 
        }
274
 
        g_free(tmp);
 
240
        /*GConfClient *client;
 
241
        
 
242
        client = gconf_client_get_default ();*/
275
243
}