- Added some comments
This commit is contained in:
parent
ac2afa4d6a
commit
3953706579
11 changed files with 55 additions and 18 deletions
|
|
@ -10,6 +10,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""The connector for discord. Connects in as if it was Streamkit for OBS or Xsplit and communicates to get voice & text info to display"""
|
||||
import select
|
||||
import time
|
||||
import json
|
||||
|
|
@ -21,6 +22,8 @@ import requests
|
|||
|
||||
|
||||
class DiscordConnector:
|
||||
"""The connector for discord. Connects in as if it was Streamkit for OBS or Xsplit and communicates to get voice & text info to display"""
|
||||
|
||||
def __init__(self, text_settings, voice_settings, text_overlay, voice_overlay):
|
||||
self.text_settings = text_settings
|
||||
self.text_overlay = text_overlay
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""Main application class"""
|
||||
import os
|
||||
import sys
|
||||
import gi
|
||||
import logging
|
||||
import gi
|
||||
import pidfile
|
||||
from .settings_window import MainSettingsWindow
|
||||
from .voice_overlay import VoiceOverlayWindow
|
||||
|
|
@ -30,6 +31,8 @@ except ModuleNotFoundError:
|
|||
|
||||
|
||||
class Discover:
|
||||
"""Main application class"""
|
||||
|
||||
def __init__(self, rpc_file, args):
|
||||
self.ind = None
|
||||
self.tray = None
|
||||
|
|
|
|||
|
|
@ -10,8 +10,9 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import gi
|
||||
"""Core Settings Tab"""
|
||||
from configparser import ConfigParser
|
||||
import gi
|
||||
from .settings import SettingsWindow
|
||||
from .autostart import Autostart
|
||||
gi.require_version("Gtk", "3.0")
|
||||
|
|
@ -20,6 +21,8 @@ from gi.repository import Gtk
|
|||
|
||||
|
||||
class GeneralSettingsWindow(SettingsWindow):
|
||||
"""Core Settings Tab"""
|
||||
|
||||
def __init__(self, overlay, overlay2):
|
||||
SettingsWindow.__init__(self)
|
||||
self.overlay = overlay
|
||||
|
|
|
|||
|
|
@ -10,20 +10,22 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import gi
|
||||
"""Functions & Classes to assist image loading."""
|
||||
import urllib
|
||||
import requests
|
||||
import threading
|
||||
import cairo
|
||||
import logging
|
||||
import gi
|
||||
import requests
|
||||
import cairo
|
||||
import PIL.Image as Image
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version('GdkPixbuf', '2.0')
|
||||
# pylint: disable=wrong-import-position
|
||||
from gi.repository import Gio, GdkPixbuf
|
||||
|
||||
|
||||
class Image_Getter():
|
||||
class ImageGetter():
|
||||
"""Older attempt. Not advised as it can't manage anything but PNG. Loads to GDK Pixmap"""
|
||||
|
||||
def __init__(self, func, url, identifier, size):
|
||||
self.func = func
|
||||
self.id = identifier
|
||||
|
|
@ -51,7 +53,9 @@ class Image_Getter():
|
|||
logging.error(exception)
|
||||
|
||||
|
||||
class Surface_Getter():
|
||||
class SurfaceGetter():
|
||||
"""Download and decode image using PIL and store as a cairo surface"""
|
||||
|
||||
def __init__(self, func, url, identifier, size):
|
||||
self.func = func
|
||||
self.id = identifier
|
||||
|
|
@ -59,7 +63,7 @@ class Surface_Getter():
|
|||
self.size = size
|
||||
|
||||
def get_url(self):
|
||||
|
||||
"""Downloads and decodes"""
|
||||
try:
|
||||
resp = requests.get(self.url, stream=True, headers={
|
||||
'Referer': 'https://streamkit.discord.com/overlay/voice', 'User-Agent': 'Mozilla/5.0'})
|
||||
|
|
@ -96,18 +100,21 @@ class Surface_Getter():
|
|||
|
||||
|
||||
def get_image(func, identifier, ava, size):
|
||||
image_getter = Image_Getter(func, identifier, ava, size)
|
||||
"""Download to GDK Pixmap"""
|
||||
image_getter = ImageGetter(func, identifier, ava, size)
|
||||
t = threading.Thread(target=image_getter.get_url, args=())
|
||||
t.start()
|
||||
|
||||
|
||||
def get_surface(func, identifier, ava, size):
|
||||
image_getter = Surface_Getter(func, identifier, ava, size)
|
||||
"""Download to cairo surface"""
|
||||
image_getter = SurfaceGetter(func, identifier, ava, size)
|
||||
t = threading.Thread(target=image_getter.get_url, args=())
|
||||
t.start()
|
||||
|
||||
|
||||
def get_aspected_size(img, w, h, anchor=0, hanchor=0):
|
||||
"""Get dimensions of image keeping current aspect ratio"""
|
||||
px = img.get_width()
|
||||
py = img.get_height()
|
||||
if py < 1 or h < 1:
|
||||
|
|
@ -135,6 +142,7 @@ def get_aspected_size(img, w, h, anchor=0, hanchor=0):
|
|||
|
||||
|
||||
def draw_img_to_rect(img, ctx, x, y, w, h, path=False, aspect=False, anchor=0, hanchor=0):
|
||||
"""Draw cairo surface onto context"""
|
||||
# Path - only add the path do not fill : True/False
|
||||
# Aspect - keep aspect ratio : True/False
|
||||
# Anchor - with aspect : 0=left 1=middle 2=right
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""Overlay parent class. Helpful if we need more overlay types without copy-and-pasting too much code"""
|
||||
import sys
|
||||
import logging
|
||||
import gi
|
||||
|
|
@ -20,6 +21,8 @@ from gi.repository import Gtk, Gdk, GtkLayerShell
|
|||
|
||||
|
||||
class OverlayWindow(Gtk.Window):
|
||||
"""Overlay parent class. Helpful if we need more overlay types without copy-and-pasting too much code"""
|
||||
|
||||
def detect_type(self):
|
||||
window = Gtk.Window()
|
||||
screen = window.get_screen()
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""Settings tab parent class. Helpful if we need more overlay types without copy-and-pasting too much code"""
|
||||
import os
|
||||
import logging
|
||||
import gi
|
||||
|
|
@ -25,6 +26,8 @@ except ModuleNotFoundError:
|
|||
|
||||
|
||||
class SettingsWindow(Gtk.VBox):
|
||||
"""Settings tab parent class. Helpful if we need more overlay types without copy-and-pasting too much code"""
|
||||
|
||||
def __init__(self):
|
||||
Gtk.VBox.__init__(self)
|
||||
self.placement_window = None
|
||||
|
|
|
|||
|
|
@ -10,16 +10,19 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""Settings window holding all settings tab"""
|
||||
import gi
|
||||
from .voice_settings import VoiceSettingsWindow
|
||||
from .text_settings import TextSettingsWindow
|
||||
from .general_settings import GeneralSettingsWindow
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
# pylint: disable=wrong-import-position
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class MainSettingsWindow(Gtk.Window):
|
||||
"""Settings window holding all settings tab"""
|
||||
|
||||
def __init__(self, text_overlay, voice_overlay):
|
||||
Gtk.Window.__init__(self)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
from .overlay import OverlayWindow
|
||||
import cairo
|
||||
"""Overlay window for text"""
|
||||
import logging
|
||||
import time
|
||||
import re
|
||||
from .image_getter import get_surface, draw_img_to_rect, get_aspected_size
|
||||
import cairo
|
||||
import gi
|
||||
from .image_getter import get_surface, draw_img_to_rect, get_aspected_size
|
||||
from .overlay import OverlayWindow
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version('PangoCairo', '1.0')
|
||||
# pylint: disable=wrong-import-position
|
||||
|
|
@ -25,6 +25,8 @@ from gi.repository import Pango, PangoCairo
|
|||
|
||||
|
||||
class TextOverlayWindow(OverlayWindow):
|
||||
"""Overlay window for voice"""
|
||||
|
||||
def __init__(self, discover):
|
||||
OverlayWindow.__init__(self)
|
||||
self.discover = discover
|
||||
|
|
|
|||
|
|
@ -10,13 +10,15 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""Text setting tab on settings window"""
|
||||
import json
|
||||
import logging
|
||||
from configparser import ConfigParser
|
||||
import gi
|
||||
from .draggable_window import DraggableWindow
|
||||
from .draggable_window_wayland import DraggableWindowWayland
|
||||
from .settings import SettingsWindow
|
||||
import logging
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
# pylint: disable=wrong-import-position
|
||||
from gi.repository import Gtk, Gdk, Pango
|
||||
|
|
@ -26,6 +28,8 @@ GUILD_DEFAULT_VALUE = "0"
|
|||
|
||||
|
||||
class TextSettingsWindow(SettingsWindow):
|
||||
"""Text setting tab on settings window"""
|
||||
|
||||
def __init__(self, overlay):
|
||||
SettingsWindow.__init__(self)
|
||||
self.overlay = overlay
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""Overlay window for voice"""
|
||||
import math
|
||||
import cairo
|
||||
from .overlay import OverlayWindow
|
||||
|
|
@ -17,6 +18,7 @@ from .image_getter import get_surface, draw_img_to_rect
|
|||
|
||||
|
||||
class VoiceOverlayWindow(OverlayWindow):
|
||||
"""Overlay window for voice"""
|
||||
|
||||
def __init__(self, discover):
|
||||
OverlayWindow.__init__(self)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""Voice setting tab on settings window"""
|
||||
import json
|
||||
from configparser import ConfigParser
|
||||
import gi
|
||||
|
|
@ -22,6 +23,8 @@ from gi.repository import Gtk, Gdk, Pango
|
|||
|
||||
|
||||
class VoiceSettingsWindow(SettingsWindow):
|
||||
"""Voice setting tab on settings window"""
|
||||
|
||||
def __init__(self, overlay):
|
||||
SettingsWindow.__init__(self)
|
||||
self.overlay = overlay
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue