Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 335962 - ScrollBar.getVisible() is wrong under gtk
Summary: ScrollBar.getVisible() is wrong under gtk
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.6.1   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 4.1   Edit
Assignee: Arun Thondapu CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-01 09:42 EST by Michael Seele CLA
Modified: 2011-11-14 10:49 EST (History)
1 user (show)

See Also:


Attachments
Solution-patch (627 bytes, text/plain)
2011-02-01 09:42 EST, Michael Seele CLA
no flags Details
Snippet that demonstrates the effect (4.57 KB, text/x-java)
2011-03-23 04:23 EDT, Michael Seele CLA
no flags Details
Screenshot of the snippet (47.38 KB, image/png)
2011-03-23 04:24 EDT, Michael Seele CLA
no flags Details
Proposed patch (936 bytes, patch)
2011-07-08 11:24 EDT, Arun Thondapu CLA
no flags Details | Diff
Revised patch (4.65 KB, patch)
2011-07-11 12:33 EDT, Arun Thondapu CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Seele CLA 2011-02-01 09:42:53 EST
Created attachment 188048 [details]
Solution-patch

When i use ScrollBar.getVisible() under gtk, it returns true even if the scroll bar is not visible. 
This happens cause getVisible() doesn't check if the scroll bar is visible, getVisible() check if the policy is not GTK_POLICY_NEVER.
The problem is that the policy can be GTK_POLICY_AUTOMATIC and the scroll bar can be hidden. In this reason, it returns true instead of false.

Please see my patch which solves the problem.
Comment 1 Bogdan Gheorghe CLA 2011-02-22 14:12:03 EST
Arun, please check this out.
Comment 2 Arun Thondapu CLA 2011-03-22 11:30:17 EDT
Michael,

Can you please provide me with a code snippet which helps me to reproduce the problem stated?
I see that getVisible() does return false when the ScrollBar visibility is set to false.
Besides, you should use isVisible() to confirm visibility rather than getVisible().
In fact, the javadoc for getVisible() itself states that the behavior you noticed is possible and so might not need to be fixed in my opinion. Please see the relevant javadoc excerpt below:

"If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, this method may still indicate that it is considered visible even though it may not actually be showing."

Thanks!

(In reply to comment #0)
> Created attachment 188048 [details]
> Solution-patch
> 
> When i use ScrollBar.getVisible() under gtk, it returns true even if the scroll
> bar is not visible. 
> This happens cause getVisible() doesn't check if the scroll bar is visible,
> getVisible() check if the policy is not GTK_POLICY_NEVER.
> The problem is that the policy can be GTK_POLICY_AUTOMATIC and the scroll bar
> can be hidden. In this reason, it returns true instead of false.
> 
> Please see my patch which solves the problem.
Comment 3 Michael Seele CLA 2011-03-23 04:23:51 EDT
Created attachment 191730 [details]
Snippet that demonstrates the effect
Comment 4 Michael Seele CLA 2011-03-23 04:24:12 EDT
Created attachment 191731 [details]
Screenshot of the snippet
Comment 5 Michael Seele CLA 2011-03-23 04:30:06 EDT
(In reply to comment #2)
> Michael,
> 
> Can you please provide me with a code snippet which helps me to reproduce the
> problem stated?

Please see the attached snippet and screenshot. 
For the first table getVisible for the horizontal scrollbar returns true despite the fact that it's clearly not visible.
Comment 6 Arun Thondapu CLA 2011-07-08 11:24:21 EDT
Created attachment 199345 [details]
Proposed patch

This patch incorporates the fix to ensure scrollbar's getVisible() method works correctly.
All JUnit tests passed successfully.
Please review. Thanks!
Comment 7 Arun Thondapu CLA 2011-07-11 12:33:40 EDT
Created attachment 199429 [details]
Revised patch

Revised the patch to replace deprecated API GTK_WIDGET_VISIBLE() with the suggested newer API gtk_widget_get_visible ().
Please review and suggest whether these changes are fine.

Thanks!
Comment 8 Bogdan Gheorghe CLA 2011-11-14 10:49:20 EST
Patch released.

Fixed in master > 20111114