summaryrefslogtreecommitdiff
path: root/sensors-applet/sensors-applet.h
blob: fda92b5cde129582427b05b6f2e20a8b268ae45c (plain)
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
 * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
 *
 * 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 St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef SENSORS_APPLET_H
#define SENSORS_APPLET_H

#include <gtk/gtk.h>
#include <mate-panel-applet.h>
#include "sensors-applet-sensor.h"

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */

#ifdef HAVE_LIBNOTIFY
#include <libnotify/notify.h>
#endif

typedef struct _ActiveSensor ActiveSensor;

#include "prefs-dialog.h"

#define GRAPH_FRAME_EXTRA_WIDTH 6
#define SENSORS_APPLET_ICON "mate-sensors-applet"

static const gchar * const stock_icons[NUM_ICONS] = {
        "mate-sensors-applet-cpu",
        "mate-sensors-applet-drive-harddisk",
        "mate-sensors-applet-battery",
        "mate-sensors-applet-memory",
        "mate-sensors-applet-gpu",
        "mate-sensors-applet-chip",
        "mate-sensors-applet-fan",
        "mate-sensors-applet-case"
};        

#define DEFAULT_ICON_SIZE 22

#define UNITS_CELSIUS "\302\260C"
#define UNITS_FAHRENHEIT "\302\260F"
#define UNITS_KELVIN ""
#define UNITS_RPM _("RPM")
#define UNITS_VOLTAGE  _("V")
#define UNITS_CURRENT  _("A")


/* enumeration used to identify columns in the GtkTreeStore data
 * structure
 */
enum {
	PATH_COLUMN = 0,
	ID_COLUMN,
	LABEL_COLUMN,
	INTERFACE_COLUMN,
	SENSOR_TYPE_COLUMN,
	ENABLE_COLUMN,
	VISIBLE_COLUMN,
       	LOW_VALUE_COLUMN,
	HIGH_VALUE_COLUMN, 
	ALARM_ENABLE_COLUMN,
	LOW_ALARM_COMMAND_COLUMN,
        HIGH_ALARM_COMMAND_COLUMN,
	ALARM_TIMEOUT_COLUMN,
	MULTIPLIER_COLUMN,
	OFFSET_COLUMN,
	ICON_TYPE_COLUMN,
	ICON_PIXBUF_COLUMN,
        GRAPH_COLOR_COLUMN,
	N_COLUMNS
};


/* for display mode */
typedef enum {
	DISPLAY_LABEL_WITH_VALUE = 0,
        DISPLAY_ICON_WITH_VALUE, 
	DISPLAY_VALUE,
	DISPLAY_ICON,
	DISPLAY_GRAPH
} DisplayMode;

typedef enum {
        VALUE_BESIDE_LABEL = 0,
        VALUE_BELOW_LABEL
} LayoutMode;

typedef enum {
        KELVIN = 0,
        CELSIUS,
        FAHRENHEIT
} TemperatureScale;

/* types of Notifs - low and high alarm warnings and error conditions*/
typedef enum {
        LOW_ALARM = 0,
        HIGH_ALARM,
        SENSOR_INTERFACE_ERROR,
        NUM_NOTIFS
} NotifType;

/* only always two type of alarms - may have more notif types */
#define NUM_ALARMS 2

struct _SensorsApplet {
	/* the actual applet for this instance */
	MatePanelApplet* applet;
        gint size;

	GtkTreeStore *sensors;
	GtkTreeSelection *selection;

        GHashTable *required_plugins;
        GHashTable *plugins;
        
	guint timeout_id;
	/* preferences and about windows (if Gtk < 2.6)*/
	PrefsDialog *prefs_dialog;

	/* primary table to contain the panel dispay - we pack the
	 * list of labels and sensor values into this container */
	GtkWidget *table;
	GList *active_sensors;

	GSettings *settings;

#ifdef HAVE_LIBNOTIFY
        NotifyNotification *notification;
#endif // HAVE_LIBNOTIFY
};



/* non-static function prototypes */
void sensors_applet_init(SensorsApplet *sensors_applet);
void sensors_applet_sensor_enabled(SensorsApplet *sensors_applet,
                                   GtkTreePath *path);
void sensors_applet_sensor_disabled(SensorsApplet *sensors_applet,
                                    GtkTreePath *path);
gboolean sensors_applet_update_active_sensors(SensorsApplet *sensors_applet);
/**
 * to be called by things like prefs dialog to turn off a sensor alarm
 */
void sensors_applet_alarm_off(SensorsApplet *sensors_applet,
                              GtkTreePath *path,
                              NotifType notif_type);
void sensors_applet_all_alarms_off(SensorsApplet *sensors_applet,
                              GtkTreePath *path);
void sensors_applet_icon_changed(SensorsApplet *sensors_applet,
                                 GtkTreePath *path);
void sensors_applet_update_sensor(SensorsApplet *sensors_applet,
                                  GtkTreePath *path);

void sensors_applet_display_layout_changed(SensorsApplet *sensors_applet);
void sensors_applet_reorder_sensors(SensorsApplet *sensors_applet);
gdouble sensors_applet_convert_temperature(gdouble value, 
                                           TemperatureScale old, 
                                           TemperatureScale new);

void sensors_applet_notify_end(ActiveSensor *active_sensor, NotifType notif_type);
void sensors_applet_notify_end_all(SensorsApplet *sensors_applet);
void sensors_applet_notify_active_sensor(ActiveSensor *active_sensor, NotifType notif_type);
GdkPixbuf *sensors_applet_load_icon(IconType icon_type);
void sensors_applet_graph_size_changed(SensorsApplet *sensors_applet);

typedef void SensorsInterfaceTestSensorFunc(SensorsApplet *sensors_applet,
                                            const gchar *path);
void sensors_applet_find_sensors(SensorsApplet *sensors_applet,
                                 const gchar *path,
                                 SensorsInterfaceTestSensorFunc test_sensor);

#endif /* SENSORS_APPLET_H */