# HG changeset patch # User Richard Laager # Date 1163915810 0 # Node ID db590283788d3d01c793c32658facd8f975d0658 # Parent fee45b614eb7ce834c9ddf57dca7c9bb42598f92 [gaim-migrate @ 17777] Refactor some duplicated code, and fix a case where that code hadn't been duplicated properly. committer: Tailor Script diff -r fee45b614eb7 -r db590283788d gtk/gtklog.c --- a/gtk/gtklog.c Sun Nov 19 05:56:07 2006 +0000 +++ b/gtk/gtklog.c Sun Nov 19 05:56:50 2006 +0000 @@ -106,6 +106,14 @@ gtk_tree_path_free(path); } +static const char *log_get_date(GaimLog *log) +{ + if (log->tm) + return gaim_date_format_full(log->tm); + else + return gaim_date_format_full(localtime(&log->time)); +} + static void search_cb(GtkWidget *button, GaimGtkLogViewer *lv) { const char *search_term = gtk_entry_get_text(GTK_ENTRY(lv->entry)); @@ -145,7 +153,7 @@ gtk_tree_store_append (lv->treestore, &iter, NULL); gtk_tree_store_set(lv->treestore, &iter, - 0, gaim_date_format_full(localtime(&log->time)), + 0, log_get_date(log), 1, log, -1); } g_free(read); @@ -217,14 +225,10 @@ char *title; if (log->type == GAIM_LOG_CHAT) title = g_strdup_printf(_("Conversation in %s on %s"), - log->name, - log->tm ? gaim_date_format_full(log->tm) : - gaim_date_format_full(localtime(&log->time))); + log->name, log_get_date(log)); else title = g_strdup_printf(_("Conversation with %s on %s"), - log->name, - log->tm ? gaim_date_format_full(log->tm) : - gaim_date_format_full(localtime(&log->time))); + log->name, log_get_date(log)); gtk_label_set_markup(GTK_LABEL(viewer->label), title); g_free(title); @@ -285,7 +289,7 @@ /* sub */ gtk_tree_store_append(lv->treestore, &child, &toplevel); gtk_tree_store_set(lv->treestore, &child, - 0, log->tm ? gaim_date_format_full(log->tm) : gaim_date_format_full(localtime(&log->time)), + 0, log_get_date(log), 1, log, -1);