]> mj.ucw.cz Git - teatimer.git/commitdiff
Add name box
authorJiri Kalvoda <jirikalvoda@kam.mff.cuni.cz>
Tue, 13 Jul 2021 20:51:52 +0000 (22:51 +0200)
committerMartin Mares <mj@ucw.cz>
Thu, 15 Jul 2021 08:54:23 +0000 (10:54 +0200)
NEWS
README
teatimer.c

diff --git a/NEWS b/NEWS
index e761f4967fab957704277a51586c3980d4092591..aa6f5c592bb07dccc0e33350f6d6ead9217a7796 100644 (file)
--- 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 83f79b77f8b284b9b667f3c430dddf40f74fac41..55c712fee89a5109689bdff60c195c502d5a04d9 100644 (file)
--- a/README
+++ b/README
@@ -1,4 +1,7 @@
-Trivial Tea Timer (c) 2002, 2010, 2013 Martin Mares <mj@ucw.cz>
+Trivial Tea Timer
+
+       (c) 2002, 2010, 2013 Martin Mares <mj@ucw.cz>
+       (c) 2021 Jiri Kalvoda <jirikalvoda@kam.mff.cuni.cz>
 
 
 This program is free software; you can redistribute it and/or modify
index 07ef8760de467580a2bb4267aa42a36684a008a0..b21d15d57cb2551d96da6364db92d46002d43003 100644 (file)
@@ -2,6 +2,7 @@
  *     Trivial Tea Timer
  *
  *     (c) 2002, 2010, 2013 Martin Mares <mj@ucw.cz>
+ *     (c) 2021 Jiri Kalvoda <jirikalvoda@kam.mff.cuni.cz>
  *
  *     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);
 }