Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cutomizable timer duration #319

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

pakaoraki
Copy link
Collaborator

Add new "Timer" menu in preferences with customizable timer duration.

Screenshot from 2024-03-14 18-07-07 resized

This will close #296

@pakaoraki
Copy link
Collaborator Author

It look like there is some issues with my code, I can't fix PR right now, I will have more time tomorrow evening. Cheers

@stuarthayhurst
Copy link
Collaborator

stuarthayhurst commented Mar 14, 2024

I haven't looked at the code yet, but would it be better to store timer lengths using 1 key as an array, instead of 3 separate keys?

Also, if I remember correctly, red is supposed to be for destructive actions according to the GNOME Human Interface Guidelines I think it was? I don't know if that applies to extensions, but it might be worth considering to be consistent with the rest of GNOME.

Still, this is a clear improvement over the current system, nice work :)

@pakaoraki
Copy link
Collaborator Author

I haven't looked at the code yet, but would it be better to store timer lengths using 1 key as an array, instead of 3 separate keys?

Yes I totally agree, I was thinking the same. I just used a simple 'int' type for each duration but it need to be unified with a single key.

Also, if I remember correctly, red is supposed to be for destructive actions according to the GNOME Human Interface Guidelines I think it was? I don't know if that applies to extensions, but it might be worth considering to be consistent with the rest of GNOME.

It make sense, I hesitated to keep the red color anyway so I can remove it.

There are some other small improvements to make, I'll try to fix it all this evening or tomorrow for final review.

@pakaoraki
Copy link
Collaborator Author

There is a weird eslint issue:

/home/runner/work/gnome-shell-extension-caffeine/gnome-shell-extension-caffeine/caffeine@patapon.info/preferences/timerPage.js
283:13 error Expected property shorthand object-shorthand

The code is the same as line 66, but it cause an error only in line 283. Should I ignore this using /* eslint-disable object-shorthand */ and /* eslint-enable object-shorthand */ or did I miss something ?

@stuarthayhurst
Copy link
Collaborator

There is a weird eslint issue:

/home/runner/work/gnome-shell-extension-caffeine/gnome-shell-extension-caffeine/caffeine@patapon.info/preferences/timerPage.js
283:13 error Expected property shorthand object-shorthand

The code is the same as line 66, but it cause an error only in line 283. Should I ignore this using /* eslint-disable object-shorthand */ and /* eslint-enable object-shorthand */ or did I miss something ?

I think it's because the variables have different names, durationIndex and value. I think changing the name of value, or replacing value: value with value should do it?

@pakaoraki
Copy link
Collaborator Author

Thanks

Comment on lines 125 to 134
let enableCustomTimerSwitch = new Gtk.Switch({
valign: Gtk.Align.CENTER,
active: this._settings.get_boolean(this._settingsKey.USE_CUSTOM_DURATION)
});
this.enableCustomTimerRow = new Adw.ActionRow({
title: _('Enable custom values'),
subtitle: _('Select custom value for each duration'),
activatable_widget: enableCustomTimerSwitch
});
this.enableCustomTimerRow.add_suffix(enableCustomTimerSwitch);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let enableCustomTimerSwitch = new Gtk.Switch({
valign: Gtk.Align.CENTER,
active: this._settings.get_boolean(this._settingsKey.USE_CUSTOM_DURATION)
});
this.enableCustomTimerRow = new Adw.ActionRow({
title: _('Enable custom values'),
subtitle: _('Select custom value for each duration'),
activatable_widget: enableCustomTimerSwitch
});
this.enableCustomTimerRow.add_suffix(enableCustomTimerSwitch);
this.enableCustomTimerRow = new Adw.SwitchRow({
title: _('Enable custom values'),
subtitle: _('Select custom value for each duration'),
active: this._settings.get_boolean(this._settingsKey.USE_CUSTOM_DURATION)
});

SwitchRow was introduced with libadwaita 1.4 (Gnome 45). It would make sense to use it here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I changed it.


// Bind signals
// --------------
enableCustomTimerSwitch.connect('notify::active', (widget) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
enableCustomTimerSwitch.connect('notify::active', (widget) => {
this.enableCustomTimerRow.connect('notify::active', (widget) => {

See above

@gabrbrand
Copy link

gabrbrand commented Mar 27, 2024

I manually installed this branch with make all on Fedora Rawhide (Gnome 46).
The stopwatch-symbolic currently isn't visible in dark style:
image
This can be fixed by moving caffeine@patapon.info/icons/stopwatch-symbolic.svg to caffeine@patapon.info/icons/hicolor/scalable/actions and changing

Gio.icon_new_for_string(`${this._path}/icons/${TimerMenuIcon}.svg`); 

to

Gio.icon_new_for_string(`${this._path}/icons/hicolor/scalable/actions/${TimerMenuIcon}.svg`);

in caffeine@patapon.info/extension.js (line 147)

@pakaoraki
Copy link
Collaborator Author

pakaoraki commented Mar 27, 2024

Thanks for reporting, icon fixed. Tested in Ubuntu 24.04 / Fedora 40.

@stuarthayhurst
Copy link
Collaborator

The pipeline failure seems to be eslint 9 complaining about arguments, we wouldn't need to try and fix it if we just drop the jsdoc stuff, since I don't think we don't really use it anyway

If we drop it we just need to update the makefile, workflow definition and linter configs

@pakaoraki
Copy link
Collaborator Author

I tried to remove the jsdoc plugin but it's seams that we need to rewrite the entire Eslint config for version 9.0 (migrate-to-9.0.0) as they changed the config file format.

Should we make a separate PR for this ?

@stuarthayhurst
Copy link
Collaborator

Should we make a separate PR for this ?

Yeah, probably a good idea

@matdave
Copy link

matdave commented Apr 29, 2024

This feature is awesome. I've been wanting long timers since I work on dual computers and need both on during my work day. This is saving me from having to remember to turn caffeine off at the end of my work day.

@pakaoraki pakaoraki force-pushed the change_timers branch 2 times, most recently from 7ef6741 to dd1222c Compare April 30, 2024 22:08
@pakaoraki
Copy link
Collaborator Author

@eonpatapon @stuarthayhurst
I think it's ready to merge, let me know if it's ok for you.

@stuarthayhurst
Copy link
Collaborator

Looks ok to me, do we want to merge this with a squash merge since there are a lot of small commits and fixes for previous commits?

Remove old code
Add missing leading zero and fix subtitle display hours

Fix variable name

Change countdown-timer to seconds
Clean durations title

Clean code
Fix translations
Fix spaces and syntax issues

Remove unused vars
Fix spacing

Remove trailling space

Fix object-shorthand

Fix spacing
Fix object-shorthand with value

Rename constant with uppercase

Symplify code

Replace Gtk.Switch/ActionRow with Adw.SwitchRow

Improve code: get durations values

Fix stopwatch icon

Update translations
Update locales

Update catalan translation
Comment on lines +79 to +83
this.sliderTimer.add_mark(0, Gtk.PositionType.BOTTOM, null);
this.sliderTimer.add_mark(1, Gtk.PositionType.BOTTOM, null);
this.sliderTimer.add_mark(2, Gtk.PositionType.BOTTOM, null);
this.sliderTimer.add_mark(3, Gtk.PositionType.BOTTOM, null);
this.sliderTimer.add_mark(4, Gtk.PositionType.BOTTOM, null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a loop instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

longer timers
4 participants