gui/filter: Add a function for converting filter paths to indexes
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
f550d45811
commit
ad29c520d4
|
@ -37,3 +37,11 @@ struct track *gui_filter_path_get_track(GtkTreePath *path)
|
||||||
gtk_tree_path_free(real);
|
gtk_tree_path_free(real);
|
||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int gui_filter_path_get_index(GtkTreePath *path)
|
||||||
|
{
|
||||||
|
GtkTreePath *real = __gui_filter_convert_path(path);
|
||||||
|
unsigned int ret = gtk_tree_path_get_indices(real)[0];
|
||||||
|
gtk_tree_path_free(real);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
17
gui/view.c
17
gui/view.c
|
@ -40,21 +40,6 @@ static GtkTreeView *view_treeview = NULL;
|
||||||
static unsigned int view_sort_count = 0;
|
static unsigned int view_sort_count = 0;
|
||||||
static bool view_no_scroll = false;
|
static bool view_no_scroll = false;
|
||||||
|
|
||||||
static inline GtkTreePath *__view_filter_convert_path(GtkTreePath *orig)
|
|
||||||
{
|
|
||||||
return gtk_tree_model_filter_convert_path_to_child_path(
|
|
||||||
gui_filter_get(), orig);
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int __view_filter_get_index(GtkTreePath *orig)
|
|
||||||
{
|
|
||||||
GtkTreePath *real = __view_filter_convert_path(orig);
|
|
||||||
unsigned int ret = gtk_tree_path_get_indices(real)[0];
|
|
||||||
|
|
||||||
gtk_tree_path_free(real);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int __view_get_column_index(GtkTreeViewColumn *col)
|
static unsigned int __view_get_column_index(GtkTreeViewColumn *col)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -189,7 +174,7 @@ static void __view_delete_selection(GtkTreeSelection *selection)
|
||||||
GList *cur = g_list_reverse(rows);
|
GList *cur = g_list_reverse(rows);
|
||||||
|
|
||||||
while (cur) {
|
while (cur) {
|
||||||
queue_erase(queue, __view_filter_get_index(cur->data));
|
queue_erase(queue, gui_filter_path_get_index(cur->data));
|
||||||
cur = g_list_next(cur);
|
cur = g_list_next(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,7 @@ GtkTreeModelFilter *gui_filter_get();
|
||||||
/* Called to convert a filter model path into a track. */
|
/* Called to convert a filter model path into a track. */
|
||||||
struct track *gui_filter_path_get_track(GtkTreePath *);
|
struct track *gui_filter_path_get_track(GtkTreePath *);
|
||||||
|
|
||||||
|
/* Called to convert a filter model path into a queue index. */
|
||||||
|
unsigned int gui_filter_path_get_index(GtkTreePath *);
|
||||||
|
|
||||||
#endif /* OCARINA_GUI_FILTER_H */
|
#endif /* OCARINA_GUI_FILTER_H */
|
||||||
|
|
|
@ -62,10 +62,11 @@ void test_filter()
|
||||||
|
|
||||||
g_assert_true(gtk_tree_model_get_iter_first(model, &iter));
|
g_assert_true(gtk_tree_model_get_iter_first(model, &iter));
|
||||||
path = gtk_tree_model_get_path(model, &iter);
|
path = gtk_tree_model_get_path(model, &iter);
|
||||||
for (i = 1; i <= 13; i++) {
|
for (i = 0; i < 13; i++) {
|
||||||
track = gui_filter_path_get_track(path);
|
track = gui_filter_path_get_track(path);
|
||||||
g_assert_nonnull(track);
|
g_assert_nonnull(track);
|
||||||
g_assert_cmpuint(track->tr_track, ==, i);
|
g_assert_cmpuint(track->tr_track, ==, i + 1);
|
||||||
|
g_assert_cmpuint(gui_filter_path_get_index(path), ==, i);
|
||||||
gtk_tree_path_next(path);
|
gtk_tree_path_next(path);
|
||||||
}
|
}
|
||||||
g_assert_null(gui_filter_path_get_track(path));
|
g_assert_null(gui_filter_path_get_track(path));
|
||||||
|
|
Loading…
Reference in New Issue