gtk-stream 0.11.1__py3-none-any.whl → 0.11.3__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.1'
16
- __version_tuple__ = version_tuple = (0, 11, 1)
15
+ __version__ = version = '0.11.3'
16
+ __version_tuple__ = version_tuple = (0, 11, 3)
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,33 +14,74 @@
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
17
+ import argparse
21
18
 
22
- from .parser import GtkStreamXMLHandler
23
- from .common import Logger, LogLevel
24
- from . import GLib
19
+ def main():
20
+ parser = argparse.ArgumentParser(
21
+ prog='gtk-stream',
22
+ description='A stream-based GUI tool',
23
+ add_help=False
24
+ )
25
+ parser.add_argument('--list-icons', action='store_true')
26
+ parser.add_argument('--hook')
27
+ parser.add_argument('-h', '--help', action='store_true')
28
+ args = parser.parse_args()
25
29
 
26
- logLevel = LogLevel.__dict__.get(os.environ.get('GTK_STREAM_LOGLEVEL', 'WARN'), LogLevel.WARN)
30
+ if args.help:
31
+ parser.print_help()
27
32
 
28
- logger = Logger(logLevel)
33
+ elif args.list_icons:
34
+ from . import Gtk, Gdk
35
+ theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
36
+ for name in theme.get_icon_names():
37
+ print(name)
29
38
 
30
- class GtkStreamErrorHandler(sax.handler.ErrorHandler):
31
- def error(self, exc):
32
- raise exc
33
- def fatalError(self, exc):
34
- raise exc
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.recv() {
55
+ read -u "$GTK_STREAM_EVENTS" "$@"
56
+ }
57
+ ''')
58
+ else:
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
35
66
 
36
- def main():
37
- handler = GtkStreamXMLHandler(logger)
38
- errHandler = GtkStreamErrorHandler()
39
- parser = sax.make_parser()
40
- parser.setContentHandler(handler)
41
- parser.setErrorHandler(errHandler)
42
- try:
43
- parser.parse(io.FileIO(0, 'r', closefd=False))
44
- except Exception as e:
45
- logger.error("Done with exception : %s", e)
46
- handler.quit_application()
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)
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()
@@ -20,16 +20,15 @@ from .. import Document
20
20
 
21
21
  class Picture(Document):
22
22
  __g_class__ = Gtk.Picture
23
- def __init__(self, app, src, **kwargs):
23
+ def __init__(self, app, **kwargs):
24
24
  super().__init__(app, **kwargs)
25
- self.src = src
26
25
  def render_raw(self):
27
- return Gtk.Picture.new_for_filename(self.src)
26
+ return Gtk.Picture()
28
27
 
29
28
  class Icon(Document):
30
29
  __g_class__ = Gtk.Image
31
- def __init__(self, app, src, **kwargs):
30
+ def __init__(self, app, **kwargs):
32
31
  super().__init__(app, **kwargs)
33
- self.src = src
34
32
  def render_raw(self):
35
- return Gtk.Image.new_from_file(self.src)
33
+ return Gtk.Image()
34
+
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
@@ -16,7 +16,7 @@
16
16
 
17
17
  import sys
18
18
 
19
- from . import Gtk
19
+ from . import Gtk, Gio
20
20
 
21
21
  def _const(x):
22
22
  return lambda _: x
@@ -53,6 +53,16 @@ def _parse_widget_property(val):
53
53
  return lambda app: app.namedWidgets[val]
54
54
  def _parse_window_property(val):
55
55
  return lambda app: app.namedWindows[val]
56
+ def _parse_gfile_property(val):
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)
56
66
 
57
67
  _PARSE_TYPE_PROPERTY = {
58
68
  'GStrv' : _parse_css_classes_property,
@@ -66,6 +76,8 @@ _PARSE_TYPE_PROPERTY = {
66
76
  'GtkWindow' : _parse_window_property,
67
77
  'GtkAdjustment' : _parse_adjustment_property,
68
78
  'gchararray' : _const,
79
+ 'GFile' : _parse_gfile_property,
80
+ 'GtkAlign' : _parse_align_property,
69
81
  }
70
82
 
71
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.1
3
+ Version: 0.11.3
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=GfnRHfD9z98AbNAoXaNE50CPUnbpEikyDWn-_mn0J2Q,413
3
- gtk_stream/application.py,sha256=uFquTXCV0fbGlSURBmjrg9BK3Enf9N0_WKX6Lv-5Fko,4993
4
- gtk_stream/command_line.py,sha256=Ej4mmPiuYjr5-1JrvjGK0BDitKUCfVEI9uHp1p_FAr4,1520
2
+ gtk_stream/_version.py,sha256=OkAeaAqw1G6xdcg59fk8Mamyqb2RLX_cARtBOHOICIM,413
3
+ gtk_stream/application.py,sha256=Au4MngStEIKQdGnl-H6eGWDt923onqRDjW1mPFB9M8I,4911
4
+ gtk_stream/command_line.py,sha256=aagZJ6kyQxbIcx818jU8XPHddC68q7qtkJRNpk5IvJk,2833
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=Pgu59t3K-SkHXCZzkrk2DU8ODtjOhkZmf7dLqDYiDqc,3116
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
@@ -16,7 +16,7 @@ gtk_stream/documents/classes/Frame.py,sha256=zAZvsT-YTZMijsgk7p0YVf6siAmFoCCSXou
16
16
  gtk_stream/documents/classes/Grid.py,sha256=jDJ9U1GJZ45hi1VvPsCwFILN7CwEkgjqYqhTzMdtX9o,1249
17
17
  gtk_stream/documents/classes/Label.py,sha256=bBNBTvGs6fM8uLf4EDb2Ro8FmCeS27cnU1Ao-44nRYs,1023
18
18
  gtk_stream/documents/classes/Paned.py,sha256=q1goKJMWBg1d3hS0eanPBxzBqLB-Pz5hUnH9N-RXXh8,1392
19
- gtk_stream/documents/classes/Picture.py,sha256=QCLQNuQxfXmaasd-bPgXxJZYyc1e1DQkLdxCZ39gvlI,1251
19
+ gtk_stream/documents/classes/Picture.py,sha256=p84N1ntCHu47O84m48zC8uKFgso3-38yXpPlAjr4IKU,1153
20
20
  gtk_stream/documents/classes/ProgressBar.py,sha256=NPJtP3qaKiZUEAYEHZk4FEoWSFn2KVorI2SVb8cDnW0,966
21
21
  gtk_stream/documents/classes/Scale.py,sha256=6rW6sBCdpPaqgDEGUPZi5UR8CT3bPmaZQqXXhnl-oaw,1124
22
22
  gtk_stream/documents/classes/ScrolledWindow.py,sha256=WaTPgz6GBC-hjH83SQT2OGUdCapHAgO3xEmSMJZ8q70,1041
@@ -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.1.dist-info/METADATA,sha256=iwqbihyKY2PV24joIWUqAAt6D8npjUmm6T4GVOFCD4I,807
28
- gtk_stream-0.11.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
29
- gtk_stream-0.11.1.dist-info/entry_points.txt,sha256=PmhKTb4MMQM6dN2HJcoDSMI8L0lZIFIlFn-BgdfPDpo,60
30
- gtk_stream-0.11.1.dist-info/top_level.txt,sha256=vE9zfHGe9Ke7FSe0wBK2WYJI-BpcQNu6xDC3Cu5O8rQ,11
31
- gtk_stream-0.11.1.dist-info/RECORD,,
27
+ gtk_stream-0.11.3.dist-info/METADATA,sha256=KVLg05oiD8yi-hsNSWs9Zc_DNEZv6BOAwonyhImOYcs,807
28
+ gtk_stream-0.11.3.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
29
+ gtk_stream-0.11.3.dist-info/entry_points.txt,sha256=PmhKTb4MMQM6dN2HJcoDSMI8L0lZIFIlFn-BgdfPDpo,60
30
+ gtk_stream-0.11.3.dist-info/top_level.txt,sha256=vE9zfHGe9Ke7FSe0wBK2WYJI-BpcQNu6xDC3Cu5O8rQ,11
31
+ gtk_stream-0.11.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.7.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5