gtk-stream 0.11.5__tar.gz → 0.12__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. {gtk_stream-0.11.5 → gtk_stream-0.12}/PKG-INFO +1 -1
  2. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/_version.py +2 -2
  3. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/application.py +31 -11
  4. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/command_line.py +23 -10
  5. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Document.py +1 -1
  6. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/parser.py +14 -34
  7. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream.egg-info/PKG-INFO +1 -1
  8. {gtk_stream-0.11.5 → gtk_stream-0.12}/README.md +0 -0
  9. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk-stream +0 -0
  10. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/__init__.py +0 -0
  11. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/common.py +0 -0
  12. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/__init__.py +0 -0
  13. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Box.py +0 -0
  14. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Button.py +0 -0
  15. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Dropdown.py +0 -0
  16. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Entry.py +0 -0
  17. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/FlowBox.py +0 -0
  18. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Frame.py +0 -0
  19. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Grid.py +0 -0
  20. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Label.py +0 -0
  21. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Paned.py +0 -0
  22. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Picture.py +0 -0
  23. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/ProgressBar.py +0 -0
  24. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Scale.py +0 -0
  25. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/ScrolledWindow.py +0 -0
  26. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Separator.py +0 -0
  27. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Stack.py +0 -0
  28. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/Switch.py +0 -0
  29. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/documents/classes/__init__.py +0 -0
  30. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream/properties.py +0 -0
  31. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream.egg-info/SOURCES.txt +0 -0
  32. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream.egg-info/dependency_links.txt +0 -0
  33. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream.egg-info/entry_points.txt +0 -0
  34. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream.egg-info/requires.txt +0 -0
  35. {gtk_stream-0.11.5 → gtk_stream-0.12}/gtk_stream.egg-info/top_level.txt +0 -0
  36. {gtk_stream-0.11.5 → gtk_stream-0.12}/pyproject.toml +0 -0
  37. {gtk_stream-0.11.5 → gtk_stream-0.12}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gtk-stream
3
- Version: 0.11.5
3
+ Version: 0.12
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/
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.11.5'
16
- __version_tuple__ = version_tuple = (0, 11, 5)
15
+ __version__ = version = '0.12'
16
+ __version_tuple__ = version_tuple = (0, 12)
@@ -15,6 +15,9 @@
15
15
  # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
16
 
17
17
  import sys
18
+ import threading
19
+ import signal
20
+
18
21
  from . import Gtk, GLib, Gdk
19
22
  from .common import printEvent
20
23
  from .properties import parse_property, get_prop_type, set_parse_prop
@@ -68,14 +71,31 @@ class GtkStreamApp(Gtk.Application):
68
71
  for cb in callback_queue:
69
72
  GLib.idle_add(cb)
70
73
  self.run_when_idle = GLib.idle_add
74
+
75
+ def on_sigint(a,b):
76
+ self.logger.info("SIGINT received, quitting application")
77
+ self.quit()
78
+ signal.signal(signal.SIGINT, on_sigint)
71
79
  self.connect('startup', on_startup)
80
+
81
+ def on_activate(a):
82
+ a.hold()
83
+ self.connect('activate', on_activate)
84
+
85
+ self.attrs_set = threading.Semaphore()
86
+ self.attrs_set.acquire()
72
87
 
73
- def nameWidget(self, id, w):
88
+ def name_widget(self, id, w):
74
89
  if id is not None:
75
90
  self.namedWidgets[id] = w
76
91
 
92
+ def set_attrs(self, attrs):
93
+ for name, val in attrs.items():
94
+ set_parse_prop(self, self, name, val)
95
+ self.attrs_set.release()
96
+
77
97
  @app_message('file-dialog')
78
- def openFileDialog(self, id, parent):
98
+ def open_file_dialog(self, id, parent):
79
99
  dialog = Gtk.FileDialog()
80
100
  dialog.props.modal = True
81
101
  def on_choose(_, b):
@@ -90,7 +110,7 @@ class GtkStreamApp(Gtk.Application):
90
110
  dialog.open(parent = self.namedWindows[parent], callback = on_choose)
91
111
 
92
112
  @app_message('window', single_store)
93
- def newWindow(self, document, id, **attrs):
113
+ def new_window(self, document, id, **attrs):
94
114
  win = Gtk.Window(application=self)
95
115
  for (attr_name, attr_val) in attrs.items():
96
116
  self.logger.debug("Setting attr '%s' on window", attr_name)
@@ -101,31 +121,31 @@ class GtkStreamApp(Gtk.Application):
101
121
  win.present()
102
122
 
103
123
  @app_message('style', style_store)
104
- def addStyle(self, style):
124
+ def add_style(self, style):
105
125
  provider = Gtk.CssProvider()
106
126
  provider.load_from_data(style)
107
127
  Gtk.StyleContext.add_provider_for_display(Gdk.Display.get_default(), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
108
128
 
109
129
  @app_message('add-icon-path')
110
- def addIconPath(self, path):
130
+ def add_icon_path(self, path):
111
131
  theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
112
132
  theme.add_search_path(path)
113
133
 
114
134
  @app_message('close-window')
115
- def closeWindow(self, id):
135
+ def close_window(self, id):
116
136
  self.namedWindows[id].close()
117
137
 
118
138
  @app_message('remove')
119
- def removeWidget(self, id):
139
+ def remove_widget(self, id):
120
140
  w = self.namedWidgets[id]
121
141
  w.get_parent().remove(w)
122
142
 
123
143
  @app_message('insert', multiple_store)
124
- def insertWidgets(self, documents, into):
144
+ def insert_widgets(self, documents, into):
125
145
  for doc in documents:
126
- self.insertWidget(doc, into)
146
+ self.insert_widget(doc, into)
127
147
 
128
- def insertWidget(self, document, into):
148
+ def insert_widget(self, document, into):
129
149
  if into in self.namedWidgets:
130
150
  w = self.namedWidgets[into]
131
151
  w.insert_child(document)
@@ -133,7 +153,7 @@ class GtkStreamApp(Gtk.Application):
133
153
  raise Exception(f"Error: unknown widget id '{into}'")
134
154
 
135
155
  @app_message('set-prop')
136
- def setProp(self, id, name, value):
156
+ def set_prop(self, id, name, value):
137
157
  w = self.namedWidgets[id]
138
158
  w.set_property(name, parse_property(get_prop_type(w.__class__, name), value)(self))
139
159
 
@@ -59,7 +59,9 @@ function GTK.receive() {
59
59
  import io
60
60
  import sys
61
61
  import os
62
+ import threading
62
63
  import xml.sax as sax
64
+
63
65
  from .parser import GtkStreamXMLHandler
64
66
  from .application import GtkStreamApp
65
67
  from .common import Logger, LogLevel
@@ -75,13 +77,24 @@ function GTK.receive() {
75
77
  logger = Logger(logLevel)
76
78
 
77
79
  app = GtkStreamApp(logger)
78
- handler = GtkStreamXMLHandler(logger,app)
79
- errHandler = GtkStreamErrorHandler()
80
- parser = sax.make_parser()
81
- parser.setContentHandler(handler)
82
- parser.setErrorHandler(errHandler)
83
- try:
84
- parser.parse(io.FileIO(0, 'r', closefd=False))
85
- except Exception as e:
86
- logger.error("Done with exception : %s", e)
87
- handler.quit_application()
80
+
81
+ def parser_main():
82
+ handler = GtkStreamXMLHandler(app)
83
+ errHandler = GtkStreamErrorHandler()
84
+ parser = sax.make_parser()
85
+ parser.setContentHandler(handler)
86
+ parser.setErrorHandler(errHandler)
87
+ try:
88
+ parser.parse(io.FileIO(0, 'r', closefd=False))
89
+ except Exception as e:
90
+ logger.error("Done with exception : %s", e)
91
+ handler.quit_application()
92
+
93
+ parser_thread = threading.Thread(target = parser_main, daemon = True)
94
+ parser_thread.start()
95
+
96
+ # When the parser parses the 'application' tag, it sets the
97
+ # application attributes, and releases the semaphore so the
98
+ # application can start
99
+ app.attrs_set.acquire()
100
+ app.run()
@@ -37,7 +37,7 @@ class Document:
37
37
  """Method to render the document to a widet"""
38
38
  raise Exception("Method 'render' not implemented")
39
39
  def set_properties(self, w):
40
- self.app.nameWidget(self.id, w)
40
+ self.app.name_widget(self.id, w)
41
41
  for (p,v) in self.props.items():
42
42
  val = v(self.app)
43
43
  self.app.logger.debug("Setting property '%s' to '%s' in widget %s", p, val, self.__class__)
@@ -22,6 +22,7 @@ import xml.sax as sax
22
22
 
23
23
  from . import GLib
24
24
  from . import documents as docs
25
+ from .properties import set_parse_prop
25
26
 
26
27
  WIDGET_DOCUMENTS = {
27
28
  'progress-bar' : docs.ProgressBar,
@@ -51,28 +52,29 @@ WIDGET_DOCUMENTS = {
51
52
  }
52
53
 
53
54
  class GtkStreamXMLHandler(sax.ContentHandler):
54
- def __init__(self, logger, app):
55
- self.logger = logger
55
+ def __init__(self, app):
56
56
  self.app = app
57
+ self.logger = app.logger
58
+
57
59
  self.transition_enter = self.transE_conn
58
60
  self.transition_leave = self.transL_final
59
61
  self.transition_chars = self.ignore_chars
60
- self.namedWidgets = { }
61
- self.windows = { }
62
+
63
+ # Get all messages directly from the application
64
+ # class. This allows defining new messages without
65
+ # touching the parser
66
+ self.messages = {
67
+ f.__tag_name__: self.startMessage(functools.partial(f,self.app), f.__store__)
68
+ for f in self.app.__class__.__dict__.values()
69
+ if hasattr(f, '__tag_name__')
70
+ }
62
71
 
63
72
  def quit_application(self):
64
73
  def cb():
65
74
  self.logger.info("Quitting app")
66
75
  self.app.quit()
67
76
  GLib.idle_add(cb)
68
- self.logger.info("Waiting for app to terminate")
69
- self.app_thread.join()
70
- self.logger.info("App terminated")
71
- sys.exit(0)
72
77
 
73
- def setNamed(self, attrs, ):
74
- if 'id' in attrs:
75
- self.namedWidgets[attrs['id']] = widget
76
78
  def ignore_chars(self, s):
77
79
  pass
78
80
 
@@ -94,29 +96,7 @@ class GtkStreamXMLHandler(sax.ContentHandler):
94
96
  def transE_conn(self, name, attrs):
95
97
  match name:
96
98
  case 'application':
97
- def on_activate(a):
98
- a.hold()
99
- self.app.connect('activate', on_activate)
100
- def appMain():
101
- self.app.run([])
102
- self.app_thread = threading.Thread(target = appMain)
103
- self.app_thread.start()
104
-
105
- def on_sigint(a,b):
106
- self.logger.info("SIGINT received")
107
- self.quit_application()
108
- signal.signal(signal.SIGINT, on_sigint)
109
-
110
- # Get all messages directly from the application
111
- # class. This allows defining new messages without
112
- # touching the parser
113
- self.messages = {
114
- f.__tag_name__: self.startMessage(functools.partial(f,self.app), f.__store__)
115
- for f in self.app.__class__.__dict__.values()
116
- if hasattr(f, '__tag_name__')
117
- }
118
- self.logger.debug("Messages: %s", self.messages)
119
-
99
+ self.app.set_attrs(attrs)
120
100
  self.transition_enter = self.transE_message
121
101
  self.transition_leave = self.transL_tag('application', self.transE_final, self.transL_final)
122
102
  case _:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gtk-stream
3
- Version: 0.11.5
3
+ Version: 0.12
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/
File without changes
File without changes
File without changes
File without changes