From 2ae5bbfa6fcc2b75d56c0bf747eb1f917c1b3402 Mon Sep 17 00:00:00 2001 From: Jiri Kalvoda Date: Tue, 13 Jul 2021 22:51:52 +0200 Subject: [PATCH] Add name box --- NEWS | 4 ++++ README | 5 ++++- teatimer.c | 24 ++++++++++++++++++++---- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index e761f49..aa6f5c5 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +Version 1.4 (2021-07-13) + + o Added name box. You can specify which tea you make. + Version 1.3 (2013-10-07) o Supports teas, which require more than 99 minutes of brewing. diff --git a/README b/README index 83f79b7..55c712f 100644 --- a/README +++ b/README @@ -1,4 +1,7 @@ -Trivial Tea Timer (c) 2002, 2010, 2013 Martin Mares +Trivial Tea Timer + + (c) 2002, 2010, 2013 Martin Mares + (c) 2021 Jiri Kalvoda This program is free software; you can redistribute it and/or modify diff --git a/teatimer.c b/teatimer.c index 07ef876..b21d15d 100644 --- a/teatimer.c +++ b/teatimer.c @@ -2,6 +2,7 @@ * Trivial Tea Timer * * (c) 2002, 2010, 2013 Martin Mares + * (c) 2021 Jiri Kalvoda * * GPL'ed */ @@ -19,7 +20,7 @@ static guint second_timer; static char old_text[16]; -static GtkWidget *win, *hbox1, *timebox, *togglebutton1; +static GtkWidget *win, *hbox1, *vbox1, *timebox, *namebox, *togglebutton1; static time_t alarm_time; static char *run_cmd; static int expired; @@ -73,7 +74,7 @@ on_second_timeout(gpointer data UNUSED) } static gint -on_timebox_key(GtkWidget *widget UNUSED, GdkEventKey *ev, gpointer user_data UNUSED) +on_box_key(GtkWidget *widget UNUSED, GdkEventKey *ev, gpointer user_data UNUSED) { if (!strcmp(ev->string, "\r")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(togglebutton1), !GTK_TOGGLE_BUTTON(togglebutton1)->active); @@ -161,9 +162,18 @@ open_window(void) gtk_widget_show(hbox1); gtk_container_add(GTK_CONTAINER (win), hbox1); + vbox1 = gtk_vbox_new(FALSE, 0); + gtk_widget_show(vbox1); + gtk_box_pack_start(GTK_BOX(hbox1), vbox1, TRUE, TRUE, 0); + + 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"); + timebox = gtk_entry_new_with_max_length(9); gtk_widget_show(timebox); - gtk_box_pack_start(GTK_BOX(hbox1), timebox, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox1), timebox, TRUE, TRUE, 0); gtk_entry_set_text(GTK_ENTRY(timebox), "00:00"); togglebutton1 = gtk_toggle_button_new_with_label("Run"); @@ -171,11 +181,17 @@ open_window(void) gtk_box_pack_start(GTK_BOX(hbox1), togglebutton1, FALSE, FALSE, 0); gtk_signal_connect(GTK_OBJECT(win), "remove", GTK_SIGNAL_FUNC(on_window_remove), NULL); - gtk_signal_connect(GTK_OBJECT(timebox), "key_press_event", GTK_SIGNAL_FUNC(on_timebox_key), NULL); + gtk_signal_connect(GTK_OBJECT(namebox), "key_press_event", GTK_SIGNAL_FUNC(on_box_key), NULL); + gtk_signal_connect(GTK_OBJECT(timebox), "key_press_event", GTK_SIGNAL_FUNC(on_box_key), NULL); gtk_signal_connect(GTK_OBJECT(togglebutton1), "toggled", GTK_SIGNAL_FUNC(on_togglebutton1_toggled), NULL); gtk_widget_grab_focus(timebox); + // Do not focus button + GList *focus_chain = NULL; + focus_chain = g_list_append(focus_chain, vbox1); + gtk_container_set_focus_chain(GTK_CONTAINER (hbox1), focus_chain); + gtk_widget_show(win); } -- 2.39.2