@@ -201,29 +201,48 @@ def on_module_selected(self):
201201 tooltip_text = _ ("No personal information included" ),
202202 always_show_image = True ,
203203 image = spinner )
204- button .connect ("clicked" , self .on_button_clicked , spinner )
204+ button .connect ("clicked" , self .on_upload_button_clicked , spinner )
205205 widget .pack_start (button , True , True , 0 )
206206 settings .add_row (widget )
207207
208208 if shutil .which ("inxi" ):
209209 widget = SettingsWidget ()
210210
211- button = Gtk .Button (label = _ ("Copy to clipboard" ))
212- button .connect ("clicked" , self .on_copy_clipboard_button_clicked )
211+ spinner = Gtk .Spinner (visible = True )
212+ button = Gtk .Button (label = _ ("Copy to clipboard" ),
213+ always_show_image = True ,
214+ image = spinner )
215+ button .connect ("clicked" , self .on_copy_clipboard_button_clicked , spinner )
213216 widget .pack_start (button , True , True , 0 )
214217 settings .add_row (widget )
215218
216- def on_copy_clipboard_button_clicked (self , button ):
217- try :
218- inxiOutput = subprocess .run (['inxi' , '-Fxxrzc0' ], check = True , stdout = subprocess .PIPE ).stdout
219- clipboard = Gtk .Clipboard .get (Gdk .SELECTION_CLIPBOARD )
220- clipboard .set_text (inxiOutput .decode ("utf-8" ), - 1 )
221- except Exception as e :
222- print ("An error occurred while copying the system information to clipboard" )
223- print (e )
219+ def on_copy_clipboard_button_clicked (self , button , spinner ):
220+ spinner .start ()
221+
222+ def finished_inxi (output ):
223+ spinner .stop ()
224+
225+ if output is None :
226+ return
227+
228+ clipboard = Gtk .Clipboard .get (Gdk .SELECTION_CLIPBOARD )
229+ clipboard .set_text (output .decode ("utf-8" ), - 1 )
230+
231+ def _run_inxi (spinner ):
232+ inxiOutput = None
233+
234+ try :
235+ inxiOutput = subprocess .run (['inxi' , '-Fxxrzc0' ], check = True , stdout = subprocess .PIPE ).stdout
236+ except Exception as e :
237+ print ("An error occurred while copying the system information to clipboard" )
238+ print (e )
239+
240+ GLib .idle_add (finished_inxi , inxiOutput )
224241
225- def on_button_clicked (self , button , spinner ):
242+ inxi_thread = threading .Thread (target = _run_inxi , args = (spinner ,))
243+ inxi_thread .start ()
226244
245+ def on_upload_button_clicked (self , button , spinner ):
227246 try :
228247 subproc = Gio .Subprocess .new (["upload-system-info" ], Gio .SubprocessFlags .NONE )
229248 subproc .wait_check_async (None , self .on_subprocess_complete , spinner )
0 commit comments