[gnome-power-manager] Make the battery status translatable in gnome-power-statistics
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-power-manager] Make the battery status translatable in gnome-power-statistics
- Date: Tue, 30 Mar 2010 13:23:22 +0000 (UTC)
commit f2c04094f44f69c37b8799b98d330b34cfc5166b
Author: Richard Hughes <richard hughsie com>
Date: Tue Mar 30 14:23:10 2010 +0100
Make the battery status translatable in gnome-power-statistics
src/gpm-manager.c | 2 +-
src/gpm-statistics.c | 6 +++---
src/gpm-tray-icon.c | 2 +-
src/gpm-upower.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
src/gpm-upower.h | 9 +++++----
5 files changed, 54 insertions(+), 13 deletions(-)
---
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index 0f3c0bb..c5e24be 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -1375,7 +1375,7 @@ gpm_manager_engine_discharging_cb (GpmEngine *engine, UpDevice *device, GpmManag
/* only show text if there is a valid time */
if (time_to_empty > 0)
remaining_text = gpm_get_timestring (time_to_empty);
- kind_desc = gpm_device_kind_to_localised_text (kind, 1);
+ kind_desc = gpm_device_kind_to_localised_string (kind, 1);
if (kind == UP_DEVICE_KIND_BATTERY) {
/* TRANSLATORS: laptop battery is now discharging */
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index bd98f89..f46c411 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -399,7 +399,7 @@ gpm_stats_update_info_page_details (UpDevice *device)
gpm_stats_add_info_data (_("Device"), device_path);
g_free (device_path);
- gpm_stats_add_info_data (_("Type"), gpm_device_kind_to_localised_text (kind, 1));
+ gpm_stats_add_info_data (_("Type"), gpm_device_kind_to_localised_string (kind, 1));
if (vendor != NULL && vendor[0] != '\0')
gpm_stats_add_info_data (_("Vendor"), vendor);
if (model != NULL && model[0] != '\0')
@@ -425,7 +425,7 @@ gpm_stats_update_info_page_details (UpDevice *device)
if (kind == UP_DEVICE_KIND_BATTERY ||
kind == UP_DEVICE_KIND_MOUSE ||
kind == UP_DEVICE_KIND_KEYBOARD)
- gpm_stats_add_info_data (_("State"), up_device_state_to_string (state));
+ gpm_stats_add_info_data (_("State"), gpm_device_state_to_localised_string (state));
if (kind == UP_DEVICE_KIND_BATTERY) {
text = g_strdup_printf ("%.1f Wh", energy);
gpm_stats_add_info_data (_("Energy"), text);
@@ -1155,7 +1155,7 @@ gpm_stats_add_device (UpDevice *device)
NULL);
id = up_device_get_object_path (device);
- text = gpm_device_kind_to_localised_text (kind, 1);
+ text = gpm_device_kind_to_localised_string (kind, 1);
icon = gpm_upower_get_device_icon (device);
gtk_list_store_append (list_store_devices, &iter);
diff --git a/src/gpm-tray-icon.c b/src/gpm-tray-icon.c
index 4b9623d..2a16551 100644
--- a/src/gpm-tray-icon.c
+++ b/src/gpm-tray-icon.c
@@ -233,7 +233,7 @@ gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *arr
added++;
/* generate the label */
- desc = gpm_device_kind_to_localised_text (kind, 1);
+ desc = gpm_device_kind_to_localised_string (kind, 1);
label = g_strdup_printf ("%s (%.1f%%)", desc, percentage);
item = gtk_image_menu_item_new_with_label (label);
diff --git a/src/gpm-upower.c b/src/gpm-upower.c
index 838c252..4710bf4 100644
--- a/src/gpm-upower.c
+++ b/src/gpm-upower.c
@@ -206,7 +206,7 @@ gpm_upower_get_device_summary (UpDevice *device)
if (!is_present)
return NULL;
- kind_desc = gpm_device_kind_to_localised_text (kind, 1);
+ kind_desc = gpm_device_kind_to_localised_string (kind, 1);
/* don't display all the extra stuff for keyboards and mice */
if (kind == UP_DEVICE_KIND_MOUSE ||
@@ -352,7 +352,7 @@ gpm_upower_get_device_description (UpDevice *device)
NULL);
details = g_string_new ("");
- text = gpm_device_kind_to_localised_text (kind, 1);
+ text = gpm_device_kind_to_localised_string (kind, 1);
/* TRANSLATORS: the type of data, e.g. Laptop battery */
g_string_append_printf (details, "<b>%s</b> %s\n", _("Product:"), text);
@@ -466,10 +466,10 @@ gpm_upower_get_device_description (UpDevice *device)
}
/**
- * gpm_device_kind_to_localised_text:
+ * gpm_device_kind_to_localised_string:
**/
const gchar *
-gpm_device_kind_to_localised_text (UpDeviceKind kind, guint number)
+gpm_device_kind_to_localised_string (UpDeviceKind kind, guint number)
{
const gchar *text = NULL;
switch (kind) {
@@ -594,3 +594,43 @@ gpm_device_technology_to_localised_string (UpDeviceTechnology technology_enum)
return technology;
}
+/**
+ * gpm_device_state_to_localised_string:
+ **/
+const gchar *
+gpm_device_state_to_localised_string (UpDeviceState state)
+{
+ const gchar *state_string = NULL;
+
+ switch (state) {
+ case UP_DEVICE_STATE_CHARGING:
+ /* TRANSLATORS: battery state */
+ state_string = _("Charging");
+ break;
+ case UP_DEVICE_STATE_DISCHARGING:
+ /* TRANSLATORS: battery state */
+ state_string = _("Discharging");
+ break;
+ case UP_DEVICE_STATE_EMPTY:
+ /* TRANSLATORS: battery state */
+ state_string = _("Empty");
+ break;
+ case UP_DEVICE_STATE_FULLY_CHARGED:
+ /* TRANSLATORS: battery state */
+ state_string = _("Fully charged");
+ break;
+ case UP_DEVICE_STATE_PENDING_CHARGE:
+ /* TRANSLATORS: battery state */
+ state_string = _("Waiting to charge");
+ break;
+ case UP_DEVICE_STATE_PENDING_DISCHARGE:
+ /* TRANSLATORS: battery state */
+ state_string = _("Waiting to discharge");
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ return state_string;
+}
+
diff --git a/src/gpm-upower.h b/src/gpm-upower.h
index 7b0580a..c1a9c03 100644
--- a/src/gpm-upower.h
+++ b/src/gpm-upower.h
@@ -27,13 +27,14 @@
G_BEGIN_DECLS
-const gchar *gpm_device_kind_to_localised_text (UpDeviceKind kind,
+const gchar *gpm_device_kind_to_localised_string (UpDeviceKind kind,
guint number);
const gchar *gpm_device_kind_to_icon (UpDeviceKind kind);
const gchar *gpm_device_technology_to_localised_string (UpDeviceTechnology technology_enum);
-gchar *gpm_upower_get_device_icon (UpDevice *device);
-gchar *gpm_upower_get_device_summary (UpDevice *device);
-gchar *gpm_upower_get_device_description (UpDevice *device);
+const gchar *gpm_device_state_to_localised_string (UpDeviceState state);
+gchar *gpm_upower_get_device_icon (UpDevice *device);
+gchar *gpm_upower_get_device_summary (UpDevice *device);
+gchar *gpm_upower_get_device_description (UpDevice *device);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]