gui/treeview: Respond to the notify::width signal
I connect this in code so I can pass the column index as data to the function, avoding the need for a "column index" lookup function. I restore saved column widths during startup. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
dbc1df154a
commit
1c386809d0
|
@ -1,21 +1,27 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2016 (c) Anna Schumaker.
|
* Copyright 2016 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
|
#include <core/settings.h>
|
||||||
#include <gui/filter.h>
|
#include <gui/filter.h>
|
||||||
#include <gui/model.h>
|
#include <gui/model.h>
|
||||||
#include <gui/treeview.h>
|
#include <gui/treeview.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static const enum compare_t GUI_COL_MAP[GUI_MODEL_N_COLUMNS] = {
|
struct col_map_entry {
|
||||||
[GUI_MODEL_TRACK_NR] = COMPARE_TRACK,
|
enum compare_t compare;
|
||||||
[GUI_MODEL_TITLE] = COMPARE_TITLE,
|
const gchar *setting;
|
||||||
[GUI_MODEL_LENGTH] = COMPARE_LENGTH,
|
};
|
||||||
[GUI_MODEL_ARTIST] = COMPARE_ARTIST,
|
|
||||||
[GUI_MODEL_ALBUM] = COMPARE_ALBUM,
|
static const struct col_map_entry GUI_COL_MAP[GUI_MODEL_N_COLUMNS] = {
|
||||||
[GUI_MODEL_YEAR] = COMPARE_YEAR,
|
[GUI_MODEL_TRACK_NR] = { COMPARE_TRACK, "gui.queue.track" },
|
||||||
[GUI_MODEL_GENRE] = COMPARE_GENRE,
|
[GUI_MODEL_TITLE] = { COMPARE_TITLE, "gui.queue.title" },
|
||||||
[GUI_MODEL_COUNT] = COMPARE_COUNT,
|
[GUI_MODEL_LENGTH] = { COMPARE_LENGTH, "gui.queue.length" },
|
||||||
[GUI_MODEL_LAST_PLAY] = COMPARE_PLAYED,
|
[GUI_MODEL_ARTIST] = { COMPARE_ARTIST, "gui.queue.artist" },
|
||||||
|
[GUI_MODEL_ALBUM] = { COMPARE_ALBUM, "gui.queue.album" },
|
||||||
|
[GUI_MODEL_YEAR] = { COMPARE_YEAR, "gui.queue.year" },
|
||||||
|
[GUI_MODEL_GENRE] = { COMPARE_GENRE, "gui.queue.genre" },
|
||||||
|
[GUI_MODEL_COUNT] = { COMPARE_COUNT, "gui.queue.count" },
|
||||||
|
[GUI_MODEL_LAST_PLAY] = { COMPARE_PLAYED, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int sort_count = 0;
|
static unsigned int sort_count = 0;
|
||||||
|
@ -48,7 +54,7 @@ static void __gui_treeview_set_sort_indicators()
|
||||||
if (!col)
|
if (!col)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
field = __gui_treeview_colum_match_sort(GUI_COL_MAP[i]);
|
field = __gui_treeview_colum_match_sort(GUI_COL_MAP[i].compare);
|
||||||
order = (field > 0) ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING;
|
order = (field > 0) ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING;
|
||||||
|
|
||||||
gtk_tree_view_column_set_sort_indicator(col, field != 0);
|
gtk_tree_view_column_set_sort_indicator(col, field != 0);
|
||||||
|
@ -139,6 +145,13 @@ static void __gui_treeview_column_clicked(GtkTreeViewColumn *col,
|
||||||
g_timeout_add_seconds(3, __gui_treeview_dec_sort, NULL);
|
g_timeout_add_seconds(3, __gui_treeview_dec_sort, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __gui_treeview_column_resized(GtkTreeViewColumn *col, GParamSpec *pspec,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
settings_set(GUI_COL_MAP[GPOINTER_TO_UINT(data)].setting,
|
||||||
|
gtk_tree_view_column_get_width(col));
|
||||||
|
}
|
||||||
|
|
||||||
void __gui_treeview_row_activated(GtkTreeView *treeview, GtkTreePath *path,
|
void __gui_treeview_row_activated(GtkTreeView *treeview, GtkTreePath *path,
|
||||||
GtkTreeViewColumn *col, gpointer data)
|
GtkTreeViewColumn *col, gpointer data)
|
||||||
{
|
{
|
||||||
|
@ -150,7 +163,7 @@ void __gui_treeview_row_activated(GtkTreeView *treeview, GtkTreePath *path,
|
||||||
void gui_treeview_init()
|
void gui_treeview_init()
|
||||||
{
|
{
|
||||||
GtkTreeViewColumn *col;
|
GtkTreeViewColumn *col;
|
||||||
unsigned int i;
|
int i, pos;
|
||||||
|
|
||||||
gtk_tree_view_set_model(gui_treeview(),
|
gtk_tree_view_set_model(gui_treeview(),
|
||||||
GTK_TREE_MODEL(gui_filter_get()));
|
GTK_TREE_MODEL(gui_filter_get()));
|
||||||
|
@ -160,7 +173,13 @@ void gui_treeview_init()
|
||||||
if (col) {
|
if (col) {
|
||||||
g_signal_connect(col, "clicked",
|
g_signal_connect(col, "clicked",
|
||||||
G_CALLBACK(__gui_treeview_column_clicked),
|
G_CALLBACK(__gui_treeview_column_clicked),
|
||||||
GUINT_TO_POINTER(GUI_COL_MAP[i]));
|
GUINT_TO_POINTER(GUI_COL_MAP[i].compare));
|
||||||
|
g_signal_connect(col, "notify::width",
|
||||||
|
G_CALLBACK(__gui_treeview_column_resized),
|
||||||
|
GUINT_TO_POINTER(i));
|
||||||
|
pos = settings_get(GUI_COL_MAP[i].setting);
|
||||||
|
if (pos > 0)
|
||||||
|
gtk_tree_view_column_set_fixed_width(col, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
44
gui/view.c
44
gui/view.c
|
@ -13,42 +13,8 @@
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static const gchar *QUEUE_SETTINGS[GUI_MODEL_N_COLUMNS] = {
|
|
||||||
[GUI_MODEL_TRACK_NR] = "gui.queue.track",
|
|
||||||
[GUI_MODEL_TITLE] = "gui.queue.title",
|
|
||||||
[GUI_MODEL_LENGTH] = "gui.queue.length",
|
|
||||||
[GUI_MODEL_ARTIST] = "gui.queue.artist",
|
|
||||||
[GUI_MODEL_ALBUM] = "gui.queue.album",
|
|
||||||
[GUI_MODEL_YEAR] = "gui.queue.year",
|
|
||||||
[GUI_MODEL_GENRE] = "gui.queue.genre",
|
|
||||||
[GUI_MODEL_COUNT] = "gui.queue.count",
|
|
||||||
};
|
|
||||||
|
|
||||||
static GtkTreeView *view_treeview = NULL;
|
static GtkTreeView *view_treeview = NULL;
|
||||||
|
|
||||||
static unsigned int __view_get_column_index(GtkTreeViewColumn *col)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
if (!view_treeview)
|
|
||||||
return GUI_MODEL_N_COLUMNS;
|
|
||||||
|
|
||||||
for (i = 0; i < GUI_MODEL_N_COLUMNS; i++) {
|
|
||||||
if (col == gtk_tree_view_get_column(view_treeview, i))
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GUI_MODEL_N_COLUMNS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void __view_column_resized(GtkTreeViewColumn *col, GParamSpec *pspec,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
unsigned int index = __view_get_column_index(col);
|
|
||||||
|
|
||||||
settings_set(QUEUE_SETTINGS[index], gtk_tree_view_column_get_width(col));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct view_add_data {
|
struct view_add_data {
|
||||||
enum playlist_type_t vad_type;
|
enum playlist_type_t vad_type;
|
||||||
const gchar *vad_name;
|
const gchar *vad_name;
|
||||||
|
@ -274,17 +240,7 @@ bool __view_button_press(GtkTreeView *treeview, GdkEventButton *event,
|
||||||
|
|
||||||
void gui_view_init()
|
void gui_view_init()
|
||||||
{
|
{
|
||||||
GtkTreeViewColumn *col;
|
|
||||||
int i, pos;
|
|
||||||
|
|
||||||
view_treeview = gui_treeview();
|
view_treeview = gui_treeview();
|
||||||
|
|
||||||
for (i = 0; i < GUI_MODEL_N_COLUMNS; i++) {
|
|
||||||
col = gtk_tree_view_get_column(view_treeview, i);
|
|
||||||
pos = settings_get(QUEUE_SETTINGS[i]);
|
|
||||||
if (col && pos > 0)
|
|
||||||
gtk_tree_view_column_set_fixed_width(col, pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_view_set_playlist(struct playlist *playlist)
|
void gui_view_set_playlist(struct playlist *playlist)
|
||||||
|
|
|
@ -898,7 +898,6 @@ audio-volume-medium</property>
|
||||||
<property name="fixed_width">20</property>
|
<property name="fixed_width">20</property>
|
||||||
<property name="title" translatable="yes">#</property>
|
<property name="title" translatable="yes">#</property>
|
||||||
<property name="clickable">True</property>
|
<property name="clickable">True</property>
|
||||||
<signal name="notify::width" handler="__view_column_resized" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext4"/>
|
<object class="GtkCellRendererText" id="cellrenderertext4"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
@ -915,7 +914,6 @@ audio-volume-medium</property>
|
||||||
<property name="fixed_width">300</property>
|
<property name="fixed_width">300</property>
|
||||||
<property name="title" translatable="yes">Title</property>
|
<property name="title" translatable="yes">Title</property>
|
||||||
<property name="clickable">True</property>
|
<property name="clickable">True</property>
|
||||||
<signal name="notify::width" handler="__view_column_resized" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext5"/>
|
<object class="GtkCellRendererText" id="cellrenderertext5"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
@ -932,7 +930,6 @@ audio-volume-medium</property>
|
||||||
<property name="fixed_width">60</property>
|
<property name="fixed_width">60</property>
|
||||||
<property name="title" translatable="yes">Length</property>
|
<property name="title" translatable="yes">Length</property>
|
||||||
<property name="clickable">True</property>
|
<property name="clickable">True</property>
|
||||||
<signal name="notify::width" handler="__view_column_resized" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext6"/>
|
<object class="GtkCellRendererText" id="cellrenderertext6"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
@ -949,7 +946,6 @@ audio-volume-medium</property>
|
||||||
<property name="fixed_width">100</property>
|
<property name="fixed_width">100</property>
|
||||||
<property name="title" translatable="yes">Artist</property>
|
<property name="title" translatable="yes">Artist</property>
|
||||||
<property name="clickable">True</property>
|
<property name="clickable">True</property>
|
||||||
<signal name="notify::width" handler="__view_column_resized" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext7"/>
|
<object class="GtkCellRendererText" id="cellrenderertext7"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
@ -966,7 +962,6 @@ audio-volume-medium</property>
|
||||||
<property name="fixed_width">100</property>
|
<property name="fixed_width">100</property>
|
||||||
<property name="title" translatable="yes">Album</property>
|
<property name="title" translatable="yes">Album</property>
|
||||||
<property name="clickable">True</property>
|
<property name="clickable">True</property>
|
||||||
<signal name="notify::width" handler="__view_column_resized" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext8"/>
|
<object class="GtkCellRendererText" id="cellrenderertext8"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
@ -983,7 +978,6 @@ audio-volume-medium</property>
|
||||||
<property name="fixed_width">45</property>
|
<property name="fixed_width">45</property>
|
||||||
<property name="title" translatable="yes">Year</property>
|
<property name="title" translatable="yes">Year</property>
|
||||||
<property name="clickable">True</property>
|
<property name="clickable">True</property>
|
||||||
<signal name="notify::width" handler="__view_column_resized" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext9"/>
|
<object class="GtkCellRendererText" id="cellrenderertext9"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
@ -1000,7 +994,6 @@ audio-volume-medium</property>
|
||||||
<property name="fixed_width">100</property>
|
<property name="fixed_width">100</property>
|
||||||
<property name="title" translatable="yes">Genre</property>
|
<property name="title" translatable="yes">Genre</property>
|
||||||
<property name="clickable">True</property>
|
<property name="clickable">True</property>
|
||||||
<signal name="notify::width" handler="__view_column_resized" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext10"/>
|
<object class="GtkCellRendererText" id="cellrenderertext10"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
@ -1017,7 +1010,6 @@ audio-volume-medium</property>
|
||||||
<property name="fixed_width">60</property>
|
<property name="fixed_width">60</property>
|
||||||
<property name="title" translatable="yes">Count</property>
|
<property name="title" translatable="yes">Count</property>
|
||||||
<property name="clickable">True</property>
|
<property name="clickable">True</property>
|
||||||
<signal name="notify::width" handler="__view_column_resized" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext11"/>
|
<object class="GtkCellRendererText" id="cellrenderertext11"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
@ -1034,7 +1026,6 @@ audio-volume-medium</property>
|
||||||
<property name="fixed_width">1</property>
|
<property name="fixed_width">1</property>
|
||||||
<property name="title" translatable="yes">Played</property>
|
<property name="title" translatable="yes">Played</property>
|
||||||
<property name="clickable">True</property>
|
<property name="clickable">True</property>
|
||||||
<signal name="notify::width" handler="__view_column_resized" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext12"/>
|
<object class="GtkCellRendererText" id="cellrenderertext12"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
|
|
@ -4,10 +4,26 @@
|
||||||
#include <core/audio.h>
|
#include <core/audio.h>
|
||||||
#include <core/core.h>
|
#include <core/core.h>
|
||||||
#include <core/idle.h>
|
#include <core/idle.h>
|
||||||
|
#include <core/settings.h>
|
||||||
#include <gui/filter.h>
|
#include <gui/filter.h>
|
||||||
#include <gui/model.h>
|
#include <gui/model.h>
|
||||||
#include <gui/treeview.h>
|
#include <gui/treeview.h>
|
||||||
#include <tests/test.h>
|
#include <tests/test.h>
|
||||||
|
#include <tests/gui.h>
|
||||||
|
|
||||||
|
const gchar *GUI_COL_SETTINGS[GUI_MODEL_N_COLUMNS] = {
|
||||||
|
[GUI_MODEL_TRACK_NR] = "gui.queue.track",
|
||||||
|
[GUI_MODEL_TITLE] = "gui.queue.title",
|
||||||
|
[GUI_MODEL_LENGTH] = "gui.queue.length",
|
||||||
|
[GUI_MODEL_ARTIST] = "gui.queue.artist",
|
||||||
|
[GUI_MODEL_ALBUM] = "gui.queue.album",
|
||||||
|
[GUI_MODEL_YEAR] = "gui.queue.year",
|
||||||
|
[GUI_MODEL_GENRE] = "gui.queue.genre",
|
||||||
|
[GUI_MODEL_COUNT] = "gui.queue.count",
|
||||||
|
[GUI_MODEL_LAST_PLAY] = "gui.queue.played",
|
||||||
|
[GUI_MODEL_FILE_PATH] = "gui.queue.filepath",
|
||||||
|
[GUI_MODEL_FONT] = "gui.queue.font",
|
||||||
|
};
|
||||||
|
|
||||||
static void test_load(struct track *track) { }
|
static void test_load(struct track *track) { }
|
||||||
static void test_state_change(GstState state) {}
|
static void test_state_change(GstState state) {}
|
||||||
|
@ -149,6 +165,33 @@ void test_treeview_sort()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_treeview_columns()
|
||||||
|
{
|
||||||
|
GtkTreeViewColumn *col;
|
||||||
|
unsigned int i;
|
||||||
|
const gchar *setting;
|
||||||
|
|
||||||
|
for (i = 0; i < GUI_MODEL_N_COLUMNS; i++) {
|
||||||
|
col = gtk_tree_view_get_column(gui_treeview(), i);
|
||||||
|
if (!col)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
g_assert_false(settings_has(GUI_COL_SETTINGS[i]));
|
||||||
|
gtk_tree_view_column_set_fixed_width(col, (i + 2) * 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
gui_test_main_loop();
|
||||||
|
for (i = 0; i < GUI_MODEL_N_COLUMNS; i++) {
|
||||||
|
col = gtk_tree_view_get_column(gui_treeview(), i);
|
||||||
|
if (!col || (i == GUI_MODEL_LAST_PLAY))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
setting = GUI_COL_SETTINGS[i];
|
||||||
|
g_assert_true(setting);
|
||||||
|
g_assert_cmpuint(settings_get(setting), ==, (i + 2) * 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -159,15 +202,19 @@ int main(int argc, char **argv)
|
||||||
gui_model_init();
|
gui_model_init();
|
||||||
gui_filter_init();
|
gui_filter_init();
|
||||||
gui_treeview_init();
|
gui_treeview_init();
|
||||||
|
gui_test_init();
|
||||||
|
|
||||||
playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony");
|
playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony");
|
||||||
while (idle_run_task()) {}
|
while (idle_run_task()) {}
|
||||||
|
|
||||||
g_test_init(&argc, &argv, NULL);
|
g_test_init(&argc, &argv, NULL);
|
||||||
g_test_add_func("/Gui/Treeview/Init", test_treeview_init);
|
g_test_add_func("/Gui/Treeview/Init", test_treeview_init);
|
||||||
g_test_add_func("/Gui/Treeview/Sort", test_treeview_sort);
|
g_test_add_func("/Gui/Treeview/Sort", test_treeview_sort);
|
||||||
|
g_test_add_func("/Gui/Treeview/Columns", test_treeview_columns);
|
||||||
ret = g_test_run();
|
ret = g_test_run();
|
||||||
|
|
||||||
core_deinit();
|
core_deinit();
|
||||||
|
gui_test_deinit();
|
||||||
gui_treeview_deinit();
|
gui_treeview_deinit();
|
||||||
gui_filter_deinit();
|
gui_filter_deinit();
|
||||||
gui_model_deinit();
|
gui_model_deinit();
|
||||||
|
|
|
@ -12,21 +12,6 @@
|
||||||
#include <gui/treeview.h>
|
#include <gui/treeview.h>
|
||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
#include <tests/test.h>
|
#include <tests/test.h>
|
||||||
#include <tests/gui.h>
|
|
||||||
|
|
||||||
const gchar *QUEUE_SETTINGS[GUI_MODEL_N_COLUMNS] = {
|
|
||||||
[GUI_MODEL_TRACK_NR] = "gui.queue.track",
|
|
||||||
[GUI_MODEL_TITLE] = "gui.queue.title",
|
|
||||||
[GUI_MODEL_LENGTH] = "gui.queue.length",
|
|
||||||
[GUI_MODEL_ARTIST] = "gui.queue.artist",
|
|
||||||
[GUI_MODEL_ALBUM] = "gui.queue.album",
|
|
||||||
[GUI_MODEL_YEAR] = "gui.queue.year",
|
|
||||||
[GUI_MODEL_GENRE] = "gui.queue.genre",
|
|
||||||
[GUI_MODEL_COUNT] = "gui.queue.count",
|
|
||||||
[GUI_MODEL_LAST_PLAY] = "gui.queue.played",
|
|
||||||
[GUI_MODEL_FILE_PATH] = "gui.queue.filepath",
|
|
||||||
[GUI_MODEL_FONT] = "gui.queue.font",
|
|
||||||
};
|
|
||||||
|
|
||||||
unsigned int load_count = 0;
|
unsigned int load_count = 0;
|
||||||
|
|
||||||
|
@ -46,12 +31,10 @@ struct core_init_data init_data = {
|
||||||
|
|
||||||
static void test_treeview()
|
static void test_treeview()
|
||||||
{
|
{
|
||||||
GtkTreeViewColumn *col;
|
|
||||||
GtkTreeView *treeview;
|
GtkTreeView *treeview;
|
||||||
GtkTreeModel *filter;
|
GtkTreeModel *filter;
|
||||||
GtkTreePath *path;
|
GtkTreePath *path;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony");
|
playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony");
|
||||||
while (idle_run_task() == true) {}
|
while (idle_run_task() == true) {}
|
||||||
|
@ -60,37 +43,6 @@ static void test_treeview()
|
||||||
|
|
||||||
treeview = gui_treeview();
|
treeview = gui_treeview();
|
||||||
|
|
||||||
for (i = 0; i < GUI_MODEL_N_COLUMNS; i++)
|
|
||||||
g_assert_false(settings_has(QUEUE_SETTINGS[i]));
|
|
||||||
|
|
||||||
for (i = 0; i < GUI_MODEL_N_COLUMNS; i++) {
|
|
||||||
if (i == GUI_MODEL_FILE_PATH || i == GUI_MODEL_FONT)
|
|
||||||
continue;
|
|
||||||
col = gtk_tree_view_get_column(treeview, i);
|
|
||||||
gtk_tree_view_column_set_fixed_width(col, (i + 2) * 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
gui_test_main_loop();
|
|
||||||
for (i = 0; i < GUI_MODEL_N_COLUMNS; i++) {
|
|
||||||
bool has = (i < GUI_MODEL_LAST_PLAY);
|
|
||||||
g_assert(settings_has(QUEUE_SETTINGS[i]) == has);
|
|
||||||
/* The "Played" column gets any remaining space. */
|
|
||||||
if (has)
|
|
||||||
g_assert_cmpuint(settings_get(QUEUE_SETTINGS[i]),
|
|
||||||
==, (i + 2) * 10);
|
|
||||||
}
|
|
||||||
g_assert_false(settings_has("gui.queue.filepath"));
|
|
||||||
g_assert_cmpuint(settings_get("gui.queue.filepath"), ==, 0);
|
|
||||||
|
|
||||||
for (i = 0; i < GUI_MODEL_LAST_PLAY; i++)
|
|
||||||
settings_set(QUEUE_SETTINGS[i], 42);
|
|
||||||
|
|
||||||
gui_view_init();
|
|
||||||
for (i = 0; i < GUI_MODEL_LAST_PLAY; i++) {
|
|
||||||
col = gtk_tree_view_get_column(treeview, i);
|
|
||||||
g_assert_cmpuint(gtk_tree_view_column_get_fixed_width(col), ==, 42);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_assert((void *)gtk_tree_view_get_model(treeview) ==
|
g_assert((void *)gtk_tree_view_get_model(treeview) ==
|
||||||
(void *)gui_filter_get());
|
(void *)gui_filter_get());
|
||||||
|
|
||||||
|
@ -101,7 +53,6 @@ static void test_treeview()
|
||||||
gtk_tree_path_free(path);
|
gtk_tree_path_free(path);
|
||||||
|
|
||||||
gui_view_set_playlist(NULL);
|
gui_view_set_playlist(NULL);
|
||||||
gui_test_deinit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
@ -111,7 +62,6 @@ int main(int argc, char **argv)
|
||||||
gui_builder_init("share/ocarina/ocarina.ui");
|
gui_builder_init("share/ocarina/ocarina.ui");
|
||||||
gui_model_init();
|
gui_model_init();
|
||||||
gui_view_init();
|
gui_view_init();
|
||||||
gui_test_init();
|
|
||||||
while (idle_run_task()) {};
|
while (idle_run_task()) {};
|
||||||
|
|
||||||
g_test_init(&argc, &argv, NULL);
|
g_test_init(&argc, &argv, NULL);
|
||||||
|
|
Loading…
Reference in New Issue