rind: Add gtk Application and Builder
I also add a basic UI file that contains the main window. I'll add on to the gui from here. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
22b3953be0
commit
d42492ced5
|
@ -1,3 +1,4 @@
|
|||
*__pycache__*
|
||||
*.ogg
|
||||
*.coverage
|
||||
*.ui~
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# Copyright 2019 (c) Anna Schumaker.
|
||||
import curds
|
||||
import rind
|
||||
import sys
|
||||
|
||||
rind.Application.run(sys.argv)
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkApplicationWindow" id="window">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Emmental</property>
|
||||
<property name="default_width">1280</property>
|
||||
<property name="default_height">800</property>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">label</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright 2019 (c) Anna Schumaker.
|
||||
from . import gtk
|
||||
|
||||
Application = gtk.Application
|
|
@ -0,0 +1,20 @@
|
|||
# Copyright 2019 (c) Anna Schumaker.
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
Builder = Gtk.Builder()
|
||||
Builder.add_from_file("emmental.ui")
|
||||
|
||||
class EmmentalApplication(Gtk.Application):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, application_id="org.gtk.emmental", **kwargs)
|
||||
self.window = None
|
||||
|
||||
def do_activate(self):
|
||||
if self.window == None:
|
||||
self.window = Builder.get_object("window")
|
||||
self.add_window(self.window)
|
||||
self.window.present()
|
||||
|
||||
Application = EmmentalApplication()
|
|
@ -0,0 +1,28 @@
|
|||
# Copyright 2019 (c) Anna Schumaker.
|
||||
from . import gtk
|
||||
import curds
|
||||
import time
|
||||
import unittest
|
||||
from gi.repository import Gtk
|
||||
|
||||
class TestGtk(unittest.TestCase):
|
||||
def test_builder(self):
|
||||
self.assertIsInstance(gtk.Builder, Gtk.Builder)
|
||||
self.assertIsInstance(gtk.Builder.get_object("window"), Gtk.ApplicationWindow)
|
||||
|
||||
def test_window(self):
|
||||
window = gtk.Builder.get_object("window")
|
||||
self.assertIsInstance(window, Gtk.ApplicationWindow)
|
||||
self.assertIsNone(gtk.Application.window)
|
||||
self.assertEqual(window.get_title(), "Emmental")
|
||||
|
||||
thread = curds.ThreadQueue()
|
||||
thread.push(gtk.Application.run)
|
||||
while gtk.Application.window == None:
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(window.is_visible())
|
||||
gtk.Application.quit()
|
||||
thread.stop()
|
||||
|
||||
def test_application(self):
|
||||
self.assertIsInstance(gtk.Application, Gtk.Application)
|
|
@ -1,5 +1,6 @@
|
|||
# Copyright 2019 (c) Anna Schumaker.
|
||||
import curds
|
||||
import rind
|
||||
import unittest
|
||||
|
||||
class TestEmmental(unittest.TestCase):
|
||||
|
@ -10,3 +11,6 @@ class TestEmmental(unittest.TestCase):
|
|||
self.assertEqual(curds.Playlist, curds.playlist.playlist.Playlist)
|
||||
self.assertEqual(curds.ThreadQueue, curds.threadqueue.ThreadQueue)
|
||||
self.assertEqual(curds.Track, curds.tags.Track)
|
||||
|
||||
def test_import_rind(self):
|
||||
self.assertEqual(rind.Application, rind.gtk.Application)
|
||||
|
|
Loading…
Reference in New Issue