1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2  *
3  * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
4  * Copyright (C) 2012-2021 MATE Developers
5  *
6  * Licensed under the GNU General Public License Version 2
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #ifndef __GPMCOMMON_H
24 #define __GPMCOMMON_H
25 
26 #include <glib.h>
27 #include <gtk/gtk.h>
28 
29 #include <unistd.h>
30 
31 G_BEGIN_DECLS
32 
33 #define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0)
34 
35 #define	GPM_DBUS_SERVICE		"org.mate.PowerManager"
36 #define	GPM_DBUS_INTERFACE		"org.mate.PowerManager"
37 #define	GPM_DBUS_INTERFACE_BACKLIGHT	"org.mate.PowerManager.Backlight"
38 #define	GPM_DBUS_INTERFACE_KBD_BACKLIGHT	"org.mate.PowerManager.KbdBacklight"
39 #define	GPM_DBUS_PATH			"/org/mate/PowerManager"
40 #define	GPM_DBUS_PATH_BACKLIGHT		"/org/mate/PowerManager/Backlight"
41 #define GPM_DBUS_PATH_KBD_BACKLIGHT    "/org/mate/PowerManager/KbdBacklight"
42 
43 /* common descriptions of this program */
44 #define GPM_NAME 			_("Power Manager")
45 #define GPM_DESCRIPTION 		_("Power Manager for the MATE desktop")
46 
47 /* schema location */
48 #define GPM_SETTINGS_SCHEMA				"org.mate.power-manager"
49 
50 /* actions */
51 #define GPM_SETTINGS_ACTION_CRITICAL_UPS		"action-critical-ups"
52 #define GPM_SETTINGS_ACTION_CRITICAL_BATT		"action-critical-battery"
53 #define GPM_SETTINGS_ACTION_LOW_UPS			"action-low-ups"
54 #define GPM_SETTINGS_ACTION_SLEEP_TYPE_AC		"action-sleep-type-ac"
55 #define GPM_SETTINGS_ACTION_SLEEP_TYPE_BATT		"action-sleep-type-battery"
56 #define GPM_SETTINGS_SLEEP_WHEN_CLOSED			"event-when-closed-battery"
57 
58 /* backlight stuff */
59 #define GPM_SETTINGS_BACKLIGHT_ENABLE			"backlight-enable"
60 #define GPM_SETTINGS_BACKLIGHT_BATTERY_REDUCE		"backlight-battery-reduce"
61 #define GPM_SETTINGS_DPMS_METHOD_AC			"dpms-method-ac"
62 #define GPM_SETTINGS_DPMS_METHOD_BATT			"dpms-method-battery"
63 #define GPM_SETTINGS_IDLE_BRIGHTNESS			"idle-brightness"
64 #define GPM_SETTINGS_IDLE_DIM_AC			"idle-dim-ac"
65 #define GPM_SETTINGS_IDLE_DIM_BATT			"idle-dim-battery"
66 #define GPM_SETTINGS_IDLE_DIM_TIME			"idle-dim-time"
67 #define GPM_SETTINGS_BRIGHTNESS_AC			"brightness-ac"
68 #define GPM_SETTINGS_BRIGHTNESS_DIM_BATT		"brightness-dim-battery"
69 
70 /* keyboard backlight */
71 #define GPM_SETTINGS_KBD_BACKLIGHT_BATT_REDUCE     "kbd-backlight-battery-reduce"
72 #define GPM_SETTINGS_KBD_BRIGHTNESS_ON_AC      "kbd-brightness-on-ac"
73 #define GPM_SETTINGS_KBD_BRIGHTNESS_DIM_BY_ON_BATT      "kbd-brightness-dim-by-on-battery"
74 #define GPM_SETTINGS_KBD_BRIGHTNESS_DIM_BY_ON_IDLE "kbd-brightness-dim-by-on-idle"
75 
76 /* buttons */
77 #define GPM_SETTINGS_BUTTON_LID_AC			"button-lid-ac"
78 #define GPM_SETTINGS_BUTTON_LID_BATT			"button-lid-battery"
79 #define GPM_SETTINGS_BUTTON_SUSPEND			"button-suspend"
80 #define GPM_SETTINGS_BUTTON_HIBERNATE			"button-hibernate"
81 #define GPM_SETTINGS_BUTTON_POWER			"button-power"
82 
83 /* general */
84 #define GPM_SETTINGS_USE_TIME_POLICY			"use-time-for-policy"
85 #define GPM_SETTINGS_NETWORKMANAGER_SLEEP		"network-sleep"
86 #define GPM_SETTINGS_IDLE_CHECK_CPU			"check-type-cpu"
87 
88 /* lock */
89 #define GPM_SETTINGS_LOCK_USE_SCREENSAVER		"lock-use-screensaver"
90 #define GPM_SETTINGS_LOCK_ON_BLANK_SCREEN		"lock-blank-screen"
91 #define GPM_SETTINGS_LOCK_ON_SUSPEND			"lock-suspend"
92 #define GPM_SETTINGS_LOCK_ON_HIBERNATE			"lock-hibernate"
93 #define GPM_SETTINGS_LOCK_KEYRING_SUSPEND		"lock-keyring-suspend"
94 #define GPM_SETTINGS_LOCK_KEYRING_HIBERNATE		"lock-keyring-hibernate"
95 
96 /* notify */
97 #define GPM_SETTINGS_NOTIFY_LOW_CAPACITY		"notify-low-capacity"
98 #define GPM_SETTINGS_NOTIFY_DISCHARGING			"notify-discharging"
99 #define GPM_SETTINGS_NOTIFY_FULLY_CHARGED		"notify-fully-charged"
100 #define GPM_SETTINGS_NOTIFY_SLEEP_FAILED		"notify-sleep-failed"
101 #define GPM_SETTINGS_NOTIFY_SLEEP_FAILED_URI		"notify-sleep-failed-uri"
102 #define GPM_SETTINGS_NOTIFY_LOW_POWER			"notify-low-power"
103 #define GPM_SETTINGS_NOTIFY_LOW_CAPACITY_MOUSE		"notify-low-capacity-mouse"
104 
105 /* thresholds */
106 #define GPM_SETTINGS_PERCENTAGE_LOW			"percentage-low"
107 #define GPM_SETTINGS_PERCENTAGE_CRITICAL		"percentage-critical"
108 #define GPM_SETTINGS_PERCENTAGE_ACTION			"percentage-action"
109 #define GPM_SETTINGS_TIME_LOW				"time-low"
110 #define GPM_SETTINGS_TIME_CRITICAL			"time-critical"
111 #define GPM_SETTINGS_TIME_ACTION			"time-action"
112 
113 /* timeout */
114 #define GPM_SETTINGS_SLEEP_COMPUTER_AC			"sleep-computer-ac"
115 #define GPM_SETTINGS_SLEEP_COMPUTER_BATT		"sleep-computer-battery"
116 #define GPM_SETTINGS_SLEEP_COMPUTER_UPS			"sleep-computer-ups"
117 #define GPM_SETTINGS_SLEEP_DISPLAY_AC			"sleep-display-ac"
118 #define GPM_SETTINGS_SLEEP_DISPLAY_BATT			"sleep-display-battery"
119 #define GPM_SETTINGS_SLEEP_DISPLAY_UPS			"sleep-display-ups"
120 
121 /* ui */
122 #define GPM_SETTINGS_ICON_POLICY			"icon-policy"
123 #define GPM_SETTINGS_ENABLE_SOUND			"enable-sound"
124 #define GPM_SETTINGS_SHOW_ACTIONS			"show-actions"
125 
126 /* statistics */
127 #define GPM_SETTINGS_INFO_HISTORY_TIME			"info-history-time"
128 #define GPM_SETTINGS_INFO_HISTORY_TYPE			"info-history-type"
129 #define GPM_SETTINGS_INFO_HISTORY_GRAPH_SMOOTH		"info-history-graph-smooth"
130 #define GPM_SETTINGS_INFO_HISTORY_GRAPH_POINTS		"info-history-graph-points"
131 #define GPM_SETTINGS_INFO_STATS_TYPE			"info-stats-type"
132 #define GPM_SETTINGS_INFO_STATS_GRAPH_SMOOTH		"info-stats-graph-smooth"
133 #define GPM_SETTINGS_INFO_STATS_GRAPH_POINTS		"info-stats-graph-points"
134 #define GPM_SETTINGS_INFO_PAGE_NUMBER			"info-page-number"
135 #define GPM_SETTINGS_INFO_LAST_DEVICE			"info-last-device"
136 
137 /* mate-screensaver */
138 #define GS_SETTINGS_SCHEMA				"org.mate.screensaver"
139 #define GS_SETTINGS_PREF_LOCK_ENABLED			"lock-enabled"
140 
141 typedef enum {
142 	GPM_ICON_POLICY_ALWAYS,
143 	GPM_ICON_POLICY_PRESENT,
144 	GPM_ICON_POLICY_CHARGE,
145 	GPM_ICON_POLICY_LOW,
146 	GPM_ICON_POLICY_CRITICAL,
147 	GPM_ICON_POLICY_NEVER
148 } GpmIconPolicy;
149 
150 typedef enum {
151 	GPM_ACTION_POLICY_BLANK,
152 	GPM_ACTION_POLICY_SUSPEND,
153 	GPM_ACTION_POLICY_SHUTDOWN,
154 	GPM_ACTION_POLICY_HIBERNATE,
155 	GPM_ACTION_POLICY_INTERACTIVE,
156 	GPM_ACTION_POLICY_NOTHING
157 } GpmActionPolicy;
158 
159 gchar        *gpm_get_timestring                (guint time);
160 guint        gpm_discrete_from_percent          (guint percentage,
161                                                  guint levels);
162 guint        gpm_discrete_to_percent            (guint discrete,
163                                                  guint levels);
164 void         gpm_help_display                   (const gchar    *link_id);
165 gboolean     gpm_notebook_scroll_event_cb       (GtkWidget      *widget,
166                                                  GdkEventScroll *event);
167 #ifdef EGG_TEST
168 void         gpm_common_test                     (gpointer data);
169 #endif
170 
171 G_END_DECLS
172 
173 #endif	/* __GPMCOMMON_H */
174