Mercurial > pidgin.yaz
comparison pidgin/plugins/timestamp_format.c @ 16819:422bcef3154c
Fix ticket #559:
Message Timestamp Formats Parentheses Bug
If you choose "Force traditional..." or set the date to be displayed always
in the conversation window, there are no longer parentheses around the
date/time.
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Thu, 03 May 2007 13:12:16 +0000 |
parents | 3d41d0d7fb9b |
children | 09f0bb67a87f |
comparison
equal
deleted
inserted
replaced
16818:f7466b0379e8 | 16819:422bcef3154c |
---|---|
56 | 56 |
57 static char *timestamp_cb_common(PurpleConversation *conv, | 57 static char *timestamp_cb_common(PurpleConversation *conv, |
58 time_t t, | 58 time_t t, |
59 gboolean show_date, | 59 gboolean show_date, |
60 gboolean force, | 60 gboolean force, |
61 const char *dates) | 61 const char *dates, |
62 gboolean parens) | |
62 { | 63 { |
63 g_return_val_if_fail(dates != NULL, NULL); | 64 g_return_val_if_fail(dates != NULL, NULL); |
64 | 65 |
65 if (show_date || | 66 if (show_date || |
66 !strcmp(dates, "always") || | 67 !strcmp(dates, "always") || |
67 (conv != NULL && purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT && !strcmp(dates, "chats"))) | 68 (conv != NULL && purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT && !strcmp(dates, "chats"))) |
68 { | 69 { |
69 struct tm *tm = localtime(&t); | 70 struct tm *tm = localtime(&t); |
70 if (force) | 71 if (force) |
71 return g_strdup(purple_utf8_strftime("%Y-%m-%d %H:%M:%S", tm)); | 72 return g_strdup_printf("%s%s%s", parens ? "(" : "", purple_utf8_strftime("%Y-%m-%d %H:%M:%S", tm), parens ? ")" : ""); |
72 else | 73 else |
73 return g_strdup(purple_date_format_long(tm)); | 74 return g_strdup_printf("%s%s%s", parens ? "(" : "", purple_date_format_long(tm), parens ? ")" : ""); |
74 } | 75 } |
75 | 76 |
76 if (force) | 77 if (force) |
77 { | 78 { |
78 struct tm *tm = localtime(&t); | 79 struct tm *tm = localtime(&t); |
79 return g_strdup(purple_utf8_strftime("%H:%M:%S", tm)); | 80 return g_strdup_printf("%s%s%s", parens ? "(" : "", purple_utf8_strftime("%H:%M:%S", tm), parens ? ")" : ""); |
80 } | 81 } |
81 | 82 |
82 return NULL; | 83 return NULL; |
83 } | 84 } |
84 | 85 |
90 const char *dates = purple_prefs_get_string( | 91 const char *dates = purple_prefs_get_string( |
91 "/plugins/gtk/timestamp_format/use_dates/conversation"); | 92 "/plugins/gtk/timestamp_format/use_dates/conversation"); |
92 | 93 |
93 g_return_val_if_fail(conv != NULL, NULL); | 94 g_return_val_if_fail(conv != NULL, NULL); |
94 | 95 |
95 return timestamp_cb_common(conv, t, show_date, force, dates); | 96 return timestamp_cb_common(conv, t, show_date, force, dates, TRUE); |
96 } | 97 } |
97 | 98 |
98 static char *log_timestamp_cb(PurpleLog *log, time_t t, gboolean show_date, gpointer data) | 99 static char *log_timestamp_cb(PurpleLog *log, time_t t, gboolean show_date, gpointer data) |
99 { | 100 { |
100 gboolean force = purple_prefs_get_bool( | 101 gboolean force = purple_prefs_get_bool( |
102 const char *dates = purple_prefs_get_string( | 103 const char *dates = purple_prefs_get_string( |
103 "/plugins/gtk/timestamp_format/use_dates/log"); | 104 "/plugins/gtk/timestamp_format/use_dates/log"); |
104 | 105 |
105 g_return_val_if_fail(log != NULL, NULL); | 106 g_return_val_if_fail(log != NULL, NULL); |
106 | 107 |
107 return timestamp_cb_common(log->conv, t, show_date, force, dates); | 108 return timestamp_cb_common(log->conv, t, show_date, force, dates, FALSE); |
108 } | 109 } |
109 | 110 |
110 static gboolean | 111 static gboolean |
111 plugin_load(PurplePlugin *plugin) | 112 plugin_load(PurplePlugin *plugin) |
112 { | 113 { |