internalize RVAL2BOXED fix for allowing passing NIL_P (->NULL)
authorgc <gc>
Sun, 22 Jul 2007 12:04:54 +0000 (12:04 +0000)
committergc <gc>
Sun, 22 Jul 2007 12:04:54 +0000 (12:04 +0000)
bin/booh-classifier
ext/rbbooh.c

index 9a329aa..08f6e64 100644 (file)
@@ -327,11 +327,9 @@ class Entry
             button.modify_bg(Gtk::StateType::PRELIGHT, labeled.color.lighter)
             button.modify_bg(Gtk::StateType::ACTIVE, labeled.color)
         else
-            # TODO need to add proper undo support :/
-            white = Gdk::Color.new(55535, 55535, 55535)
-            button.modify_bg(Gtk::StateType::NORMAL, white)
-            button.modify_bg(Gtk::StateType::PRELIGHT, white.lighter)
-            button.modify_bg(Gtk::StateType::ACTIVE, white)
+            button.modify_bg(Gtk::StateType::NORMAL, nil)
+            button.modify_bg(Gtk::StateType::PRELIGHT, nil)
+            button.modify_bg(Gtk::StateType::ACTIVE, nil)
         end
     end
 
index e64c403..3a92f99 100644 (file)
@@ -174,6 +174,12 @@ static VALUE rotate_noleak(VALUE self, VALUE angle) {
         return ret;
 }
 
+static VALUE modify_bg(VALUE self, VALUE state, VALUE color) {
+        gtk_widget_modify_bg(GTK_WIDGET(RVAL2GOBJ(self)), RVAL2GENUM(state, GTK_TYPE_STATE_TYPE),
+                             NIL_P(color) ? NULL : (GdkColor*) RVAL2BOXED(color, GDK_TYPE_COLOR));
+        return self;
+}
+
 void 
 Init_libadds()
 {
@@ -185,6 +191,9 @@ Init_libadds()
     cinfo = (RGObjClassInfo*)rbgobj_lookup_class_by_gtype(GDK_TYPE_DRAWABLE, Qnil);
     rb_define_method(cinfo->klass, "draw_borders", draw_borders, 5);
 
+    cinfo = (RGObjClassInfo*)rbgobj_lookup_class_by_gtype(GTK_TYPE_WIDGET, Qnil);
+    rb_define_method(cinfo->klass, "modify_bg", modify_bg, 2);
+
     VALUE exif = rb_define_module("Exif");
     rb_define_module_function(exif, "orientation", exif_orientation, 1);
     rb_define_module_function(exif, "datetimeoriginal", exif_datetimeoriginal, 1);