derekstavis/transmission

Use Gtk.CSS to create a faux segmented progress bar for partial downloads

Opened this issue · 3 comments

I'm not sure how to do this other than with some gtk.css trickery. The way I would do it is:

  • Place two gtk.progressbars side by side in a .linked container. The second progressbar will always be empty since this represents the area we've chosen not to download.
  • This part I'm less sure about. Either way, no theme supports this yet that I know of. So you'll have to convince theme maintainers to adopt one of these solutions. Either you can use the :sensitive pseudo-class/property or create a new style class and add it to that first progress bar, or you can just rely on theme maintainers to use the :first-child pseudo class. Theme maintainers will need to "do the right thing" to give the trough here a special look in any case.

However, as long as the ".linked" style is respected for progress bars, themes that don't do anything special shouldn't even notice that anything has been done. So this should fall back rather gracefully.

Using a custom style sheet to force some kind of trough styling would work, but I would consider that super dirty and it will probably break the look and feel of every theme except the one you've chosen to imitate.

The two GtkProgressBars side by side approach would be my second bet, the first would be hacking into GtkProgressBar to allow multiple segments.

If that were possible in the gtk.progressbar API that would probably be nice. But that would be a rather long-term solution as you'd have to wait for the next version of Gtk before you could use it. While it's a little funky, using Gtk.CSS is something that you could ship immediately :)

(This thread is a top Google hit for "segmented gtk progress bar")
Generally speaking, multiple process-bars side-by-side seems like a very solid implementation, If I were doing it, I would probably extend gtk.Box with logic for variable number of progress bars and their width allocations if you want non-homogeneous bars. And then mock the Gtk.ProgressBar api in the extended class wither either discreet boxes: 3/5 boxes totally filed, 1 box showing current progress. or collective progress, 50% complete of three boxes would show one filled box, one half filled, and one empty.

Edit, Disclaimer, I don't understand the mechanism or premise of a css based solution to a segmented gkt progress bar.