2
* * Copyright (C) 2010 Ali <aliov@xfce.org>
4
* Licensed under the GNU General Public License Version 2
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program 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
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25
#include <libxfce4util/libxfce4util.h>
26
#include <dbus/dbus-glib-lowlevel.h>
28
#include "xfpm-power-common.h"
29
#include "xfpm-enum-glib.h"
31
#include "xfpm-icons.h"
34
* xfpm_power_enumerate_devices:
38
xfpm_power_enumerate_devices (DBusGProxy *proxy)
42
GPtrArray *array = NULL;
45
g_type_array = dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH);
47
ret = dbus_g_proxy_call (proxy, "EnumerateDevices", &error,
53
g_critical ("Couldn't enumerate power devices: %s", error->message);
61
* xfpm_power_get_interface_properties:
64
GHashTable *xfpm_power_get_interface_properties (DBusGProxy *proxy_prop, const gchar *iface_name)
68
GHashTable *props = NULL;
72
ret = dbus_g_proxy_call (proxy_prop, "GetAll", &error,
73
G_TYPE_STRING, iface_name,
75
dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &props,
80
g_warning ("Unable to get interface properties for : %s : %s", iface_name, error->message);
88
* xfpm_power_get_interface_property:
91
GValue xfpm_power_get_interface_property (DBusGProxy *proxy, const gchar *iface_name, const gchar *prop_name)
95
GValue value = { 0, };
97
ret = dbus_g_proxy_call (proxy, "Get", &error,
98
G_TYPE_STRING, iface_name,
99
G_TYPE_STRING, prop_name,
101
G_TYPE_VALUE, &value, G_TYPE_INVALID);
105
g_warning ("Unable to get property %s on interface %s : %s", prop_name, iface_name, error->message);
106
g_error_free (error);
113
* xfpm_power_translate_device_type:
117
xfpm_power_translate_device_type (guint type)
121
case XFPM_DEVICE_TYPE_BATTERY:
123
case XFPM_DEVICE_TYPE_UPS:
125
case XFPM_DEVICE_TYPE_LINE_POWER:
126
return _("Line power");
127
case XFPM_DEVICE_TYPE_MOUSE:
129
case XFPM_DEVICE_TYPE_KBD:
130
return _("Keyboard");
131
case XFPM_DEVICE_TYPE_MONITOR:
133
case XFPM_DEVICE_TYPE_PDA:
135
case XFPM_DEVICE_TYPE_PHONE:
137
case XFPM_DEVICE_TYPE_UNKNOWN:
145
* xfpm_power_translate_technology:
148
const gchar *xfpm_power_translate_technology (guint value)
155
return _("Lithium ion");
157
return _("Lithium polymer");
159
return _("Lithium iron phosphate");
161
return _("Lead acid");
163
return _("Nickel cadmium");
165
return _("Nickel metal hybride");
171
const gchar *xfpm_power_get_icon_name (guint device_type)
175
case XFPM_DEVICE_TYPE_BATTERY:
176
return XFPM_BATTERY_ICON;
177
case XFPM_DEVICE_TYPE_UPS:
178
return XFPM_UPS_ICON;
179
case XFPM_DEVICE_TYPE_LINE_POWER:
180
return XFPM_AC_ADAPTER_ICON;
181
case XFPM_DEVICE_TYPE_MOUSE:
182
return XFPM_MOUSE_ICON;
183
case XFPM_DEVICE_TYPE_KBD:
184
return XFPM_KBD_ICON;
185
case XFPM_DEVICE_TYPE_MONITOR:
187
case XFPM_DEVICE_TYPE_PDA:
188
return XFPM_PDA_ICON;
189
case XFPM_DEVICE_TYPE_PHONE:
190
return XFPM_PHONE_ICON;
191
case XFPM_DEVICE_TYPE_UNKNOWN:
192
return XFPM_BATTERY_ICON;
195
return XFPM_BATTERY_ICON;