]> git.sur5r.net Git - glabels/commitdiff
2009-09-06 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Sun, 6 Sep 2009 04:52:05 +0000 (04:52 +0000)
committerJim Evins <evins@snaught.com>
Sun, 6 Sep 2009 04:52:05 +0000 (04:52 +0000)
Some major refinements to the glColorCombo family of widgets.

* src/Makefile.am:
* src/color-button.c:
* src/color-button.h:
New widget: glColorButton.  This widget is a button that applies
the currently selected color with a ColorCombo type dropdown button
to change that selected color.  This is basically the old
glColorCombo widget.
* src/color-combo.c: (gl_color_combo_init),
(gl_color_combo_finalize), (gl_color_combo_new),
(button_press_event_cb), (menu_color_changed_cb),
(menu_selection_done_cb):
* src/color-combo.h:
The glColorCombo widget has been modified to be a single button
that is only used to change the selected color.
* src/color-swatch.c: (gl_color_swatch_init), (expose_event_cb):
Draw on parent containers window to allow an effective
transparency.
* src/object-editor-bc-page.c: (gl_object_editor_prepare_bc_page):
* src/object-editor-fill-page.c:
(gl_object_editor_prepare_fill_page):
* src/object-editor-line-page.c:
(gl_object_editor_prepare_line_page):
* src/object-editor-shadow-page.c:
(gl_object_editor_prepare_shadow_page):
* src/object-editor-text-page.c:
(gl_object_editor_prepare_text_page):
* src/prefs-dialog.c: (construct_object_page):
Change how ColorCombos are packed so that they don't
expand to fill hbox.
* src/ui-property-bar.c: (gl_ui_property_bar_construct),
(reset_to_default_properties), (update_text_properties),
(update_fill_color), (update_line_color), (text_color_changed_cb),
(fill_color_changed_cb), (line_color_changed_cb),
(set_doc_items_sensitive), (set_text_items_sensitive),
(set_fill_items_sensitive), (set_line_color_items_sensitive):
The property bar now uses the new glColorButton instead of
glColorCombo.

git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@869 f5e0f49d-192f-0410-a22d-a8d8700d0965

14 files changed:
glabels2/ChangeLog
glabels2/src/Makefile.am
glabels2/src/color-button.c [new file with mode: 0644]
glabels2/src/color-button.h [new file with mode: 0644]
glabels2/src/color-combo.c
glabels2/src/color-combo.h
glabels2/src/color-swatch.c
glabels2/src/object-editor-bc-page.c
glabels2/src/object-editor-fill-page.c
glabels2/src/object-editor-line-page.c
glabels2/src/object-editor-shadow-page.c
glabels2/src/object-editor-text-page.c
glabels2/src/prefs-dialog.c
glabels2/src/ui-property-bar.c

index 2db7c97598330193811f82202f79ce03958cc878..44cc7ed089710b07cb603625e62fc87a9843593a 100644 (file)
@@ -1,3 +1,45 @@
+2009-09-06  Jim Evins  <evins@snaught.com>
+
+       Some major refinements to the glColorCombo family of widgets.
+       
+       * src/Makefile.am:
+       * src/color-button.c:
+       * src/color-button.h:
+               New widget: glColorButton.  This widget is a button that applies
+               the currently selected color with a ColorCombo type dropdown button
+               to change that selected color.  This is basically the old
+               glColorCombo widget.
+       * src/color-combo.c: (gl_color_combo_init),
+       (gl_color_combo_finalize), (gl_color_combo_new),
+       (button_press_event_cb), (menu_color_changed_cb),
+       (menu_selection_done_cb):
+       * src/color-combo.h:
+               The glColorCombo widget has been modified to be a single button
+               that is only used to change the selected color.
+       * src/color-swatch.c: (gl_color_swatch_init), (expose_event_cb):
+               Draw on parent containers window to allow an effective
+               transparency.
+       * src/object-editor-bc-page.c: (gl_object_editor_prepare_bc_page):
+       * src/object-editor-fill-page.c:
+       (gl_object_editor_prepare_fill_page):
+       * src/object-editor-line-page.c:
+       (gl_object_editor_prepare_line_page):
+       * src/object-editor-shadow-page.c:
+       (gl_object_editor_prepare_shadow_page):
+       * src/object-editor-text-page.c:
+       (gl_object_editor_prepare_text_page):
+       * src/prefs-dialog.c: (construct_object_page):
+               Change how ColorCombos are packed so that they don't
+               expand to fill hbox.
+       * src/ui-property-bar.c: (gl_ui_property_bar_construct),
+       (reset_to_default_properties), (update_text_properties),
+       (update_fill_color), (update_line_color), (text_color_changed_cb),
+       (fill_color_changed_cb), (line_color_changed_cb),
+       (set_doc_items_sensitive), (set_text_items_sensitive),
+       (set_fill_items_sensitive), (set_line_color_items_sensitive):
+               The property bar now uses the new glColorButton instead of
+               glColorCombo.
+       
 2009-09-02  Jim Evins  <evins@snaught.com>
 
        * src/Makefile.am:
index bbe278fadff352d58e2c0b6fb65d2924df4b1048..4a2e23325f7844cf2fef8995f3b7900192029c27 100644 (file)
@@ -181,6 +181,8 @@ glabels_SOURCES =                   \
        wdgt-merge-menu.h               \
        color-combo.c                   \
        color-combo.h                   \
+       color-button.c                  \
+       color-button.h                  \
        color-combo-menu.c              \
        color-combo-menu.h              \
        color-combo-color-menu-item.c   \
diff --git a/glabels2/src/color-button.c b/glabels2/src/color-button.c
new file mode 100644 (file)
index 0000000..b4645d7
--- /dev/null
@@ -0,0 +1,434 @@
+/*
+ *  color-button.c
+ *  Copyright (C) 2008-2009  Jim Evins <evins@snaught.com>.
+ *
+ *  This file is part of gLabels.
+ *
+ *  gLabels is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  gLabels is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with gLabels.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "color-button.h"
+
+#include "color-combo-menu.h"
+#include <glib/gi18n.h>
+#include <gtk/gtktogglebutton.h>
+#include <gtk/gtkvbox.h>
+#include "color-swatch.h"
+#include <gtk/gtkarrow.h>
+#include "marshal.h"
+#include "color.h"
+
+
+#define IMAGE_W 24
+#define IMAGE_H 24
+
+#define SWATCH_H 5
+
+
+/*========================================================*/
+/* Private types.                                         */
+/*========================================================*/
+
+/** GL_COLOR_BUTTON Private fields */
+struct _glColorButtonPrivate {
+
+        guint       color;
+        gboolean    is_default_flag;
+
+        guint       default_color;
+
+        GtkWidget  *button;
+        GtkWidget  *button_vbox;
+        GtkWidget  *swatch;
+        GtkWidget  *dropdown_button;
+
+        GtkWidget  *menu;
+};
+
+enum {
+        COLOR_CHANGED,
+        LAST_SIGNAL
+};
+
+
+/*========================================================*/
+/* Private globals.                                       */
+/*========================================================*/
+
+static guint signals[LAST_SIGNAL] = {0};
+
+
+/*========================================================*/
+/* Private function prototypes.                           */
+/*========================================================*/
+
+static void
+gl_color_button_finalize (GObject *object);
+
+static void
+button_clicked_cb (glColorButton *this);
+
+static GdkPixbuf *
+create_pixbuf (glColorButton   *this,
+               gdouble         w,
+               gdouble         h);
+
+static gboolean
+dropdown_button_press_event_cb (GtkWidget      *widget,
+                                GdkEventButton *event,
+                                glColorButton  *this);
+
+static void
+menu_color_changed_cb (glColorComboMenu        *object,
+                       guint                    color,
+                       gboolean                 is_default,
+                       glColorButton           *this);
+
+static void
+menu_selection_done_cb (GtkMenuShell           *object,
+                        glColorButton          *this);
+
+
+/*****************************************************************************/
+/* Object infrastructure.                                                    */
+/*****************************************************************************/
+G_DEFINE_TYPE (glColorButton, gl_color_button, GTK_TYPE_HBOX);
+
+
+/*****************************************************************************/
+/* Class Init Function.                                                      */
+/*****************************************************************************/
+static void
+gl_color_button_class_init (glColorButtonClass *class)
+{
+        GObjectClass        *gobject_class = (GObjectClass *) class;
+        GtkWidgetClass      *widget_class  = (GtkWidgetClass *) class;
+        glColorButtonClass  *object_class  = (glColorButtonClass *) class;
+
+        gl_color_button_parent_class = g_type_class_peek_parent (class);
+
+        gobject_class->finalize = gl_color_button_finalize;
+
+        signals[COLOR_CHANGED] =
+                g_signal_new ("color_changed",
+                              G_OBJECT_CLASS_TYPE (gobject_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (glColorButtonClass, color_changed),
+                              NULL, NULL,
+                              gl_marshal_VOID__UINT_BOOLEAN,
+                              G_TYPE_NONE,
+                              2, G_TYPE_POINTER, G_TYPE_BOOLEAN);
+
+}
+
+
+/*****************************************************************************/
+/* Object Instance Init Function.                                            */
+/*****************************************************************************/
+static void
+gl_color_button_init (glColorButton *this)
+{
+        GtkWidget *arrow;
+
+        gtk_box_set_spacing (GTK_BOX (this), 0);
+
+        this->priv = g_new0 (glColorButtonPrivate, 1);
+
+        this->priv->button_vbox = gtk_vbox_new (FALSE, 0);
+
+        this->priv->button = gtk_toggle_button_new ();
+        gtk_container_add (GTK_CONTAINER (this->priv->button), this->priv->button_vbox);
+        gtk_button_set_focus_on_click (GTK_BUTTON (this->priv->button), FALSE);
+        g_signal_connect_swapped (this->priv->button, "clicked",
+                          G_CALLBACK(button_clicked_cb), this);
+
+        gtk_box_pack_start (GTK_BOX (this), this->priv->button, FALSE, FALSE, 0);
+
+        this->priv->dropdown_button = gtk_toggle_button_new ();
+        arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN);
+        gtk_container_add (GTK_CONTAINER (this->priv->dropdown_button), arrow);
+        gtk_button_set_relief (GTK_BUTTON (this->priv->dropdown_button), GTK_RELIEF_NONE);
+        gtk_button_set_focus_on_click (GTK_BUTTON (this->priv->dropdown_button), FALSE);
+        g_signal_connect (this->priv->dropdown_button, "button_press_event",
+                          G_CALLBACK(dropdown_button_press_event_cb), this);
+
+        gtk_box_pack_start (GTK_BOX (this), this->priv->dropdown_button, FALSE, FALSE, 0);
+}
+
+
+/*****************************************************************************/
+/* Finalize Method.                                                          */
+/*****************************************************************************/
+static void
+gl_color_button_finalize (GObject *object)
+{
+        glColorButton    *this;
+
+        g_return_if_fail (object && IS_GL_COLOR_BUTTON (object));
+        this = GL_COLOR_BUTTON (object);
+
+        g_free (this->priv);
+
+        G_OBJECT_CLASS (gl_color_button_parent_class)->finalize (object);
+}
+
+
+/*****************************************************************************/
+/** New Object Generator.                                                    */
+/*****************************************************************************/
+GtkWidget *
+gl_color_button_new (GdkPixbuf    *icon,
+                     const gchar  *default_label,
+                     guint         default_color,
+                     guint         color)
+{
+        glColorButton *this;
+        GdkPixbuf     *pixbuf;
+        GtkWidget     *wimage;
+
+        this = g_object_new (TYPE_GL_COLOR_BUTTON, NULL);
+
+        if (!default_label)
+        {
+                default_label = _("Default Color");
+        }
+
+        this->priv->default_color = default_color;
+        this->priv->color = color;
+
+        if (icon)
+        {
+                pixbuf = gdk_pixbuf_new_subpixbuf (icon, 0, 0, IMAGE_W, IMAGE_H-SWATCH_H);
+                wimage = gtk_image_new_from_pixbuf (pixbuf);
+                g_object_unref (G_OBJECT (pixbuf));
+                gtk_box_pack_start (GTK_BOX (this->priv->button_vbox), wimage, FALSE, FALSE, 0);
+
+                this->priv->swatch = gl_color_swatch_new (IMAGE_W, SWATCH_H, color);
+        }
+        else
+        {
+                this->priv->swatch = gl_color_swatch_new (IMAGE_W, IMAGE_H, color);
+        }
+        gtk_box_pack_start (GTK_BOX (this->priv->button_vbox), this->priv->swatch, FALSE, FALSE, 0);
+
+        this->priv->menu = gl_color_combo_menu_new (default_label, color);
+        gtk_widget_show_all (this->priv->menu);
+
+        g_signal_connect (this->priv->menu, "color_changed",
+                          G_CALLBACK (menu_color_changed_cb), this);
+        g_signal_connect (this->priv->menu, "selection_done",
+                          G_CALLBACK (menu_selection_done_cb), this);
+
+        return GTK_WIDGET (this);
+}
+
+
+/*****************************************************************************/
+/* Set color.                                                                */
+/*****************************************************************************/
+void
+gl_color_button_set_color (glColorButton  *this,
+                           guint           color)
+{
+        this->priv->color = color;
+
+        gl_color_swatch_set_color (GL_COLOR_SWATCH (this->priv->swatch), color);
+}
+
+
+/*****************************************************************************/
+/* Set to default color.                                                     */
+/*****************************************************************************/
+void
+gl_color_button_set_to_default (glColorButton  *this)
+{
+        gl_color_button_set_color (this, this->priv->default_color);
+}
+
+/*****************************************************************************/
+/* Get color.                                                                */
+/*****************************************************************************/
+guint
+gl_color_button_get_color (glColorButton  *this,
+                           gboolean       *is_default)
+{
+        if (is_default)
+        {
+                *is_default = this->priv->is_default_flag;
+        }
+
+        return this->priv->color;
+}
+
+
+/*****************************************************************************/
+/** Set relief style.                                                        */
+/*****************************************************************************/
+void
+gl_color_button_set_relief( glColorButton  *this,
+                           GtkReliefStyle   relief )
+{
+        gtk_button_set_relief (GTK_BUTTON (this->priv->button), relief);
+}
+
+
+/*****************************************************************************/
+/* Color button "clicked" callback.                                          */
+/*****************************************************************************/
+static void
+button_clicked_cb( glColorButton *this )
+{
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (this->priv->button),
+                                      FALSE);
+
+        g_signal_emit (this, signals[COLOR_CHANGED], 0,
+                       this->priv->color,
+                       this->priv->is_default_flag);
+}
+
+
+/*****************************************************************************/
+/* Menu positioning function.                                                */
+/*****************************************************************************/
+static void
+menu_position_function (GtkMenu  *menu,
+                        gint     *x,
+                        gint     *y,
+                        gboolean *push_in,
+                        gpointer  user_data)
+{
+        glColorButton *this = GL_COLOR_BUTTON (user_data);
+        gint           x1, y1;
+        gint           menu_h, menu_w;
+
+        gdk_window_get_origin (GTK_WIDGET (this)->window, &x1, &y1);
+        *x = x1 + GTK_WIDGET (this)->allocation.x;
+        *y = y1 + GTK_WIDGET (this)->allocation.y +
+                GTK_WIDGET (this)->allocation.height;
+                
+        menu_h = this->priv->menu->allocation.height;
+        menu_w = this->priv->menu->allocation.width;
+
+        if ((*y + menu_h) > gdk_screen_height ())
+        {
+                *y = y1 + GTK_WIDGET (this)->allocation.y - menu_h;
+                if ( *y < 0 )
+                {
+                        *y = gdk_screen_height () - menu_h;
+                }
+        }
+
+        if ((*x + menu_w) > gdk_screen_width ())
+        {
+                *x = gdk_screen_width () - menu_w;
+        }
+
+        *push_in = TRUE;
+}
+
+
+/*****************************************************************************/
+/* Dropdown button "button_press_event" callback.                            */
+/*****************************************************************************/
+static gboolean
+dropdown_button_press_event_cb (GtkWidget      *widget,
+                                GdkEventButton *event,
+                                glColorButton  *this)
+{
+        switch (event->button)
+        {
+
+        case 1:
+                g_signal_handlers_block_by_func (G_OBJECT (this->priv->button),
+                                                 button_clicked_cb, this);
+                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (this->priv->button),
+                                              TRUE);
+                g_signal_handlers_unblock_by_func (G_OBJECT (this->priv->button),
+                                                   button_clicked_cb, this);
+                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (this->priv->dropdown_button),
+                                              TRUE);
+
+                gtk_menu_popup (GTK_MENU (this->priv->menu),
+                                NULL, NULL,
+                                menu_position_function, this,
+                                event->button, event->time);
+                break;
+
+        default:
+                break;
+
+        }
+
+        return FALSE;
+}
+
+
+/*****************************************************************************/
+/* Menu "color changed" callback.                                          */
+/*****************************************************************************/
+static void
+menu_color_changed_cb (glColorComboMenu     *object,
+                       guint                 color,
+                       gboolean              is_default,
+                       glColorButton         *this)
+{
+        if (is_default)
+        {
+                this->priv->color = this->priv->default_color;
+        }
+        else
+        {
+                this->priv->color = color;
+        }
+        this->priv->is_default_flag = is_default;
+
+        gl_color_swatch_set_color (GL_COLOR_SWATCH (this->priv->swatch),
+                                   this->priv->color);
+
+        g_signal_emit (this, signals[COLOR_CHANGED], 0,
+                       this->priv->color,
+                       this->priv->is_default_flag);
+}
+
+
+/*****************************************************************************/
+/* Menu "color changed" callback.                                            */
+/*****************************************************************************/
+static void
+menu_selection_done_cb (GtkMenuShell         *object,
+                        glColorButton        *this)
+{
+        g_signal_handlers_block_by_func (G_OBJECT (this->priv->button),
+                                         button_clicked_cb, this);
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (this->priv->button),
+                                      FALSE);
+        g_signal_handlers_unblock_by_func (G_OBJECT (this->priv->button),
+                                           button_clicked_cb, this);
+
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (this->priv->dropdown_button),
+                                      FALSE);
+}
+
+
+
+/*
+ * Local Variables:       -- emacs
+ * mode: C                -- emacs
+ * c-basic-offset: 8      -- emacs
+ * tab-width: 8           -- emacs
+ * indent-tabs-mode: nil  -- emacs
+ * End:                   -- emacs
+ */
diff --git a/glabels2/src/color-button.h b/glabels2/src/color-button.h
new file mode 100644 (file)
index 0000000..ad1dfd6
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ *  color-button.h
+ *  Copyright (C) 2008-2009  Jim Evins <evins@snaught.com>.
+ *
+ *  This file is part of gLabels.
+ *
+ *  gLabels is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  gLabels is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with gLabels.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GL_COLOR_BUTTON_H__
+#define __GL_COLOR_BUTTON_H__
+
+
+#include <gtk/gtkhbox.h>
+
+
+G_BEGIN_DECLS
+
+#define TYPE_GL_COLOR_BUTTON              (gl_color_button_get_type ())
+#define GL_COLOR_BUTTON(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GL_COLOR_BUTTON, glColorButton))
+#define GL_COLOR_BUTTON_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GL_COLOR_BUTTON, glColorButtonClass))
+#define IS_GL_COLOR_BUTTON(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GL_COLOR_BUTTON))
+#define IS_GL_COLOR_BUTTON_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GL_COLOR_BUTTON))
+#define GL_COLOR_BUTTON_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), TYPE_GL_COLOR_BUTTON, glColorButtonClass))
+
+
+typedef struct _glColorButton          glColorButton;
+typedef struct _glColorButtonPrivate   glColorButtonPrivate;
+typedef struct _glColorButtonClass     glColorButtonClass;
+
+
+struct _glColorButton {
+        GtkHBox                        parent;
+
+        glColorButtonPrivate          *priv;
+};
+
+struct _glColorButtonClass {
+        GtkHBoxClass                   parent_class;
+
+        /*
+         * Signals
+         */
+        void (*color_changed) (glColorButton *object,
+                               guint         color,
+                               gboolean      is_default,
+                               gpointer      user_data);
+
+};
+
+
+GType            gl_color_button_get_type         (void) G_GNUC_CONST;
+
+GtkWidget       *gl_color_button_new              (GdkPixbuf     *icon,
+                                                   const gchar   *default_label,
+                                                   guint          default_color,
+                                                   guint          color);
+
+void             gl_color_button_set_color        (glColorButton  *this,
+                                                   guint          color);
+
+void             gl_color_button_set_to_default   (glColorButton  *this);
+
+guint            gl_color_button_get_color        (glColorButton  *this,
+                                                   gboolean      *is_default);
+
+void             gl_color_button_set_relief       (glColorButton  *this,
+                                                   GtkReliefStyle relief);
+
+
+G_END_DECLS
+
+#endif /* __GL_COLOR_BUTTON_H__ */
+
+
+
+/*
+ * Local Variables:       -- emacs
+ * mode: C                -- emacs
+ * c-basic-offset: 8      -- emacs
+ * tab-width: 8           -- emacs
+ * indent-tabs-mode: nil  -- emacs
+ * End:                   -- emacs
+ */
index f296f51ea038a386af9ba02ea18db7bab9257b5d..6b9e5761260c575a27f367e037fc4a11a3b8a454 100644 (file)
@@ -24,8 +24,7 @@
 
 #include "color-combo-menu.h"
 #include <glib/gi18n.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkvbox.h>
+#include <gtk/gtkhbox.h>
 #include "color-swatch.h"
 #include <gtk/gtkarrow.h>
 #include "marshal.h"
@@ -35,8 +34,6 @@
 #define IMAGE_W 24
 #define IMAGE_H 24
 
-#define SWATCH_H 5
-
 
 /*========================================================*/
 /* Private types.                                         */
@@ -50,10 +47,7 @@ struct _glColorComboPrivate {
 
         guint       default_color;
 
-        GtkWidget  *button;
-        GtkWidget  *button_vbox;
         GtkWidget  *swatch;
-        GtkWidget  *dropdown_button;
 
         GtkWidget  *menu;
 };
@@ -77,30 +71,31 @@ static guint signals[LAST_SIGNAL] = {0};
 
 static void gl_color_combo_finalize      (GObject             *object);
 
-static void
-button_clicked_cb (glColorCombo *this);
+static gboolean
+button_press_event_cb (GtkWidget      *widget,
+                       GdkEventButton *event,
+                       glColorCombo   *this);
 
 static GdkPixbuf *
 create_pixbuf (glColorCombo   *this,
                gdouble         w,
                gdouble         h);
 
-static gboolean
-dropdown_button_press_event_cb (GtkWidget      *widget,
-                                GdkEventButton *event,
-                                glColorCombo   *this);
-
 static void
 menu_color_changed_cb (glColorComboMenu   *object,
                        guint               color,
                        gboolean            is_default,
                        glColorCombo       *this);
 
+static void
+menu_selection_done_cb (GtkMenuShell      *object,
+                        glColorCombo      *this);
+
 
 /*****************************************************************************/
 /* Object infrastructure.                                                    */
 /*****************************************************************************/
-G_DEFINE_TYPE (glColorCombo, gl_color_combo, GTK_TYPE_HBOX);
+G_DEFINE_TYPE (glColorCombo, gl_color_combo, GTK_TYPE_TOGGLE_BUTTON);
 
 
 /*****************************************************************************/
@@ -136,31 +131,22 @@ gl_color_combo_class_init (glColorComboClass *class)
 static void
 gl_color_combo_init (glColorCombo *this)
 {
+        GtkWidget *hbox;
         GtkWidget *arrow;
 
-        gtk_box_set_spacing (GTK_BOX (this), 0);
-
         this->priv = g_new0 (glColorComboPrivate, 1);
 
-        this->priv->button_vbox = gtk_vbox_new (FALSE, 0);
-
-        this->priv->button = gtk_button_new ();
-        gtk_container_add (GTK_CONTAINER (this->priv->button), this->priv->button_vbox);
-        gtk_button_set_focus_on_click (GTK_BUTTON (this->priv->button), FALSE);
-        g_signal_connect_swapped (this->priv->button, "clicked",
-                          G_CALLBACK(button_clicked_cb), this);
+        hbox = gtk_hbox_new (FALSE, 3);
+        gtk_container_add (GTK_CONTAINER (this), hbox);
+        
+        this->priv->swatch = gl_color_swatch_new (IMAGE_W, IMAGE_H, GL_COLOR_NONE);
+        gtk_box_pack_start (GTK_BOX (hbox), this->priv->swatch, FALSE, FALSE, 0);
 
-        gtk_box_pack_start (GTK_BOX (this), this->priv->button, FALSE, FALSE, 0);
-
-        this->priv->dropdown_button = gtk_button_new ();
         arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN);
-        gtk_container_add (GTK_CONTAINER (this->priv->dropdown_button), arrow);
-        gtk_button_set_relief (GTK_BUTTON (this->priv->dropdown_button), GTK_RELIEF_NONE);
-        gtk_button_set_focus_on_click (GTK_BUTTON (this->priv->dropdown_button), FALSE);
-        g_signal_connect (this->priv->dropdown_button, "button_press_event",
-                          G_CALLBACK(dropdown_button_press_event_cb), this);
+        gtk_box_pack_end (GTK_BOX (hbox), arrow, FALSE, FALSE, 0);
 
-        gtk_box_pack_start (GTK_BOX (this), this->priv->dropdown_button, FALSE, FALSE, 0);
+        g_signal_connect (this, "button_press_event",
+                          G_CALLBACK(button_press_event_cb), this);
 }
 
 
@@ -175,6 +161,7 @@ gl_color_combo_finalize (GObject *object)
         g_return_if_fail (object && IS_GL_COLOR_COMBO (object));
         this = GL_COLOR_COMBO (object);
 
+        g_object_ref_sink (this->priv->menu);
         g_free (this->priv);
 
         G_OBJECT_CLASS (gl_color_combo_parent_class)->finalize (object);
@@ -185,8 +172,7 @@ gl_color_combo_finalize (GObject *object)
 /** New Object Generator.                                                    */
 /*****************************************************************************/
 GtkWidget *
-gl_color_combo_new (GdkPixbuf    *icon,
-                    const gchar  *default_label,
+gl_color_combo_new (const gchar  *default_label,
                     guint         default_color,
                     guint         color)
 {
@@ -204,20 +190,7 @@ gl_color_combo_new (GdkPixbuf    *icon,
         this->priv->default_color = default_color;
         this->priv->color = color;
 
-        if (icon)
-        {
-                pixbuf = gdk_pixbuf_new_subpixbuf (icon, 0, 0, IMAGE_W, IMAGE_H-SWATCH_H);
-                wimage = gtk_image_new_from_pixbuf (pixbuf);
-                g_object_unref (G_OBJECT (pixbuf));
-                gtk_box_pack_start (GTK_BOX (this->priv->button_vbox), wimage, FALSE, FALSE, 0);
-
-                this->priv->swatch = gl_color_swatch_new (IMAGE_W, SWATCH_H, color);
-        }
-        else
-        {
-                this->priv->swatch = gl_color_swatch_new (IMAGE_W, IMAGE_H, color);
-        }
-        gtk_box_pack_start (GTK_BOX (this->priv->button_vbox), this->priv->swatch, FALSE, FALSE, 0);
+        gl_color_swatch_set_color (GL_COLOR_SWATCH (this->priv->swatch), color);
 
         this->priv->menu = gl_color_combo_menu_new (default_label,
                                                     color);
@@ -225,6 +198,8 @@ gl_color_combo_new (GdkPixbuf    *icon,
 
         g_signal_connect (this->priv->menu, "color_changed",
                           G_CALLBACK (menu_color_changed_cb), this);
+        g_signal_connect (this->priv->menu, "selection_done",
+                          G_CALLBACK (menu_selection_done_cb), this);
 
         return GTK_WIDGET (this);
 }
@@ -268,38 +243,15 @@ gl_color_combo_get_color (glColorCombo  *this,
 }
 
 
-/*****************************************************************************/
-/** Set relief style.                                                        */
-/*****************************************************************************/
-void
-gl_color_combo_set_relief( glColorCombo  *this,
-                           GtkReliefStyle relief )
-{
-        gtk_button_set_relief (GTK_BUTTON (this->priv->button), relief);
-}
-
-
-/*****************************************************************************/
-/* Color button "clicked" callback.                                          */
-/*****************************************************************************/
-static void
-button_clicked_cb( glColorCombo *this )
-{
-        g_signal_emit (this, signals[COLOR_CHANGED], 0,
-                       this->priv->color,
-                       this->priv->is_default_flag);
-}
-
-
 /*****************************************************************************/
 /* Menu positioning function.                                                */
 /*****************************************************************************/
 static void
-menu_position_function (GtkMenu *menu,
-                        gint *x,
-                        gint *y,
+menu_position_function (GtkMenu  *menu,
+                        gint     *x,
+                        gint     *y,
                         gboolean *push_in,
-                        gpointer user_data)
+                        gpointer  user_data)
 {
         glColorCombo *this = GL_COLOR_COMBO (user_data);
         gint          x1, y1;
@@ -332,17 +284,19 @@ menu_position_function (GtkMenu *menu,
 
 
 /*****************************************************************************/
-/* Dropdown button "clicked" callback.                                       */
+/* Button "button_press_event" callback.                                     */
 /*****************************************************************************/
 static gboolean
-dropdown_button_press_event_cb (GtkWidget      *widget,
-                                GdkEventButton *event,
-                                glColorCombo   *this)
+button_press_event_cb (GtkWidget      *widget,
+                       GdkEventButton *event,
+                       glColorCombo   *this)
 {
         switch (event->button)
         {
 
         case 1:
+                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (this), TRUE);
+
                 gtk_menu_popup (GTK_MENU (this->priv->menu),
                                 NULL, NULL,
                                 menu_position_function, this,
@@ -359,7 +313,7 @@ dropdown_button_press_event_cb (GtkWidget      *widget,
 
 
 /*****************************************************************************/
-/* Menu "color changed" callback.                                          */
+/* Menu "color changed" callback.                                            */
 /*****************************************************************************/
 static void
 menu_color_changed_cb (glColorComboMenu     *object,
@@ -377,7 +331,8 @@ menu_color_changed_cb (glColorComboMenu     *object,
         }
         this->priv->is_default_flag = is_default;
 
-        gl_color_swatch_set_color (GL_COLOR_SWATCH (this->priv->swatch), color);
+        gl_color_swatch_set_color (GL_COLOR_SWATCH (this->priv->swatch),
+                                   this->priv->color);
 
         g_signal_emit (this, signals[COLOR_CHANGED], 0,
                        this->priv->color,
@@ -385,6 +340,17 @@ menu_color_changed_cb (glColorComboMenu     *object,
 }
 
 
+/*****************************************************************************/
+/* Menu "color changed" callback.                                            */
+/*****************************************************************************/
+static void
+menu_selection_done_cb (GtkMenuShell         *object,
+                        glColorCombo         *this)
+{
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (this), FALSE);
+}
+
+
 
 /*
  * Local Variables:       -- emacs
index 55456b45644d438565acb2a8080334ba4b662e06..6f1d3562e9ad820d6c1df783e0423fd7ba407c68 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  color-combo.h
- *  Copyright (C) 2008  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2008-2009  Jim Evins <evins@snaught.com>.
  *
  *  This file is part of gLabels.
  *
@@ -22,7 +22,7 @@
 #define __GL_COLOR_COMBO_H__
 
 
-#include <gtk/gtkhbox.h>
+#include <gtk/gtktogglebutton.h>
 
 
 G_BEGIN_DECLS
@@ -41,13 +41,13 @@ typedef struct _glColorComboClass     glColorComboClass;
 
 
 struct _glColorCombo {
-        GtkHBox                        parent;
+        GtkToggleButton                parent;
 
         glColorComboPrivate           *priv;
 };
 
 struct _glColorComboClass {
-        GtkHBoxClass                   parent_class;
+        GtkToggleButtonClass           parent_class;
 
         /*
          * Signals
@@ -62,8 +62,7 @@ struct _glColorComboClass {
 
 GType            gl_color_combo_get_type          (void) G_GNUC_CONST;
 
-GtkWidget       *gl_color_combo_new               (GdkPixbuf     *icon,
-                                                   const gchar   *default_label,
+GtkWidget       *gl_color_combo_new               (const gchar   *default_label,
                                                    guint          default_color,
                                                    guint          color);
 
index b0d453e1ebcc39914157489721895df2462a062a..ae72e3dcb990dbf51374da0a733c9094be9dad9a 100644 (file)
@@ -92,6 +92,8 @@ gl_color_swatch_class_init (glColorSwatchClass *class)
 static void
 gl_color_swatch_init (glColorSwatch *this)
 {
+        GTK_WIDGET_SET_FLAGS (GTK_WIDGET (this), GTK_NO_WINDOW);
+
        this->priv = g_new0 (glColorSwatchPrivate, 1);
 }
 
@@ -180,6 +182,8 @@ expose_event_cb (GtkWidget      *widget,
                        event->area.width, event->area.height);
        cairo_clip (cr);
 
+        cairo_translate (cr, widget->allocation.x, widget->allocation.y);
+
        draw_swatch (GL_COLOR_SWATCH (widget), cr);
 
        cairo_destroy (cr);
index 9b13bb1cc17433054ea958d56cb3f3fdf12ed868..eb01b1133c22edf1f3d8cd6110267bbaa25d36d8 100644 (file)
@@ -90,12 +90,12 @@ gl_object_editor_prepare_bc_page (glObjectEditor       *editor)
 
        editor->priv->data_format_fixed_flag = FALSE;
 
-       editor->priv->bc_color_combo = gl_color_combo_new (NULL,
-                                                           _("Default"),
+       editor->priv->bc_color_combo = gl_color_combo_new (_("Default"),
                                                            GL_COLOR_BC_DEFAULT,
                                                            gl_prefs->default_line_color);
-        gtk_container_add (GTK_CONTAINER (editor->priv->bc_color_hbox),
-                           editor->priv->bc_color_combo);
+        gtk_box_pack_start (GTK_BOX (editor->priv->bc_color_hbox),
+                            editor->priv->bc_color_combo,
+                            FALSE, FALSE, 0);
 
        gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->bc_style_combo));
        gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->bc_key_combo));
index f13e19be73d3eaaa717d776ea144876739bf8312..9a7caf9647a60f5ee92f3944b55dfe548005ea38 100644 (file)
@@ -76,12 +76,12 @@ gl_object_editor_prepare_fill_page (glObjectEditor *editor)
                                      "fill_color_radio", &editor->priv->fill_color_radio,
                                      NULL);
        
-       editor->priv->fill_color_combo = gl_color_combo_new (NULL,
-                                                             _("No Fill"),
+       editor->priv->fill_color_combo = gl_color_combo_new (_("No Fill"),
                                                              GL_COLOR_NO_FILL,
                                                              gl_prefs->default_fill_color);
-        gtk_container_add (GTK_CONTAINER (editor->priv->fill_color_hbox),
-                           editor->priv->fill_color_combo);
+        gtk_box_pack_start (GTK_BOX (editor->priv->fill_color_hbox),
+                            editor->priv->fill_color_combo,
+                            FALSE, FALSE, 0);
 
        gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->fill_key_combo));
 
index f870d38c2ddade2f58a406659b3c38fcfd591b16..dbbd545c7075a548d25caea7f6c3ee78c6dbc705 100644 (file)
@@ -78,12 +78,12 @@ gl_object_editor_prepare_line_page (glObjectEditor *editor)
                                      "line_color_radio", &editor->priv->line_color_radio,
                                      NULL);
 
-       editor->priv->line_color_combo = gl_color_combo_new (NULL,
-                                                             _("No Line"),
+       editor->priv->line_color_combo = gl_color_combo_new (_("No Line"),
                                                              GL_COLOR_NO_LINE,
                                                              gl_prefs->default_line_color);
-        gtk_container_add (GTK_CONTAINER (editor->priv->line_color_hbox),
-                           editor->priv->line_color_combo);
+        gtk_box_pack_start (GTK_BOX (editor->priv->line_color_hbox),
+                            editor->priv->line_color_combo,
+                            FALSE, FALSE, 0);
 
        gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->line_key_combo));
 
index 6abcbd7abb773b00e1181f8c5b890f3146e1307f..86a3bc06d75d3880884b7eed6cd88243d918df1d 100644 (file)
@@ -90,8 +90,7 @@ gl_object_editor_prepare_shadow_page (glObjectEditor *editor)
                                      "shadow_opacity_spin",   &editor->priv->shadow_opacity_spin,
                                      NULL);
 
-       editor->priv->shadow_color_combo = gl_color_combo_new (NULL,
-                                                               _("Default"),
+       editor->priv->shadow_color_combo = gl_color_combo_new (_("Default"),
                                                                GL_COLOR_SHADOW_DEFAULT,
                                                                GL_COLOR_SHADOW_DEFAULT);
         gtk_container_add (GTK_CONTAINER (editor->priv->shadow_color_hbox),
index b4bb69fc924d8f6d4f5f08be4072b47de09b984d..fcc088237158779916b7dc94d51130ac04c9e6ab 100644 (file)
@@ -90,12 +90,12 @@ gl_object_editor_prepare_text_page (glObjectEditor       *editor)
                                      "text_auto_shrink_check", &editor->priv->text_auto_shrink_check,
                                      NULL);
 
-       editor->priv->text_color_combo = gl_color_combo_new (NULL,
-                                                             _("Default"),
+       editor->priv->text_color_combo = gl_color_combo_new (_("Default"),
                                                              GL_COLOR_TEXT_DEFAULT,
                                                              gl_prefs->default_text_color);
-        gtk_container_add (GTK_CONTAINER (editor->priv->text_color_hbox),
-                           editor->priv->text_color_combo);
+        gtk_box_pack_start (GTK_BOX (editor->priv->text_color_hbox),
+                            editor->priv->text_color_combo,
+                            FALSE, FALSE, 0);
 
        gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->text_family_combo));
        gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->text_color_key_combo));
index c87d03d98be65a3121fd9cb6fe6121d73771213b..a0f2492356a868a33e8504aee9dd935b58845f08 100644 (file)
@@ -26,6 +26,7 @@
 #include <gtk/gtkbuilder.h>
 #include <gtk/gtktogglebutton.h>
 #include <gtk/gtkstock.h>
+#include <gtk/gtkbox.h>
 #include <gtk/gtkcombobox.h>
 #include <gtk/gtkspinbutton.h>
 
@@ -337,22 +338,25 @@ construct_object_page (glPrefsDialog *dialog)
 
        gl_util_combo_box_add_text_model (GTK_COMBO_BOX (dialog->priv->text_family_combo));
 
-       dialog->priv->text_color_combo = gl_color_combo_new (NULL, _("Default"),
+       dialog->priv->text_color_combo = gl_color_combo_new (_("Default"),
                                                              GL_COLOR_TEXT_DEFAULT,
                                                              gl_prefs->default_text_color);
-       dialog->priv->line_color_combo = gl_color_combo_new (NULL, _("No Line"),
+       dialog->priv->line_color_combo = gl_color_combo_new (_("No Line"),
                                                              GL_COLOR_NO_LINE,
                                                              gl_prefs->default_line_color);
-       dialog->priv->fill_color_combo = gl_color_combo_new (NULL, _("No Fill"),
+       dialog->priv->fill_color_combo = gl_color_combo_new (_("No Fill"),
                                                              GL_COLOR_NO_FILL,
                                                              gl_prefs->default_fill_color);
 
-        gtk_container_add (GTK_CONTAINER (dialog->priv->text_color_hbox),
-                           dialog->priv->text_color_combo);
-        gtk_container_add (GTK_CONTAINER (dialog->priv->line_color_hbox),
-                           dialog->priv->line_color_combo);
-        gtk_container_add (GTK_CONTAINER (dialog->priv->fill_color_hbox),
-                           dialog->priv->fill_color_combo);
+        gtk_box_pack_start (GTK_BOX (dialog->priv->text_color_hbox),
+                            dialog->priv->text_color_combo,
+                            FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (dialog->priv->line_color_hbox),
+                            dialog->priv->line_color_combo,
+                            FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_CONTAINER (dialog->priv->fill_color_hbox),
+                            dialog->priv->fill_color_combo,
+                            FALSE, FALSE, 0);
 
         /* Load family names */
         family_names = gl_util_get_font_family_list ();
index 2a5f48a6879e600e51afe61f55cda003b08a8207..644748f8273f211c5753c0d650e431cf5ca41746 100644 (file)
@@ -31,7 +31,7 @@
 #include <string.h>
 
 #include "util.h"
-#include "color-combo.h"
+#include "color-button.h"
 #include "stock-pixmaps/stockpixbufs.h"
 #include "prefs.h"
 #include "color.h"
@@ -69,10 +69,10 @@ struct _glUIPropertyBarPrivate {
 
        /* Color combos */
         GtkWidget  *text_color_eventbox;
-       GtkWidget  *text_color_combo;
-       GtkWidget  *fill_color_combo;
+       GtkWidget  *text_color_button;
+       GtkWidget  *fill_color_button;
         GtkWidget  *fill_color_eventbox;
-       GtkWidget  *line_color_combo;
+       GtkWidget  *line_color_button;
         GtkWidget  *line_color_eventbox;
 
        /* Line width */
@@ -104,17 +104,17 @@ static void     font_family_changed_cb           (GtkComboBox          *combo,
 static void     font_size_changed_cb             (GtkSpinButton        *spin,
                                                  glUIPropertyBar      *this);
 
-static void     text_color_changed_cb            (glColorCombo         *cc,
+static void     text_color_changed_cb            (glColorButton        *cc,
                                                   guint                 color,
                                                  gboolean              is_default,
                                                  glUIPropertyBar      *this);
 
-static void     fill_color_changed_cb            (glColorCombo         *cc,
+static void     fill_color_changed_cb            (glColorButton        *cc,
                                                   guint                 color,
                                                  gboolean              is_default,
                                                  glUIPropertyBar      *this);
 
-static void     line_color_changed_cb            (glColorCombo         *cc,
+static void     line_color_changed_cb            (glColorButton        *cc,
                                                   guint                 color,
                                                  gboolean              is_default,
                                                  glUIPropertyBar      *this);
@@ -273,40 +273,40 @@ gl_ui_property_bar_construct (glUIPropertyBar   *this)
        gtk_container_add (GTK_CONTAINER (this), this->priv->tool_bar);
 
         pixbuf = gdk_pixbuf_new_from_inline (-1, stock_text_24, FALSE, NULL);
-        this->priv->text_color_combo =
-                gl_color_combo_new (pixbuf,
-                                    _("Default"),
-                                    GL_COLOR_TEXT_DEFAULT,
-                                    gl_prefs->default_text_color);
-       gl_color_combo_set_relief (GL_COLOR_COMBO(this->priv->text_color_combo),
-                                   GTK_RELIEF_NONE);
+        this->priv->text_color_button =
+                gl_color_button_new (pixbuf,
+                                     _("Default"),
+                                     GL_COLOR_TEXT_DEFAULT,
+                                     gl_prefs->default_text_color);
+        gl_color_button_set_relief (GL_COLOR_BUTTON(this->priv->text_color_button),
+                                    GTK_RELIEF_NONE);
        g_object_unref (G_OBJECT (pixbuf));
         gtk_container_add (GTK_CONTAINER (this->priv->text_color_eventbox),
-                           this->priv->text_color_combo);
+                           this->priv->text_color_button);
 
         pixbuf = gdk_pixbuf_new_from_inline (-1, stock_bucket_fill_24, FALSE, NULL);
-        this->priv->fill_color_combo =
-                gl_color_combo_new (pixbuf,
-                                    _("No Fill"),
-                                    GL_COLOR_NO_FILL,
-                                    gl_prefs->default_fill_color);
-       gl_color_combo_set_relief (GL_COLOR_COMBO(this->priv->fill_color_combo),
-                                   GTK_RELIEF_NONE);
+        this->priv->fill_color_button =
+                gl_color_button_new (pixbuf,
+                                     _("No Fill"),
+                                     GL_COLOR_NO_FILL,
+                                     gl_prefs->default_fill_color);
+        gl_color_button_set_relief (GL_COLOR_BUTTON(this->priv->fill_color_button),
+                                    GTK_RELIEF_NONE);
        g_object_unref (G_OBJECT (pixbuf));
         gtk_container_add (GTK_CONTAINER (this->priv->fill_color_eventbox),
-                           this->priv->fill_color_combo);
+                           this->priv->fill_color_button);
 
         pixbuf = gdk_pixbuf_new_from_inline (-1, stock_pencil_24, FALSE, NULL);
-        this->priv->line_color_combo =
-                gl_color_combo_new (pixbuf,
-                                    _("No Line"),
-                                    GL_COLOR_NO_LINE,
-                                    gl_prefs->default_line_color);
-       gl_color_combo_set_relief (GL_COLOR_COMBO(this->priv->line_color_combo),
-                                   GTK_RELIEF_NONE);
+        this->priv->line_color_button =
+                gl_color_button_new (pixbuf,
+                                     _("No Line"),
+                                     GL_COLOR_NO_LINE,
+                                     gl_prefs->default_line_color);
+       gl_color_button_set_relief (GL_COLOR_BUTTON(this->priv->line_color_button),
+                                    GTK_RELIEF_NONE);
        g_object_unref (G_OBJECT (pixbuf));
         gtk_container_add (GTK_CONTAINER (this->priv->line_color_eventbox),
-                           this->priv->line_color_combo);
+                           this->priv->line_color_button);
 
         /* Save reference to gui tree so we don't lose tooltips */
         this->priv->builder = builder;
@@ -372,20 +372,20 @@ gl_ui_property_bar_construct (glUIPropertyBar   *this)
                          "toggled", G_CALLBACK (text_align_toggled_cb), this);
 
        /* Text color widget */
-       gl_color_combo_set_color (GL_COLOR_COMBO (this->priv->text_color_combo), gl_prefs->default_text_color);
-       g_signal_connect (G_OBJECT (this->priv->text_color_combo),
+       gl_color_button_set_color (GL_COLOR_BUTTON (this->priv->text_color_button), gl_prefs->default_text_color);
+       g_signal_connect (G_OBJECT (this->priv->text_color_button),
                          "color_changed",
                          G_CALLBACK (text_color_changed_cb), this);
 
        /* Fill color widget */
-       gl_color_combo_set_color (GL_COLOR_COMBO (this->priv->fill_color_combo), gl_prefs->default_fill_color);
-       g_signal_connect (G_OBJECT (this->priv->fill_color_combo),
+       gl_color_button_set_color (GL_COLOR_BUTTON (this->priv->fill_color_button), gl_prefs->default_fill_color);
+       g_signal_connect (G_OBJECT (this->priv->fill_color_button),
                          "color_changed",
                          G_CALLBACK (fill_color_changed_cb), this);
 
        /* Line color widget */
-       gl_color_combo_set_color (GL_COLOR_COMBO (this->priv->line_color_combo), gl_prefs->default_line_color);
-       g_signal_connect (G_OBJECT (this->priv->line_color_combo),
+       gl_color_button_set_color (GL_COLOR_BUTTON (this->priv->line_color_button), gl_prefs->default_line_color);
+       g_signal_connect (G_OBJECT (this->priv->line_color_button),
                          "color_changed",
                          G_CALLBACK (line_color_changed_cb), this);
 
@@ -448,11 +448,11 @@ reset_to_default_properties (glView *view,
        gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio),
                                           (view->default_text_alignment == PANGO_ALIGN_RIGHT));
 
-       gl_color_combo_set_color (GL_COLOR_COMBO(this->priv->text_color_combo), view->default_text_color);
+       gl_color_button_set_color (GL_COLOR_BUTTON(this->priv->text_color_button), view->default_text_color);
 
-       gl_color_combo_set_color (GL_COLOR_COMBO(this->priv->fill_color_combo), view->default_fill_color);
+       gl_color_button_set_color (GL_COLOR_BUTTON(this->priv->fill_color_button), view->default_fill_color);
 
-       gl_color_combo_set_color (GL_COLOR_COMBO(this->priv->line_color_combo), view->default_line_color);
+       gl_color_button_set_color (GL_COLOR_BUTTON(this->priv->line_color_button), view->default_line_color);
 
        gtk_spin_button_set_value (GTK_SPIN_BUTTON(this->priv->line_width_spin),
                                   view->default_line_width);
@@ -621,7 +621,7 @@ update_text_properties (glView *view,
        if (is_same_text_color)
         {
                gl_debug (DEBUG_PROPERTY_BAR, "same text color = %08x", selection_text_color);
-               gl_color_combo_set_color (GL_COLOR_COMBO (this->priv->text_color_combo),
+               gl_color_button_set_color (GL_COLOR_BUTTON (this->priv->text_color_button),
                                           selection_text_color);
        }
 
@@ -713,7 +713,7 @@ update_fill_color (glView *view,
        if (is_same_fill_color)
         {
                gl_debug (DEBUG_PROPERTY_BAR, "same fill color = %08x", selection_fill_color);
-               gl_color_combo_set_color (GL_COLOR_COMBO (this->priv->fill_color_combo),
+               gl_color_button_set_color (GL_COLOR_BUTTON (this->priv->fill_color_button),
                                           selection_fill_color);
        }
 }
@@ -777,7 +777,7 @@ update_line_color (glView *view,
        if (is_same_line_color)
         {
                gl_debug (DEBUG_PROPERTY_BAR, "same line color = %08x", selection_line_color);
-               gl_color_combo_set_color (GL_COLOR_COMBO (this->priv->line_color_combo),
+               gl_color_button_set_color (GL_COLOR_BUTTON (this->priv->line_color_button),
                                           selection_line_color);
        }
 }
@@ -933,7 +933,7 @@ font_size_changed_cb (GtkSpinButton        *spin,
 /* PRIVATE.  Text color combo changed.                                      */
 /*--------------------------------------------------------------------------*/
 static void
-text_color_changed_cb (glColorCombo         *cc,
+text_color_changed_cb (glColorButton        *cc,
                        guint                 color,
                       gboolean              is_default,
                       glUIPropertyBar      *this)
@@ -981,7 +981,7 @@ text_color_changed_cb (glColorCombo         *cc,
 /* PRIVATE.  Fill color combo changed.                                      */
 /*--------------------------------------------------------------------------*/
 static void
-fill_color_changed_cb (glColorCombo         *cc,
+fill_color_changed_cb (glColorButton        *cc,
                        guint                 color,
                       gboolean              is_default,
                       glUIPropertyBar      *this)
@@ -1030,7 +1030,7 @@ fill_color_changed_cb (glColorCombo         *cc,
 /* PRIVATE.  Line color combo changed.                                      */
 /*--------------------------------------------------------------------------*/
 static void
-line_color_changed_cb (glColorCombo         *cc,
+line_color_changed_cb (glColorButton        *cc,
                        guint                 color,
                       gboolean              is_default,
                       glUIPropertyBar      *this)
@@ -1213,9 +1213,9 @@ set_doc_items_sensitive (glUIPropertyBar      *this,
        gtk_widget_set_sensitive (this->priv->text_align_left_radio,   state);
        gtk_widget_set_sensitive (this->priv->text_align_center_radio, state);
        gtk_widget_set_sensitive (this->priv->text_align_right_radio,  state);
-       gtk_widget_set_sensitive (this->priv->text_color_combo,        state);
-       gtk_widget_set_sensitive (this->priv->fill_color_combo,        state);
-       gtk_widget_set_sensitive (this->priv->line_color_combo,        state);
+       gtk_widget_set_sensitive (this->priv->text_color_button,       state);
+       gtk_widget_set_sensitive (this->priv->fill_color_button,       state);
+       gtk_widget_set_sensitive (this->priv->line_color_button,       state);
        gtk_widget_set_sensitive (this->priv->line_width_spin,         state);
 }
 
@@ -1234,7 +1234,7 @@ set_text_items_sensitive (glUIPropertyBar      *this,
        gtk_widget_set_sensitive (this->priv->text_align_left_radio,   state);
        gtk_widget_set_sensitive (this->priv->text_align_center_radio, state);
        gtk_widget_set_sensitive (this->priv->text_align_right_radio,  state);
-       gtk_widget_set_sensitive (this->priv->text_color_combo,        state);
+       gtk_widget_set_sensitive (this->priv->text_color_button,       state);
 }
 
 
@@ -1245,7 +1245,7 @@ static void
 set_fill_items_sensitive (glUIPropertyBar      *this,
                          gboolean              state)
 {
-       gtk_widget_set_sensitive (this->priv->fill_color_combo,        state);
+       gtk_widget_set_sensitive (this->priv->fill_color_button,       state);
 }
 
 
@@ -1256,7 +1256,7 @@ static void
 set_line_color_items_sensitive (glUIPropertyBar      *this,
                                gboolean              state)
 {
-       gtk_widget_set_sensitive (this->priv->line_color_combo,        state);
+       gtk_widget_set_sensitive (this->priv->line_color_button,       state);
 }