From: Jiri Kalvoda Date: Thu, 15 Jul 2021 13:06:22 +0000 (+0200) Subject: Add option to set default name X-Git-Tag: v1.4~3 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=156656d367839b039c5fb3d3cd4953498467d68b;p=teatimer.git Add option to set default name --- diff --git a/teatimer.c b/teatimer.c index 56d78c1..1971d0d 100644 --- a/teatimer.c +++ b/teatimer.c @@ -23,6 +23,7 @@ static char old_text[16]; static GtkWidget *win, *hbox1, *vbox1, *timebox, *namebox, *togglebutton1; static time_t alarm_time; static char *run_cmd; +static char *default_name = "Tea"; static int expired; static void @@ -195,7 +196,7 @@ open_window(void) namebox = gtk_entry_new_with_max_length(30); gtk_widget_show(namebox); gtk_box_pack_start(GTK_BOX(vbox1), namebox, TRUE, TRUE, 0); - gtk_entry_set_text(GTK_ENTRY(namebox), "Tea"); + gtk_entry_set_text(GTK_ENTRY(namebox), default_name); timebox = gtk_entry_new_with_max_length(9); gtk_widget_show(timebox); @@ -221,10 +222,11 @@ open_window(void) gtk_widget_show(win); } -static const char short_opts[] = "r:"; +static const char short_opts[] = "r:n:"; static const struct option long_opts[] = { { "run", required_argument, NULL, 'r' }, + { "timer-name", required_argument, NULL, 'n' }, { NULL, 0, NULL, 0 }, }; @@ -236,6 +238,7 @@ Options:\n\ -r, --run=\t\tRun a given program when the tea is ready\n\ \t\t\t\t%%d will be expanded to timer name\n\ \t\t\t\t%%%% will be expanded to %%\n\ +-n, --timer-name=\tFill name box with \n\ "); exit(1); } @@ -253,6 +256,9 @@ main(int argc, char **argv) case 'r': run_cmd = optarg; break; + case 'n': + default_name = optarg; + break; default: usage(); }