gtk-stream 0.3__py3-none-any.whl → 0.4__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/application.py CHANGED
@@ -2,7 +2,7 @@ import sys
2
2
 
3
3
  from . import Gtk, GLib, Gdk
4
4
  from .common import printEvent
5
- from .properties import parse_property
5
+ from .properties import parse_property, get_prop_type
6
6
 
7
7
  class GtkStreamApp(Gtk.Application):
8
8
  def __init__(self, name = None, **kwargs):
@@ -81,5 +81,5 @@ class GtkStreamApp(Gtk.Application):
81
81
  def setProp(self, id, name, value):
82
82
  def cb():
83
83
  w = self.namedWidgets[id]
84
- w.set_property(name, parse_property(name, value))
84
+ w.set_property(name, parse_property(get_prop_type(w.__class__, name), value))
85
85
  self.run_when_idle(cb)
@@ -1,8 +1,10 @@
1
1
  from .classes.Document import Document, PseudoDocument
2
2
 
3
3
  from .classes.Label import Label
4
- from .classes.Button import Button, LinkButton
4
+ from .classes.Picture import Picture
5
5
  from .classes.ProgressBar import ProgressBar
6
+
7
+ from .classes.Button import Button, LinkButton
6
8
  from .classes.Dropdown import Dropdown, Item
7
9
  from .classes.Switch import Switch
8
10
 
@@ -7,6 +7,7 @@ class BoxPrepend(PseudoDocument):
7
7
  self.after = after
8
8
 
9
9
  class Box(Document):
10
+ __g_class__ = Gtk.Box
10
11
  def __init__(self, app, **kwargs):
11
12
  super().__init__(app, **kwargs)
12
13
  def render_raw(self):
@@ -3,6 +3,7 @@ from ...common import printEvent
3
3
  from .. import Document
4
4
 
5
5
  class Button(Document):
6
+ __g_class__ = Gtk.Button
6
7
  def __init__(self, app, id, **kwargs):
7
8
  super().__init__(app, id = id, **kwargs)
8
9
  def render_raw(self):
@@ -13,6 +14,7 @@ class Button(Document):
13
14
  w.set_child(d.render())
14
15
 
15
16
  class LinkButton(Button):
17
+ __g_class__ = Gtk.LinkButton
16
18
  def __init__(self, app, id, **kwargs):
17
19
  super().__init__(app, id=id, **kwargs)
18
20
  def render_raw(self):
@@ -1,11 +1,11 @@
1
- import sys
2
- from ...properties import parse_property
1
+ from ...properties import parse_property, get_prop_type
3
2
 
4
3
  class Document:
4
+ __g_class__ = None
5
5
  def __init__(self, app, id = None, **attrs):
6
6
  self.id = id
7
7
  self.app = app
8
- self.props = { attr: parse_property(attr, val) for (attr, val) in attrs.items() }
8
+ self.props = { attr: parse_property(get_prop_type(self.__g_class__, attr), val) for (attr, val) in attrs.items() }
9
9
  self.children = []
10
10
 
11
11
  def add_child(self, child):
@@ -17,6 +17,7 @@ class Document:
17
17
  def set_properties(self, w):
18
18
  self.app.nameWidget(self.id, w)
19
19
  for (p,v) in self.props.items():
20
+ # print(f"Setting property '{p}' to '{v}' in widget {self.__class__}", file=sys.stderr)
20
21
  w.set_property(p, v)
21
22
  w.insert_child = lambda d: self.insert_child(w, d)
22
23
  def render(self):
@@ -22,6 +22,7 @@ class _ItemObject(GObject.Object):
22
22
  return self.value
23
23
 
24
24
  class Dropdown(Document):
25
+ __g_class__ = Gtk.DropDown
25
26
  def __init__(self, app, id, **kwargs):
26
27
  super().__init__(app, id=id, **kwargs)
27
28
  def render_raw(self):
@@ -6,6 +6,7 @@ class FrameLabel(PseudoDocument):
6
6
  super().__init__(app)
7
7
 
8
8
  class Frame(Document):
9
+ __g_class__ = Gtk.Frame
9
10
  def __init__(self, app, **kwargs):
10
11
  super().__init__(app,**kwargs)
11
12
  def render_raw(self):
@@ -10,6 +10,7 @@ class Cell(PseudoDocument):
10
10
  self.h = int(h)
11
11
 
12
12
  class Grid(Document):
13
+ __g_class__ = Gtk.Grid
13
14
  def __init__(self, app, **kwargs):
14
15
  super().__init__(app, **kwargs)
15
16
 
@@ -2,6 +2,7 @@ from ... import Gtk
2
2
  from .. import Document
3
3
 
4
4
  class Label(Document):
5
+ __g_class__ = Gtk.Label
5
6
  def __init__(self, app, text, **kwargs):
6
7
  super().__init__(app, **kwargs)
7
8
  self.text = text
@@ -2,6 +2,7 @@ from ... import Gtk
2
2
  from .. import Document
3
3
 
4
4
  class Paned(Document):
5
+ __g_class__ = Gtk.Paned
5
6
  def __init__(self, app, **kwargs):
6
7
  super().__init__(app, **kwargs)
7
8
  def render(self):
@@ -0,0 +1,11 @@
1
+ import sys
2
+ from ... import Gtk
3
+ from .. import Document
4
+
5
+ class Picture(Document):
6
+ __g_class__ = Gtk.Picture
7
+ def __init__(self, app, src, **kwargs):
8
+ super().__init__(app, **kwargs)
9
+ self.src = src
10
+ def render_raw(self):
11
+ return Gtk.Picture.new_for_filename(self.src)
@@ -2,6 +2,7 @@ from ... import Gtk
2
2
  from .. import Document
3
3
 
4
4
  class ProgressBar(Document):
5
+ __g_class__ = Gtk.ProgressBar
5
6
  def __init__(self, app, **kwargs):
6
7
  super().__init__(app, **kwargs)
7
8
  def render_raw(self):
@@ -4,9 +4,10 @@ from .. import Document
4
4
  from ...properties import parse_property
5
5
 
6
6
  class Switch(Document):
7
+ __g_class__ = Gtk.Switch
7
8
  def __init__(self, app, id, managed = "false", **kwargs):
8
9
  super().__init__(app, id=id, **kwargs)
9
- self.managed = parse_property('managed', managed)
10
+ self.managed = parse_property('gboolean', managed)
10
11
  def render_raw(self):
11
12
  ret = Gtk.Switch()
12
13
  ret.connect('state-set', printEvent('switch', self.id,
gtk_stream/parser.py CHANGED
@@ -1,29 +1,32 @@
1
1
  import threading
2
2
  import signal
3
+ import sys
3
4
  import xml.sax as sax
4
5
 
5
6
  from . import GLib
6
- from .documents import Document, Label, Box, Button, ProgressBar, Dropdown, Item, Paned, Frame, Grid, Cell, LinkButton, Switch, FrameLabel, BoxPrepend
7
+ from . import documents as docs
8
+
7
9
  from .application import GtkStreamApp
8
10
 
9
11
  class _Object:
10
12
  pass
11
13
 
12
14
  WIDGET_DOCUMENTS = {
13
- 'progress-bar': ProgressBar,
14
- 'label': Label,
15
- 'box': Box,
16
- 'box-prepend': BoxPrepend,
17
- 'button': Button,
18
- 'dropdown': Dropdown,
19
- 'item': Item,
20
- 'paned': Paned,
21
- 'grid': Grid,
22
- 'cell': Cell,
23
- 'frame': Frame,
24
- 'frame-label': FrameLabel,
25
- 'link': LinkButton,
26
- 'switch': Switch
15
+ 'progress-bar' : docs.ProgressBar,
16
+ 'label' : docs.Label,
17
+ 'box' : docs.Box,
18
+ 'box-prepend' : docs.BoxPrepend,
19
+ 'button' : docs.Button,
20
+ 'dropdown' : docs.Dropdown,
21
+ 'item' : docs.Item,
22
+ 'paned' : docs.Paned,
23
+ 'grid' : docs.Grid,
24
+ 'cell' : docs.Cell,
25
+ 'frame' : docs.Frame,
26
+ 'frame-label' : docs.FrameLabel,
27
+ 'link' : docs.LinkButton,
28
+ 'switch' : docs.Switch,
29
+ 'picture' : docs.Picture
27
30
  }
28
31
 
29
32
  class GtkStreamXMLHandler(sax.ContentHandler):
@@ -80,11 +83,12 @@ class GtkStreamXMLHandler(sax.ContentHandler):
80
83
  match name:
81
84
  case 'style':
82
85
  style = _Object()
86
+ style.chars = []
83
87
  def onchars(s):
84
- style.chars = s
88
+ style.chars.append(s)
85
89
  def leave():
86
90
  self.transition_chars = self.ignore_chars
87
- self.app.addStyle(style.chars)
91
+ self.app.addStyle(" ".join(style.chars))
88
92
  self.transition_chars = onchars
89
93
  self.transition_enter = self.transE_final
90
94
  self.transition_leave = self.transL_tag('style', self.transE_message, leave_parent, leave)
gtk_stream/properties.py CHANGED
@@ -1,3 +1,5 @@
1
+ import sys
2
+
1
3
  from . import Gtk
2
4
 
3
5
  def _parse_orientation_property(val):
@@ -19,23 +21,18 @@ def _parse_searchMode_property(val):
19
21
  def _parse_css_classes_property(val):
20
22
  return val.split()
21
23
 
22
- _PARSE_PROPERTY = {
23
- 'css-classes': _parse_css_classes_property,
24
- 'orientation': _parse_orientation_property,
25
- 'fraction': _parse_float_property,
26
- 'show-text': _parse_boolean_property,
27
- 'enable-search': _parse_boolean_property,
28
- 'search-match-mode': _parse_searchMode_property,
29
- 'visited': _parse_boolean_property,
30
- 'hexpand': _parse_boolean_property,
31
- 'hexpand-set': _parse_boolean_property,
32
- 'vexpand': _parse_boolean_property,
33
- 'vexpand-set': _parse_boolean_property,
34
- 'xalign': _parse_float_property,
35
- 'yalign': _parse_float_property,
36
- 'state': _parse_boolean_property,
37
- 'managed': _parse_boolean_property
24
+ _PARSE_TYPE_PROPERTY = {
25
+ 'GStrv' : _parse_css_classes_property,
26
+ 'GtkOrientation' : _parse_orientation_property,
27
+ 'gdouble' : _parse_float_property,
28
+ 'gfloat' : _parse_float_property,
29
+ 'gint' : _parse_int_property,
30
+ 'gboolean' : _parse_boolean_property,
31
+ 'GtkStringFilterMatchMode' : _parse_searchMode_property
38
32
  }
39
33
 
40
- def parse_property(prop, val):
41
- return _PARSE_PROPERTY.get(prop, lambda x: x)(val)
34
+ def parse_property(prop_type, val):
35
+ # print(f"Parsing property '{val}' of type '{prop_type}'", file=sys.stderr)
36
+ return _PARSE_TYPE_PROPERTY.get(prop_type, lambda x: x)(val)
37
+ def get_prop_type(klass, prop):
38
+ return klass.find_property(prop).value_type.name
@@ -1,11 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gtk-stream
3
- Version: 0.3
3
+ Version: 0.4
4
4
  Summary: A simple stream-oriented GUI protocol
5
5
  Author-email: Marc Coiffier <marc.coiffier@univ-grenoble-alpes.fr>
6
6
  Project-URL: Homepage, https://coiffiem.gricad-pages.univ-grenoble-alpes.fr/gtk-stream/
7
7
  Classifier: Development Status :: 4 - Beta
8
8
  Classifier: Intended Audience :: Developers
9
+ Classifier: Environment :: X11 Applications :: GTK
9
10
  Classifier: Topic :: Software Development :: User Interfaces
10
11
  Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2)
11
12
  Requires-Dist: pygobject
@@ -0,0 +1,24 @@
1
+ gtk_stream/__init__.py,sha256=pDhUSN4AYNsP8_tilU1zmDCYdiv7ak4PE1TW0qFrDlg,99
2
+ gtk_stream/application.py,sha256=e_Xvi9xG1kCD979CnZyAZlFj0F8cDUf_9_Tad2bmirs,3111
3
+ gtk_stream/command_line.py,sha256=c2ghqIQB5hYxtCszss1z84yKoeRYvaMJJMi4aiTspWg,312
4
+ gtk_stream/common.py,sha256=sEw15nVw9SVp8eLVOB5Zj1JITVhUhCF0i3PSwpd8lis,590
5
+ gtk_stream/parser.py,sha256=KRzJ8yic5GcSnHUTo7vJ7HRvY7SILLrQMCC9oXOoErc,7028
6
+ gtk_stream/properties.py,sha256=jxd7f-9Xl2cfMQpXuVEc_0VrgjfWcRjES7EzfhjQ5Rw,1392
7
+ gtk_stream/documents/__init__.py,sha256=u_TgDNy8m_aNR9TYjfgxbFn1r9zASHy3LKYGCHz6pFE,456
8
+ gtk_stream/documents/classes/Box.py,sha256=-L0OSIcPCOYedJqD9zPpe183EJJkClboX1-3yGHmnL0,661
9
+ gtk_stream/documents/classes/Button.py,sha256=HeIYBix4qLVZc_a6Fs_MofyqxHeXbuZzsk_FneGLGb4,809
10
+ gtk_stream/documents/classes/Document.py,sha256=w3DXEmEvqRO8efJ5ovre_ToGylSVjN5C1vu81LiNl1U,1379
11
+ gtk_stream/documents/classes/Dropdown.py,sha256=-H344e7PsfwlnHT7eYBC35rVFkwVPSRJL3szU6w2A8U,1706
12
+ gtk_stream/documents/classes/Frame.py,sha256=xG8Wts9xBw0Kk7VKv_YHSq-zf2coeRRtQKQkdtJMXAc,502
13
+ gtk_stream/documents/classes/Grid.py,sha256=HG7zW6i4h9MMVnmBwvDI8A1mspmRk35HOc0lwGYxPQc,529
14
+ gtk_stream/documents/classes/Label.py,sha256=3KI9JyVaBhgw0RZ7jK1NEn6mZg7GG0LrZz-Y_NSS2Kg,303
15
+ gtk_stream/documents/classes/Paned.py,sha256=4xG_BWNlOn3Esd_99953OAMGmjWkdkGSHKJhnprtzG8,672
16
+ gtk_stream/documents/classes/Picture.py,sha256=fNtM3TLkr2au92m8MCJmE3fYvyajFgw1VxMfj7dYV3s,298
17
+ gtk_stream/documents/classes/ProgressBar.py,sha256=aegonsruP3jPGA6Wguk-MdIm5e3y-4Ug3q_cGglDcAA,246
18
+ gtk_stream/documents/classes/Switch.py,sha256=AQYK8MTwiB7vzJpv1JB8RTgWpW3bZ-EGY7_8MX-29TY,640
19
+ gtk_stream/documents/classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ gtk_stream-0.4.dist-info/METADATA,sha256=ogiVCA8s4UOOvDsDpOII5rqSLgH55NI2fSU0pzpa_SE,555
21
+ gtk_stream-0.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
22
+ gtk_stream-0.4.dist-info/entry_points.txt,sha256=PmhKTb4MMQM6dN2HJcoDSMI8L0lZIFIlFn-BgdfPDpo,60
23
+ gtk_stream-0.4.dist-info/top_level.txt,sha256=vE9zfHGe9Ke7FSe0wBK2WYJI-BpcQNu6xDC3Cu5O8rQ,11
24
+ gtk_stream-0.4.dist-info/RECORD,,
@@ -1,23 +0,0 @@
1
- gtk_stream/__init__.py,sha256=pDhUSN4AYNsP8_tilU1zmDCYdiv7ak4PE1TW0qFrDlg,99
2
- gtk_stream/application.py,sha256=jnVejsyc8EqH6e8XgM2x3mrTAmFY2vIMnRmYO5G9FII,3068
3
- gtk_stream/command_line.py,sha256=c2ghqIQB5hYxtCszss1z84yKoeRYvaMJJMi4aiTspWg,312
4
- gtk_stream/common.py,sha256=sEw15nVw9SVp8eLVOB5Zj1JITVhUhCF0i3PSwpd8lis,590
5
- gtk_stream/parser.py,sha256=GTkh0M6AJFSChn8W62IgcuCLwGt9DW09tvGP2Qjk8jk,6887
6
- gtk_stream/properties.py,sha256=9bYzvqmUq8EidtBDZdKupLgYM9ucIGyxmahcIp9TxT8,1542
7
- gtk_stream/documents/__init__.py,sha256=NfRHkr2-hRZjR1pcokLFAM8FZ6sEwfzKg1QA20LAQDE,418
8
- gtk_stream/documents/classes/Box.py,sha256=8HApUyNBBtX1ErTaAMBNrM1SPueizQFgNoKIkIrFDKw,635
9
- gtk_stream/documents/classes/Button.py,sha256=Hh7999KPs-9JPV7wu1cWi2J5fjfkTGfajbEqMqvejqE,747
10
- gtk_stream/documents/classes/Document.py,sha256=CC7XMXbyldPpxU0PgwQIVbxd13KN0fTSOgoUK-LnpR0,1219
11
- gtk_stream/documents/classes/Dropdown.py,sha256=NYTCSPS8Plib_3KuCdpzLeiFzGJ6WyA-P2DtMo08SC0,1675
12
- gtk_stream/documents/classes/Frame.py,sha256=5rigOtrrY1rQxuU98sxX5mUJ0ClvgabZUOW6BSxDE4w,474
13
- gtk_stream/documents/classes/Grid.py,sha256=CD_B5Gr5tPvgBl39aJxcesybTqH1M0bHvHKYl2vPcEI,502
14
- gtk_stream/documents/classes/Label.py,sha256=BeL3zlf9YPuBGYS_YtHI0Q-MoVVLPao7kPIzPlwpyHY,275
15
- gtk_stream/documents/classes/Paned.py,sha256=4jZGEebhv9pNzTyYbQ8lyx_nsKd9Nmr10703V5n_kNw,644
16
- gtk_stream/documents/classes/ProgressBar.py,sha256=2_KCboyweGsqpBck61TvVGZYIsN8QVzAyqwwTDh-pDU,212
17
- gtk_stream/documents/classes/Switch.py,sha256=uXmd_cZPZXkM31wYE4Z5d1-wuxqdt7wvS6qoE8ubaGc,610
18
- gtk_stream/documents/classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- gtk_stream-0.3.dist-info/METADATA,sha256=bzz6Ac4DhmmpkF-unA0WW8ay4_yITRHuTru7rixRNKI,504
20
- gtk_stream-0.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
21
- gtk_stream-0.3.dist-info/entry_points.txt,sha256=PmhKTb4MMQM6dN2HJcoDSMI8L0lZIFIlFn-BgdfPDpo,60
22
- gtk_stream-0.3.dist-info/top_level.txt,sha256=vE9zfHGe9Ke7FSe0wBK2WYJI-BpcQNu6xDC3Cu5O8rQ,11
23
- gtk_stream-0.3.dist-info/RECORD,,