gui/view: Show sort indicators on columns
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
cacd344741
commit
d5c365ddf0
42
gui/view.c
42
gui/view.c
|
@ -10,6 +10,7 @@
|
|||
#include <gui/queue.h>
|
||||
#include <gui/settings.h>
|
||||
#include <gui/view.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static const gchar *QUEUE_SETTINGS[Q_MODEL_N_COLUMNS] = {
|
||||
[Q_MODEL_TRACK_NR] = "gui.queue.track",
|
||||
|
@ -104,6 +105,44 @@ static int __view_dec_sort(gpointer data)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static void __view_set_column_sort_indicator(GtkTreeViewColumn *col,
|
||||
unsigned int index)
|
||||
{
|
||||
struct queue *queue = __view_filter_get_queue();
|
||||
GSList *cur = queue ? queue->q_sort : NULL;
|
||||
unsigned int order = GTK_SORT_ASCENDING;
|
||||
bool show = false;
|
||||
int field;
|
||||
|
||||
while (cur) {
|
||||
order = GTK_SORT_ASCENDING;
|
||||
field = GPOINTER_TO_INT(cur->data);
|
||||
|
||||
if (abs(field) == QUEUE_SORT[index]) {
|
||||
show = true;
|
||||
if (field < 0)
|
||||
order = GTK_SORT_DESCENDING;
|
||||
break;
|
||||
}
|
||||
|
||||
cur = g_slist_next(cur);
|
||||
}
|
||||
|
||||
gtk_tree_view_column_set_sort_indicator(col, show);
|
||||
gtk_tree_view_column_set_sort_order(col, order);
|
||||
}
|
||||
|
||||
static void __view_set_sort_indicators()
|
||||
{
|
||||
GtkTreeViewColumn *col;
|
||||
|
||||
for (unsigned int i = 0; i < Q_MODEL_N_COLUMNS; i++) {
|
||||
col = gtk_tree_view_get_column(view_treeview, i);
|
||||
if (col)
|
||||
__view_set_column_sort_indicator(col, i);
|
||||
}
|
||||
}
|
||||
|
||||
void __view_row_activated(GtkTreeView *treeview, GtkTreePath *path,
|
||||
GtkTreeViewColumn *col, gpointer data)
|
||||
{
|
||||
|
@ -138,6 +177,8 @@ void __view_column_clicked(GtkTreeViewColumn *col, gpointer data)
|
|||
g_free(text);
|
||||
}
|
||||
|
||||
__view_set_sort_indicators();
|
||||
|
||||
view_sort_count++;
|
||||
g_timeout_add_seconds(3, __view_dec_sort, NULL);
|
||||
}
|
||||
|
@ -299,4 +340,5 @@ void gui_view_set_model(GtkTreeModelFilter *filter)
|
|||
|
||||
view_sort_count = 0;
|
||||
__view_display_sorting("");
|
||||
__view_set_sort_indicators();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue