Skip to content

Commit

Permalink
Implement quick settings toggle setting
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarthayhurst committed Jul 6, 2024
1 parent a6438fd commit 58711bb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions caffeine@patapon.info/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const INHIBIT_APPS_KEY = 'inhibit-apps';
const SHOW_INDICATOR_KEY = 'show-indicator';
const SHOW_NOTIFICATIONS_KEY = 'show-notifications';
const SHOW_TIMER_KEY = 'show-timer';
const SHOW_TOGGLE_KEY = 'show-toggle';
const DURATION_TIMER_LIST = 'duration-timer-list';
const USER_ENABLED_KEY = 'user-enabled';
const RESTORE_KEY = 'restore-state';
Expand Down Expand Up @@ -418,12 +419,11 @@ const CaffeineToggle = GObject.registerClass({
this._iconDeactivated = Gio.icon_new_for_string(`${this._path}/icons/${DisabledIcon}.svg`);
this.updateIcon();

// Menu
// Set up entry
this.menu.setHeader(this.finalTimerMenuIcon, _('Caffeine Timer'), null);

// Add elements
this._itemsSection = new PopupMenu.PopupMenuSection();
this.menu.addMenuItem(this._itemsSection);
this.visible = this._settings.get_boolean(SHOW_TOGGLE_KEY);

// Init Timers
this._timerItems = new Map();
Expand All @@ -435,6 +435,10 @@ const CaffeineToggle = GObject.registerClass({
() => this._sync(),
`changed::${DURATION_TIMER_LIST}`,
() => this._syncTimers(true),
`changed::${SHOW_TOGGLE_KEY}`,
() => {
this.visible = this._settings.get_boolean(SHOW_TOGGLE_KEY);
},
this);
this.connect('destroy', () => {
this._iconActivated = null;
Expand Down

0 comments on commit 58711bb

Please sign in to comment.