+static gint priority_cmp(GtkTreeModel *model,
+ GtkTreeIter *a,
+ GtkTreeIter *b,
+ gpointer user_data)
+{
+ GValue v1 = {0,}, v2 = {0,};
+ const char *str1, *str2;
+ int i1, i2;
+
+ gtk_tree_model_get_value(model, a, COL_PRIORITY, &v1);
+ str1 = g_value_get_string(&v1);
+ i1 = priority_to_int(str1);
+
+ gtk_tree_model_get_value(model, b, COL_PRIORITY, &v2);
+ str2 = g_value_get_string(&v2);
+ i2 = priority_to_int(str2);
+
+ if (i1 < i2)
+ return -1;
+ else if (i1 > i2)
+ return 1;
+ else
+ return 0;
+}
+
+static void log_init()
+{
+ char *home, *path, *dir;
+
+ home = getenv("HOME");
+
+ if (!home)
+ return ;
+
+ dir = malloc(strlen(home)+1+strlen(".ptask")+1);
+ sprintf(dir, "%s/%s", home, ".ptask");
+ mkdir(dir, 0777);
+
+ path = malloc(strlen(dir)+1+strlen("log")+1);
+ sprintf(path, "%s/%s", dir, "log");
+
+ log_open(path);
+
+ free(dir);
+ free(path);
+}
+