gui/sidebar: Add new sidebar widget
This is a GtkPaned that remembers its size between Ocarina sessions. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
870a2b769b
commit
58d61f52e2
|
@ -7,6 +7,7 @@ extern "C" {
|
|||
#include <gui/audio.h>
|
||||
#include <gui/builder.h>
|
||||
#include <gui/settings.h>
|
||||
#include <gui/sidebar.h>
|
||||
#include <gui/window.h>
|
||||
}
|
||||
#include <gui/ocarina.h>
|
||||
|
@ -65,6 +66,7 @@ int main(int argc, char **argv)
|
|||
core_init(&argc, &argv, &init_data);
|
||||
gui_settings_init();
|
||||
gui_window_init(gui :: share_file("ocarina.png").c_str());
|
||||
gui_sidebar_init();
|
||||
gui_audio_init();
|
||||
|
||||
plist :: init();
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <gui/builder.h>
|
||||
#include <gui/settings.h>
|
||||
#include <gui/sidebar.h>
|
||||
|
||||
const gchar *SIDEBAR_SETTING = "gui.sidebar.pos";
|
||||
|
||||
void __sidebar_resize(GtkPaned *pane, GParamSpec *pspec, gpointer data)
|
||||
{
|
||||
gui_settings_set(SIDEBAR_SETTING, gtk_paned_get_position(pane));
|
||||
}
|
||||
|
||||
void gui_sidebar_init()
|
||||
{
|
||||
GtkPaned *pane = GTK_PANED(gui_builder_widget("o_sidebar"));
|
||||
int pos = gui_settings_get(SIDEBAR_SETTING);
|
||||
|
||||
if (pos > 0)
|
||||
gtk_paned_set_position(pane, pos);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef OCARINA_GUI_SIDEBAR_H
|
||||
#define OCARINA_GUI_SIDEBAR_H
|
||||
|
||||
/* Called to initialize the sidebar. */
|
||||
void gui_sidebar_init();
|
||||
|
||||
#endif /* OCARINA_GUI_SIDEBAR_H */
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef TESTS_GUI_H
|
||||
#define TESTS_GUI_H
|
||||
|
||||
#ifdef TEST_NEED_AUDIO
|
||||
void __audio_can_accel() {}
|
||||
void __audio_pause_count() {}
|
||||
void __audio_pause_enabled() {}
|
||||
void __audio_seek() {}
|
||||
#endif
|
||||
|
||||
#ifdef TEST_NEED_SIDEBAR
|
||||
void __sidebar_resize() {}
|
||||
#endif /* TEST_NEED_SIDEBAR */
|
||||
|
||||
#endif /* TESTS_GUI_H */
|
|
@ -260,8 +260,8 @@
|
|||
<property name="icon_name">media-skip-backward</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="n" signal="clicked" modifiers="GDK_SHIFT_MASK"/>
|
||||
<accelerator key="AudioPrev" signal="clicked"/>
|
||||
<accelerator key="n" signal="clicked" modifiers="GDK_SHIFT_MASK"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -295,8 +295,8 @@
|
|||
<property name="icon_size">5</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="space" signal="clicked"/>
|
||||
<accelerator key="AudioPlay" signal="clicked"/>
|
||||
<accelerator key="space" signal="clicked"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -329,8 +329,8 @@
|
|||
<property name="icon_size">5</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="space" signal="clicked"/>
|
||||
<accelerator key="AudioPlay" signal="clicked"/>
|
||||
<accelerator key="space" signal="clicked"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -363,8 +363,8 @@
|
|||
<property name="icon_name">media-playback-stop</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="AudioPlay" signal="clicked" modifiers="GDK_MOD1_MASK"/>
|
||||
<accelerator key="space" signal="clicked" modifiers="GDK_MOD1_MASK"/>
|
||||
<accelerator key="AudioPlay" signal="clicked" modifiers="GDK_MOD1_MASK"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -397,8 +397,8 @@
|
|||
<property name="icon_name">media-skip-forward</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="n" signal="clicked"/>
|
||||
<accelerator key="AudioNext" signal="clicked"/>
|
||||
<accelerator key="n" signal="clicked"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -573,6 +573,31 @@
|
|||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkPaned" id="o_sidebar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="position">125</property>
|
||||
<property name="position_set">True</property>
|
||||
<property name="wide_handle">True</property>
|
||||
<signal name="notify::position" handler="__sidebar_resize" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Future
|
||||
Sidebar</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="resize">False</property>
|
||||
<property name="shrink">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkNotebook" id="o_notebook">
|
||||
<property name="visible">True</property>
|
||||
|
@ -786,7 +811,7 @@
|
|||
</object>
|
||||
</child>
|
||||
<child type="tab">
|
||||
<object class="GtkBox" id="box1">
|
||||
<object class="GtkBox" id="box4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
|
@ -827,7 +852,7 @@ Manager</property>
|
|||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -849,7 +874,7 @@ Manager</property>
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -866,7 +891,7 @@ Manager</property>
|
|||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -882,7 +907,7 @@ Manager</property>
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">5</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -898,7 +923,7 @@ Manager</property>
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">6</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -906,7 +931,6 @@ Manager</property>
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="caps_lock_warning">False</property>
|
||||
<property name="input_purpose">digits</property>
|
||||
<property name="adjustment">adjustment1</property>
|
||||
<property name="numeric">True</property>
|
||||
<signal name="changed" handler="__audio_pause_count" swapped="no"/>
|
||||
|
@ -914,7 +938,7 @@ Manager</property>
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">7</property>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -927,14 +951,27 @@ Manager</property>
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">8</property>
|
||||
<property name="position">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="resize">True</property>
|
||||
<property name="shrink">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
builder
|
||||
settings
|
||||
window
|
||||
sidebar
|
||||
audio
|
||||
|
|
|
@ -27,6 +27,7 @@ env.UsePackage("gmodule-export-2.0")
|
|||
res += [ GuiTest("builder") ]
|
||||
res += [ GuiTest("settings") ]
|
||||
res += [ GuiTest("window") ]
|
||||
res += [ GuiTest("sidebar") ]
|
||||
res += [ GuiTest("audio") ]
|
||||
|
||||
ignore.close()
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#define TEST_NEED_AUDIO
|
||||
#include <gui/builder.h>
|
||||
#include <gui/settings.h>
|
||||
#include <gui/sidebar.h>
|
||||
#include <tests/gui.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
static void test_sidebar()
|
||||
{
|
||||
GtkPaned *paned;
|
||||
int argc = 0;
|
||||
|
||||
test_equal(gui_settings_has("gui.sidebar.pos"), (bool)false);
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
gui_builder_init("share/ocarina/ocarina6.glade");
|
||||
gui_settings_init();
|
||||
gui_sidebar_init();
|
||||
paned = GTK_PANED(gui_builder_widget("o_sidebar"));
|
||||
|
||||
test_equal(gui_settings_has("gui.sidebar.pos"), (bool)false);
|
||||
test_equal(gtk_paned_get_position(paned), 125);
|
||||
|
||||
gtk_paned_set_position(paned, 300);
|
||||
test_equal(gui_settings_has("gui.sidebar.pos"), (bool)true);
|
||||
test_equal(gui_settings_get("gui.sidebar.pos"), 300);
|
||||
|
||||
gui_settings_set("gui.sidebar.pos", 250);
|
||||
gui_sidebar_init();
|
||||
test_equal(gui_settings_get("gui.sidebar.pos"), 250);
|
||||
test_equal(gtk_paned_get_position(paned), 250);
|
||||
|
||||
gui_settings_deinit();
|
||||
gui_builder_deinit();
|
||||
}
|
||||
|
||||
DECLARE_UNIT_TESTS(
|
||||
UNIT_TEST("Sidebar", test_sidebar),
|
||||
);
|
|
@ -1,18 +1,16 @@
|
|||
/*
|
||||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#define TEST_NEED_AUDIO
|
||||
#define TEST_NEED_SIDEBAR
|
||||
#include <gui/builder.h>
|
||||
#include <gui/settings.h>
|
||||
#include <gui/window.h>
|
||||
#include <tests/gui.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
GMainLoop *main_loop;
|
||||
|
||||
void __audio_can_accel() {}
|
||||
void __audio_pause_count() {}
|
||||
void __audio_pause_enabled() {}
|
||||
void __audio_seek() {}
|
||||
|
||||
static int test_on_idle(gpointer data)
|
||||
{
|
||||
g_main_loop_quit(main_loop);
|
||||
|
|
Loading…
Reference in New Issue