/*
* Sylpheed templates subsystem
* Copyright (C) 2001 Alexander Barinov
- * Copyright (C) 2001-2006 Hiroyuki Yamamoto and the Sylpheed-Claws team
+ * Copyright (C) 2001-2007 Hiroyuki Yamamoto and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
}
tmpl = g_new(Template, 1);
+ tmpl->load_filename = g_strdup(filename);;
tmpl->name = NULL;
tmpl->subject = NULL;
tmpl->to = NULL;
void template_free(Template *tmpl)
{
+ g_free(tmpl->load_filename);
g_free(tmpl->name);
g_free(tmpl->subject);
g_free(tmpl->to);
g_slist_free(tmpl_list);
}
-gint tmpl_compare(gconstpointer tmpl1, gconstpointer tmpl2)
+static gint tmpl_compare(gconstpointer tmpl1, gconstpointer tmpl2)
{
+ gchar *basename1, *basename2;
+ long filenum1, filenum2;
+ gint ret = 0;
+
if ((Template *)tmpl1 == NULL || (Template *)tmpl2 == NULL)
return 0;
- if (((Template *)tmpl1)->name == NULL || ((Template *)tmpl2)->name == NULL)
+ if (((Template *)tmpl1)->load_filename == NULL || ((Template *)tmpl2)->load_filename == NULL)
+ return 0;
+
+ basename1 = g_path_get_basename(((Template *)tmpl1)->load_filename);
+ basename2 = g_path_get_basename(((Template *)tmpl2)->load_filename);
+ filenum1 = atol(basename1);
+ filenum2 = atol(basename2);
+ g_free(basename1);
+ g_free(basename2);
+
+ if (filenum1 == 0 || filenum2 == 0)
return 0;
- return (gint) strcmp((char *)((Template *)tmpl1)->name,
- (char *)((Template *)tmpl2)->name);
+ if (filenum1 < filenum2)
+ ret = -1;
+ else
+ if (filenum1 > filenum2)
+ ret = 1;
+
+ return ret;
}
GSList *template_read_config(void)