~ubuntu-branches/debian/stretch/sensors-applet/stretch

« back to all changes in this revision

Viewing changes to sensors-applet/sensors-applet-gconf.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2011-11-05 14:53:12 UTC
  • mfrom: (1.2.7)
  • Revision ID: package-import@ubuntu.com-20111105145312-pce58z1ov0rc9moq
Tags: 3.0.0-0.1
* Non-maintainer upload.
* New upstream release, with support for GNOME3 Panel (closes: #638099).
* Drop link-to-libdl and libnotify_0.7_api_change patches, applied
  upstream.
* Drop dh_autoreconf and all bootstrap friends from Build-Depends and
  Build-Conflicts, not needed anymore.
* Update Build-Depends for the GTK+3 port, as per configure.ac.
* Drop .a and .la files (closes: #633257).
* Build-Depend on libsensors4 for kfreebsd again, as the package is now
* available on that architecture.
* Avoid hardcoding architecture names for libatamart-dev, and drop it
  entirely for libsensors4, as all architectures should be supported,
  even if the Hurd isn't available yet (closes: #634515).
* As libsensors-applet-plugin hasn't bumped its sonames but has at least
  got an ABI break (due to the switch to GTK+3), and given there are no
  external rdepends, avoid a library rename by bumping its shlibs and
  adding Breaks: sensor-applets (<< 3.0.0).
* Change install path for the applet binary, and remove obsolete dirs.
* Tighten sensors-applet dependency on libsensors-applet-plugin to
  (= ${binary:Version}), just in case.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include "config.h"
21
21
#endif /* HAVE_CONFIG_H */
22
22
 
 
23
#include <glib/gi18n.h>
 
24
 
23
25
#include "sensors-applet.h"
24
26
#include "sensors-applet-gconf.h"
25
27
 
28
30
 
29
31
static const gchar * const compatible_versions[] = {
30
32
        PACKAGE_VERSION, /* always list current version */
 
33
        "2.2.7",
31
34
        "2.2.6",
32
35
        "2.2.5",
33
36
        "2.2.4",
50
53
static const gchar * const error_messages[] = {
51
54
        N_("An error has occurred when loading the stored sensors data. "
52
55
           "The default values will be used to recover from this error."),
53
 
        
 
56
 
54
57
        N_("Unfortunately the previous configuration for GNOME Sensors Applet "
55
58
           "is not compatible with this version. The existing sensors data "
56
59
           "will be overwritten with the default values for this new version.")
88
91
        panel_applet_gconf_set_int(sensors_applet->applet, GRAPH_SIZE, DEFAULT_GRAPH_SIZE, NULL);
89
92
#ifdef HAVE_LIBNOTIFY
90
93
        panel_applet_gconf_set_bool(sensors_applet->applet, DISPLAY_NOTIFICATIONS, TRUE, NULL);
91
 
#endif        
 
94
#endif
92
95
        panel_applet_gconf_set_bool(sensors_applet->applet, IS_SETUP, FALSE, NULL);
93
96
 
94
97
}
128
131
                                           "num_samples",
129
132
                                           0,
130
133
                                           NULL);
131
 
                
132
 
        }                                      
 
134
 
 
135
        }
133
136
 
134
137
        /* convert old alarm_commands to high and low if exist */
135
138
        GSList *alarm_commands;
137
140
                                                          "alarm_commands",
138
141
                                                          GCONF_VALUE_STRING,
139
142
                                                          NULL))) {
140
 
                
 
143
 
141
144
                g_debug("Converting old alarm commands to new high and low commands");
142
 
                
 
145
 
143
146
                panel_applet_gconf_set_list(sensors_applet->applet,
144
147
                                            LOW_ALARM_COMMANDS,
145
148
                                            GCONF_VALUE_STRING,
158
161
                                            NULL);
159
162
                g_slist_foreach(alarm_commands, (GFunc)g_free, NULL);
160
163
                g_slist_free(alarm_commands);
161
 
                
 
164
 
162
165
        }
163
166
 
164
 
        setup = panel_applet_gconf_get_bool(sensors_applet->applet, 
 
167
        setup = panel_applet_gconf_get_bool(sensors_applet->applet,
165
168
                                            IS_SETUP, &error);
166
169
        if (error) {
167
170
                g_debug("Previous configuration not found: %s, setting up manually", error->message);
170
173
                setup = FALSE;
171
174
        }
172
175
 
173
 
 
174
176
        if (setup) {
175
177
                /* see if setup version matches */
176
178
                old_version = panel_applet_gconf_get_string(sensors_applet->applet,
184
186
                        error = NULL;
185
187
                        old_version = NULL;
186
188
                }
187
 
                
 
189
 
188
190
                if (old_version) {
189
191
                        if (sensors_applet_gconf_is_compatible(old_version)) {
190
192
                                /* previously setup and versions match so use
191
193
                                 * old values */
192
194
                                g_debug("GConf data is compatible. Trying to set up sensors from gconf data");
 
195
 
193
196
                                if (sensors_applet_gconf_setup_sensors(sensors_applet)) {
194
197
                                        g_debug("done setting up from gconf");
195
198
                                } else {
200
203
 
201
204
                                return;
202
205
 
203
 
                                        
 
206
 
204
207
                        }
205
208
                        g_free(old_version);
206
209
 
207
210
                }
208
211
                sensors_applet_notify(sensors_applet, GCONF_READ_ERROR);
209
 
                
210
 
                        
 
212
 
 
213
 
211
214
                sensors_applet_gconf_error_occurred(SENSORS_APPLET_VERSION_ERROR);
212
215
        }
213
 
        
 
216
 
214
217
        /* use defaults */
215
218
        g_debug("Setting gconf defaults only");
216
219
        sensors_applet_gconf_set_defaults(sensors_applet);
221
224
        IDS_INDEX,
222
225
        LABELS_INDEX,
223
226
        INTERFACES_INDEX,
224
 
        SENSOR_TYPES_INDEX, 
225
 
        ENABLES_INDEX, 
226
 
        LOW_VALUES_INDEX, 
227
 
        HIGH_VALUES_INDEX, 
228
 
        ALARM_ENABLES_INDEX, 
229
 
        LOW_ALARM_COMMANDS_INDEX, 
 
227
        SENSOR_TYPES_INDEX,
 
228
        ENABLES_INDEX,
 
229
        LOW_VALUES_INDEX,
 
230
        HIGH_VALUES_INDEX,
 
231
        ALARM_ENABLES_INDEX,
 
232
        LOW_ALARM_COMMANDS_INDEX,
230
233
        HIGH_ALARM_COMMANDS_INDEX,
231
 
        ALARM_TIMEOUTS_INDEX, 
 
234
        ALARM_TIMEOUTS_INDEX,
232
235
        MULTIPLIERS_INDEX,
233
236
        OFFSETS_INDEX,
234
 
        ICON_TYPES_INDEX, 
 
237
        ICON_TYPES_INDEX,
235
238
        GRAPH_COLORS_INDEX,
236
239
        NUM_KEYS
237
240
};
241
244
        IDS,
242
245
        LABELS,
243
246
        INTERFACES,
244
 
        SENSOR_TYPES, 
245
 
        ENABLES, 
246
 
        LOW_VALUES, 
247
 
        HIGH_VALUES, 
248
 
        ALARM_ENABLES, 
 
247
        SENSOR_TYPES,
 
248
        ENABLES,
 
249
        LOW_VALUES,
 
250
        HIGH_VALUES,
 
251
        ALARM_ENABLES,
249
252
        LOW_ALARM_COMMANDS,
250
253
        HIGH_ALARM_COMMANDS,
251
 
        ALARM_TIMEOUTS, 
 
254
        ALARM_TIMEOUTS,
252
255
        MULTIPLIERS,
253
256
        OFFSETS,
254
 
        ICON_TYPES, 
 
257
        ICON_TYPES,
255
258
        GRAPH_COLORS,
256
259
};
257
260
 
317
320
           we set to -1, and visible which we set to false for all
318
321
           parent nodes and true for all child nodes */
319
322
        int i;
320
 
        GSList *lists[NUM_KEYS] = {NULL}; 
 
323
        GSList *lists[NUM_KEYS] = {NULL};
321
324
 
322
 
        GSList *current[NUM_KEYS] = {NULL}; 
 
325
        GSList *current[NUM_KEYS] = {NULL};
323
326
 
324
327
        GError *error = NULL;
325
328
 
326
329
        for (i = 0; i < NUM_KEYS; i++) {
327
 
                lists[i] = panel_applet_gconf_get_list(sensors_applet->applet, 
328
 
                                                       keys[i], 
329
 
                                                       key_types[i], 
 
330
                lists[i] = panel_applet_gconf_get_list(sensors_applet->applet,
 
331
                                                       keys[i],
 
332
                                                       key_types[i],
330
333
                                                       &error);
331
334
                if (error || NULL == lists[i]) {
332
335
                        sensors_applet_notify(sensors_applet, GCONF_READ_ERROR);
333
 
                
 
336
 
334
337
                        sensors_applet_gconf_error_occurred(SENSORS_APPLET_GCONF_ERROR);
335
338
                        if (error) {
336
339
                                g_error_free(error);
352
355
                /* need to ensure correct order */
353
356
                sensors_applet_add_sensor(sensors_applet,
354
357
                                          (gchar *)(current[PATHS_INDEX]->data),
355
 
                                          (gchar *)(current[IDS_INDEX]->data), 
356
 
                                          (gchar *)(current[LABELS_INDEX]->data), 
 
358
                                          (gchar *)(current[IDS_INDEX]->data),
 
359
                                          (gchar *)(current[LABELS_INDEX]->data),
357
360
                                          (gchar *)(current[INTERFACES_INDEX]->data),
358
361
                                          GPOINTER_TO_UINT(current[SENSOR_TYPES_INDEX]->data),
359
362
                                          GPOINTER_TO_INT(current[ENABLES_INDEX]->data),
367
370
                                          (gdouble)(GPOINTER_TO_INT(current[OFFSETS_INDEX]->data) / 1000.0),
368
371
                                          (SensorType)GPOINTER_TO_UINT(current[ICON_TYPES_INDEX]->data),
369
372
                                          (gchar *)(current[GRAPH_COLORS_INDEX]->data)
370
 
                                          
 
373
 
371
374
                        );
372
 
                
 
375
 
373
376
        }
374
377
        sensors_applet_gconf_free_lists(lists,
375
378
                                        NUM_KEYS);
391
394
        GSList *lists[NUM_KEYS] = {NULL};
392
395
        int i;
393
396
        gchar *current_path, *current_id, *current_label, *current_interface,
394
 
                *current_low_alarm_command, *current_high_alarm_command, 
 
397
                *current_low_alarm_command, *current_high_alarm_command,
395
398
                *current_graph_color;
396
399
        gboolean current_enable, current_alarm_enable;
397
 
        gdouble current_low_value, current_high_value, current_multiplier, 
 
400
        gdouble current_low_value, current_high_value, current_multiplier,
398
401
                current_offset;
399
 
        guint current_alarm_timeout, current_sensor_type, 
 
402
        guint current_alarm_timeout, current_sensor_type,
400
403
                current_icon_type;
401
 
        
 
404
 
402
405
        GError *error = NULL;
403
406
 
404
407
        /* now step through the GtkTreeStore sensors to
405
408
           find which sensors are enabled */
406
409
        for (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter); not_end_of_interfaces; not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) {
407
410
                // store a gconf key for this interface
408
 
                gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), 
 
411
                gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors),
409
412
                                   &interfaces_iter,
410
413
                                   ID_COLUMN, &current_id,
411
414
                                   -1);
412
415
 
413
416
                panel_applet_gconf_set_bool(sensors_applet->applet, current_id, TRUE, NULL);
414
417
                g_free(current_id);
415
 
                
 
418
 
416
419
                /* reset sensors sentinel */
417
420
                not_end_of_sensors = TRUE;
418
 
                
 
421
 
419
422
                for (gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter, &interfaces_iter); not_end_of_sensors; not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter)) {
420
 
                        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), 
 
423
                        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors),
421
424
                                           &sensors_iter,
422
425
                                           PATH_COLUMN, &current_path,
423
426
                                           ID_COLUMN, &current_id,
462
465
        for (i = 0; i < NUM_KEYS; i++) {
463
466
                if (lists[i] != NULL) {
464
467
                        lists[i] = g_slist_reverse(lists[i]);
465
 
                        
466
 
                        panel_applet_gconf_set_list(sensors_applet->applet, 
467
 
                                                    keys[i], 
 
468
 
 
469
                        panel_applet_gconf_set_list(sensors_applet->applet,
 
470
                                                    keys[i],
468
471
                                                    key_types[i],
469
472
                                                    lists[i], &error);
470
473
                        if (error) {
471
474
                                sensors_applet_notify(sensors_applet, GCONF_WRITE_ERROR);
472
 
                
 
475
 
473
476
                                g_error_free(error);
474
477
                                return FALSE;
475
478
                        }
476
479
                } else {
477
480
                        g_debug("list %s is NULL", keys[i]);
478
481
                }
479
 
                        
 
482
 
480
483
        }
481
484
 
482
485
        sensors_applet_gconf_free_lists(lists,
489
492
 
490
493
        return TRUE;
491
494
}
492