diff options
| author | Scott Moynes <smoynes@nexus.carleton.ca> | 2003-05-09 23:15:28 +0000 |
|---|---|---|
| committer | Scott Moynes <smoynes@nexus.carleton.ca> | 2003-05-09 23:15:28 +0000 |
| commit | a8a4a2cca30602b66b7a7f68bb9f3fffd34e92c9 (patch) | |
| tree | fddb23143b63c703c73886be2d1e45765ec0bad5 /plugins/menu/timed_menu.c | |
| parent | d5eacc5642ad8f5611f7c946d734863bc8898513 (diff) | |
Menu uber patch
Since we have no menu parser see menu_startup() to customize
Diffstat (limited to 'plugins/menu/timed_menu.c')
| -rw-r--r-- | plugins/menu/timed_menu.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/plugins/menu/timed_menu.c b/plugins/menu/timed_menu.c new file mode 100644 index 00000000..2c264347 --- /dev/null +++ b/plugins/menu/timed_menu.c @@ -0,0 +1,73 @@ +#include "kernel/menu.h" +#include "kernel/timer.h" +#include "timed_menu.h" +#include "kernel/action.h" + +static char *PLUGIN_NAME = "timed_menu"; + +typedef enum { + TIMED_MENU_PIPE +} Timed_Menu_Type; + +/* we can use various GIO channels to support reading menus (can we add them to + the event loop? ) + stat() based update + exec() based read +*/ +typedef struct { + Timed_Menu_Type type; + Timer *timer; /* timer code handles free */ +} Timed_Menu_Data; + + +void plugin_setup_config() { } +void plugin_startup() +{ } +void plugin_shutdown() { } + +void timed_menu_timeout_handler(void *data) +{ + Action *a; + printf("woop timer %s\n", ((Menu *)data)->name); + ((Menu *)data)->invalid = TRUE; + + if (((Menu *)data)->shown) { + a = action_from_string("execute"); + a->data.execute.path = g_strdup("xeyes"); + menu_add_entry((Menu *)data, menu_entry_new("xeyes", a)); + + menu_show_full( (Menu *)data, ((Menu *)data)->location.x, + ((Menu *)data)->location.y, NULL); + } else { + GList *it; + + for (it = ((Menu *)data)->entries; it; it = it->next) { + MenuEntry *entry = it->data; + menu_entry_free(entry); + } + ((Menu *)data)->entries = NULL; + } +} + +void *plugin_create() +{ + Timed_Menu_Data *d = g_new(Timed_Menu_Data, 1); + Menu *m = menu_new("", PLUGIN_NAME, NULL); + + m->plugin = PLUGIN_NAME; + + d->type = TIMED_MENU_PIPE; + d->timer = timer_start(1000000, &timed_menu_timeout_handler, m); + + m->plugin_data = (void *)d; + + return (void *)m; +} + +void plugin_destroy (void *m) +{ + /* this will be freed by timer_* */ + timer_stop( ((Timed_Menu_Data *)((Menu *)m)->plugin_data)->timer); + + g_free( ((Menu *)m)->plugin_data ); +} |
