Solving "Download bar can get wider than Midori window"

Bug #851452 reported by Walther
40
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Midori Web Browser
Fix Released
Undecided
Walther

Bug Description

This has been reported in different parts before, as launchpad bug #719033 and #715079, for example. However, I've delved into this issue for the past several hours to understand what is happening.

In a way, I think the problem is using a toolbar to store the downloadbar. I don't think toolbars were designed to dynamically grow beyond the size of the window. And Midori will not use the "Arrow" style to enable extra entries to appear there (in fact, downloads don't appear there if I try using that).

To keep the download bar as a single line in the status-bar, then there are two choices:
- Shrink the individual download buttons as much as needed to make them all fit.
- Remove old downloads when adding a new one makes the downloadbar be larger than the containing window.

I tried approach number one, but it turns out the download files will not let themselves be shrunk because GtkProgressBars have this style property:

The "min-horizontal-bar-width" style property
The minimum horizontal width of the progress bar.
Allowed values: >= 1
Default value: 150
Since 2.14

That default causes the download items to not shrink further (in fact, the call to gtk_widget_set_size_request() in midori-transferbar.c is pointless because it isn't larger than 150 for most situations). You could technically change this, but it isn't that easy, look here for more information: http://www.gtkforums.com/viewtopic.php?t=5862

"Use gtk_widget_class_install_style_property() to install style properties for a widget class, gtk_widget_class_find_style_property() or gtk_widget_class_list_style_properties() to get information about existing style properties and gtk_widget_style_get_property(), gtk_widget_style_get() or gtk_widget_style_get_valist() to obtain the value of a style property."

Documentation seems sparse on how to properly use these functions, so I gave up on that front. Maybe somebody else will want to look at it.

Instead, I decided to tackle approach number two. After adding a new download, a function is called to compare the requested size of the downloadBar versus the window's width. If the downloadBar does not fits, then the last completed download is removed. I added a configuration switch that allows users to choose that ALL completed downloads should be removed, not just the last one.

There is one drawback to this implementation, it does not allows disabling the new setting. I am not sure how we can implement tri-state switches. Maybe the real solution is to ALSO implement part 1, and set a more reasonably minimum width for progress bars.

I am open to suggestions on what could be done with this patch. I do think that a feature to "auto remove cleared downloads when the bar is full" would be welcomed amongst more than a few users, on the very least.

Revision history for this message
Walther (walther-md) wrote :
Cris Dywan (kalikiana)
tags: added: downloads
Revision history for this message
Cris Dywan (kalikiana) wrote :

Walther, the solution works fine for me. I don't think the preference is very useful to be honest, if you don't want to see downloads you may as well hide the transferbar to the same effect. The attached patch omits the preference.

Please tell me a full name and email address so I can credit you properly in the commit (if you prefer via PM).

Changed in midori:
status: New → In Progress
assignee: nobody → Walther (walther-md)
Revision history for this message
Walther (walther-md) wrote :

Hey, what is this patch that says "if (!FALSE) break;" ? :P If you don't want a preference, and you'd rather hardcode "always clean the download bar when full" then you may as well remove useless statements from the patch. I attach a "cleaner" version and I'll PM you the details in a second.

Revision history for this message
Cris Dywan (kalikiana) wrote :

You're completely right, what you saw there was the equivalent of a half-executed train of thought. Thanks for cleaning it up. I pushed the commit.

Changed in midori:
status: In Progress → Fix Committed
Cris Dywan (kalikiana)
Changed in midori:
status: Fix Committed → Fix Released
Revision history for this message
v_2e (v-2e) wrote :

Unfortunately, Midori still fails to handle the overloaded downloads bar correctly when there are incomplete (or stuck) downloads.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.