OSDN Git Service

全GUI化
authorNakajima <fl.kouhei@gmail.com>
Tue, 30 Apr 2019 05:04:29 +0000 (14:04 +0900)
committerNakajima <fl.kouhei@gmail.com>
Tue, 30 Apr 2019 05:04:29 +0000 (14:04 +0900)
usr/share/serene-setup-wizard/src/Interfaces.py
usr/share/serene-setup-wizard/src/serene-setup-wizard

index e49a2b2..d32ed9d 100755 (executable)
@@ -76,6 +76,10 @@ class CUI(Interface) :
 
 class Zenity(CUI) :
 
+    def __init__(self) :
+
+        self.item_list = None
+        
     def yesnoback(self, _strs) :
         
         str = ""
@@ -89,10 +93,53 @@ class Zenity(CUI) :
             str = _strs
 
         
-        ans = subprocess.call(["zenity", "--question", "--title=Serene Setup Wizard", "--text={}".format(str), "--width=300"])
+        ans = subprocess.call(["zenity", "--question", "--title=Serene Setup Wizard", "--text={}".format(str), "--width=300"], stderr=open("/dev/null", "w"))
 
         if ans == 0 :
             return True
         else :
             return False
 
+
+    def show(self, _str) :
+        
+        if self.item_list is None :
+
+            self.item_list = list()
+
+        self.item_list.append(_str)
+
+
+    def choose(self, _) :
+
+        str = ["zenity", "--list", "--title=Serene Setup Wizard", "--text", "Choose the item you want to change.", "--height=400", "--width=400", "--column", "No.", "--column", "Item", "--column", "Status", "--print-column=all"]
+        
+
+        for i, item in enumerate(self.item_list) :
+
+            str.append("{}".format(i+1))
+            str.append("{}".format(item[0]))
+            str.append("{}".format(item[1]))
+
+        self.item_list = None
+       
+        while True :
+
+            tmp = open("/tmp/serene-setup-wizard.tmp", "w")
+            ret = subprocess.call(str, stdout=tmp, stderr=open("/dev/null", "w"))
+            tmp.close()
+
+            if ret :
+                print("")
+                return False
+
+            tmp = open("/tmp/serene-setup-wizard.tmp", "r")
+            ans = tmp.readline().split("|")[0]
+            tmp.close()
+
+            if ans != "" :   
+                break
+        
+        print("")
+        return int(ans)
+
index ffd0410..b89e032 100755 (executable)
@@ -11,7 +11,7 @@ import Interfaces
 def show_help() :
     print("\n*****Serene Setup Wizard*****")
     print("  Options :")
-    print("    --command-mode -c : Don't use GUI\n")
+    print("    --command-mode -c : Not using GUI\n")
     sys.exit()
 
 
@@ -100,7 +100,9 @@ if not os.path.exists(PATH + "/../data/not_first_time") :
 
 else :
     
-    frag = False 
+    if interface.yesnoback("Do you want to run 'sudo apt update' ?"):
+
+        update()
 
     items = Items.getItems(interface)
 
@@ -115,10 +117,6 @@ else :
         
         if result :
 
-            if not frag :
-                update()
-                frag = True 
-
             items[result-1].change()
 
         else :