Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:zhy20120210:failed_1
gnome-power-manager
gnome-power-manager-bnc443956-fix-time-accurate...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gnome-power-manager-bnc443956-fix-time-accurate.patch of Package gnome-power-manager
Index: gnome-power-manager-2.24.2/src/gpm-cell-array.c =================================================================== --- gnome-power-manager-2.24.2.orig/src/gpm-cell-array.c +++ gnome-power-manager-2.24.2/src/gpm-cell-array.c @@ -489,21 +489,12 @@ gpm_cell_array_emit_system_action (GpmCellArray *cell_array, GpmWarningsState warnings_state) { - gfloat accuracy; GpmCellUnit *unit; g_return_val_if_fail (GPM_IS_CELL_ARRAY (cell_array), FALSE); - /* do we trust the profile enough to make a decision? */ + /* array */ unit = &(cell_array->priv->unit); - if (unit->kind == GPM_CELL_UNIT_KIND_PRIMARY) { - accuracy = gpm_profile_get_accuracy_average (cell_array->priv->profile, - unit->is_discharging); - if (accuracy < GPM_PROFILE_GOOD_TRUST) { - egg_debug ("profile is not accurate. Not doing policy action"); - return FALSE; - } - } /* we are not primary, or we are primary with a trusted profile */ if (warnings_state == GPM_WARNINGS_ACTION) { @@ -530,6 +521,7 @@ { GpmWarningsState warnings_state; GpmCellUnit *unit; + gfloat accuracy; g_return_if_fail (GPM_IS_CELL_ARRAY (cell_array)); @@ -556,6 +548,12 @@ cell_array->priv->done_fully_charged = FALSE; } + /* do we trust the profile enough to make a decision based on time? */ + if (unit->kind == GPM_CELL_UNIT_KIND_PRIMARY) { + accuracy = gpm_profile_get_accuracy_average (cell_array->priv->profile, unit->is_discharging); + gpm_warnings_time_is_accurate (cell_array->priv->warnings, (accuracy > GPM_PROFILE_GOOD_TRUST)); + } + /* only get a warning state if we are discharging */ if (unit->is_discharging) { warnings_state = gpm_warnings_get_state (cell_array->priv->warnings, unit); Index: gnome-power-manager-2.24.2/src/gpm-warnings.c =================================================================== --- gnome-power-manager-2.24.2.orig/src/gpm-warnings.c +++ gnome-power-manager-2.24.2/src/gpm-warnings.c @@ -50,6 +50,7 @@ { GpmConf *conf; gboolean use_time_primary; + gboolean time_is_accurate; guint low_percentage; guint critical_percentage; @@ -64,6 +65,21 @@ static gpointer gpm_warnings_object = NULL; +/** + * gpm_warnings_time_is_accurate: + * @warnings: This class instance + * @time_accurate: If the time remaining is accurate, and should be used for a policy action + * + * Return value: %TRUE if set + **/ +void +gpm_warnings_time_is_accurate (GpmWarnings *warnings, gboolean time_accurate) +{ + g_return_if_fail (GPM_IS_WARNINGS (warnings)); + egg_debug ("time accurate is %i", time_accurate); + warnings->priv->time_is_accurate = time_accurate; +} + static GpmWarningsState gpm_warnings_get_state_csr (GpmWarnings *warnings, GpmCellUnit *unit) @@ -150,15 +166,13 @@ type = gpm_warnings_get_state_percentage (warnings, unit); - } else if (unit->kind == GPM_CELL_UNIT_KIND_PRIMARY && - warnings->priv->use_time_primary) { - - type = gpm_warnings_get_state_time (warnings, unit); - - } else if (unit->kind == GPM_CELL_UNIT_KIND_PRIMARY && - warnings->priv->use_time_primary == FALSE) { - - type = gpm_warnings_get_state_percentage (warnings, unit); + } else if (unit->kind == GPM_CELL_UNIT_KIND_PRIMARY) { + /* only use the time when it is accurate, and GConf is not disabled */ + if (warnings->priv->time_is_accurate && + warnings->priv->use_time_primary) + type = gpm_warnings_get_state_time (warnings, unit); + else + type = gpm_warnings_get_state_percentage (warnings, unit); } /* If we have no important warningss, we should test for discharging */ @@ -254,6 +268,7 @@ { warnings->priv = GPM_WARNINGS_GET_PRIVATE (warnings); + warnings->priv->time_is_accurate = TRUE; warnings->priv->conf = gpm_conf_new (); g_signal_connect (warnings->priv->conf, "value-changed", G_CALLBACK (gconf_key_changed_cb), warnings); Index: gnome-power-manager-2.24.2/src/gpm-warnings.h =================================================================== --- gnome-power-manager-2.24.2.orig/src/gpm-warnings.h +++ gnome-power-manager-2.24.2/src/gpm-warnings.h @@ -56,11 +56,13 @@ GObjectClass parent_class; } GpmWarningsClass; -GType gpm_warnings_get_type (void); -GpmWarnings *gpm_warnings_new (void); +GType gpm_warnings_get_type (void); +GpmWarnings *gpm_warnings_new (void); -GpmWarningsState gpm_warnings_get_state (GpmWarnings *warnings, - GpmCellUnit *unit); +GpmWarningsState gpm_warnings_get_state (GpmWarnings *warnings, + GpmCellUnit *unit); +void gpm_warnings_time_is_accurate (GpmWarnings *warnings, + gboolean time_accurate); G_END_DECLS
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor