rind: add an up / down toggle button

I'm going to use this to show and hide the text entries for playlist
filtering and autopause controls.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2019-03-31 14:18:14 -04:00
parent ace07b74eb
commit c6f8a48b0d
3 changed files with 79 additions and 2 deletions

View File

@ -214,6 +214,52 @@
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
<property name="layout_style">expand</property>
<child>
<object class="GtkToggleButton" id="updown_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<child>
<object class="GtkImage" id="up_arrow">
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="icon_name">go-up-symbolic</property>
<property name="icon_size">2</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="down_arrow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="icon_name">go-down-symbolic</property>
<property name="icon_size">2</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="random_button">
<property name="visible">True</property>
@ -231,7 +277,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="position">1</property>
</packing>
</child>
<child>
@ -273,7 +319,7 @@ audio-volume-medium-symbolic</property>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</object>

View File

@ -7,6 +7,10 @@ from gi.repository import Gtk, GLib
Builder = Gtk.Builder()
Builder.add_from_file("emmental.ui")
UpDown = Builder.get_object("updown_button")
UpArrow = Builder.get_object("up_arrow")
DownArrow = Builder.get_object("down_arrow")
class EmmentalApplication(Gtk.Application):
def __init__(self, *args, **kwargs):
super().__init__(*args, application_id="org.gtk.emmental", **kwargs)
@ -32,4 +36,12 @@ class EmmentalApplication(Gtk.Application):
curds.notify.run_queued()
return GLib.SOURCE_CONTINUE
def updown_toggled(self, *args):
active = UpDown.get_active()
UpArrow.set_visible(active)
DownArrow.set_visible(not active)
UpDown.connect("toggled", updown_toggled)
Application = EmmentalApplication()

View File

@ -26,3 +26,22 @@ class TestGtk(unittest.TestCase):
def test_application(self):
self.assertIsInstance(gtk.Application, Gtk.Application)
def test_updown(self):
self.assertIsInstance(gtk.UpDown, Gtk.ToggleButton)
self.assertIsInstance(gtk.UpArrow, Gtk.Image)
self.assertIsInstance(gtk.DownArrow, Gtk.Image)
self.assertFalse(gtk.UpDown.get_active())
self.assertFalse(gtk.UpArrow.is_visible())
self.assertTrue(gtk.DownArrow.is_visible())
gtk.UpDown.set_active(True)
self.assertTrue(gtk.UpDown.get_active())
self.assertTrue(gtk.UpArrow.is_visible())
self.assertFalse(gtk.DownArrow.is_visible())
gtk.UpDown.set_active(False)
self.assertFalse(gtk.UpDown.get_active())
self.assertFalse(gtk.UpArrow.is_visible())
self.assertTrue(gtk.DownArrow.is_visible())