GwyColorButton

GwyColorButton — A color displaying button launching GtkColorSelectionDialog

Synopsis




struct      GwyColorButtonPrivate;
struct      GwyColorButton;
GtkWidget*  gwy_color_button_new            (void);
GtkWidget*  gwy_color_button_new_with_color (GdkColor *color);
void        gwy_color_button_set_color      (GwyColorButton *color_button,
                                             GdkColor *color);
void        gwy_color_button_set_alpha      (GwyColorButton *color_button,
                                             guint16 alpha);
void        gwy_color_button_get_color      (GwyColorButton *color_button,
                                             GdkColor *color);
guint16     gwy_color_button_get_alpha      (GwyColorButton *color_button);
void        gwy_color_button_set_use_alpha  (GwyColorButton *color_button,
                                             gboolean use_alpha);
gboolean    gwy_color_button_get_use_alpha  (GwyColorButton *color_button);
void        gwy_color_button_set_title      (GwyColorButton *color_button,
                                             const gchar *title);
G_CONST_RETURN gchar* gwy_color_button_get_title
                                            (GwyColorButton *color_button);

Object Hierarchy


  GObject
   +----GtkObject
         +----GtkWidget
               +----GtkContainer
                     +----GtkBin
                           +----GtkButton
                                 +----GwyColorButton

Implemented Interfaces

GwyColorButton implements AtkImplementorIface.

Properties


  "alpha"                guint                : Read / Write
  "color"                GdkColor             : Read / Write
  "title"                gchararray           : Read / Write
  "use-alpha"            gboolean             : Read / Write

Signal Prototypes


"color-set" void        user_function      (GwyColorButton *widget,
                                            gpointer user_data);

Description

This is GtkColorButton widget backported from Gtk+-2.4. It will be removed at some unspecified point in the future when Gtk+-2.4 become common.

Details

struct GwyColorButtonPrivate

struct GwyColorButtonPrivate {

  GdkPixbuf *pixbuf;    /* Pixbuf for rendering sample */
  GdkGC *gc;            /* GC for drawing */

  GtkWidget *drawing_area;/* Drawing area for color sample */
  GtkWidget *cs_dialog; /* Color selection dialog */

  gchar *title;         /* Title for the color selection window */

  GdkColor color;
  guint16 alpha;

  guint use_alpha : 1;  /* Use alpha or not */
};


struct GwyColorButton

struct GwyColorButton;


gwy_color_button_new ()

GtkWidget*  gwy_color_button_new            (void);

Creates a new color button. This returns a widget in the form of a small button containing a swatch representing the current selected color. When the button is clicked, a color-selection dialog will open, allowing the user to select a color. The swatch will be updated to reflect the new color when the user finishes.

Returns : a new color button.

Since 2.4


gwy_color_button_new_with_color ()

GtkWidget*  gwy_color_button_new_with_color (GdkColor *color);

Creates a new color button.

color: A GdkColor to set the current color with.
Returns : a new color button.

Since 2.4


gwy_color_button_set_color ()

void        gwy_color_button_set_color      (GwyColorButton *color_button,
                                             GdkColor *color);

Sets the current color to be color.

color_button: a GwyColorButton.
color: A GdkColor to set the current color with.

Since 2.4


gwy_color_button_set_alpha ()

void        gwy_color_button_set_alpha      (GwyColorButton *color_button,
                                             guint16 alpha);

Sets the current opacity to be alpha.

color_button: a GwyColorButton.
alpha: an integer between 0 and 65535.

Since 2.4


gwy_color_button_get_color ()

void        gwy_color_button_get_color      (GwyColorButton *color_button,
                                             GdkColor *color);

Sets color to be the current color in the GwyColorButton widget.

color_button: a GwyColorButton.
color: a GdkColor to fill in with the current color.

Since 2.4


gwy_color_button_get_alpha ()

guint16     gwy_color_button_get_alpha      (GwyColorButton *color_button);

Returns the current alpha value.

color_button: a GwyColorButton.
Returns : an integer between 0 and 65535.

Since 2.4


gwy_color_button_set_use_alpha ()

void        gwy_color_button_set_use_alpha  (GwyColorButton *color_button,
                                             gboolean use_alpha);

Sets whether or not the color button should use the alpha channel.

color_button: a GwyColorButton.
use_alpha: TRUE if color button should use alpha channel, FALSE if not.

Since 2.4


gwy_color_button_get_use_alpha ()

gboolean    gwy_color_button_get_use_alpha  (GwyColorButton *color_button);

Does the color selection dialog use the alpha channel?

color_button: a GwyColorButton.
Returns : TRUE if the color sample uses alpha channel, FALSE if not.

Since 2.4


gwy_color_button_set_title ()

void        gwy_color_button_set_title      (GwyColorButton *color_button,
                                             const gchar *title);

Sets the title for the color selection dialog.

color_button: a GwyColorButton
title: String containing new window title.

Since 2.4


gwy_color_button_get_title ()

G_CONST_RETURN gchar* gwy_color_button_get_title
                                            (GwyColorButton *color_button);

Gets the title of the color selection dialog.

color_button: a GwyColorButton
Returns : An internal string, do not free the return value

Since 2.4

Properties

"alpha" (guint : Read / Write)

The selected opacity value (0 fully transparent, 65535 fully opaque).

"color" (GdkColor : Read / Write)

The selected color.

"title" (gchararray : Read / Write)

The title of the color selection dialog.

"use-alpha" (gboolean : Read / Write)

Whether or not to give the color an alpha value.

Signals

The "color-set" signal

void        user_function                  (GwyColorButton *widget,
                                            gpointer user_data);

The ::color-set signal is emitted when the user selects a color. When handling this signal, use gwy_color_button_get_color() and gwy_color_button_get_alpha() to find out which color was just selected.

widget: the object which received the signal.
user_data:user data set when the signal handler was connected.