Need help with GtkColorButton in sawfish

Hi all,

I just began finishing the GtkPreview/GtkColorSelection to
GtkColorButton transistion in sawfish-ui, but now I began struggling
around T_T

You'll need rep-gtk 0.90 HEAD to be able to test (I've added the
GtkColorButton Widget to it there)

First of all the patch:

diff --git a/lisp/sawfish/gtk/widgets/color.jl
index ae07e20..7cdbcae 100644
--- a/lisp/sawfish/gtk/widgets/color.jl
+++ b/lisp/sawfish/gtk/widgets/color.jl
@@ -26,50 +26,30 @@
     (open rep
-	  sawfish.gtk.widget
-	  sawfish.gtk.color-preview)
+	  sawfish.gtk.widget)
   (defconst default-color "#000000")
   (define (make-color-item changed-callback)
     (let* ((value default-color)
-	   (button (button-new-with-color value)))
-      (g-signal-connect
-       button "clicked"
+	   (button (gtk-color-button-new-with-color (gdk-color-parse-interp
+      (g-signal-connect button "color-set"
        (lambda ()
-	 (let ((colorsel (gtk-color-selection-dialog-new (_ "Select color"))))
-	   (gtk-color-selection-set-color-interp
-	    (gtk-color-selection-dialog-colorsel colorsel)
-	    (gdk-color-parse-interp value))
-	   (g-signal-connect
-	    (gtk-color-selection-dialog-ok-button colorsel) "clicked"
-	    (lambda ()
-	      (let ((color (gtk-color-selection-get-color-interp
-			    (gtk-color-selection-dialog-colorsel colorsel))))
-		(setq value (format nil "#%04x%04x%04x"
-				    (gdk-color-red color)
-				    (gdk-color-green color)
-				    (gdk-color-blue color)))
-		(set-button-color button value)
-		(call-callback changed-callback)
-		(gtk-widget-destroy colorsel))))
-	   (g-signal-connect
-	    (gtk-color-selection-dialog-cancel-button colorsel) "clicked"
-	    (lambda () (gtk-widget-destroy colorsel)))
-	   (g-signal-connect colorsel "delete_event"
-			       (lambda () (gtk-widget-destroy colorsel)))
-	   (gtk-widget-hide (gtk-color-selection-dialog-help-button colorsel))
-	   (gtk-widget-show colorsel)
-	   (gtk-grab-add colorsel))))
-      (gtk-widget-show button)
+         (let ((color (gtk-color-button-get-color button color)))
+	   (setq value (format nil "#%04x%04x%04x"
+	     (gdk-color-red color)
+	     (gdk-color-blue color)
+	     (gdk-color-green color)))
+	     (call-callback changed-callback))))
+       (gtk-widget-show button)
       (lambda (op)
 	(case op
 	  ((set) (lambda (x)
 		   (setq value x)
-		   (set-button-color button value)))
+		   (gtk-color-button-set-color button (gdk-color-parse-interp
 	  ((clear) (lambda ()
 		     (setq value default-color)
-		     (set-button-color button nil)))
+		     (gtk-color-button-set-color button (gdk-color-parse-interp
 	  ((ref) (lambda () value))
 	  ((gtk-widget) button)
 	  ((validp) (lambda (x)

as you can see I want to grab the GdkColor via the following call:

gtk-color-button-get-color arg1 arg2

arg1 is the widget (here: button)
arg2 is the variable to save the color in, but how do I declare the type
of the variable color as GdkColor? Or should I do it in an other way?

Everything else is already working, but without beeing able to actually
set a new color it's quite useless. I really hope you can help me. 

If I finished it, gtk/color-preview can be safely removed and sawfish-ui
is a bit more gtk1(!)-stuff free. Well, there are more gtk1 widgets
(they are still part of gtk2, but will be removed in gtk3 AFAIK) in
sawfish-ui: GtkCombo (new one: GtkCombobox and GtkComboboxEntry),
GtkTree (new one: GtkTreeView) and GtkClist (new one: GtkTreeView) so
it's still a long way to go.

Thanks in advance,

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