Codebase list gnome-shell-extension-gamemode / upstream/7
New upstream release Jonathan Carter 2 years ago
6 changed file(s) with 152 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
113113 "ngettext": false
114114 },
115115 "parserOptions": {
116 "ecmaVersion": 2017
116 "ecmaVersion": 2018
117117 }
118118 }
0 gnome-shell-extension-gamemode (7-1) unstable; urgency=medium
1
2 * New upstream release (Closes: #1008548)
3 * Update standards version to 4.6.0
4
5 -- Jonathan Carter <jcc@debian.org> Tue, 03 May 2022 13:40:32 +0200
6
07 gnome-shell-extension-gamemode (6-1) unstable; urgency=medium
18
29 * New upstream release (Closes: #996057)
55 libglib2.0-bin,
66 meson,
77 ninja-build
8 Standards-Version: 4.5.1
8 Standards-Version: 4.6.0
99 Homepage: https://github.com/gicmo/gamemode-extension
1010 Vcs-Browser: https://salsa.debian.org/gnome-team/shell-extensions/gnome-shell-extension-gamemode
1111 Vcs-Git: https://salsa.debian.org/gnome-team/shell-extensions/gnome-shell-extension-gamemode.git
00 project('gamemode-extension',
1 version: '6',
1 version: '7',
22 meson_version: '>= 0.46.0',
33 license: 'LGPL-2.1' )
44
22 "name": "GameMode",
33 "description": "Status indicator for GameMode",
44 "uuid": "@UUID@",
5 "shell-version": ["3.38", "40", "41"],
5 "shell-version": ["3.38", "40", "41", "42"],
66 "version": "@VERSION@",
77 "url": "@URL@",
88 "original-author": "ckellner@redhat.com",
0 const GObject = imports.gi.GObject;
1 const Gtk = imports.gi.Gtk;
2 const Gdk = imports.gi.Gdk;
3 const Lang = imports.lang;
4 const Gio = imports.gi.Gio;
5
60 const ExtensionUtils = imports.misc.extensionUtils;
71 const Me = ExtensionUtils.getCurrentExtension();
82
93 const Config = imports.misc.config;
104 const [major] = Config.PACKAGE_VERSION.split('.');
115 const shellVersion = Number.parseInt(major);
6
7 const {Gdk, Gio, GObject, Gtk} = imports.gi;
8 const Adw = shellVersion >= 42 ? imports.gi.Adw : null;
9
1210
1311 var GameModeSettings = GObject.registerClass(class GameModePrefWidget extends Gtk.ListBox {
1412
147145 }
148146 });
149147
148
149 /*Gnome 42 - libadwaita implementation*/
150
151 const RowColorButton = shellVersion < 42 ? null : GObject.registerClass(
152 {
153 GTypeName: 'RowColorButton',
154 Properties: {
155 'css-color': GObject.ParamSpec.string(
156 'css-color', 'css color',
157 'The currently selected color, as a valid css color spec.',
158 GObject.ParamFlags.READWRITE, ''
159 )
160 }
161 },
162 class RowColorButton extends Gtk.ColorButton {
163
164 constructor(params) {
165 super(params);
166 this.bind_property_full(
167 'css-color', this, 'rgba',
168 GObject.BindingFlags.SYNC_CREATE |
169 GObject.BindingFlags.BIDIRECTIONAL,
170 (_, target)=> {
171 let rgba = new Gdk.RGBA();
172 rgba.parse(target);
173 return [true, rgba];
174 },
175 (_, target)=>[true, target.to_string()]
176 );
177 }
178 });
179
180
181 const SwitchActionRow = shellVersion < 42 ? null : GObject.registerClass(
182 {
183 GTypeName: 'SwitchActionRow',
184 Properties: {
185 'active-key': GObject.ParamSpec.string(
186 'active-key', 'Active key',
187 'Key name in settings that stores the switch active property.',
188 GObject.ParamFlags.READWRITE, ''
189 ),
190 },
191 },
192 class SwitchActionRow extends Adw.ActionRow {
193
194 constructor({active_key, ...args}) {
195 super(args);
196 this._settings = ExtensionUtils.getSettings();
197 this._suffix_container = new Gtk.Box(
198 {orientation: Gtk.Orientation.HORIZONTAL}
199 );
200 this._switch = new Gtk.Switch({valign: Gtk.Align.CENTER});
201
202 this.add_suffix(this._suffix_container);
203 this.add_suffix(this._switch);
204 this.set_activatable_widget(this._switch);
205 this.activeKey = active_key;
206 }
207
208 get active_key() {
209 return this._active_key;
210 }
211
212 set active_key(key) {
213 if (this.active_key === key)
214 return;
215 if (this._settings.settings_schema.get_key(key)) {
216 let schema_key = this._settings.settings_schema.get_key(key);
217 this.title = schema_key.get_summary();
218 this.subtitle = schema_key.get_description();
219 this._settings.bind(key, this._switch, 'active',
220 Gio.SettingsBindFlags.DEFAULT);
221 this._active_key = key;
222 this.notify('active-key');
223 }
224 }
225 });
226
227
228 const ColorActionRow = shellVersion < 42 ? null : GObject.registerClass(
229 {
230 GTypeName: 'ColorActionRow',
231 InternalChilds: ['color_btn'],
232 Properties: {
233 'color-key': GObject.ParamSpec.string(
234 'color-key', 'Color key',
235 'Key name in settings that stores the selected color.',
236 GObject.ParamFlags.READWRITE, ''
237 ),
238 },
239 },
240 class ColorActionRow extends SwitchActionRow {
241
242 constructor({color_key, ...args}) {
243 super(args);
244 this._color_btn = new RowColorButton({valign: Gtk.Align.CENTER});
245 this._suffix_container.append(this._color_btn);
246 this.colorKey = color_key;
247 }
248
249 get color_key() {
250 return this._color_key;
251 }
252
253 set color_key(key) {
254 if (this.color_key === key)
255 return;
256 if (this._settings.settings_schema.get_key(key)) {
257 let schema_key = this._settings.settings_schema.get_key(key);
258 this._color_btn.set_tooltip_markup(schema_key.get_description());
259 this._settings.bind(key, this._color_btn, 'css-color',
260 Gio.SettingsBindFlags.DEFAULT |
261 Gio.SettingsBindFlags.NO_SENSITIVITY);
262 this._color_key = key;
263 this.notify('color-key');
264 }
265 }
266 });
267
268
150269 function init() {
151270 ExtensionUtils.initTranslations();
152271 }
153272
273 // Gnome Shell < 42
154274 function buildPrefsWidget() {
155275 let widget = new GameModeSettings();
156276
160280
161281 return widget;
162282 }
283
284 // Gnome Shell >= 42
285 function fillPreferencesWindow(window) {
286 let settings_page = Adw.PreferencesPage.new();
287 let main_group = Adw.PreferencesGroup.new();
288
289 main_group.add(new SwitchActionRow({active_key: 'emit-notifications'}));
290 main_group.add(new SwitchActionRow({active_key: 'always-show-icon'}));
291 main_group.add(new ColorActionRow(
292 {active_key: 'active-tint', color_key: 'active-color'}));
293
294 settings_page.add(main_group);
295 window.add(settings_page);
296 }
297