gui/playlist: Begin new playlist sidebar widget
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
ca88bca999
commit
be6895630d
|
@ -7,6 +7,7 @@ extern "C" {
|
|||
#include <gui/audio.h>
|
||||
#include <gui/builder.h>
|
||||
#include <gui/collection.h>
|
||||
#include <gui/playlist.h>
|
||||
#include <gui/settings.h>
|
||||
#include <gui/sidebar.h>
|
||||
#include <gui/window.h>
|
||||
|
@ -69,6 +70,7 @@ int main(int argc, char **argv)
|
|||
gui_window_init(gui :: share_file("ocarina.png").c_str());
|
||||
gui_sidebar_init();
|
||||
gui_collection_init();
|
||||
gui_playlist_init();
|
||||
gui_audio_init();
|
||||
|
||||
plist :: init();
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <gui/builder.h>
|
||||
#include <gui/playlist.h>
|
||||
|
||||
enum playlist_sidebar_columns {
|
||||
P_SB_IMAGE,
|
||||
P_SB_IMAGE_SZ,
|
||||
P_SB_NAME,
|
||||
};
|
||||
|
||||
static GtkTreeModel *p_model;
|
||||
|
||||
static gboolean __playlist_select(GtkTreeSelection *selection,
|
||||
GtkTreeModel *model, GtkTreePath *path,
|
||||
gboolean selected, gpointer data)
|
||||
{
|
||||
return gtk_tree_path_get_depth(path) != 1;
|
||||
}
|
||||
|
||||
void gui_playlist_init()
|
||||
{
|
||||
GtkTreeView *treeview;
|
||||
GtkTreeIter iter;
|
||||
|
||||
p_model = GTK_TREE_MODEL(gui_builder_object("o_playlist_store"));
|
||||
|
||||
/* Add "Playlist" header. */
|
||||
gtk_tree_store_insert(GTK_TREE_STORE(p_model), &iter, NULL, -1);
|
||||
gtk_tree_store_set(GTK_TREE_STORE(p_model), &iter,
|
||||
P_SB_IMAGE, "emblem-documents",
|
||||
P_SB_IMAGE_SZ, GTK_ICON_SIZE_LARGE_TOOLBAR,
|
||||
P_SB_NAME, "<span size='large'>Playlists</span>",
|
||||
-1);
|
||||
|
||||
treeview = GTK_TREE_VIEW(gui_builder_widget("o_playlist_view"));
|
||||
gtk_tree_selection_set_select_function(
|
||||
gtk_tree_view_get_selection(treeview),
|
||||
__playlist_select, NULL, NULL);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef OCARINA_GUI_PLAYLIST_H
|
||||
#define OCARINA_GUI_PLAYLIST_H
|
||||
|
||||
/* Called to initialize the GUI playlist code. */
|
||||
void gui_playlist_init();
|
||||
|
||||
#endif /* OCARINA_GUI_PLAYLIST_H */
|
|
@ -212,6 +212,7 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">window-close</property>
|
||||
</object>
|
||||
<object class="GtkListStore" id="liststore1"/>
|
||||
<object class="GtkTreeStore" id="o_collection_store">
|
||||
<columns>
|
||||
<!-- column-name Image -->
|
||||
|
@ -228,6 +229,16 @@
|
|||
<column type="gpointer"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkTreeStore" id="o_playlist_store">
|
||||
<columns>
|
||||
<!-- column-name Image -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name ImageSize -->
|
||||
<column type="GtkIconSize"/>
|
||||
<!-- column-name Name -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="o_progress">
|
||||
<property name="upper">100000000000</property>
|
||||
<property name="step_increment">1000000000</property>
|
||||
|
@ -618,6 +629,49 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="o_playlist_view">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="model">o_playlist_store</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<property name="show_expanders">False</property>
|
||||
<property name="level_indentation">10</property>
|
||||
<property name="enable_tree_lines">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection3"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
|
||||
<property name="title" translatable="yes">Image</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererPixbuf" id="cellrendererpixbuf2"/>
|
||||
<attributes>
|
||||
<attribute name="icon-name">0</attribute>
|
||||
<attribute name="stock-size">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
|
||||
<property name="title" translatable="yes">column</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext1"/>
|
||||
<attributes>
|
||||
<attribute name="markup">2</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="o_collection_view">
|
||||
<property name="visible">True</property>
|
||||
|
@ -675,7 +729,7 @@
|
|||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -3,4 +3,5 @@ settings
|
|||
window
|
||||
sidebar
|
||||
collection
|
||||
playlist
|
||||
audio
|
||||
|
|
|
@ -29,6 +29,7 @@ res += [ GuiTest("settings") ]
|
|||
res += [ GuiTest("window") ]
|
||||
res += [ GuiTest("sidebar") ]
|
||||
res += [ GuiTest("collection") ]
|
||||
res += [ GuiTest("playlist") ]
|
||||
res += [ GuiTest("audio") ]
|
||||
|
||||
ignore.close()
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#define TEST_NEED_AUDIO
|
||||
#include <gui/builder.h>
|
||||
#include <gui/playlist.h>
|
||||
#include <tests/gui.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
static void test_playlist_sidebar()
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeView *treeview;
|
||||
GtkTreeModel *model;
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
int argc = 0;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
gui_builder_init("share/ocarina/ocarina6.glade");
|
||||
gui_playlist_init();
|
||||
|
||||
treeview = GTK_TREE_VIEW(gui_builder_widget("o_playlist_view"));
|
||||
selection = gtk_tree_view_get_selection(treeview);
|
||||
model = GTK_TREE_MODEL(gui_builder_object("o_playlist_store"));
|
||||
test_equal(gtk_tree_model_get_iter_first(model, &iter), true);
|
||||
|
||||
path = gtk_tree_model_get_path(model, &iter);
|
||||
gtk_tree_view_set_cursor(treeview, path, NULL, false);
|
||||
gtk_tree_path_free(path);
|
||||
|
||||
test_equal(gtk_tree_selection_count_selected_rows(selection), 0);
|
||||
|
||||
gui_builder_deinit();
|
||||
}
|
||||
|
||||
DECLARE_UNIT_TESTS(
|
||||
UNIT_TEST("Playlist Sidebar", test_playlist_sidebar),
|
||||
);
|
Loading…
Reference in New Issue