Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VIGNET Pierre
cadbiom
Commits
4c966e1c
Commit
4c966e1c
authored
Feb 04, 2020
by
VIGNET Pierre
Browse files
[gui] Ability to install a desktop file shortcut
parent
a7bc33df
Changes
1
Hide whitespace changes
Inline
Side-by-side
gui/cadbiom_gui/__main__.py
View file @
4c966e1c
...
...
@@ -30,12 +30,53 @@ Created on Nov 2016
..sectionauthor:: Pierre Vignet <pierre.vignet@irisa.fr>
"""
import
sys
import
os
import
pkg_resources
import
gtk
from
cadbiom_gui.gt_gui.charter
import
Charter
from
cadbiom
import
commons
as
cm
def
main
():
LOGGER
=
cm
.
logger
()
def
build_desktop_shortcut
(
executable_path
):
"""Install a .desktop launcher file in ~/.local/share/applications"""
if
sys
.
platform
!=
"linux2"
:
LOGGER
.
error
(
"This option is only supported on GNU/Linux platforms."
)
exit
(
1
)
favicon_path
=
pkg_resources
.
resource_filename
(
__name__
,
"gt_gui/images/favicon.ico"
)
desktop_content
=
"""[Desktop Entry]
Comment=Cadbiom GUI launcher
Encoding=UTF-8
Exec={}
Icon={}
Categories=Science;
Name=Cadbiom
Type=Application
Terminal=false
"""
.
format
(
executable_path
,
favicon_path
)
desktop_path
=
"%s/.local/share/applications/"
%
os
.
path
.
expanduser
(
"~"
)
with
open
(
desktop_path
+
"Cadbiom.desktop"
,
"w"
)
as
f_d
:
f_d
.
write
(
desktop_content
)
LOGGER
.
info
(
"Desktop file created in <%s>"
,
desktop_path
)
exit
(
0
)
def
main
():
"""Launch Cadbiom gui"""
import
gtk
from
cadbiom_gui.gt_gui.charter
import
Charter
if
"--install_desktop_shortcut"
in
sys
.
argv
:
build_desktop_shortcut
(
sys
.
argv
[
0
])
charter
=
Charter
(
None
)
charter
.
show
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment