Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 386401 - Use gtk_widget_get_allocation in newer GTK+
Summary: Use gtk_widget_get_allocation in 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: Arun Thondapu CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 340067
  Show dependency tree
 
Reported: 2012-08-01 11:29 EDT by Anatoly Spektor CLA
Modified: 2012-10-24 14:26 EDT (History)
2 users (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-01 11:29:54 EDT
This patch uses gtk_widget_get_allocation instead of GTK_WIDGET_WIDTH GTK_WIDGET_HEIGH GTK_WIDGET_X and GTK_WIDGET_Y, thus avoiding compilation warnings when G_SEAL_ENABLE flag is defined:


http://fedorapeople.org/gitweb?p=aspektor/public_git/eclipse.platform.swt.git;a=commit;h=e2eec58f5a7bca2908e0116758c3fe8312d273e1
Comment 1 Anatoly Spektor CLA 2012-08-02 13:37:39 EDT
(In reply to comment #0)
> This patch uses gtk_widget_get_allocation instead of GTK_WIDGET_WIDTH
> GTK_WIDGET_HEIGH GTK_WIDGET_X and GTK_WIDGET_Y, thus avoiding compilation
> warnings when G_SEAL_ENABLE flag is defined:
> 
> 
> http://fedorapeople.org/gitweb?p=aspektor/public_git/eclipse.platform.swt.
> git;a=commit;h=e2eec58f5a7bca2908e0116758c3fe8312d273e1

Unfortunately, yesterday fedorapeople stopped supporting "gitweb", so  some links are not active anymore.

The patch is available from here:

http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=gtk_widget_get_allocation__
Comment 3 Silenio Quarti CLA 2012-08-03 17:17:03 EDT
The change in Combo.java seems unrelated to the patch. Is it necessary?
Comment 4 Silenio Quarti CLA 2012-08-03 17:32:07 EDT
Should we add a helper for gtk_widget_get_allocation(). One reason not to do it is that we could avoid the creation of the GtkAllocation object for the <2.18 code path, but most of the code in master is not taking advantage of that anyways.  Another reason is that sometimes we only need the width so we would be getting x,y,height for nothing in the old code path (it probably does not matter).

The big advantage of the helper is that it makes the code cleaner.
Comment 5 Anatoly Spektor CLA 2012-08-07 10:54:49 EDT
Regarding code in Combo:

 No it's not necessary and probably I shouldn't put it, as it is better to use GtkRequisition object instead of constants which are mostly deprecated, so when you have time, please revert this change, or I can release  patch myself that reverts these changes if you like.

Sorry for this confusion.

Anatoly
Comment 6 Arun Thondapu CLA 2012-08-07 14:14:46 EDT
(In reply to comment #5)
> Regarding code in Combo:
> 
> so when you have time, please revert this change, or I can release  patch

Reverted the changes in Combo.java - http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=58b1e1bc94f63d5d1638e502924a79642df3a55a
Comment 7 Silenio Quarti CLA 2012-08-08 09:25:39 EDT
(In reply to comment #5)
> Regarding code in Combo:
> 
>  No it's not necessary and probably I shouldn't put it, as it is better to
> use GtkRequisition object instead of constants which are mostly deprecated,
> so when you have time, please revert this change, or I can release  patch
> myself that reverts these changes if you like.
> 
> Sorry for this confusion.
> 
> Anatoly

Take a look at this comment to see why we reach in to get the requisition of the widget:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=374754#add_comment
Comment 8 Anatoly Spektor CLA 2012-08-13 13:44:40 EDT
Bug in Sash widget caused by previous patch:

 If you run ControlExample, Sash won't work, because one case of gtk_widget_allocation is missed.

 Please apply this patch to solve the bug:

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


 Sorry for the confusion.
Comment 10 Silenio Quarti CLA 2012-08-27 15:54:04 EDT
Added helper. 

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=9effcc166dfa61e54b0f9bb76b17f1175f53b69b

With this helper it is easy to check whether we are still calling the GTK_WIDGET_X,Y,W,H and I found places were the original patch was wrong:

1) Composite.moveChildren() - call to gtk_widget_get_allocation() to get width,height overwrites the x,y value set just before the if (end of the method)

2) Buton.setBounds() - gtk_widget_get_allocation() called more then needed

3) ToolItem.resizeHandle() - still used GTK_WIDGET_X/GTK_WIDGET_Y

4) Control.setBounds() - gtk_widget_get_allocation() called more then needed