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

Bug 389910

Summary: Substitute GdkColor with GdkRGBA
Product: [Eclipse Project] Platform Reporter: Anatoly Spektor <spektor.anatoly>
Component: SWTAssignee: Silenio Quarti <Silenio_Quarti>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Silenio_Quarti
Version: 4.2   
Target Milestone: 4.3 M4   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on:    
Bug Blocks: 340067    

Description Anatoly Spektor CLA 2012-09-19 11:52:44 EDT
GTK+ 3 uses GdkRGBA instead of GdkColor.

GdkColor is widely used through SWT, some classes have number of getter/setter functions that return GdkColor.

What is the expected procedure to substitute GdkColor with GdkRGBA? Should GdkRGBA has its own getter/setter methods ? If yes what is the naming policy of this methods, should this getter/setters be flagged that they are for Gtk+ 3 only ?

As an example of use of GdkColor here are methods from Control.java:

GdkColor getForegroundColor () {
	return getFgColor ();
}

GdkColor getFgColor () {
	int /*long*/ fontHandle = fontHandle ();
	OS.gtk_widget_realize (fontHandle);
	GdkColor color = new GdkColor ();
	OS.gtk_style_get_fg (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color);
	return color;
}

....etc

Implementation of GdkRGBA is needed because it is used by GtkStyleContext that replaces GtkStyle in Gtk3.Without GdkRGBA we cannot substitute this GtkStyle methods:

gtk_style_get_bg_gc
gtk_style_get_black_gc
gtk_style_get_dark_gc
gtk_style_get_fg_gc
gtk_style_get_light_gc
gtk_style_get_mid_gc
gtk_style_get_text_aa_gc
gtk_style_get_text_gc
gtk_style_get_white_gc
gtk_style_render_icon
Comment 1 Silenio Quarti CLA 2012-11-02 10:33:31 EDT
For now, we need to keep our color handle as a GdkColor so that we can run on GTK2, but we have to convert a GdkColor to GdkRGBA and use the new GtkStyleContext API to change colors and fonts on widgets.

This is fixed in the branch below. I will push to master when M3 is done.

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/log/?h=silenio/Bug389910
Comment 2 Silenio Quarti CLA 2012-11-02 16:27:48 EDT
Pushed to master.