gtk-stream 0.3__tar.gz → 0.4__tar.gz

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.
Files changed (29) hide show
  1. {gtk_stream-0.3 → gtk_stream-0.4}/PKG-INFO +2 -1
  2. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/application.py +2 -2
  3. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/documents/__init__.py +3 -1
  4. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/documents/classes/Box.py +1 -0
  5. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/documents/classes/Button.py +2 -0
  6. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/documents/classes/Document.py +4 -3
  7. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/documents/classes/Dropdown.py +1 -0
  8. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/documents/classes/Frame.py +1 -0
  9. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/documents/classes/Grid.py +1 -0
  10. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/documents/classes/Label.py +1 -0
  11. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/documents/classes/Paned.py +1 -0
  12. gtk_stream-0.4/gtk_stream/documents/classes/Picture.py +11 -0
  13. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/documents/classes/ProgressBar.py +1 -0
  14. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/documents/classes/Switch.py +2 -1
  15. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/parser.py +21 -17
  16. gtk_stream-0.4/gtk_stream/properties.py +38 -0
  17. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream.egg-info/PKG-INFO +2 -1
  18. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream.egg-info/SOURCES.txt +1 -0
  19. {gtk_stream-0.3 → gtk_stream-0.4}/pyproject.toml +2 -1
  20. gtk_stream-0.3/gtk_stream/properties.py +0 -41
  21. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/__init__.py +0 -0
  22. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/command_line.py +0 -0
  23. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/common.py +0 -0
  24. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream/documents/classes/__init__.py +0 -0
  25. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream.egg-info/dependency_links.txt +0 -0
  26. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream.egg-info/entry_points.txt +0 -0
  27. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream.egg-info/requires.txt +0 -0
  28. {gtk_stream-0.3 → gtk_stream-0.4}/gtk_stream.egg-info/top_level.txt +0 -0
  29. {gtk_stream-0.3 → gtk_stream-0.4}/setup.cfg +0 -0
@@ -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
@@ -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,
@@ -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)
@@ -0,0 +1,38 @@
1
+ import sys
2
+
3
+ from . import Gtk
4
+
5
+ def _parse_orientation_property(val):
6
+ return (Gtk.Orientation.HORIZONTAL) if val == "horizontal" else (Gtk.Orientation.VERTICAL)
7
+ def _parse_boolean_property(val):
8
+ return True if val == "true" else False
9
+ def _parse_float_property(val):
10
+ return float(val)
11
+ def _parse_int_property(val):
12
+ return int(val)
13
+ def _parse_searchMode_property(val):
14
+ match val:
15
+ case 'exact':
16
+ return Gtk.StringFilterMatchMode.EXACT
17
+ case 'substring':
18
+ return Gtk.StringFilterMatchMode.SUBSTRING
19
+ case _:
20
+ return Gtk.StringFilterMatchMode.PREFIX
21
+ def _parse_css_classes_property(val):
22
+ return val.split()
23
+
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
32
+ }
33
+
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
@@ -20,6 +20,7 @@ gtk_stream/documents/classes/Frame.py
20
20
  gtk_stream/documents/classes/Grid.py
21
21
  gtk_stream/documents/classes/Label.py
22
22
  gtk_stream/documents/classes/Paned.py
23
+ gtk_stream/documents/classes/Picture.py
23
24
  gtk_stream/documents/classes/ProgressBar.py
24
25
  gtk_stream/documents/classes/Switch.py
25
26
  gtk_stream/documents/classes/__init__.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gtk-stream"
7
- version = "0.3"
7
+ version = "0.4"
8
8
  description = "A simple stream-oriented GUI protocol"
9
9
  authors = [
10
10
  { name = "Marc Coiffier", email = "marc.coiffier@univ-grenoble-alpes.fr" }
@@ -14,6 +14,7 @@ dependencies = [ "pygobject" ]
14
14
  classifiers = [
15
15
  "Development Status :: 4 - Beta",
16
16
  "Intended Audience :: Developers",
17
+ "Environment :: X11 Applications :: GTK",
17
18
  "Topic :: Software Development :: User Interfaces",
18
19
  "License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
19
20
  ]
@@ -1,41 +0,0 @@
1
- from . import Gtk
2
-
3
- def _parse_orientation_property(val):
4
- return (Gtk.Orientation.HORIZONTAL) if val == "horizontal" else (Gtk.Orientation.VERTICAL)
5
- def _parse_boolean_property(val):
6
- return True if val == "true" else False
7
- def _parse_float_property(val):
8
- return float(val)
9
- def _parse_int_property(val):
10
- return int(val)
11
- def _parse_searchMode_property(val):
12
- match val:
13
- case 'exact':
14
- return Gtk.StringFilterMatchMode.EXACT
15
- case 'substring':
16
- return Gtk.StringFilterMatchMode.SUBSTRING
17
- case _:
18
- return Gtk.StringFilterMatchMode.PREFIX
19
- def _parse_css_classes_property(val):
20
- return val.split()
21
-
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
38
- }
39
-
40
- def parse_property(prop, val):
41
- return _PARSE_PROPERTY.get(prop, lambda x: x)(val)
File without changes
File without changes