gtk-stream 0.5.1__tar.gz → 0.6.1__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 (45) hide show
  1. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/PKG-INFO +9 -2
  2. gtk_stream-0.6.1/README.md +5 -0
  3. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream/application.py +17 -2
  4. gtk_stream-0.6.1/gtk_stream/command_line.py +30 -0
  5. gtk_stream-0.6.1/gtk_stream/common.py +35 -0
  6. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream/documents/__init__.py +1 -0
  7. gtk_stream-0.6.1/gtk_stream/documents/classes/Box.py +38 -0
  8. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream/documents/classes/Button.py +16 -0
  9. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream/documents/classes/Document.py +17 -1
  10. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream/documents/classes/Dropdown.py +16 -0
  11. gtk_stream-0.6.1/gtk_stream/documents/classes/Frame.py +34 -0
  12. gtk_stream-0.6.1/gtk_stream/documents/classes/Grid.py +36 -0
  13. gtk_stream-0.6.1/gtk_stream/documents/classes/Label.py +28 -0
  14. gtk_stream-0.6.1/gtk_stream/documents/classes/Paned.py +37 -0
  15. gtk_stream-0.6.1/gtk_stream/documents/classes/Picture.py +27 -0
  16. gtk_stream-0.6.1/gtk_stream/documents/classes/ProgressBar.py +25 -0
  17. gtk_stream-0.6.1/gtk_stream/documents/classes/ScrolledWindow.py +27 -0
  18. gtk_stream-0.6.1/gtk_stream/documents/classes/Separator.py +25 -0
  19. gtk_stream-0.6.1/gtk_stream/documents/classes/Stack.py +27 -0
  20. gtk_stream-0.6.1/gtk_stream/documents/classes/Switch.py +32 -0
  21. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream/parser.py +18 -1
  22. gtk_stream-0.6.1/gtk_stream/properties.py +60 -0
  23. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream.egg-info/PKG-INFO +9 -2
  24. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream.egg-info/SOURCES.txt +2 -0
  25. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/pyproject.toml +3 -2
  26. gtk_stream-0.5.1/gtk_stream/command_line.py +0 -14
  27. gtk_stream-0.5.1/gtk_stream/common.py +0 -19
  28. gtk_stream-0.5.1/gtk_stream/documents/classes/Box.py +0 -22
  29. gtk_stream-0.5.1/gtk_stream/documents/classes/Frame.py +0 -18
  30. gtk_stream-0.5.1/gtk_stream/documents/classes/Grid.py +0 -20
  31. gtk_stream-0.5.1/gtk_stream/documents/classes/Label.py +0 -12
  32. gtk_stream-0.5.1/gtk_stream/documents/classes/Paned.py +0 -21
  33. gtk_stream-0.5.1/gtk_stream/documents/classes/Picture.py +0 -11
  34. gtk_stream-0.5.1/gtk_stream/documents/classes/ProgressBar.py +0 -9
  35. gtk_stream-0.5.1/gtk_stream/documents/classes/ScrolledWindow.py +0 -11
  36. gtk_stream-0.5.1/gtk_stream/documents/classes/Separator.py +0 -9
  37. gtk_stream-0.5.1/gtk_stream/documents/classes/Switch.py +0 -16
  38. gtk_stream-0.5.1/gtk_stream/properties.py +0 -38
  39. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream/__init__.py +0 -0
  40. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream/documents/classes/__init__.py +0 -0
  41. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream.egg-info/dependency_links.txt +0 -0
  42. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream.egg-info/entry_points.txt +0 -0
  43. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream.egg-info/requires.txt +0 -0
  44. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/gtk_stream.egg-info/top_level.txt +0 -0
  45. {gtk_stream-0.5.1 → gtk_stream-0.6.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gtk-stream
3
- Version: 0.5.1
3
+ Version: 0.6.1
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://coiffier.net/projects/gtk-stream/
@@ -9,5 +9,12 @@ Classifier: Development Status :: 4 - Beta
9
9
  Classifier: Intended Audience :: Developers
10
10
  Classifier: Environment :: X11 Applications :: GTK
11
11
  Classifier: Topic :: Software Development :: User Interfaces
12
- Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2)
12
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
13
+ Description-Content-Type: text/markdown
13
14
  Requires-Dist: pygobject
15
+
16
+ GTK-Stream
17
+ ==========
18
+
19
+ - Pretty documentation : [link](https://coiffier.net/projects/gtk-stream/)
20
+ - Same documentation, but less pretty : [link](doc/index.md)
@@ -0,0 +1,5 @@
1
+ GTK-Stream
2
+ ==========
3
+
4
+ - Pretty documentation : [link](https://coiffier.net/projects/gtk-stream/)
5
+ - Same documentation, but less pretty : [link](doc/index.md)
@@ -1,5 +1,20 @@
1
- import sys
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
2
16
 
17
+ import sys
3
18
  from . import Gtk, GLib, Gdk
4
19
  from .common import printEvent
5
20
  from .properties import parse_property, get_prop_type
@@ -81,5 +96,5 @@ class GtkStreamApp(Gtk.Application):
81
96
  def setProp(self, id, name, value):
82
97
  def cb():
83
98
  w = self.namedWidgets[id]
84
- w.set_property(name, parse_property(get_prop_type(w.__class__, name), value))
99
+ w.set_property(name, parse_property(get_prop_type(w.__class__, name), value)(self))
85
100
  self.run_when_idle(cb)
@@ -0,0 +1,30 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ import io
18
+ import xml.sax as sax
19
+ import signal
20
+
21
+ from .parser import GtkStreamXMLHandler
22
+
23
+ def main():
24
+ handler = GtkStreamXMLHandler()
25
+ parser = sax.make_parser()
26
+ parser.setContentHandler(handler)
27
+ try:
28
+ parser.parse(io.FileIO(0, 'r', closefd=False))
29
+ finally:
30
+ handler.app.release()
@@ -0,0 +1,35 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ import sys
18
+
19
+ def _data_str_default(*args):
20
+ return ''
21
+ def _data_str_by(get_data):
22
+ def ret(*args):
23
+ return ":"+get_data(*args)
24
+ return ret
25
+
26
+ def printEvent(event, id, retval = None, get_data = None):
27
+ data_str = _data_str_default if get_data == None else _data_str_by(get_data)
28
+ def ret(*args):
29
+ try:
30
+ print("{}:{}{}".format(id,event,data_str(*args)), file=sys.stdout)
31
+ sys.stdout.flush()
32
+ except Exception as e:
33
+ print("Exception when writing an event: {}".format(e), file=sys.stderr)
34
+ return retval
35
+ return ret
@@ -14,3 +14,4 @@ from .classes.ScrolledWindow import ScrolledWindow
14
14
  from .classes.Paned import Paned
15
15
  from .classes.Frame import Frame, FrameLabel
16
16
  from .classes.Grid import Grid, Cell
17
+ from .classes.Stack import Stack
@@ -0,0 +1,38 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ from ... import Gtk
18
+ from .. import Document, PseudoDocument
19
+
20
+ class BoxPrepend(PseudoDocument):
21
+ def __init__(self, app, after = None):
22
+ super().__init__(app)
23
+ self.after = after
24
+
25
+ class Box(Document):
26
+ __g_class__ = Gtk.Box
27
+ def __init__(self, app, **kwargs):
28
+ super().__init__(app, **kwargs)
29
+ def render_raw(self):
30
+ return Gtk.Box()
31
+ def insert_child(self, w, d):
32
+ if isinstance(d, BoxPrepend):
33
+ if d.after != None:
34
+ w.insert_child_after(d.render(), self.app.namedWidgets[d.after])
35
+ else:
36
+ w.prepend(d.render())
37
+ else:
38
+ w.append(d.render())
@@ -1,3 +1,19 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
1
17
  from ... import Gtk
2
18
  from ...common import printEvent
3
19
  from .. import Document
@@ -1,3 +1,19 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
1
17
  from ...properties import parse_property, get_prop_type
2
18
 
3
19
  class Document:
@@ -18,7 +34,7 @@ class Document:
18
34
  self.app.nameWidget(self.id, w)
19
35
  for (p,v) in self.props.items():
20
36
  # print(f"Setting property '{p}' to '{v}' in widget {self.__class__}", file=sys.stderr)
21
- w.set_property(p, v)
37
+ w.set_property(p, v(self.app))
22
38
  w.insert_child = lambda d: self.insert_child(w, d)
23
39
  def render(self):
24
40
  w = self.render_raw()
@@ -1,3 +1,19 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
1
17
  from ... import Gtk, Gio, GObject
2
18
  from .. import Document
3
19
  from ...common import printEvent
@@ -0,0 +1,34 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ from ... import Gtk
18
+ from .. import Document, PseudoDocument
19
+
20
+ class FrameLabel(PseudoDocument):
21
+ def __init__(self, app):
22
+ super().__init__(app)
23
+
24
+ class Frame(Document):
25
+ __g_class__ = Gtk.Frame
26
+ def __init__(self, app, **kwargs):
27
+ super().__init__(app,**kwargs)
28
+ def render_raw(self):
29
+ return Gtk.Frame()
30
+ def insert_child(self, w, d):
31
+ if isinstance(d, FrameLabel):
32
+ w.set_label_widget(d.render())
33
+ else:
34
+ w.set_child(d.render())
@@ -0,0 +1,36 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ from ... import Gtk
18
+ from .. import Document, PseudoDocument
19
+
20
+ class Cell(PseudoDocument):
21
+ def __init__(self, app, x, y, w="1", h="1"):
22
+ super().__init__(app)
23
+ self.x = int(x)
24
+ self.y = int(y)
25
+ self.w = int(w)
26
+ self.h = int(h)
27
+
28
+ class Grid(Document):
29
+ __g_class__ = Gtk.Grid
30
+ def __init__(self, app, **kwargs):
31
+ super().__init__(app, **kwargs)
32
+
33
+ def render_raw(self):
34
+ return Gtk.Grid()
35
+ def insert_child(self, w, d):
36
+ w.attach(d.render(), d.x, d.y, d.w, d.h)
@@ -0,0 +1,28 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ from ... import Gtk
18
+ from .. import Document
19
+
20
+ class Label(Document):
21
+ __g_class__ = Gtk.Label
22
+ def __init__(self, app, text, **kwargs):
23
+ super().__init__(app, **kwargs)
24
+ self.text = text
25
+ def render_raw(self):
26
+ l = Gtk.Label()
27
+ l.set_text(self.text)
28
+ return l
@@ -0,0 +1,37 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ from ... import Gtk
18
+ from .. import Document
19
+
20
+ class Paned(Document):
21
+ __g_class__ = Gtk.Paned
22
+ def __init__(self, app, **kwargs):
23
+ super().__init__(app, **kwargs)
24
+ def render(self):
25
+ if len(self.children) == 1:
26
+ return self.children[0].render()
27
+
28
+ l = self.children[0].render()
29
+ for (r,rem_size) in zip(self.children[1:], range(len(self.children),1,-1)):
30
+ j = Gtk.Paned()
31
+ j.set_shrink_start_child(False)
32
+ j.set_shrink_end_child(False)
33
+ j.props.start_child = l
34
+ j.props.end_child = r.render()
35
+ self.set_properties(j)
36
+ l = j
37
+ return l
@@ -0,0 +1,27 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ import sys
18
+ from ... import Gtk
19
+ from .. import Document
20
+
21
+ class Picture(Document):
22
+ __g_class__ = Gtk.Picture
23
+ def __init__(self, app, src, **kwargs):
24
+ super().__init__(app, **kwargs)
25
+ self.src = src
26
+ def render_raw(self):
27
+ return Gtk.Picture.new_for_filename(self.src)
@@ -0,0 +1,25 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ from ... import Gtk
18
+ from .. import Document
19
+
20
+ class ProgressBar(Document):
21
+ __g_class__ = Gtk.ProgressBar
22
+ def __init__(self, app, **kwargs):
23
+ super().__init__(app, **kwargs)
24
+ def render_raw(self):
25
+ return Gtk.ProgressBar()
@@ -0,0 +1,27 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ from ... import Gtk
18
+ from .. import Document
19
+
20
+ class ScrolledWindow(Document):
21
+ __g_class__ = Gtk.ScrolledWindow
22
+ def __init__(self, app, **kwargs):
23
+ super().__init__(app, **kwargs)
24
+ def render_raw(self):
25
+ return Gtk.ScrolledWindow()
26
+ def insert_child(self, w, d):
27
+ w.set_child(d.render())
@@ -0,0 +1,25 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ from ... import Gtk
18
+ from .. import Document
19
+
20
+ class Separator(Document):
21
+ __g_class__ = Gtk.Separator
22
+ def __init__(self, app, **kwargs):
23
+ super().__init__(app, **kwargs)
24
+ def render_raw(self):
25
+ return Gtk.Separator()
@@ -0,0 +1,27 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ from ... import Gtk
18
+ from .. import Document, PseudoDocument
19
+
20
+ class Stack(Document):
21
+ __g_class__ = Gtk.Stack
22
+ def __init__(self, app, **kwargs):
23
+ super().__init__(app, **kwargs)
24
+ def render_raw(self):
25
+ return Gtk.Stack()
26
+ def insert_child(self, w, d):
27
+ w.add_child(d.render())
@@ -0,0 +1,32 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ from ... import Gtk
18
+ from ...common import printEvent
19
+ from .. import Document
20
+ from ...properties import parse_property
21
+
22
+ class Switch(Document):
23
+ __g_class__ = Gtk.Switch
24
+ def __init__(self, app, id, managed = "false", **kwargs):
25
+ super().__init__(app, id=id, **kwargs)
26
+ self.managed = parse_property('gboolean', managed)(app)
27
+ def render_raw(self):
28
+ ret = Gtk.Switch()
29
+ ret.connect('state-set', printEvent('switch', self.id,
30
+ retval = self.managed,
31
+ get_data = lambda _,state: "on" if state else "off"))
32
+ return ret
@@ -1,3 +1,19 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
1
17
  import threading
2
18
  import signal
3
19
  import sys
@@ -28,7 +44,8 @@ WIDGET_DOCUMENTS = {
28
44
  'switch' : docs.Switch,
29
45
  'picture' : docs.Picture,
30
46
  'separator' : docs.Separator,
31
- 'scrolled-window' : docs.ScrolledWindow
47
+ 'scrolled-window' : docs.ScrolledWindow,
48
+ 'stack' : docs.Stack
32
49
  }
33
50
 
34
51
  class GtkStreamXMLHandler(sax.ContentHandler):
@@ -0,0 +1,60 @@
1
+ # Gtk-Stream : A stream-based GUI protocol
2
+ # Copyright (C) 2024 Marc Coiffier
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ import sys
18
+
19
+ from . import Gtk
20
+
21
+ def _const(x):
22
+ return lambda _: x
23
+ def _parse_orientation_property(val):
24
+ return _const((Gtk.Orientation.HORIZONTAL) if val == "horizontal" else (Gtk.Orientation.VERTICAL))
25
+ def _parse_boolean_property(val):
26
+ return _const(True if val == "true" else False)
27
+ def _parse_float_property(val):
28
+ return _const(float(val))
29
+ def _parse_int_property(val):
30
+ return _const(int(val))
31
+ def _parse_searchMode_property(val):
32
+ match val:
33
+ case 'exact':
34
+ return _const(Gtk.StringFilterMatchMode.EXACT)
35
+ case 'substring':
36
+ return _const(Gtk.StringFilterMatchMode.SUBSTRING)
37
+ case _:
38
+ return _const(Gtk.StringFilterMatchMode.PREFIX)
39
+ def _parse_css_classes_property(val):
40
+ return _const(val.split())
41
+ def _parse_widget_property(val):
42
+ return lambda app: app.namedWidgets[val]
43
+
44
+ _PARSE_TYPE_PROPERTY = {
45
+ 'GStrv' : _parse_css_classes_property,
46
+ 'GtkOrientation' : _parse_orientation_property,
47
+ 'gdouble' : _parse_float_property,
48
+ 'gfloat' : _parse_float_property,
49
+ 'gint' : _parse_int_property,
50
+ 'gboolean' : _parse_boolean_property,
51
+ 'GtkStringFilterMatchMode' : _parse_searchMode_property,
52
+ 'GtkWidget' : _parse_widget_property,
53
+ 'gchararray' : _const,
54
+ }
55
+
56
+ def parse_property(prop_type, val):
57
+ # print(f"Parsing property '{val}' of type '{prop_type}'", file=sys.stderr)
58
+ return _PARSE_TYPE_PROPERTY[prop_type](val)
59
+ def get_prop_type(klass, prop):
60
+ return klass.find_property(prop).value_type.name
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gtk-stream
3
- Version: 0.5.1
3
+ Version: 0.6.1
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://coiffier.net/projects/gtk-stream/
@@ -9,5 +9,12 @@ Classifier: Development Status :: 4 - Beta
9
9
  Classifier: Intended Audience :: Developers
10
10
  Classifier: Environment :: X11 Applications :: GTK
11
11
  Classifier: Topic :: Software Development :: User Interfaces
12
- Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2)
12
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
13
+ Description-Content-Type: text/markdown
13
14
  Requires-Dist: pygobject
15
+
16
+ GTK-Stream
17
+ ==========
18
+
19
+ - Pretty documentation : [link](https://coiffier.net/projects/gtk-stream/)
20
+ - Same documentation, but less pretty : [link](doc/index.md)
@@ -1,3 +1,4 @@
1
+ README.md
1
2
  pyproject.toml
2
3
  gtk_stream/__init__.py
3
4
  gtk_stream/application.py
@@ -24,5 +25,6 @@ gtk_stream/documents/classes/Picture.py
24
25
  gtk_stream/documents/classes/ProgressBar.py
25
26
  gtk_stream/documents/classes/ScrolledWindow.py
26
27
  gtk_stream/documents/classes/Separator.py
28
+ gtk_stream/documents/classes/Stack.py
27
29
  gtk_stream/documents/classes/Switch.py
28
30
  gtk_stream/documents/classes/__init__.py
@@ -4,11 +4,12 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gtk-stream"
7
- version = "0.5.1"
7
+ version = "0.6.1"
8
8
  description = "A simple stream-oriented GUI protocol"
9
9
  authors = [
10
10
  { name = "Marc Coiffier", email = "marc.coiffier@univ-grenoble-alpes.fr" }
11
11
  ]
12
+ readme = "README.md"
12
13
 
13
14
  dependencies = [ "pygobject" ]
14
15
  classifiers = [
@@ -16,7 +17,7 @@ classifiers = [
16
17
  "Intended Audience :: Developers",
17
18
  "Environment :: X11 Applications :: GTK",
18
19
  "Topic :: Software Development :: User Interfaces",
19
- "License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
20
+ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
20
21
  ]
21
22
 
22
23
  [project.urls]
@@ -1,14 +0,0 @@
1
- import io
2
- import xml.sax as sax
3
- import signal
4
-
5
- from .parser import GtkStreamXMLHandler
6
-
7
- def main():
8
- handler = GtkStreamXMLHandler()
9
- parser = sax.make_parser()
10
- parser.setContentHandler(handler)
11
- try:
12
- parser.parse(io.FileIO(0, 'r', closefd=False))
13
- finally:
14
- handler.app.release()
@@ -1,19 +0,0 @@
1
- import sys
2
-
3
- def _data_str_default(*args):
4
- return ''
5
- def _data_str_by(get_data):
6
- def ret(*args):
7
- return ":"+get_data(*args)
8
- return ret
9
-
10
- def printEvent(event, id, retval = None, get_data = None):
11
- data_str = _data_str_default if get_data == None else _data_str_by(get_data)
12
- def ret(*args):
13
- try:
14
- print("{}:{}{}".format(id,event,data_str(*args)), file=sys.stdout)
15
- sys.stdout.flush()
16
- except Exception as e:
17
- print("Exception when writing an event: {}".format(e), file=sys.stderr)
18
- return retval
19
- return ret
@@ -1,22 +0,0 @@
1
- from ... import Gtk
2
- from .. import Document, PseudoDocument
3
-
4
- class BoxPrepend(PseudoDocument):
5
- def __init__(self, app, after = None):
6
- super().__init__(app)
7
- self.after = after
8
-
9
- class Box(Document):
10
- __g_class__ = Gtk.Box
11
- def __init__(self, app, **kwargs):
12
- super().__init__(app, **kwargs)
13
- def render_raw(self):
14
- return Gtk.Box()
15
- def insert_child(self, w, d):
16
- if isinstance(d, BoxPrepend):
17
- if d.after != None:
18
- w.insert_child_after(d.render(), self.app.namedWidgets[d.after])
19
- else:
20
- w.prepend(d.render())
21
- else:
22
- w.append(d.render())
@@ -1,18 +0,0 @@
1
- from ... import Gtk
2
- from .. import Document, PseudoDocument
3
-
4
- class FrameLabel(PseudoDocument):
5
- def __init__(self, app):
6
- super().__init__(app)
7
-
8
- class Frame(Document):
9
- __g_class__ = Gtk.Frame
10
- def __init__(self, app, **kwargs):
11
- super().__init__(app,**kwargs)
12
- def render_raw(self):
13
- return Gtk.Frame()
14
- def insert_child(self, w, d):
15
- if isinstance(d, FrameLabel):
16
- w.set_label_widget(d.render())
17
- else:
18
- w.set_child(d.render())
@@ -1,20 +0,0 @@
1
- from ... import Gtk
2
- from .. import Document, PseudoDocument
3
-
4
- class Cell(PseudoDocument):
5
- def __init__(self, app, x, y, w="1", h="1"):
6
- super().__init__(app)
7
- self.x = int(x)
8
- self.y = int(y)
9
- self.w = int(w)
10
- self.h = int(h)
11
-
12
- class Grid(Document):
13
- __g_class__ = Gtk.Grid
14
- def __init__(self, app, **kwargs):
15
- super().__init__(app, **kwargs)
16
-
17
- def render_raw(self):
18
- return Gtk.Grid()
19
- def insert_child(self, w, d):
20
- w.attach(d.render(), d.x, d.y, d.w, d.h)
@@ -1,12 +0,0 @@
1
- from ... import Gtk
2
- from .. import Document
3
-
4
- class Label(Document):
5
- __g_class__ = Gtk.Label
6
- def __init__(self, app, text, **kwargs):
7
- super().__init__(app, **kwargs)
8
- self.text = text
9
- def render_raw(self):
10
- l = Gtk.Label()
11
- l.set_text(self.text)
12
- return l
@@ -1,21 +0,0 @@
1
- from ... import Gtk
2
- from .. import Document
3
-
4
- class Paned(Document):
5
- __g_class__ = Gtk.Paned
6
- def __init__(self, app, **kwargs):
7
- super().__init__(app, **kwargs)
8
- def render(self):
9
- if len(self.children) == 1:
10
- return self.children[0].render()
11
-
12
- l = self.children[0].render()
13
- for (r,rem_size) in zip(self.children[1:], range(len(self.children),1,-1)):
14
- j = Gtk.Paned()
15
- j.set_shrink_start_child(False)
16
- j.set_shrink_end_child(False)
17
- j.props.start_child = l
18
- j.props.end_child = r.render()
19
- self.set_properties(j)
20
- l = j
21
- return l
@@ -1,11 +0,0 @@
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)
@@ -1,9 +0,0 @@
1
- from ... import Gtk
2
- from .. import Document
3
-
4
- class ProgressBar(Document):
5
- __g_class__ = Gtk.ProgressBar
6
- def __init__(self, app, **kwargs):
7
- super().__init__(app, **kwargs)
8
- def render_raw(self):
9
- return Gtk.ProgressBar()
@@ -1,11 +0,0 @@
1
- from ... import Gtk
2
- from .. import Document
3
-
4
- class ScrolledWindow(Document):
5
- __g_class__ = Gtk.ScrolledWindow
6
- def __init__(self, app, **kwargs):
7
- super().__init__(app, **kwargs)
8
- def render_raw(self):
9
- return Gtk.ScrolledWindow()
10
- def insert_child(self, w, d):
11
- w.set_child(d.render())
@@ -1,9 +0,0 @@
1
- from ... import Gtk
2
- from .. import Document
3
-
4
- class Separator(Document):
5
- __g_class__ = Gtk.Separator
6
- def __init__(self, app, **kwargs):
7
- super().__init__(app, **kwargs)
8
- def render_raw(self):
9
- return Gtk.Separator()
@@ -1,16 +0,0 @@
1
- from ... import Gtk
2
- from ...common import printEvent
3
- from .. import Document
4
- from ...properties import parse_property
5
-
6
- class Switch(Document):
7
- __g_class__ = Gtk.Switch
8
- def __init__(self, app, id, managed = "false", **kwargs):
9
- super().__init__(app, id=id, **kwargs)
10
- self.managed = parse_property('gboolean', managed)
11
- def render_raw(self):
12
- ret = Gtk.Switch()
13
- ret.connect('state-set', printEvent('switch', self.id,
14
- retval = self.managed,
15
- get_data = lambda _,state: "on" if state else "off"))
16
- return ret
@@ -1,38 +0,0 @@
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
File without changes