summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2013-07-18 14:23:21 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2013-07-18 15:08:40 +0200
commit6fcf60b5678e9602486d36462cc246454ae636d0 (patch)
tree9d3652aab00c39e55f44dc4e2329362c762d3df2 /bin
parent9fdc54d27a8290b98d6fb7122af6beb5ab3b05db (diff)
downloaduca-6fcf60b5678e9602486d36462cc246454ae636d0.tar.gz
uca-6fcf60b5678e9602486d36462cc246454ae636d0.tar.bz2
uca-6fcf60b5678e9602486d36462cc246454ae636d0.tar.xz
uca-6fcf60b5678e9602486d36462cc246454ae636d0.zip
Don't accept invalid values
Diffstat (limited to 'bin')
-rw-r--r--bin/gui/egg-histogram-view.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/bin/gui/egg-histogram-view.c b/bin/gui/egg-histogram-view.c
index 912c2fa..6e35f74 100644
--- a/bin/gui/egg-histogram-view.c
+++ b/bin/gui/egg-histogram-view.c
@@ -62,7 +62,7 @@ enum
LAST_SIGNAL
};
-static GParamSpec *egg_histogram_view_properties[N_PROPERTIES] = { NULL, };
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
static guint egg_histogram_view_signals[LAST_SIGNAL] = { 0 };
@@ -289,9 +289,10 @@ egg_histogram_view_set_property (GObject *object,
{
gdouble v = g_value_get_double (value);
- if (v > priv->max_value)
+ if (v > priv->max_value) {
g_warning ("Minimum value `%f' larger than maximum value `%f'",
v, priv->max_value);
+ }
else {
priv->min_value = v;
gtk_widget_queue_draw (GTK_WIDGET (object));
@@ -303,9 +304,10 @@ egg_histogram_view_set_property (GObject *object,
{
gdouble v = g_value_get_double (value);
- if (v < priv->min_value)
+ if (v < priv->min_value) {
g_warning ("Maximum value `%f' larger than minimum value `%f'",
v, priv->min_value);
+ }
else {
priv->max_value = v;
gtk_widget_queue_draw (GTK_WIDGET (object));
@@ -371,12 +373,12 @@ set_grab_value (EggHistogramView *view,
if (view->priv->grabbed == GRAB_MIN) {
view->priv->min_value = value;
g_object_notify_by_pspec (G_OBJECT (view),
- egg_histogram_view_properties[PROP_MINIMUM_BIN_VALUE]);
+ properties[PROP_MINIMUM_BIN_VALUE]);
}
else {
view->priv->max_value = value;
g_object_notify_by_pspec (G_OBJECT (view),
- egg_histogram_view_properties[PROP_MAXIMUM_BIN_VALUE]);
+ properties[PROP_MAXIMUM_BIN_VALUE]);
}
}
@@ -397,10 +399,10 @@ egg_histogram_view_motion_notify (GtkWidget *widget,
coord = screen_to_histogram_coordinate (priv, &allocation, event->x);
- if (ABS (priv->max_value - priv->min_value) > 8.0)
+ if (ABS (priv->max_value - priv->min_value) > 8.0 && coord > 0 && coord < priv->max) {
set_grab_value (view, coord);
-
- gtk_widget_queue_draw (widget);
+ gtk_widget_queue_draw (widget);
+ }
}
else {
if (is_on_border (priv, &allocation, event->x))
@@ -474,22 +476,22 @@ egg_histogram_view_class_init (EggHistogramViewClass *klass)
widget_class->button_release_event = egg_histogram_view_button_release;
widget_class->motion_notify_event = egg_histogram_view_motion_notify;
- egg_histogram_view_properties[PROP_MINIMUM_BIN_VALUE] =
+ properties[PROP_MINIMUM_BIN_VALUE] =
g_param_spec_double ("minimum-bin-value",
"Smallest possible bin value",
"Smallest possible bin value, everything below is discarded.",
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE);
- egg_histogram_view_properties[PROP_MAXIMUM_BIN_VALUE] =
+ properties[PROP_MAXIMUM_BIN_VALUE] =
g_param_spec_double ("maximum-bin-value",
"Largest possible bin value",
"Largest possible bin value, everything above is discarded.",
0.0, G_MAXDOUBLE, 256.0,
G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_MINIMUM_BIN_VALUE, egg_histogram_view_properties[PROP_MINIMUM_BIN_VALUE]);
- g_object_class_install_property (object_class, PROP_MAXIMUM_BIN_VALUE, egg_histogram_view_properties[PROP_MAXIMUM_BIN_VALUE]);
+ g_object_class_install_property (object_class, PROP_MINIMUM_BIN_VALUE, properties[PROP_MINIMUM_BIN_VALUE]);
+ g_object_class_install_property (object_class, PROP_MAXIMUM_BIN_VALUE, properties[PROP_MAXIMUM_BIN_VALUE]);
egg_histogram_view_signals[CHANGED] =
g_signal_new ("changed",