gtk-stream 0.8__py3-none-any.whl → 0.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gtk_stream/_version.py +2 -2
- gtk_stream/application.py +70 -54
- gtk_stream/documents/__init__.py +1 -1
- gtk_stream/documents/classes/Picture.py +8 -0
- gtk_stream/parser.py +8 -0
- gtk_stream/properties.py +6 -1
- {gtk_stream-0.8.dist-info → gtk_stream-0.10.dist-info}/METADATA +1 -1
- {gtk_stream-0.8.dist-info → gtk_stream-0.10.dist-info}/RECORD +11 -11
- {gtk_stream-0.8.dist-info → gtk_stream-0.10.dist-info}/WHEEL +0 -0
- {gtk_stream-0.8.dist-info → gtk_stream-0.10.dist-info}/entry_points.txt +0 -0
- {gtk_stream-0.8.dist-info → gtk_stream-0.10.dist-info}/top_level.txt +0 -0
gtk_stream/_version.py
CHANGED
gtk_stream/application.py
CHANGED
@@ -17,7 +17,16 @@
|
|
17
17
|
import sys
|
18
18
|
from . import Gtk, GLib, Gdk
|
19
19
|
from .common import printEvent
|
20
|
-
from .properties import parse_property, get_prop_type
|
20
|
+
from .properties import parse_property, get_prop_type, set_parse_prop
|
21
|
+
|
22
|
+
def piloted(f):
|
23
|
+
"""A decorator for methods that are both called from the pilot
|
24
|
+
application and need access to the gtk main thread"""
|
25
|
+
def ret(self, *args, **kwargs):
|
26
|
+
def cb():
|
27
|
+
f(self, *args, **kwargs)
|
28
|
+
self.run_when_idle(cb)
|
29
|
+
return ret
|
21
30
|
|
22
31
|
class GtkStreamApp(Gtk.Application):
|
23
32
|
def __init__(self, logger, name = None, **kwargs):
|
@@ -28,14 +37,18 @@ class GtkStreamApp(Gtk.Application):
|
|
28
37
|
self.namedWidgets = { }
|
29
38
|
self.namedWindows = { }
|
30
39
|
|
31
|
-
|
32
|
-
|
40
|
+
# The first messages from the pilot may arrive before the
|
41
|
+
# application is ready to process them.
|
42
|
+
#
|
43
|
+
# If that happens, store the actions until they can be taken
|
44
|
+
# (when the "startup" signal is called)
|
45
|
+
callback_queue = []
|
33
46
|
def run_when_idle_before_startup(cb):
|
34
|
-
|
47
|
+
callback_queue.append(cb)
|
35
48
|
self.run_when_idle = run_when_idle_before_startup
|
36
49
|
|
37
50
|
def on_startup(_):
|
38
|
-
for cb in
|
51
|
+
for cb in callback_queue:
|
39
52
|
GLib.idle_add(cb)
|
40
53
|
self.run_when_idle = GLib.idle_add
|
41
54
|
self.connect('startup', on_startup)
|
@@ -44,58 +57,61 @@ class GtkStreamApp(Gtk.Application):
|
|
44
57
|
if id is not None:
|
45
58
|
self.namedWidgets[id] = w
|
46
59
|
|
60
|
+
@piloted
|
47
61
|
def openFileDialog(self, id, parent):
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
def newWindow(self, document, id,
|
63
|
-
|
64
|
-
|
65
|
-
win
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
return False
|
73
|
-
self.run_when_idle(cb)
|
62
|
+
dialog = Gtk.FileDialog()
|
63
|
+
dialog.props.modal = True
|
64
|
+
def on_choose(_, b):
|
65
|
+
try:
|
66
|
+
file = dialog.open_finish(b)
|
67
|
+
print(f"{id}:selected:{file.get_path()}")
|
68
|
+
sys.stdout.flush()
|
69
|
+
except GLib.GError as e:
|
70
|
+
print(f"{id}:none-selected")
|
71
|
+
sys.stdout.flush()
|
72
|
+
|
73
|
+
dialog.open(parent = self.namedWindows[parent], callback = on_choose)
|
74
|
+
|
75
|
+
@piloted
|
76
|
+
def newWindow(self, document, id, **attrs):
|
77
|
+
win = Gtk.Window(application=self)
|
78
|
+
for (attr_name, attr_val) in attrs.items():
|
79
|
+
set_parse_prop(self, win, attr_name, attr_val)
|
80
|
+
self.namedWindows[id] = win
|
81
|
+
win.set_child(document.render())
|
82
|
+
win.connect('close-request', printEvent(self.logger, 'close-request', id))
|
83
|
+
win.present()
|
84
|
+
|
85
|
+
@piloted
|
74
86
|
def addStyle(self, style):
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
87
|
+
provider = Gtk.CssProvider()
|
88
|
+
provider.load_from_data(style)
|
89
|
+
Gtk.StyleContext.add_provider_for_display(Gdk.Display.get_default(), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
90
|
+
|
91
|
+
@piloted
|
92
|
+
def addIconPath(self, path):
|
93
|
+
theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
|
94
|
+
theme.add_search_path(path)
|
95
|
+
|
96
|
+
@piloted
|
80
97
|
def closeWindow(self, id):
|
81
|
-
|
82
|
-
|
83
|
-
|
98
|
+
self.namedWindows[id].close()
|
99
|
+
|
100
|
+
@piloted
|
84
101
|
def removeWidget(self, id):
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
102
|
+
w = self.namedWidgets[id]
|
103
|
+
w.get_parent().remove(w)
|
104
|
+
|
105
|
+
@piloted
|
89
106
|
def insertWidget(self, to, document):
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
107
|
+
if to in self.namedWidgets:
|
108
|
+
w = self.namedWidgets[to]
|
109
|
+
w.insert_child(document)
|
110
|
+
else:
|
111
|
+
raise Exception(f"Error: unknown widget id '{to}'")
|
112
|
+
|
113
|
+
@piloted
|
97
114
|
def setProp(self, id, name, value):
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
self.run_when_idle(cb)
|
115
|
+
w = self.namedWidgets[id]
|
116
|
+
w.set_property(name, parse_property(get_prop_type(w.__class__, name), value)(self))
|
117
|
+
|
gtk_stream/documents/__init__.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from .classes.Document import Document, PseudoDocument
|
2
2
|
|
3
3
|
from .classes.Label import Label
|
4
|
-
from .classes.Picture import Picture
|
4
|
+
from .classes.Picture import Picture, Icon
|
5
5
|
from .classes.ProgressBar import ProgressBar
|
6
6
|
from .classes.Separator import Separator
|
7
7
|
|
@@ -25,3 +25,11 @@ class Picture(Document):
|
|
25
25
|
self.src = src
|
26
26
|
def render_raw(self):
|
27
27
|
return Gtk.Picture.new_for_filename(self.src)
|
28
|
+
|
29
|
+
class Icon(Document):
|
30
|
+
__g_class__ = Gtk.Image
|
31
|
+
def __init__(self, app, src, **kwargs):
|
32
|
+
super().__init__(app, **kwargs)
|
33
|
+
self.src = src
|
34
|
+
def render_raw(self):
|
35
|
+
return Gtk.Image.new_from_file(self.src)
|
gtk_stream/parser.py
CHANGED
@@ -43,6 +43,7 @@ WIDGET_DOCUMENTS = {
|
|
43
43
|
'link' : docs.LinkButton,
|
44
44
|
'switch' : docs.Switch,
|
45
45
|
'picture' : docs.Picture,
|
46
|
+
'icon' : docs.Icon,
|
46
47
|
'separator' : docs.Separator,
|
47
48
|
'scrolled-window' : docs.ScrolledWindow,
|
48
49
|
'stack' : docs.Stack,
|
@@ -126,6 +127,13 @@ class GtkStreamXMLHandler(sax.ContentHandler):
|
|
126
127
|
self.transition_chars = onchars
|
127
128
|
self.transition_enter = self.transE_final
|
128
129
|
self.transition_leave = self.transL_tag('style', self.transE_message, leave_parent, leave)
|
130
|
+
|
131
|
+
case 'add-icon-path':
|
132
|
+
if 'path' in attrs:
|
133
|
+
def leave():
|
134
|
+
self.app.addIconPath(attrs['path'])
|
135
|
+
self.transition_enter = self.transE_final
|
136
|
+
self.transition_leave = self.transL_tag('add-icon-path', self.transE_message, leave_parent, leave)
|
129
137
|
|
130
138
|
case 'window':
|
131
139
|
if 'id' in attrs:
|
gtk_stream/properties.py
CHANGED
@@ -57,4 +57,9 @@ def parse_property(prop_type, val):
|
|
57
57
|
# print(f"Parsing property '{val}' of type '{prop_type}'", file=sys.stderr)
|
58
58
|
return _PARSE_TYPE_PROPERTY[prop_type](val)
|
59
59
|
def get_prop_type(klass, prop):
|
60
|
-
|
60
|
+
try:
|
61
|
+
return klass.find_property(prop).value_type.name
|
62
|
+
except AttributeError:
|
63
|
+
raise Exception(f"Unknown GTK property '{prop}' of class '{klass}'")
|
64
|
+
def set_parse_prop(app, w, prop_name, val):
|
65
|
+
w.set_property(prop_name, parse_property(get_prop_type(w.__class__, prop_name), val)(app))
|
@@ -1,11 +1,11 @@
|
|
1
1
|
gtk_stream/__init__.py,sha256=y6JLknVFexWrSo_Zl7-TXrPR6EQ5XVMeFO1bUzLN9Lg,98
|
2
|
-
gtk_stream/_version.py,sha256=
|
3
|
-
gtk_stream/application.py,sha256=
|
2
|
+
gtk_stream/_version.py,sha256=wg35lkz1DoondiGS1z7m4ZtbxPvMGnIj2qR4wzIH4-U,408
|
3
|
+
gtk_stream/application.py,sha256=s-2A8JSSIum9QDo35oxri-10OLg5BUIfTKS0FZDQd6A,4114
|
4
4
|
gtk_stream/command_line.py,sha256=Ej4mmPiuYjr5-1JrvjGK0BDitKUCfVEI9uHp1p_FAr4,1520
|
5
5
|
gtk_stream/common.py,sha256=xdscxYgBg_Ux6iyk26gB-AMSgoUIqlZUPgso5YS_gKE,2106
|
6
|
-
gtk_stream/parser.py,sha256=
|
7
|
-
gtk_stream/properties.py,sha256=
|
8
|
-
gtk_stream/documents/__init__.py,sha256=
|
6
|
+
gtk_stream/parser.py,sha256=rcZtH0T5s6ttVXvbHZjX2hBoasWNbtDR5LEa8yiHUj4,8772
|
7
|
+
gtk_stream/properties.py,sha256=oCG4EIMWS4WdKY4YzQZzllddoIY33GvnbgvMG3C5Muo,2630
|
8
|
+
gtk_stream/documents/__init__.py,sha256=MVqnPXrTuoKyUHJ41jgqbFr3VA5JWfI6QFfXAIE6DuQ,789
|
9
9
|
gtk_stream/documents/classes/Box.py,sha256=d01o2-JQ3-k0VjvvY8E7mly-u_f1v1NqYz1IDjHZLUo,1381
|
10
10
|
gtk_stream/documents/classes/Button.py,sha256=0Cs5DOt-FoDVLWIktJHuH6OasI58TNI0Gs3uIKJDj2o,1563
|
11
11
|
gtk_stream/documents/classes/Document.py,sha256=drWy-2HzgmpxSmRR27uIydlTJbaYTiRJPWwpELXrGSk,2135
|
@@ -16,15 +16,15 @@ gtk_stream/documents/classes/Frame.py,sha256=zAZvsT-YTZMijsgk7p0YVf6siAmFoCCSXou
|
|
16
16
|
gtk_stream/documents/classes/Grid.py,sha256=jDJ9U1GJZ45hi1VvPsCwFILN7CwEkgjqYqhTzMdtX9o,1249
|
17
17
|
gtk_stream/documents/classes/Label.py,sha256=bBNBTvGs6fM8uLf4EDb2Ro8FmCeS27cnU1Ao-44nRYs,1023
|
18
18
|
gtk_stream/documents/classes/Paned.py,sha256=q1goKJMWBg1d3hS0eanPBxzBqLB-Pz5hUnH9N-RXXh8,1392
|
19
|
-
gtk_stream/documents/classes/Picture.py,sha256=
|
19
|
+
gtk_stream/documents/classes/Picture.py,sha256=QCLQNuQxfXmaasd-bPgXxJZYyc1e1DQkLdxCZ39gvlI,1251
|
20
20
|
gtk_stream/documents/classes/ProgressBar.py,sha256=NPJtP3qaKiZUEAYEHZk4FEoWSFn2KVorI2SVb8cDnW0,966
|
21
21
|
gtk_stream/documents/classes/ScrolledWindow.py,sha256=WaTPgz6GBC-hjH83SQT2OGUdCapHAgO3xEmSMJZ8q70,1041
|
22
22
|
gtk_stream/documents/classes/Separator.py,sha256=uw_EgAKs_6pNA8nrOLzruIlJfk4uaogB0p_jeoY0PHM,960
|
23
23
|
gtk_stream/documents/classes/Stack.py,sha256=YA6NDzZL2u4Ko8GXtx8Or-jEWGMCEw2cC1HNkAMRw-8,1030
|
24
24
|
gtk_stream/documents/classes/Switch.py,sha256=OLCWWNeVyNrk4Tu3JDe64FqsLhedh3dDzKDKne2CyDw,1382
|
25
25
|
gtk_stream/documents/classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
|
-
gtk_stream-0.
|
27
|
-
gtk_stream-0.
|
28
|
-
gtk_stream-0.
|
29
|
-
gtk_stream-0.
|
30
|
-
gtk_stream-0.
|
26
|
+
gtk_stream-0.10.dist-info/METADATA,sha256=Tmq513moUwqczsg1EYEh0-eBcz-SJs3gTVAXUHGlt_Y,805
|
27
|
+
gtk_stream-0.10.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
28
|
+
gtk_stream-0.10.dist-info/entry_points.txt,sha256=PmhKTb4MMQM6dN2HJcoDSMI8L0lZIFIlFn-BgdfPDpo,60
|
29
|
+
gtk_stream-0.10.dist-info/top_level.txt,sha256=vE9zfHGe9Ke7FSe0wBK2WYJI-BpcQNu6xDC3Cu5O8rQ,11
|
30
|
+
gtk_stream-0.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|