comparison src/gtklog.c @ 13104:e1e5462b7d81

[gaim-migrate @ 15466] Rework lots of date parsing. I either introduced a whole lot of bugs, or I've made sure all dates are localized properly now. Only time will tell which it is... ;) committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Thu, 02 Feb 2006 19:50:51 +0000
parents 0aa231ebbfd5
children fcde3faa1f57
comparison
equal deleted inserted replaced
13103:a6811e213977 13104:e1e5462b7d81
112 for (logs = lv->logs; logs != NULL; logs = logs->next) { 112 for (logs = lv->logs; logs != NULL; logs = logs->next) {
113 char *read = gaim_log_read((GaimLog*)logs->data, NULL); 113 char *read = gaim_log_read((GaimLog*)logs->data, NULL);
114 if (read && *read && gaim_strcasestr(read, search_term)) { 114 if (read && *read && gaim_strcasestr(read, search_term)) {
115 GtkTreeIter iter; 115 GtkTreeIter iter;
116 GaimLog *log = logs->data; 116 GaimLog *log = logs->data;
117 char title[64];
118 char *title_utf8; /* temporary variable for utf8 conversion */
119
120 gaim_strftime(title, sizeof(title), "%c", localtime(&log->time));
121 title_utf8 = gaim_utf8_try_convert(title);
122 strncpy(title, title_utf8, sizeof(title));
123 g_free(title_utf8);
124 117
125 gtk_tree_store_append (lv->treestore, &iter, NULL); 118 gtk_tree_store_append (lv->treestore, &iter, NULL);
126 gtk_tree_store_set(lv->treestore, &iter, 119 gtk_tree_store_set(lv->treestore, &iter,
127 0, title, 120 0, gaim_date_format_full(log->time),
128 1, log, -1); 121 1, log, -1);
129 } 122 }
130 g_free(read); 123 g_free(read);
131 } 124 }
132 125
179 GtkTreeModel *model = GTK_TREE_MODEL(viewer->treestore); 172 GtkTreeModel *model = GTK_TREE_MODEL(viewer->treestore);
180 GaimLog *log = NULL; 173 GaimLog *log = NULL;
181 GdkCursor *cursor; 174 GdkCursor *cursor;
182 GaimLogReadFlags flags; 175 GaimLogReadFlags flags;
183 char *read = NULL; 176 char *read = NULL;
184 char time[64];
185 177
186 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) 178 if (!gtk_tree_selection_get_selected(sel, &model, &iter))
187 return; 179 return;
188 180
189 val.g_type = 0; 181 val.g_type = 0;
204 gtk_main_iteration(); 196 gtk_main_iteration();
205 } 197 }
206 198
207 if (log->type != GAIM_LOG_SYSTEM) { 199 if (log->type != GAIM_LOG_SYSTEM) {
208 char *title; 200 char *title;
209 char *title_utf8; /* temporary variable for utf8 conversion */
210
211 gaim_strftime(time, sizeof(time), "%c", localtime(&log->time));
212
213 if (log->type == GAIM_LOG_CHAT) 201 if (log->type == GAIM_LOG_CHAT)
214 title = g_strdup_printf(_("Conversation in %s on %s"), log->name, time); 202 title = g_strdup_printf(_("<span size='larger' weight='bold'>Conversation in %s on %s</span>"),
203 log->name, gaim_date_format_full(log->time));
215 else 204 else
216 title = g_strdup_printf(_("Conversation with %s on %s"), log->name, time); 205 title = g_strdup_printf(_("<span size='larger' weight='bold'>Conversation with %s on %s</span>"),
217 206 log->name, gaim_date_format_full(log->time));
218 title_utf8 = gaim_utf8_try_convert(title);
219 g_free(title);
220
221 title = g_strdup_printf("<span size='larger' weight='bold'>%s</span>", title_utf8);
222 g_free(title_utf8);
223 207
224 gtk_label_set_markup(GTK_LABEL(viewer->label), title); 208 gtk_label_set_markup(GTK_LABEL(viewer->label), title);
225 g_free(title); 209 g_free(title);
226 } 210 }
227 211
257 */ 241 */
258 static void populate_log_tree(GaimGtkLogViewer *lv) 242 static void populate_log_tree(GaimGtkLogViewer *lv)
259 /* Logs are made from trees in real life. 243 /* Logs are made from trees in real life.
260 This is a tree made from logs */ 244 This is a tree made from logs */
261 { 245 {
262 char month[30]; 246 const char *month;
263 char title[64];
264 char prev_top_month[30] = ""; 247 char prev_top_month[30] = "";
265 char *utf8_tmp; /* temporary variable for utf8 conversion */
266 GtkTreeIter toplevel, child; 248 GtkTreeIter toplevel, child;
267 GList *logs = lv->logs; 249 GList *logs = lv->logs;
268 250
269 while (logs != NULL) { 251 while (logs != NULL) {
270 GaimLog *log = logs->data; 252 GaimLog *log = logs->data;
271 253
272 gaim_strftime(month, sizeof(month), "%B %Y", localtime(&log->time)); 254 month = gaim_utf8_strftime(_("%B %Y"), localtime(&log->time));
273 gaim_strftime(title, sizeof(title), "%c", localtime(&log->time)); 255
274 256 if (strcmp(month, prev_top_month) != 0)
275 /* do utf8 conversions */ 257 {
276 utf8_tmp = gaim_utf8_try_convert(month);
277 strncpy(month, utf8_tmp, sizeof(month));
278 g_free(utf8_tmp);
279 utf8_tmp = gaim_utf8_try_convert(title);
280 strncpy(title, utf8_tmp, sizeof(title));
281 g_free(utf8_tmp);
282
283 if (strncmp(month, prev_top_month, sizeof(month)) != 0) {
284 /* top level */ 258 /* top level */
285 gtk_tree_store_append(lv->treestore, &toplevel, NULL); 259 gtk_tree_store_append(lv->treestore, &toplevel, NULL);
286 gtk_tree_store_set(lv->treestore, &toplevel, 0, month, 1, NULL, -1); 260 gtk_tree_store_set(lv->treestore, &toplevel, 0, month, 1, NULL, -1);
287 261
288 strncpy(prev_top_month, month, sizeof(prev_top_month)); 262 strncpy(prev_top_month, month, sizeof(prev_top_month));
289 } 263 }
290 264
291 /* sub */ 265 /* sub */
292 gtk_tree_store_append(lv->treestore, &child, &toplevel); 266 gtk_tree_store_append(lv->treestore, &child, &toplevel);
293 gtk_tree_store_set(lv->treestore, &child, 0, title, 1, log, -1); 267 gtk_tree_store_set(lv->treestore, &child,
268 0, gaim_date_format_full(log->time),
269 1, log,
270 -1);
294 271
295 logs = logs->next; 272 logs = logs->next;
296 } 273 }
297 } 274 }
298 275