Kaydet (Commit) 2aa7ae45 authored tarafından Nick Treleaven's avatar Nick Treleaven

Add utils_get_current_time_string and fix getting the time string

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@515 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst e1f43a4d
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
* src/notebook.c: Don't prevent notebook tab focus because this * src/notebook.c: Don't prevent notebook tab focus because this
disables the notebook arrows. disables the notebook arrows.
* src/callbacks.c: Prevent a segfault if the VTE has not been loaded. * 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@uvena.de> 2006-06-30 Enrico Tröger <enrico.troeger@uvena.de>
......
...@@ -169,6 +169,7 @@ void msgwin_status_add(gchar const *format, ...) ...@@ -169,6 +169,7 @@ void msgwin_status_add(gchar const *format, ...)
GtkTreeIter iter; GtkTreeIter iter;
static gint state = 0; static gint state = 0;
static gchar string[512]; static gchar string[512];
gchar *statusmsg, *time_str;
va_list args; va_list args;
//if (! app->msgwindow_visible) return; //if (! app->msgwindow_visible) return;
...@@ -183,25 +184,18 @@ void msgwin_status_add(gchar const *format, ...) ...@@ -183,25 +184,18 @@ void msgwin_status_add(gchar const *format, ...)
gtk_list_store_append(msgwindow.store_status, &iter); gtk_list_store_append(msgwindow.store_status, &iter);
//gtk_list_store_insert(msgwindow.store_status, &iter, 0); //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); //gtk_list_store_set(msgwindow.store_status, &iter, 0, (state > 0) ? &white : &dark, 1, string, -1);
{
GTimeVal cur_time; // add a timestamp to status messages
gchar *date_str, *statusmsg; time_str = utils_get_current_time_string();
gchar **strv; if (time_str == NULL)
statusmsg = g_strdup(string);
g_get_current_time(&cur_time); else
date_str = ctime(&cur_time.tv_sec); //uses internal string buffer statusmsg = g_strconcat(time_str, ": ", string, NULL);
strv = g_strsplit(date_str, " ", 5); g_free(time_str);
if (strv[3] != NULL)
statusmsg = g_strconcat(strv[3], ": ", string, NULL); gtk_list_store_set(msgwindow.store_status, &iter, 0,
else ((state++ % 2) == 0) ? &white : &dark, 1, statusmsg, -1);
statusmsg = g_strdup(string); g_free(statusmsg);
gtk_list_store_set(msgwindow.store_status, &iter, 0,
((state++ % 2) == 0) ? &white : &dark, 1, statusmsg, -1);
g_free(statusmsg);
g_strfreev(strv);
}
if (app->main_window_realized) if (app->main_window_realized)
{ {
......
...@@ -2475,3 +2475,24 @@ void utils_parse_compiler_error_line(const gchar *string, gchar **filename, gint ...@@ -2475,3 +2475,24 @@ void utils_parse_compiler_error_line(const gchar *string, gchar **filename, gint
g_strfreev(fields); 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;
}
...@@ -217,4 +217,7 @@ double utils_strtod(const char *source, char **end); ...@@ -217,4 +217,7 @@ double utils_strtod(const char *source, char **end);
* filename must be freed unless it is NULL. */ * filename must be freed unless it is NULL. */
void utils_parse_compiler_error_line(const gchar *string, gchar **filename, gint *line); 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 #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment