def __init__(self, secure_internet_uri, institute_access_uri, verify_key, lets_connect): """setup UI thingies, don't do any fetching or DBus communication yet""" self.secure_internet_uri = secure_internet_uri self.institute_access_uri = institute_access_uri self.lets_connect = lets_connect # minimal global state to pass around data between steps where otherwise difficult self.selected_meta = None self.prefix = get_prefix() self.builder = Gtk.Builder() for b in builder_files: p = os.path.join(self.prefix, 'share/eduvpn/builder', b) if not os.access(p, os.R_OK): logger.error( "Can't find {}! That is quite an important file.".format( p)) raise Exception self.builder.add_from_file(p) # the signals coming from the GTK ui handlers = { "delete_window": Gtk.main_quit, "add_config": self.add, "del_config": self.delete, "select_config": self.select, "connect_set": self.switched, } self.builder.connect_signals(handlers) self.window = self.builder.get_object('eduvpn-window') self.verifier = make_verifier(verify_key) self.window.set_position(Gtk.WindowPosition.CENTER)
from eduvpn.util import get_prefix from typing import Tuple prefix = get_prefix() eduvpn_main_logo = prefix + "/share/icons/hicolor/" \ "128x128/apps/eduvpn-client.png" # type: str eduvpn_name = "eduVPN" # type: str lets_connect_main_logo = prefix + "/share/icons/hicolor/128x128" \ "/apps/lets-connect-client.png" # type: str lets_connect_name = "Let's Connect!" # type: str def get_brand(lets_connect): # type: (bool) -> Tuple[str, str] """Returns the name for the app currently in use.""" if lets_connect: return lets_connect_main_logo, lets_connect_name else: return eduvpn_main_logo, eduvpn_name
def test_get_prefix(self): get_prefix()
# python-eduvpn-client - The GNU/Linux eduVPN client and Python API # # Copyright: 2017, The Commons Conservancy eduVPN Programme # SPDX-License-Identifier: GPL-3.0+ from os import path import gi gi.require_version('Notify', '0.7') gi.require_version('Gtk', '3.0') from gi.repository import Notify, GdkPixbuf from eduvpn.util import get_prefix, have_dbus Notify.init("eduVPN client") image_path = path.join(get_prefix(), 'share/eduvpn/eduvpn.png') image = GdkPixbuf.Pixbuf.new_from_file(image_path) notification = Notify.Notification.new('test') notification.set_icon_from_pixbuf(image) notification.set_app_name("eduVPN") def notify(msg, small_msg=None): notification.update(msg, small_msg) if have_dbus(): notification.show()