[libgd] Use a revealed property for GdRevealer
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgd] Use a revealed property for GdRevealer
- Date: Fri, 8 Feb 2013 16:07:51 +0000 (UTC)
commit 245347f00a297e8f4ca7920e62788e29147e7627
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Fri Feb 8 09:45:54 2013 -0500
Use a revealed property for GdRevealer
libgd/gd-revealer.c | 44 +++++++++++++++++++++++++++-----------------
libgd/gd-revealer.h | 6 +++---
2 files changed, 30 insertions(+), 20 deletions(-)
---
diff --git a/libgd/gd-revealer.c b/libgd/gd-revealer.c
index 5836c60..4da6982 100644
--- a/libgd/gd-revealer.c
+++ b/libgd/gd-revealer.c
@@ -27,7 +27,8 @@
enum {
PROP_0,
PROP_ORIENTATION,
- PROP_DURATION
+ PROP_DURATION,
+ PROP_REVEALED
};
#define FRAME_TIME_MSEC 17 /* 17 msec => 60 fps */
@@ -145,6 +146,9 @@ gd_revealer_get_property (GObject *object,
case PROP_DURATION:
g_value_set_int (value, gd_revealer_get_duration (revealer));
break;
+ case PROP_REVEALED:
+ g_value_set_boolean (value, gd_revealer_get_revealed (revealer));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -166,6 +170,9 @@ gd_revealer_set_property (GObject *object,
case PROP_DURATION:
gd_revealer_set_duration (revealer, g_value_get_int (value));
break;
+ case PROP_REVEALED:
+ gd_revealer_set_revealed (revealer, g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -211,6 +218,12 @@ gd_revealer_class_init (GdRevealerClass * klass)
G_MININT, G_MAXINT,
250,
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_REVEALED,
+ g_param_spec_boolean ("revealed", "revealed",
+ "Whether the child is revealed",
+ FALSE,
+ GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_type_class_add_private (klass, sizeof (GdRevealerPrivate));
}
@@ -503,6 +516,8 @@ gd_revealer_start_animation (GdRevealer *revealer,
}
else
gd_revealer_set_position (revealer, target);
+
+ g_object_notify (G_OBJECT (revealer), "revealed");
}
@@ -565,22 +580,25 @@ gd_revealer_real_draw (GtkWidget *widget,
}
void
-gd_revealer_reveal (GdRevealer *revealer)
+gd_revealer_set_revealed (GdRevealer *revealer,
+ gboolean setting)
{
- g_return_if_fail (revealer != NULL);
+ g_return_if_fail (GD_IS_REVEALER (revealer));
- gd_revealer_start_animation (revealer, 1.0);
+ if (setting)
+ gd_revealer_start_animation (revealer, 1.0);
+ else
+ gd_revealer_start_animation (revealer, 0.0);
}
-void
-gd_revealer_unreveal (GdRevealer *revealer)
+gboolean
+gd_revealer_get_revealed (GdRevealer *revealer)
{
- g_return_if_fail (revealer != NULL);
+ g_return_val_if_fail (GD_IS_REVEALER (revealer), FALSE);
- gd_revealer_start_animation (revealer, 0.0);
+ return revealer->priv->target_pos != 0.0;
}
-
/* These all report only the natural size, ignoring the minimal size,
* because its not really possible to allocate the right size during
* animation if the child size can change (without the child
@@ -715,11 +733,3 @@ gd_revealer_set_duration (GdRevealer *revealer,
revealer->priv->duration = value;
g_object_notify (G_OBJECT (revealer), "duration");
}
-
-gboolean
-gd_revealer_get_is_revealed (GdRevealer *revealer)
-{
- g_return_val_if_fail (revealer != NULL, FALSE);
-
- return revealer->priv->target_pos != 0.0;
-}
diff --git a/libgd/gd-revealer.h b/libgd/gd-revealer.h
index 2be0509..87d6772 100644
--- a/libgd/gd-revealer.h
+++ b/libgd/gd-revealer.h
@@ -50,9 +50,9 @@ struct _GdRevealerClass {
GType gd_revealer_get_type (void) G_GNUC_CONST;
GdRevealer* gd_revealer_new (void);
-void gd_revealer_reveal (GdRevealer *revealer);
-void gd_revealer_unreveal (GdRevealer *revealer);
-gboolean gd_revealer_get_is_revealed (GdRevealer *revealer);
+gboolean gd_revealer_get_revealed (GdRevealer *revealer);
+void gd_revealer_set_revealed (GdRevealer *revealer,
+ gboolean setting);
GtkOrientation gd_revealer_get_orientation (GdRevealer *revealer);
void gd_revealer_set_orientation (GdRevealer *revealer,
GtkOrientation value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]