diff options
| author | rbuj <[email protected]> | 2021-12-24 15:27:50 +0100 | 
|---|---|---|
| committer | Luke from DC <[email protected]> | 2022-03-23 04:31:52 +0000 | 
| commit | 72ae2b2176a40f7be71ecfa36caed4a8c0cec8c3 (patch) | |
| tree | 1270da452fbc6dc381ef708249de21b2c3d41e18 | |
| parent | 27179fe049f751ec173ba5658ac6585163eeac20 (diff) | |
| download | mate-applets-72ae2b2176a40f7be71ecfa36caed4a8c0cec8c3.tar.bz2 mate-applets-72ae2b2176a40f7be71ecfa36caed4a8c0cec8c3.tar.xz | |
battstat: present is bistate, charging and acline_status are tristate
| -rw-r--r-- | battstat/battstat.h | 27 | ||||
| -rw-r--r-- | battstat/battstat_applet.c | 11 | 
2 files changed, 22 insertions, 16 deletions
| diff --git a/battstat/battstat.h b/battstat/battstat.h index cbe07855..994f7e7e 100644 --- a/battstat/battstat.h +++ b/battstat/battstat.h @@ -56,13 +56,20 @@ typedef enum    STATUS_PIXMAP_NUM  } StatusPixmapIndex; +typedef enum +{ +  POWER_STATUS_OFF = 0, +  POWER_STATUS_ON, +  POWER_STATUS_UNKNOWN +} PowerStatus; +  typedef struct  { -  gboolean on_ac_power; -  gboolean charging; -  gboolean present; -  gint minutes; -  gint percent; +  PowerStatus on_ac_power; +  PowerStatus charging; +  gboolean    present; +  gint        minutes; +  gint        percent;  } BatteryStatus;  typedef enum @@ -133,12 +140,12 @@ typedef struct _ProgressData {    int timeout;    /* last_* for the benefit of the check_for_updates function */ -  guint last_batt_life; -  guint last_acline_status; +  guint             last_batt_life;    StatusPixmapIndex last_pixmap_index; -  guint last_charging; -  guint last_minutes; -  gboolean last_present; +  PowerStatus       last_acline_status; +  PowerStatus       last_charging; +  gboolean          last_present; +  guint             last_minutes;  } ProgressData;  /* battstat_applet.c */ diff --git a/battstat/battstat_applet.c b/battstat/battstat_applet.c index 30d15e75..41f29fa0 100644 --- a/battstat/battstat_applet.c +++ b/battstat/battstat_applet.c @@ -675,8 +675,7 @@ check_for_updates (gpointer data)      }      if (battstat->last_charging && -        battstat->last_acline_status && -        battstat->last_acline_status!=1000 && +        battstat->last_acline_status == POWER_STATUS_ON &&          !info.charging &&          info.on_ac_power &&          info.present && @@ -726,10 +725,10 @@ check_for_updates (gpointer data)          battstat->refresh_label = FALSE;      } -    battstat->last_charging = (info.charging != FALSE); +    battstat->last_charging = info.charging;      battstat->last_batt_life = info.percent;      battstat->last_minutes = info.minutes; -    battstat->last_acline_status = (info.on_ac_power != FALSE); +    battstat->last_acline_status = info.on_ac_power;      battstat->last_present = info.present;      return TRUE; @@ -1146,8 +1145,8 @@ battstat_applet_fill (MatePanelApplet *applet)      battstat->applet = GTK_WIDGET (applet);      battstat->refresh_label = TRUE;      battstat->last_batt_life = 1000; -    battstat->last_acline_status = 1000; -    battstat->last_charging = 1000; +    battstat->last_acline_status = POWER_STATUS_UNKNOWN; +    battstat->last_charging = POWER_STATUS_UNKNOWN;      battstat->orienttype = mate_panel_applet_get_orient (applet);      battstat->battery_low_dialog = NULL;      battstat->battery_low_label = NULL; | 
