[glib] Add example for 'change-state' signal
- From: Javier JardÃn <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add example for 'change-state' signal
- Date: Wed, 29 Jun 2011 15:22:56 +0000 (UTC)
commit 535dcf4f22ba7621c6078f3fe96db6d3e64f0132
Author: Ryan Lortie <desrt desrt ca>
Date: Wed Jun 29 14:53:24 2011 +0100
Add example for 'change-state' signal
Pulled from the testcase.
gio/gsimpleaction.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/gio/gsimpleaction.c b/gio/gsimpleaction.c
index 0f26c0f..bf8dd73 100644
--- a/gio/gsimpleaction.c
+++ b/gio/gsimpleaction.c
@@ -351,6 +351,28 @@ g_simple_action_class_init (GSimpleActionClass *class)
* default action is taken. If the state should change then you must
* call g_simple_action_set_state() from the handler.
*
+ * <example>
+ * <title>Example 'change-state' handler</title>
+ * <programlisting>
+ * static void
+ * change_volume_state (GSimpleAction *action,
+ * GVariant *value,
+ * gpointer user_data)
+ * {
+ * gint requested;
+ *
+ * requested = g_variant_get_int32 (value);
+ *
+ * // Volume only goes from 0 to 10
+ * if (0 <= requested && requested <= 10)
+ * g_simple_action_set_state (action, value);
+ * }
+ * </programlisting>
+ * </example>
+ *
+ * The handler need not set the state to the requested value. It
+ * could set it to any value at all, or take some other action.
+ *
* Since: 2.30
*/
g_simple_action_signals[SIGNAL_CHANGE_STATE] =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]