1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
/*
* Copyright (C) 2000 by Jörgen Pehrson <jp@spektr.eu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
$Id$
*/
#ifndef _battstat_h_
#define _battstat_h_
#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <mate-panel-applet.h>
#include <mate-panel-applet-gsettings.h>
#define DEBUG 0
#define PROGLEN 33.0
/* I made these multipliers up
* --davyd
*/
#define ORANGE_MULTIPLIER 1.5
#define YELLOW_MULTIPLIER 2.5
typedef enum
{
APPLET_SHOW_NONE = 0,
APPLET_SHOW_PERCENT,
APPLET_SHOW_TIME
} AppletTextType;
typedef enum
{
STATUS_PIXMAP_BATTERY,
STATUS_PIXMAP_METER,
STATUS_PIXMAP_AC,
STATUS_PIXMAP_CHARGE,
STATUS_PIXMAP_WARNING,
STATUS_PIXMAP_NUM
} StatusPixmapIndex;
typedef struct
{
gboolean on_ac_power;
gboolean charging;
gboolean present;
gint minutes;
gint percent;
} BatteryStatus;
typedef enum
{
LAYOUT_NONE,
LAYOUT_LONG,
LAYOUT_TOPLEFT,
LAYOUT_TOP,
LAYOUT_LEFT,
LAYOUT_CENTRE,
LAYOUT_RIGHT,
LAYOUT_BOTTOM
} LayoutLocation;
typedef struct
{
LayoutLocation status;
LayoutLocation text;
LayoutLocation battery;
} LayoutConfiguration;
typedef struct _ProgressData {
GtkWidget *applet;
/* flags set from gsettings or the properties dialog */
GSettings *settings;
guint red_val;
guint orange_val;
guint yellow_val;
gboolean red_value_is_time;
gboolean lowbattnotification;
gboolean fullbattnot;
gboolean beep;
AppletTextType showtext;
/* label changed type (% <-> h:mm) and must be refreshed */
gboolean refresh_label;
/* the main grid that contains the visual elements */
GtkWidget *grid;
/* the visual elements */
GtkWidget *battery;
GtkWidget *status;
GtkWidget *percent;
/* dialog boxes that might be displayed */
GtkWidget *prop_win;
GtkWidget *battery_low_dialog;
/* text label inside the low battery dialog */
GtkLabel *battery_low_label;
/* our height/width as given to us by size_allocate */
gint width, height;
/* should the battery meter be drawn horizontally? */
gboolean horizont;
/* on a vertical or horizontal panel? (up/down/left/right) */
MatePanelAppletOrient orienttype;
/* the current layout of the visual elements inside the grid */
LayoutConfiguration layout;
/* g_timeout source identifier */
int timeout_id;
int timeout;
/* last_* for the benefit of the check_for_updates function */
guint last_batt_life;
guint last_acline_status;
StatusPixmapIndex last_pixmap_index;
guint last_charging;
guint last_minutes;
gboolean last_present;
} ProgressData;
/* battstat_applet.c */
void reconfigure_layout( ProgressData *battstat );
void battstat_show_help( ProgressData *battstat, const char *section );
void prop_cb (GtkAction *, ProgressData *);
/* power-management.c */
const char *power_management_getinfo( BatteryStatus *status );
const char *power_management_initialise (void (*callback) (void));
void power_management_cleanup( void );
int power_management_using_upower( void );
#endif /* _battstat_h_ */
|