Mercurial > pidgin.yaz
comparison gtk/gtklog.c @ 14999:db590283788d
[gaim-migrate @ 17777]
Refactor some duplicated code, and fix a case where that code hadn't been duplicated properly.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 19 Nov 2006 05:56:50 +0000 |
parents | e908bff64af5 |
children | 2bcb8684bfb5 |
comparison
equal
deleted
inserted
replaced
14998:fee45b614eb7 | 14999:db590283788d |
---|---|
104 gtk_tree_selection_select_path(gtk_tree_view_get_selection(GTK_TREE_VIEW(lv->treeview)), path); | 104 gtk_tree_selection_select_path(gtk_tree_view_get_selection(GTK_TREE_VIEW(lv->treeview)), path); |
105 | 105 |
106 gtk_tree_path_free(path); | 106 gtk_tree_path_free(path); |
107 } | 107 } |
108 | 108 |
109 static const char *log_get_date(GaimLog *log) | |
110 { | |
111 if (log->tm) | |
112 return gaim_date_format_full(log->tm); | |
113 else | |
114 return gaim_date_format_full(localtime(&log->time)); | |
115 } | |
116 | |
109 static void search_cb(GtkWidget *button, GaimGtkLogViewer *lv) | 117 static void search_cb(GtkWidget *button, GaimGtkLogViewer *lv) |
110 { | 118 { |
111 const char *search_term = gtk_entry_get_text(GTK_ENTRY(lv->entry)); | 119 const char *search_term = gtk_entry_get_text(GTK_ENTRY(lv->entry)); |
112 GList *logs; | 120 GList *logs; |
113 | 121 |
143 GtkTreeIter iter; | 151 GtkTreeIter iter; |
144 GaimLog *log = logs->data; | 152 GaimLog *log = logs->data; |
145 | 153 |
146 gtk_tree_store_append (lv->treestore, &iter, NULL); | 154 gtk_tree_store_append (lv->treestore, &iter, NULL); |
147 gtk_tree_store_set(lv->treestore, &iter, | 155 gtk_tree_store_set(lv->treestore, &iter, |
148 0, gaim_date_format_full(localtime(&log->time)), | 156 0, log_get_date(log), |
149 1, log, -1); | 157 1, log, -1); |
150 } | 158 } |
151 g_free(read); | 159 g_free(read); |
152 } | 160 } |
153 | 161 |
215 | 223 |
216 if (log->type != GAIM_LOG_SYSTEM) { | 224 if (log->type != GAIM_LOG_SYSTEM) { |
217 char *title; | 225 char *title; |
218 if (log->type == GAIM_LOG_CHAT) | 226 if (log->type == GAIM_LOG_CHAT) |
219 title = g_strdup_printf(_("<span size='larger' weight='bold'>Conversation in %s on %s</span>"), | 227 title = g_strdup_printf(_("<span size='larger' weight='bold'>Conversation in %s on %s</span>"), |
220 log->name, | 228 log->name, log_get_date(log)); |
221 log->tm ? gaim_date_format_full(log->tm) : | |
222 gaim_date_format_full(localtime(&log->time))); | |
223 else | 229 else |
224 title = g_strdup_printf(_("<span size='larger' weight='bold'>Conversation with %s on %s</span>"), | 230 title = g_strdup_printf(_("<span size='larger' weight='bold'>Conversation with %s on %s</span>"), |
225 log->name, | 231 log->name, log_get_date(log)); |
226 log->tm ? gaim_date_format_full(log->tm) : | |
227 gaim_date_format_full(localtime(&log->time))); | |
228 | 232 |
229 gtk_label_set_markup(GTK_LABEL(viewer->label), title); | 233 gtk_label_set_markup(GTK_LABEL(viewer->label), title); |
230 g_free(title); | 234 g_free(title); |
231 } | 235 } |
232 | 236 |
283 } | 287 } |
284 | 288 |
285 /* sub */ | 289 /* sub */ |
286 gtk_tree_store_append(lv->treestore, &child, &toplevel); | 290 gtk_tree_store_append(lv->treestore, &child, &toplevel); |
287 gtk_tree_store_set(lv->treestore, &child, | 291 gtk_tree_store_set(lv->treestore, &child, |
288 0, log->tm ? gaim_date_format_full(log->tm) : gaim_date_format_full(localtime(&log->time)), | 292 0, log_get_date(log), |
289 1, log, | 293 1, log, |
290 -1); | 294 -1); |
291 | 295 |
292 logs = logs->next; | 296 logs = logs->next; |
293 } | 297 } |