2016-08-21 10:27:52 -04:00
|
|
|
/*
|
|
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#include <gui/filter.h>
|
|
|
|
#include <gui/model.h>
|
|
|
|
|
|
|
|
static GtkTreeModelFilter *filter_model = NULL;
|
|
|
|
|
|
|
|
|
2016-08-21 12:49:07 -04:00
|
|
|
static inline GtkTreePath *__gui_filter_convert_path(GtkTreePath *path)
|
|
|
|
{
|
|
|
|
return gtk_tree_model_filter_convert_path_to_child_path(filter_model,
|
|
|
|
path);
|
|
|
|
}
|
|
|
|
|
2016-08-21 10:27:52 -04:00
|
|
|
void gui_filter_init()
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = GTK_TREE_MODEL(gui_model_get());
|
|
|
|
GtkTreeModel *filter = gtk_tree_model_filter_new(model, NULL);
|
|
|
|
filter_model = GTK_TREE_MODEL_FILTER(filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_filter_deinit()
|
|
|
|
{
|
|
|
|
g_object_unref(G_OBJECT(filter_model));
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkTreeModelFilter *gui_filter_get()
|
|
|
|
{
|
|
|
|
return filter_model;
|
|
|
|
}
|
2016-08-21 12:49:07 -04:00
|
|
|
|
|
|
|
struct track *gui_filter_path_get_track(GtkTreePath *path)
|
|
|
|
{
|
|
|
|
GtkTreePath *real = __gui_filter_convert_path(path);
|
|
|
|
struct track *track = real ? gui_model_path_get_track(real) : NULL;
|
|
|
|
gtk_tree_path_free(real);
|
|
|
|
return track;
|
|
|
|
}
|