@@ -27,8 +27,15 @@ typedef struct
27 guint actions_export_id;
27 guint actions_export_id;
28 guint menu_export_id;
28 guint menu_export_id;
29 int action_delay;
29 int action_delay;
30} IndicatorTestService;
31} IndicatorTestService;
35+ GSimpleAction *action;
32static void
39static void
33bus_acquired (GDBusConnection *connection,
40bus_acquired (GDBusConnection *connection,
34 const gchar *name,
41 const gchar *name,
@@ -96,10 +103,10 @@ actual_switch (gpointer user_data)
96 gboolean state = g_variant_get_boolean (v);
103 gboolean state = g_variant_get_boolean (v);
97 GVariant *new_state = g_variant_new_boolean (state == TRUE ? FALSE : TRUE);
104 GVariant *new_state = g_variant_new_boolean (state == TRUE ? FALSE : TRUE);
99− g_simple_action_set_state(G_SIMPLE_ACTION(action), new_state);
106+ g_simple_action_set_state(action, new_state);
101 g_variant_unref (v);
108 g_variant_unref (v);
102− g_message ("switching");
109+ g_message ("switching %d", state);
103 return FALSE;
110 return FALSE;
@@ -120,13 +127,12 @@ activate_switch (GSimpleAction *action,
120static gboolean
127static gboolean
121actual_slide (gpointer user_data)
128actual_slide (gpointer user_data)
123− GSimpleAction *action = user_data;
130+ Action *slide_action = user_data;
125− GVariant* new_state = g_object_get_qdata (G_OBJECT (action), slider_value_quark ());
127− g_simple_action_set_state(G_SIMPLE_ACTION(action), new_state);
132+ g_simple_action_set_state(G_SIMPLE_ACTION(slide_action->action), slide_action->value);
133+ g_message ("sliding %f", g_variant_get_double(slide_action->value));
129− g_message ("switching");
130 return FALSE;
136 return FALSE;
@@ -136,10 +142,40 @@ void change_slider (GSimpleAction *action,
137 IndicatorTestService *indicator = user_data;
143 IndicatorTestService *indicator = user_data;
139− g_object_set_qdata (G_OBJECT (action), slider_value_quark (), g_variant_ref(value));
145+ Action* slide_action = malloc(sizeof(Action));
146+ slide_action->action = action;
147+ slide_action->value = g_variant_ref(value);
141− g_timeout_add(indicator->action_delay, actual_slide, action);
149+ g_timeout_add(indicator->action_delay, actual_slide, slide_action);
142− g_message ("slide delay %.03f", g_variant_get_double(value));
150+ g_message ("slide delay %f", g_variant_get_double(value));
154+change_interval (gpointer user_data)
156+ g_message ("change interval");
158+ IndicatorTestService *indicator = user_data;
160+ GAction* action_switch = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.switch");
161+ actual_switch(G_SIMPLE_ACTION(action_switch));
163+ GAction* action_checkbox = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.checkbox");
164+ actual_switch(G_SIMPLE_ACTION(action_checkbox));
166+ GAction* action_accessPoint = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.accessPoint");
167+ actual_switch(G_SIMPLE_ACTION(action_accessPoint));
169+ GAction* action_slider = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.slider");
170+ static double old_value = 0.25;
171+ double new_value = old_value == 0.25 ? 0.75 : 0.25;
172+ old_value = new_value;
173+ Action* slide_action = malloc(sizeof(Action));
174+ slide_action->action = G_SIMPLE_ACTION(action_slider);
175+ slide_action->value = g_variant_new_double(new_value);
176+ actual_slide(slide_action);
@@ -147,6 +183,7 @@ main (int argc, char **argv)
148 IndicatorTestService indicator = { 0 };
184 IndicatorTestService indicator = { 0 };
149 indicator.action_delay = -1;
185 indicator.action_delay = -1;
186+ indicator.change_interval = -1;
150 GMenuItem *item;
187 GMenuItem *item;
151 GMenu *submenu;
188 GMenu *submenu;
152 GActionEntry entries[] = {
189 GActionEntry entries[] = {
@@ -191,6 +228,27 @@ main (int argc, char **argv)
235+ if (!arg[0] && i < argc-1) {
239+ if (sscanf(argv[i], "%d", &interval) == 1) {
240+ indicator.change_interval = interval;
242+ printf("Invalid change interval value: %s\n", argv[i]);
246+ printf("Invalid change interval value: %s\n", argv[i]);
194 case 'h':
252 case 'h':
195 help = 1;
253 help = 1;
@@ -201,8 +259,9 @@ main (int argc, char **argv)
202 if (help) {
260 if (help) {
203 printf("Usage: %s [<options>]\n"
261 printf("Usage: %s [<options>]\n"
204− " -t DELAY Action activation delay\n"
262+ " -t DELAY Action activation delay\n"
263+ " -c CHANGE_INTERVAL Interval to change action values\n"
205− " -h Show this help text\n"
264+ " -h Show this help text\n"
206 , argv[0]);
265 , argv[0]);
207 return 0;
266 return 0;
@@ -249,6 +308,11 @@ main (int argc, char **argv)
251 loop = g_main_loop_new (NULL, FALSE);
310 loop = g_main_loop_new (NULL, FALSE);
312+ if (indicator.change_interval != -1) {
313+ g_timeout_add(indicator.change_interval, change_interval, &indicator);
252 g_main_loop_run (loop);
316 g_main_loop_run (loop);
254 g_object_unref (submenu);
318 g_object_unref (submenu);