Updating branch refs/heads/master to d7252850d8070a0d8247d4af9d8930014f2a423b (commit) from 3b4815eeb2b0edc7e8f24a453feddf069bbea3bc (commit)
commit d7252850d8070a0d8247d4af9d8930014f2a423b Author: Jérôme Guelfucci <jero...@xfce.org> Date: Sun Aug 11 22:40:11 2013 +0200 Fix typo. src/xfpm-battery.c | 252 ++++++++++++++++++++++++++-------------------------- 1 file changed, 126 insertions(+), 126 deletions(-) diff --git a/src/xfpm-battery.c b/src/xfpm-battery.c index 34a1da1..b3690d2 100644 --- a/src/xfpm-battery.c +++ b/src/xfpm-battery.c @@ -55,9 +55,9 @@ struct XfpmBatteryPrivate XfpmButton *button; DBusGProxy *proxy; DBusGProxy *proxy_prop; - + gchar *icon_prefix; - + XfpmBatteryCharge charge; XfpmDeviceState state; XfpmDeviceType type; @@ -68,10 +68,10 @@ struct XfpmBatteryPrivate gint64 time_to_empty; const gchar *battery_name; - + gulong sig; gulong sig_bt; - + guint notify_idle; }; @@ -82,7 +82,7 @@ enum PROP_CHARGE_STATUS, PROP_DEVICE_TYPE }; - + enum { BATTERY_CHARGE_CHANGED, @@ -96,27 +96,27 @@ G_DEFINE_TYPE (XfpmBattery, xfpm_battery, GTK_TYPE_STATUS_ICON) static const gchar * G_GNUC_CONST xfpm_battery_get_icon_index (XfpmDeviceType type, guint percent) { - if (percent < 10) + if (percent < 10) { return "000"; - } - else if (percent < 30) + } + else if (percent < 30) { return ( (type == XFPM_DEVICE_TYPE_BATTERY || type == XFPM_DEVICE_TYPE_UPS) ? "020" : "030"); - } - else if (percent < 50) + } + else if (percent < 50) { return ( (type == XFPM_DEVICE_TYPE_BATTERY || type == XFPM_DEVICE_TYPE_UPS ) ? "040" : "030"); - } - else if (percent < 70) + } + else if (percent < 70) { return "060"; - } - else if (percent < 90) + } + else if (percent < 90) { return ((type == XFPM_DEVICE_TYPE_BATTERY || type == XFPM_DEVICE_TYPE_UPS) ? "080" : "060"); } - + return "100"; } @@ -125,11 +125,11 @@ xfpm_battery_refresh_visible (XfpmBattery *battery) { XfpmShowIcon show_icon; gboolean visible = TRUE; - + g_object_get (G_OBJECT (battery->priv->conf), SHOW_TRAY_ICON_CFG, &show_icon, NULL); - + if ( show_icon == SHOW_ICON_ALWAYS ) visible = TRUE; else if ( show_icon == NEVER_SHOW_ICON ) @@ -148,7 +148,7 @@ xfpm_battery_refresh_visible (XfpmBattery *battery) } XFPM_DEBUG_ENUM (show_icon, XFPM_TYPE_SHOW_ICON, "visible=%s", xfpm_bool_to_string (visible)); - + gtk_status_icon_set_visible (GTK_STATUS_ICON (battery), visible); } @@ -166,13 +166,13 @@ xfpm_battery_get_time_string (guint seconds) /* Add 0.5 to do rounding */ minutes = (int) ( ( seconds / 60.0 ) + 0.5 ); - if (minutes == 0) + if (minutes == 0) { timestring = g_strdup (_("Unknown time")); return timestring; } - if (minutes < 60) + if (minutes < 60) { timestring = g_strdup_printf (ngettext ("%i minute", "%i minutes", @@ -201,8 +201,8 @@ static gchar * xfpm_battery_get_message_from_battery_state (XfpmBattery *battery) { gchar *msg = NULL; - - + + if (battery->priv->type == XFPM_DEVICE_TYPE_BATTERY || battery->priv->type == XFPM_DEVICE_TYPE_UPS) { switch (battery->priv->state) @@ -212,16 +212,16 @@ xfpm_battery_get_message_from_battery_state (XfpmBattery *battery) break; case XFPM_DEVICE_STATE_CHARGING: msg = g_strdup_printf (_("Your %s is charging"), battery->priv->battery_name); - + if ( battery->priv->time_to_full != 0 ) { gchar *tmp, *est_time_str; tmp = g_strdup (msg); g_free (msg); - + est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_full); - - msg = g_strdup_printf (_("%s (%i%%)\n%s until is fully charged."), tmp, battery->priv->percentage, est_time_str); + + msg = g_strdup_printf (_("%s (%i%%)\n%s until it is fully charged."), tmp, battery->priv->percentage, est_time_str); g_free (est_time_str); g_free (tmp); } @@ -232,15 +232,15 @@ xfpm_battery_get_message_from_battery_state (XfpmBattery *battery) msg = g_strdup_printf (_("Your %s is discharging"), battery->priv->battery_name); else msg = g_strdup_printf (_("System is running on %s power"), battery->priv->battery_name); - + if ( battery->priv->time_to_empty != 0 ) { gchar *tmp, *est_time_str; tmp = g_strdup (msg); g_free (msg); - + est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_empty); - + msg = g_strdup_printf (_("%s (%i%%)\nEstimated time left is %s."), tmp, battery->priv->percentage, est_time_str); g_free (tmp); g_free (est_time_str); @@ -252,7 +252,7 @@ xfpm_battery_get_message_from_battery_state (XfpmBattery *battery) default: break; } - + } else if (battery->priv->type >= XFPM_DEVICE_TYPE_MONITOR) { @@ -274,7 +274,7 @@ xfpm_battery_get_message_from_battery_state (XfpmBattery *battery) break; } } - + return msg; } @@ -282,10 +282,10 @@ static void xfpm_battery_refresh_icon (XfpmBattery *battery) { gchar icon_name[128]; - + XFPM_DEBUG ("Battery state %d", battery->priv->state); - - if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY || + + if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY || battery->priv->type == XFPM_DEVICE_TYPE_UPS ) { if (!battery->priv->present) @@ -296,19 +296,19 @@ xfpm_battery_refresh_icon (XfpmBattery *battery) { g_snprintf (icon_name, 128, "%s%s", battery->priv->icon_prefix, battery->priv->ac_online ? "charged" : "100"); } - else if ( battery->priv->state == XFPM_DEVICE_STATE_CHARGING || + else if ( battery->priv->state == XFPM_DEVICE_STATE_CHARGING || battery->priv->state == XFPM_DEVICE_STATE_PENDING_CHARGING) { - g_snprintf (icon_name, 128, "%s%s-%s", - battery->priv->icon_prefix, + g_snprintf (icon_name, 128, "%s%s-%s", + battery->priv->icon_prefix, xfpm_battery_get_icon_index (battery->priv->type, battery->priv->percentage), "charging"); } else if ( battery->priv->state == XFPM_DEVICE_STATE_DISCHARGING || battery->priv->state == XFPM_DEVICE_STATE_PENDING_DISCHARGING) { - g_snprintf (icon_name, 128, "%s%s", - battery->priv->icon_prefix, + g_snprintf (icon_name, 128, "%s%s", + battery->priv->icon_prefix, xfpm_battery_get_icon_index (battery->priv->type, battery->priv->percentage)); } else if ( battery->priv->state == XFPM_DEVICE_STATE_EMPTY) @@ -328,12 +328,12 @@ xfpm_battery_refresh_icon (XfpmBattery *battery) } else if ( battery->priv->state == XFPM_DEVICE_STATE_DISCHARGING ) { - g_snprintf (icon_name, 128, "%s-%s", - battery->priv->icon_prefix, + g_snprintf (icon_name, 128, "%s-%s", + battery->priv->icon_prefix, xfpm_battery_get_icon_index (battery->priv->type, battery->priv->percentage)); } } - + gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (battery), icon_name); } @@ -341,21 +341,21 @@ static void xfpm_battery_notify (XfpmBattery *battery) { gchar *message = NULL; - + message = xfpm_battery_get_message_from_battery_state (battery); - + if ( !message ) return; - - xfpm_notify_show_notification (battery->priv->notify, - _("Power Manager"), - message, + + xfpm_notify_show_notification (battery->priv->notify, + _("Power Manager"), + message, gtk_status_icon_get_icon_name (GTK_STATUS_ICON (battery)), 8000, FALSE, XFPM_NOTIFY_NORMAL, GTK_STATUS_ICON (battery)); - + g_free (message); } @@ -363,10 +363,10 @@ static gboolean xfpm_battery_notify_idle (gpointer data) { XfpmBattery *battery = XFPM_BATTERY (data); - + xfpm_battery_notify (battery); battery->priv->notify_idle = 0; - + return FALSE; } @@ -375,10 +375,10 @@ xfpm_battery_notify_state (XfpmBattery *battery) { gboolean notify; static gboolean starting_up = TRUE; - + if ( !gtk_status_icon_get_visible (GTK_STATUS_ICON (battery)) ) return; - + if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY || battery->priv->type == XFPM_DEVICE_TYPE_UPS ) { @@ -387,11 +387,11 @@ xfpm_battery_notify_state (XfpmBattery *battery) starting_up = FALSE; return; } - + g_object_get (G_OBJECT (battery->priv->conf), GENERAL_NOTIFICATION_CFG, ¬ify, NULL); - + if ( notify ) { if (battery->priv->notify_idle == 0) @@ -409,24 +409,24 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip) gchar *tip; gchar *est_time_str = NULL; gchar *power_status = NULL; - + power_status = g_strdup_printf (battery->priv->ac_online ? _("Adaptor is online") : _("System is running on battery power")); - + if ( battery->priv->state == XFPM_DEVICE_STATE_FULLY_CHARGED ) { if ( battery->priv->time_to_empty > 0 ) { est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_empty); - tip = g_strdup_printf (_("%s\nYour %s is fully charged (%i%%).\nProvides %s runtime"), + tip = g_strdup_printf (_("%s\nYour %s is fully charged (%i%%).\nProvides %s runtime"), power_status, - battery->priv->battery_name, + battery->priv->battery_name, battery->priv->percentage, est_time_str); g_free (est_time_str); } else { - tip = g_strdup_printf (_("%s\nYour %s is fully charged (%i%%)."), + tip = g_strdup_printf (_("%s\nYour %s is fully charged (%i%%)."), power_status, battery->priv->battery_name, battery->priv->percentage); @@ -437,10 +437,10 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip) if ( battery->priv->time_to_full != 0 ) { est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_full); - tip = g_strdup_printf (_("%s\nYour %s is charging (%i%%)\n%s until is fully charged."), + tip = g_strdup_printf (_("%s\nYour %s is charging (%i%%)\n%s until is fully charged."), power_status, - battery->priv->battery_name, - battery->priv->percentage, + battery->priv->battery_name, + battery->priv->percentage, est_time_str); g_free (est_time_str); } @@ -457,10 +457,10 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip) if ( battery->priv->time_to_empty != 0 ) { est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_empty); - tip = g_strdup_printf (_("%s\nYour %s is discharging (%i%%)\nEstimated time left is %s."), + tip = g_strdup_printf (_("%s\nYour %s is discharging (%i%%)\nEstimated time left is %s."), power_status, - battery->priv->battery_name, - battery->priv->percentage, + battery->priv->battery_name, + battery->priv->percentage, est_time_str); g_free (est_time_str); } @@ -471,7 +471,7 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip) battery->priv->battery_name, battery->priv->percentage); } - + } else if ( battery->priv->state == XFPM_DEVICE_STATE_PENDING_CHARGING ) { @@ -485,7 +485,7 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip) { tip = g_strdup_printf (_("%s\nYour %s is empty"), power_status, battery->priv->battery_name); } - + gtk_tooltip_set_text (tooltip, tip); g_free (power_status); g_free (tip); @@ -496,20 +496,20 @@ xfpm_battery_check_charge (XfpmBattery *battery) { XfpmBatteryCharge charge; guint critical_level, low_level; - + g_object_get (G_OBJECT (battery->priv->conf), CRITICAL_POWER_LEVEL, &critical_level, NULL); - + low_level = critical_level + 10; - + if ( battery->priv->percentage > low_level ) charge = XFPM_BATTERY_CHARGE_OK; else if ( battery->priv->percentage <= low_level && battery->priv->percentage > critical_level ) charge = XFPM_BATTERY_CHARGE_LOW; else if ( battery->priv->percentage <= critical_level ) charge = XFPM_BATTERY_CHARGE_CRITICAL; - + if ( charge != battery->priv->charge) { battery->priv->charge = charge; @@ -527,24 +527,24 @@ xfpm_battery_refresh (XfpmBattery *battery, GHashTable *props) { GValue *value; guint state; - + value = g_hash_table_lookup (props, "IsPresent"); - + if ( value == NULL ) { g_warning ("No 'IsPresent' property found"); goto out; } - + battery->priv->present = g_value_get_boolean (value); - + value = g_hash_table_lookup (props, "State"); - + if ( value == NULL ) { g_warning ("No 'State' property found"); } - + state = g_value_get_uint (value); if ( state != battery->priv->state ) { @@ -552,45 +552,45 @@ xfpm_battery_refresh (XfpmBattery *battery, GHashTable *props) xfpm_battery_refresh_visible (battery); xfpm_battery_notify_state (battery); } - + value = g_hash_table_lookup (props, "Percentage"); - + if ( value == NULL ) { g_warning ("No 'Percentage' property found on battery device"); goto out; } - + battery->priv->percentage = (guint) g_value_get_double (value); - + xfpm_battery_check_charge (battery); - + xfpm_battery_refresh_icon (battery); - + if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY || battery->priv->type == XFPM_DEVICE_TYPE_UPS ) { value = g_hash_table_lookup (props, "TimeToEmpty"); - + if ( value == NULL ) { g_warning ("No 'TimeToEmpty' property found on battery device"); goto out; } - + battery->priv->time_to_empty = g_value_get_int64 (value); - + value = g_hash_table_lookup (props, "TimeToFull"); - + if ( value == NULL ) { g_warning ("No 'TimeToFull' property found on battery device"); goto out; } - + battery->priv->time_to_full = g_value_get_int64 (value); } - + out: g_hash_table_destroy (props); } @@ -606,23 +606,23 @@ static void xfpm_battery_changed_cb (DBusGProxy *proxy, XfpmBattery *battery) { GHashTable *props; - - props = xfpm_power_get_interface_properties (battery->priv->proxy_prop, + + props = xfpm_power_get_interface_properties (battery->priv->proxy_prop, UPOWER_IFACE_DEVICE); - + if ( props ) xfpm_battery_refresh (battery, props); } static gboolean -xfpm_battery_query_tooltip (GtkStatusIcon *icon, +xfpm_battery_query_tooltip (GtkStatusIcon *icon, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip) { XfpmBattery *battery; - + battery = XFPM_BATTERY (icon); if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY || @@ -631,7 +631,7 @@ xfpm_battery_query_tooltip (GtkStatusIcon *icon, xfpm_battery_set_tooltip_primary (battery, tooltip); return TRUE; } - + return FALSE; } @@ -647,9 +647,9 @@ static void xfpm_battery_get_property (GObject *object, GParamSpec *pspec) { XfpmBattery *battery; - + battery = XFPM_BATTERY (object); - + switch (prop_id) { case PROP_AC_ONLINE: @@ -673,9 +673,9 @@ static void xfpm_battery_set_property (GObject *object, GParamSpec *pspec) { XfpmBattery *battery; - + battery = XFPM_BATTERY (object); - + switch (prop_id) { case PROP_AC_ONLINE: @@ -700,8 +700,8 @@ xfpm_battery_class_init (XfpmBatteryClass *klass) object_class->set_property = xfpm_battery_set_property; status_icon_class->query_tooltip = xfpm_battery_query_tooltip; - - signals [BATTERY_CHARGE_CHANGED] = + + signals [BATTERY_CHARGE_CHANGED] = g_signal_new ("battery-charge-changed", XFPM_TYPE_BATTERY, G_SIGNAL_RUN_LAST, @@ -709,7 +709,7 @@ xfpm_battery_class_init (XfpmBatteryClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, G_TYPE_NONE); - + g_object_class_install_property (object_class, PROP_AC_ONLINE, g_param_spec_boolean("ac-online", @@ -740,7 +740,7 @@ static void xfpm_battery_init (XfpmBattery *battery) { battery->priv = XFPM_BATTERY_GET_PRIVATE (battery); - + battery->priv->conf = xfpm_xfconf_new (); battery->priv->notify = xfpm_notify_new (); battery->priv->proxy_prop = NULL; @@ -752,11 +752,11 @@ xfpm_battery_init (XfpmBattery *battery) battery->priv->time_to_empty = 0; battery->priv->button = xfpm_button_new (); battery->priv->ac_online = TRUE; - + battery->priv->sig = g_signal_connect (G_OBJECT (battery->priv->conf), "notify::" SHOW_TRAY_ICON_CFG, G_CALLBACK (xfpm_battery_tray_icon_settings_changed), battery); - - + + battery->priv->sig_bt = g_signal_connect (G_OBJECT (battery->priv->button), "button-pressed", G_CALLBACK (xfpm_battery_button_pressed_cb), battery); } @@ -767,7 +767,7 @@ xfpm_battery_finalize (GObject *object) XfpmBattery *battery; battery = XFPM_BATTERY (object); - + g_free (battery->priv->icon_prefix); if (battery->priv->notify_idle != 0) @@ -775,13 +775,13 @@ xfpm_battery_finalize (GObject *object) dbus_g_proxy_disconnect_signal (battery->priv->proxy, "Changed", G_CALLBACK (xfpm_battery_changed_cb), battery); - + if ( g_signal_handler_is_connected (battery->priv->conf, battery->priv->sig ) ) g_signal_handler_disconnect (G_OBJECT (battery->priv->conf), battery->priv->sig); - + if ( g_signal_handler_is_connected (battery->priv->button, battery->priv->sig_bt ) ) g_signal_handler_disconnect (G_OBJECT (battery->priv->button), battery->priv->sig_bt); - + g_object_unref (battery->priv->proxy); g_object_unref (battery->priv->proxy_prop); g_object_unref (battery->priv->conf); @@ -798,23 +798,23 @@ xfpm_battery_get_icon_prefix_device_enum_type (XfpmDeviceType type) { return g_strdup (XFPM_PRIMARY_ICON_PREFIX); } - else if ( type == XFPM_DEVICE_TYPE_UPS ) + else if ( type == XFPM_DEVICE_TYPE_UPS ) { return g_strdup (XFPM_UPS_ICON_PREFIX); } - else if ( type == XFPM_DEVICE_TYPE_MOUSE ) + else if ( type == XFPM_DEVICE_TYPE_MOUSE ) { return g_strdup (XFPM_MOUSE_ICON_PREFIX); } - else if ( type == XFPM_DEVICE_TYPE_KBD ) + else if ( type == XFPM_DEVICE_TYPE_KBD ) { return g_strdup (XFPM_KBD_ICON_PREFIX); } - else if ( type == XFPM_DEVICE_TYPE_PHONE ) + else if ( type == XFPM_DEVICE_TYPE_PHONE ) { return g_strdup (XFPM_PHONE_ICON_PREFIX); } - + return g_strdup (XFPM_PRIMARY_ICON_PREFIX); } @@ -822,7 +822,7 @@ static const gchar * xfpm_battery_get_name (XfpmDeviceType type) { const gchar *name = NULL; - + switch (type) { case XFPM_DEVICE_TYPE_BATTERY: @@ -850,7 +850,7 @@ xfpm_battery_get_name (XfpmDeviceType type) name = _("Unknown"); break; } - + return name; } @@ -858,9 +858,9 @@ GtkStatusIcon * xfpm_battery_new (void) { XfpmBattery *battery = NULL; - + battery = g_object_new (XFPM_TYPE_BATTERY, NULL); - + return GTK_STATUS_ICON (battery); } @@ -874,8 +874,8 @@ void xfpm_battery_monitor_device (XfpmBattery *battery, battery->priv->proxy = proxy; battery->priv->icon_prefix = xfpm_battery_get_icon_prefix_device_enum_type (device_type); battery->priv->battery_name = xfpm_battery_get_name (device_type); - - + + dbus_g_proxy_add_signal (proxy, "Changed", G_TYPE_INVALID); dbus_g_proxy_connect_signal (proxy, "Changed", G_CALLBACK (xfpm_battery_changed_cb), battery, NULL); @@ -890,27 +890,27 @@ void xfpm_battery_monitor_device (XfpmBattery *battery, XfpmDeviceType xfpm_battery_get_device_type (XfpmBattery *battery) { g_return_val_if_fail (XFPM_IS_BATTERY (battery), XFPM_DEVICE_TYPE_UNKNOWN ); - + return battery->priv->type; } XfpmBatteryCharge xfpm_battery_get_charge (XfpmBattery *battery) { g_return_val_if_fail (XFPM_IS_BATTERY (battery), XFPM_BATTERY_CHARGE_UNKNOWN); - + return battery->priv->charge; } const gchar *xfpm_battery_get_battery_name (XfpmBattery *battery) { g_return_val_if_fail (XFPM_IS_BATTERY (battery), NULL); - + return battery->priv->battery_name; } gchar *xfpm_battery_get_time_left (XfpmBattery *battery) { g_return_val_if_fail (XFPM_IS_BATTERY (battery), NULL); - + return xfpm_battery_get_time_string (battery->priv->time_to_empty); } _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits