<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40706 >
Patch implements an option to have chat messages prefixed by a time string of the form "[hour:minute:second] ". ----------------------------------------------------------------------- 誰か私の時計を見つけたか。
diff --git a/client/gui-gtk-2.0/chatline.c b/client/gui-gtk-2.0/chatline.c index 0431e22..33028d6 100644 --- a/client/gui-gtk-2.0/chatline.c +++ b/client/gui-gtk-2.0/chatline.c @@ -18,6 +18,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <gdk/gdkkeysyms.h> @@ -83,6 +84,18 @@ void real_append_output_window(const char *astring, int conn_id) buf = message_buffer; gtk_text_buffer_get_end_iter(buf, &i); gtk_text_buffer_insert(buf, &i, "\n", -1); + + if (show_chat_message_time) { + char timebuf[64]; + time_t now; + struct tm now_tm; + + now = time(NULL); + localtime_r(&now, &now_tm); + strftime(timebuf, sizeof(timebuf), "[%H:%M:%S] ", &now_tm); + gtk_text_buffer_insert(buf, &i, timebuf, -1); + } + gtk_text_buffer_insert(buf, &i, astring, -1); /* have to use a mark, or this won't work properly */ diff --git a/client/gui-gtk-2.0/gui_main.c b/client/gui-gtk-2.0/gui_main.c index 93ce820..2f79f7a 100644 --- a/client/gui-gtk-2.0/gui_main.c +++ b/client/gui-gtk-2.0/gui_main.c @@ -94,6 +94,7 @@ int overview_canvas_store_height = 2 * 50; bool enable_tabs = TRUE; bool better_fog = TRUE; +bool show_chat_message_time = FALSE; GtkWidget *toplevel; GdkWindow *root_window; @@ -178,7 +179,13 @@ client_option gui_options[] = { N_("If this is enabled then a better method is used " "for drawing fog-of-war. It is not any slower but " "will consume about twice as much memory."), - COC_GRAPHICS, mapview_redraw_callback) + COC_GRAPHICS, mapview_redraw_callback), + GEN_BOOL_OPTION(show_chat_message_time, + N_("Show time for each chat message"), + N_("If this option is enabled then all chat messages " + "will be prefixed by a time string of the form " + "[hour:minute:second]."), + COC_INTERFACE) }; const int num_gui_options = ARRAY_SIZE(gui_options); diff --git a/client/gui-gtk-2.0/gui_main.h b/client/gui-gtk-2.0/gui_main.h index 0b4c063..65c7114 100644 --- a/client/gui-gtk-2.0/gui_main.h +++ b/client/gui-gtk-2.0/gui_main.h @@ -26,6 +26,7 @@ extern PangoFontDescription * city_productions_font; extern bool enable_tabs; extern bool better_fog; +extern bool show_chat_message_time; extern GdkGC * civ_gc; extern GdkGC * mask_fg_gc;
diff --git a/client/gui-gtk-2.0/chatline.c b/client/gui-gtk-2.0/chatline.c index 1354ea3..dabb9dd 100644 --- a/client/gui-gtk-2.0/chatline.c +++ b/client/gui-gtk-2.0/chatline.c @@ -18,6 +18,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <gdk/gdkkeysyms.h> @@ -82,6 +83,18 @@ void real_append_output_window(const char *astring, int conn_id) buf = message_buffer; gtk_text_buffer_get_end_iter(buf, &i); gtk_text_buffer_insert(buf, &i, "\n", -1); + + if (show_chat_message_time) { + char timebuf[64]; + time_t now; + struct tm now_tm; + + now = time(NULL); + localtime_r(&now, &now_tm); + strftime(timebuf, sizeof(timebuf), "[%H:%M:%S] ", &now_tm); + gtk_text_buffer_insert(buf, &i, timebuf, -1); + } + gtk_text_buffer_insert(buf, &i, astring, -1); /* have to use a mark, or this won't work properly */ diff --git a/client/gui-gtk-2.0/gui_main.c b/client/gui-gtk-2.0/gui_main.c index 6448d26..c317155 100644 --- a/client/gui-gtk-2.0/gui_main.c +++ b/client/gui-gtk-2.0/gui_main.c @@ -97,6 +97,7 @@ int overview_canvas_store_height = 2 * 50; bool enable_tabs = TRUE; bool better_fog = TRUE; +bool show_chat_message_time = FALSE; GtkWidget *toplevel; GdkWindow *root_window; @@ -198,6 +199,12 @@ client_option gui_options[] = { "for drawing fog-of-war. It is not any slower but " "will consume about twice as much memory."), COC_GRAPHICS, mapview_redraw_callback), + GEN_BOOL_OPTION(show_chat_message_time, + N_("Show time for each chat message"), + N_("If this option is enabled then all chat messages " + "will be prefixed by a time string of the form " + "[hour:minute:second]."), + COC_INTERFACE), GEN_FONT_OPTION(font_city_label, city_label, N_("City Label"), diff --git a/client/gui-gtk-2.0/gui_main.h b/client/gui-gtk-2.0/gui_main.h index f5ed3fa..6cdcc46 100644 --- a/client/gui-gtk-2.0/gui_main.h +++ b/client/gui-gtk-2.0/gui_main.h @@ -26,6 +26,7 @@ extern PangoFontDescription * city_productions_font; extern bool enable_tabs; extern bool better_fog; +extern bool show_chat_message_time; extern GdkGC * civ_gc; extern GdkGC * mask_fg_gc;
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev