diff --git a/plugins/power/csd-power-manager.c b/plugins/power/csd-power-manager.c index 4e2b0c2..3a15985 100644 --- a/plugins/power/csd-power-manager.c +++ b/plugins/power/csd-power-manager.c @@ -155,7 +155,6 @@ struct CsdPowerManagerPrivate gint kbd_brightness_pre_dim; GnomeRRScreen *x11_screen; gboolean use_time_primary; - gchar *previous_summary; GIcon *previous_icon; GpmPhone *phone; GPtrArray *devices_array; @@ -204,7 +203,6 @@ static void csd_power_manager_finalize (GObject *object); static UpDevice *engine_get_composite_device (CsdPowerManager *manager, UpDevice *original_device); static UpDevice *engine_update_composite_device (CsdPowerManager *manager, UpDevice *original_device); static GIcon *engine_get_icon (CsdPowerManager *manager); -static gchar *engine_get_summary (CsdPowerManager *manager); static UpDevice *engine_get_primary_device (CsdPowerManager *manager); static void engine_charge_low (CsdPowerManager *manager, UpDevice *device); static void engine_charge_critical (CsdPowerManager *manager, UpDevice *device); @@ -381,8 +379,7 @@ typedef enum { static void engine_emit_changed (CsdPowerManager *manager, - gboolean icon_changed, - gboolean state_changed) + gboolean icon_changed) { /* not yet connected to the bus */ if (manager->priv->power_iface == NULL) @@ -404,17 +401,6 @@ engine_emit_changed (CsdPowerManager *manager, g_object_unref (gicon); } - if (state_changed) { - gchar *tooltip; - - tooltip = engine_get_summary (manager); - - csd_power_set_tooltip (manager->priv->power_iface, tooltip); - need_flush = TRUE; - - g_free (tooltip); - } - if (need_flush) { g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (manager->priv->power_iface)); } @@ -558,47 +544,6 @@ engine_get_warning (CsdPowerManager *manager, UpDevice *device) return warning_type; } -static gchar * -engine_get_summary (CsdPowerManager *manager) -{ - guint i; - GPtrArray *array; - UpDevice *device; - UpDeviceState state; - GString *tooltip = NULL; - gchar *part; - gboolean is_present; - - - /* need to get AC state */ - tooltip = g_string_new (""); - - /* do we have specific device types? */ - array = manager->priv->devices_array; - for (i=0;ilen;i++) { - device = g_ptr_array_index (array, i); - g_object_get (device, - "is-present", &is_present, - "state", &state, - NULL); - if (!is_present) - continue; - if (state == UP_DEVICE_STATE_EMPTY) - continue; - part = gpm_upower_get_device_summary (device); - if (part != NULL) - g_string_append_printf (tooltip, "%s\n", part); - g_free (part); - } - - /* remove the last \n */ - g_string_truncate (tooltip, tooltip->len-1); - - g_debug ("tooltip: %s", tooltip->str); - - return g_string_free (tooltip, FALSE); -} - static GIcon * engine_get_icon_priv (CsdPowerManager *manager, UpDeviceKind device_kind, @@ -740,40 +685,16 @@ engine_recalculate_state_icon (CsdPowerManager *manager) return FALSE; } -static gboolean -engine_recalculate_state_summary (CsdPowerManager *manager) -{ - gchar *summary; - - summary = engine_get_summary (manager); - if (manager->priv->previous_summary == NULL) { - manager->priv->previous_summary = summary; - return TRUE; - } - - if (strcmp (manager->priv->previous_summary, summary) != 0) { - g_free (manager->priv->previous_summary); - manager->priv->previous_summary = summary; - return TRUE; - } - g_debug ("no change"); - /* nothing to do */ - g_free (summary); - return FALSE; -} - static void engine_recalculate_state (CsdPowerManager *manager) { gboolean icon_changed = FALSE; - gboolean state_changed = FALSE; icon_changed = engine_recalculate_state_icon (manager); - state_changed = engine_recalculate_state_summary (manager); - /* only emit if the icon or summary has changed */ - if (icon_changed || state_changed) - engine_emit_changed (manager, icon_changed, state_changed); + /* only emit if the icon has changed */ + if (icon_changed) + engine_emit_changed (manager, icon_changed); } static UpDevice * @@ -1091,8 +1012,6 @@ engine_ups_discharging (CsdPowerManager *manager, UpDevice *device) /* TRANSLATORS: tell the user how much time they have got */ g_string_append_printf (message, _("%s of UPS backup power remaining"), remaining_text); - } else { - g_string_append (message, gpm_device_to_localised_string (device)); } g_string_append_printf (message, " (%.0f%%)", percentage); @@ -4391,9 +4310,6 @@ csd_power_manager_stop (CsdPowerManager *manager) manager->priv->previous_icon = NULL; } - g_free (manager->priv->previous_summary); - manager->priv->previous_summary = NULL; - if (manager->priv->session_proxy != NULL) { g_object_unref (manager->priv->session_proxy); manager->priv->session_proxy = NULL; diff --git a/plugins/power/gpm-common.c b/plugins/power/gpm-common.c index 2feb7d6..15984f1 100644 --- a/plugins/power/gpm-common.c +++ b/plugins/power/gpm-common.c @@ -253,781 +253,3 @@ gpm_upower_get_device_icon (UpDevice *device, gboolean use_symbolic) g_string_free (filename, TRUE); return icon; } - -/** - * gpm_precision_round_down: - * @value: The input value - * @smallest: The smallest increment allowed - * - * 101, 10 100 - * 95, 10 90 - * 0, 10 0 - * 112, 10 110 - * 100, 10 100 - **/ -static gint -gpm_precision_round_down (gfloat value, gint smallest) -{ - gfloat division; - if (fabs (value) < 0.01) - return 0; - if (smallest == 0) { - g_warning ("divisor zero"); - return 0; - } - division = (gfloat) value / (gfloat) smallest; - division = floorf (division); - division *= smallest; - return (gint) division; -} - -gchar * -gpm_upower_get_device_summary (UpDevice *device) -{ - const gchar *kind_desc = NULL; - const gchar *device_desc = NULL; - GString *description; - guint time_to_full_round; - guint time_to_empty_round; - gchar *time_to_full_str = NULL; - gchar *time_to_empty_str = NULL; - UpDeviceKind kind; - UpDeviceState state; - gdouble percentage; - gboolean is_present; - gint64 time_to_full; - gint64 time_to_empty; - - /* get device properties */ - g_object_get (device, - "kind", &kind, - "state", &state, - "percentage", &percentage, - "is-present", &is_present, - "time-to-full", &time_to_full, - "time-to-empty", &time_to_empty, - NULL); - - description = g_string_new (NULL); - kind_desc = gpm_device_kind_to_localised_string (kind, 1); - device_desc = gpm_device_to_localised_string (device); - - /* not installed */ - if (!is_present) { - g_string_append (description, device_desc); - goto out; - } - - /* don't display all the extra stuff for keyboards and mice */ - if (kind == UP_DEVICE_KIND_MOUSE || - kind == UP_DEVICE_KIND_KEYBOARD || - kind == UP_DEVICE_KIND_PDA) { - g_string_append (description, kind_desc); - g_string_append_printf (description, " (%.0f%%)", percentage); - goto out; - } - - /* we care if we are on AC */ - if (kind == UP_DEVICE_KIND_PHONE) { - if (state == UP_DEVICE_STATE_CHARGING || !(state == UP_DEVICE_STATE_DISCHARGING)) { - g_string_append (description, device_desc); - g_string_append_printf (description, " (%.0f%%)", percentage); - goto out; - } - g_string_append (description, kind_desc); - g_string_append_printf (description, " (%.0f%%)", percentage); - goto out; - } - - /* precalculate so we don't get Unknown time remaining */ - time_to_full_round = gpm_precision_round_down (time_to_full, GPM_UP_TIME_PRECISION); - time_to_empty_round = gpm_precision_round_down (time_to_empty, GPM_UP_TIME_PRECISION); - - /* we always display "Laptop battery 16 minutes remaining" as we need to clarify what device we are referring to */ - if (state == UP_DEVICE_STATE_FULLY_CHARGED) { - - g_string_append (description, device_desc); - - if (kind == UP_DEVICE_KIND_BATTERY && time_to_empty_round > GPM_UP_TEXT_MIN_TIME) { - time_to_empty_str = gpm_get_timestring (time_to_empty_round); - g_string_append (description, " - "); - /* TRANSLATORS: The laptop battery is charged, and we know a time. - * The parameter is the time, e.g. 7 hours 6 minutes */ - g_string_append_printf (description, _("provides %s laptop runtime"), time_to_empty_str); - } - goto out; - } - if (state == UP_DEVICE_STATE_DISCHARGING) { - - if (time_to_empty_round > GPM_UP_TEXT_MIN_TIME) { - time_to_empty_str = gpm_get_timestring (time_to_empty_round); - /* TRANSLATORS: the device is discharging, and we have a time remaining - * The first parameter is the device type, e.g. "Laptop battery" and - * the second is the time, e.g. 7 hours 6 minutes */ - g_string_append_printf (description, _("%s %s remaining"), - kind_desc, time_to_empty_str); - g_string_append_printf (description, " (%.0f%%)", percentage); - } else { - g_string_append (description, device_desc); - g_string_append_printf (description, " (%.0f%%)", percentage); - } - goto out; - } - if (state == UP_DEVICE_STATE_CHARGING) { - - if (time_to_full_round > GPM_UP_TEXT_MIN_TIME && - time_to_empty_round > GPM_UP_TEXT_MIN_TIME) { - - /* display both discharge and charge time */ - time_to_full_str = gpm_get_timestring (time_to_full_round); - time_to_empty_str = gpm_get_timestring (time_to_empty_round); - - /* TRANSLATORS: device is charging, and we have a time to full and a percentage - * The first parameter is the device type, e.g. "Laptop battery" and - * the second is the time, e.g. "7 hours 6 minutes" */ - g_string_append_printf (description, _("%s %s until charged"), - kind_desc, time_to_full_str); - g_string_append_printf (description, " (%.0f%%)", percentage); - - g_string_append (description, " - "); - /* TRANSLATORS: the device is charging, and we have a time to full and empty. - * The parameter is a time string, e.g. "7 hours 6 minutes" */ - g_string_append_printf (description, _("provides %s battery runtime"), - time_to_empty_str); - } else if (time_to_full_round > GPM_UP_TEXT_MIN_TIME) { - - /* display only charge time */ - time_to_full_str = gpm_get_timestring (time_to_full_round); - - /* TRANSLATORS: device is charging, and we have a time to full and a percentage. - * The first parameter is the device type, e.g. "Laptop battery" and - * the second is the time, e.g. "7 hours 6 minutes" */ - g_string_append_printf (description, _("%s %s until charged"), - kind_desc, time_to_full_str); - g_string_append_printf (description, " (%.0f%%)", percentage); - } else { - g_string_append (description, device_desc); - g_string_append_printf (description, " (%.0f%%)", percentage); - } - goto out; - } - if (state == UP_DEVICE_STATE_PENDING_DISCHARGE) { - g_string_append (description, device_desc); - g_string_append_printf (description, " (%.0f%%)", percentage); - goto out; - } - if (state == UP_DEVICE_STATE_PENDING_CHARGE) { - g_string_append (description, device_desc); - g_string_append_printf (description, " (%.0f%%)", percentage); - goto out; - } - if (state == UP_DEVICE_STATE_EMPTY) { - g_string_append (description, device_desc); - goto out; - } - - /* fallback */ - g_warning ("in an undefined state we are not charging or " - "discharging and the batteries are also not charged"); - g_string_append (description, device_desc); - g_string_append_printf (description, " (%.0f%%)", percentage); -out: - g_free (time_to_full_str); - g_free (time_to_empty_str); - return g_string_free (description, FALSE); -} - -gchar * -gpm_upower_get_device_description (UpDevice *device) -{ - GString *details; - const gchar *text; - gchar *time_str; - UpDeviceKind kind; - UpDeviceState state; - UpDeviceTechnology technology; - gdouble percentage; - gdouble capacity; - gdouble energy; - gdouble energy_full; - gdouble energy_full_design; - gdouble energy_rate; - gboolean is_present; - gint64 time_to_full; - gint64 time_to_empty; - gchar *vendor = NULL; - gchar *serial = NULL; - gchar *model = NULL; - - g_return_val_if_fail (device != NULL, NULL); - - /* get device properties */ - g_object_get (device, - "kind", &kind, - "state", &state, - "percentage", &percentage, - "is-present", &is_present, - "time-to-full", &time_to_full, - "time-to-empty", &time_to_empty, - "technology", &technology, - "capacity", &capacity, - "energy", &energy, - "energy-full", &energy_full, - "energy-full-design", &energy_full_design, - "energy-rate", &energy_rate, - "vendor", &vendor, - "serial", &serial, - "model", &model, - NULL); - - details = g_string_new (""); - text = gpm_device_kind_to_localised_string (kind, 1); - /* TRANSLATORS: the type of data, e.g. Laptop battery */ - g_string_append_printf (details, "%s %s\n", _("Product:"), text); - - if (!is_present) { - /* TRANSLATORS: device is missing */ - g_string_append_printf (details, "%s %s\n", _("Status:"), _("Missing")); - } else if (state == UP_DEVICE_STATE_FULLY_CHARGED) { - /* TRANSLATORS: device is charged */ - g_string_append_printf (details, "%s %s\n", _("Status:"), _("Charged")); - } else if (state == UP_DEVICE_STATE_CHARGING) { - /* TRANSLATORS: device is charging */ - g_string_append_printf (details, "%s %s\n", _("Status:"), _("Charging")); - } else if (state == UP_DEVICE_STATE_DISCHARGING) { - /* TRANSLATORS: device is discharging */ - g_string_append_printf (details, "%s %s\n", _("Status:"), _("Discharging")); - } - - if (percentage >= 0) { - /* TRANSLATORS: percentage */ - g_string_append_printf (details, "%s %.1f%%\n", _("Percentage charge:"), percentage); - } - if (vendor) { - /* TRANSLATORS: manufacturer */ - g_string_append_printf (details, "%s %s\n", _("Vendor:"), vendor); - } - if (technology != UP_DEVICE_TECHNOLOGY_UNKNOWN) { - text = gpm_device_technology_to_localised_string (technology); - /* TRANSLATORS: how the battery is made, e.g. Lithium Ion */ - g_string_append_printf (details, "%s %s\n", _("Technology:"), text); - } - if (serial) { - /* TRANSLATORS: serial number of the battery */ - g_string_append_printf (details, "%s %s\n", _("Serial number:"), serial); - } - if (model) { - /* TRANSLATORS: model number of the battery */ - g_string_append_printf (details, "%s %s\n", _("Model:"), model); - } - if (time_to_full > 0) { - time_str = gpm_get_timestring (time_to_full); - /* TRANSLATORS: time to fully charged */ - g_string_append_printf (details, "%s %s\n", _("Charge time:"), time_str); - g_free (time_str); - } - if (time_to_empty > 0) { - time_str = gpm_get_timestring (time_to_empty); - /* TRANSLATORS: time to empty */ - g_string_append_printf (details, "%s %s\n", _("Discharge time:"), time_str); - g_free (time_str); - } - if (capacity > 0) { - const gchar *condition; - if (capacity > 99) { - /* TRANSLATORS: Excellent, Good, Fair and Poor are all related to battery Capacity */ - condition = _("Excellent"); - } else if (capacity > 90) { - condition = _("Good"); - } else if (capacity > 70) { - condition = _("Fair"); - } else { - condition = _("Poor"); - } - /* TRANSLATORS: %.1f is a percentage and %s the condition (Excellent, Good, ...) */ - g_string_append_printf (details, "%s %.1f%% (%s)\n", - _("Capacity:"), capacity, condition); - } - if (kind == UP_DEVICE_KIND_BATTERY) { - if (energy > 0) { - /* TRANSLATORS: current charge */ - g_string_append_printf (details, "%s %.1f Wh\n", - _("Current charge:"), energy); - } - if (energy_full > 0 && - energy_full_design != energy_full) { - /* TRANSLATORS: last full is the charge the battery was seen to charge to */ - g_string_append_printf (details, "%s %.1f Wh\n", - _("Last full charge:"), energy_full); - } - if (energy_full_design > 0) { - /* Translators: */ - /* TRANSLATORS: Design charge is the amount of charge the battery is designed to have when brand new */ - g_string_append_printf (details, "%s %.1f Wh\n", - _("Design charge:"), energy_full_design); - } - if (energy_rate > 0) { - /* TRANSLATORS: the charge or discharge rate */ - g_string_append_printf (details, "%s %.1f W\n", - _("Charge rate:"), energy_rate); - } - } - if (kind == UP_DEVICE_KIND_MOUSE || - kind == UP_DEVICE_KIND_KEYBOARD) { - if (energy > 0) { - /* TRANSLATORS: the current charge for CSR devices */ - g_string_append_printf (details, "%s %.0f/7\n", - _("Current charge:"), energy); - } - if (energy_full_design > 0) { - /* TRANSLATORS: the design charge for CSR devices */ - g_string_append_printf (details, "%s %.0f/7\n", - _("Design charge:"), energy_full_design); - } - } - /* remove the last \n */ - g_string_truncate (details, details->len-1); - - g_free (vendor); - g_free (serial); - g_free (model); - return g_string_free (details, FALSE); -} - -const gchar * -gpm_device_kind_to_localised_string (UpDeviceKind kind, guint number) -{ - const gchar *text = NULL; - switch (kind) { - case UP_DEVICE_KIND_LINE_POWER: - /* TRANSLATORS: system power cord */ - text = ngettext ("AC adapter", "AC adapters", number); - break; - case UP_DEVICE_KIND_BATTERY: - /* TRANSLATORS: laptop primary battery */ - text = ngettext ("Laptop battery", "Laptop batteries", number); - break; - case UP_DEVICE_KIND_UPS: - /* TRANSLATORS: battery-backed AC power source */ - text = ngettext ("UPS", "UPSs", number); - break; - case UP_DEVICE_KIND_MONITOR: - /* TRANSLATORS: a monitor is a device to measure voltage and current */ - text = ngettext ("Monitor", "Monitors", number); - break; - case UP_DEVICE_KIND_MOUSE: - /* TRANSLATORS: wireless mice with internal batteries */ - text = ngettext ("Mouse", "Mice", number); - break; - case UP_DEVICE_KIND_KEYBOARD: - /* TRANSLATORS: wireless keyboard with internal battery */ - text = ngettext ("Keyboard", "Keyboards", number); - break; - case UP_DEVICE_KIND_PDA: - /* TRANSLATORS: portable device */ - text = ngettext ("PDA", "PDAs", number); - break; - case UP_DEVICE_KIND_PHONE: - /* TRANSLATORS: cell phone (mobile...) */ - text = ngettext ("Cell phone", "Cell phones", number); - break; - case UP_DEVICE_KIND_MEDIA_PLAYER: - /* TRANSLATORS: media player, mp3 etc */ - text = ngettext ("Media player", "Media players", number); - break; - case UP_DEVICE_KIND_TABLET: - /* TRANSLATORS: tablet device */ - text = ngettext ("Tablet", "Tablets", number); - break; - case UP_DEVICE_KIND_COMPUTER: - /* TRANSLATORS: tablet device */ - text = ngettext ("Computer", "Computers", number); - break; - case UP_DEVICE_KIND_GAMING_INPUT: - /* TRANSLATORS: gaming peripherals */ - text = ngettext ("Game controller", "Game controllers", number); - break; - case UP_DEVICE_KIND_UNKNOWN: - text = ngettext ("Unknown device", "Unknown devices", number); - break; - case UP_DEVICE_KIND_LAST: - default: - g_warning ("enum unrecognised: %i", kind); - text = up_device_kind_to_string (kind); - } - return text; -} - -const gchar * -gpm_device_kind_to_icon (UpDeviceKind kind) -{ - const gchar *icon = NULL; - switch (kind) { - case UP_DEVICE_KIND_LINE_POWER: - icon = "ac-adapter"; - break; - case UP_DEVICE_KIND_BATTERY: - icon = "battery"; - break; - case UP_DEVICE_KIND_UPS: - icon = "network-wired"; - break; - case UP_DEVICE_KIND_MONITOR: - icon = "application-certificate"; - break; - case UP_DEVICE_KIND_MOUSE: - icon = "input-mouse"; - break; - case UP_DEVICE_KIND_KEYBOARD: - icon = "input-keyboard"; - break; - case UP_DEVICE_KIND_PDA: - icon = "pda"; - break; - case UP_DEVICE_KIND_PHONE: - icon = "phone"; - break; - case UP_DEVICE_KIND_MEDIA_PLAYER: - icon = "multimedia-player"; - break; - case UP_DEVICE_KIND_TABLET: - icon = "input-tablet"; - break; - case UP_DEVICE_KIND_COMPUTER: - icon = "computer-apple-ipad"; - break; - case UP_DEVICE_KIND_GAMING_INPUT: - icon = "input-gaming"; - break; - case UP_DEVICE_KIND_UNKNOWN: - icon = "gtk-help"; - break; - case UP_DEVICE_KIND_LAST: - default: - g_warning ("enum unrecognised: %i", kind); - icon = "gtk-help"; - } - return icon; -} - -const gchar * -gpm_device_technology_to_localised_string (UpDeviceTechnology technology_enum) -{ - const gchar *technology = NULL; - switch (technology_enum) { - case UP_DEVICE_TECHNOLOGY_LITHIUM_ION: - /* TRANSLATORS: battery technology */ - technology = _("Lithium Ion"); - break; - case UP_DEVICE_TECHNOLOGY_LITHIUM_POLYMER: - /* TRANSLATORS: battery technology */ - technology = _("Lithium Polymer"); - break; - case UP_DEVICE_TECHNOLOGY_LITHIUM_IRON_PHOSPHATE: - /* TRANSLATORS: battery technology */ - technology = _("Lithium Iron Phosphate"); - break; - case UP_DEVICE_TECHNOLOGY_LEAD_ACID: - /* TRANSLATORS: battery technology */ - technology = _("Lead acid"); - break; - case UP_DEVICE_TECHNOLOGY_NICKEL_CADMIUM: - /* TRANSLATORS: battery technology */ - technology = _("Nickel Cadmium"); - break; - case UP_DEVICE_TECHNOLOGY_NICKEL_METAL_HYDRIDE: - /* TRANSLATORS: battery technology */ - technology = _("Nickel metal hydride"); - break; - case UP_DEVICE_TECHNOLOGY_UNKNOWN: - /* TRANSLATORS: battery technology */ - technology = _("Unknown technology"); - break; - case UP_DEVICE_TECHNOLOGY_LAST: - default: - g_assert_not_reached (); - break; - } - return technology; -} - -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 = _("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; - case UP_DEVICE_STATE_UNKNOWN: - /* TRANSLATORS: battery state */ - state_string = _("Unknown"); - break; - case UP_DEVICE_STATE_LAST: - default: - g_assert_not_reached (); - break; - } - return state_string; -} - -const gchar * -gpm_device_to_localised_string (UpDevice *device) -{ - UpDeviceState state; - UpDeviceKind kind; - gboolean present; - - /* get device parameters */ - g_object_get (device, - "is-present", &present, - "kind", &kind, - "state", &state, - NULL); - - /* laptop battery */ - if (kind == UP_DEVICE_KIND_BATTERY) { - - if (!present) { - /* TRANSLATORS: device not present */ - return _("Laptop battery not present"); - } - if (state == UP_DEVICE_STATE_CHARGING) { - /* TRANSLATORS: battery state */ - return _("Laptop battery is charging"); - } - if (state == UP_DEVICE_STATE_DISCHARGING) { - /* TRANSLATORS: battery state */ - return _("Laptop battery is discharging"); - } - if (state == UP_DEVICE_STATE_EMPTY) { - /* TRANSLATORS: battery state */ - return _("Laptop battery is empty"); - } - if (state == UP_DEVICE_STATE_FULLY_CHARGED) { - /* TRANSLATORS: battery state */ - return _("Laptop battery is charged"); - } - if (state == UP_DEVICE_STATE_PENDING_CHARGE) { - /* TRANSLATORS: battery state */ - return _("Laptop battery is waiting to charge"); - } - if (state == UP_DEVICE_STATE_PENDING_DISCHARGE) { - /* TRANSLATORS: battery state */ - return _("Laptop battery is waiting to discharge"); - } - } - - /* UPS */ - if (kind == UP_DEVICE_KIND_UPS) { - - if (state == UP_DEVICE_STATE_CHARGING) { - /* TRANSLATORS: battery state */ - return _("UPS is charging"); - } - if (state == UP_DEVICE_STATE_DISCHARGING) { - /* TRANSLATORS: battery state */ - return _("UPS is discharging"); - } - if (state == UP_DEVICE_STATE_EMPTY) { - /* TRANSLATORS: battery state */ - return _("UPS is empty"); - } - if (state == UP_DEVICE_STATE_FULLY_CHARGED) { - /* TRANSLATORS: battery state */ - return _("UPS is charged"); - } - } - - /* mouse */ - if (kind == UP_DEVICE_KIND_MOUSE) { - - if (state == UP_DEVICE_STATE_CHARGING) { - /* TRANSLATORS: battery state */ - return _("Mouse is charging"); - } - if (state == UP_DEVICE_STATE_DISCHARGING) { - /* TRANSLATORS: battery state */ - return _("Mouse is discharging"); - } - if (state == UP_DEVICE_STATE_EMPTY) { - /* TRANSLATORS: battery state */ - return _("Mouse is empty"); - } - if (state == UP_DEVICE_STATE_FULLY_CHARGED) { - /* TRANSLATORS: battery state */ - return _("Mouse is charged"); - } - } - - /* keyboard */ - if (kind == UP_DEVICE_KIND_KEYBOARD) { - - if (state == UP_DEVICE_STATE_CHARGING) { - /* TRANSLATORS: battery state */ - return _("Keyboard is charging"); - } - if (state == UP_DEVICE_STATE_DISCHARGING) { - /* TRANSLATORS: battery state */ - return _("Keyboard is discharging"); - } - if (state == UP_DEVICE_STATE_EMPTY) { - /* TRANSLATORS: battery state */ - return _("Keyboard is empty"); - } - if (state == UP_DEVICE_STATE_FULLY_CHARGED) { - /* TRANSLATORS: battery state */ - return _("Keyboard is charged"); - } - } - - /* PDA */ - if (kind == UP_DEVICE_KIND_PDA) { - - if (state == UP_DEVICE_STATE_CHARGING) { - /* TRANSLATORS: battery state */ - return _("PDA is charging"); - } - if (state == UP_DEVICE_STATE_DISCHARGING) { - /* TRANSLATORS: battery state */ - return _("PDA is discharging"); - } - if (state == UP_DEVICE_STATE_EMPTY) { - /* TRANSLATORS: battery state */ - return _("PDA is empty"); - } - if (state == UP_DEVICE_STATE_FULLY_CHARGED) { - /* TRANSLATORS: battery state */ - return _("PDA is charged"); - } - } - - /* phone */ - if (kind == UP_DEVICE_KIND_PHONE) { - - if (state == UP_DEVICE_STATE_CHARGING) { - /* TRANSLATORS: battery state */ - return _("Cell phone is charging"); - } - if (state == UP_DEVICE_STATE_DISCHARGING) { - /* TRANSLATORS: battery state */ - return _("Cell phone is discharging"); - } - if (state == UP_DEVICE_STATE_EMPTY) { - /* TRANSLATORS: battery state */ - return _("Cell phone is empty"); - } - if (state == UP_DEVICE_STATE_FULLY_CHARGED) { - /* TRANSLATORS: battery state */ - return _("Cell phone is charged"); - } - } - - /* media player */ - if (kind == UP_DEVICE_KIND_MEDIA_PLAYER) { - - if (state == UP_DEVICE_STATE_CHARGING) { - /* TRANSLATORS: battery state */ - return _("Media player is charging"); - } - if (state == UP_DEVICE_STATE_DISCHARGING) { - /* TRANSLATORS: battery state */ - return _("Media player is discharging"); - } - if (state == UP_DEVICE_STATE_EMPTY) { - /* TRANSLATORS: battery state */ - return _("Media player is empty"); - } - if (state == UP_DEVICE_STATE_FULLY_CHARGED) { - /* TRANSLATORS: battery state */ - return _("Media player is charged"); - } - } - - /* tablet */ - if (kind == UP_DEVICE_KIND_TABLET) { - - if (state == UP_DEVICE_STATE_CHARGING) { - /* TRANSLATORS: battery state */ - return _("Tablet is charging"); - } - if (state == UP_DEVICE_STATE_DISCHARGING) { - /* TRANSLATORS: battery state */ - return _("Tablet is discharging"); - } - if (state == UP_DEVICE_STATE_EMPTY) { - /* TRANSLATORS: battery state */ - return _("Tablet is empty"); - } - if (state == UP_DEVICE_STATE_FULLY_CHARGED) { - /* TRANSLATORS: battery state */ - return _("Tablet is charged"); - } - } - - /* computer */ - if (kind == UP_DEVICE_KIND_COMPUTER) { - - if (state == UP_DEVICE_STATE_CHARGING) { - /* TRANSLATORS: battery state */ - return _("Computer is charging"); - } - if (state == UP_DEVICE_STATE_DISCHARGING) { - /* TRANSLATORS: battery state */ - return _("Computer is discharging"); - } - if (state == UP_DEVICE_STATE_EMPTY) { - /* TRANSLATORS: battery state */ - return _("Computer is empty"); - } - if (state == UP_DEVICE_STATE_FULLY_CHARGED) { - /* TRANSLATORS: battery state */ - return _("Computer is charged"); - } - } - - /* computer */ - if (kind == UP_DEVICE_KIND_GAMING_INPUT) { - - if (state == UP_DEVICE_STATE_CHARGING) { - /* TRANSLATORS: battery state */ - return _("Game controller is charging"); - } - if (state == UP_DEVICE_STATE_DISCHARGING) { - /* TRANSLATORS: battery state */ - return _("Game controller is discharging"); - } - if (state == UP_DEVICE_STATE_EMPTY) { - /* TRANSLATORS: battery state */ - return _("Game controller is empty"); - } - if (state == UP_DEVICE_STATE_FULLY_CHARGED) { - /* TRANSLATORS: battery state */ - return _("Game controller is charged"); - } - } - - return gpm_device_kind_to_localised_string (kind, 1); -} diff --git a/plugins/power/gpm-common.h b/plugins/power/gpm-common.h index d8a4758..b8e31d8 100644 --- a/plugins/power/gpm-common.h +++ b/plugins/power/gpm-common.h @@ -28,16 +28,8 @@ G_BEGIN_DECLS gchar *gpm_get_timestring (guint time); -const gchar *gpm_device_to_localised_string (UpDevice *device); -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); -const gchar *gpm_device_state_to_localised_string (UpDeviceState state); GIcon *gpm_upower_get_device_icon (UpDevice *device, gboolean use_symbolic); -gchar *gpm_upower_get_device_summary (UpDevice *device); -gchar *gpm_upower_get_device_description (UpDevice *device); G_END_DECLS diff --git a/plugins/power/org.cinnamon.SettingsDaemon.Power.xml b/plugins/power/org.cinnamon.SettingsDaemon.Power.xml index 7665597..fee0d3d 100644 --- a/plugins/power/org.cinnamon.SettingsDaemon.Power.xml +++ b/plugins/power/org.cinnamon.SettingsDaemon.Power.xml @@ -6,8 +6,6 @@ - -