-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
42 lines (35 loc) · 1.65 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import gi, json
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
settingEditor_command = ""
def loadSetings(ui):
settingsData = json.loads(open("settings.json", "r").read())
ui.get_object("settingDirLabel").set_text(settingsData["settingDir"])
ui.get_object("settingEditorLabel").set_text(settingsData["settingEditor"]["name"])
def saveSettings(ui):
settingsData = json.loads(open("settings.json", "r").read())
settingsData["settingDir"] = ui.get_object("settingDirLabel").get_text()
settingsData["settingEditor"]["name"] = ui.get_object("settingEditorLabel").get_text()
settingsData["settingEditor"]["command"] = settingEditor_command
json.dump(settingsData, open("settings.json", "w"), indent=4)
def getSettings():
settingsData = json.loads(open("settings.json", "r").read())
return settingsData
def settingDir(parent, output):
dialog = Gtk.FileChooserDialog(
title="Please choose a location", parent=parent, action=Gtk.FileChooserAction.SELECT_FOLDER)
dialog.add_buttons(
Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, "Select", Gtk.ResponseType.OK)
response = dialog.run()
if response == Gtk.ResponseType.OK:
output.set_text(dialog.get_filename())
dialog.destroy()
def settingEditor(parent, output):
global settingEditor_command
dialog = Gtk.AppChooserDialog(
title="Please choose default text editor", parent=parent, content_type="text/plain")
response = dialog.run()
if response == Gtk.ResponseType.OK:
output.set_text(dialog.get_app_info().get_display_name())
settingEditor_command = dialog.get_app_info().get_commandline()
dialog.destroy()