gui/collection: Add sidebar widget showing Collection header
And make it non-selectable. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
480090f78d
commit
eb81fa2e20
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2015 (c) Anna Schumaker.
|
||||||
|
*/
|
||||||
|
#include <gui/builder.h>
|
||||||
|
#include <gui/collection.h>
|
||||||
|
|
||||||
|
enum collection_sidebar_columns {
|
||||||
|
C_SB_IMAGE,
|
||||||
|
C_SB_IMAGE_SZ,
|
||||||
|
C_SB_ENABLED,
|
||||||
|
C_SB_SHOW_ENABLED,
|
||||||
|
C_SB_PATH,
|
||||||
|
C_SB_LIBRARY,
|
||||||
|
};
|
||||||
|
|
||||||
|
static GtkTreeModel *c_model;
|
||||||
|
|
||||||
|
static gboolean __collection_select(GtkTreeSelection *selection,
|
||||||
|
GtkTreeModel *model, GtkTreePath *path,
|
||||||
|
gboolean selected, gpointer data)
|
||||||
|
{
|
||||||
|
return gtk_tree_path_get_depth(path) != 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gui_collection_init()
|
||||||
|
{
|
||||||
|
GtkTreeView *treeview;
|
||||||
|
GtkTreeIter parent;
|
||||||
|
|
||||||
|
c_model = GTK_TREE_MODEL(gui_builder_object("o_collection_store"));
|
||||||
|
|
||||||
|
/* Add "Collection" header. */
|
||||||
|
gtk_tree_store_insert(GTK_TREE_STORE(c_model), &parent, NULL, -1);
|
||||||
|
gtk_tree_store_set(GTK_TREE_STORE(c_model), &parent,
|
||||||
|
C_SB_IMAGE, "system-file-manager",
|
||||||
|
C_SB_IMAGE_SZ, GTK_ICON_SIZE_LARGE_TOOLBAR,
|
||||||
|
C_SB_PATH, "<span size='large'>Collection</span>",
|
||||||
|
-1);
|
||||||
|
|
||||||
|
treeview = GTK_TREE_VIEW(gui_builder_widget("o_collection_view"));
|
||||||
|
gtk_tree_selection_set_select_function(
|
||||||
|
gtk_tree_view_get_selection(treeview),
|
||||||
|
__collection_select, NULL, NULL);
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ extern "C" {
|
||||||
#include <core/idle.h>
|
#include <core/idle.h>
|
||||||
#include <gui/audio.h>
|
#include <gui/audio.h>
|
||||||
#include <gui/builder.h>
|
#include <gui/builder.h>
|
||||||
|
#include <gui/collection.h>
|
||||||
#include <gui/settings.h>
|
#include <gui/settings.h>
|
||||||
#include <gui/sidebar.h>
|
#include <gui/sidebar.h>
|
||||||
#include <gui/window.h>
|
#include <gui/window.h>
|
||||||
|
@ -67,6 +68,7 @@ int main(int argc, char **argv)
|
||||||
gui_settings_init();
|
gui_settings_init();
|
||||||
gui_window_init(gui :: share_file("ocarina.png").c_str());
|
gui_window_init(gui :: share_file("ocarina.png").c_str());
|
||||||
gui_sidebar_init();
|
gui_sidebar_init();
|
||||||
|
gui_collection_init();
|
||||||
gui_audio_init();
|
gui_audio_init();
|
||||||
|
|
||||||
plist :: init();
|
plist :: init();
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2015 (c) Anna Schumaker.
|
||||||
|
*/
|
||||||
|
#ifndef OCARINA_GUI_COLLECTION_H
|
||||||
|
#define OCARINA_GUI_COLLECTION_H
|
||||||
|
|
||||||
|
/* Called to initialize the GUI collection code. */
|
||||||
|
void gui_collection_init();
|
||||||
|
|
||||||
|
#endif /* OCARINA_GUI_COLLECTION_H */
|
|
@ -205,6 +205,22 @@
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="icon_name">window-close</property>
|
<property name="icon_name">window-close</property>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkTreeStore" id="o_collection_store">
|
||||||
|
<columns>
|
||||||
|
<!-- column-name Image -->
|
||||||
|
<column type="gchararray"/>
|
||||||
|
<!-- column-name ImageSize -->
|
||||||
|
<column type="GtkIconSize"/>
|
||||||
|
<!-- column-name Enabled -->
|
||||||
|
<column type="gboolean"/>
|
||||||
|
<!-- column-name ShowEnabled -->
|
||||||
|
<column type="gboolean"/>
|
||||||
|
<!-- column-name Path -->
|
||||||
|
<column type="gchararray"/>
|
||||||
|
<!-- column-name Library -->
|
||||||
|
<column type="gpointer"/>
|
||||||
|
</columns>
|
||||||
|
</object>
|
||||||
<object class="GtkAdjustment" id="o_progress">
|
<object class="GtkAdjustment" id="o_progress">
|
||||||
<property name="upper">100000000000</property>
|
<property name="upper">100000000000</property>
|
||||||
<property name="step_increment">1000000000</property>
|
<property name="step_increment">1000000000</property>
|
||||||
|
@ -582,11 +598,77 @@
|
||||||
<property name="wide_handle">True</property>
|
<property name="wide_handle">True</property>
|
||||||
<signal name="notify::position" handler="__sidebar_resize" swapped="no"/>
|
<signal name="notify::position" handler="__sidebar_resize" swapped="no"/>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="label4">
|
<object class="GtkScrolledWindow" id="scrolledwindow3">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">Future
|
<property name="shadow_type">in</property>
|
||||||
Sidebar</property>
|
<child>
|
||||||
|
<object class="GtkViewport" id="viewport1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="box5">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeView" id="o_collection_view">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="model">o_collection_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-selection2"/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
|
||||||
|
<property name="title" translatable="yes">Image</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCellRendererPixbuf" id="cellrendererpixbuf1"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="icon-name">0</attribute>
|
||||||
|
<attribute name="stock-size">1</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="treeviewcolumn4">
|
||||||
|
<property name="title" translatable="yes">Enabled</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCellRendererToggle" id="cellrenderertoggle1"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="visible">3</attribute>
|
||||||
|
<attribute name="active">2</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="treeviewcolumn5">
|
||||||
|
<property name="title" translatable="yes">Path</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCellRendererText" id="cellrenderertext3"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="markup">4</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="resize">False</property>
|
<property name="resize">False</property>
|
||||||
|
|
|
@ -2,4 +2,5 @@ builder
|
||||||
settings
|
settings
|
||||||
window
|
window
|
||||||
sidebar
|
sidebar
|
||||||
|
collection
|
||||||
audio
|
audio
|
||||||
|
|
|
@ -24,11 +24,12 @@ def GuiTest(name):
|
||||||
|
|
||||||
|
|
||||||
env.UsePackage("gmodule-export-2.0")
|
env.UsePackage("gmodule-export-2.0")
|
||||||
res += [ GuiTest("builder") ]
|
res += [ GuiTest("builder") ]
|
||||||
res += [ GuiTest("settings") ]
|
res += [ GuiTest("settings") ]
|
||||||
res += [ GuiTest("window") ]
|
res += [ GuiTest("window") ]
|
||||||
res += [ GuiTest("sidebar") ]
|
res += [ GuiTest("sidebar") ]
|
||||||
res += [ GuiTest("audio") ]
|
res += [ GuiTest("collection") ]
|
||||||
|
res += [ GuiTest("audio") ]
|
||||||
|
|
||||||
ignore.close()
|
ignore.close()
|
||||||
Return("res")
|
Return("res")
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2015 (c) Anna Schumaker.
|
||||||
|
*/
|
||||||
|
#define TEST_NEED_AUDIO
|
||||||
|
#include <gui/builder.h>
|
||||||
|
#include <gui/collection.h>
|
||||||
|
#include <tests/gui.h>
|
||||||
|
#include <tests/test.h>
|
||||||
|
|
||||||
|
static void test_collection_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_collection_init();
|
||||||
|
|
||||||
|
treeview = GTK_TREE_VIEW(gui_builder_widget("o_collection_view"));
|
||||||
|
selection = gtk_tree_view_get_selection(treeview);
|
||||||
|
model = GTK_TREE_MODEL(gui_builder_object("o_collection_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("Collection Sidebar", test_collection_sidebar),
|
||||||
|
);
|
Loading…
Reference in New Issue