Skip to content

Commit 3c687e6

Browse files
authored
Merge pull request #7 from freepn/icons-and-ui
Icons and ui testing, package up for evaluation
2 parents b255b83 + bd02aa3 commit 3c687e6

11 files changed

+208
-10
lines changed

.gitattributes

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
# Explicitly declare source files to always be normalized and converted
5+
# to native line endings on checkout.
6+
*.svd text
7+
*.xml text
8+
*.svg text
9+
*.dot text
10+
*.S text
11+
*.s text
12+
*.c text
13+
*.h text
14+
*.ld text
15+
Makefile* text
16+
Doxyfile* text
17+
18+
# Declare files that will always have CRLF line endings on checkout.
19+
*.sln eol=crlf
20+
*.vcproj eol=crlf
21+
*.bat eol=crlf
22+
*.ico -text
23+
24+
# Denote all files that are truly binary and should not be modified.
25+
*.png binary
26+
*.jpg binary
27+
*.out binary
28+
*.bin binary
29+
*.hex binary
30+
*.pdf binary
31+
*.zip binary

freepn-gtk3-indicator

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,48 @@ gi.require_version('AppIndicator3', '0.1') # noqa
1818
gi.require_version('Notify', '0.7') # noqa
1919
from gi.repository import Gtk, AppIndicator3, Notify
2020

21-
from node_tools.helper_funcs import get_runtimedir
21+
try:
22+
from node_tools.helper_funcs import get_runtimedir
23+
state_file = Path(get_runtimedir()).joinpath('fpnd.state')
24+
except ImportError:
25+
import os
26+
state_file = Path(os.path.join('/run/fpnd', 'fpnd.state'))
2227

2328

2429
APPINDICATOR_ID = 'fpndindicator'
25-
state_file = Path(get_runtimedir()).joinpath('fpnd.state')
30+
APP_VERSION = '0.0.4'
2631

2732

2833
def get_state_icon(state):
2934
"""
3035
Look up the state msg and return the icon name.
3136
"""
32-
state_dict = {
37+
install_path = '/usr/share/icons/hicolor/scalable/status'
38+
icon_name = 'network-freepn-connected-symbolic.svg'
39+
40+
fallback_dict = {
3341
'CONNECTED': 'network-vpn-symbolic',
34-
'WAITING': 'network-vpn-acquiring-symbolic',
35-
'CONFIG': 'network-vpn-no-route-symbolic',
42+
'WAITING': 'network-vpn-no-route-symbolic',
43+
'CONFIG': 'network-vpn-acquiring-symbolic',
3644
'ERROR': 'network-error-symbolic',
37-
'STARTING': 'network-idle-symbolic',
45+
'STARTING': 'network-vpn-acquiring-symbolic',
3846
'NONE': 'network-offline-symbolic'
3947
}
48+
49+
freepn_dict = {
50+
'CONNECTED': 'network-freepn-connected-symbolic',
51+
'WAITING': 'network-freepn-no-route-symbolic',
52+
'CONFIG': 'network-freepn-acquiring-symbolic',
53+
'ERROR': 'network-freepn-error-symbolic',
54+
'STARTING': 'network-freepn-acquiring-symbolic',
55+
'NONE': 'network-freepn-offline-symbolic'
56+
}
57+
58+
state_dict = freepn_dict
59+
connected_icon = Path(install_path).joinpath(icon_name)
60+
if not connected_icon.exists():
61+
state_dict = fallback_dict
62+
4063
return state_dict.get(state, state_dict['NONE'])
4164

4265

@@ -143,6 +166,7 @@ class Indicator():
143166
Check for new state msg and update icon if new.
144167
"""
145168
old_state = 'NONE'
169+
new_state = 'NONE'
146170
guide = '999999999'
147171

148172
while True:
@@ -152,8 +176,7 @@ class Indicator():
152176
new_state = msg_queue.pop().strip()
153177
# if there is a change in state, update the icon
154178
if old_state != new_state:
155-
icon_name = get_state_icon(new_state)
156-
self.indicator.set_icon_full(icon_name, new_state)
179+
self.indicator.set_icon_full(get_state_icon(new_state), new_state)
157180
# Notify.Notification.new(new_state, None, None).show()
158181
# note the second label arg should be the longest possible label str
159182
self.indicator.set_label(new_state.format().center(9), guide)
@@ -184,13 +207,34 @@ class Indicator():
184207
item_separator = Gtk.SeparatorMenuItem()
185208
menu.append(item_separator)
186209

210+
item_about = Gtk.MenuItem(label='About')
211+
item_about.connect('activate', self.about)
212+
menu.append(item_about)
213+
187214
item_quit = Gtk.MenuItem(label='Quit')
188215
item_quit.connect('activate', self.stop)
189216
menu.append(item_quit)
190217

191218
menu.show_all()
192219
return menu
193220

221+
def about(self, source):
222+
dlg = Gtk.AboutDialog()
223+
dlg.set_name('About...')
224+
dlg.set_program_name('freepn-gtk3-indicator')
225+
dlg.set_version(APP_VERSION)
226+
dlg.set_copyright('© 2019-2020 The FreePN Team')
227+
dlg.set_license_type(Gtk.License.AGPL_3_0)
228+
dlg.set_logo_icon_name('freepn')
229+
dlg.set_website('https://github.com/freepn')
230+
dlg.set_comments("""
231+
FreePN network daemon control and status tool.
232+
""")
233+
dlg.set_authors(['Stephen L Arnold <[email protected]>'])
234+
dlg.set_artists(['Marianne Cruzat <[email protected]>'])
235+
dlg.run()
236+
dlg.hide()
237+
194238
def stop(self, source):
195239
Notify.uninit()
196240
Gtk.main_quit()
@@ -215,6 +259,7 @@ class Indicator():
215259
svc_msg = run_service_cmd(action='stop')
216260
if not svc_msg:
217261
svc_msg = 'Stopping...'
262+
self.indicator.set_icon_full(get_state_icon('NONE'), 'NONE')
218263
Notify.Notification.new("Daemon status", svc_msg, None).show()
219264

220265

icons/connected_test_dark2.svg

Lines changed: 103 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)