--- gnome-core-1.4.0.4/applets/gen_util/clock.c	Fri Feb  9 06:40:46 2001
+++ gnome-core-1.4.0.4-juri/applets/gen_util/clock.c	Fri Sep 21 23:17:29 2001
@@ -41,6 +41,7 @@
 	int timeout;
 	int timeouttime;
 	int hourformat;
+	gboolean showsecs;
         gboolean showdate;
 	gboolean unixtime;
 	gboolean internettime;
@@ -53,6 +54,7 @@
 
 	GtkWidget *props;
 	int prop_hourformat;
+	gboolean prop_showsecs;
         gboolean prop_showdate;
 	gboolean prop_unixtime;
 	gboolean prop_internettime;
@@ -87,7 +89,7 @@
 
 	(*cd->update_func) (cd, current_time);
 
-	if(cd->unixtime) {
+	if(cd->unixtime || cd->showsecs) {
 		if (cd->timeouttime != 1000) {
 			cd->timeouttime = 1000;
 			cd->timeout = gtk_timeout_add(cd->timeouttime,
@@ -125,6 +127,7 @@
 	ClockData *cd = data;
 	gnome_config_push_prefix(privcfgpath);
 	gnome_config_set_int("clock/hourformat", cd->hourformat);
+	gnome_config_set_int("clock/showsecs", cd->showsecs);
 	gnome_config_set_int("clock/showdate", cd->showdate);
 	gnome_config_set_int("clock/unixtime", cd->unixtime);
 	gnome_config_set_int("clock/internettime", cd->internettime);
@@ -156,10 +159,13 @@
 {
 	ComputerClock *cc;
 	struct tm *tm;
-	GString *gs = g_string_new("");
+	GString *gs = g_string_new(""), *tformat = g_string_sized_new(16);
 	char date[256], hour[256], tooltip[256];
+	int vertical;
 
 	cc = gtk_object_get_user_data(GTK_OBJECT(cd->clockw));
+	vertical = (cd->orient == ORIENT_LEFT || cd->orient == ORIENT_RIGHT) &&
+		cd->size >= PIXEL_SIZE_STANDARD;
 
 	if (cd->gmt_time)
 		tm = gmtime(&current_time);
@@ -167,8 +173,7 @@
 		tm = localtime(&current_time);
 
 	if (cd->unixtime) {
-		if ((cd->orient == ORIENT_LEFT || cd->orient == ORIENT_RIGHT) &&
-		    cd->size >= PIXEL_SIZE_STANDARD) {
+		if (vertical) {
 			g_snprintf(hour,sizeof(hour),"%lu\n%05lu",
 				   (unsigned long)(current_time/100000L),
 				   (unsigned long)(current_time%100000L));
@@ -180,29 +185,26 @@
 		float itime = get_itime (current_time);
 		g_snprintf(hour,sizeof(hour),"@%3.2f",itime);
 		g_string_append(gs,hour);
-	} else if (cd->hourformat == 12) {
-		/* This format string is used, to display the actual time in
-		   12 hour format.  */
-		if ((cd->orient == ORIENT_LEFT || cd->orient == ORIENT_RIGHT) &&
-		    cd->size >= PIXEL_SIZE_STANDARD) {
-			if (strftime(hour, sizeof (hour), _("%I:%M\n%p"), tm) <= 0)
-				strcpy (hour, "???");
-		} else {
-			if (strftime(hour, sizeof (hour), _("%I:%M %p"), tm) <= 0)
-				strcpy (hour, "???");
-		} 
-		g_string_append(gs,hour);
-	} else if (cd->hourformat == 24) {
-		/* This format string is used, to display the actual time in
-		   24 hour format.  */
-		if (strftime(hour, sizeof (hour), _("%H:%M"), tm) <= 0)
-			strcpy (hour, "???");
-		g_string_append(gs,hour);
+	} else {
+		/* Construct strftime format string. */
+		if (cd->hourformat == 12) {
+			g_string_append(tformat, "%I:%M");
+			if (cd->showsecs)
+				g_string_append(tformat, ":%S");
+			g_string_append(tformat, vertical ? "\n" : " ");
+			g_string_append(tformat, "%p");
+		} else if (cd->hourformat == 24) {
+			g_string_append(tformat, "%H:%M");
+			if (cd->showsecs)
+				g_string_append(tformat, ":%S");
+		}
+		if (strftime(hour, sizeof (hour), _(tformat->str), tm) <= 0)
+			strcpy(hour, "???");
+		g_string_append(gs, hour);
 	}
 
 	if (cd->showdate && !cd->unixtime && !cd->internettime) {
-		if ((cd->orient == ORIENT_LEFT || cd->orient == ORIENT_RIGHT) &&
-		    cd->size >= PIXEL_SIZE_STANDARD) {
+		if (vertical) {
 			/* This format string is used, to display the actual day,
 			   when showing a vertical panel.  For an explanation of
 			   this format string type 'man strftime'.  */
@@ -244,6 +246,7 @@
 	gtk_label_set_text(GTK_LABEL(cc->time), gs->str);
 	applet_widget_queue_resize(APPLET_WIDGET(cd->applet));
 	g_string_free(gs,TRUE);
+	g_string_free(tformat, TRUE);
 }
 
 static void
@@ -540,6 +543,8 @@
 		if (cd->hourformat != 12 && cd->hourformat != 24)
 			cd->hourformat = 24;
 	}
+	cd->showsecs = gnome_config_get_int("clock/showsecs=0");
+
 	/* if on a small screen don't show data by default */
 	if(gdk_screen_width()<=800)
 		cd->showdate = gnome_config_get_int("clock/showdate=0");
@@ -637,6 +642,7 @@
 	struct tm *tm;
 
 	cd->hourformat = cd->prop_hourformat;
+	cd->showsecs = cd->prop_showsecs;
 	cd->showdate = cd->prop_showdate;
 	cd->unixtime = cd->prop_unixtime;
    	cd->internettime = cd->prop_internettime;
@@ -655,7 +661,7 @@
 	else
 		tm = localtime(&current_time);
 
-	if(cd->unixtime)
+	if(cd->unixtime||cd->showsecs)
 		cd->timeouttime = 1000;
         else if(cd->internettime)
                 cd->timeouttime = INTERNETSECOND;
@@ -690,6 +696,15 @@
 }
 
 static void
+set_show_secs_cb(GtkWidget * w, gpointer data)
+{
+	ClockData *cd = data;
+
+	cd->prop_showsecs = GTK_TOGGLE_BUTTON(w)->active;
+	gnome_property_box_changed (GNOME_PROPERTY_BOX (cd->props));
+}
+
+static void
 set_show_date_cb(GtkWidget * w, gpointer data)
 {
 	ClockData *cd = data;
@@ -749,6 +764,7 @@
 	GtkWidget *table;
 	GtkWidget *twelvehour;
 	GtkWidget *twentyfourhour;
+	GtkWidget *showsecs;
 	GtkWidget *showdate;
 	GtkWidget *showtooltip;
 	GtkWidget *unixtime;
@@ -828,6 +844,20 @@
 	gtk_box_pack_start_defaults(GTK_BOX(hbox), vbox);
 	gtk_widget_show(vbox);
 
+	showsecs = gtk_check_button_new_with_label(_("Show seconds in applet"));
+	gtk_box_pack_start_defaults(GTK_BOX(vbox), showsecs);
+	gtk_widget_show(showsecs);
+
+	if (cd->showsecs)
+	  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showsecs),
+				      TRUE);
+	cd->prop_showsecs = cd->showsecs;
+
+	gtk_signal_connect(GTK_OBJECT(showsecs),
+			   "toggled",
+			   (GtkSignalFunc) set_show_secs_cb,
+			   data);
+
 	showdate = gtk_check_button_new_with_label(_("Show date in applet"));
 	gtk_box_pack_start_defaults(GTK_BOX(vbox), showdate);
 	gtk_widget_show(showdate);
@@ -883,6 +913,9 @@
 			   hour_frame);
 	gtk_signal_connect(GTK_OBJECT(unixtime), "toggled",
 			   (GtkSignalFunc) set_datasensitive_cb,
+			   showsecs);
+	gtk_signal_connect(GTK_OBJECT(unixtime), "toggled",
+			   (GtkSignalFunc) set_datasensitive_cb,
 			   showdate);
 	gtk_signal_connect(GTK_OBJECT(unixtime), "toggled",
 			   (GtkSignalFunc) set_datasensitive_cb,
@@ -903,6 +936,9 @@
 	gtk_signal_connect(GTK_OBJECT(internettime), "toggled",
 			   (GtkSignalFunc) set_datasensitive_cb,
 			   hour_frame);
+	gtk_signal_connect(GTK_OBJECT(internettime), "toggled",
+			   (GtkSignalFunc) set_datasensitive_cb,
+			   showsecs);
 	gtk_signal_connect(GTK_OBJECT(internettime), "toggled",
 			   (GtkSignalFunc) set_datasensitive_cb,
 			   showdate);
