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 Opacity Slider extension #676

Merged
merged 2 commits into from
Jul 21, 2024
Merged

Conversation

NeatNit
Copy link
Contributor

@NeatNit NeatNit commented Jul 20, 2024

Add new extension: Opacity Slider. I should have done this a year ago, it was ready then. (https://github.com/NeatNit/cinnamon-opacity-slider)

screenshot

To do before merge:

  • clean up code, comments
  • add icon (wish I didn't have to)
  • add readme
  • test on latest Cinnamon (can someone do this for me? I'm not keen on messing with this on my only working device)
  • make sure the file structure is all there
  • (optional?) figure out how translations work

Hope this will be accepted! I had to basically hijack the menu building function in order to add my custom entry. Perhaps in future versions of Cinnamon there should be a proper way of adding menu items.

All feedback welcome.

@rcalixte
Copy link
Member

  • test on latest Cinnamon (can someone do this for me? I'm not keen on messing with this on my only working device)

Are you able to setup a virtual machine or use a live USB ISO? Both are common strategies for testing changes without affecting your current system.

  • (optional?) figure out how translations work

There is a script in the root of the repository to assist with that (cinnamon-spices-makepot), along with the README, assuming you add the gettext portions in the code for the strings you want to be extracted. (The metadata and settings are automatically parsed.) Take a look at other extensions for an example. You need to cleanup the UUID portion to match the name of the Spice as well. For simplicity, you can use your GitHub username instead of what appears to be an invalid web domain. For faster validation, you can run it locally before pushing to GitHub:

$ ./validate-spice [email protected] (or opacity-slider@neatnit)

Feel free to reach out if you need anything explained further.

@rcalixte rcalixte marked this pull request as draft July 20, 2024 17:51
@NeatNit
Copy link
Contributor Author

NeatNit commented Jul 20, 2024

Thanks for marking as draft, I couldn't find the option.

Are you able to setup a virtual machine or use a live USB ISO? Both are common strategies for testing changes without affecting your current system.

Unfortunately no, I have pretty much no free space right now.

I should clarify, I'm running the latest stable Mint, but I know a new release is coming up soon and that's the one I can't test.

The domain is mine, it's just not used for anything at the moment. If it's really not okay to use it in this state, I'll change it.

@rcalixte
Copy link
Member

I should clarify, I'm running the latest stable Mint, but I know a new release is coming up soon and that's the one I can't test.

There are no major breaking changes in Cinnamon so I would expect this to continue working. If anything does come up, we can address it when the time comes.

If it's really not okay to use it in this state, I'll change it.

The current convention is to have the UUID be descriptive-name@github-username.

@NeatNit
Copy link
Contributor Author

NeatNit commented Jul 20, 2024

Alright, I think it's done besides translations.

There is a script in the root of the repository to assist with that (cinnamon-spices-makepot), along with the README, assuming you add the gettext portions in the code for the strings you want to be extracted. (The metadata and settings are automatically parsed.) Take a look at other extensions for an example.

Right, I think I figured this out as I was writing this, but it was a bit confusing. I hope I got it right. There's one string that needs to be translated in the code:

function updateLabel(opacity) {
label.setLabel(_("Opacity") + ": " + Math.floor(100*opacity/255).toString() + "%")
}

Is it correct to use _("Opacity") to get a translated string? I don't remember where I got this from, it was over a year ago. Probably from https://github.com/linuxmint/cinnamon/blob/master/js/ui/windowMenu.js which I referenced a lot.

cinnamon-spices-makepot seems to have figured it out so it's probably good.

PS. what threw me off is that apparently my metadata.json was missing a version, and makepot refused to run because of that. Shouldn't the validate-spice script catch this kind of thing?

@NeatNit NeatNit marked this pull request as ready for review July 20, 2024 22:08
@rcalixte
Copy link
Member

Is it correct to use _("Opacity") to get a translated string?

You still need to define the function and import the gettext library. The string was parsed correct by the script but it is still not operational for users with other localizations configured on the setups.

PS. what threw me off is that apparently my metadata.json was missing a version, and makepot refused to run because of that. Shouldn't the validate-spice script catch this kind of thing?

It's technically an optional parameter so it should be crashing. The script was updated recently so this might be an oversight. I can take a look at that separately.

@NeatNit
Copy link
Contributor Author

NeatNit commented Jul 20, 2024

You still need to define the function and import the gettext library. The string was parsed correct by the script but it is still not operational for users with other localizations configured on the setups.

Can you give me a specific extension example to copy? I'm not familiar with the whole thing, it's a bit confusing.

@NeatNit
Copy link
Contributor Author

NeatNit commented Jul 21, 2024

Okay, I'm pretty sure I did it right this time. I tested with a stupid en translation and it worked.

@rcalixte rcalixte merged commit cb9f367 into linuxmint:master Jul 21, 2024
1 check passed
@rcalixte
Copy link
Member

Okay, I'm pretty sure I did it right this time.

Congrats on getting this done!

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.

2 participants