X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/c00fce3ab1dc8b810a439e81e419d7b8ae1d97b9..73f1b9f30c98dc525a5b6a540f6f135855d640a0:/disobedience/disobedience.c diff --git a/disobedience/disobedience.c b/disobedience/disobedience.c index 72b0720..6271560 100644 --- a/disobedience/disobedience.c +++ b/disobedience/disobedience.c @@ -49,6 +49,9 @@ GtkWidget *tabs; /** @brief Main client */ disorder_eclient *client; +/** @brief Log client */ +disorder_eclient *logclient; + /** @brief Last reported state * * This is updated by log_state(). @@ -69,15 +72,18 @@ int volume_r; double goesupto = 10; /* volume upper bound */ -/** @brief Break up choose tab by initial letter */ -int choosealpha; - /** @brief True if a NOP is in flight */ static int nop_in_flight; /** @brief Global tooltip group */ GtkTooltips *tips; +/** @brief Linked list of functions to call when we reset login parameters */ +static struct reset_callback_node { + struct reset_callback_node *next; + reset_callback *callback; +} *resets; + /* Window creation --------------------------------------------------------- */ /* Note that all the client operations kicked off from here will only complete @@ -127,6 +133,8 @@ static GtkWidget *notebook(void) { gtk_label_new("Recent")); gtk_notebook_append_page(GTK_NOTEBOOK(tabs), choose_widget(), gtk_label_new("Choose")); + gtk_notebook_append_page(GTK_NOTEBOOK(tabs), added_widget(), + gtk_label_new("Added")); return tabs; } @@ -318,7 +326,6 @@ static const struct option options[] = { { "version", no_argument, 0, 'V' }, { "config", required_argument, 0, 'c' }, { "tufnel", no_argument, 0, 't' }, - { "choosealpha", no_argument, 0, 'C' }, { "debug", no_argument, 0, 'd' }, { 0, 0, 0, 0 } }; @@ -347,9 +354,28 @@ static void version(void) { exit(0); } +/* reset state */ +void reset(void) { + struct reset_callback_node *r; + + /* reset the clients */ + disorder_eclient_close(client); + disorder_eclient_close(logclient); + for(r = resets; r; r = r->next) + r->callback(); +} + +/** @brief Register a reset callback */ +void register_reset(reset_callback *callback) { + struct reset_callback_node *const r = xmalloc(sizeof *r); + + r->next = resets; + r->callback = callback; + resets = r; +} + int main(int argc, char **argv) { int n; - disorder_eclient *logclient; mem_init(); /* garbage-collect PCRE's memory */ @@ -362,14 +388,13 @@ int main(int argc, char **argv) { if(!setlocale(LC_CTYPE, "")) fatal(errno, "error calling setlocale"); gtk_init(&argc, &argv); gtk_rc_parse_string(style); - while((n = getopt_long(argc, argv, "hVc:dtH", options, 0)) >= 0) { + while((n = getopt_long(argc, argv, "hVc:dtHC", options, 0)) >= 0) { switch(n) { case 'h': help(); case 'V': version(); case 'c': configfile = optarg; break; case 'd': debugging = 1; break; case 't': goesupto = 11; break; - case 'C': choosealpha = 1; break; /* not well tested any more */ default: fatal(0, "invalid option"); } } @@ -404,6 +429,7 @@ int main(int argc, char **argv) { maybe_send_nop, 0/*data*/, 0/*notify*/); + register_reset(properties_reset); /* Start monitoring the log */ disorder_eclient_log(logclient, &log_callbacks, 0); D(("enter main loop"));