From 674d8084ea166d5974d5188f2384e2fbd59348a9 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Tue, 28 Dec 2021 23:35:04 +0100 Subject: [PATCH] Removed all Gtk GUI stuff. This is found in the separate repository fritzui from now on. --- fritzgui.py | 19 ------ fritztray.py | 179 --------------------------------------------------- gui/.gitkeep | 0 gui/INFO.md | 1 - 4 files changed, 199 deletions(-) delete mode 100644 fritzgui.py delete mode 100755 fritztray.py delete mode 100644 gui/.gitkeep delete mode 100644 gui/INFO.md diff --git a/fritzgui.py b/fritzgui.py deleted file mode 100644 index 13cc167..0000000 --- a/fritzgui.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/python3 -d - -# Copyright (C) 2021 Johannes Findeisen -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Maybe this program ist not needed and should be integrated into the tray app but i think it is -# better to separate things so people could decide if they want to use the tray. diff --git a/fritztray.py b/fritztray.py deleted file mode 100755 index a849511..0000000 --- a/fritztray.py +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/python3 -d - -# Copyright (C) 2021 Johannes Findeisen -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import gi -gi.require_version('Gtk', '3.0') -gi.require_version('AppIndicator3', '0.1') -gi.require_version('Notify', '0.7') -from gi.repository import Gtk -from gi.repository import AppIndicator3 -from gi.repository import Notify - -import os -import json -import signal -import subprocess -import time -import urllib.request -import xmltodict - -from pathlib import Path -from threading import Thread - -try: - from fritzconnection.fritzconnection.lib.fritzstatus import FritzStatus -except ImportError: - from fritzconnection.lib.fritzstatus import FritzStatus - -APP_VERSION = '0.0.1' -APPINDICATOR_ID = 'fritztray' - -def get_state_icon(state): - """ - Look up the state msg and return the icon name. - """ - install_path = '/usr/share/icons/hicolor/scalable/status' - icon_name = 'network-fritz-connected-symbolic.svg' - - fallback_dict = { - 'CONNECTED': 'network-vpn-symbolic', - 'WAITING': 'network-vpn-no-route-symbolic', - 'CONFIG': 'network-vpn-acquiring-symbolic', - 'ERROR': 'network-error-symbolic', - 'STARTING': 'network-vpn-acquiring-symbolic', - 'UPGRADE': 'network-offline-symbolic', - 'NONE': 'network-offline-symbolic' - } - - fritztray_dict = { - 'CONNECTED': 'network-freepn-connected-key2-symbolic', - 'WAITING': 'network-freepn-no-route-symbolic', - 'CONFIG': 'network-freepn-acquiring-symbolic', - 'ERROR': 'network-freepn-error-symbolic', - 'STARTING': 'network-freepn-acquiring-symbolic', - 'UPGRADE': 'network-freepn-offline-symbolic', - 'NONE': 'network-freepn-offline-symbolic' - } - - state_dict = fritztray_dict - connected_icon = Path(install_path).joinpath(icon_name) - if not connected_icon.exists(): - state_dict = fallback_dict - - return state_dict.get(state, state_dict['NONE']) - - -def fetch_geoip(): - """ - Fetch location info from ubuntu.com geoip server and transform the - xml payload to json. - """ - request = urllib.request.Request('https://geoip.ubuntu.com/lookup') - response = urllib.request.urlopen(request) - payload = xmltodict.parse(response.read()) - return json.dumps(payload, indent=4, separators=(',', ': ')) - - -class Indicator: - def __init__(self): - self.app_id = APPINDICATOR_ID - icon_name = get_state_icon('NONE') - self.indicator = AppIndicator3.Indicator.new( - self.app_id, - icon_name, - AppIndicator3.IndicatorCategory.APPLICATION_STATUS) - - self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE) - # self.indicator.set_attention_icon_full('indicator-messages-new', - # 'State update') - self.indicator.set_menu(self.create_menu()) - # setup the state updater thread - self.update = Thread(target=self.check_for_phone_state) - self.update.daemon - self.update.start() - - def check_for_phone_state(self): - """ - Check for new state msg and update icon if new. - """ - #old_state = 'NONE' - #new_state = 'NONE' - #guide = '999999999' - - #while True: - #if state_file.exists(): - # msg_queue = get_status(str(state_file)) - # new_state = msg_queue.pop().strip() - # if there is a change in state, update the icon - #if old_state != new_state: - # if new_state == 'UPGRADE': - # Notify.Notification.new("Version Error!!", "Wuhhuuuuu", None).show() - # self.indicator.set_icon_full(get_state_icon(new_state), new_state) - # # Notify.Notification.new(new_state, None, None).show() - # # note the second label arg should be the longest possible label str - # self.indicator.set_label(new_state.format().center(9), guide) - #old_state = new_state - #time.sleep(1) - - def create_menu(self): - menu = Gtk.Menu() - - #item_separator = Gtk.SeparatorMenuItem() - #menu.append(item_separator) - - item_about = Gtk.MenuItem(label='About Fritz!Tray') - item_about.connect('activate', self.about) - menu.append(item_about) - - item_quit = Gtk.MenuItem(label='Quit') - item_quit.connect('activate', self.quit) - menu.append(item_quit) - - menu.show_all() - return menu - - def about(self, source): - about_dialog = Gtk.AboutDialog() - about_dialog.set_name('About...') - about_dialog.set_program_name('Fritz!Tray') - about_dialog.set_version(APP_VERSION) - about_dialog.set_copyright('© 2021 Johannes Findeisen') - about_dialog.set_license_type(Gtk.License.GPL_3_0) - about_dialog.set_logo_icon_name('fritztray') - about_dialog.set_website('https://git.unixpeople.org/hanez/uplink') - about_dialog.set_website_label('https://git.unixpeople.org/hanez/uplink') - about_dialog.set_comments(""" -Fritz!Box control and status tool. - """) - about_dialog.set_authors(['Johannes Findeisen ']) - about_dialog.set_artists(['Foo Bar ']) - about_dialog.run() - about_dialog.hide() - - def quit(self, source): - Notify.uninit() - Gtk.main_quit() - -def main(): - Indicator() - Notify.init(APPINDICATOR_ID) - Gtk.main() - - -if __name__ == "__main__": - signal.signal(signal.SIGINT, signal.SIG_DFL) - main() diff --git a/gui/.gitkeep b/gui/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/gui/INFO.md b/gui/INFO.md deleted file mode 100644 index 725319f..0000000 --- a/gui/INFO.md +++ /dev/null @@ -1 +0,0 @@ -# Directory for GTK Glade files in the future.