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."),
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);
92
95
panel_applet_gconf_set_bool(sensors_applet->applet, IS_SETUP, FALSE, NULL);
159
162
g_slist_foreach(alarm_commands, (GFunc)g_free, NULL);
160
163
g_slist_free(alarm_commands);
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);
167
170
g_debug("Previous configuration not found: %s, setting up manually", error->message);
185
187
old_version = NULL;
188
190
if (old_version) {
189
191
if (sensors_applet_gconf_is_compatible(old_version)) {
190
192
/* previously setup and versions match so use
192
194
g_debug("GConf data is compatible. Trying to set up sensors from gconf data");
193
196
if (sensors_applet_gconf_setup_sensors(sensors_applet)) {
194
197
g_debug("done setting up from gconf");
205
208
g_free(old_version);
208
211
sensors_applet_notify(sensors_applet, GCONF_READ_ERROR);
211
214
sensors_applet_gconf_error_occurred(SENSORS_APPLET_VERSION_ERROR);
214
217
/* use defaults */
215
218
g_debug("Setting gconf defaults only");
216
219
sensors_applet_gconf_set_defaults(sensors_applet);
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 */
320
GSList *lists[NUM_KEYS] = {NULL};
323
GSList *lists[NUM_KEYS] = {NULL};
322
GSList *current[NUM_KEYS] = {NULL};
325
GSList *current[NUM_KEYS] = {NULL};
324
327
GError *error = NULL;
326
329
for (i = 0; i < NUM_KEYS; i++) {
327
lists[i] = panel_applet_gconf_get_list(sensors_applet->applet,
330
lists[i] = panel_applet_gconf_get_list(sensors_applet->applet,
331
334
if (error || NULL == lists[i]) {
332
335
sensors_applet_notify(sensors_applet, GCONF_READ_ERROR);
334
337
sensors_applet_gconf_error_occurred(SENSORS_APPLET_GCONF_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)
374
377
sensors_applet_gconf_free_lists(lists,
391
394
GSList *lists[NUM_KEYS] = {NULL};
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,
399
guint current_alarm_timeout, current_sensor_type,
402
guint current_alarm_timeout, current_sensor_type,
400
403
current_icon_type;
402
405
GError *error = NULL;
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, ¤t_id,
413
416
panel_applet_gconf_set_bool(sensors_applet->applet, current_id, TRUE, NULL);
414
417
g_free(current_id);
416
419
/* reset sensors sentinel */
417
420
not_end_of_sensors = TRUE;
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),
422
425
PATH_COLUMN, ¤t_path,
423
426
ID_COLUMN, ¤t_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]);
466
panel_applet_gconf_set_list(sensors_applet->applet,
469
panel_applet_gconf_set_list(sensors_applet->applet,
469
472
lists[i], &error);
471
474
sensors_applet_notify(sensors_applet, GCONF_WRITE_ERROR);
473
476
g_error_free(error);
477
480
g_debug("list %s is NULL", keys[i]);
482
485
sensors_applet_gconf_free_lists(lists,