gui/view: Add gui_view_set_model()
To set the currently displayed treemodel Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
76a6eba537
commit
bbf111ecb0
|
@ -6,6 +6,7 @@
|
|||
#include <gui/builder.h>
|
||||
#include <gui/model.h>
|
||||
#include <gui/queue.h>
|
||||
#include <gui/view.h>
|
||||
|
||||
static struct gui_queue *gq_queue = NULL;
|
||||
|
||||
|
@ -94,13 +95,13 @@ struct gui_queue *gui_queue_alloc(struct queue *queue, const gchar *text,
|
|||
|
||||
void gui_queue_free(struct queue *queue)
|
||||
{
|
||||
GtkTreeView *treeview = GTK_TREE_VIEW(gui_builder_widget("o_treeview"));
|
||||
struct gui_queue *gq = gui_queue(queue);
|
||||
|
||||
gtk_tree_view_set_model(treeview, NULL);
|
||||
set_deinit(&gq->gq_visible);
|
||||
queue->q_private = NULL;
|
||||
|
||||
if (gq_queue == gq)
|
||||
gui_view_set_model(NULL);
|
||||
g_object_unref(gq->gq_model);
|
||||
g_free(gq->gq_text);
|
||||
g_free(gq);
|
||||
|
@ -125,7 +126,7 @@ void gui_queue_show(struct gui_queue *queue)
|
|||
has_random = queue_has_flag(queue->gq_queue, Q_RANDOM);
|
||||
has_repeat = queue_has_flag(queue->gq_queue, Q_REPEAT);
|
||||
is_enabled = queue_has_flag(queue->gq_queue, Q_ENABLED);
|
||||
gtk_tree_view_set_model(view, queue->gq_filter);
|
||||
gui_view_set_model(GTK_TREE_MODEL_FILTER(queue->gq_filter));
|
||||
}
|
||||
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(random), has_random);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <gui/model.h>
|
||||
#include <gui/queue.h>
|
||||
#include <gui/settings.h>
|
||||
#include <gui/view.h>
|
||||
|
||||
static const gchar *QUEUE_SETTINGS[Q_MODEL_N_COLUMNS] = {
|
||||
[Q_MODEL_TRACK_NR] = "gui.queue.track",
|
||||
|
@ -49,3 +50,8 @@ void gui_view_init()
|
|||
gtk_tree_view_column_set_fixed_width(col, pos);
|
||||
}
|
||||
}
|
||||
|
||||
void gui_view_set_model(GtkTreeModelFilter *filter)
|
||||
{
|
||||
gtk_tree_view_set_model(view_treeview, GTK_TREE_MODEL(filter));
|
||||
}
|
||||
|
|
|
@ -7,4 +7,7 @@
|
|||
/* Called to initialize structures needed by the treeview. */
|
||||
void gui_view_init();
|
||||
|
||||
/* Called to set the currently displayed model. */
|
||||
void gui_view_set_model(GtkTreeModelFilter *);
|
||||
|
||||
#endif /* OCARINA_GUI_VIEW_H */
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <core/core.h>
|
||||
#include <gui/builder.h>
|
||||
#include <gui/collection.h>
|
||||
#include <gui/view.h>
|
||||
#include <tests/gui.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
|
@ -36,6 +37,7 @@ static void test_collection_sidebar()
|
|||
gtk_init(&argc, NULL);
|
||||
gui_builder_init("share/ocarina/ocarina6.glade");
|
||||
core_init(&argc, NULL, &init_data);
|
||||
gui_view_init();
|
||||
gui_collection_init();
|
||||
|
||||
main_loop = g_main_loop_new(NULL, FALSE);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <core/idle.h>
|
||||
#include <gui/builder.h>
|
||||
#include <gui/queue.h>
|
||||
#include <gui/view.h>
|
||||
#include <tests/gui.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
|
@ -49,6 +50,7 @@ static void test_queue()
|
|||
|
||||
gtk_init(&argc, NULL);
|
||||
gui_builder_init("share/ocarina/ocarina6.glade");
|
||||
gui_view_init();
|
||||
search = GTK_ENTRY(gui_builder_widget("o_search"));
|
||||
enable = GTK_SWITCH(gui_builder_widget("o_enable"));
|
||||
random = GTK_TOGGLE_BUTTON(gui_builder_widget("o_random"));
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
#define TEST_NEED_QUEUE
|
||||
#define TEST_NEED_SIDEBAR
|
||||
#define TEST_NEED_WINDOW
|
||||
#include <core/collection.h>
|
||||
#include <core/core.h>
|
||||
#include <core/idle.h>
|
||||
#include <gui/builder.h>
|
||||
#include <gui/model.h>
|
||||
#include <gui/settings.h>
|
||||
|
@ -28,6 +31,7 @@ const gchar *QUEUE_SETTINGS[Q_MODEL_N_COLUMNS] = {
|
|||
};
|
||||
|
||||
GMainLoop *main_loop;
|
||||
struct core_init_data init_data;
|
||||
|
||||
static int test_on_idle(gpointer data)
|
||||
{
|
||||
|
@ -37,16 +41,23 @@ static int test_on_idle(gpointer data)
|
|||
|
||||
static void test_treeview()
|
||||
{
|
||||
GtkTreeModel *model, *filter;
|
||||
GtkTreeViewColumn *col;
|
||||
GtkTreeView *treeview;
|
||||
unsigned int i;
|
||||
int argc = 0;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
core_init(&argc, NULL, &init_data);
|
||||
gui_builder_init("share/ocarina/ocarina6.glade");
|
||||
gui_settings_init();
|
||||
gui_view_init();
|
||||
|
||||
collection_add("tests/Music/Hyrule Symphony");
|
||||
while (idle_run_task() == true) {}
|
||||
model = GTK_TREE_MODEL(gui_queue_model_new(collection_get_queue()));
|
||||
filter = gtk_tree_model_filter_new(model, NULL);
|
||||
|
||||
treeview = GTK_TREE_VIEW(gui_builder_widget("o_treeview"));
|
||||
main_loop = g_main_loop_new(NULL, FALSE);
|
||||
g_idle_add(test_on_idle, NULL);
|
||||
|
@ -81,6 +92,12 @@ static void test_treeview()
|
|||
col = gtk_tree_view_get_column(treeview, i);
|
||||
test_loop_equal(gtk_tree_view_column_get_fixed_width(col), 42, i);
|
||||
} test_loop_passed();
|
||||
|
||||
gui_view_set_model(GTK_TREE_MODEL_FILTER(filter));
|
||||
test_equal((void *)gtk_tree_view_get_model(treeview), (void *)filter);
|
||||
|
||||
gui_view_set_model(NULL);
|
||||
test_equal((void *)gtk_tree_view_get_model(treeview), NULL);
|
||||
}
|
||||
|
||||
DECLARE_UNIT_TESTS(
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#define TEST_NEED_PLAYLIST
|
||||
#include <gui/builder.h>
|
||||
#include <gui/settings.h>
|
||||
#include <gui/view.h>
|
||||
#include <gui/window.h>
|
||||
#include <tests/gui.h>
|
||||
#include <tests/test.h>
|
||||
|
@ -27,6 +28,7 @@ static void test_window()
|
|||
gtk_init(&argc, NULL);
|
||||
gui_builder_init("share/ocarina/ocarina6.glade");
|
||||
gui_settings_init();
|
||||
gui_view_init();
|
||||
gui_window_init("share/ocarina/ocarina.png");
|
||||
|
||||
main_loop = g_main_loop_new(NULL, FALSE);
|
||||
|
|
Loading…
Reference in New Issue