1 #include "kernel/menu.h"
2 #include "kernel/timer.h"
3 #include "timed_menu.h"
4 #include "kernel/action.h"
6 static char *PLUGIN_NAME
= "timed_menu";
12 /* we can use various GIO channels to support reading menus (can we add them to
19 Timer
*timer
; /* timer code handles free */
23 void plugin_setup_config() { }
26 void plugin_shutdown() { }
28 void timed_menu_timeout_handler(void *data
)
31 printf("woop timer %s\n", ((Menu
*)data
)->name
);
32 ((Menu
*)data
)->invalid
= TRUE
;
34 if (((Menu
*)data
)->shown
) {
35 a
= action_from_string("execute");
36 a
->data
.execute
.path
= g_strdup("xeyes");
37 menu_add_entry((Menu
*)data
, menu_entry_new("xeyes", a
));
39 menu_show_full( (Menu
*)data
, ((Menu
*)data
)->location
.x
,
40 ((Menu
*)data
)->location
.y
, NULL
);
44 for (it
= ((Menu
*)data
)->entries
; it
; it
= it
->next
) {
45 MenuEntry
*entry
= it
->data
;
46 menu_entry_free(entry
);
48 ((Menu
*)data
)->entries
= NULL
;
54 Timed_Menu_Data
*d
= g_new(Timed_Menu_Data
, 1);
55 Menu
*m
= menu_new("", PLUGIN_NAME
, NULL
);
57 m
->plugin
= PLUGIN_NAME
;
59 d
->type
= TIMED_MENU_PIPE
;
60 d
->timer
= timer_start(1000000, &timed_menu_timeout_handler
, m
);
62 m
->plugin_data
= (void *)d
;
67 void plugin_destroy (void *m
)
69 /* this will be freed by timer_* */
70 timer_stop( ((Timed_Menu_Data
*)((Menu
*)m
)->plugin_data
)->timer
);
72 g_free( ((Menu
*)m
)->plugin_data
);