SF.net SVN: geany: [515] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Sat Jul 1 12:02:39 UTC 2006


Revision: 515
Author:   ntrel
Date:     2006-07-01 05:02:30 -0700 (Sat, 01 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=515&view=rev

Log Message:
-----------
Add utils_get_current_time_string and fix getting the time string

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/msgwindow.c
    trunk/src/utils.c
    trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-07-01 10:44:15 UTC (rev 514)
+++ trunk/ChangeLog	2006-07-01 12:02:30 UTC (rev 515)
@@ -3,6 +3,8 @@
  * src/notebook.c: Don't prevent notebook tab focus because this
                    disables the notebook arrows.
  * src/callbacks.c: Prevent a segfault if the VTE has not been loaded.
+ * src/utils.c, src/utils.h, src/msgwindow.c:
+   Add utils_get_current_time_string and fix getting the time string.
 
 
 2006-06-30  Enrico Tröger  <enrico.troeger at uvena.de>

Modified: trunk/src/msgwindow.c
===================================================================
--- trunk/src/msgwindow.c	2006-07-01 10:44:15 UTC (rev 514)
+++ trunk/src/msgwindow.c	2006-07-01 12:02:30 UTC (rev 515)
@@ -169,6 +169,7 @@
 	GtkTreeIter iter;
 	static gint state = 0;
 	static gchar string[512];
+	gchar *statusmsg, *time_str;
 	va_list args;
 
 	//if (! app->msgwindow_visible) return;
@@ -183,26 +184,19 @@
 	gtk_list_store_append(msgwindow.store_status, &iter);
 	//gtk_list_store_insert(msgwindow.store_status, &iter, 0);
 	//gtk_list_store_set(msgwindow.store_status, &iter, 0, (state > 0) ? &white : &dark, 1, string, -1);
-	{
-		GTimeVal cur_time;
-		gchar *date_str, *statusmsg;
-		gchar **strv;
 
-		g_get_current_time(&cur_time);
-		date_str = ctime(&cur_time.tv_sec); //uses internal string buffer
-		strv = g_strsplit(date_str, " ", 5);
-		if (strv[3] != NULL)
-			statusmsg = g_strconcat(strv[3], ": ", string, NULL);
-		else
-			statusmsg = g_strdup(string);
+	// add a timestamp to status messages
+	time_str = utils_get_current_time_string();
+	if (time_str == NULL)
+		statusmsg = g_strdup(string);
+	else
+		statusmsg = g_strconcat(time_str, ": ", string, NULL);
+	g_free(time_str);
 
-		gtk_list_store_set(msgwindow.store_status, &iter, 0,
-			((state++ % 2) == 0) ? &white : &dark, 1, statusmsg, -1);
+	gtk_list_store_set(msgwindow.store_status, &iter, 0,
+		((state++ % 2) == 0) ? &white : &dark, 1, statusmsg, -1);
+	g_free(statusmsg);
 
-		g_free(statusmsg);
-		g_strfreev(strv);
-	}
-
 	if (app->main_window_realized)
 	{
 		GtkTreePath *path = gtk_tree_model_get_path(gtk_tree_view_get_model(GTK_TREE_VIEW(msgwindow.tree_status)), &iter);

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2006-07-01 10:44:15 UTC (rev 514)
+++ trunk/src/utils.c	2006-07-01 12:02:30 UTC (rev 515)
@@ -2475,3 +2475,24 @@
 
 	g_strfreev(fields);
 }
+
+
+// returned string must be freed.
+gchar *utils_get_current_time_string()
+{
+	GTimeVal cur_time;
+	gchar *date_str, *time_str, *result;
+	gchar **strv;
+
+	g_get_current_time(&cur_time);
+	date_str = ctime(&cur_time.tv_sec); //uses internal string buffer
+	strv = g_strsplit(date_str, " ", 6);
+
+	// if single digit day then strv[2] will be empty
+	time_str = (*strv[2] == 0) ? strv[4] : strv[3];
+	result = g_strdup(time_str);
+	g_strfreev(strv);
+	return result;
+}
+
+

Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h	2006-07-01 10:44:15 UTC (rev 514)
+++ trunk/src/utils.h	2006-07-01 12:02:30 UTC (rev 515)
@@ -217,4 +217,7 @@
  * filename must be freed unless it is NULL. */
 void utils_parse_compiler_error_line(const gchar *string, gchar **filename, gint *line);
 
+// returned string must be freed.
+gchar *utils_get_current_time_string();
+
 #endif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list