diff --git a/CHANGELOG b/CHANGELOG index bd322488..8187e0c5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ 6.4.13: +- Enable bolding the current track in the GtkTreeView - Enable GtkTreeView fixed-height mode - Fix bug where temporary queues don't save - Fix bug where a queue is not selected on startup diff --git a/gui/model.c b/gui/model.c index fde3fd23..243aeb56 100644 --- a/gui/model.c +++ b/gui/model.c @@ -1,6 +1,7 @@ /* * Copyright 2016 (c) Anna Schumaker. */ +#include #include #include #include @@ -8,6 +9,8 @@ static const GTypeInfo queue_type_info; static const GInterfaceInfo queue_tree_model; static GObjectClass *parent_class = NULL; +static gchar *font_current = "bold"; +static gchar *font_regular = ""; static GType queue_columns[Q_MODEL_N_COLUMNS] = { [Q_MODEL_TRACK_NR] = G_TYPE_UINT, @@ -20,6 +23,7 @@ static GType queue_columns[Q_MODEL_N_COLUMNS] = { [Q_MODEL_COUNT] = G_TYPE_UINT, [Q_MODEL_LAST_PLAY] = G_TYPE_STRING, [Q_MODEL_FILE_PATH] = G_TYPE_STRING, + [Q_MODEL_FONT] = G_TYPE_STRING, }; static gboolean __queue_model_iter_nth(GuiQueueModel *model, @@ -126,6 +130,10 @@ static void _queue_model_get_value(GtkTreeModel *model, GtkTreeIter *iter, g_value_take_string(value, g_markup_escape_text(str, -1)); g_free(str); break; + case Q_MODEL_FONT: + str = (track == audio_cur_track()) ? font_current : font_regular; + g_value_set_static_string(value, str); + break; } } diff --git a/gui/view.c b/gui/view.c index 7b0d33b7..947465e5 100644 --- a/gui/view.c +++ b/gui/view.c @@ -23,6 +23,7 @@ static const gchar *QUEUE_SETTINGS[Q_MODEL_N_COLUMNS] = { [Q_MODEL_COUNT] = "gui.queue.count", [Q_MODEL_LAST_PLAY] = "gui.queue.played", [Q_MODEL_FILE_PATH] = "gui.queue.filepath", + [Q_MODEL_FONT] = "gui.queue.font", }; static const enum compare_t QUEUE_SORT[Q_MODEL_N_COLUMNS] = { diff --git a/include/gui/model.h b/include/gui/model.h index b5343294..2051740a 100644 --- a/include/gui/model.h +++ b/include/gui/model.h @@ -21,6 +21,7 @@ enum queue_model_columns { Q_MODEL_COUNT, Q_MODEL_LAST_PLAY, Q_MODEL_FILE_PATH, + Q_MODEL_FONT, Q_MODEL_N_COLUMNS, }; diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index ec312b3e..760cdd7d 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -1146,6 +1146,7 @@ + 10 0 @@ -1163,6 +1164,7 @@ + 10 1 @@ -1180,6 +1182,7 @@ + 10 2 @@ -1197,6 +1200,7 @@ + 10 3 @@ -1214,6 +1218,7 @@ + 10 4 @@ -1231,6 +1236,7 @@ + 10 5 @@ -1248,6 +1254,7 @@ + 10 6 @@ -1265,6 +1272,7 @@ + 10 7 @@ -1282,6 +1290,7 @@ + 10 8 diff --git a/tests/gui/model.c b/tests/gui/model.c index 2b879119..82a3ade8 100644 --- a/tests/gui/model.c +++ b/tests/gui/model.c @@ -1,6 +1,7 @@ /* * Copyright 2016 (c) Anna Schumaker. */ +#include #include #include #include @@ -31,6 +32,9 @@ void test_queue_cleared(struct queue *queue, unsigned int n) void test_queue_save(struct queue *queue, enum queue_flags flag) {} void test_queue_updated(struct queue *queue, unsigned int row) { gui_queue_model_update(queue->q_private, row); } +void test_on_load(struct track *track) {} +void test_on_state_change(GstState state) {} +void test_on_config_pause(int count) {} struct queue_ops test_ops = { .qop_init = test_queue_init, @@ -42,8 +46,15 @@ struct queue_ops test_ops = { .qop_updated = test_queue_updated, }; +struct audio_ops test_audio_ops = { + .on_load = test_on_load, + .on_state_change = test_on_state_change, + .on_config_pause = test_on_config_pause, +}; + struct core_init_data init_data = { .collection_ops = &test_ops, + .audio_ops = &test_audio_ops, }; static void test_init() @@ -59,7 +70,7 @@ static void test_init() treemodel = GTK_TREE_MODEL(model); test_equal(gtk_tree_model_get_flags(treemodel), GTK_TREE_MODEL_LIST_ONLY); - test_equal(gtk_tree_model_get_n_columns(treemodel), 10); + test_equal(gtk_tree_model_get_n_columns(treemodel), 11); type = gtk_tree_model_get_column_type(treemodel, Q_MODEL_TRACK_NR); test_equal(type, G_TYPE_UINT); @@ -81,6 +92,8 @@ static void test_init() test_equal(type, G_TYPE_STRING); type = gtk_tree_model_get_column_type(treemodel, Q_MODEL_FILE_PATH); test_equal(type, G_TYPE_STRING); + type = gtk_tree_model_get_column_type(treemodel, Q_MODEL_FONT); + test_equal(type, G_TYPE_STRING); /* This should trigger an assertion failure */ type = gtk_tree_model_get_column_type(treemodel, Q_MODEL_N_COLUMNS); @@ -125,6 +138,8 @@ static void test_empty() test_equal(G_IS_VALUE(&value), false); gtk_tree_model_get_value(model, &iter, Q_MODEL_FILE_PATH, &value); test_equal(G_IS_VALUE(&value), false); + gtk_tree_model_get_value(model, &iter, Q_MODEL_FONT, &value); + test_equal(G_IS_VALUE(&value), false); test_equal(gtk_tree_model_iter_next(model, &iter), false); test_equal(gtk_tree_model_iter_children(model, &iter, NULL), false); @@ -167,6 +182,7 @@ static void test_model() test_equal(gtk_tree_model_get_iter_first(model, &iter), true); track = gui_queue_model_iter_get_track(GUI_QUEUE_MODEL(model), &iter); test_equal(track->tr_track, 1); + audio_load(track); path = gtk_tree_model_get_path(model, &iter); test_not_equal((void *)path, NULL); @@ -206,10 +222,16 @@ static void test_model() test_equal(g_value_get_string(&value), "tests/Music/Hyrule Symphony/01 - Title Theme.ogg"); g_value_unset(&value); + gtk_tree_model_get_value(model, &iter, Q_MODEL_FONT, &value); + test_equal(g_value_get_string(&value), "bold"); + g_value_unset(&value); test_equal(gtk_tree_model_iter_next(model, &iter), true); track = gui_queue_model_iter_get_track(GUI_QUEUE_MODEL(model), &iter); test_equal(track->tr_track, 2); + gtk_tree_model_get_value(model, &iter, Q_MODEL_FONT, &value); + test_equal(g_value_get_string(&value), ""); + g_value_unset(&value); test_equal(gtk_tree_model_iter_children(model, &iter, NULL), true); track = gui_queue_model_iter_get_track(GUI_QUEUE_MODEL(model), &iter); diff --git a/tests/gui/view.c b/tests/gui/view.c index 159c0d7d..4729de7a 100644 --- a/tests/gui/view.c +++ b/tests/gui/view.c @@ -29,6 +29,7 @@ const gchar *QUEUE_SETTINGS[Q_MODEL_N_COLUMNS] = { [Q_MODEL_COUNT] = "gui.queue.count", [Q_MODEL_LAST_PLAY] = "gui.queue.played", [Q_MODEL_FILE_PATH] = "gui.queue.filepath", + [Q_MODEL_FONT] = "gui.queue.font", }; GMainLoop *main_loop; @@ -84,17 +85,19 @@ static void test_treeview() (bool)false, i); } test_loop_passed(); - for (i = 0; i < (Q_MODEL_N_COLUMNS - 1); i++) { + for (i = 0; i < Q_MODEL_N_COLUMNS; i++) { + if (i == Q_MODEL_FILE_PATH || i == Q_MODEL_FONT) + continue; col = gtk_tree_view_get_column(treeview, i); gtk_tree_view_column_set_fixed_width(col, (i + 1) * 10); } g_main_loop_run(main_loop); - for (i = 0; i < (Q_MODEL_N_COLUMNS - 1); i++) { - test_loop_equal(gui_settings_has(QUEUE_SETTINGS[i]), - (bool)true, i); + for (i = 0; i < Q_MODEL_N_COLUMNS; i++) { + bool has = (i != Q_MODEL_FILE_PATH) && (i != Q_MODEL_FONT); + test_loop_equal(gui_settings_has(QUEUE_SETTINGS[i]), has, i); /* The "Played" column gets any remaining space. */ - if (i != Q_MODEL_LAST_PLAY) + if (has && i != Q_MODEL_LAST_PLAY) test_loop_equal(gui_settings_get(QUEUE_SETTINGS[i]), (i + 1) * 10, i); } test_loop_passed();