[rep-gtk] added gtk_color_button_get_color_interp



commit 458584af16cba4b0c7fa1221d2aed191cd46023b
Author: chrisb <zanghar freenet de>
Date:   Thu Jul 30 13:50:36 2009 +0200

    added gtk_color_button_get_color_interp

 ChangeLog    |    5 +++++
 gtk-compat.c |   34 ++++++++++++++++++++++++----------
 gtk.defs     |    4 ++++
 rep-gtk.h    |    7 ++++---
 4 files changed, 37 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e5751c8..0d94179 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-30  Christopher Bratusek <zanghar freenet de>
+	* rep-gtk.h
+	* gtk-compat.c
+	* gtk.defs: added gtk_color_button_get_color_interp (outputs a GdkColor in 6 digits hexformat)
+
 2009-07-29  Christopher Bratusek <zanghar freenet de>
 	* gtk.defs: gtk+ 2.12 API added:
 	*********** gtkbutton.h ***********
diff --git a/gtk-compat.c b/gtk-compat.c
index 4d4a176..7a44b5d 100644
--- a/gtk-compat.c
+++ b/gtk-compat.c
@@ -165,14 +165,14 @@ gtk_signal_set_class_function_full (GtkType            type,
 }
 #endif
 
-void 
+void
 gtk_color_selection_set_color_interp (GtkColorSelection *selection, GdkColor *color)
 {
   gdouble vals[4];
-  
-  vals[0] = color->red / 65535.0; 
-  vals[1] = color->green / 65535.0; 
-  vals[2] = color->blue / 65535.0; 
+
+  vals[0] = color->red / 65535.0;
+  vals[1] = color->green / 65535.0;
+  vals[2] = color->blue / 65535.0;
   vals[3] = 1.0;
 
   gtk_color_selection_set_color (selection, vals);
@@ -193,14 +193,28 @@ gtk_color_selection_get_color_interp (GtkColorSelection *selection)
 
   /* Since this color is not part of a colormap, the pixel value is
      pointless */
-  color->pixel = 0; 
-  color->red = (gushort) (65535.0 * vals[0]); 
-  color->green = (gushort) (65535.0 * vals[1]); 
-  color->blue = (gushort) (65535.0 * vals[2]); 
+  color->pixel = 0;
+  color->red = (gushort) (65535.0 * vals[0]);
+  color->green = (gushort) (65535.0 * vals[1]);
+  color->blue = (gushort) (65535.0 * vals[2]);
 
   return color;
 }
 
+char *
+gtk_color_button_get_color_interp (GtkColorButton *button)
+{
+  GdkColor color;
+  gchar *str;
+
+  gtk_color_button_get_color (button, &color);
+
+  str = g_strdup_printf ("#%02x%02x%02x", color.red >> 8,
+		  color.green >> 8, color.blue >> 8);
+
+  return str;
+}
+
 void
 gtk_widget_draw_interp (GtkWidget *widget)
 {
@@ -221,7 +235,7 @@ gtk_status_icon_popup_menu(GtkStatusIcon *status_icon,
 		     pos_func, user_data, button, activate_time);
 }
 
-gboolean 
+gboolean
 gtk_status_icon_get_geometry_interp(GtkStatusIcon *status_icon,
 				    gint *x,
 				    gint *y,
diff --git a/gtk.defs b/gtk.defs
index 317f18e..346d3c2 100644
--- a/gtk.defs
+++ b/gtk.defs
@@ -4758,6 +4758,10 @@
   ((GtkColorButton color_button)
    (GdkColor color)))
 
+(define-func gtk_color_button_get_color_interp
+  string
+  ((GtkColorButton button)))
+
 (define-func gtk_color_button_set_alpha
   none
   ((GtkColorButton color_button)
diff --git a/rep-gtk.h b/rep-gtk.h
index bd8da09..d2b2c58 100644
--- a/rep-gtk.h
+++ b/rep-gtk.h
@@ -2,17 +2,17 @@
  * Copyright (C) 1999 John Harper <john dcs warwick ac uk>
  *
  * $Id$
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2, or (at your option)
  * any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this software; see the file COPYING.  If not, write to
  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -332,6 +332,7 @@ void gtk_signal_set_class_function_full (GtkType            type,
 
 void gtk_color_selection_set_color_interp (GtkColorSelection *sel, GdkColor *color);
 GdkColor *gtk_color_selection_get_color_interp (GtkColorSelection *sel);
+char *gtk_color_button_get_color_interp (GtkColorButton *button);
 extern void gtk_widget_draw_interp (GtkWidget *widget);
 
 GtkTextIter *gtk_text_iter_new (void);



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