gui/sidebar: Add a gui_sidebar() function
Called to access the GtkPaned widget. I also rename the widget "sidebar" to match the new convention. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
fd84222c2b
commit
b3074979f7
|
@ -107,9 +107,9 @@ static void __ocarina_startup(GApplication *application, gpointer data)
|
|||
gui_model_init();
|
||||
gui_filter_init();
|
||||
gui_treeview_init();
|
||||
gui_sidebar_init();
|
||||
gui_view_init();
|
||||
gui_queue_init();
|
||||
gui_sidebar_init();
|
||||
gui_collection_init();
|
||||
gui_playlist_init();
|
||||
gui_audio_init();
|
||||
|
|
|
@ -2,22 +2,19 @@
|
|||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/settings.h>
|
||||
#include <gui/builder.h>
|
||||
#include <gui/sidebar.h>
|
||||
|
||||
const gchar *SIDEBAR_SETTING = "gui.sidebar.pos";
|
||||
|
||||
|
||||
void __sidebar_resize(GtkPaned *pane, GParamSpec *pspec, gpointer data)
|
||||
void __gui_sidebar_resized(GtkPaned *pane, GParamSpec *pspec, gpointer data)
|
||||
{
|
||||
settings_set(SIDEBAR_SETTING, gtk_paned_get_position(pane));
|
||||
}
|
||||
|
||||
void gui_sidebar_init()
|
||||
{
|
||||
GtkPaned *pane = GTK_PANED(gui_builder_widget("o_sidebar"));
|
||||
int pos = settings_get(SIDEBAR_SETTING);
|
||||
|
||||
if (pos > 0)
|
||||
gtk_paned_set_position(pane, pos);
|
||||
gtk_paned_set_position(gui_sidebar(), pos);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,15 @@
|
|||
*/
|
||||
#ifndef OCARINA_GUI_SIDEBAR_H
|
||||
#define OCARINA_GUI_SIDEBAR_H
|
||||
|
||||
#include <gui/builder.h>
|
||||
|
||||
/* Called to initialize the sidebar. */
|
||||
void gui_sidebar_init();
|
||||
|
||||
/* Called to get the sidebar widget. */
|
||||
static inline GtkPaned *gui_sidebar()
|
||||
{
|
||||
return GTK_PANED(gui_builder_widget("sidebar"));
|
||||
}
|
||||
|
||||
#endif /* OCARINA_GUI_SIDEBAR_H */
|
||||
|
|
|
@ -659,14 +659,14 @@ audio-volume-medium</property>
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkPaned" id="o_sidebar">
|
||||
<object class="GtkPaned" id="sidebar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="position">140</property>
|
||||
<property name="position_set">True</property>
|
||||
<property name="wide_handle">True</property>
|
||||
<signal name="notify::position" handler="__sidebar_resize" swapped="no"/>
|
||||
<signal name="notify::position" handler="__gui_sidebar_resized" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkBox" id="box5">
|
||||
<property name="visible">True</property>
|
||||
|
|
|
@ -4,8 +4,8 @@ idle
|
|||
model
|
||||
filter
|
||||
treeview
|
||||
sidebar
|
||||
view
|
||||
queue
|
||||
sidebar
|
||||
playlist
|
||||
audio
|
||||
|
|
|
@ -10,8 +10,8 @@ gui_unit_test(Idle)
|
|||
gui_unit_test(Model)
|
||||
gui_unit_test(Filter)
|
||||
gui_unit_test(Treeview)
|
||||
gui_unit_test(Sidebar)
|
||||
gui_unit_test(View)
|
||||
gui_unit_test(Queue)
|
||||
gui_unit_test(Sidebar)
|
||||
gui_unit_test(Playlist)
|
||||
gui_unit_test(Audio)
|
||||
|
|
|
@ -2,24 +2,21 @@
|
|||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/settings.h>
|
||||
#include <gui/builder.h>
|
||||
#include <gui/sidebar.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
static void test_sidebar()
|
||||
{
|
||||
GtkPaned *paned = GTK_PANED(gui_builder_widget("o_sidebar"));
|
||||
|
||||
g_assert_false(settings_has("gui.sidebar.pos"));
|
||||
|
||||
gtk_paned_set_position(paned, 300);
|
||||
gtk_paned_set_position(gui_sidebar(), 300);
|
||||
g_assert_true(settings_has("gui.sidebar.pos"));
|
||||
g_assert_cmpuint(settings_get("gui.sidebar.pos"), ==, 300);
|
||||
|
||||
settings_set("gui.sidebar.pos", 250);
|
||||
gui_sidebar_init();
|
||||
g_assert_cmpuint(settings_get("gui.sidebar.pos"), ==, 250);
|
||||
g_assert_cmpuint(gtk_paned_get_position(paned), ==, 250);
|
||||
g_assert_cmpuint(gtk_paned_get_position(gui_sidebar()), ==, 250);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
Loading…
Reference in New Issue