Bläddra i källkod

Do not strictly depend on kdialog

Use QInputDialog where possible, fallback to zenity where not.
Marek Marczykowski 11 år sedan
förälder
incheckning
73598b0344
3 ändrade filer med 24 tillägg och 19 borttagningar
  1. 15 17
      qubesmanager/main.py
  2. 8 1
      qubesmanager/mount_for_backup.sh
  3. 1 1
      rpm_spec/qmgr.spec

+ 15 - 17
qubesmanager/main.py

@@ -1264,14 +1264,13 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
         while self.qvm_collection.get_vm_by_name(name_format % name_number):
             name_number += 1
 
-        cmd = ['kdialog', '--title', 'Qubes clone VM', '--inputbox', 'Enter name for VM <b>'+vm.name+'</b> clone:', name_format % name_number]
-        kdialog = subprocess.Popen(cmd, stdout = subprocess.PIPE)
-        clone_name = kdialog.stdout.read().strip()
-        if clone_name == "":
+        (clone_name, ok) = QInputDialog.getText(self, 'Qubes clone VM',
+                'Enter name for VM <b>'+vm.name+'</b> clone:', text=name_format % name_number)
+        if not ok or clone_name == "":
             return
 
         thread_monitor = ThreadMonitor()
-        thread = threading.Thread (target=self.do_clone_vm, args=(vm, clone_name, thread_monitor))
+        thread = threading.Thread (target=self.do_clone_vm, args=(vm, str(clone_name), thread_monitor))
         thread.daemon = True
         thread.start()
 
@@ -1496,8 +1495,12 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
     def action_run_command_in_vm_triggered(self):
         vm = self.get_selected_vm()
 
+        (command_to_run, ok) = QInputDialog.getText(self, 'Qubes command entry',
+                'Run command in <b>'+vm.name+'</b>:')
+        if not ok or command_to_run == "":
+            return
         thread_monitor = ThreadMonitor()
-        thread = threading.Thread (target=self.do_run_command_in_vm, args=(vm, thread_monitor))
+        thread = threading.Thread (target=self.do_run_command_in_vm, args=(vm, str(command_to_run), thread_monitor))
         thread.daemon = True
         thread.start()
 
@@ -1509,17 +1512,12 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
             QMessageBox.warning (None, "Error while running command", "Exception while running command:<br>{0}".format(thread_monitor.error_msg))
 
 
-    def do_run_command_in_vm(self, vm, thread_monitor):
-        cmd = ['kdialog', '--title', 'Qubes command entry', '--inputbox', 'Run command in <b>'+vm.name+'</b>:']
-        kdialog = subprocess.Popen(cmd, stdout = subprocess.PIPE)
-        command_to_run = kdialog.stdout.read()
-        command_to_run = command_to_run.strip()
-        if command_to_run != "":
-            try:
-                vm.run(command_to_run, verbose=False, autostart=True,
-                        notify_function=lambda lvl, msg: trayIcon.showMessage(msg, msecs=3000) )
-            except Exception as ex:
-                thread_monitor.set_error_msg(str(ex))
+    def do_run_command_in_vm(self, vm, command_to_run, thread_monitor):
+        try:
+            vm.run(command_to_run, verbose=False, autostart=True,
+                    notify_function=lambda lvl, msg: trayIcon.showMessage(msg, msecs=3000) )
+        except Exception as ex:
+            thread_monitor.set_error_msg(str(ex))
         thread_monitor.set_finished()
 
     @pyqtSlot(name='on_action_set_keyboard_layout_triggered')

+ 8 - 1
qubesmanager/mount_for_backup.sh

@@ -9,10 +9,17 @@ if [ ! -e $1 ]; then
     exit 1; #no such path
 fi
 
+if type kdialog &> /dev/null; then
+    PROMPT="kdialog --title Qubes --password"
+else
+    PROMPT="zenity --entry --title Qubes --hide-text --text"
+fi
+
+
 #check if luks-encrypted
 if sudo cryptsetup isLuks $1 ; then
     # Is a luks device
-    if ! kdialog --password "Please unlock the LUKS-encrypted $1 device:" | sudo pmount $1 $2 ; then
+    if ! $PROMPT "Please unlock the LUKS-encrypted $1 device:" | sudo pmount $1 $2 ; then
         exit 1;
     fi
 else

+ 1 - 1
rpm_spec/qmgr.spec

@@ -11,7 +11,7 @@ Group:		Qubes
 Vendor:		Invisible Things Lab
 License:	GPL
 URL:		http://fixme
-Requires:	python, PyQt4, qubes-core-dom0 > 1.7.23, kdebase
+Requires:	python, PyQt4, qubes-core-dom0 > 1.7.23
 Requires:	pmount, cryptsetup, wmctrl
 Requires:	dbus
 BuildRequires:	PyQt4-devel