Commit 04d9d5bd authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

libgimpwidgets/gimpcolorarea.c more object properties.

2005-05-20  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/gimpcolorarea.c
	* libgimpwidgets/gimpcolorbutton.c: more object properties.
parent 6bd6a444
2005-05-20 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpcolorarea.c
* libgimpwidgets/gimpcolorbutton.c: more object properties.
2005-05-20 Sven Neumann <sven@gimp.org>
* libgimpwidgets/Makefile.am
......
......@@ -45,7 +45,9 @@ enum
enum
{
PROP_0,
PROP_TYPE
PROP_COLOR,
PROP_TYPE,
PROP_DRAG_MASK
};
......@@ -126,6 +128,7 @@ gimp_color_area_class_init (GimpColorAreaClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GimpRGB color;
parent_class = g_type_class_peek_parent (klass);
......@@ -152,6 +155,20 @@ gimp_color_area_class_init (GimpColorAreaClass *klass)
klass->color_changed = NULL;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
/**
* GimpColorArea:color:
*
* The color displayed in the color area.
*
* Since: GIMP 2.4
*/
g_object_class_install_property (object_class, PROP_COLOR,
gimp_param_spec_rgb ("color", NULL, NULL,
&color,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
/**
* GimpColorArea:type:
*
......@@ -165,6 +182,19 @@ gimp_color_area_class_init (GimpColorAreaClass *klass)
GIMP_COLOR_AREA_FLAT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
/**
* GimpColorArea:drag-type:
*
* The event_mask that should trigger drags.
*
* Since: GIMP 2.4
*/
g_object_class_install_property (object_class, PROP_DRAG_MASK,
g_param_spec_flags ("drag-mask", NULL, NULL,
GDK_TYPE_MODIFIER_TYPE,
0,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
......@@ -176,7 +206,12 @@ gimp_color_area_init (GimpColorArea *area)
area->rowstride = 0;
area->draw_border = FALSE;
gimp_rgba_set (&area->color, 0.0, 0.0, 0.0, 1.0);
gtk_drag_dest_set (GTK_WIDGET (area),
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
&target, 1,
GDK_ACTION_COPY);
}
static void
......@@ -203,6 +238,10 @@ gimp_color_area_get_property (GObject *object,
switch (property_id)
{
case PROP_COLOR:
g_value_set_boxed (value, &area->color);
break;
case PROP_TYPE:
g_value_set_enum (value, area->type);
break;
......@@ -220,13 +259,29 @@ gimp_color_area_set_property (GObject *object,
GParamSpec *pspec)
{
GimpColorArea *area = GIMP_COLOR_AREA (object);
GdkModifierType drag_mask;
switch (property_id)
{
case PROP_COLOR:
gimp_color_area_set_color (area, g_value_get_boxed (value));
break;
case PROP_TYPE:
gimp_color_area_set_type (area, g_value_get_enum (value));
break;
case PROP_DRAG_MASK:
drag_mask = g_value_get_flags (value) & (GDK_BUTTON1_MASK |
GDK_BUTTON2_MASK |
GDK_BUTTON3_MASK);
if (drag_mask)
gtk_drag_source_set (GTK_WIDGET (area),
drag_mask,
&target, 1,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -312,32 +367,11 @@ gimp_color_area_new (const GimpRGB *color,
GimpColorAreaType type,
GdkModifierType drag_mask)
{
GimpColorArea *area;
g_return_val_if_fail (color != NULL, NULL);
area = g_object_new (GIMP_TYPE_COLOR_AREA,
return g_object_new (GIMP_TYPE_COLOR_AREA,
"color", color,
"type", type,
"drag-mask", drag_mask,
NULL);
area->color = *color;
gtk_drag_dest_set (GTK_WIDGET (area),
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
&target, 1,
GDK_ACTION_COPY);
drag_mask &= (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK);
if (drag_mask)
gtk_drag_source_set (GTK_WIDGET (area),
drag_mask,
&target, 1,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
return GTK_WIDGET (area);
}
/**
......@@ -370,6 +404,8 @@ gimp_color_area_set_color (GimpColorArea *area,
area->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (area));
g_object_notify (G_OBJECT (area), "color");
g_signal_emit (area, gimp_color_area_signals[COLOR_CHANGED], 0);
}
......
......@@ -64,7 +64,10 @@ enum
enum
{
PROP_0,
PROP_TITLE
PROP_TITLE,
PROP_COLOR,
PROP_TYPE,
PROP_UPDATE
};
......@@ -104,7 +107,7 @@ static void gimp_color_button_help_func (const gchar *help_id,
gpointer help_data);
static GtkActionEntry actions[] =
static const GtkActionEntry actions[] =
{
{ "color-button-popup", NULL,
"Color Button Menu", NULL, NULL,
......@@ -169,6 +172,7 @@ gimp_color_button_class_init (GimpColorButtonClass *klass)
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
GimpRGB color;
parent_class = g_type_class_peek_parent (klass);
......@@ -195,6 +199,8 @@ gimp_color_button_class_init (GimpColorButtonClass *klass)
klass->color_changed = NULL;
klass->get_action_type = gimp_color_button_get_action_type;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
/**
* GimpColorButton:title:
*
......@@ -207,6 +213,44 @@ gimp_color_button_class_init (GimpColorButtonClass *klass)
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
/**
* GimpColorButton:color:
*
* The color displayed in the button's color area.
*
* Since: GIMP 2.4
*/
g_object_class_install_property (object_class, PROP_COLOR,
gimp_param_spec_rgb ("color", NULL, NULL,
&color,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
/**
* GimpColorButton:type:
*
* The type of the button's color area.
*
* Since: GIMP 2.4
*/
g_object_class_install_property (object_class, PROP_TYPE,
g_param_spec_enum ("type", NULL, NULL,
GIMP_TYPE_COLOR_AREA_TYPE,
GIMP_COLOR_AREA_FLAT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
/**
* GimpColorButton:continuous-update:
*
* The update policy of the color button.
*
* Since: GIMP 2.4
*/
g_object_class_install_property (object_class, PROP_UPDATE,
g_param_spec_boolean ("continuous-update",
NULL, NULL,
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
......@@ -215,15 +259,15 @@ gimp_color_button_init (GimpColorButton *button,
{
GtkActionGroup *group;
GtkUIManager *ui_manager;
GimpRGB color;
gint i;
button->continuous_update = FALSE;
button->title = NULL;
button->dialog = NULL;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
button->color_area = gimp_color_area_new (&color, FALSE, GDK_BUTTON2_MASK);
button->color_area = g_object_new (GIMP_TYPE_COLOR_AREA,
"drag-mask", GDK_BUTTON2_MASK,
NULL);
g_signal_connect (button->color_area, "color_changed",
G_CALLBACK (gimp_color_button_area_changed),
button);
......@@ -305,6 +349,18 @@ gimp_color_button_get_property (GObject *object,
g_value_set_string (value, button->title);
break;
case PROP_COLOR:
g_object_get_property (G_OBJECT (button->color_area), "color", value);
break;
case PROP_TYPE:
g_object_get_property (G_OBJECT (button->color_area), "type", value);
break;
case PROP_UPDATE:
g_value_set_boolean (value, button->continuous_update);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -326,6 +382,18 @@ gimp_color_button_set_property (GObject *object,
button->title = g_value_dup_string (value);
break;
case PROP_COLOR:
g_object_set_property (G_OBJECT (button->color_area), "color", value);
break;
case PROP_TYPE:
g_object_set_property (G_OBJECT (button->color_area), "type", value);
break;
case PROP_UPDATE:
gimp_color_button_set_update (button, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -493,13 +561,12 @@ gimp_color_button_new (const gchar *title,
button = g_object_new (GIMP_TYPE_COLOR_BUTTON,
"title", title,
"type", type,
"color", color,
NULL);
gtk_widget_set_size_request (GTK_WIDGET (button->color_area), width, height);
gimp_color_area_set_type (GIMP_COLOR_AREA (button->color_area), type);
gimp_color_area_set_color (GIMP_COLOR_AREA (button->color_area), color);
return GTK_WIDGET (button);
}
......@@ -518,6 +585,8 @@ gimp_color_button_set_color (GimpColorButton *button,
g_return_if_fail (color != NULL);
gimp_color_area_set_color (GIMP_COLOR_AREA (button->color_area), color);
g_object_notify (G_OBJECT (button), "color");
}
/**
......@@ -568,6 +637,8 @@ gimp_color_button_set_type (GimpColorButton *button,
g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
gimp_color_area_set_type (GIMP_COLOR_AREA (button->color_area), type);
g_object_notify (G_OBJECT (button), "type");
}
/**
......@@ -624,6 +695,8 @@ gimp_color_button_set_update (GimpColorButton *button,
gimp_color_button_set_color (button, &color);
}
}
g_object_notify (G_OBJECT (button), "continuous-update");
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment