Add a counter to a toolbar button, like nMatrix?

Talk about code development, features, specific bugzilla bugs, enhancements, patches, and other highly technical things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific referenced Bugzilla bugs, mercurial, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Most "bug reports" do not belong in this board and should initially be posted in Community Support or other relevant support boards.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
Post Reply
User avatar
moonbat
Board Warrior
Board Warrior
Posts: 1616
Joined: 2015-12-09, 15:45

Add a counter to a toolbar button, like nMatrix?

Post by moonbat » 2020-04-19, 09:30

I'm revamping Pure URL, converting it from Jetpack to a regular overlay extension, and trying to add a few visual improvements (helps me learn more about extension development as well). Currently it has a toolbar button that launches an options dialog (with an easier to use list of garbage fields to add/remove).How do I display a mini counter on top of the toolbar icon for links processed, similar to nMatrix or uBlock Origin?
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Linux Mint 20 Xfce x64 on HP i5 laptop with 12 GB RAM, always latest versions of PM & Basilisk unless specified.

vannilla
Board Warrior
Board Warrior
Posts: 1005
Joined: 2018-05-05, 13:29

Re: Add a counter to a toolbar button, like nMatrix?

Post by vannilla » 2020-04-19, 10:27

It's probably a good starting point to read the source code of the extensions you listed.

User avatar
moonbat
Board Warrior
Board Warrior
Posts: 1616
Joined: 2015-12-09, 15:45

Re: Add a counter to a toolbar button, like nMatrix?

Post by moonbat » 2020-04-19, 10:36

Does it make a difference if they're addon/jetpack vs the regular overlay extension I'm working on?
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Linux Mint 20 Xfce x64 on HP i5 laptop with 12 GB RAM, always latest versions of PM & Basilisk unless specified.

vannilla
Board Warrior
Board Warrior
Posts: 1005
Joined: 2018-05-05, 13:29

Re: Add a counter to a toolbar button, like nMatrix?

Post by vannilla » 2020-04-19, 13:57

moonbat wrote:
2020-04-19, 10:36
Does it make a difference if they're addon/jetpack vs the regular overlay extension I'm working on?
I don't think so, no.
Just make sure you call the code only if the toolbar button is actually on a toolbar.

User avatar
moonbat
Board Warrior
Board Warrior
Posts: 1616
Joined: 2015-12-09, 15:45

Re: Add a counter to a toolbar button, like nMatrix?

Post by moonbat » 2020-04-19, 14:10

Can't make head or tail of the code in uBO - there is no XUL to define the toolbar icon since it is a bootstrap/jetpack extension. I searched the code for words like 'icon' but no luck, it is almost entirely only related with processing pages (as expected).
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Linux Mint 20 Xfce x64 on HP i5 laptop with 12 GB RAM, always latest versions of PM & Basilisk unless specified.

User avatar
adesh
Board Warrior
Board Warrior
Posts: 1055
Joined: 2017-06-06, 07:38

Re: Add a counter to a toolbar button, like nMatrix?

Post by adesh » 2020-04-19, 14:23

Look for "badge" in uMatrix codebase.

https://github.com/gorhill/uMatrix/comm ... e64a921f6e

User avatar
moonbat
Board Warrior
Board Warrior
Posts: 1616
Joined: 2015-12-09, 15:45

Re: Add a counter to a toolbar button, like nMatrix?

Post by moonbat » 2020-04-19, 14:44

Interesting, he's using CSS to superimpose a badge. Good point to start looking, thanks :thumbup:
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Linux Mint 20 Xfce x64 on HP i5 laptop with 12 GB RAM, always latest versions of PM & Basilisk unless specified.

Post Reply