188
195
device->priv->capacity = g_value_get_double (value);
189
196
else if (g_strcmp0 (key, "state") == 0)
190
197
device->priv->state = g_value_get_uint (value);
198
else if (g_strcmp0 (key, "recall-notice") == 0)
199
device->priv->recall_notice = g_value_get_boolean (value);
200
else if (g_strcmp0 (key, "recall-vendor") == 0)
201
device->priv->recall_vendor = g_strdup (g_value_get_string (value));
202
else if (g_strcmp0 (key, "recall-url") == 0)
203
device->priv->recall_url = g_strdup (g_value_get_string (value));
192
205
g_warning ("unhandled property '%s'", key);
193
g_assert_not_reached ();
382
393
strftime (time_buf, sizeof time_buf, "%c", time_tm);
384
395
g_print (" native-path: %s\n", device->priv->native_path);
385
if (device->priv->vendor != NULL)
396
if (device->priv->vendor != NULL && device->priv->vendor[0] != '\0')
386
397
g_print (" vendor: %s\n", device->priv->vendor);
387
if (device->priv->model != NULL)
398
if (device->priv->model != NULL && device->priv->model[0] != '\0')
388
399
g_print (" model: %s\n", device->priv->model);
389
if (device->priv->serial != NULL)
400
if (device->priv->serial != NULL && device->priv->serial[0] != '\0')
390
401
g_print (" serial: %s\n", device->priv->serial);
391
402
g_print (" power supply: %s\n", dkp_device_print_bool_to_text (device->priv->power_supply));
392
403
g_print (" updated: %s (%d seconds ago)\n", time_buf, (int) (time (NULL) - device->priv->update_time));
405
416
g_print (" rechargeable: %s\n", dkp_device_print_bool_to_text (device->priv->is_rechargeable));
406
417
if (device->priv->type == DKP_DEVICE_TYPE_BATTERY ||
407
418
device->priv->type == DKP_DEVICE_TYPE_MOUSE ||
408
device->priv->type == DKP_DEVICE_TYPE_KEYBOARD)
419
device->priv->type == DKP_DEVICE_TYPE_KEYBOARD ||
420
device->priv->type == DKP_DEVICE_TYPE_UPS)
409
421
g_print (" state: %s\n", dkp_device_state_to_text (device->priv->state));
410
422
if (device->priv->type == DKP_DEVICE_TYPE_BATTERY) {
411
423
g_print (" energy: %g Wh\n", device->priv->energy);
418
430
g_print (" energy-rate: %g W\n", device->priv->energy_rate);
419
431
if (device->priv->type == DKP_DEVICE_TYPE_UPS ||
420
432
device->priv->type == DKP_DEVICE_TYPE_BATTERY ||
421
device->priv->type == DKP_DEVICE_TYPE_MONITOR)
422
g_print (" voltage: %g V\n", device->priv->voltage);
433
device->priv->type == DKP_DEVICE_TYPE_MONITOR) {
434
if (device->priv->voltage > 0)
435
g_print (" voltage: %g V\n", device->priv->voltage);
423
437
if (device->priv->type == DKP_DEVICE_TYPE_BATTERY ||
424
438
device->priv->type == DKP_DEVICE_TYPE_UPS) {
425
if (device->priv->time_to_full >= 0) {
439
if (device->priv->time_to_full > 0) {
426
440
time_str = dkp_device_print_time_to_text (device->priv->time_to_full);
427
441
g_print (" time to full: %s\n", time_str);
428
442
g_free (time_str);
430
if (device->priv->time_to_empty >= 0) {
444
if (device->priv->time_to_empty > 0) {
431
445
time_str = dkp_device_print_time_to_text (device->priv->time_to_empty);
432
446
g_print (" time to empty: %s\n", time_str);
433
447
g_free (time_str);
438
452
device->priv->type == DKP_DEVICE_TYPE_KEYBOARD ||
439
453
device->priv->type == DKP_DEVICE_TYPE_UPS)
440
454
g_print (" percentage: %g%%\n", device->priv->percentage);
441
if (device->priv->type == DKP_DEVICE_TYPE_BATTERY)
442
g_print (" capacity: %g%%\n", device->priv->capacity);
443
if (device->priv->type == DKP_DEVICE_TYPE_BATTERY)
444
g_print (" technology: %s\n", dkp_device_technology_to_text (device->priv->technology));
455
if (device->priv->type == DKP_DEVICE_TYPE_BATTERY) {
456
if (device->priv->capacity > 0)
457
g_print (" capacity: %g%%\n", device->priv->capacity);
459
if (device->priv->type == DKP_DEVICE_TYPE_BATTERY) {
460
if (device->priv->technology != DKP_DEVICE_TECHNOLOGY_UNKNOWN)
461
g_print (" technology: %s\n", dkp_device_technology_to_text (device->priv->technology));
445
463
if (device->priv->type == DKP_DEVICE_TYPE_LINE_POWER)
446
464
g_print (" online: %s\n", dkp_device_print_bool_to_text (device->priv->online));
465
if (device->priv->type == DKP_DEVICE_TYPE_BATTERY) {
466
if (device->priv->recall_notice) {
467
g_print (" recall vendor: %s\n", device->priv->recall_vendor);
468
g_print (" recall url: %s\n", device->priv->recall_url);
448
472
/* if we can, get history */
449
473
if (device->priv->has_history) {
715
739
case PROP_TECHNOLOGY:
716
740
device->priv->technology = g_value_get_uint (value);
742
case PROP_RECALL_NOTICE:
743
device->priv->recall_notice = g_value_get_boolean (value);
745
case PROP_RECALL_VENDOR:
746
g_free (device->priv->recall_vendor);
747
device->priv->recall_vendor = g_strdup (g_value_get_string (value));
749
case PROP_RECALL_URL:
750
g_free (device->priv->recall_url);
751
device->priv->recall_url = g_strdup (g_value_get_string (value));
719
754
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
802
837
case PROP_PERCENTAGE:
803
838
g_value_set_double (value, device->priv->percentage);
840
case PROP_RECALL_NOTICE:
841
g_value_set_boolean (value, device->priv->recall_notice);
843
case PROP_RECALL_VENDOR:
844
g_value_set_string (value, device->priv->recall_vendor);
846
case PROP_RECALL_URL:
847
g_value_set_string (value, device->priv->recall_url);
806
850
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1047
1091
g_param_spec_double ("percentage", NULL, NULL,
1048
1092
0.0, 100.f, 100.0,
1049
1093
G_PARAM_READWRITE));
1095
* DkpDevice:recall-notice:
1097
g_object_class_install_property (object_class,
1099
g_param_spec_boolean ("recall-notice",
1102
G_PARAM_READWRITE));
1104
* DkpDevice:recall-vendor:
1106
g_object_class_install_property (object_class,
1108
g_param_spec_string ("recall-vendor",
1111
G_PARAM_READWRITE));
1113
* DkpDevice:recall-url:
1115
g_object_class_install_property (object_class,
1117
g_param_spec_string ("recall-url",
1120
G_PARAM_READWRITE));
1051
1122
g_type_class_add_private (klass, sizeof (DkpDevicePrivate));
1082
1153
g_free (device->priv->model);
1083
1154
g_free (device->priv->serial);
1084
1155
g_free (device->priv->native_path);
1156
g_free (device->priv->recall_vendor);
1157
g_free (device->priv->recall_url);
1085
1158
if (device->priv->proxy_device != NULL)
1086
1159
g_object_unref (device->priv->proxy_device);
1087
1160
if (device->priv->proxy_props != NULL)