gtk+ r19559 - in branches/gtk-2-12: . gdk/quartz



Author: rhult
Date: Wed Feb 13 14:24:46 2008
New Revision: 19559
URL: http://svn.gnome.org/viewvc/gtk+?rev=19559&view=rev

Log:
2008-02-13  Richard Hult  <richard imendio com>

	Merged from trunk:

	* gdk/quartz/gdkcolor-quartz.c: (gdk_colormap_alloc_colors): Fix
	the return value (return number of colors that failed), and handle
	RGBA colormap.
	(gdk_colormap_free_colors): Fix typo in comment.


Modified:
   branches/gtk-2-12/ChangeLog
   branches/gtk-2-12/gdk/quartz/gdkcolor-quartz.c

Modified: branches/gtk-2-12/gdk/quartz/gdkcolor-quartz.c
==============================================================================
--- branches/gtk-2-12/gdk/quartz/gdkcolor-quartz.c	(original)
+++ branches/gtk-2-12/gdk/quartz/gdkcolor-quartz.c	Wed Feb 13 14:24:46 2008
@@ -137,9 +137,7 @@
 			  GdkColor    *colors,
 			  gint         ncolors)
 {
-  /* This function shouldn't do anything since
-   * colors are neve allocated.
-   */
+  /* This function shouldn't do anything since colors are never allocated. */
 }
 
 gint
@@ -151,18 +149,28 @@
 			   gboolean    *success)
 {
   int i;
+  int alpha;
+
+  g_return_val_if_fail (GDK_IS_COLORMAP (colormap), ncolors);
+  g_return_val_if_fail (colors != NULL, ncolors);
+  g_return_val_if_fail (success != NULL, ncolors);
+
+  if (gdk_colormap_get_visual (colormap)->depth == 32)
+    alpha = 0xff;
+  else
+    alpha = 0;
 
   for (i = 0; i < ncolors; i++)
     {
-      colors[i].pixel = ((colors[i].red >> 8) & 0xff) << 16 |
-	                ((colors[i].green >> 8) & 0xff) << 8 |
-	                ((colors[i].blue >> 8) & 0xff);
+      colors[i].pixel = alpha << 24 |
+        ((colors[i].red >> 8) & 0xff) << 16 |
+        ((colors[i].green >> 8) & 0xff) << 8 |
+        ((colors[i].blue >> 8) & 0xff);
     }
 
-  if (success)
-    *success = TRUE;
+  *success = TRUE;
 
-  return ncolors;
+  return 0;
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]