[gnome-settings-daemon] power: Remove unused helper functions



commit ea7b5f08ec60f8cb9a3e0ccb0147f8a9afa0ee84
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Oct 16 22:37:03 2013 +0200

    power: Remove unused helper functions
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709736

 plugins/power/gpm-common.c |  498 --------------------------------------------
 plugins/power/gpm-common.h |    5 -
 2 files changed, 0 insertions(+), 503 deletions(-)
---
diff --git a/plugins/power/gpm-common.c b/plugins/power/gpm-common.c
index 81af0b7..7e47f2d 100644
--- a/plugins/power/gpm-common.c
+++ b/plugins/power/gpm-common.c
@@ -242,504 +242,6 @@ gpm_upower_get_device_icon (UpDevice *device, gboolean use_symbolic)
         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 
refering 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);
-}
-
-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;
-#if UP_CHECK_VERSION(0,9,5)
-        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;
-#endif
-        default:
-                g_warning ("enum unrecognised: %i", kind);
-                text = up_device_kind_to_string (kind);
-        }
-        return text;
-}
-
-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;
-        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");
-                }
-        }
-#if UP_CHECK_VERSION(0,9,5)
-
-        /* 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");
-                }
-        }
-#endif
-
-        return gpm_device_kind_to_localised_string (kind, 1);
-}
-
 static gboolean
 parse_vm_kernel_cmdline (gboolean *is_virtual_machine)
 {
diff --git a/plugins/power/gpm-common.h b/plugins/power/gpm-common.h
index 083f35b..ffd2d7a 100644
--- a/plugins/power/gpm-common.h
+++ b/plugins/power/gpm-common.h
@@ -29,13 +29,8 @@ G_BEGIN_DECLS
 
 /* UPower helpers */
 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_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);
 
 /* Power helpers */
 gboolean         gsd_power_is_hardware_a_vm             (void);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]