Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 335962

Summary: ScrollBar.getVisible() is wrong under gtk
Product: [Eclipse Project] Platform Reporter: Michael Seele <mseele>
Component: SWTAssignee: Arun Thondapu <arunkumar.thondapu>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: gheorghe
Version: 3.6.1   
Target Milestone: 4.1   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Attachments:
Description Flags
Solution-patch
none
Snippet that demonstrates the effect
none
Screenshot of the snippet
none
Proposed patch
none
Revised patch none

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