sidebar: Begin sidebar widgets

They involve a stack and a vbox where toggle buttons will eventually be
placed.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-06-16 09:47:07 -04:00
parent 5275feecf3
commit aff3fade6f
4 changed files with 26 additions and 2 deletions

9
sidebar/__init__.py Normal file
View File

@ -0,0 +1,9 @@
# Copyright 2021 (c) Anna Schumaker.
from gi.repository import Gtk
Switcher = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
Stack = Gtk.Stack()
Box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
Box.append(Switcher)
Box.append(Stack)

13
test_sidebar.py Normal file
View File

@ -0,0 +1,13 @@
# Copyright 2021 (c) Anna Schumaker.
import sidebar
import unittest
from gi.repository import Gtk
class TestSidebar(unittest.TestCase):
def test_sidebar_init(self):
self.assertIsInstance(sidebar.Switcher, Gtk.Box)
self.assertIsInstance(sidebar.Stack, Gtk.Stack)
self.assertIsInstance(sidebar.Box, Gtk.Box)
self.assertIn(sidebar.Switcher, sidebar.Box)
self.assertIn(sidebar.Stack, sidebar.Box)

View File

@ -1,6 +1,7 @@
# Copyright 2021 (c) Anna Schumaker.
from lib import settings
from gi.repository import Gtk
import sidebar
Pane = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)
@ -9,6 +10,7 @@ def initialize():
initialize()
Pane.set_position(settings.get_int("sidebar.width"))
Pane.set_start_child(sidebar.Box)
Pane.set_vexpand(True)
def on_change_position(pane, position):
@ -19,7 +21,5 @@ Pane.connect("notify::position", on_change_position)
#
# Create some dummy widgets so the pane actually shows up
#
Sidebar = Gtk.Label.new(str="Sidebar")
Content = Gtk.Label.new(str="Content")
Pane.set_start_child(Sidebar)
Pane.set_end_child(Content)

View File

@ -2,6 +2,7 @@
from lib import settings
from . import pane
from gi.repository import Gtk
import sidebar
import unittest
class TestUIPane(unittest.TestCase):
@ -10,6 +11,7 @@ class TestUIPane(unittest.TestCase):
def test_pane_init(self):
self.assertIsInstance(pane.Pane, Gtk.Paned)
self.assertEqual(pane.Pane.get_start_child(), sidebar.Box)
self.assertTrue(pane.Pane.get_vexpand())
self.assertEqual(pane.Pane.get_position(), 250)