Now using built-in sorting function for date (with timestamp as data source)
This commit is contained in:
parent
40c2b77d39
commit
ae843c384d
@ -8,26 +8,6 @@ enum {
|
|||||||
COL_COUNT
|
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)
|
static void mainWindow_configure_treeView(struct mainWindow *mainWindow)
|
||||||
{
|
{
|
||||||
GtkCellRenderer *renderer;
|
GtkCellRenderer *renderer;
|
||||||
@ -47,7 +27,7 @@ static void mainWindow_configure_treeView(struct mainWindow *mainWindow)
|
|||||||
"text", COL_DATE, NULL);
|
"text", COL_DATE, NULL);
|
||||||
col = gtk_tree_view_get_column(mainWindow->entryListView, COL_DATE);
|
col = gtk_tree_view_get_column(mainWindow->entryListView, COL_DATE);
|
||||||
gtk_tree_view_column_set_resizable(col, 1);
|
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();
|
renderer = gtk_cell_renderer_text_new();
|
||||||
gtk_tree_view_insert_column_with_attributes(mainWindow->entryListView, -1, "Tags", renderer,
|
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);
|
gtk_tree_view_column_set_sort_column_id(col, COL_TAGS);
|
||||||
|
|
||||||
sortable = GTK_TREE_SORTABLE(mainWindow->entryListStore);
|
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);
|
gtk_tree_sortable_set_sort_column_id(sortable, COL_DATE, GTK_SORT_DESCENDING);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user