gtk-stream 0.11.2__py3-none-any.whl → 0.11.4__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
gtk_stream/_version.py CHANGED
@@ -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.2'
16
- __version_tuple__ = version_tuple = (0, 11, 2)
15
+ __version__ = version = '0.11.4'
16
+ __version_tuple__ = version_tuple = (0, 11, 4)
gtk_stream/application.py CHANGED
@@ -48,11 +48,9 @@ def style_store():
48
48
  return (lambda: " ".join(style),None, style.append)
49
49
 
50
50
  class GtkStreamApp(Gtk.Application):
51
- def __init__(self, logger, name = None, **kwargs):
51
+ def __init__(self, logger, **kwargs):
52
52
  super().__init__(**kwargs)
53
53
  self.logger = logger
54
- if name != None:
55
- GLib.set_application_name(name)
56
54
  self.namedWidgets = { }
57
55
  self.namedWindows = { }
58
56
 
@@ -14,26 +14,8 @@
14
14
  # You should have received a copy of the GNU General Public License
15
15
  # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
16
 
17
- import io
18
- import xml.sax as sax
19
- import sys
20
- import os
21
17
  import argparse
22
18
 
23
- from .parser import GtkStreamXMLHandler
24
- from .common import Logger, LogLevel
25
- from . import GLib, Gtk, Gdk
26
-
27
- logLevel = LogLevel.__dict__.get(os.environ.get('GTK_STREAM_LOGLEVEL', 'WARN'), LogLevel.WARN)
28
-
29
- logger = Logger(logLevel)
30
-
31
- class GtkStreamErrorHandler(sax.handler.ErrorHandler):
32
- def error(self, exc):
33
- raise exc
34
- def fatalError(self, exc):
35
- raise exc
36
-
37
19
  def main():
38
20
  parser = argparse.ArgumentParser(
39
21
  prog='gtk-stream',
@@ -41,17 +23,59 @@ def main():
41
23
  add_help=False
42
24
  )
43
25
  parser.add_argument('--list-icons', action='store_true')
26
+ parser.add_argument('--hook')
44
27
  parser.add_argument('-h', '--help', action='store_true')
45
28
  args = parser.parse_args()
46
29
 
47
30
  if args.help:
48
31
  parser.print_help()
32
+
49
33
  elif args.list_icons:
34
+ from . import Gtk, Gdk
50
35
  theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
51
36
  for name in theme.get_icon_names():
52
37
  print(name)
38
+
39
+ elif args.hook:
40
+ match args.hook:
41
+ case "bash":
42
+ print('''
43
+ coproc GTK_STREAM { exec gtk-stream; }
44
+ trap 'kill -INT "$GTK_STREAM_PID"; wait' EXIT
45
+ exec {GTK_STREAM_EVENTS}<&"${GTK_STREAM[0]}"
46
+ exec {GTK_STREAM_MESSAGES}>&"${GTK_STREAM[1]}"
47
+ function GTK.send() {
48
+ if (($# > 0)); then
49
+ printf "$@" >&"$GTK_STREAM_MESSAGES"
50
+ else
51
+ cat >&"$GTK_STREAM_MESSAGES"
52
+ fi
53
+ }
54
+ function GTK.receive() {
55
+ read -u "$GTK_STREAM_EVENTS" "$@"
56
+ }
57
+ ''')
53
58
  else:
54
- handler = GtkStreamXMLHandler(logger)
59
+ import io
60
+ import sys
61
+ import os
62
+ import xml.sax as sax
63
+ from .parser import GtkStreamXMLHandler
64
+ from .application import GtkStreamApp
65
+ from .common import Logger, LogLevel
66
+
67
+ class GtkStreamErrorHandler(sax.handler.ErrorHandler):
68
+ def error(self, exc):
69
+ raise exc
70
+ def fatalError(self, exc):
71
+ raise exc
72
+
73
+ logLevel = LogLevel.__dict__.get(os.environ.get('GTK_STREAM_LOGLEVEL', 'WARN'), LogLevel.WARN)
74
+
75
+ logger = Logger(logLevel)
76
+
77
+ app = GtkStreamApp(logger)
78
+ handler = GtkStreamXMLHandler(logger,app)
55
79
  errHandler = GtkStreamErrorHandler()
56
80
  parser = sax.make_parser()
57
81
  parser.setContentHandler(handler)
gtk_stream/parser.py CHANGED
@@ -23,8 +23,6 @@ import xml.sax as sax
23
23
  from . import GLib
24
24
  from . import documents as docs
25
25
 
26
- from .application import GtkStreamApp
27
-
28
26
  WIDGET_DOCUMENTS = {
29
27
  'progress-bar' : docs.ProgressBar,
30
28
  'label' : docs.Label,
@@ -53,8 +51,9 @@ WIDGET_DOCUMENTS = {
53
51
  }
54
52
 
55
53
  class GtkStreamXMLHandler(sax.ContentHandler):
56
- def __init__(self, logger):
54
+ def __init__(self, logger, app):
57
55
  self.logger = logger
56
+ self.app = app
58
57
  self.transition_enter = self.transE_conn
59
58
  self.transition_leave = self.transL_final
60
59
  self.transition_chars = self.ignore_chars
@@ -95,7 +94,6 @@ class GtkStreamXMLHandler(sax.ContentHandler):
95
94
  def transE_conn(self, name, attrs):
96
95
  match name:
97
96
  case 'application':
98
- self.app = GtkStreamApp(self.logger, **attrs)
99
97
  def on_activate(a):
100
98
  a.hold()
101
99
  self.app.connect('activate', on_activate)
@@ -114,7 +112,7 @@ class GtkStreamXMLHandler(sax.ContentHandler):
114
112
  # touching the parser
115
113
  self.messages = {
116
114
  f.__tag_name__: self.startMessage(functools.partial(f,self.app), f.__store__)
117
- for f in GtkStreamApp.__dict__.values()
115
+ for f in self.app.__class__.__dict__.values()
118
116
  if hasattr(f, '__tag_name__')
119
117
  }
120
118
  self.logger.debug("Messages: %s", self.messages)
gtk_stream/properties.py CHANGED
@@ -55,6 +55,14 @@ def _parse_window_property(val):
55
55
  return lambda app: app.namedWindows[val]
56
56
  def _parse_gfile_property(val):
57
57
  return _const(Gio.File.new_for_path(val))
58
+ def _parse_align_property(val):
59
+ match val:
60
+ case "start":
61
+ return _const(Gtk.Align.START)
62
+ case "center":
63
+ return _const(Gtk.Align.CENTER)
64
+ case "end":
65
+ return _const(Gtk.Align.END)
58
66
 
59
67
  _PARSE_TYPE_PROPERTY = {
60
68
  'GStrv' : _parse_css_classes_property,
@@ -69,6 +77,7 @@ _PARSE_TYPE_PROPERTY = {
69
77
  'GtkAdjustment' : _parse_adjustment_property,
70
78
  'gchararray' : _const,
71
79
  'GFile' : _parse_gfile_property,
80
+ 'GtkAlign' : _parse_align_property,
72
81
  }
73
82
 
74
83
  def parse_property(prop_type, val):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gtk-stream
3
- Version: 0.11.2
3
+ Version: 0.11.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://coiffier.net/projects/gtk-stream/
@@ -1,10 +1,10 @@
1
1
  gtk_stream/__init__.py,sha256=y6JLknVFexWrSo_Zl7-TXrPR6EQ5XVMeFO1bUzLN9Lg,98
2
- gtk_stream/_version.py,sha256=v52WNNFq-_uq9OSfK9O7vLpi66zlufcyohjNPzWbpdk,413
3
- gtk_stream/application.py,sha256=uFquTXCV0fbGlSURBmjrg9BK3Enf9N0_WKX6Lv-5Fko,4993
4
- gtk_stream/command_line.py,sha256=NdfJ1WTG-NmbW_CGaLCuiEK2SB8jhV-7GVsOW6e-ooI,2104
2
+ gtk_stream/_version.py,sha256=Y8H6O5UbMXMwQ2kw8OHf7YgQortJ0vzoBtMUiJYly1M,413
3
+ gtk_stream/application.py,sha256=Au4MngStEIKQdGnl-H6eGWDt923onqRDjW1mPFB9M8I,4911
4
+ gtk_stream/command_line.py,sha256=ArasvzpzJcWgYS9DdrC3sdq9gp3qrf010mPjn0h9hDo,2836
5
5
  gtk_stream/common.py,sha256=xdscxYgBg_Ux6iyk26gB-AMSgoUIqlZUPgso5YS_gKE,2106
6
- gtk_stream/parser.py,sha256=LOCGoTT_L5Qf29YJ2wFfTYLHtH0al-QjpFWf9HEHYxU,6561
7
- gtk_stream/properties.py,sha256=wrKtpyN76BEdm394wBl2A5ssT7Slov-RMf72aREuryk,3255
6
+ gtk_stream/parser.py,sha256=kyZtHxB4yz_gr0kc6akBMZfFouHZP6XnXF0BZzO_adA,6494
7
+ gtk_stream/properties.py,sha256=RjdRgKUSldIK4Nsij8leBANJicf6oP-Nr53tYI4uEE8,3551
8
8
  gtk_stream/documents/__init__.py,sha256=T9mIonSi9DWrpXQzbjq0s0TPU0hB7HylfhMA20OfWIg,831
9
9
  gtk_stream/documents/classes/Box.py,sha256=d01o2-JQ3-k0VjvvY8E7mly-u_f1v1NqYz1IDjHZLUo,1381
10
10
  gtk_stream/documents/classes/Button.py,sha256=21bVI7DUWmiusboxdsimTgcqKtLqzQydhS9ifIt4R64,1512
@@ -24,8 +24,8 @@ gtk_stream/documents/classes/Separator.py,sha256=uw_EgAKs_6pNA8nrOLzruIlJfk4uaog
24
24
  gtk_stream/documents/classes/Stack.py,sha256=YA6NDzZL2u4Ko8GXtx8Or-jEWGMCEw2cC1HNkAMRw-8,1030
25
25
  gtk_stream/documents/classes/Switch.py,sha256=jQVuxqS9Pmpp1ymB_dbJPxasJNpm4e35ry0JYPHdAsk,1275
26
26
  gtk_stream/documents/classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
- gtk_stream-0.11.2.dist-info/METADATA,sha256=Naho27fPS6mB7yEnEr09ECYKoNXL9G91tzSfxtTLHUo,807
28
- gtk_stream-0.11.2.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
29
- gtk_stream-0.11.2.dist-info/entry_points.txt,sha256=PmhKTb4MMQM6dN2HJcoDSMI8L0lZIFIlFn-BgdfPDpo,60
30
- gtk_stream-0.11.2.dist-info/top_level.txt,sha256=vE9zfHGe9Ke7FSe0wBK2WYJI-BpcQNu6xDC3Cu5O8rQ,11
31
- gtk_stream-0.11.2.dist-info/RECORD,,
27
+ gtk_stream-0.11.4.dist-info/METADATA,sha256=FwF8RwvflMhGtAK1rNBukVXsk3HgQRwCvGLQZqrNr84,807
28
+ gtk_stream-0.11.4.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
29
+ gtk_stream-0.11.4.dist-info/entry_points.txt,sha256=PmhKTb4MMQM6dN2HJcoDSMI8L0lZIFIlFn-BgdfPDpo,60
30
+ gtk_stream-0.11.4.dist-info/top_level.txt,sha256=vE9zfHGe9Ke7FSe0wBK2WYJI-BpcQNu6xDC3Cu5O8rQ,11
31
+ gtk_stream-0.11.4.dist-info/RECORD,,