Now using built-in sorting function for date (with timestamp as data source)

newfile
Markus Koch 2017-01-31 22:36:13 +01:00
parent 40c2b77d39
commit ae843c384d
1 changed files with 1 additions and 23 deletions

View File

@ -8,26 +8,6 @@ enum {
COL_COUNT
};
static gint
mainWindow_sort_date_compare_func(GtkTreeModel *model,
GtkTreeIter *a,
GtkTreeIter *b,
gpointer userdata)
{
guint time1, time2;
gtk_tree_model_get(model, a, COL_TIMESTAMP, &time1, -1);
gtk_tree_model_get(model, b, COL_TIMESTAMP, &time2, -1);
if (time1 == time2)
return 0;
else if (time1 > time2)
return 1;
else
return -1;
}
static void mainWindow_configure_treeView(struct mainWindow *mainWindow)
{
GtkCellRenderer *renderer;
@ -47,7 +27,7 @@ static void mainWindow_configure_treeView(struct mainWindow *mainWindow)
"text", COL_DATE, NULL);
col = gtk_tree_view_get_column(mainWindow->entryListView, COL_DATE);
gtk_tree_view_column_set_resizable(col, 1);
gtk_tree_view_column_set_sort_column_id(col, COL_DATE);
gtk_tree_view_column_set_sort_column_id(col, COL_TIMESTAMP);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(mainWindow->entryListView, -1, "Tags", renderer,
@ -57,8 +37,6 @@ static void mainWindow_configure_treeView(struct mainWindow *mainWindow)
gtk_tree_view_column_set_sort_column_id(col, COL_TAGS);
sortable = GTK_TREE_SORTABLE(mainWindow->entryListStore);
gtk_tree_sortable_set_sort_func(sortable, COL_DATE, mainWindow_sort_date_compare_func,
GINT_TO_POINTER(COL_DATE), NULL);
gtk_tree_sortable_set_sort_column_id(sortable, COL_DATE, GTK_SORT_DESCENDING);
/*