Skip to content

Commit

Permalink
Fixed links on about page
Browse files Browse the repository at this point in the history
  • Loading branch information
boltgolt committed Dec 24, 2020
1 parent 6e58ac9 commit adfb8a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions howdy-gtk/src/ui.glade
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
<attribute name="foreground" value="#2929ababe2e2"/>
<attribute name="underline-color" value="#2929ababe2e2"/>
</attributes>
<signal name="activate-link" handler="on_about_link" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
Expand All @@ -295,6 +296,7 @@
<attribute name="foreground" value="#2929ababe2e2"/>
<attribute name="underline-color" value="#2929ababe2e2"/>
</attributes>
<signal name="activate-link" handler="on_about_link" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
Expand Down
11 changes: 11 additions & 0 deletions howdy-gtk/src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import os
import elevate
import subprocess

# Make sure we have the libs we need
gi.require_version("Gtk", "3.0")
Expand Down Expand Up @@ -81,6 +82,16 @@ def load_model_list(self):

self.treeview.set_model(self.listmodel)

def on_about_link(self, label, uri):
"""Open links on about page as a non-root user"""
try:
user = os.getlogin()
except Exception:
user = os.environ.get("SUDO_USER")

status, output = subprocess.getstatusoutput(["sudo -u " + user + " timeout 10 xdg-open " + uri])
return True

def exit(self, widget, context):
"""Cleanly exit"""
gtk.main_quit()
Expand Down

0 comments on commit adfb8a8

Please sign in to comment.