Merge ~daniel-kaluza-dk/dpcs:settingsPanel into dpcs:master

Proposed by Daniel Kałuża
Status: Rejected
Rejected by: Marek Bardoński
Proposed branch: ~daniel-kaluza-dk/dpcs:settingsPanel
Merge into: dpcs:master
Diff against target: 163 lines (+145/-1)
3 files modified
client/settings/panel.py (+138/-0)
client/settings/panelEvoker.py (+6/-0)
client/settings/readme.md (+1/-1)
Reviewer Review Type Date Requested Status
Mateusz Susik Needs Information
Dzjkb (community) Abstain
Marek Bardoński static Needs Fixing
Mateusz Susik Pending
Review via email: mp+288181@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Marek Bardoński (bdfhjk) wrote :

There are no changes inside.

review: Needs Fixing (static)
Revision history for this message
Dzjkb (jakub-pies) :
review: Abstain
~daniel-kaluza-dk/dpcs:settingsPanel updated
a844da3... by Daniel Kałuża

Panel v 1.0

1c529f8... by Daniel Kałuża

Panel v 1.1

Revision history for this message
Mateusz Susik (mateuszsusik) wrote :

IOError: [Errno 13] Brak dostępu: '/etc/dpcs.conf'

Po wciśnięciu OK. Jeśli ustawienia będą wymagać sudo, to należy je zaimplementować tak, aby były wymagane przy uruchamianiu - w podobny sposób jak działają np. menadżery pakietów.

review: Needs Information
~daniel-kaluza-dk/dpcs:settingsPanel updated
0ea1b7e... by Daniel Kałuża

Panel v1.2 with evoker.

b19324e... by Daniel Kałuża

remove settingsPanel.py

Revision history for this message
Mateusz Susik (mateuszsusik) wrote :

1). The settings file is uncleae - I see only ones and zeros after opening it with a text editor and I don't know whoch value corresponds to which option. If you don't want to spend time on parsing, use JSON format.

2). panelEvoker should have if __name__ == "__main__"

3). panelEvoker introduces additional requirement: superuser must have access to Python. On some computers Python is not available and it should be possible to change settings without global python installation. You should be able to implement a solution where you ask the user for a password and then use it for handling the file.

Revision history for this message
Mateusz Susik (mateuszsusik) wrote :

If you don't want to implement a solution for sudo, a user-wise configuration should be good as well.

Please move to our github repo, and take https://github.com/bdfhjk/DPCS/issues/5

Revision history for this message
Daniel Kałuża (daniel-kaluza-dk) wrote :

We will manage with sudo solution and handling the file, I hope I will push
the new solution later today

2016-03-09 20:49 GMT+01:00 Mateusz Susik <email address hidden>:

> If you don't want to implement a solution for sudo, a user-wise
> configuration should be good as well.
>
> Please move to our github repo, and take
> https://github.com/bdfhjk/DPCS/issues/5
> --
> https://code.launchpad.net/~daniel-kaluza-dk/dpcs/+git/dpcs/+merge/288181
> You are the owner of ~daniel-kaluza-dk/dpcs:settingsPanel.
>

Unmerged commits

b19324e... by Daniel Kałuża

remove settingsPanel.py

0ea1b7e... by Daniel Kałuża

Panel v1.2 with evoker.

1c529f8... by Daniel Kałuża

Panel v 1.1

a844da3... by Daniel Kałuża

Panel v 1.0

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/client/settings/panel.py b/client/settings/panel.py
2new file mode 100644
3index 0000000..243dbd5
4--- /dev/null
5+++ b/client/settings/panel.py
6@@ -0,0 +1,138 @@
7+#coding: utf-8
8+
9+import gi
10+gi.require_version('Gtk', '3.0')
11+from gi.repository import Gtk
12+import os.path
13+import subprocess
14+
15+# the window title
16+PANELTITLE = "DPCS Settings"
17+
18+# about DPCS - authors, basic info, licensing and such...
19+ABOUT_DPCS = """ To be written!
20+"""
21+
22+# minimal window width and height
23+WIDTH = 350
24+HEIGHT = 400
25+# list with the settings
26+settings = []
27+#config file path
28+FILE = '/etc/dpcs.conf'
29+
30+def displaypanel():
31+ """ displays the prefs dialog
32+ """
33+ win = SettingsPanel()
34+ win.show_all()
35+ Gtk.main()
36+
37+def addCheckButton(label, parent):
38+ """ add checkbox with label @label to container @parent
39+ """
40+ checkButton = Gtk.CheckButton.new_with_label(label)
41+ parent.pack_start(checkButton, False, False, 10)
42+ settings.append(checkButton)
43+ return checkButton
44+
45+def save_setting (checkButton, file_ptr):
46+ """ saves checkbox value as new line to @file_ptr
47+ """
48+ if checkButton.get_active():
49+ value = '1'
50+ else:
51+ value = '0'
52+ value = str( value + '\n')
53+ file_ptr.write(value)
54+def load_setting (checkButton, line):
55+ """ loads initial value of @checkbutton from @line in config
56+ """
57+ if line == '1\n' :
58+ checkButton.set_active(True)
59+ else:
60+ checkButton.set_active(False)
61+
62+class SettingsPanel(Gtk.Window):
63+ """ The preferences dialog for DPCS
64+ """
65+
66+ def __init__(self):
67+ Gtk.Window.__init__(self, title=PANELTITLE)
68+ self.set_size_request(WIDTH,HEIGHT)
69+
70+ maincontainer = Gtk.Box(orientation = Gtk.Orientation.VERTICAL, spacing = 0)
71+ self.add(maincontainer)
72+
73+ notebook = Gtk.Notebook()
74+ maincontainer.pack_start(notebook, True, True, 0)
75+
76+ buttonscontainer = Gtk.Box(orientation = Gtk.Orientation.HORIZONTAL)
77+ maincontainer.pack_start(buttonscontainer, False, False, 0)
78+
79+ # settings tab
80+
81+ settingspage = Gtk.Box(orientation = Gtk.Orientation.VERTICAL, spacing = 5)
82+
83+ # add setting boxes here by addCheckButton(Label, Box)
84+
85+ eb = addCheckButton('Enable DPCS', settingspage)
86+ ab = addCheckButton('test1', settingspage)
87+ bb = addCheckButton('test2', settingspage)
88+ gb = addCheckButton('test3', settingspage)
89+
90+ # end of setting boxes
91+
92+ notebook.append_page(settingspage, Gtk.Label('Settings'))
93+
94+ # about DPCS tab
95+
96+ aboutpage = Gtk.Box(orientation = Gtk.Orientation.VERTICAL, spacing = 5)
97+
98+ acontent = Gtk.Label()
99+ acontent.set_text(ABOUT_DPCS)
100+ acontent.set_justify(Gtk.Justification.LEFT)
101+ aboutpage.pack_start(acontent, True, True, 0)
102+
103+ notebook.append_page(aboutpage, Gtk.Label('About DPCS'))
104+
105+ # ok, apply and cancel buttons
106+
107+ self.ok = Gtk.Button(label="Ok")
108+ cancel = Gtk.Button(label="Cancel")
109+ applyb = Gtk.Button(label="Apply")
110+
111+ buttonscontainer.pack_end(self.ok, False, False, 0)
112+ buttonscontainer.pack_end(applyb, False, False, 0)
113+ buttonscontainer.pack_end(cancel, False, False, 0)
114+
115+ cancel.connect("clicked", Gtk.main_quit)
116+ applyb.connect("clicked", self.applysettings)
117+ self.ok.connect("clicked", self.applysettings)
118+
119+ # loads current config
120+ self.loadconfig()
121+ self.connect("delete-event", Gtk.main_quit)
122+
123+ def applysettings(self, widget):
124+ """ writes settings to dpcs.config, exits
125+ if ok has been pressed
126+ """
127+ f = open(FILE, 'w')
128+ for s in settings:
129+ save_setting(s, f)
130+ f.close()
131+ if widget == self.ok:
132+ Gtk.main_quit()
133+
134+ def loadconfig(self):
135+ """ loads current settings from dpcs.config
136+ """
137+ if os.path.isfile(FILE):
138+ i=0
139+ f = open(FILE, 'r')
140+ for line in f:
141+ load_setting(settings[i],line)
142+ i+=1
143+ f.close()
144+displaypanel()
145diff --git a/client/settings/panelEvoker.py b/client/settings/panelEvoker.py
146new file mode 100644
147index 0000000..5c7c389
148--- /dev/null
149+++ b/client/settings/panelEvoker.py
150@@ -0,0 +1,6 @@
151+#coding: utf-8
152+
153+import subprocess
154+
155+subprocess.call(["sudo python panel.py"], shell=True )
156+
157diff --git a/client/settings/readme.md b/client/settings/readme.md
158index 9c558e3..003cdb5 100644
159--- a/client/settings/readme.md
160+++ b/client/settings/readme.md
161@@ -1 +1 @@
162-.
163+Pushed second version of settigs panel, with evoker.

Subscribers

People subscribed via source and target branches

to all changes: