gtk-stream 0.14.2__py3-none-any.whl → 0.15.1__py3-none-any.whl

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.
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.14.2'
16
- __version_tuple__ = version_tuple = (0, 14, 2)
15
+ __version__ = version = '0.15.1'
16
+ __version_tuple__ = version_tuple = (0, 15, 1)
gtk_stream/application.py CHANGED
@@ -98,19 +98,52 @@ class GtkStreamApp(Gtk.Application):
98
98
  self.attrs_set.release()
99
99
 
100
100
  @app_message('file-dialog')
101
- def open_file_dialog(self, id, parent):
102
- dialog = Gtk.FileDialog()
103
- dialog.props.modal = True
104
- def on_choose(_, b):
105
- try:
106
- file = dialog.open_finish(b)
107
- print(f"{id}:selected:{file.get_path()}")
108
- sys.stdout.flush()
109
- except GLib.GError as e:
110
- print(f"{id}:none-selected")
111
- sys.stdout.flush()
112
-
113
- dialog.open(parent = self.named_windows[parent], callback = on_choose)
101
+ def open_file_dialog(self, id, parent, action = "open"):
102
+ parent_window = self.named_windows[parent]
103
+ if Gtk.MINOR_VERSION >= 10:
104
+ # From version 4.10, use FileDialog
105
+ dialog = Gtk.FileDialog()
106
+ dialog.props.modal = True
107
+ match action:
108
+ case 'open':
109
+ open_func = dialog.open
110
+ finish_func = dialog.open_finish
111
+ case 'save':
112
+ open_func = dialog.save
113
+ finish_func = dialog.save_finish
114
+
115
+ def on_choose(_, b):
116
+ try:
117
+ file = finish_func(b)
118
+ print(f"{id}:selected:{file.get_path()}")
119
+ sys.stdout.flush()
120
+ except GLib.GError as e:
121
+ print(f"{id}:none-selected")
122
+ sys.stdout.flush()
123
+
124
+ open_func(parent = parent_window, callback = on_choose)
125
+
126
+ else:
127
+ # Before version 4.10, use FileChooserDialog
128
+ match action:
129
+ case 'open':
130
+ fc_action = Gtk.FileChooserAction.OPEN
131
+ fc_label = "Open"
132
+ case 'save':
133
+ fc_action = Gtk.FileChooserAction.SAVE
134
+ fc_label = "Save"
135
+ dialog = Gtk.FileChooserDialog.new("Choose a file", parent_window, fc_action, fc_label, Gtk.ResponseType.ACCEPT)
136
+ dialog.props.modal = True
137
+ def on_choose(_, b):
138
+ try:
139
+ file = dialog.get_file()
140
+ print(f"{id}:selected:{file.get_path()}")
141
+ sys.stdout.flush()
142
+ except GLib.GError as e:
143
+ print(f"{id}:none-selected")
144
+ sys.stdout.flush()
145
+ dialog.connect("response", on_choose)
146
+ dialog.present()
114
147
 
115
148
  @app_message('window', single_store)
116
149
  def new_window(self, document, id, **attrs):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: gtk-stream
3
- Version: 0.14.2
3
+ Version: 0.15.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/
@@ -1,6 +1,6 @@
1
1
  gtk_stream/__init__.py,sha256=y6JLknVFexWrSo_Zl7-TXrPR6EQ5XVMeFO1bUzLN9Lg,98
2
- gtk_stream/_version.py,sha256=rlRT2sdhOGuXEsCM8RZA3pLtxwYV_87Qc0n3HT-mx2U,413
3
- gtk_stream/application.py,sha256=1C0AsqemyV2VX_z7C7PWH6eYlQ0Q5jo7PAFjolaO0HM,5562
2
+ gtk_stream/_version.py,sha256=po5_rvCFTU8xU9IC56wyK0-zfBgz_U4xX6CO2mv9Mzs,413
3
+ gtk_stream/application.py,sha256=Tf5kbpHmsZ_rnFFklLtCGBul7HoHiXe0398wExP3q_M,6944
4
4
  gtk_stream/command_line.py,sha256=57slfbV-EUWVI8bsA50IzmCLqNjN9aZpz8J8Gtituro,3105
5
5
  gtk_stream/common.py,sha256=2USRh42DmmxtPO1y8gpeU0hMuHfhcqJBPuxtvd46YHg,2112
6
6
  gtk_stream/parser.py,sha256=lt1cHYwhrd0SwSQfbxtbK6NdwbnFmgeBDIeNY0eepwc,5709
@@ -24,8 +24,8 @@ gtk_stream/documents/classes/Separator.py,sha256=uw_EgAKs_6pNA8nrOLzruIlJfk4uaog
24
24
  gtk_stream/documents/classes/Stack.py,sha256=diZyuBLwuCjn_WE3wx5MBgHN_ty6WXSsyIFRVAbe8yI,1572
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.14.2.dist-info/METADATA,sha256=h4Hb6ESz4eBopKXwEG7XYaR5v5CHUP-sJ3__HXL3xcc,807
28
- gtk_stream-0.14.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
29
- gtk_stream-0.14.2.dist-info/entry_points.txt,sha256=PmhKTb4MMQM6dN2HJcoDSMI8L0lZIFIlFn-BgdfPDpo,60
30
- gtk_stream-0.14.2.dist-info/top_level.txt,sha256=vE9zfHGe9Ke7FSe0wBK2WYJI-BpcQNu6xDC3Cu5O8rQ,11
31
- gtk_stream-0.14.2.dist-info/RECORD,,
27
+ gtk_stream-0.15.1.dist-info/METADATA,sha256=KFQPdW6O5As9qAmoagWL8NkZHzE03a9zStuS1_e7Hps,807
28
+ gtk_stream-0.15.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
29
+ gtk_stream-0.15.1.dist-info/entry_points.txt,sha256=PmhKTb4MMQM6dN2HJcoDSMI8L0lZIFIlFn-BgdfPDpo,60
30
+ gtk_stream-0.15.1.dist-info/top_level.txt,sha256=vE9zfHGe9Ke7FSe0wBK2WYJI-BpcQNu6xDC3Cu5O8rQ,11
31
+ gtk_stream-0.15.1.dist-info/RECORD,,