Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 386953 - Omit use of GTK_RANGE_HAS_STEPPER_A,B,C,D for newer GTK+
Summary: Omit use of GTK_RANGE_HAS_STEPPER_A,B,C,D for newer GTK+
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.3 M2   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 340067
  Show dependency tree
 
Reported: 2012-08-09 13:24 EDT by Anatoly Spektor CLA
Modified: 2012-10-24 14:26 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anatoly Spektor CLA 2012-08-09 13:24:44 EDT
When compiling with GSEAL_ENABLE I am getting this errors:

os.c: In function ‘Java_org_eclipse_swt_internal_gtk_OS_GTK_1RANGE_1HAS_1STEPPER_1A’:
os.c:158:17: error: ‘GtkRange’ has no member named ‘has_stepper_a’
os.c: In function ‘Java_org_eclipse_swt_internal_gtk_OS_GTK_1RANGE_1HAS_1STEPPER_1B’:
os.c:170:17: error: ‘GtkRange’ has no member named ‘has_stepper_b’
os.c: In function ‘Java_org_eclipse_swt_internal_gtk_OS_GTK_1RANGE_1HAS_1STEPPER_1C’:
os.c:182:17: error: ‘GtkRange’ has no member named ‘has_stepper_c’
os.c: In function ‘Java_org_eclipse_swt_internal_gtk_OS_GTK_1RANGE_1HAS_1STEPPER_1D’:
os.c:194:17: error: ‘GtkRange’ has no member named ‘has_stepper_d’



These deprecated constants are used in : Scrollbar widget


Looking at GTK API I can assume that GtkRange's methods:

  gtk_range_get_lower_stepper_sensitivity 
  gtk_range_get_upper_stepper_sensitivity

could help replacing this constants. (not 100% sure) And if they will, how to get other 2 steppers ?
Comment 1 Anatoly Spektor CLA 2012-08-09 13:55:17 EDT
(In reply to comment #0)
> When compiling with GSEAL_ENABLE I am getting this errors:
> 
> os.c: In function
> ‘Java_org_eclipse_swt_internal_gtk_OS_GTK_1RANGE_1HAS_1STEPPER_1A’:
> os.c:158:17: error: ‘GtkRange’ has no member named ‘has_stepper_a’
> os.c: In function
> ‘Java_org_eclipse_swt_internal_gtk_OS_GTK_1RANGE_1HAS_1STEPPER_1B’:
> os.c:170:17: error: ‘GtkRange’ has no member named ‘has_stepper_b’
> os.c: In function
> ‘Java_org_eclipse_swt_internal_gtk_OS_GTK_1RANGE_1HAS_1STEPPER_1C’:
> os.c:182:17: error: ‘GtkRange’ has no member named ‘has_stepper_c’
> os.c: In function
> ‘Java_org_eclipse_swt_internal_gtk_OS_GTK_1RANGE_1HAS_1STEPPER_1D’:
> os.c:194:17: error: ‘GtkRange’ has no member named ‘has_stepper_d’
> 
> 
> 
> These deprecated constants are used in : Scrollbar widget
> 
> 
> Looking at GTK API I can assume that GtkRange's methods:
> 
>   gtk_range_get_lower_stepper_sensitivity 
>   gtk_range_get_upper_stepper_sensitivity
> 
> could help replacing this constants. (not 100% sure) And if they will, how
> to get other 2 steppers ?

Update:

The function that is suitable for this case is: gtk_range_get_range_rect ()

But I am still wondering how to test steppers, as all the snippets that are out there return false.
Comment 2 Anatoly Spektor CLA 2012-08-10 16:21:24 EDT
(In reply to comment #1)
> (In reply to comment #0)
> > When compiling with GSEAL_ENABLE I am getting this errors:
> > 
> > os.c: In function
> > ‘Java_org_eclipse_swt_internal_gtk_OS_GTK_1RANGE_1HAS_1STEPPER_1A’:
> > os.c:158:17: error: ‘GtkRange’ has no member named ‘has_stepper_a’
> > os.c: In function
> > ‘Java_org_eclipse_swt_internal_gtk_OS_GTK_1RANGE_1HAS_1STEPPER_1B’:
> > os.c:170:17: error: ‘GtkRange’ has no member named ‘has_stepper_b’
> > os.c: In function
> > ‘Java_org_eclipse_swt_internal_gtk_OS_GTK_1RANGE_1HAS_1STEPPER_1C’:
> > os.c:182:17: error: ‘GtkRange’ has no member named ‘has_stepper_c’
> > os.c: In function
> > ‘Java_org_eclipse_swt_internal_gtk_OS_GTK_1RANGE_1HAS_1STEPPER_1D’:
> > os.c:194:17: error: ‘GtkRange’ has no member named ‘has_stepper_d’
> > 
> > 
> > 
> > These deprecated constants are used in : Scrollbar widget
> > 
> > 
> > Looking at GTK API I can assume that GtkRange's methods:
> > 
> >   gtk_range_get_lower_stepper_sensitivity 
> >   gtk_range_get_upper_stepper_sensitivity
> > 
> > could help replacing this constants. (not 100% sure) And if they will, how
> > to get other 2 steppers ?
> 
> Update:
> 
> The function that is suitable for this case is: gtk_range_get_range_rect ()
> 
> But I am still wondering how to test steppers, as all the snippets that are
> out there return false.

Here is the patch that I would like to propose:

http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=gtk_has_stepper


Explanation behind it:

http://developer.gnome.org/gtk/2.24/GtkRange.html#gtk-range-get-range-rect

Documentation Says:

"This function returns the area that contains the range's trough and its steppers, in widget->window coordinates. "

So I thought if "range_rect" contains steppers in the coordinates, why not to check if coordinates of range_rect (width, height, x,y) are zero, if they are, most probably there are no steppers. Does it make sense ? 

If you disagree with this approach, I would love to hear any ideas on how this issue can be approached.

Regards,

Anatoly
Comment 3 Silenio Quarti CLA 2012-08-13 17:18:30 EDT
I did not check but it seems your patch would fail since the doc says it includes the area for the range trough's. If I understand correctly the width, height of the rectangle would never be zero (unless the scrollbar size is small).

Does it work if you check the value of these properties?

http://developer.gnome.org/gtk/stable/GtkScrollbar.html#GtkScrollbar--s-has-backward-stepper
http://developer.gnome.org/gtk/stable/GtkScrollbar.html#GtkScrollbar--s-has-forward-stepper
http://developer.gnome.org/gtk/stable/GtkScrollbar.html#GtkScrollbar--s-has-secondary-backward-stepper
http://developer.gnome.org/gtk/stable/GtkScrollbar.html#GtkScrollbar--s-has-secondary-forward-stepper
Comment 4 Silenio Quarti CLA 2012-08-13 17:24:24 EDT
I seems promising. Tried this and it returned good values:

	int[] hasA = new int[1];
	OS.gtk_widget_style_get (handle, "has-backward-stepper\0".getBytes(), hasA, 0);
	System.out.println("has back=" + hasA[0]);
	OS.gtk_widget_style_get (handle, "has-secondary-backward-stepper\0".getBytes(), hasA, 0);
	System.out.println("has secondary=" + hasA[0]);
Comment 5 Anatoly Spektor CLA 2012-08-15 16:04:46 EDT
(In reply to comment #4)
> I seems promising. Tried this and it returned good values:
> 
> 	int[] hasA = new int[1];
> 	OS.gtk_widget_style_get (handle, "has-backward-stepper\0".getBytes(), hasA,
> 0);
> 	System.out.println("has back=" + hasA[0]);
> 	OS.gtk_widget_style_get (handle,
> "has-secondary-backward-stepper\0".getBytes(), hasA, 0);
> 	System.out.println("has secondary=" + hasA[0]);

Good call, I made series of tests and it returns correct values. As I was playing with the code I incorporated example you posted, I hope you don't mind!

If you would like to use patch I made basing on sample you gave, please go ahead:

http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=gtk_has_stepper
Comment 6 Silenio Quarti CLA 2012-08-16 10:15:29 EDT
- What version those style properties where added? If they have been there long enough, you can remove GTK_RANGE_HAS_STEPPER_A,B,C,D, otherwise you have to add a version check and run the old code (no need for helpers, since it is used only once).

- Need to create the string constants in OS. Take a look at OS.gtk_double_click_time for an example.
Comment 7 Anatoly Spektor CLA 2012-08-16 10:53:24 EDT
(In reply to comment #6)
> - What version those style properties where added? If they have been there
> long enough, you can remove GTK_RANGE_HAS_STEPPER_A,B,C,D, otherwise you
> have to add a version check and run the old code (no need for helpers, since
> it is used only once).
> 
> - Need to create the string constants in OS. Take a look at
> OS.gtk_double_click_time for an example.

What I did:

1. As you have pointed out  gtk_widget_get_style is "old" enough to replace GTK_RANGE_HAS_STEPPER, thus I've removed GTK_RANGE_HAS_STEPPER functions

2. I have added constants for every stepper property and put in gtk_widget_get_style

3. I have amended my previous commit, and the new version is available here:

 http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=gtk_has_stepper

 Is there anything else I am missing ?

 Thank you for your time,

 Anatoly