]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcolorsel.c
filechooserentry: Start autocomplete immediately
[~andy/gtk] / gtk / gtkcolorsel.c
index 4bd1e50412643ec810b3cb19d1679c8fddce6b9b..32f18ce715f0c1fd642a1c95e52feb57246484ae 100644 (file)
@@ -22,7 +22,7 @@
  * Modified by the GTK+ Team and others 1997-2001.  See the AUTHORS
  * file for a list of people on the GTK+ Team.  See the ChangeLog
  * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  */
 
 #include "config.h"
 #include <math.h>
 #include <string.h>
 
-#include "gdkconfig.h"
-#include "gdk/gdkkeysyms.h"
+#include "gdk/gdk.h"
+#include "gtkorientable.h"
 #include "gtkhsv.h"
 #include "gtkwindow.h"
 #include "gtkselection.h"
 #include "gtkdnd.h"
 #include "gtkdrawingarea.h"
-#include "gtkhbox.h"
-#include "gtkhbbox.h"
-#include "gtkrc.h"
 #include "gtkframe.h"
-#include "gtktable.h"
+#include "gtkgrid.h"
 #include "gtklabel.h"
 #include "gtkmarshalers.h"
 #include "gtkimage.h"
 #include "gtkspinbutton.h"
 #include "gtkrange.h"
-#include "gtkhscale.h"
+#include "gtkscale.h"
 #include "gtkentry.h"
 #include "gtkbutton.h"
-#include "gtkhseparator.h"
-#include "gtkinvisible.h"
 #include "gtkmenuitem.h"
 #include "gtkmain.h"
 #include "gtksettings.h"
 #include "gtkstock.h"
 #include "gtkaccessible.h"
 #include "gtksizerequest.h"
+#include "gtkseparator.h"
 #include "gtkprivate.h"
 #include "gtkintl.h"
 
+
+/**
+ * SECTION:gtkcolorsel
+ * @Short_description: A widget used to select a color
+ * @Title: GtkColorSelection
+ *
+ * The #GtkColorSelection is a widget that is used to select
+ * a color.  It consists of a color wheel and number of sliders
+ * and entry boxes for color parameters such as hue, saturation,
+ * value, red, green, blue, and opacity.  It is found on the standard
+ * color selection dialog box #GtkColorSelectionDialog.
+ */
+
+
 /* Keep it in sync with gtksettings.c:default_color_palette */
 #define DEFAULT_COLOR_PALETTE   "black:white:gray50:red:purple:blue:light blue:green:yellow:orange:lavender:brown:goldenrod4:dodger blue:pink:light green:gray10:gray30:gray75:gray90"
 
@@ -82,7 +92,7 @@
 
 #define SAMPLE_WIDTH  64
 #define SAMPLE_HEIGHT 28
-#define CHECK_SIZE 16  
+#define CHECK_SIZE 16
 #define BIG_STEP 20
 
 /* Conversion between 0->1 double and and guint16. See
@@ -120,16 +130,16 @@ enum {
 
 struct _GtkColorSelectionPrivate
 {
-  guint has_opacity : 1;
-  guint has_palette : 1;
-  guint changing : 1;
-  guint default_set : 1;
+  guint has_opacity       : 1;
+  guint has_palette       : 1;
+  guint changing          : 1;
+  guint default_set       : 1;
   guint default_alpha_set : 1;
-  guint has_grab : 1;
-  
+  guint has_grab          : 1;
+
   gdouble color[COLORSEL_NUM_CHANNELS];
   gdouble old_color[COLORSEL_NUM_CHANNELS];
-  
+
   GtkWidget *triangle_colorsel;
   GtkWidget *hue_spinbutton;
   GtkWidget *sat_spinbutton;
@@ -142,10 +152,10 @@ struct _GtkColorSelectionPrivate
   GtkWidget *opacity_entry;
   GtkWidget *palette_frame;
   GtkWidget *hex_entry;
-  
+
   /* The Palette code */
   GtkWidget *custom_palette [GTK_CUSTOM_PALETTE_WIDTH][GTK_CUSTOM_PALETTE_HEIGHT];
-  
+
   /* The color_sample stuff */
   GtkWidget *sample_area;
   GtkWidget *old_sample;
@@ -163,77 +173,77 @@ struct _GtkColorSelectionPrivate
 };
 
 
-static void gtk_color_selection_destroy                (GtkWidget               *widget);
-static void gtk_color_selection_finalize        (GObject                *object);
-static void update_color                       (GtkColorSelection       *colorsel);
+static void gtk_color_selection_destroy         (GtkWidget               *widget);
+static void gtk_color_selection_finalize        (GObject                 *object);
+static void update_color                        (GtkColorSelection       *colorsel);
 static void gtk_color_selection_set_property    (GObject                 *object,
-                                                guint                    prop_id,
-                                                const GValue            *value,
-                                                GParamSpec              *pspec);
+                                                 guint                    prop_id,
+                                                 const GValue            *value,
+                                                 GParamSpec              *pspec);
 static void gtk_color_selection_get_property    (GObject                 *object,
-                                                guint                    prop_id,
-                                                GValue                  *value,
-                                                GParamSpec              *pspec);
+                                                 guint                    prop_id,
+                                                 GValue                  *value,
+                                                 GParamSpec              *pspec);
 
 static void gtk_color_selection_realize         (GtkWidget               *widget);
 static void gtk_color_selection_unrealize       (GtkWidget               *widget);
 static void gtk_color_selection_show_all        (GtkWidget               *widget);
 static gboolean gtk_color_selection_grab_broken (GtkWidget               *widget,
-                                                GdkEventGrabBroken      *event);
+                                                 GdkEventGrabBroken      *event);
 
 static void     gtk_color_selection_set_palette_color   (GtkColorSelection *colorsel,
                                                          gint               index,
                                                          GdkColor          *color);
 static void     set_focus_line_attributes               (GtkWidget         *drawing_area,
-                                                        cairo_t           *cr,
-                                                        gint              *focus_width);
+                                                         cairo_t           *cr,
+                                                         gint              *focus_width);
 static void     default_noscreen_change_palette_func    (const GdkColor    *colors,
-                                                        gint               n_colors);
-static void     default_change_palette_func             (GdkScreen        *screen,
-                                                        const GdkColor    *colors,
-                                                        gint               n_colors);
+                                                         gint               n_colors);
+static void     default_change_palette_func             (GdkScreen         *screen,
+                                                         const GdkColor    *colors,
+                                                         gint               n_colors);
 static void     make_control_relations                  (AtkObject         *atk_obj,
                                                          GtkWidget         *widget);
 static void     make_all_relations                      (AtkObject         *atk_obj,
                                                          GtkColorSelectionPrivate *priv);
 
-static void    hsv_changed                             (GtkWidget         *hsv,
-                                                        gpointer           data);
-static void    get_screen_color                        (GtkWidget         *button);
-static void    adjustment_changed                      (GtkAdjustment     *adjustment,
-                                                        gpointer           data);
-static void    opacity_entry_changed                   (GtkWidget         *opacity_entry,
-                                                        gpointer           data);
-static void    hex_changed                             (GtkWidget         *hex_entry,
-                                                        gpointer           data);
-static gboolean hex_focus_out                           (GtkWidget                *hex_entry, 
-                                                        GdkEventFocus     *event,
-                                                        gpointer           data);
-static void    color_sample_new                        (GtkColorSelection *colorsel);
-static void    make_label_spinbutton                   (GtkColorSelection *colorsel,
-                                                        GtkWidget        **spinbutton,
-                                                        gchar             *text,
-                                                        GtkWidget         *table,
-                                                        gint               i,
-                                                        gint               j,
-                                                        gint               channel_type,
-                                                        const gchar       *tooltip);
-static void    make_palette_frame                      (GtkColorSelection *colorsel,
-                                                        GtkWidget         *table,
-                                                        gint               i,
-                                                        gint               j);
-static void    set_selected_palette                    (GtkColorSelection *colorsel,
-                                                        int                x,
-                                                        int                y);
-static void    set_focus_line_attributes               (GtkWidget         *drawing_area,
-                                                        cairo_t           *cr,
-                                                        gint              *focus_width);
-static gboolean mouse_press                            (GtkWidget         *invisible,
-                                                        GdkEventButton    *event,
-                                                        gpointer           data);
+static void     hsv_changed                             (GtkWidget         *hsv,
+                                                         gpointer           data);
+static void     get_screen_color                        (GtkWidget         *button);
+static void     adjustment_changed                      (GtkAdjustment     *adjustment,
+                                                         gpointer           data);
+static void     opacity_entry_changed                   (GtkWidget         *opacity_entry,
+                                                         gpointer           data);
+static void     hex_changed                             (GtkWidget         *hex_entry,
+                                                         gpointer           data);
+static gboolean hex_focus_out                           (GtkWidget         *hex_entry,
+                                                         GdkEventFocus     *event,
+                                                         gpointer           data);
+static void     color_sample_new                        (GtkColorSelection *colorsel);
+static void     make_label_spinbutton                   (GtkColorSelection *colorsel,
+                                                         GtkWidget        **spinbutton,
+                                                         gchar             *text,
+                                                         GtkWidget         *table,
+                                                         gint               i,
+                                                         gint               j,
+                                                         gint               channel_type,
+                                                         const gchar       *tooltip);
+static void     make_palette_frame                      (GtkColorSelection *colorsel,
+                                                         GtkWidget         *table,
+                                                         gint               i,
+                                                         gint               j);
+static void     set_selected_palette                    (GtkColorSelection *colorsel,
+                                                         int                x,
+                                                         int                y);
+static void     set_focus_line_attributes               (GtkWidget         *drawing_area,
+                                                         cairo_t           *cr,
+                                                         gint              *focus_width);
+static gboolean mouse_press                             (GtkWidget         *invisible,
+                                                         GdkEventButton    *event,
+                                                         gpointer           data);
 static void  palette_change_notify_instance (GObject    *object,
-                                            GParamSpec *pspec,
-                                            gpointer    data);
+                                             GParamSpec *pspec,
+                                             gpointer    data);
 static void update_palette (GtkColorSelection *colorsel);
 static void shutdown_eyedropper (GtkWidget *widget);
 
@@ -285,14 +295,14 @@ static const guchar dropper_bits[] = {
   "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
   "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"};
 
-G_DEFINE_TYPE (GtkColorSelection, gtk_color_selection, GTK_TYPE_VBOX)
+G_DEFINE_TYPE (GtkColorSelection, gtk_color_selection, GTK_TYPE_BOX)
 
 static void
 gtk_color_selection_class_init (GtkColorSelectionClass *klass)
 {
   GObjectClass *gobject_class;
   GtkWidgetClass *widget_class;
-  
+
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = gtk_color_selection_finalize;
   gobject_class->set_property = gtk_color_selection_set_property;
@@ -304,21 +314,21 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass)
   widget_class->unrealize = gtk_color_selection_unrealize;
   widget_class->show_all = gtk_color_selection_show_all;
   widget_class->grab_broken_event = gtk_color_selection_grab_broken;
-  
+
   g_object_class_install_property (gobject_class,
                                    PROP_HAS_OPACITY_CONTROL,
                                    g_param_spec_boolean ("has-opacity-control",
-                                                        P_("Has Opacity Control"),
-                                                        P_("Whether the color selector should allow setting opacity"),
-                                                        FALSE,
-                                                        GTK_PARAM_READWRITE));
+                                                         P_("Has Opacity Control"),
+                                                         P_("Whether the color selector should allow setting opacity"),
+                                                         FALSE,
+                                                         GTK_PARAM_READWRITE));
   g_object_class_install_property (gobject_class,
                                    PROP_HAS_PALETTE,
                                    g_param_spec_boolean ("has-palette",
-                                                        P_("Has palette"),
-                                                        P_("Whether a palette should be used"),
-                                                        FALSE,
-                                                        GTK_PARAM_READWRITE));
+                                                         P_("Has palette"),
+                                                         P_("Whether a palette should be used"),
+                                                         FALSE,
+                                                         GTK_PARAM_READWRITE));
   g_object_class_install_property (gobject_class,
                                    PROP_CURRENT_COLOR,
                                    g_param_spec_boxed ("current-color",
@@ -329,10 +339,10 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass)
   g_object_class_install_property (gobject_class,
                                    PROP_CURRENT_ALPHA,
                                    g_param_spec_uint ("current-alpha",
-                                                     P_("Current Alpha"),
-                                                     P_("The current opacity value (0 fully transparent, 65535 fully opaque)"),
-                                                     0, 65535, 65535,
-                                                     GTK_PARAM_READWRITE));
+                                                      P_("Current Alpha"),
+                                                      P_("The current opacity value (0 fully transparent, 65535 fully opaque)"),
+                                                      0, 65535, 65535,
+                                                      GTK_PARAM_READWRITE));
 
   /**
    * GtkColorSelection:current-rgba
@@ -349,14 +359,21 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass)
                                                        GDK_TYPE_RGBA,
                                                        GTK_PARAM_READWRITE));
 
+  /**
+   * GtkColorSelection::color-changed:
+   * @colorselection: the object which received the signal.
+   *
+   * This signal is emitted when the color changes in the #GtkColorSelection
+   * according to its update policy.
+   */
   color_selection_signals[COLOR_CHANGED] =
     g_signal_new (I_("color-changed"),
-                 G_OBJECT_CLASS_TYPE (gobject_class),
-                 G_SIGNAL_RUN_FIRST,
-                 G_STRUCT_OFFSET (GtkColorSelectionClass, color_changed),
-                 NULL, NULL,
-                 _gtk_marshal_VOID__VOID,
-                 G_TYPE_NONE, 0);
+                  G_OBJECT_CLASS_TYPE (gobject_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (GtkColorSelectionClass, color_changed),
+                  NULL, NULL,
+                  _gtk_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
 
   g_type_class_add_private (gobject_class, sizeof (GtkColorSelectionPrivate));
 }
@@ -373,18 +390,21 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
   GtkColorSelectionPrivate *priv;
   AtkObject *atk_obj;
   GList *focus_chain = NULL;
-  
+
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (colorsel),
+                                  GTK_ORIENTATION_VERTICAL);
+
   gtk_widget_push_composite_child ();
 
   priv = colorsel->private_data = G_TYPE_INSTANCE_GET_PRIVATE (colorsel, GTK_TYPE_COLOR_SELECTION, GtkColorSelectionPrivate);
   priv->changing = FALSE;
   priv->default_set = FALSE;
   priv->default_alpha_set = FALSE;
-  
-  top_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 12);
+
+  top_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
   gtk_box_pack_start (GTK_BOX (colorsel), top_hbox, FALSE, FALSE, 0);
-  
-  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 6);
+
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
   priv->triangle_colorsel = gtk_hsv_new ();
   g_signal_connect (priv->triangle_colorsel, "changed",
                     G_CALLBACK (hsv_changed), colorsel);
@@ -392,22 +412,24 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
   gtk_box_pack_start (GTK_BOX (top_hbox), vbox, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX (vbox), priv->triangle_colorsel, FALSE, FALSE, 0);
   gtk_widget_set_tooltip_text (priv->triangle_colorsel,
-                        _("Select the color you want from the outer ring. Select the darkness or lightness of that color using the inner triangle."));
-  
-  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 6);
+                        _("Select the color you want from the outer ring. "
+                          "Select the darkness or lightness of that color "
+                          "using the inner triangle."));
+
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
   gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-  
+
   frame = gtk_frame_new (NULL);
   gtk_widget_set_size_request (frame, -1, 30);
   gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
   color_sample_new (colorsel);
   gtk_container_add (GTK_CONTAINER (frame), priv->sample_area);
   gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
-  
+
   button = gtk_button_new ();
 
   gtk_widget_set_events (button, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
-  g_object_set_data (G_OBJECT (button), I_("COLORSEL"), colorsel); 
+  g_object_set_data (G_OBJECT (button), I_("COLORSEL"), colorsel);
   g_signal_connect (button, "clicked",
                     G_CALLBACK (get_screen_color), NULL);
   picker_image = gtk_image_new_from_stock (GTK_STOCK_COLOR_PICKER, GTK_ICON_SIZE_BUTTON);
@@ -416,19 +438,20 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
   gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
 
   gtk_widget_set_tooltip_text (button,
-                        _("Click the eyedropper, then click a color anywhere on your screen to select that color."));
-  
-  top_right_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 6);
+                        _("Click the eyedropper, then click a color "
+                          "anywhere on your screen to select that color."));
+
+  top_right_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
   gtk_box_pack_start (GTK_BOX (top_hbox), top_right_vbox, FALSE, FALSE, 0);
-  table = gtk_table_new (8, 6, FALSE);
+  table = gtk_grid_new ();
   gtk_box_pack_start (GTK_BOX (top_right_vbox), table, FALSE, FALSE, 0);
-  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
-  gtk_table_set_col_spacings (GTK_TABLE (table), 12);
-  
+  gtk_grid_set_row_spacing (GTK_GRID (table), 6);
+  gtk_grid_set_column_spacing (GTK_GRID (table), 12);
+
   make_label_spinbutton (colorsel, &priv->hue_spinbutton, _("_Hue:"), table, 0, 0, COLORSEL_HUE,
                          _("Position on the color wheel."));
   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (priv->hue_spinbutton), TRUE);
-  make_label_spinbutton (colorsel, &priv->sat_spinbutton, _("_Saturation:"), table, 0, 1, COLORSEL_SATURATION,
+  make_label_spinbutton (colorsel, &priv->sat_spinbutton, _("S_aturation:"), table, 0, 1, COLORSEL_SATURATION,
                          _("Intensity of the color."));
   make_label_spinbutton (colorsel, &priv->val_spinbutton, _("_Value:"), table, 0, 2, COLORSEL_VALUE,
                          _("Brightness of the color."));
@@ -438,13 +461,14 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
                          _("Amount of green light in the color."));
   make_label_spinbutton (colorsel, &priv->blue_spinbutton, _("_Blue:"), table, 6, 2, COLORSEL_BLUE,
                          _("Amount of blue light in the color."));
-  gtk_table_attach_defaults (GTK_TABLE (table), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), 0, 8, 3, 4); 
+  gtk_grid_attach (GTK_GRID (table), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), 0, 3, 8, 1);
 
-  priv->opacity_label = gtk_label_new_with_mnemonic (_("Op_acity:")); 
-  gtk_misc_set_alignment (GTK_MISC (priv->opacity_label), 0.0, 0.5); 
-  gtk_table_attach_defaults (GTK_TABLE (table), priv->opacity_label, 0, 1, 4, 5); 
+  priv->opacity_label = gtk_label_new_with_mnemonic (_("Op_acity:"));
+  gtk_widget_set_halign (priv->opacity_label, GTK_ALIGN_START);
+  gtk_widget_set_valign (priv->opacity_label, GTK_ALIGN_CENTER);
+  gtk_grid_attach (GTK_GRID (table), priv->opacity_label, 0, 4, 1, 1);
   adjust = gtk_adjustment_new (0.0, 0.0, 255.0, 1.0, 1.0, 0.0);
-  g_object_set_data (G_OBJECT (adjust), I_("COLORSEL"), colorsel); 
+  g_object_set_data (G_OBJECT (adjust), I_("COLORSEL"), colorsel);
   priv->opacity_slider = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adjust);
   gtk_widget_set_tooltip_text (priv->opacity_slider,
                         _("Transparency of the color."));
@@ -454,19 +478,20 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
   g_signal_connect (adjust, "value-changed",
                     G_CALLBACK (adjustment_changed),
                     GINT_TO_POINTER (COLORSEL_OPACITY));
-  gtk_table_attach_defaults (GTK_TABLE (table), priv->opacity_slider, 1, 7, 4, 5); 
-  priv->opacity_entry = gtk_entry_new (); 
+  gtk_grid_attach (GTK_GRID (table), priv->opacity_slider, 1, 4, 6, 1);
+  priv->opacity_entry = gtk_entry_new ();
   gtk_widget_set_tooltip_text (priv->opacity_entry,
                         _("Transparency of the color."));
-  gtk_widget_set_size_request (priv->opacity_entry, 40, -1); 
+  gtk_widget_set_size_request (priv->opacity_entry, 40, -1);
 
   g_signal_connect (priv->opacity_entry, "activate",
                     G_CALLBACK (opacity_entry_changed), colorsel);
-  gtk_table_attach_defaults (GTK_TABLE (table), priv->opacity_entry, 7, 8, 4, 5);
-  
+  gtk_grid_attach (GTK_GRID (table), priv->opacity_entry, 7, 4, 1, 1);
+
   label = gtk_label_new_with_mnemonic (_("Color _name:"));
-  gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 5, 6);
-  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  gtk_grid_attach (GTK_GRID (table), label, 0, 5, 1, 1);
+  gtk_widget_set_halign (label, GTK_ALIGN_START);
+  gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
   priv->hex_entry = gtk_entry_new ();
 
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->hex_entry);
@@ -478,10 +503,12 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
                     G_CALLBACK (hex_focus_out), colorsel);
 
   gtk_widget_set_tooltip_text (priv->hex_entry,
-                        _("You can enter an HTML-style hexadecimal color value, or simply a color name such as 'orange' in this entry."));
-  
+                        _("You can enter an HTML-style hexadecimal color "
+                          "value, or simply a color name such as 'orange' "
+                          "in this entry."));
+
   gtk_entry_set_width_chars (GTK_ENTRY (priv->hex_entry), 7);
-  gtk_table_attach_defaults (GTK_TABLE (table), priv->hex_entry, 1, 5, 5, 6);
+  gtk_grid_attach (GTK_GRID (table), priv->hex_entry, 1, 5, 4, 1);
 
   focus_chain = g_list_append (focus_chain, priv->hue_spinbutton);
   focus_chain = g_list_append (focus_chain, priv->sat_spinbutton);
@@ -496,39 +523,40 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
   g_list_free (focus_chain);
 
   /* Set up the palette */
-  table = gtk_table_new (GTK_CUSTOM_PALETTE_HEIGHT, GTK_CUSTOM_PALETTE_WIDTH, TRUE);
-  gtk_table_set_row_spacings (GTK_TABLE (table), 1);
-  gtk_table_set_col_spacings (GTK_TABLE (table), 1);
+  table = gtk_grid_new ();
+  gtk_grid_set_row_spacing (GTK_GRID (table), 1);
+  gtk_grid_set_column_spacing (GTK_GRID (table), 1);
   for (i = 0; i < GTK_CUSTOM_PALETTE_WIDTH; i++)
     {
       for (j = 0; j < GTK_CUSTOM_PALETTE_HEIGHT; j++)
-       {
-         make_palette_frame (colorsel, table, i, j);
-       }
+        {
+          make_palette_frame (colorsel, table, i, j);
+        }
     }
   set_selected_palette (colorsel, 0, 0);
-  priv->palette_frame = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 6);
+  priv->palette_frame = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
   label = gtk_label_new_with_mnemonic (_("_Palette:"));
-  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  gtk_widget_set_halign (label, GTK_ALIGN_START);
+  gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
   gtk_box_pack_start (GTK_BOX (priv->palette_frame), label, FALSE, FALSE, 0);
 
   gtk_label_set_mnemonic_widget (GTK_LABEL (label),
                                  priv->custom_palette[0][0]);
-  
+
   gtk_box_pack_end (GTK_BOX (top_right_vbox), priv->palette_frame, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX (priv->palette_frame), table, FALSE, FALSE, 0);
-  
+
   gtk_widget_show_all (top_hbox);
 
   /* hide unused stuff */
-  
+
   if (priv->has_opacity == FALSE)
     {
       gtk_widget_hide (priv->opacity_label);
       gtk_widget_hide (priv->opacity_slider);
       gtk_widget_hide (priv->opacity_entry);
     }
-  
+
   if (priv->has_palette == FALSE)
     {
       gtk_widget_hide (priv->palette_frame);
@@ -540,7 +568,7 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
       atk_object_set_name (atk_obj, _("Color Wheel"));
       atk_object_set_role (gtk_widget_get_accessible (GTK_WIDGET (colorsel)), ATK_ROLE_COLOR_CHOOSER);
       make_all_relations (atk_obj, priv);
-    } 
+    }
 
   gtk_widget_pop_composite_child ();
 }
@@ -554,21 +582,21 @@ gtk_color_selection_finalize (GObject *object)
 
 static void
 gtk_color_selection_set_property (GObject         *object,
-                                 guint            prop_id,
-                                 const GValue    *value,
-                                 GParamSpec      *pspec)
+                                  guint            prop_id,
+                                  const GValue    *value,
+                                  GParamSpec      *pspec)
 {
   GtkColorSelection *colorsel = GTK_COLOR_SELECTION (object);
-  
+
   switch (prop_id)
     {
     case PROP_HAS_OPACITY_CONTROL:
-      gtk_color_selection_set_has_opacity_control (colorsel, 
-                                                  g_value_get_boolean (value));
+      gtk_color_selection_set_has_opacity_control (colorsel,
+                                                   g_value_get_boolean (value));
       break;
     case PROP_HAS_PALETTE:
-      gtk_color_selection_set_has_palette (colorsel, 
-                                          g_value_get_boolean (value));
+      gtk_color_selection_set_has_palette (colorsel,
+                                           g_value_get_boolean (value));
       break;
     case PROP_CURRENT_COLOR:
       gtk_color_selection_set_current_color (colorsel, g_value_get_boxed (value));
@@ -583,18 +611,18 @@ gtk_color_selection_set_property (GObject         *object,
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
     }
-  
+
 }
 
 static void
 gtk_color_selection_get_property (GObject     *object,
-                                 guint        prop_id,
-                                 GValue      *value,
-                                 GParamSpec  *pspec)
+                                  guint        prop_id,
+                                  GValue      *value,
+                                  GParamSpec  *pspec)
 {
   GtkColorSelection *colorsel = GTK_COLOR_SELECTION (object);
   GdkColor color;
-  
+
   switch (prop_id)
     {
     case PROP_HAS_OPACITY_CONTROL:
@@ -649,9 +677,9 @@ gtk_color_selection_realize (GtkWidget *widget)
   GtkSettings *settings = gtk_widget_get_settings (widget);
 
   priv->settings_connection =  g_signal_connect (settings,
-                                                "notify::gtk-color-palette",
-                                                G_CALLBACK (palette_change_notify_instance),
-                                                widget);
+                                                 "notify::gtk-color-palette",
+                                                 G_CALLBACK (palette_change_notify_instance),
+                                                 widget);
   update_palette (colorsel);
 
   GTK_WIDGET_CLASS (gtk_color_selection_parent_class)->realize (widget);
@@ -679,9 +707,9 @@ gtk_color_selection_show_all (GtkWidget *widget)
   gtk_widget_show (widget);
 }
 
-static gboolean 
+static gboolean
 gtk_color_selection_grab_broken (GtkWidget          *widget,
-                                GdkEventGrabBroken *event)
+                                 GdkEventGrabBroken *event)
 {
   shutdown_eyedropper (widget);
 
@@ -701,11 +729,11 @@ static void color_sample_update_samples (GtkColorSelection *colorsel);
 
 static void
 set_color_internal (GtkColorSelection *colorsel,
-                   gdouble           *color)
+                    gdouble           *color)
 {
   GtkColorSelectionPrivate *priv;
   gint i;
-  
+
   priv = colorsel->private_data;
   priv->changing = TRUE;
   priv->color[COLORSEL_RED] = color[0];
@@ -713,15 +741,15 @@ set_color_internal (GtkColorSelection *colorsel,
   priv->color[COLORSEL_BLUE] = color[2];
   priv->color[COLORSEL_OPACITY] = color[3];
   gtk_rgb_to_hsv (priv->color[COLORSEL_RED],
-                 priv->color[COLORSEL_GREEN],
-                 priv->color[COLORSEL_BLUE],
-                 &priv->color[COLORSEL_HUE],
-                 &priv->color[COLORSEL_SATURATION],
-                 &priv->color[COLORSEL_VALUE]);
+                  priv->color[COLORSEL_GREEN],
+                  priv->color[COLORSEL_BLUE],
+                  &priv->color[COLORSEL_HUE],
+                  &priv->color[COLORSEL_SATURATION],
+                  &priv->color[COLORSEL_VALUE]);
   if (priv->default_set == FALSE)
     {
       for (i = 0; i < COLORSEL_NUM_CHANNELS; i++)
-       priv->old_color[i] = priv->color[i];
+        priv->old_color[i] = priv->color[i];
     }
   priv->default_set = TRUE;
   priv->default_alpha_set = TRUE;
@@ -730,35 +758,35 @@ set_color_internal (GtkColorSelection *colorsel,
 
 static void
 set_color_icon (GdkDragContext *context,
-               gdouble        *colors)
+                gdouble        *colors)
 {
   GdkPixbuf *pixbuf;
   guint32 pixel;
 
   pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE,
-                          8, 48, 32);
+                           8, 48, 32);
 
   pixel = (((UNSCALE (colors[COLORSEL_RED])   & 0xff00) << 16) |
-          ((UNSCALE (colors[COLORSEL_GREEN]) & 0xff00) << 8) |
-          ((UNSCALE (colors[COLORSEL_BLUE])  & 0xff00)));
+           ((UNSCALE (colors[COLORSEL_GREEN]) & 0xff00) << 8) |
+           ((UNSCALE (colors[COLORSEL_BLUE])  & 0xff00)));
 
   gdk_pixbuf_fill (pixbuf, pixel);
-  
+
   gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2);
   g_object_unref (pixbuf);
 }
 
 static void
 color_sample_drag_begin (GtkWidget      *widget,
-                        GdkDragContext *context,
-                        gpointer        data)
+                         GdkDragContext *context,
+                         gpointer        data)
 {
   GtkColorSelection *colorsel = data;
   GtkColorSelectionPrivate *priv;
   gdouble *colsrc;
-  
+
   priv = colorsel->private_data;
-  
+
   if (widget == priv->old_sample)
     colsrc = priv->old_color;
   else
@@ -769,88 +797,91 @@ color_sample_drag_begin (GtkWidget      *widget,
 
 static void
 color_sample_drag_end (GtkWidget      *widget,
-                      GdkDragContext *context,
-                      gpointer        data)
+                       GdkDragContext *context,
+                       gpointer        data)
 {
   g_object_set_data (G_OBJECT (widget), I_("gtk-color-selection-drag-window"), NULL);
 }
 
 static void
 color_sample_drop_handle (GtkWidget        *widget,
-                         GdkDragContext   *context,
-                         gint              x,
-                         gint              y,
-                         GtkSelectionData *selection_data,
-                         guint             info,
-                         guint             time,
-                         gpointer          data)
+                          GdkDragContext   *context,
+                          gint              x,
+                          gint              y,
+                          GtkSelectionData *selection_data,
+                          guint             info,
+                          guint             time,
+                          gpointer          data)
 {
   GtkColorSelection *colorsel = data;
   GtkColorSelectionPrivate *priv;
+  gint length;
   guint16 *vals;
   gdouble color[4];
   priv = colorsel->private_data;
-  
+
   /* This is currently a guint16 array of the format:
    * R
    * G
    * B
    * opacity
    */
-  
-  if (selection_data->length < 0)
+
+  length = gtk_selection_data_get_length (selection_data);
+
+  if (length < 0)
     return;
-  
+
   /* We accept drops with the wrong format, since the KDE color
    * chooser incorrectly drops application/x-color with format 8.
    */
-  if (selection_data->length != 8)
+  if (length != 8)
     {
       g_warning ("Received invalid color data\n");
       return;
     }
-  
-  vals = (guint16 *)selection_data->data;
-  
+
+  vals = (guint16 *) gtk_selection_data_get_data (selection_data);
+
   if (widget == priv->cur_sample)
     {
       color[0] = (gdouble)vals[0] / 0xffff;
       color[1] = (gdouble)vals[1] / 0xffff;
       color[2] = (gdouble)vals[2] / 0xffff;
       color[3] = (gdouble)vals[3] / 0xffff;
-      
+
       set_color_internal (colorsel, color);
     }
 }
 
 static void
 color_sample_drag_handle (GtkWidget        *widget,
-                         GdkDragContext   *context,
-                         GtkSelectionData *selection_data,
-                         guint             info,
-                         guint             time,
-                         gpointer          data)
+                          GdkDragContext   *context,
+                          GtkSelectionData *selection_data,
+                          guint             info,
+                          guint             time,
+                          gpointer          data)
 {
   GtkColorSelection *colorsel = data;
   GtkColorSelectionPrivate *priv;
   guint16 vals[4];
   gdouble *colsrc;
-  
+
   priv = colorsel->private_data;
-  
+
   if (widget == priv->old_sample)
     colsrc = priv->old_color;
   else
     colsrc = priv->color;
-  
+
   vals[0] = colsrc[COLORSEL_RED] * 0xffff;
   vals[1] = colsrc[COLORSEL_GREEN] * 0xffff;
   vals[2] = colsrc[COLORSEL_BLUE] * 0xffff;
   vals[3] = priv->has_opacity ? colsrc[COLORSEL_OPACITY] * 0xffff : 0xffff;
-  
+
   gtk_selection_data_set (selection_data,
-                         gdk_atom_intern_static_string ("application/x-color"),
-                         16, (guchar *)vals, 8);
+                          gdk_atom_intern_static_string ("application/x-color"),
+                          16, (guchar *)vals, 8);
 }
 
 /* which = 0 means draw old sample, which = 1 means draw new */
@@ -863,10 +894,10 @@ color_sample_draw_sample (GtkColorSelection *colorsel,
   gint x, y, goff;
   GtkColorSelectionPrivate *priv;
   int width, height;
-  
+
   g_return_if_fail (colorsel != NULL);
   priv = colorsel->private_data;
-  
+
   g_return_if_fail (priv->sample_area != NULL);
   if (!gtk_widget_is_drawable (priv->sample_area))
     return;
@@ -885,10 +916,10 @@ color_sample_draw_sample (GtkColorSelection *colorsel,
       goff =  old_sample_allocation.width % 32;
     }
 
-  /* Below needs tweaking for non-power-of-two */  
+  /* Below needs tweaking for non-power-of-two */
   width = gtk_widget_get_allocated_width (da);
   height = gtk_widget_get_allocated_height (da);
-  
+
   if (priv->has_opacity)
     {
       /* Draw checks in background */
@@ -899,29 +930,29 @@ color_sample_draw_sample (GtkColorSelection *colorsel,
 
       cairo_set_source_rgb (cr, 0.75, 0.75, 0.75);
       for (x = goff & -CHECK_SIZE; x < goff + width; x += CHECK_SIZE)
-       for (y = 0; y < height; y += CHECK_SIZE)
-         if ((x / CHECK_SIZE + y / CHECK_SIZE) % 2 == 0)
-           cairo_rectangle (cr, x - goff, y, CHECK_SIZE, CHECK_SIZE);
+        for (y = 0; y < height; y += CHECK_SIZE)
+          if ((x / CHECK_SIZE + y / CHECK_SIZE) % 2 == 0)
+            cairo_rectangle (cr, x - goff, y, CHECK_SIZE, CHECK_SIZE);
       cairo_fill (cr);
     }
 
   if (which == 0)
     {
       cairo_set_source_rgba (cr,
-                            priv->old_color[COLORSEL_RED], 
-                            priv->old_color[COLORSEL_GREEN], 
-                            priv->old_color[COLORSEL_BLUE],
-                            priv->has_opacity ?
-                               priv->old_color[COLORSEL_OPACITY] : 1.0);
+                             priv->old_color[COLORSEL_RED],
+                             priv->old_color[COLORSEL_GREEN],
+                             priv->old_color[COLORSEL_BLUE],
+                             priv->has_opacity ?
+                                priv->old_color[COLORSEL_OPACITY] : 1.0);
     }
   else
     {
       cairo_set_source_rgba (cr,
-                            priv->color[COLORSEL_RED], 
-                            priv->color[COLORSEL_GREEN], 
-                            priv->color[COLORSEL_BLUE],
-                            priv->has_opacity ?
-                              priv->color[COLORSEL_OPACITY] : 1.0);
+                             priv->color[COLORSEL_RED],
+                             priv->color[COLORSEL_GREEN],
+                             priv->color[COLORSEL_BLUE],
+                             priv->has_opacity ?
+                               priv->color[COLORSEL_OPACITY] : 1.0);
     }
 
   cairo_rectangle (cr, 0, 0, width, height);
@@ -964,37 +995,37 @@ color_sample_setup_dnd (GtkColorSelection *colorsel, GtkWidget *sample)
   };
   GtkColorSelectionPrivate *priv;
   priv = colorsel->private_data;
-  
+
   gtk_drag_source_set (sample,
-                      GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
-                      targets, 1,
-                      GDK_ACTION_COPY | GDK_ACTION_MOVE);
-  
+                       GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                       targets, 1,
+                       GDK_ACTION_COPY | GDK_ACTION_MOVE);
+
   g_signal_connect (sample, "drag-begin",
-                   G_CALLBACK (color_sample_drag_begin),
-                   colorsel);
+                    G_CALLBACK (color_sample_drag_begin),
+                    colorsel);
   if (sample == priv->cur_sample)
     {
-      
+
       gtk_drag_dest_set (sample,
-                        GTK_DEST_DEFAULT_HIGHLIGHT |
-                        GTK_DEST_DEFAULT_MOTION |
-                        GTK_DEST_DEFAULT_DROP,
-                        targets, 1,
-                        GDK_ACTION_COPY);
-      
+                         GTK_DEST_DEFAULT_HIGHLIGHT |
+                         GTK_DEST_DEFAULT_MOTION |
+                         GTK_DEST_DEFAULT_DROP,
+                         targets, 1,
+                         GDK_ACTION_COPY);
+
       g_signal_connect (sample, "drag-end",
-                       G_CALLBACK (color_sample_drag_end),
-                       colorsel);
+                        G_CALLBACK (color_sample_drag_end),
+                        colorsel);
     }
-  
+
   g_signal_connect (sample, "drag-data-get",
-                   G_CALLBACK (color_sample_drag_handle),
-                   colorsel);
+                    G_CALLBACK (color_sample_drag_handle),
+                    colorsel);
   g_signal_connect (sample, "drag-data-received",
-                   G_CALLBACK (color_sample_drop_handle),
-                   colorsel);
-  
+                    G_CALLBACK (color_sample_drop_handle),
+                    colorsel);
+
 }
 
 static void
@@ -1007,18 +1038,23 @@ update_tooltips (GtkColorSelection *colorsel)
   if (priv->has_palette == TRUE)
     {
       gtk_widget_set_tooltip_text (priv->old_sample,
-                            _("The previously-selected color, for comparison to the color you're selecting now. You can drag this color to a palette entry, or select this color as current by dragging it to the other color swatch alongside."));
+        _("The previously-selected color, for comparison to the color "
+          "you're selecting now. You can drag this color to a palette "
+          "entry, or select this color as current by dragging it to the "
+          "other color swatch alongside."));
 
       gtk_widget_set_tooltip_text (priv->cur_sample,
-                            _("The color you've chosen. You can drag this color to a palette entry to save it for use in the future."));
+        _("The color you've chosen. You can drag this color to a palette "
+          "entry to save it for use in the future."));
     }
   else
     {
       gtk_widget_set_tooltip_text (priv->old_sample,
-                            _("The previously-selected color, for comparison to the color you're selecting now."));
+        _("The previously-selected color, for comparison to the color "
+          "you're selecting now."));
 
       gtk_widget_set_tooltip_text (priv->cur_sample,
-                            _("The color you've chosen."));
+        _("The color you've chosen."));
     }
 }
 
@@ -1026,25 +1062,25 @@ static void
 color_sample_new (GtkColorSelection *colorsel)
 {
   GtkColorSelectionPrivate *priv;
-  
+
   priv = colorsel->private_data;
-  
-  priv->sample_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0);
+
+  priv->sample_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
   priv->old_sample = gtk_drawing_area_new ();
   priv->cur_sample = gtk_drawing_area_new ();
 
   gtk_box_pack_start (GTK_BOX (priv->sample_area), priv->old_sample,
-                     TRUE, TRUE, 0);
+                      TRUE, TRUE, 0);
   gtk_box_pack_start (GTK_BOX (priv->sample_area), priv->cur_sample,
-                     TRUE, TRUE, 0);
-  
+                      TRUE, TRUE, 0);
+
   g_signal_connect (priv->old_sample, "draw",
-                   G_CALLBACK (color_old_sample_draw),
-                   colorsel);
+                    G_CALLBACK (color_old_sample_draw),
+                    colorsel);
   g_signal_connect (priv->cur_sample, "draw",
-                   G_CALLBACK (color_cur_sample_draw),
-                   colorsel);
-  
+                    G_CALLBACK (color_cur_sample_draw),
+                    colorsel);
+
   color_sample_setup_dnd (colorsel, priv->old_sample);
   color_sample_setup_dnd (colorsel, priv->cur_sample);
 
@@ -1054,19 +1090,15 @@ color_sample_new (GtkColorSelection *colorsel)
 }
 
 
-/*
- *
- * The palette area code
- *
- */
+/* The palette area code */
 
 static void
 palette_get_color (GtkWidget *drawing_area, gdouble *color)
 {
   gdouble *color_val;
-  
+
   g_return_if_fail (color != NULL);
-  
+
   color_val = g_object_get_data (G_OBJECT (drawing_area), "color_val");
   if (color_val == NULL)
     {
@@ -1077,7 +1109,7 @@ palette_get_color (GtkWidget *drawing_area, gdouble *color)
       color[3] = 1.0;
       return;
     }
-  
+
   color[0] = color_val[0];
   color[1] = color_val[1];
   color[2] = color_val[2];
@@ -1087,14 +1119,18 @@ palette_get_color (GtkWidget *drawing_area, gdouble *color)
 static gboolean
 palette_draw (GtkWidget *drawing_area,
                cairo_t   *cr,
-              gpointer   data)
+               gpointer   data)
 {
+  GtkStyleContext *context;
   gint focus_width;
+  GdkRGBA color;
 
-  gdk_cairo_set_source_color (cr, &gtk_widget_get_style (drawing_area)->bg[GTK_STATE_NORMAL]);
+  context = gtk_widget_get_style_context (drawing_area);
+  gtk_style_context_get_background_color (context, 0, &color);
+  gdk_cairo_set_source_rgba (cr, &color);
   cairo_paint (cr);
-  
-  if (gtk_widget_has_focus (drawing_area))
+
+  if (gtk_widget_has_visible_focus (drawing_area))
     {
       set_focus_line_attributes (drawing_area, cr, &focus_width);
 
@@ -1110,17 +1146,17 @@ palette_draw (GtkWidget *drawing_area,
 
 static void
 set_focus_line_attributes (GtkWidget *drawing_area,
-                          cairo_t   *cr,
-                          gint      *focus_width)
+                           cairo_t   *cr,
+                           gint      *focus_width)
 {
   gdouble color[4];
   gint8 *dash_list;
-  
+
   gtk_widget_style_get (drawing_area,
-                       "focus-line-width", focus_width,
-                       "focus-line-pattern", (gchar *)&dash_list,
-                       NULL);
-      
+                        "focus-line-width", focus_width,
+                        "focus-line-pattern", (gchar *)&dash_list,
+                        NULL);
+
   palette_get_color (drawing_area, color);
 
   if (INTENSITY (color[0], color[1], color[2]) > 0.5)
@@ -1139,10 +1175,10 @@ set_focus_line_attributes (GtkWidget *drawing_area,
       gint i;
 
       for (i = 0; i < n_dashes; i++)
-       {
-         dashes[i] = dash_list[i];
-         total_length += dash_list[i];
-       }
+        {
+          dashes[i] = dash_list[i];
+          total_length += dash_list[i];
+        }
 
       /* The dash offset here aligns the pattern to integer pixels
        * by starting the dash at the right side of the left border
@@ -1151,8 +1187,8 @@ set_focus_line_attributes (GtkWidget *drawing_area,
        */
       dash_offset = - *focus_width / 2.;
       while (dash_offset < 0)
-       dash_offset += total_length;
-      
+        dash_offset += total_length;
+
       cairo_set_dash (cr, dashes, n_dashes, dash_offset);
       g_free (dashes);
     }
@@ -1162,42 +1198,42 @@ set_focus_line_attributes (GtkWidget *drawing_area,
 
 static void
 palette_drag_begin (GtkWidget      *widget,
-                   GdkDragContext *context,
-                   gpointer        data)
+                    GdkDragContext *context,
+                    gpointer        data)
 {
   gdouble colors[4];
-  
+
   palette_get_color (widget, colors);
   set_color_icon (context, colors);
 }
 
 static void
 palette_drag_handle (GtkWidget        *widget,
-                    GdkDragContext   *context,
-                    GtkSelectionData *selection_data,
-                    guint             info,
-                    guint             time,
-                    gpointer          data)
+                     GdkDragContext   *context,
+                     GtkSelectionData *selection_data,
+                     guint             info,
+                     guint             time,
+                     gpointer          data)
 {
   guint16 vals[4];
   gdouble colsrc[4];
-  
+
   palette_get_color (widget, colsrc);
-  
+
   vals[0] = colsrc[COLORSEL_RED] * 0xffff;
   vals[1] = colsrc[COLORSEL_GREEN] * 0xffff;
   vals[2] = colsrc[COLORSEL_BLUE] * 0xffff;
   vals[3] = 0xffff;
-  
+
   gtk_selection_data_set (selection_data,
-                         gdk_atom_intern_static_string ("application/x-color"),
-                         16, (guchar *)vals, 8);
+                          gdk_atom_intern_static_string ("application/x-color"),
+                          16, (guchar *)vals, 8);
 }
 
 static void
 palette_drag_end (GtkWidget      *widget,
-                 GdkDragContext *context,
-                 gpointer        data)
+                  GdkDragContext *context,
+                  gpointer        data)
 {
   g_object_set_data (G_OBJECT (widget), I_("gtk-color-selection-drag-window"), NULL);
 }
@@ -1212,7 +1248,7 @@ get_current_colors (GtkColorSelection *colorsel)
 
   settings = gtk_widget_get_settings (GTK_WIDGET (colorsel));
   g_object_get (settings, "gtk-color-palette", &palette, NULL);
-  
+
   if (!gtk_color_selection_palette_from_string (palette, &colors, &n_colors))
     {
       gtk_color_selection_palette_from_string (DEFAULT_COLOR_PALETTE,
@@ -1225,23 +1261,23 @@ get_current_colors (GtkColorSelection *colorsel)
        * color selection, we fill in the rest from the defaults.
        */
       if (n_colors < (GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT))
-       {
-         GdkColor *tmp_colors = colors;
-         gint tmp_n_colors = n_colors;
-         
-         gtk_color_selection_palette_from_string (DEFAULT_COLOR_PALETTE,
+        {
+          GdkColor *tmp_colors = colors;
+          gint tmp_n_colors = n_colors;
+
+          gtk_color_selection_palette_from_string (DEFAULT_COLOR_PALETTE,
                                                    &colors,
                                                    &n_colors);
-         memcpy (colors, tmp_colors, sizeof (GdkColor) * tmp_n_colors);
+          memcpy (colors, tmp_colors, sizeof (GdkColor) * tmp_n_colors);
 
-         g_free (tmp_colors);
-       }
+          g_free (tmp_colors);
+        }
     }
 
   /* make sure that we fill every slot */
   g_assert (n_colors == GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT);
   g_free (palette);
-  
+
   return colors;
 }
 
@@ -1259,16 +1295,16 @@ palette_change_color (GtkWidget         *drawing_area,
 
   g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
   g_return_if_fail (GTK_IS_DRAWING_AREA (drawing_area));
-  
+
   priv = colorsel->private_data;
-  
+
   gdk_color.red = UNSCALE (color[0]);
   gdk_color.green = UNSCALE (color[1]);
   gdk_color.blue = UNSCALE (color[2]);
   gdk_color.pixel = 0;
 
   x = 0;
-  y = 0;                       /* Quiet GCC */
+  y = 0;                        /* Quiet GCC */
   while (x < GTK_CUSTOM_PALETTE_WIDTH)
     {
       y = 0;
@@ -1276,7 +1312,7 @@ palette_change_color (GtkWidget         *drawing_area,
         {
           if (priv->custom_palette[x][y] == drawing_area)
             goto out;
-          
+
           ++y;
         }
 
@@ -1284,7 +1320,7 @@ palette_change_color (GtkWidget         *drawing_area,
     }
 
  out:
-  
+
   g_assert (x < GTK_CUSTOM_PALETTE_WIDTH || y < GTK_CUSTOM_PALETTE_HEIGHT);
 
   current_colors = get_current_colors (colorsel);
@@ -1292,18 +1328,19 @@ palette_change_color (GtkWidget         *drawing_area,
 
   screen = gtk_widget_get_screen (GTK_WIDGET (colorsel));
   if (change_palette_hook != default_change_palette_func)
-    (* change_palette_hook) (screen, current_colors, 
-                            GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT);
+    (* change_palette_hook) (screen, current_colors,
+                             GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT);
   else if (noscreen_change_palette_hook != default_noscreen_change_palette_func)
     {
       if (screen != gdk_screen_get_default ())
-       g_warning ("gtk_color_selection_set_change_palette_hook used by widget is not on the default screen.");
-      (* noscreen_change_palette_hook) (current_colors, 
-                                       GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT);
+        g_warning ("gtk_color_selection_set_change_palette_hook used by "
+                   "widget is not on the default screen.");
+      (* noscreen_change_palette_hook) (current_colors,
+                                        GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT);
     }
   else
-    (* change_palette_hook) (screen, current_colors, 
-                            GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT);
+    (* change_palette_hook) (screen, current_colors,
+                             GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT);
 
   g_free (current_colors);
 }
@@ -1311,45 +1348,47 @@ palette_change_color (GtkWidget         *drawing_area,
 /* Changes the view color */
 static void
 palette_set_color (GtkWidget         *drawing_area,
-                  GtkColorSelection *colorsel,
-                  gdouble           *color)
+                   GtkColorSelection *colorsel,
+                   gdouble           *color)
 {
   gdouble *new_color = g_new (double, 4);
-  GdkColor gdk_color;
-  
-  gdk_color.red = UNSCALE (color[0]);
-  gdk_color.green = UNSCALE (color[1]);
-  gdk_color.blue = UNSCALE (color[2]);
+  GdkRGBA rgba;
+
+  rgba.red = color[0];
+  rgba.green = color[1];
+  rgba.blue = color[2];
+  rgba.alpha = 1;
+
+  gtk_widget_override_background_color (drawing_area, GTK_STATE_FLAG_NORMAL, &rgba);
 
-  gtk_widget_modify_bg (drawing_area, GTK_STATE_NORMAL, &gdk_color);
-  
   if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (drawing_area), "color_set")) == 0)
     {
       static const GtkTargetEntry targets[] = {
-       { "application/x-color", 0 }
+        { "application/x-color", 0 }
       };
       gtk_drag_source_set (drawing_area,
-                          GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
-                          targets, 1,
-                          GDK_ACTION_COPY | GDK_ACTION_MOVE);
-      
+                           GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                           targets, 1,
+                           GDK_ACTION_COPY | GDK_ACTION_MOVE);
+
       g_signal_connect (drawing_area, "drag-begin",
-                       G_CALLBACK (palette_drag_begin),
-                       colorsel);
+                        G_CALLBACK (palette_drag_begin),
+                        colorsel);
       g_signal_connect (drawing_area, "drag-data-get",
-                       G_CALLBACK (palette_drag_handle),
-                       colorsel);
-      
+                        G_CALLBACK (palette_drag_handle),
+                        colorsel);
+
       g_object_set_data (G_OBJECT (drawing_area), I_("color_set"),
-                        GINT_TO_POINTER (1));
+                         GINT_TO_POINTER (1));
     }
 
   new_color[0] = color[0];
   new_color[1] = color[1];
   new_color[2] = color[2];
   new_color[3] = 1.0;
-  
-  g_object_set_data_full (G_OBJECT (drawing_area), I_("color_val"), new_color, (GDestroyNotify)g_free);
+
+  g_object_set_data_full (G_OBJECT (drawing_area),
+                          I_("color_val"), new_color, (GDestroyNotify)g_free);
 }
 
 static void
@@ -1357,16 +1396,16 @@ popup_position_func (GtkMenu   *menu,
                      gint      *x,
                      gint      *y,
                      gboolean  *push_in,
-                     gpointer  user_data)
+                     gpointer   user_data)
 {
   GtkAllocation allocation;
   GtkWidget *widget;
-  GtkRequisition req;      
+  GtkRequisition req;
   gint root_x, root_y;
   GdkScreen *screen;
-  
+
   widget = GTK_WIDGET (user_data);
-  
+
   g_return_if_fail (gtk_widget_get_realized (widget));
 
   gdk_window_get_origin (gtk_widget_get_window (widget),
@@ -1395,13 +1434,13 @@ save_color_selected (GtkWidget *menuitem,
   GtkColorSelectionPrivate *priv;
 
   drawing_area = GTK_WIDGET (data);
-  
+
   colorsel = GTK_COLOR_SELECTION (g_object_get_data (G_OBJECT (drawing_area),
                                                      "gtk-color-sel"));
 
   priv = colorsel->private_data;
-  
-  palette_change_color (drawing_area, colorsel, priv->color);  
+
+  palette_change_color (drawing_area, colorsel, priv->color);
 }
 
 static void
@@ -1411,11 +1450,11 @@ do_popup (GtkColorSelection *colorsel,
 {
   GtkWidget *menu;
   GtkWidget *mi;
-  
+
   g_object_set_data (G_OBJECT (drawing_area),
                      I_("gtk-color-sel"),
                      colorsel);
-  
+
   menu = gtk_menu_new ();
 
   mi = gtk_menu_item_new_with_mnemonic (_("_Save color here"));
@@ -1423,7 +1462,7 @@ do_popup (GtkColorSelection *colorsel,
   g_signal_connect (mi, "activate",
                     G_CALLBACK (save_color_selected),
                     drawing_area);
-  
+
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
 
   gtk_widget_show_all (mi);
@@ -1436,39 +1475,38 @@ do_popup (GtkColorSelection *colorsel,
 
 static gboolean
 palette_enter (GtkWidget        *drawing_area,
-              GdkEventCrossing *event,
-              gpointer        data)
+               GdkEventCrossing *event,
+               gpointer        data)
 {
   g_object_set_data (G_OBJECT (drawing_area),
-                    I_("gtk-colorsel-have-pointer"),
-                    GUINT_TO_POINTER (TRUE));
+                     I_("gtk-colorsel-have-pointer"),
+                     GUINT_TO_POINTER (TRUE));
 
   return FALSE;
 }
 
 static gboolean
 palette_leave (GtkWidget        *drawing_area,
-              GdkEventCrossing *event,
-              gpointer        data)
+               GdkEventCrossing *event,
+               gpointer        data)
 {
   g_object_set_data (G_OBJECT (drawing_area),
-                    I_("gtk-colorsel-have-pointer"),
-                    NULL);
+                     I_("gtk-colorsel-have-pointer"),
+                     NULL);
 
   return FALSE;
 }
 
 static gboolean
 palette_press (GtkWidget      *drawing_area,
-              GdkEventButton *event,
-              gpointer        data)
+               GdkEventButton *event,
+               gpointer        data)
 {
   GtkColorSelection *colorsel = GTK_COLOR_SELECTION (data);
 
   gtk_widget_grab_focus (drawing_area);
-  
-  if (event->button == 3 &&
-      event->type == GDK_BUTTON_PRESS)
+
+  if (gdk_event_triggers_context_menu ((GdkEvent *) event))
     {
       do_popup (colorsel, drawing_area, event->time);
       return TRUE;
@@ -1479,8 +1517,8 @@ palette_press (GtkWidget      *drawing_area,
 
 static gboolean
 palette_release (GtkWidget      *drawing_area,
-                GdkEventButton *event,
-                gpointer        data)
+                 GdkEventButton *event,
+                 gpointer        data)
 {
   GtkColorSelection *colorsel = GTK_COLOR_SELECTION (data);
 
@@ -1488,7 +1526,7 @@ palette_release (GtkWidget      *drawing_area,
 
   if (event->button == 1 &&
       g_object_get_data (G_OBJECT (drawing_area),
-                        "gtk-colorsel-have-pointer") != NULL)
+                         "gtk-colorsel-have-pointer") != NULL)
     {
       if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (drawing_area), "color_set")) != 0)
         {
@@ -1503,32 +1541,35 @@ palette_release (GtkWidget      *drawing_area,
 
 static void
 palette_drop_handle (GtkWidget        *widget,
-                    GdkDragContext   *context,
-                    gint              x,
-                    gint              y,
-                    GtkSelectionData *selection_data,
-                    guint             info,
-                    guint             time,
-                    gpointer          data)
+                     GdkDragContext   *context,
+                     gint              x,
+                     gint              y,
+                     GtkSelectionData *selection_data,
+                     guint             info,
+                     guint             time,
+                     gpointer          data)
 {
   GtkColorSelection *colorsel = GTK_COLOR_SELECTION (data);
+  gint length;
   guint16 *vals;
   gdouble color[4];
-  
-  if (selection_data->length < 0)
+
+  length = gtk_selection_data_get_length (selection_data);
+
+  if (length < 0)
     return;
-  
+
   /* We accept drops with the wrong format, since the KDE color
    * chooser incorrectly drops application/x-color with format 8.
    */
-  if (selection_data->length != 8)
+  if (length != 8)
     {
       g_warning ("Received invalid color data\n");
       return;
     }
-  
-  vals = (guint16 *)selection_data->data;
-  
+
+  vals = (guint16 *) gtk_selection_data_get_data (selection_data);
+
   color[0] = (gdouble)vals[0] / 0xffff;
   color[1] = (gdouble)vals[1] / 0xffff;
   color[2] = (gdouble)vals[2] / 0xffff;
@@ -1539,8 +1580,8 @@ palette_drop_handle (GtkWidget        *widget,
 
 static gint
 palette_activate (GtkWidget   *widget,
-                 GdkEventKey *event,
-                 gpointer     data)
+                  GdkEventKey *event,
+                  gpointer     data)
 {
   /* should have a drawing area subclass with an activate signal */
   if ((event->keyval == GDK_KEY_space) ||
@@ -1557,7 +1598,7 @@ palette_activate (GtkWidget   *widget,
         }
       return TRUE;
     }
-  
+
   return FALSE;
 }
 
@@ -1570,69 +1611,64 @@ palette_popup (GtkWidget *widget,
   do_popup (colorsel, widget, GDK_CURRENT_TIME);
   return TRUE;
 }
-               
+
 
 static GtkWidget*
 palette_new (GtkColorSelection *colorsel)
 {
   GtkWidget *retval;
-  GtkColorSelectionPrivate *priv;
-  
+
   static const GtkTargetEntry targets[] = {
     { "application/x-color", 0 }
   };
 
-  priv = colorsel->private_data;
-  
   retval = gtk_drawing_area_new ();
 
   gtk_widget_set_can_focus (retval, TRUE);
-  
-  g_object_set_data (G_OBJECT (retval), I_("color_set"), GINT_TO_POINTER (0)); 
+
+  g_object_set_data (G_OBJECT (retval), I_("color_set"), GINT_TO_POINTER (0));
   gtk_widget_set_events (retval, GDK_BUTTON_PRESS_MASK
                          | GDK_BUTTON_RELEASE_MASK
                          | GDK_EXPOSURE_MASK
                          | GDK_ENTER_NOTIFY_MASK
                          | GDK_LEAVE_NOTIFY_MASK);
-  
+
   g_signal_connect (retval, "draw",
-                   G_CALLBACK (palette_draw), colorsel);
+                    G_CALLBACK (palette_draw), colorsel);
   g_signal_connect (retval, "button-press-event",
-                   G_CALLBACK (palette_press), colorsel);
+                    G_CALLBACK (palette_press), colorsel);
   g_signal_connect (retval, "button-release-event",
-                   G_CALLBACK (palette_release), colorsel);
+                    G_CALLBACK (palette_release), colorsel);
   g_signal_connect (retval, "enter-notify-event",
-                   G_CALLBACK (palette_enter), colorsel);
+                    G_CALLBACK (palette_enter), colorsel);
   g_signal_connect (retval, "leave-notify-event",
-                   G_CALLBACK (palette_leave), colorsel);
+                    G_CALLBACK (palette_leave), colorsel);
   g_signal_connect (retval, "key-press-event",
-                   G_CALLBACK (palette_activate), colorsel);
+                    G_CALLBACK (palette_activate), colorsel);
   g_signal_connect (retval, "popup-menu",
-                   G_CALLBACK (palette_popup), colorsel);
-  
+                    G_CALLBACK (palette_popup), colorsel);
+
   gtk_drag_dest_set (retval,
-                    GTK_DEST_DEFAULT_HIGHLIGHT |
-                    GTK_DEST_DEFAULT_MOTION |
-                    GTK_DEST_DEFAULT_DROP,
-                    targets, 1,
-                    GDK_ACTION_COPY);
-  
+                     GTK_DEST_DEFAULT_HIGHLIGHT |
+                     GTK_DEST_DEFAULT_MOTION |
+                     GTK_DEST_DEFAULT_DROP,
+                     targets, 1,
+                     GDK_ACTION_COPY);
+
   g_signal_connect (retval, "drag-end",
                     G_CALLBACK (palette_drag_end), NULL);
   g_signal_connect (retval, "drag-data-received",
                     G_CALLBACK (palette_drop_handle), colorsel);
 
   gtk_widget_set_tooltip_text (retval,
-                        _("Click this palette entry to make it the current color. To change this entry, drag a color swatch here or right-click it and select \"Save color here.\""));
+    _("Click this palette entry to make it the current color. "
+      "To change this entry, drag a color swatch here or right-click "
+      "it and select \"Save color here.\""));
   return retval;
 }
 
 
-/*
- *
- * The actual GtkColorSelection widget
- *
- */
+/* The actual GtkColorSelection widget */
 
 static GdkCursor *
 make_picker_cursor (GdkScreen *screen)
@@ -1640,7 +1676,7 @@ make_picker_cursor (GdkScreen *screen)
   GdkCursor *cursor;
 
   cursor = gdk_cursor_new_from_name (gdk_screen_get_display (screen),
-                                    "color-picker");
+                                     "color-picker");
 
   if (!cursor)
     {
@@ -1654,11 +1690,11 @@ make_picker_cursor (GdkScreen *screen)
 
       cursor = gdk_cursor_new_from_pixbuf (gdk_screen_get_display (screen),
                                            pixbuf,
-                                          DROPPER_X_HOT, DROPPER_Y_HOT);
-      
+                                           DROPPER_X_HOT, DROPPER_Y_HOT);
+
       g_object_unref (pixbuf);
     }
-      
+
   return cursor;
 }
 
@@ -1675,24 +1711,23 @@ grab_color_at_pointer (GdkScreen *screen,
   GtkColorSelectionPrivate *priv;
   GdkColor color;
   GdkWindow *root_window = gdk_screen_get_root_window (screen);
-  
+
   priv = colorsel->private_data;
-  
+
   pixbuf = gdk_pixbuf_get_from_window (root_window,
                                        x_root, y_root,
                                        1, 1);
   if (!pixbuf)
     {
       gint x, y;
-      GdkDisplay *display = gdk_screen_get_display (screen);
-      GdkWindow *window = gdk_display_get_window_at_device_position (display, device, &x, &y);
+      GdkWindow *window = gdk_device_get_window_at_position (device, &x, &y);
       if (!window)
-       return;
+        return;
       pixbuf = gdk_pixbuf_get_from_window (window,
                                            x, y,
                                            1, 1);
       if (!pixbuf)
-       return;
+        return;
     }
   pixels = gdk_pixbuf_get_pixels (pixbuf);
   color.red = pixels[0] * 0x101;
@@ -1703,13 +1738,13 @@ grab_color_at_pointer (GdkScreen *screen,
   priv->color[COLORSEL_RED] = SCALE (color.red);
   priv->color[COLORSEL_GREEN] = SCALE (color.green);
   priv->color[COLORSEL_BLUE] = SCALE (color.blue);
-  
+
   gtk_rgb_to_hsv (priv->color[COLORSEL_RED],
-                 priv->color[COLORSEL_GREEN],
-                 priv->color[COLORSEL_BLUE],
-                 &priv->color[COLORSEL_HUE],
-                 &priv->color[COLORSEL_SATURATION],
-                 &priv->color[COLORSEL_VALUE]);
+                  priv->color[COLORSEL_GREEN],
+                  priv->color[COLORSEL_BLUE],
+                  &priv->color[COLORSEL_HUE],
+                  &priv->color[COLORSEL_SATURATION],
+                  &priv->color[COLORSEL_VALUE]);
 
   update_color (colorsel);
 }
@@ -1737,8 +1772,8 @@ shutdown_eyedropper (GtkWidget *widget)
 
 static void
 mouse_motion (GtkWidget      *invisible,
-             GdkEventMotion *event,
-             gpointer        data)
+              GdkEventMotion *event,
+              gpointer        data)
 {
   grab_color_at_pointer (gdk_event_get_screen ((GdkEvent *) event),
                          gdk_event_get_device ((GdkEvent *) event),
@@ -1747,8 +1782,8 @@ mouse_motion (GtkWidget      *invisible,
 
 static gboolean
 mouse_release (GtkWidget      *invisible,
-              GdkEventButton *event,
-              gpointer        data)
+               GdkEventButton *event,
+               gpointer        data)
 {
   /* GtkColorSelection *colorsel = data; */
 
@@ -1760,13 +1795,13 @@ mouse_release (GtkWidget      *invisible,
                          event->x_root, event->y_root, data);
 
   shutdown_eyedropper (GTK_WIDGET (data));
-  
+
   g_signal_handlers_disconnect_by_func (invisible,
-                                       mouse_motion,
-                                       data);
+                                        mouse_motion,
+                                        data);
   g_signal_handlers_disconnect_by_func (invisible,
-                                       mouse_release,
-                                       data);
+                                        mouse_release,
+                                        data);
 
   return TRUE;
 }
@@ -1777,8 +1812,7 @@ static gboolean
 key_press (GtkWidget   *invisible,
            GdkEventKey *event,
            gpointer     data)
-{  
-  GdkDisplay *display = gtk_widget_get_display (invisible);
+{
   GdkScreen *screen = gdk_event_get_screen ((GdkEvent *) event);
   GdkDevice *device, *pointer_device;
   guint state = event->state & gtk_accelerator_get_default_mod_mask ();
@@ -1787,12 +1821,12 @@ key_press (GtkWidget   *invisible,
 
   device = gdk_event_get_device ((GdkEvent * ) event);
   pointer_device = gdk_device_get_associated_device (device);
-  gdk_display_get_device_state (display, pointer_device, NULL, &x, &y, NULL);
+  gdk_device_get_position (pointer_device, NULL, &x, &y);
 
   dx = 0;
   dy = 0;
 
-  switch (event->keyval) 
+  switch (event->keyval)
     {
     case GDK_KEY_space:
     case GDK_KEY_Return:
@@ -1804,17 +1838,16 @@ key_press (GtkWidget   *invisible,
 
     case GDK_KEY_Escape:
       shutdown_eyedropper (data);
-      
+
       g_signal_handlers_disconnect_by_func (invisible,
-                                           mouse_press,
-                                           data);
+                                            mouse_press,
+                                            data);
       g_signal_handlers_disconnect_by_func (invisible,
-                                           key_press,
-                                           data);
-      
+                                            key_press,
+                                            data);
+
       return TRUE;
 
-#if defined GDK_WINDOWING_X11 || defined GDK_WINDOWING_WIN32
     case GDK_KEY_Up:
     case GDK_KEY_KP_Up:
       dy = state == GDK_MOD1_MASK ? -BIG_STEP : -1;
@@ -1834,13 +1867,12 @@ key_press (GtkWidget   *invisible,
     case GDK_KEY_KP_Right:
       dx = state == GDK_MOD1_MASK ? BIG_STEP : 1;
       break;
-#endif
 
     default:
       return FALSE;
     }
 
-  gdk_display_warp_device (display, pointer_device, screen, x + dx, y + dy);
+  gdk_device_warp (pointer_device, screen, x + dx, y + dy);
 
   return TRUE;
 
@@ -1848,26 +1880,21 @@ key_press (GtkWidget   *invisible,
 
 static gboolean
 mouse_press (GtkWidget      *invisible,
-            GdkEventButton *event,
-            gpointer        data)
+             GdkEventButton *event,
+             gpointer        data)
 {
-  /* GtkColorSelection *colorsel = data; */
-  
-  if (event->type == GDK_BUTTON_PRESS &&
-      event->button == 1)
+  if (event->type == GDK_BUTTON_PRESS && event->button == 1)
     {
       g_signal_connect (invisible, "motion-notify-event",
-                        G_CALLBACK (mouse_motion),
-                        data);
+                        G_CALLBACK (mouse_motion), data);
       g_signal_connect (invisible, "button-release-event",
-                        G_CALLBACK (mouse_release),
-                        data);
+                        G_CALLBACK (mouse_release), data);
       g_signal_handlers_disconnect_by_func (invisible,
-                                           mouse_press,
-                                           data);
+                                            mouse_press,
+                                            data);
       g_signal_handlers_disconnect_by_func (invisible,
-                                           key_press,
-                                           data);
+                                            key_press,
+                                            data);
       return TRUE;
     }
 
@@ -1891,7 +1918,7 @@ get_screen_color (GtkWidget *button)
 
   device = gtk_get_current_event_device ();
 
-  if (device->source == GDK_SOURCE_KEYBOARD)
+  if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
     {
       keyb_device = device;
       pointer_device = gdk_device_get_associated_device (device);
@@ -1912,15 +1939,15 @@ get_screen_color (GtkWidget *button)
 
       gtk_widget_add_events (grab_widget,
                              GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
-      
+
       toplevel = gtk_widget_get_toplevel (GTK_WIDGET (colorsel));
-  
+
       if (GTK_IS_WINDOW (toplevel))
-       {
+        {
           if (gtk_window_has_group (GTK_WINDOW (toplevel)))
-           gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
-                                        GTK_WINDOW (grab_widget));
-       }
+            gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
+                                         GTK_WINDOW (grab_widget));
+        }
 
       priv->dropper_grab_widget = grab_widget;
     }
@@ -1942,7 +1969,7 @@ get_screen_color (GtkWidget *button)
                                  GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK,
                                  picker_cursor,
                                  time);
-  gdk_cursor_unref (picker_cursor);
+  g_object_unref (picker_cursor);
 
   if (grab_status != GDK_GRAB_SUCCESS)
     {
@@ -1967,157 +1994,157 @@ get_screen_color (GtkWidget *button)
 
 static void
 hex_changed (GtkWidget *hex_entry,
-            gpointer   data)
+             gpointer   data)
 {
   GtkColorSelection *colorsel;
   GtkColorSelectionPrivate *priv;
   GdkColor color;
   gchar *text;
-  
+
   colorsel = GTK_COLOR_SELECTION (data);
   priv = colorsel->private_data;
-  
+
   if (priv->changing)
     return;
-  
+
   text = gtk_editable_get_chars (GTK_EDITABLE (priv->hex_entry), 0, -1);
   if (gdk_color_parse (text, &color))
     {
-      priv->color[COLORSEL_RED] = CLAMP (color.red/65535.0, 0.0, 1.0);
-      priv->color[COLORSEL_GREEN] = CLAMP (color.green/65535.0, 0.0, 1.0);
-      priv->color[COLORSEL_BLUE] = CLAMP (color.blue/65535.0, 0.0, 1.0);
+      priv->color[COLORSEL_RED]   = CLAMP (color.red   / 65535.0, 0.0, 1.0);
+      priv->color[COLORSEL_GREEN] = CLAMP (color.green / 65535.0, 0.0, 1.0);
+      priv->color[COLORSEL_BLUE]  = CLAMP (color.blue  / 65535.0, 0.0, 1.0);
       gtk_rgb_to_hsv (priv->color[COLORSEL_RED],
-                     priv->color[COLORSEL_GREEN],
-                     priv->color[COLORSEL_BLUE],
-                     &priv->color[COLORSEL_HUE],
-                     &priv->color[COLORSEL_SATURATION],
-                     &priv->color[COLORSEL_VALUE]);
+                      priv->color[COLORSEL_GREEN],
+                      priv->color[COLORSEL_BLUE],
+                      &priv->color[COLORSEL_HUE],
+                      &priv->color[COLORSEL_SATURATION],
+                      &priv->color[COLORSEL_VALUE]);
       update_color (colorsel);
     }
   g_free (text);
 }
 
 static gboolean
-hex_focus_out (GtkWidget     *hex_entry, 
-              GdkEventFocus *event,
-              gpointer       data)
+hex_focus_out (GtkWidget     *hex_entry,
+               GdkEventFocus *event,
+               gpointer       data)
 {
   hex_changed (hex_entry, data);
-  
+
   return FALSE;
 }
 
 static void
 hsv_changed (GtkWidget *hsv,
-            gpointer   data)
+             gpointer   data)
 {
   GtkColorSelection *colorsel;
   GtkColorSelectionPrivate *priv;
-  
+
   colorsel = GTK_COLOR_SELECTION (data);
   priv = colorsel->private_data;
-  
+
   if (priv->changing)
     return;
-  
+
   gtk_hsv_get_color (GTK_HSV (hsv),
-                    &priv->color[COLORSEL_HUE],
-                    &priv->color[COLORSEL_SATURATION],
-                    &priv->color[COLORSEL_VALUE]);
+                     &priv->color[COLORSEL_HUE],
+                     &priv->color[COLORSEL_SATURATION],
+                     &priv->color[COLORSEL_VALUE]);
   gtk_hsv_to_rgb (priv->color[COLORSEL_HUE],
-                 priv->color[COLORSEL_SATURATION],
-                 priv->color[COLORSEL_VALUE],
-                 &priv->color[COLORSEL_RED],
-                 &priv->color[COLORSEL_GREEN],
-                 &priv->color[COLORSEL_BLUE]);
+                  priv->color[COLORSEL_SATURATION],
+                  priv->color[COLORSEL_VALUE],
+                  &priv->color[COLORSEL_RED],
+                  &priv->color[COLORSEL_GREEN],
+                  &priv->color[COLORSEL_BLUE]);
   update_color (colorsel);
 }
 
 static void
 adjustment_changed (GtkAdjustment *adjustment,
-                   gpointer       data)
+                    gpointer       data)
 {
   GtkColorSelection *colorsel;
   GtkColorSelectionPrivate *priv;
-  
+
   colorsel = GTK_COLOR_SELECTION (g_object_get_data (G_OBJECT (adjustment), "COLORSEL"));
   priv = colorsel->private_data;
-  
+
   if (priv->changing)
     return;
-  
+
   switch (GPOINTER_TO_INT (data))
     {
     case COLORSEL_SATURATION:
     case COLORSEL_VALUE:
-      priv->color[GPOINTER_TO_INT (data)] = adjustment->value / 100;
+      priv->color[GPOINTER_TO_INT (data)] = gtk_adjustment_get_value (adjustment) / 100;
       gtk_hsv_to_rgb (priv->color[COLORSEL_HUE],
-                     priv->color[COLORSEL_SATURATION],
-                     priv->color[COLORSEL_VALUE],
-                     &priv->color[COLORSEL_RED],
-                     &priv->color[COLORSEL_GREEN],
-                     &priv->color[COLORSEL_BLUE]);
+                      priv->color[COLORSEL_SATURATION],
+                      priv->color[COLORSEL_VALUE],
+                      &priv->color[COLORSEL_RED],
+                      &priv->color[COLORSEL_GREEN],
+                      &priv->color[COLORSEL_BLUE]);
       break;
     case COLORSEL_HUE:
-      priv->color[GPOINTER_TO_INT (data)] = adjustment->value / 360;
+      priv->color[GPOINTER_TO_INT (data)] = gtk_adjustment_get_value (adjustment) / 360;
       gtk_hsv_to_rgb (priv->color[COLORSEL_HUE],
-                     priv->color[COLORSEL_SATURATION],
-                     priv->color[COLORSEL_VALUE],
-                     &priv->color[COLORSEL_RED],
-                     &priv->color[COLORSEL_GREEN],
-                     &priv->color[COLORSEL_BLUE]);
+                      priv->color[COLORSEL_SATURATION],
+                      priv->color[COLORSEL_VALUE],
+                      &priv->color[COLORSEL_RED],
+                      &priv->color[COLORSEL_GREEN],
+                      &priv->color[COLORSEL_BLUE]);
       break;
     case COLORSEL_RED:
     case COLORSEL_GREEN:
     case COLORSEL_BLUE:
-      priv->color[GPOINTER_TO_INT (data)] = adjustment->value / 255;
-      
+      priv->color[GPOINTER_TO_INT (data)] = gtk_adjustment_get_value (adjustment) / 255;
+
       gtk_rgb_to_hsv (priv->color[COLORSEL_RED],
-                     priv->color[COLORSEL_GREEN],
-                     priv->color[COLORSEL_BLUE],
-                     &priv->color[COLORSEL_HUE],
-                     &priv->color[COLORSEL_SATURATION],
-                     &priv->color[COLORSEL_VALUE]);
+                      priv->color[COLORSEL_GREEN],
+                      priv->color[COLORSEL_BLUE],
+                      &priv->color[COLORSEL_HUE],
+                      &priv->color[COLORSEL_SATURATION],
+                      &priv->color[COLORSEL_VALUE]);
       break;
     default:
-      priv->color[GPOINTER_TO_INT (data)] = adjustment->value / 255;
+      priv->color[GPOINTER_TO_INT (data)] = gtk_adjustment_get_value (adjustment) / 255;
       break;
     }
   update_color (colorsel);
 }
 
-static void 
+static void
 opacity_entry_changed (GtkWidget *opacity_entry,
-                      gpointer   data)
+                       gpointer   data)
 {
   GtkColorSelection *colorsel;
   GtkColorSelectionPrivate *priv;
   GtkAdjustment *adj;
   gchar *text;
-  
+
   colorsel = GTK_COLOR_SELECTION (data);
   priv = colorsel->private_data;
-  
+
   if (priv->changing)
     return;
-  
+
   text = gtk_editable_get_chars (GTK_EDITABLE (priv->opacity_entry), 0, -1);
   adj = gtk_range_get_adjustment (GTK_RANGE (priv->opacity_slider));
-  gtk_adjustment_set_value (adj, g_strtod (text, NULL)); 
-  
+  gtk_adjustment_set_value (adj, g_strtod (text, NULL));
+
   update_color (colorsel);
-  
+
   g_free (text);
 }
 
 static void
 make_label_spinbutton (GtkColorSelection *colorsel,
-                      GtkWidget        **spinbutton,
-                      gchar             *text,
-                      GtkWidget         *table,
-                      gint               i,
-                      gint               j,
-                      gint               channel_type,
+                       GtkWidget        **spinbutton,
+                       gchar             *text,
+                       GtkWidget         *table,
+                       gint               i,
+                       gint               j,
+                       gint               channel_type,
                        const gchar       *tooltip)
 {
   GtkWidget *label;
@@ -2128,7 +2155,7 @@ make_label_spinbutton (GtkColorSelection *colorsel,
       adjust = gtk_adjustment_new (0.0, 0.0, 360.0, 1.0, 1.0, 0.0);
     }
   else if (channel_type == COLORSEL_SATURATION ||
-          channel_type == COLORSEL_VALUE)
+           channel_type == COLORSEL_VALUE)
     {
       adjust = gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 1.0, 0.0);
     }
@@ -2139,7 +2166,7 @@ make_label_spinbutton (GtkColorSelection *colorsel,
   g_object_set_data (G_OBJECT (adjust), I_("COLORSEL"), colorsel);
   *spinbutton = gtk_spin_button_new (adjust, 10.0, 0);
 
-  gtk_widget_set_tooltip_text (*spinbutton, tooltip);  
+  gtk_widget_set_tooltip_text (*spinbutton, tooltip);
 
   g_signal_connect (adjust, "value-changed",
                     G_CALLBACK (adjustment_changed),
@@ -2147,34 +2174,35 @@ make_label_spinbutton (GtkColorSelection *colorsel,
   label = gtk_label_new_with_mnemonic (text);
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), *spinbutton);
 
-  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-  gtk_table_attach_defaults (GTK_TABLE (table), label, i, i+1, j, j+1);
-  gtk_table_attach_defaults (GTK_TABLE (table), *spinbutton, i+1, i+2, j, j+1);
+  gtk_widget_set_halign (label, GTK_ALIGN_START);
+  gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
+  gtk_grid_attach (GTK_GRID (table), label, i, j, 1, 1);
+  gtk_grid_attach (GTK_GRID (table), *spinbutton, i+1, j, 1, 1);
 }
 
 static void
 make_palette_frame (GtkColorSelection *colorsel,
-                   GtkWidget         *table,
-                   gint               i,
-                   gint               j)
+                    GtkWidget         *table,
+                    gint               i,
+                    gint               j)
 {
   GtkWidget *frame;
   GtkColorSelectionPrivate *priv;
-  
+
   priv = colorsel->private_data;
   frame = gtk_frame_new (NULL);
   gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
   priv->custom_palette[i][j] = palette_new (colorsel);
   gtk_widget_set_size_request (priv->custom_palette[i][j], CUSTOM_PALETTE_ENTRY_WIDTH, CUSTOM_PALETTE_ENTRY_HEIGHT);
   gtk_container_add (GTK_CONTAINER (frame), priv->custom_palette[i][j]);
-  gtk_table_attach_defaults (GTK_TABLE (table), frame, i, i+1, j, j+1);
+  gtk_grid_attach (GTK_GRID (table), frame, i, j, 1, 1);
 }
 
 /* Set the palette entry [x][y] to be the currently selected one. */
-static void 
+static void
 set_selected_palette (GtkColorSelection *colorsel, int x, int y)
 {
-  GtkColorSelectionPrivate *priv = colorsel->private_data; 
+  GtkColorSelectionPrivate *priv = colorsel->private_data;
 
   gtk_widget_grab_focus (priv->custom_palette[x][y]);
 }
@@ -2195,44 +2223,44 @@ update_color (GtkColorSelection *colorsel)
   gchar entryval[12];
   gchar opacity_text[32];
   gchar *ptr;
-  
+
   priv->changing = TRUE;
   color_sample_update_samples (colorsel);
-  
+
   gtk_hsv_set_color (GTK_HSV (priv->triangle_colorsel),
-                    priv->color[COLORSEL_HUE],
-                    priv->color[COLORSEL_SATURATION],
-                    priv->color[COLORSEL_VALUE]);
+                     priv->color[COLORSEL_HUE],
+                     priv->color[COLORSEL_SATURATION],
+                     priv->color[COLORSEL_VALUE]);
   gtk_adjustment_set_value (gtk_spin_button_get_adjustment
-                           (GTK_SPIN_BUTTON (priv->hue_spinbutton)),
-                           scale_round (priv->color[COLORSEL_HUE], 360));
+                            (GTK_SPIN_BUTTON (priv->hue_spinbutton)),
+                            scale_round (priv->color[COLORSEL_HUE], 360));
   gtk_adjustment_set_value (gtk_spin_button_get_adjustment
-                           (GTK_SPIN_BUTTON (priv->sat_spinbutton)),
-                           scale_round (priv->color[COLORSEL_SATURATION], 100));
+                            (GTK_SPIN_BUTTON (priv->sat_spinbutton)),
+                            scale_round (priv->color[COLORSEL_SATURATION], 100));
   gtk_adjustment_set_value (gtk_spin_button_get_adjustment
-                           (GTK_SPIN_BUTTON (priv->val_spinbutton)),
-                           scale_round (priv->color[COLORSEL_VALUE], 100));
+                            (GTK_SPIN_BUTTON (priv->val_spinbutton)),
+                            scale_round (priv->color[COLORSEL_VALUE], 100));
   gtk_adjustment_set_value (gtk_spin_button_get_adjustment
-                           (GTK_SPIN_BUTTON (priv->red_spinbutton)),
-                           scale_round (priv->color[COLORSEL_RED], 255));
+                            (GTK_SPIN_BUTTON (priv->red_spinbutton)),
+                            scale_round (priv->color[COLORSEL_RED], 255));
   gtk_adjustment_set_value (gtk_spin_button_get_adjustment
-                           (GTK_SPIN_BUTTON (priv->green_spinbutton)),
-                           scale_round (priv->color[COLORSEL_GREEN], 255));
+                            (GTK_SPIN_BUTTON (priv->green_spinbutton)),
+                            scale_round (priv->color[COLORSEL_GREEN], 255));
   gtk_adjustment_set_value (gtk_spin_button_get_adjustment
-                           (GTK_SPIN_BUTTON (priv->blue_spinbutton)),
-                           scale_round (priv->color[COLORSEL_BLUE], 255));
+                            (GTK_SPIN_BUTTON (priv->blue_spinbutton)),
+                            scale_round (priv->color[COLORSEL_BLUE], 255));
   gtk_adjustment_set_value (gtk_range_get_adjustment
-                           (GTK_RANGE (priv->opacity_slider)),
-                           scale_round (priv->color[COLORSEL_OPACITY], 255));
-  
+                            (GTK_RANGE (priv->opacity_slider)),
+                            scale_round (priv->color[COLORSEL_OPACITY], 255));
+
   g_snprintf (opacity_text, 32, "%.0f", scale_round (priv->color[COLORSEL_OPACITY], 255));
   gtk_entry_set_text (GTK_ENTRY (priv->opacity_entry), opacity_text);
-  
+
   g_snprintf (entryval, 11, "#%2X%2X%2X",
-             (guint) (scale_round (priv->color[COLORSEL_RED], 255)),
-             (guint) (scale_round (priv->color[COLORSEL_GREEN], 255)),
-             (guint) (scale_round (priv->color[COLORSEL_BLUE], 255)));
-  
+              (guint) (scale_round (priv->color[COLORSEL_RED], 255)),
+              (guint) (scale_round (priv->color[COLORSEL_GREEN], 255)),
+              (guint) (scale_round (priv->color[COLORSEL_BLUE], 255)));
+
   for (ptr = entryval; *ptr; ptr++)
     if (*ptr == ' ')
       *ptr = '0';
@@ -2240,14 +2268,14 @@ update_color (GtkColorSelection *colorsel)
   priv->changing = FALSE;
 
   g_object_ref (colorsel);
-  
+
   g_signal_emit (colorsel, color_selection_signals[COLOR_CHANGED], 0);
-  
+
   g_object_freeze_notify (G_OBJECT (colorsel));
   g_object_notify (G_OBJECT (colorsel), "current-color");
   g_object_notify (G_OBJECT (colorsel), "current-alpha");
   g_object_thaw_notify (G_OBJECT (colorsel));
-  
+
   g_object_unref (colorsel);
 }
 
@@ -2258,19 +2286,19 @@ update_palette (GtkColorSelection *colorsel)
   gint i, j;
 
   current_colors = get_current_colors (colorsel);
-  
+
   for (i = 0; i < GTK_CUSTOM_PALETTE_HEIGHT; i++)
     {
       for (j = 0; j < GTK_CUSTOM_PALETTE_WIDTH; j++)
-       {
+        {
           gint index;
 
           index = i * GTK_CUSTOM_PALETTE_WIDTH + j;
-          
+
           gtk_color_selection_set_palette_color (colorsel,
                                                  index,
                                                  &current_colors[index]);
-       }
+        }
     }
 
   g_free (current_colors);
@@ -2286,18 +2314,18 @@ palette_change_notify_instance (GObject    *object,
 
 static void
 default_noscreen_change_palette_func (const GdkColor *colors,
-                                     gint            n_colors)
+                                      gint            n_colors)
 {
   default_change_palette_func (gdk_screen_get_default (), colors, n_colors);
 }
 
 static void
-default_change_palette_func (GdkScreen     *screen,
-                            const GdkColor *colors,
+default_change_palette_func (GdkScreen      *screen,
+                             const GdkColor *colors,
                              gint            n_colors)
 {
   gchar *str;
-  
+
   str = gtk_color_selection_palette_to_string (colors, n_colors);
 
   gtk_settings_set_string_property (gtk_settings_get_for_screen (screen),
@@ -2310,11 +2338,11 @@ default_change_palette_func (GdkScreen      *screen,
 
 /**
  * gtk_color_selection_new:
- * 
+ *
  * Creates a new GtkColorSelection.
- * 
+ *
  * Return value: a new #GtkColorSelection
- **/
+ */
 GtkWidget *
 gtk_color_selection_new (void)
 {
@@ -2325,125 +2353,125 @@ gtk_color_selection_new (void)
   color[1] = 1.0;
   color[2] = 1.0;
   color[3] = 1.0;
-  
+
   colorsel = g_object_new (GTK_TYPE_COLOR_SELECTION, NULL);
   priv = colorsel->private_data;
   set_color_internal (colorsel, color);
   gtk_color_selection_set_has_opacity_control (colorsel, TRUE);
-  
-  /* We want to make sure that default_set is FALSE */
-  /* This way the user can still set it */
+
+  /* We want to make sure that default_set is FALSE.
+   * This way the user can still set it.
+   */
   priv->default_set = FALSE;
   priv->default_alpha_set = FALSE;
-  
+
   return GTK_WIDGET (colorsel);
 }
 
 /**
  * gtk_color_selection_get_has_opacity_control:
- * @colorsel: a #GtkColorSelection.
- * 
+ * @colorsel: a #GtkColorSelection
+ *
  * Determines whether the colorsel has an opacity control.
- * 
- * Return value: %TRUE if the @colorsel has an opacity control.  %FALSE if it does't.
- **/
+ *
+ * Return value: %TRUE if the @colorsel has an opacity control,
+ *     %FALSE if it does't
+ */
 gboolean
 gtk_color_selection_get_has_opacity_control (GtkColorSelection *colorsel)
 {
   GtkColorSelectionPrivate *priv;
-  
+
   g_return_val_if_fail (GTK_IS_COLOR_SELECTION (colorsel), FALSE);
-  
+
   priv = colorsel->private_data;
-  
+
   return priv->has_opacity;
 }
 
 /**
  * gtk_color_selection_set_has_opacity_control:
- * @colorsel: a #GtkColorSelection.
- * @has_opacity: %TRUE if @colorsel can set the opacity, %FALSE otherwise.
+ * @colorsel: a #GtkColorSelection
+ * @has_opacity: %TRUE if @colorsel can set the opacity, %FALSE otherwise
  *
  * Sets the @colorsel to use or not use opacity.
- * 
- **/
+ */
 void
 gtk_color_selection_set_has_opacity_control (GtkColorSelection *colorsel,
-                                            gboolean           has_opacity)
+                                             gboolean           has_opacity)
 {
   GtkColorSelectionPrivate *priv;
-  
+
   g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
-  
+
   priv = colorsel->private_data;
   has_opacity = has_opacity != FALSE;
-  
+
   if (priv->has_opacity != has_opacity)
     {
       priv->has_opacity = has_opacity;
       if (has_opacity)
-       {
-         gtk_widget_show (priv->opacity_slider);
-         gtk_widget_show (priv->opacity_label);
-         gtk_widget_show (priv->opacity_entry);
-       }
+        {
+          gtk_widget_show (priv->opacity_slider);
+          gtk_widget_show (priv->opacity_label);
+          gtk_widget_show (priv->opacity_entry);
+        }
       else
-       {
-         gtk_widget_hide (priv->opacity_slider);
-         gtk_widget_hide (priv->opacity_label);
-         gtk_widget_hide (priv->opacity_entry);
-       }
+        {
+          gtk_widget_hide (priv->opacity_slider);
+          gtk_widget_hide (priv->opacity_label);
+          gtk_widget_hide (priv->opacity_entry);
+        }
       color_sample_update_samples (colorsel);
-      
+
       g_object_notify (G_OBJECT (colorsel), "has-opacity-control");
     }
 }
 
 /**
  * gtk_color_selection_get_has_palette:
- * @colorsel: a #GtkColorSelection.
- * 
+ * @colorsel: a #GtkColorSelection
+ *
  * Determines whether the color selector has a color palette.
- * 
- * Return value: %TRUE if the selector has a palette.  %FALSE if it hasn't.
- **/
+ *
+ * Return value: %TRUE if the selector has a palette, %FALSE if it hasn't
+ */
 gboolean
 gtk_color_selection_get_has_palette (GtkColorSelection *colorsel)
 {
   GtkColorSelectionPrivate *priv;
-  
+
   g_return_val_if_fail (GTK_IS_COLOR_SELECTION (colorsel), FALSE);
-  
+
   priv = colorsel->private_data;
-  
+
   return priv->has_palette;
 }
 
 /**
  * gtk_color_selection_set_has_palette:
- * @colorsel: a #GtkColorSelection.
- * @has_palette: %TRUE if palette is to be visible, %FALSE otherwise.
+ * @colorsel: a #GtkColorSelection
+ * @has_palette: %TRUE if palette is to be visible, %FALSE otherwise
  *
  * Shows and hides the palette based upon the value of @has_palette.
- * 
- **/
+ */
 void
 gtk_color_selection_set_has_palette (GtkColorSelection *colorsel,
-                                    gboolean           has_palette)
+                                     gboolean           has_palette)
 {
   GtkColorSelectionPrivate *priv;
   g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
-  
+
   priv = colorsel->private_data;
   has_palette = has_palette != FALSE;
-  
+
   if (priv->has_palette != has_palette)
     {
       priv->has_palette = has_palette;
       if (has_palette)
-       gtk_widget_show (priv->palette_frame);
+        gtk_widget_show (priv->palette_frame);
       else
-       gtk_widget_hide (priv->palette_frame);
+        gtk_widget_hide (priv->palette_frame);
 
       update_tooltips (colorsel);
 
@@ -2453,19 +2481,21 @@ gtk_color_selection_set_has_palette (GtkColorSelection *colorsel,
 
 /**
  * gtk_color_selection_set_current_color:
- * @colorsel: a #GtkColorSelection.
- * @color: A #GdkColor to set the current color with.
+ * @colorsel: a #GtkColorSelection
+ * @color: a #GdkColor to set the current color with
+ *
+ * Sets the current color to be @color.
  *
- * Sets the current color to be @color.  The first time this is called, it will
- * also set the original color to be @color too.
- **/
+ * The first time this is called, it will also set
+ * the original color to be @color too.
+ */
 void
 gtk_color_selection_set_current_color (GtkColorSelection *colorsel,
-                                      const GdkColor    *color)
+                                       const GdkColor    *color)
 {
   GtkColorSelectionPrivate *priv;
   gint i;
-  
+
   g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
   g_return_if_fail (color != NULL);
 
@@ -2475,15 +2505,15 @@ gtk_color_selection_set_current_color (GtkColorSelection *colorsel,
   priv->color[COLORSEL_GREEN] = SCALE (color->green);
   priv->color[COLORSEL_BLUE] = SCALE (color->blue);
   gtk_rgb_to_hsv (priv->color[COLORSEL_RED],
-                 priv->color[COLORSEL_GREEN],
-                 priv->color[COLORSEL_BLUE],
-                 &priv->color[COLORSEL_HUE],
-                 &priv->color[COLORSEL_SATURATION],
-                 &priv->color[COLORSEL_VALUE]);
+                  priv->color[COLORSEL_GREEN],
+                  priv->color[COLORSEL_BLUE],
+                  &priv->color[COLORSEL_HUE],
+                  &priv->color[COLORSEL_SATURATION],
+                  &priv->color[COLORSEL_VALUE]);
   if (priv->default_set == FALSE)
     {
       for (i = 0; i < COLORSEL_NUM_CHANNELS; i++)
-       priv->old_color[i] = priv->color[i];
+        priv->old_color[i] = priv->color[i];
     }
   priv->default_set = TRUE;
   update_color (colorsel);
@@ -2491,28 +2521,30 @@ gtk_color_selection_set_current_color (GtkColorSelection *colorsel,
 
 /**
  * gtk_color_selection_set_current_alpha:
- * @colorsel: a #GtkColorSelection.
- * @alpha: an integer between 0 and 65535.
+ * @colorsel: a #GtkColorSelection
+ * @alpha: an integer between 0 and 65535
  *
- * Sets the current opacity to be @alpha.  The first time this is called, it will
- * also set the original opacity to be @alpha too.
- **/
+ * Sets the current opacity to be @alpha.
+ *
+ * The first time this is called, it will also set
+ * the original opacity to be @alpha too.
+ */
 void
 gtk_color_selection_set_current_alpha (GtkColorSelection *colorsel,
-                                      guint16            alpha)
+                                       guint16            alpha)
 {
   GtkColorSelectionPrivate *priv;
   gint i;
-  
+
   g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
-  
+
   priv = colorsel->private_data;
   priv->changing = TRUE;
   priv->color[COLORSEL_OPACITY] = SCALE (alpha);
   if (priv->default_alpha_set == FALSE)
     {
       for (i = 0; i < COLORSEL_NUM_CHANNELS; i++)
-       priv->old_color[i] = priv->color[i];
+        priv->old_color[i] = priv->color[i];
     }
   priv->default_alpha_set = TRUE;
   update_color (colorsel);
@@ -2520,20 +2552,20 @@ gtk_color_selection_set_current_alpha (GtkColorSelection *colorsel,
 
 /**
  * gtk_color_selection_get_current_color:
- * @colorsel: a #GtkColorSelection.
- * @color: (out): a #GdkColor to fill in with the current color.
+ * @colorsel: a #GtkColorSelection
+ * @color: (out): a #GdkColor to fill in with the current color
  *
  * Sets @color to be the current color in the GtkColorSelection widget.
- **/
+ */
 void
 gtk_color_selection_get_current_color (GtkColorSelection *colorsel,
-                                      GdkColor          *color)
+                                       GdkColor          *color)
 {
   GtkColorSelectionPrivate *priv;
-  
+
   g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
   g_return_if_fail (color != NULL);
-  
+
   priv = colorsel->private_data;
   color->red = UNSCALE (priv->color[COLORSEL_RED]);
   color->green = UNSCALE (priv->color[COLORSEL_GREEN]);
@@ -2542,53 +2574,55 @@ gtk_color_selection_get_current_color (GtkColorSelection *colorsel,
 
 /**
  * gtk_color_selection_get_current_alpha:
- * @colorsel: a #GtkColorSelection.
+ * @colorsel: a #GtkColorSelection
  *
  * Returns the current alpha value.
  *
- * Return value: an integer between 0 and 65535.
- **/
+ * Return value: an integer between 0 and 65535
+ */
 guint16
 gtk_color_selection_get_current_alpha (GtkColorSelection *colorsel)
 {
   GtkColorSelectionPrivate *priv;
-  
+
   g_return_val_if_fail (GTK_IS_COLOR_SELECTION (colorsel), 0);
-  
+
   priv = colorsel->private_data;
   return priv->has_opacity ? UNSCALE (priv->color[COLORSEL_OPACITY]) : 65535;
 }
 
 /**
  * gtk_color_selection_set_previous_color:
- * @colorsel: a #GtkColorSelection.
- * @color: a #GdkColor to set the previous color with.
+ * @colorsel: a #GtkColorSelection
+ * @color: a #GdkColor to set the previous color with
  *
- * Sets the 'previous' color to be @color.  This function should be called with
- * some hesitations, as it might seem confusing to have that color change.
- * Calling gtk_color_selection_set_current_color() will also set this color the first
- * time it is called.
- **/
+ * Sets the 'previous' color to be @color.
+ *
+ * This function should be called with some hesitations,
+ * as it might seem confusing to have that color change.
+ * Calling gtk_color_selection_set_current_color() will also
+ * set this color the first time it is called.
+ */
 void
 gtk_color_selection_set_previous_color (GtkColorSelection *colorsel,
-                                       const GdkColor    *color)
+                                        const GdkColor    *color)
 {
   GtkColorSelectionPrivate *priv;
-  
+
   g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
   g_return_if_fail (color != NULL);
-  
+
   priv = colorsel->private_data;
   priv->changing = TRUE;
   priv->old_color[COLORSEL_RED] = SCALE (color->red);
   priv->old_color[COLORSEL_GREEN] = SCALE (color->green);
   priv->old_color[COLORSEL_BLUE] = SCALE (color->blue);
   gtk_rgb_to_hsv (priv->old_color[COLORSEL_RED],
-                 priv->old_color[COLORSEL_GREEN],
-                 priv->old_color[COLORSEL_BLUE],
-                 &priv->old_color[COLORSEL_HUE],
-                 &priv->old_color[COLORSEL_SATURATION],
-                 &priv->old_color[COLORSEL_VALUE]);
+                  priv->old_color[COLORSEL_GREEN],
+                  priv->old_color[COLORSEL_BLUE],
+                  &priv->old_color[COLORSEL_HUE],
+                  &priv->old_color[COLORSEL_SATURATION],
+                  &priv->old_color[COLORSEL_VALUE]);
   color_sample_update_samples (colorsel);
   priv->default_set = TRUE;
   priv->changing = FALSE;
@@ -2596,20 +2630,22 @@ gtk_color_selection_set_previous_color (GtkColorSelection *colorsel,
 
 /**
  * gtk_color_selection_set_previous_alpha:
- * @colorsel: a #GtkColorSelection.
- * @alpha: an integer between 0 and 65535.
+ * @colorsel: a #GtkColorSelection
+ * @alpha: an integer between 0 and 65535
  *
- * Sets the 'previous' alpha to be @alpha.  This function should be called with
- * some hesitations, as it might seem confusing to have that alpha change.
- **/
+ * Sets the 'previous' alpha to be @alpha.
+ *
+ * This function should be called with some hesitations,
+ * as it might seem confusing to have that alpha change.
+ */
 void
 gtk_color_selection_set_previous_alpha (GtkColorSelection *colorsel,
-                                       guint16            alpha)
+                                        guint16            alpha)
 {
   GtkColorSelectionPrivate *priv;
-  
+
   g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
-  
+
   priv = colorsel->private_data;
   priv->changing = TRUE;
   priv->old_color[COLORSEL_OPACITY] = SCALE (alpha);
@@ -2621,20 +2657,20 @@ gtk_color_selection_set_previous_alpha (GtkColorSelection *colorsel,
 
 /**
  * gtk_color_selection_get_previous_color:
- * @colorsel: a #GtkColorSelection.
- * @color: a #GdkColor to fill in with the original color value.
+ * @colorsel: a #GtkColorSelection
+ * @color: (out): a #GdkColor to fill in with the original color value
  *
  * Fills @color in with the original color value.
- **/
+ */
 void
 gtk_color_selection_get_previous_color (GtkColorSelection *colorsel,
-                                       GdkColor           *color)
+                                        GdkColor           *color)
 {
   GtkColorSelectionPrivate *priv;
-  
+
   g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
   g_return_if_fail (color != NULL);
-  
+
   priv = colorsel->private_data;
   color->red = UNSCALE (priv->old_color[COLORSEL_RED]);
   color->green = UNSCALE (priv->old_color[COLORSEL_GREEN]);
@@ -2643,33 +2679,35 @@ gtk_color_selection_get_previous_color (GtkColorSelection *colorsel,
 
 /**
  * gtk_color_selection_get_previous_alpha:
- * @colorsel: a #GtkColorSelection.
+ * @colorsel: a #GtkColorSelection
  *
  * Returns the previous alpha value.
  *
- * Return value: an integer between 0 and 65535.
- **/
+ * Return value: an integer between 0 and 65535
+ */
 guint16
 gtk_color_selection_get_previous_alpha (GtkColorSelection *colorsel)
 {
   GtkColorSelectionPrivate *priv;
-  
+
   g_return_val_if_fail (GTK_IS_COLOR_SELECTION (colorsel), 0);
-  
+
   priv = colorsel->private_data;
   return priv->has_opacity ? UNSCALE (priv->old_color[COLORSEL_OPACITY]) : 65535;
 }
 
 /**
  * gtk_color_selection_set_current_rgba:
- * @colorsel: a #GtkColorSelection.
+ * @colorsel: a #GtkColorSelection
  * @rgba: A #GdkRGBA to set the current color with
  *
- * Sets the current color to be @rgba.  The first time this is called, it will
- * also set the original color to be @rgba too.
+ * Sets the current color to be @rgba.
+ *
+ * The first time this is called, it will also set
+ * the original color to be @rgba too.
  *
  * Since: 3.0
- **/
+ */
 void
 gtk_color_selection_set_current_rgba (GtkColorSelection *colorsel,
                                       const GdkRGBA     *rgba)
@@ -2689,16 +2727,16 @@ gtk_color_selection_set_current_rgba (GtkColorSelection *colorsel,
   priv->color[COLORSEL_OPACITY] = CLAMP (rgba->alpha, 0, 1);
 
   gtk_rgb_to_hsv (priv->color[COLORSEL_RED],
-                 priv->color[COLORSEL_GREEN],
-                 priv->color[COLORSEL_BLUE],
-                 &priv->color[COLORSEL_HUE],
-                 &priv->color[COLORSEL_SATURATION],
-                 &priv->color[COLORSEL_VALUE]);
+                  priv->color[COLORSEL_GREEN],
+                  priv->color[COLORSEL_BLUE],
+                  &priv->color[COLORSEL_HUE],
+                  &priv->color[COLORSEL_SATURATION],
+                  &priv->color[COLORSEL_VALUE]);
 
   if (priv->default_set == FALSE)
     {
       for (i = 0; i < COLORSEL_NUM_CHANNELS; i++)
-       priv->old_color[i] = priv->color[i];
+        priv->old_color[i] = priv->color[i];
     }
 
   priv->default_set = TRUE;
@@ -2707,13 +2745,13 @@ gtk_color_selection_set_current_rgba (GtkColorSelection *colorsel,
 
 /**
  * gtk_color_selection_get_current_rgba:
- * @colorsel: a #GtkColorSelection.
- * @rgba: (out): a #GdkRGBA to fill in with the current color.
+ * @colorsel: a #GtkColorSelection
+ * @rgba: (out): a #GdkRGBA to fill in with the current color
  *
  * Sets @rgba to be the current color in the GtkColorSelection widget.
  *
  * Since: 3.0
- **/
+ */
 void
 gtk_color_selection_get_current_rgba (GtkColorSelection *colorsel,
                                       GdkRGBA           *rgba)
@@ -2732,16 +2770,18 @@ gtk_color_selection_get_current_rgba (GtkColorSelection *colorsel,
 
 /**
  * gtk_color_selection_set_previous_rgba:
- * @colorsel: a #GtkColorSelection.
+ * @colorsel: a #GtkColorSelection
  * @rgba: a #GdkRGBA to set the previous color with
  *
- * Sets the 'previous' color to be @rgba.  This function should be called with
- * some hesitations, as it might seem confusing to have that color change.
- * Calling gtk_color_selection_set_current_rgba() will also set this color the first
- * time it is called.
+ * Sets the 'previous' color to be @rgba.
+ *
+ * This function should be called with some hesitations,
+ * as it might seem confusing to have that color change.
+ * Calling gtk_color_selection_set_current_rgba() will also
+ * set this color the first time it is called.
  *
  * Since: 3.0
- **/
+ */
 void
 gtk_color_selection_set_previous_rgba (GtkColorSelection *colorsel,
                                        const GdkRGBA     *rgba)
@@ -2760,11 +2800,11 @@ gtk_color_selection_set_previous_rgba (GtkColorSelection *colorsel,
   priv->old_color[COLORSEL_OPACITY] = CLAMP (rgba->alpha, 0, 1);
 
   gtk_rgb_to_hsv (priv->old_color[COLORSEL_RED],
-                 priv->old_color[COLORSEL_GREEN],
-                 priv->old_color[COLORSEL_BLUE],
-                 &priv->old_color[COLORSEL_HUE],
-                 &priv->old_color[COLORSEL_SATURATION],
-                 &priv->old_color[COLORSEL_VALUE]);
+                  priv->old_color[COLORSEL_GREEN],
+                  priv->old_color[COLORSEL_BLUE],
+                  &priv->old_color[COLORSEL_HUE],
+                  &priv->old_color[COLORSEL_SATURATION],
+                  &priv->old_color[COLORSEL_VALUE]);
 
   color_sample_update_samples (colorsel);
   priv->default_set = TRUE;
@@ -2773,13 +2813,13 @@ gtk_color_selection_set_previous_rgba (GtkColorSelection *colorsel,
 
 /**
  * gtk_color_selection_get_previous_rgba:
- * @colorsel: a #GtkColorSelection.
- * @rgba: a #GdkRGBA to fill in with the original color value.
+ * @colorsel: a #GtkColorSelection
+ * @rgba: (out): a #GdkRGBA to fill in with the original color value
  *
  * Fills @rgba in with the original color value.
  *
  * Since: 3.0
- **/
+ */
 void
 gtk_color_selection_get_previous_rgba (GtkColorSelection *colorsel,
                                        GdkRGBA           *rgba)
@@ -2798,80 +2838,80 @@ gtk_color_selection_get_previous_rgba (GtkColorSelection *colorsel,
 
 /**
  * gtk_color_selection_set_palette_color:
- * @colorsel: a #GtkColorSelection.
- * @index: the color index of the palette.
- * @color: A #GdkColor to set the palette with.
+ * @colorsel: a #GtkColorSelection
+ * @index: the color index of the palette
+ * @color: A #GdkColor to set the palette with
  *
  * Sets the palette located at @index to have @color as its color.
- * 
- **/
+ */
 static void
-gtk_color_selection_set_palette_color (GtkColorSelection   *colorsel,
-                                      gint                 index,
-                                      GdkColor            *color)
+gtk_color_selection_set_palette_color (GtkColorSelection *colorsel,
+                                       gint               index,
+                                       GdkColor          *color)
 {
   GtkColorSelectionPrivate *priv;
   gint x, y;
   gdouble col[3];
-  
+
   g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
   g_return_if_fail (index >= 0  && index < GTK_CUSTOM_PALETTE_WIDTH*GTK_CUSTOM_PALETTE_HEIGHT);
 
   x = index % GTK_CUSTOM_PALETTE_WIDTH;
   y = index / GTK_CUSTOM_PALETTE_WIDTH;
-  
+
   priv = colorsel->private_data;
   col[0] = SCALE (color->red);
   col[1] = SCALE (color->green);
   col[2] = SCALE (color->blue);
-  
+
   palette_set_color (priv->custom_palette[x][y], colorsel, col);
 }
 
 /**
  * gtk_color_selection_is_adjusting:
- * @colorsel: a #GtkColorSelection.
+ * @colorsel: a #GtkColorSelection
  *
  * Gets the current state of the @colorsel.
  *
- * Return value: %TRUE if the user is currently dragging a color around, and %FALSE
- * if the selection has stopped.
- **/
+ * Return value: %TRUE if the user is currently dragging
+ *     a color around, and %FALSE if the selection has stopped
+ */
 gboolean
 gtk_color_selection_is_adjusting (GtkColorSelection *colorsel)
 {
   GtkColorSelectionPrivate *priv;
-  
+
   g_return_val_if_fail (GTK_IS_COLOR_SELECTION (colorsel), FALSE);
-  
+
   priv = colorsel->private_data;
-  
+
   return (gtk_hsv_is_adjusting (GTK_HSV (priv->triangle_colorsel)));
 }
 
 
 /**
  * gtk_color_selection_palette_from_string:
- * @str: a string encoding a color palette.
- * @colors: return location for allocated array of #GdkColor.
- * @n_colors: return location for length of array.
- * 
+ * @str: a string encoding a color palette
+ * @colors: (out) (array length=n_colors): return location for
+ *     allocated array of #GdkColor
+ * @n_colors: return location for length of array
+ *
  * Parses a color palette string; the string is a colon-separated
  * list of color names readable by gdk_color_parse().
- * 
- * Return value: %TRUE if a palette was successfully parsed.
- **/
+ *
+ * Return value: %TRUE if a palette was successfully parsed
+ */
 gboolean
-gtk_color_selection_palette_from_string (const gchar *str,
-                                         GdkColor   **colors,
-                                         gint        *n_colors)
+gtk_color_selection_palette_from_string (const gchar  *str,
+                                         GdkColor    **colors,
+                                         gint         *n_colors)
 {
   GdkColor *retval;
   gint count;
   gchar *p;
   gchar *start;
   gchar *copy;
-  
+
   count = 0;
   retval = NULL;
   copy = g_strdup (str);
@@ -2888,7 +2928,7 @@ gtk_color_selection_palette_from_string (const gchar *str,
             {
               goto failed; /* empty entry */
             }
-              
+
           if (*p)
             {
               *p = '\0';
@@ -2913,7 +2953,7 @@ gtk_color_selection_palette_from_string (const gchar *str,
     }
 
   g_free (copy);
-  
+
   if (colors)
     *colors = retval;
   else
@@ -2923,7 +2963,7 @@ gtk_color_selection_palette_from_string (const gchar *str,
     *n_colors = count;
 
   return TRUE;
-  
+
  failed:
   g_free (copy);
   g_free (retval);
@@ -2938,13 +2978,13 @@ gtk_color_selection_palette_from_string (const gchar *str,
 
 /**
  * gtk_color_selection_palette_to_string:
- * @colors: an array of colors.
- * @n_colors: length of the array.
- * 
+ * @colors: (array length=n_colors): an array of colors
+ * @n_colors: length of the array
+ *
  * Encodes a palette as a string, useful for persistent storage.
- * 
- * Return value: allocated string encoding the palette.
- **/
+ *
+ * Return value: allocated string encoding the palette
+ */
 gchar*
 gtk_color_selection_palette_to_string (const GdkColor *colors,
                                        gint            n_colors)
@@ -2952,7 +2992,7 @@ gtk_color_selection_palette_to_string (const GdkColor *colors,
   gint i;
   gchar **strs = NULL;
   gchar *retval;
-  
+
   if (n_colors == 0)
     return g_strdup ("");
 
@@ -2962,7 +3002,7 @@ gtk_color_selection_palette_to_string (const GdkColor *colors,
   while (i < n_colors)
     {
       gchar *ptr;
-      
+
       strs[i] =
         g_strdup_printf ("#%2X%2X%2X",
                          colors[i].red / 256,
@@ -2972,7 +3012,7 @@ gtk_color_selection_palette_to_string (const GdkColor *colors,
       for (ptr = strs[i]; *ptr; ptr++)
         if (*ptr == ' ')
           *ptr = '0';
-      
+
       ++i;
     }
 
@@ -2984,18 +3024,20 @@ gtk_color_selection_palette_to_string (const GdkColor *colors,
 }
 
 /**
- * gtk_color_selection_set_change_palette_with_screen_hook:
- * @func: a function to call when the custom palette needs saving.
- * 
- * Installs a global function to be called whenever the user tries to
- * modify the palette in a color selection. This function should save
- * the new palette contents, and update the GtkSettings property
- * "gtk-color-palette" so all GtkColorSelection widgets will be modified.
- * 
- * Return value: the previous change palette hook (that was replaced).
+ * gtk_color_selection_set_change_palette_with_screen_hook: (skip)
+ * @func: a function to call when the custom palette needs saving
+ *
+ * Installs a global function to be called whenever the user
+ * tries to modify the palette in a color selection.
+ *
+ * This function should save the new palette contents, and update
+ * the #GtkSettings::gtk-color-palette GtkSettings property so all
+ * GtkColorSelection widgets will be modified.
+ *
+ * Return value: the previous change palette hook (that was replaced)
  *
  * Since: 2.2
- **/
+ */
 GtkColorSelectionChangePaletteWithScreenFunc
 gtk_color_selection_set_change_palette_with_screen_hook (GtkColorSelectionChangePaletteWithScreenFunc func)
 {
@@ -3020,7 +3062,7 @@ make_control_relations (AtkObject *atk_obj,
 }
 
 static void
-make_all_relations (AtkObject *atk_obj,
+make_all_relations (AtkObject                *atk_obj,
                     GtkColorSelectionPrivate *priv)
 {
   make_control_relations (atk_obj, priv->hue_spinbutton);