2009-03-24 Alberto Garcia <agarcia@igalia.com>
[hildon] / src / hildon-color-chooser.c
index 5500e21..acbf971 100644 (file)
@@ -4,12 +4,12 @@
  * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
  *
  * Author: Kuisma Salonen <kuisma.salonen@nokia.com>
- * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
+ * Contact: Rodrigo Novo <rodrigo.novo@nokia.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; version 2.1 of
- * the License.
+ * the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -37,7 +37,8 @@
  * 
  */
 
-#include                                        <gtk/gtk.h>
+#undef                                          HILDON_DISABLE_DEPRECATED
+
 #include                                        "hildon-color-chooser.h"
 #include                                        "hildon-color-chooser-private.h"
 
@@ -73,6 +74,9 @@ hildon_color_chooser_size_allocate              (GtkWidget *widget,
 static void
 hildon_color_chooser_realize                    (GtkWidget *widget);
 
+static void
+hildon_color_chooser_unrealize                  (GtkWidget *widget);
+
 static void 
 hildon_color_chooser_map                        (GtkWidget *widget);
 
@@ -262,6 +266,7 @@ hildon_color_chooser_class_init                 (HildonColorChooserClass *klass)
     widget_class->size_request          = hildon_color_chooser_size_request;
     widget_class->size_allocate         = hildon_color_chooser_size_allocate;
     widget_class->realize               = hildon_color_chooser_realize;
+    widget_class->unrealize             = hildon_color_chooser_unrealize;
     widget_class->map                   = hildon_color_chooser_map;
     widget_class->unmap                 = hildon_color_chooser_unmap;
     widget_class->expose_event          = hildon_color_chooser_expose;
@@ -270,18 +275,25 @@ hildon_color_chooser_class_init                 (HildonColorChooserClass *klass)
     widget_class->motion_notify_event   = hildon_color_chooser_pointer_motion;
 
     gtk_widget_class_install_style_property (widget_class,
-            g_param_spec_boxed ("inner_size",
-                "Inner sizes",
-                "Sizes of SV plane, H bar and spacing",
-                GTK_TYPE_BORDER,
-                G_PARAM_READABLE));
+                                             g_param_spec_boxed ("inner_size",
+                                                                 "Inner sizes",
+                                                                 "Sizes of SV plane, H bar and spacing",
+                                                                 GTK_TYPE_BORDER,
+                                                                 G_PARAM_READABLE));
+
+    gtk_widget_class_install_style_property (widget_class,
+                                             g_param_spec_boxed ("outer_border",
+                                                                 "Outer border",
+                                                                 "The outer border for the chooser",
+                                                                 GTK_TYPE_BORDER,
+                                                                 G_PARAM_READABLE));
 
     gtk_widget_class_install_style_property (widget_class,
-            g_param_spec_boxed ("graphic_border",
-                "Graphical borders",
-                "Size of graphical border",
-                GTK_TYPE_BORDER,
-                G_PARAM_READABLE));
+                                             g_param_spec_boxed ("graphic_border",
+                                                                 "Graphical borders",
+                                                                 "Size of graphical border",
+                                                                 GTK_TYPE_BORDER,
+                                                                 G_PARAM_READABLE));
 
     /**
      * HildonColorChooser:color:
@@ -403,11 +415,24 @@ hildon_color_chooser_realize                    (GtkWidget *widget)
 
 
     gdk_window_set_user_data (priv->event_window, widget);
-    widget->window = gtk_widget_get_parent_window (widget);
 
-    widget->style = gtk_style_attach (widget->style, widget->window);
+    GTK_WIDGET_CLASS (parent_class)->realize (widget);
+}
+
+static void
+hildon_color_chooser_unrealize                  (GtkWidget *widget)
+{
+    HildonColorChooserPrivate *priv = HILDON_COLOR_CHOOSER_GET_PRIVATE (widget);
+
+    g_assert (priv);
+
+    if (priv->event_window) {
+       gdk_window_set_user_data (priv->event_window, NULL);
+       gdk_window_destroy (priv->event_window);
+       priv->event_window = NULL;
+    }
 
-    GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+    GTK_WIDGET_CLASS(parent_class)->unrealize(widget);
 }
 
 static void 
@@ -751,7 +776,7 @@ init_borders                                    (GtkWidget *w,
 
     if (tb) {
         *inner = *tb;
-        g_free (tb);
+        gtk_border_free (tb);
     } else {
         inner->left = 64;
         inner->right = 64;
@@ -1321,9 +1346,9 @@ hildon_color_chooser_get_property               (GObject *object,
     {
 
         case PROP_COLOR: {
-            GdkColor *color = g_new (GdkColor, 1);
-            hildon_color_chooser_get_color ((HildonColorChooser *) object, color);
-            g_value_take_boxed (value, color);
+            GdkColor color;
+            hildon_color_chooser_get_color ((HildonColorChooser *) object, &color);
+            g_value_set_boxed (value, &color);
             } break;
 
         default: