gui/sidebar: Add functions for setting and getting editable state
I want to be able to change this when the user middle-clicks a row, so let's start by adding in some support functions. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
79accb5bb0
commit
7e303fa2b1
|
@ -236,6 +236,13 @@ enum playlist_type_t gui_sidebar_iter_type(GtkTreeIter *iter)
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool gui_sidebar_iter_editable(GtkTreeIter *iter)
|
||||||
|
{
|
||||||
|
gboolean editable;
|
||||||
|
gtk_tree_model_get(gui_sidebar_model(), iter, SB_EDITABLE, &editable, -1);
|
||||||
|
return editable == TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
struct playlist *gui_sidebar_iter_playlist(GtkTreeIter *iter)
|
struct playlist *gui_sidebar_iter_playlist(GtkTreeIter *iter)
|
||||||
{
|
{
|
||||||
enum playlist_type_t type = gui_sidebar_iter_type(iter);
|
enum playlist_type_t type = gui_sidebar_iter_type(iter);
|
||||||
|
@ -314,6 +321,15 @@ void gui_sidebar_iter_select(GtkTreeIter *iter)
|
||||||
gtk_tree_selection_select_iter(selection, &filter);
|
gtk_tree_selection_select_iter(selection, &filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool gui_sidebar_iter_set_editable(GtkTreeIter *iter, bool editable)
|
||||||
|
{
|
||||||
|
enum playlist_type_t type = gui_sidebar_iter_type(iter);
|
||||||
|
if (type != PL_USER)
|
||||||
|
return false;
|
||||||
|
gtk_tree_store_set(gui_sidebar_store(), iter, SB_EDITABLE, editable, -1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void gui_sidebar_filter_path_select(GtkTreePath *path)
|
void gui_sidebar_filter_path_select(GtkTreePath *path)
|
||||||
{
|
{
|
||||||
GtkTreeModel *model = GTK_TREE_MODEL(gui_sidebar_filter());
|
GtkTreeModel *model = GTK_TREE_MODEL(gui_sidebar_filter());
|
||||||
|
|
|
@ -27,6 +27,9 @@ gchar *gui_sidebar_iter_name(GtkTreeIter *);
|
||||||
/* Called to find the type of the playlist at the given iterator. */
|
/* Called to find the type of the playlist at the given iterator. */
|
||||||
enum playlist_type_t gui_sidebar_iter_type(GtkTreeIter *);
|
enum playlist_type_t gui_sidebar_iter_type(GtkTreeIter *);
|
||||||
|
|
||||||
|
/* Called to find the editable state of the playlist at the given iterator. */
|
||||||
|
bool gui_sidebar_iter_editable(GtkTreeIter *);
|
||||||
|
|
||||||
/* Called to find the playlist at the given iterator. */
|
/* Called to find the playlist at the given iterator. */
|
||||||
struct playlist *gui_sidebar_iter_playlist(GtkTreeIter *);
|
struct playlist *gui_sidebar_iter_playlist(GtkTreeIter *);
|
||||||
|
|
||||||
|
@ -48,6 +51,9 @@ void gui_sidebar_iter_update(GtkTreeIter *);
|
||||||
/* Called to select the row at the current iterator. */
|
/* Called to select the row at the current iterator. */
|
||||||
void gui_sidebar_iter_select(GtkTreeIter *);
|
void gui_sidebar_iter_select(GtkTreeIter *);
|
||||||
|
|
||||||
|
/* Called to set the current iterator as editable. */
|
||||||
|
bool gui_sidebar_iter_set_editable(GtkTreeIter *, bool);
|
||||||
|
|
||||||
/* Called to set the playlist at the given iterator as the default. */
|
/* Called to set the playlist at the given iterator as the default. */
|
||||||
void gui_sidebar_filter_path_select(GtkTreePath *);
|
void gui_sidebar_filter_path_select(GtkTreePath *);
|
||||||
|
|
||||||
|
|
|
@ -32,18 +32,30 @@ static void test_user()
|
||||||
g_assert_true(gui_sidebar_iter_down(&iter, &child));
|
g_assert_true(gui_sidebar_iter_down(&iter, &child));
|
||||||
g_assert_cmpstr_free(gui_sidebar_iter_name(&child), ==, "Favorites");
|
g_assert_cmpstr_free(gui_sidebar_iter_name(&child), ==, "Favorites");
|
||||||
g_assert_cmpuint(gui_sidebar_iter_type(&child), ==, PL_SYSTEM);
|
g_assert_cmpuint(gui_sidebar_iter_type(&child), ==, PL_SYSTEM);
|
||||||
|
g_assert_false(gui_sidebar_iter_editable(&child));
|
||||||
|
|
||||||
g_assert_true(gui_sidebar_iter_next(&child));
|
g_assert_true(gui_sidebar_iter_next(&child));
|
||||||
g_assert_cmpstr_free(gui_sidebar_iter_name(&child), ==, "Hidden");
|
g_assert_cmpstr_free(gui_sidebar_iter_name(&child), ==, "Hidden");
|
||||||
g_assert_cmpuint(gui_sidebar_iter_type(&child), ==, PL_SYSTEM);
|
g_assert_cmpuint(gui_sidebar_iter_type(&child), ==, PL_SYSTEM);
|
||||||
|
g_assert_false(gui_sidebar_iter_editable(&child));
|
||||||
|
|
||||||
g_assert_true(gui_sidebar_iter_next(&child));
|
g_assert_true(gui_sidebar_iter_next(&child));
|
||||||
g_assert_cmpstr_free(gui_sidebar_iter_name(&child), ==, "Test 1");
|
g_assert_cmpstr_free(gui_sidebar_iter_name(&child), ==, "Test 1");
|
||||||
g_assert_cmpuint(gui_sidebar_iter_type(&child), ==, PL_USER);
|
g_assert_cmpuint(gui_sidebar_iter_type(&child), ==, PL_USER);
|
||||||
|
g_assert_true(gui_sidebar_iter_editable(&child));
|
||||||
|
g_assert_true( gui_sidebar_iter_set_editable(&child, false));
|
||||||
|
g_assert_false(gui_sidebar_iter_editable(&child));
|
||||||
|
g_assert_true( gui_sidebar_iter_set_editable(&child, true));
|
||||||
|
g_assert_true( gui_sidebar_iter_editable(&child));
|
||||||
|
|
||||||
g_assert_true(gui_sidebar_iter_next(&child));
|
g_assert_true(gui_sidebar_iter_next(&child));
|
||||||
g_assert_cmpstr_free(gui_sidebar_iter_name(&child), ==, "Test 2");
|
g_assert_cmpstr_free(gui_sidebar_iter_name(&child), ==, "Test 2");
|
||||||
g_assert_cmpuint(gui_sidebar_iter_type(&child), ==, PL_USER);
|
g_assert_cmpuint(gui_sidebar_iter_type(&child), ==, PL_USER);
|
||||||
|
g_assert_true(gui_sidebar_iter_editable(&child));
|
||||||
|
g_assert_true( gui_sidebar_iter_set_editable(&child, false));
|
||||||
|
g_assert_false(gui_sidebar_iter_editable(&child));
|
||||||
|
g_assert_true( gui_sidebar_iter_set_editable(&child, true));
|
||||||
|
g_assert_true( gui_sidebar_iter_editable(&child));
|
||||||
|
|
||||||
list = gui_pl_user_list();
|
list = gui_pl_user_list();
|
||||||
g_assert_nonnull(list);
|
g_assert_nonnull(list);
|
||||||
|
|
|
@ -156,6 +156,12 @@ static void test_sidebar_selection()
|
||||||
gui_sidebar_filter_path_select(path);
|
gui_sidebar_filter_path_select(path);
|
||||||
g_assert(playlist_current() == playlist_lookup(PL_SYSTEM, "Collection"));
|
g_assert(playlist_current() == playlist_lookup(PL_SYSTEM, "Collection"));
|
||||||
|
|
||||||
|
g_assert_false(gui_sidebar_iter_editable(&iter));
|
||||||
|
g_assert_false(gui_sidebar_iter_set_editable(&iter, true));
|
||||||
|
g_assert_false(gui_sidebar_iter_editable(&iter));
|
||||||
|
g_assert_false(gui_sidebar_iter_set_editable(&iter, false));
|
||||||
|
g_assert_false(gui_sidebar_iter_editable(&iter));
|
||||||
|
|
||||||
gtk_tree_selection_unselect_all(selection);
|
gtk_tree_selection_unselect_all(selection);
|
||||||
gui_sidebar_iter_next(&iter);
|
gui_sidebar_iter_next(&iter);
|
||||||
gtk_tree_path_next(path);
|
gtk_tree_path_next(path);
|
||||||
|
|
Loading…
Reference in New Issue