After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 636695 - GdkColor should be deprecated
GdkColor should be deprecated
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: X11
3.2.x
Other All
: Normal normal
: 3.4
Assigned To: gtk-bugs
gtk-bugs
deprecations
Depends on: 636697 648989
Blocks:
 
 
Reported: 2010-12-07 12:28 UTC by Murray Cumming
Modified: 2014-05-22 13:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
docs/tools/widgets.c: Use GdkRGBA instead GdkColor (1.53 KB, patch)
2011-04-30 01:02 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
docs/reference/gtk/text_widget.sgml: Use GdkRGBA instead GdkColor (2.04 KB, patch)
2011-04-30 01:04 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
gtk/gtktrayicon-x11.c: Use GdkRGBA instead GdkColor (6.48 KB, patch)
2011-05-02 15:23 UTC, Javier Jardón (IRC: jjardon)
none Details | Review
gtk/gtktrayicon-x11.c: Use GdkRGBA instead GdkColor (7.85 KB, patch)
2011-05-02 15:30 UTC, Javier Jardón (IRC: jjardon)
needs-work Details | Review
gdk/x11/gdkcursor-x11.c: Use GdkRGBA instead GdkColor (2.04 KB, patch)
2011-05-02 16:48 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
gtk/gtktrayicon-x11.c: Use GdkRGBA instead GdkColor.v2 (8.03 KB, patch)
2011-05-04 17:12 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
gail: use GdkRGBA (4.23 KB, patch)
2011-06-06 16:05 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
tests: Use GdkRGBA (3.83 KB, patch)
2011-06-06 16:05 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
gdkcreen-x11: Use GdkRGBA instead GdkColor (1.40 KB, patch)
2011-06-13 00:57 UTC, Javier Jardón (IRC: jjardon)
none Details | Review
gdkcreen-x11: Use GdkRGBA instead GdkColor.v2 (1.40 KB, patch)
2011-06-13 01:01 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
gtkcellview (1.23 KB, patch)
2011-12-19 14:04 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
gtktrayicon-x11 (948 bytes, patch)
2011-12-19 14:04 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
testgtk (1.62 KB, patch)
2011-12-19 14:05 UTC, Javier Jardón (IRC: jjardon)
rejected Details | Review
testcombo (1.35 KB, patch)
2011-12-19 14:12 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
Deprecate public API that is using GdkColor (14.07 KB, patch)
2011-12-19 14:23 UTC, Javier Jardón (IRC: jjardon)
reviewed Details | Review
Deprecate public API that is using GdkColor.v2 (21.08 KB, patch)
2011-12-20 18:33 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
gtksettings: Do not use GdkColor API (3.84 KB, patch)
2012-01-04 15:05 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
gtkcolorsel: Do not use GdkColor API (1.47 KB, patch)
2012-01-04 15:06 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
Deprecate GdkColor (3.06 KB, patch)
2012-01-04 15:07 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
Move GdkColor to deprecated directory (21.46 KB, patch)
2012-01-04 15:07 UTC, Javier Jardón (IRC: jjardon)
needs-work Details | Review

Description Murray Cumming 2010-12-07 12:28:14 UTC
GdkRGBA apparently replaces GdkColor, and there are replacement functions that use GdkRGBA instead of GdkColor. So shouldn't we deprecate GdkColor and any API that uses it?
Comment 1 Carlos Garnacho 2010-12-07 12:40:35 UTC
There are still widget style properties using GDK_TYPE_COLOR, I'm sure many of them can be deprecated as well in favor of CSS color handling (for example treeview even/odd colors), but mostly need a one by one check as widgets switch to GtkStyleContext
Comment 2 Murray Cumming 2011-01-07 13:33:14 UTC
Is this likely to happen before 3.0? It would really clean the API up.
Comment 3 Benjamin Otte (Company) 2011-01-07 15:38:16 UTC
I think the current consensus is that removing it will cause lots of stuff to no longer compile as there's too many people still using GdkColor and it would likely need weeks to get jhbuild compiling again.
So we'll probably aim at deprecating it for 3.2 or so.
Comment 4 Murray Cumming 2011-01-07 16:15:50 UTC
Well, it still seems wise to avoid its use internally and to ensure that their are GdkRGBA versions of any API that uses GdkColor.
Comment 5 Benjamin Otte (Company) 2011-01-07 16:53:04 UTC
I think we've got this covered pretty much?
I didn't check it, but what I heard from IRC was that everything but GtkTextView is done by now.
Comment 6 Javier Jardón (IRC: jjardon) 2011-04-30 01:02:29 UTC
Created attachment 186917 [details] [review]
docs/tools/widgets.c: Use GdkRGBA instead GdkColor
Comment 7 Javier Jardón (IRC: jjardon) 2011-04-30 01:04:34 UTC
Created attachment 186918 [details] [review]
docs/reference/gtk/text_widget.sgml: Use GdkRGBA instead GdkColor
Comment 8 Matthias Clasen 2011-05-01 00:52:37 UTC
Review of attachment 186917 [details] [review]:

Looks fine
Comment 9 Matthias Clasen 2011-05-01 00:53:06 UTC
Review of attachment 186918 [details] [review]:

Looks fine, too
Comment 10 Javier Jardón (IRC: jjardon) 2011-05-02 13:11:25 UTC
Comment on attachment 186917 [details] [review]
docs/tools/widgets.c: Use GdkRGBA instead GdkColor

commit e73c0d9800ca499994070cb9129f5ee868949348
Comment 11 Javier Jardón (IRC: jjardon) 2011-05-02 13:12:03 UTC
Comment on attachment 186918 [details] [review]
docs/reference/gtk/text_widget.sgml: Use GdkRGBA instead GdkColor

commit 8e1fdaebe78d701853fafe58f03310c520f0eb36
Comment 12 Javier Jardón (IRC: jjardon) 2011-05-02 15:23:55 UTC
Created attachment 187041 [details] [review]
gtk/gtktrayicon-x11.c: Use GdkRGBA instead GdkColor
Comment 13 Javier Jardón (IRC: jjardon) 2011-05-02 15:30:40 UTC
Created attachment 187042 [details] [review]
gtk/gtktrayicon-x11.c: Use GdkRGBA instead GdkColor
Comment 14 Javier Jardón (IRC: jjardon) 2011-05-02 16:48:11 UTC
Created attachment 187052 [details] [review]
gdk/x11/gdkcursor-x11.c: Use GdkRGBA instead GdkColor
Comment 15 Matthias Clasen 2011-05-04 12:40:32 UTC
Review of attachment 187042 [details] [review]:

::: gtk/gtktrayicon-x11.c
@@ +206,3 @@
+  icon->priv->success_color.red   = 0.3047;
+  icon->priv->success_color.green = 0.6016;
+  icon->priv->success_color.blue  = 0.0234;

You probably want to initialize the alpha too, here

@@ +559,3 @@
+      color.red = prop.prop[0] / 65535;
+      color.green = prop.prop[1] / 65535;
+      color.blue = prop.prop[2] / 65535;

Not sure this works correctly wrt to type propagation, as both prop[0] and 65535 are integer types.
Better to use 65535.0.
Comment 16 Matthias Clasen 2011-05-04 12:40:34 UTC
Review of attachment 187042 [details] [review]:

::: gtk/gtktrayicon-x11.c
@@ +206,3 @@
+  icon->priv->success_color.red   = 0.3047;
+  icon->priv->success_color.green = 0.6016;
+  icon->priv->success_color.blue  = 0.0234;

You probably want to initialize the alpha too, here

@@ +559,3 @@
+      color.red = prop.prop[0] / 65535;
+      color.green = prop.prop[1] / 65535;
+      color.blue = prop.prop[2] / 65535;

Not sure this works correctly wrt to type propagation, as both prop[0] and 65535 are integer types.
Better to use 65535.0.
Comment 17 Matthias Clasen 2011-05-04 12:40:34 UTC
Review of attachment 187042 [details] [review]:

::: gtk/gtktrayicon-x11.c
@@ +206,3 @@
+  icon->priv->success_color.red   = 0.3047;
+  icon->priv->success_color.green = 0.6016;
+  icon->priv->success_color.blue  = 0.0234;

You probably want to initialize the alpha too, here

@@ +559,3 @@
+      color.red = prop.prop[0] / 65535;
+      color.green = prop.prop[1] / 65535;
+      color.blue = prop.prop[2] / 65535;

Not sure this works correctly wrt to type propagation, as both prop[0] and 65535 are integer types.
Better to use 65535.0.
Comment 18 Matthias Clasen 2011-05-04 12:46:37 UTC
Review of attachment 187052 [details] [review]:

Looks fine
Comment 19 Javier Jardón (IRC: jjardon) 2011-05-04 16:59:43 UTC
Comment on attachment 187052 [details] [review]
gdk/x11/gdkcursor-x11.c: Use GdkRGBA instead GdkColor

commit 1fcfa91ee3289a321647f259c4efa62f52
Comment 20 Javier Jardón (IRC: jjardon) 2011-05-04 17:12:34 UTC
Created attachment 187220 [details] [review]
gtk/gtktrayicon-x11.c: Use GdkRGBA instead GdkColor.v2

Updated patch with your comments
Comment 21 Matthias Clasen 2011-05-05 11:07:15 UTC
Review of attachment 187220 [details] [review]:

Looks ok now
Comment 22 Javier Jardón (IRC: jjardon) 2011-05-05 11:48:50 UTC
Comment on attachment 187220 [details] [review]
gtk/gtktrayicon-x11.c: Use GdkRGBA instead GdkColor.v2

commit 2f3e1fa3e43eb751e7d730d48d6a2787868cc8f4
Comment 23 Javier Jardón (IRC: jjardon) 2011-06-06 16:05:00 UTC
Created attachment 189336 [details] [review]
gail: use GdkRGBA
Comment 24 Javier Jardón (IRC: jjardon) 2011-06-06 16:05:40 UTC
Created attachment 189337 [details] [review]
tests: Use GdkRGBA
Comment 25 Matthias Clasen 2011-06-06 18:24:42 UTC
Review of attachment 189336 [details] [review]:

This is all just really annoying conversion...
but the patch looks fine.
Comment 26 Matthias Clasen 2011-06-06 18:31:42 UTC
Review of attachment 189337 [details] [review]:

Looks ok, assuming you've tested it
Comment 27 Javier Jardón (IRC: jjardon) 2011-06-07 16:44:12 UTC
Comment on attachment 189336 [details] [review]
gail: use GdkRGBA

commit 02285b232ccc18fe6db745346046c9690fb382eb
Comment 28 Javier Jardón (IRC: jjardon) 2011-06-12 23:25:25 UTC
Comment on attachment 189337 [details] [review]
tests: Use GdkRGBA

commit 85747da97238dc101f92cd8241aa7aea44f35789
Comment 29 Javier Jardón (IRC: jjardon) 2011-06-13 00:57:05 UTC
Created attachment 189791 [details] [review]
gdkcreen-x11: Use GdkRGBA instead GdkColor
Comment 30 Javier Jardón (IRC: jjardon) 2011-06-13 01:01:09 UTC
Created attachment 189792 [details] [review]
gdkcreen-x11: Use GdkRGBA instead GdkColor.v2

There was a typo in the previuos patch
Comment 31 Matthias Clasen 2011-06-13 01:54:38 UTC
Review of attachment 189792 [details] [review]:

Same as before: looks fine if you tested it.
Comment 32 Javier Jardón (IRC: jjardon) 2011-10-01 19:46:56 UTC
Comment on attachment 189792 [details] [review]
gdkcreen-x11: Use GdkRGBA instead GdkColor.v2

commit 522c305c12c28d68b636ca8e601de22e260cb9dc
Comment 33 Javier Jardón (IRC: jjardon) 2011-12-19 14:04:30 UTC
Created attachment 203872 [details] [review]
gtkcellview
Comment 34 Javier Jardón (IRC: jjardon) 2011-12-19 14:04:53 UTC
Created attachment 203873 [details] [review]
gtktrayicon-x11
Comment 35 Javier Jardón (IRC: jjardon) 2011-12-19 14:05:28 UTC
Created attachment 203874 [details] [review]
testgtk
Comment 36 Javier Jardón (IRC: jjardon) 2011-12-19 14:12:30 UTC
Created attachment 203875 [details] [review]
testcombo
Comment 37 Javier Jardón (IRC: jjardon) 2011-12-19 14:23:03 UTC
Created attachment 203877 [details] [review]
Deprecate public API that is using GdkColor
Comment 38 Matthias Clasen 2011-12-20 14:44:22 UTC
Review of attachment 203872 [details] [review]:

::: gtk/gtkcellview.c
@@ +450,3 @@
 	  g_warning ("Don't know color `%s'", g_value_get_string (value));
+
+	g_object_notify (object, "background-rgba");

You should probably notify both background-rgba and background-gdk here ?
Comment 39 Matthias Clasen 2011-12-20 14:45:27 UTC
Review of attachment 203873 [details] [review]:

::: gtk/gtktrayicon-x11.c
@@ +962,3 @@
     {
       /* Set a transparent background */
+      GdkRGBA transparent = { 0.0, 0.0, 0.0, 0.0 }; /* Only pixel=0 matters */

The comment is misleading now and should be removed.
There is no pixel in gdkrgba.
Comment 40 Matthias Clasen 2011-12-20 14:46:26 UTC
Review of attachment 203874 [details] [review]:

::: tests/testgtk.c
@@ +4822,3 @@
 
+  gtk_color_selection_get_current_rgba (GTK_COLOR_SELECTION (colorsel), &rgba);
+  gtk_color_selection_set_current_rgba (GTK_COLOR_SELECTION (colorsel), &rgba);

I wonder - what is the point of this code ?!
Comment 41 Matthias Clasen 2011-12-20 14:47:20 UTC
Review of attachment 203875 [details] [review]:

::: tests/testcombo.c
@@ +1290,1 @@
         color.green = 0;

This leaves color.alpha uninitialized.
Comment 42 Matthias Clasen 2011-12-20 14:49:25 UTC
Review of attachment 203877 [details] [review]:

You need to add

Deprecated:3.4: Use ... instead

notes to all the doc comments as well - gtk-doc does not know how to pick up the deprecation annotations (and it wouldn't pick up the version number there anyway).
Comment 43 Javier Jardón (IRC: jjardon) 2011-12-20 18:11:58 UTC
Comment on attachment 203874 [details] [review]
testgtk

Reject patch as Its deatch code
Comment 44 Javier Jardón (IRC: jjardon) 2011-12-20 18:30:46 UTC
Comment on attachment 203872 [details] [review]
gtkcellview

commited with your comments: 0d6af75bfe2ca794153f9523158acbc90bcebbe6
Comment 45 Javier Jardón (IRC: jjardon) 2011-12-20 18:31:15 UTC
Comment on attachment 203873 [details] [review]
gtktrayicon-x11

committed with your comments: e053590ae579463820159301f6934083dbf5ce8b
Comment 46 Javier Jardón (IRC: jjardon) 2011-12-20 18:31:58 UTC
Comment on attachment 203875 [details] [review]
testcombo

committed with your comments: 14112534d64b8f05a5eb3321093c3da7a9070113
Comment 47 Javier Jardón (IRC: jjardon) 2011-12-20 18:33:35 UTC
Created attachment 203976 [details] [review]
Deprecate public API that is using GdkColor.v2
Comment 48 Matthias Clasen 2011-12-22 00:20:19 UTC
Review of attachment 203976 [details] [review]:

Looks good now.
Comment 49 Javier Jardón (IRC: jjardon) 2011-12-22 03:34:24 UTC
Comment on attachment 203976 [details] [review]
Deprecate public API that is using GdkColor.v2

commit a3abc188585156e4a6ba309e26c6d123cfe4f39d
Comment 50 Benjamin Otte (Company) 2011-12-22 12:12:59 UTC
There's a bunch of deprecation warnings when compiling GTK now. Those need to be fixed still.
Comment 51 Javier Jardón (IRC: jjardon) 2012-01-04 15:05:31 UTC
Created attachment 204578 [details] [review]
gtksettings: Do not use GdkColor API
Comment 52 Javier Jardón (IRC: jjardon) 2012-01-04 15:06:02 UTC
Created attachment 204579 [details] [review]
gtkcolorsel: Do not use GdkColor API
Comment 53 Javier Jardón (IRC: jjardon) 2012-01-04 15:07:05 UTC
Created attachment 204580 [details] [review]
Deprecate GdkColor
Comment 54 Javier Jardón (IRC: jjardon) 2012-01-04 15:07:33 UTC
Created attachment 204581 [details] [review]
Move GdkColor to deprecated directory
Comment 55 Javier Jardón (IRC: jjardon) 2012-01-04 15:09:59 UTC
There are some warnings because the link-color and the visited-link-color style properties. Should we add a GdkRGBA version of these properties?
Comment 56 Matthias Clasen 2012-01-04 15:36:23 UTC
Review of attachment 204578 [details] [review]:

Looks good
Comment 57 Matthias Clasen 2012-01-04 15:49:50 UTC
Review of attachment 204579 [details] [review]:

Looks ok. I don't think the clamping is really necessary though.
Comment 58 Matthias Clasen 2012-01-04 15:50:34 UTC
Review of attachment 204580 [details] [review]:

ok
Comment 59 Matthias Clasen 2012-01-04 15:52:39 UTC
Review of attachment 204581 [details] [review]:

Looks ok. Did you check that it survives make dist ?
Comment 60 Javier Jardón (IRC: jjardon) 2012-01-05 04:15:02 UTC
Comment on attachment 204578 [details] [review]
gtksettings: Do not use GdkColor API

commit baef3e5f2470cb727407e45a655cec59ebd4a9e5
Comment 61 Javier Jardón (IRC: jjardon) 2012-01-05 04:15:41 UTC
Comment on attachment 204579 [details] [review]
gtkcolorsel: Do not use GdkColor API

commit e77ffa6f871c0b0fd61da789ca4fc14d8e7a90ac
Comment 62 Murray Cumming 2012-01-05 16:21:03 UTC
Review of attachment 204579 [details] [review]:

Shouldn't this deprecate gtk_color_selection_palette_from_string() too, and maybe add a replacement?

/**
 * gtk_color_selection_palette_from_string:
 * @str: a string encoding a color palette
 * @colors: (out) (array length=n_colors): return location for
 *     allocated array of #GdkColor
 * @n_colors: return location for length of array
 *
 * Parses a color palette string; the string is a colon-separated
 * list of color names readable by gdk_color_parse().
 *
 * Return value: %TRUE if a palette was successfully parsed
 */
gboolean
gtk_color_selection_palette_from_string (const gchar  *str,
                                         GdkColor    **colors,
                                         gint         *n_colors)
Comment 63 André Klapper 2012-02-22 11:58:41 UTC
Javier: Could you answer Murray's question & commit your two attached patches?
Comment 64 Javier Jardón (IRC: jjardon) 2012-02-22 17:24:13 UTC
gtk_color_selection_palette_from_string() is deprecatred, so Its nor worth to have a replacement.
About apply my patches, I still have to find a way to avoid all the warnings before applying them
Comment 65 Murray Cumming 2012-02-22 20:03:02 UTC
(In reply to comment #64)
> gtk_color_selection_palette_from_string() is deprecatred,

Ah, yes, all of GtkColorSelection is now deprecated.
Comment 66 Murray Cumming 2012-02-23 08:58:44 UTC
(In reply to comment #55)
> There are some warnings because the link-color and the visited-link-color style
> properties.

Yes, these are the warnings:

gtkaboutdialog.c: In function 'follow_if_link':
gtkaboutdialog.c:1912:15: warning: 'gdk_color_free' is deprecated (declared at ../gdk/gdkcolor.h:68): Use 'gdk_rgba_free' instead [-Wdeprecated-declarations]
gtkaboutdialog.c: In function 'text_view_new':
gtkaboutdialog.c:2113:7: warning: 'gdk_color_free' is deprecated (declared at ../gdk/gdkcolor.h:68): Use 'gdk_rgba_free' instead [-Wdeprecated-declarations]
gtkaboutdialog.c:2121:7: warning: 'gdk_color_free' is deprecated (declared at ../gdk/gdkcolor.h:68): Use 'gdk_rgba_free' instead [-Wdeprecated-declarations]

>  Should we add a GdkRGBA version of these properties?

By the way, thes style properties are here:
http://git.gnome.org/browse/gtk+/tree/gtk/gtkwidget.c#n3083

Obviously we cannot just change that to use GdkRGBA because style properties are public API, when used from C code. However, the theme's .css files do not seem to need to know that it's a GdkColor. For instance:
http://git.gnome.org/browse/gnome-themes-standard/tree/themes/Adwaita/gtk-3.0/gtk-widgets.css#n31
which uses the color defined here:
http://git.gnome.org/browse/gnome-themes-standard/tree/themes/Adwaita/gtk-3.0/gtk-main.css#n46

So, I wonder how we can keep the .css the same, but let that same CSS value be retrieved by both link-color and link-rgba style properties. Maybe gtk_widget_class_install_style_property_parser() would let us do this?
Comment 67 Matthias Clasen 2012-03-18 14:43:26 UTC
Review of attachment 204580 [details] [review]:

Ok, so turns out we need to deal with the GdkColor-typed style properties first
Comment 68 Matthias Clasen 2012-03-18 14:43:50 UTC
Review of attachment 204581 [details] [review]:

This too
Comment 69 Matthias Clasen 2014-05-22 13:11:02 UTC
Attachment 204580 [details] pushed as 49cf514 - Deprecate GdkColor