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

Subscribers

People subscribed via source and target branches

to all changes: