gtk-stream 0.11.6__tar.gz → 0.13__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.6 → gtk_stream-0.13}/PKG-INFO +1 -1
  2. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/_version.py +2 -2
  3. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/application.py +31 -11
  4. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/command_line.py +23 -10
  5. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/__init__.py +1 -1
  6. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Box.py +1 -1
  7. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Document.py +1 -1
  8. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Stack.py +19 -1
  9. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/parser.py +16 -39
  10. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/properties.py +1 -0
  11. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream.egg-info/PKG-INFO +1 -1
  12. {gtk_stream-0.11.6 → gtk_stream-0.13}/README.md +0 -0
  13. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk-stream +0 -0
  14. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/__init__.py +0 -0
  15. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/common.py +0 -0
  16. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Button.py +0 -0
  17. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Dropdown.py +0 -0
  18. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Entry.py +0 -0
  19. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/FlowBox.py +0 -0
  20. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Frame.py +0 -0
  21. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Grid.py +0 -0
  22. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Label.py +0 -0
  23. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Paned.py +0 -0
  24. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Picture.py +0 -0
  25. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/ProgressBar.py +0 -0
  26. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Scale.py +0 -0
  27. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/ScrolledWindow.py +0 -0
  28. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Separator.py +0 -0
  29. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/Switch.py +0 -0
  30. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream/documents/classes/__init__.py +0 -0
  31. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream.egg-info/SOURCES.txt +0 -0
  32. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream.egg-info/dependency_links.txt +0 -0
  33. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream.egg-info/entry_points.txt +0 -0
  34. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream.egg-info/requires.txt +0 -0
  35. {gtk_stream-0.11.6 → gtk_stream-0.13}/gtk_stream.egg-info/top_level.txt +0 -0
  36. {gtk_stream-0.11.6 → gtk_stream-0.13}/pyproject.toml +0 -0
  37. {gtk_stream-0.11.6 → gtk_stream-0.13}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gtk-stream
3
- Version: 0.11.6
3
+ Version: 0.13
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.6'
16
- __version_tuple__ = version_tuple = (0, 11, 6)
15
+ __version__ = version = '0.13'
16
+ __version_tuple__ = version_tuple = (0, 13)
@@ -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()
@@ -17,4 +17,4 @@ from .classes.ScrolledWindow import ScrolledWindow
17
17
  from .classes.Paned import Paned
18
18
  from .classes.Frame import Frame, FrameLabel
19
19
  from .classes.Grid import Grid, Cell
20
- from .classes.Stack import Stack
20
+ from .classes.Stack import Stack, StackSidebar, StackPage
@@ -31,7 +31,7 @@ class Box(Document):
31
31
  def insert_child(self, w, d):
32
32
  if isinstance(d, BoxPrepend):
33
33
  if d.after != None:
34
- w.insert_child_after(d.render(), self.app.namedWidgets[d.after])
34
+ w.insert_child_after(d.render(), self.app.named_widgets[d.after])
35
35
  else:
36
36
  w.prepend(d.render())
37
37
  else:
@@ -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__)
@@ -17,6 +17,20 @@
17
17
  from ... import Gtk
18
18
  from .. import Document, PseudoDocument
19
19
 
20
+ class StackSidebar(Document):
21
+ __g_class__ = Gtk.StackSidebar
22
+ def __init__(self, app, **kwargs):
23
+ super().__init__(app, **kwargs)
24
+ def render_raw(self):
25
+ return Gtk.StackSidebar()
26
+
27
+ class StackPage(PseudoDocument):
28
+ def __init__(self, app, title):
29
+ super().__init__(app)
30
+ self.title = title
31
+ def set_page_props(self, page):
32
+ page.set_title(self.title)
33
+
20
34
  class Stack(Document):
21
35
  __g_class__ = Gtk.Stack
22
36
  def __init__(self, app, **kwargs):
@@ -24,4 +38,8 @@ class Stack(Document):
24
38
  def render_raw(self):
25
39
  return Gtk.Stack()
26
40
  def insert_child(self, w, d):
27
- w.add_child(d.render())
41
+ child = d.render()
42
+ w.add_child(child)
43
+ if isinstance(d, StackPage):
44
+ page = w.get_page(child)
45
+ d.set_page_props(page)
@@ -47,33 +47,35 @@ WIDGET_DOCUMENTS = {
47
47
  'flow-box' : docs.FlowBox,
48
48
  'flow-box-prepend': docs.FlowBoxPrepend,
49
49
  'entry' : docs.Entry,
50
- 'scale' : docs.Scale
51
-
50
+ 'scale' : docs.Scale,
51
+ 'stack-side-bar' : docs.StackSidebar,
52
+ 'stack-page' : docs.StackPage,
52
53
  }
53
54
 
54
55
  class GtkStreamXMLHandler(sax.ContentHandler):
55
- def __init__(self, logger, app):
56
- self.logger = logger
56
+ def __init__(self, app):
57
57
  self.app = app
58
+ self.logger = app.logger
59
+
58
60
  self.transition_enter = self.transE_conn
59
61
  self.transition_leave = self.transL_final
60
62
  self.transition_chars = self.ignore_chars
61
- self.namedWidgets = { }
62
- self.windows = { }
63
+
64
+ # Get all messages directly from the application
65
+ # class. This allows defining new messages without
66
+ # touching the parser
67
+ self.messages = {
68
+ f.__tag_name__: self.startMessage(functools.partial(f,self.app), f.__store__)
69
+ for f in self.app.__class__.__dict__.values()
70
+ if hasattr(f, '__tag_name__')
71
+ }
63
72
 
64
73
  def quit_application(self):
65
74
  def cb():
66
75
  self.logger.info("Quitting app")
67
76
  self.app.quit()
68
77
  GLib.idle_add(cb)
69
- self.logger.info("Waiting for app to terminate")
70
- self.app_thread.join()
71
- self.logger.info("App terminated")
72
- sys.exit(0)
73
78
 
74
- def setNamed(self, attrs, ):
75
- if 'id' in attrs:
76
- self.namedWidgets[attrs['id']] = widget
77
79
  def ignore_chars(self, s):
78
80
  pass
79
81
 
@@ -95,32 +97,7 @@ class GtkStreamXMLHandler(sax.ContentHandler):
95
97
  def transE_conn(self, name, attrs):
96
98
  match name:
97
99
  case 'application':
98
- for name, val in attrs.items():
99
- set_parse_prop(self.app, self.app, name, val)
100
-
101
- def on_activate(a):
102
- a.hold()
103
- self.app.connect('activate', on_activate)
104
- def appMain():
105
- self.app.run([])
106
- self.app_thread = threading.Thread(target = appMain)
107
- self.app_thread.start()
108
-
109
- def on_sigint(a,b):
110
- self.logger.info("SIGINT received")
111
- self.quit_application()
112
- signal.signal(signal.SIGINT, on_sigint)
113
-
114
- # Get all messages directly from the application
115
- # class. This allows defining new messages without
116
- # touching the parser
117
- self.messages = {
118
- f.__tag_name__: self.startMessage(functools.partial(f,self.app), f.__store__)
119
- for f in self.app.__class__.__dict__.values()
120
- if hasattr(f, '__tag_name__')
121
- }
122
- self.logger.debug("Messages: %s", self.messages)
123
-
100
+ self.app.set_attrs(attrs)
124
101
  self.transition_enter = self.transE_message
125
102
  self.transition_leave = self.transL_tag('application', self.transE_final, self.transL_final)
126
103
  case _:
@@ -73,6 +73,7 @@ _PARSE_TYPE_PROPERTY = {
73
73
  'gboolean' : _parse_boolean_property,
74
74
  'GtkStringFilterMatchMode' : _parse_searchMode_property,
75
75
  'GtkWidget' : _parse_widget_property,
76
+ 'GtkStack' : _parse_widget_property,
76
77
  'GtkWindow' : _parse_window_property,
77
78
  'GtkAdjustment' : _parse_adjustment_property,
78
79
  'gchararray' : _const,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gtk-stream
3
- Version: 0.11.6
3
+ Version: 0.13
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