- Added general settings
- Option to force XShape even with composite on
This commit is contained in:
parent
36411ca6c8
commit
df8f7cd35a
3 changed files with 92 additions and 11 deletions
|
|
@ -19,7 +19,7 @@ from .text_settings import TextSettingsWindow
|
|||
from .voice_overlay import VoiceOverlayWindow
|
||||
from .text_overlay import TextOverlayWindow
|
||||
from .discord_connector import DiscordConnector
|
||||
from .autostart import Autostart
|
||||
from .general_settings import GeneralSettingsWindow
|
||||
import logging
|
||||
import pidfile
|
||||
import os
|
||||
|
|
@ -33,8 +33,6 @@ except ModuleNotFoundError:
|
|||
|
||||
class Discover:
|
||||
def __init__(self, rpc_file, args):
|
||||
self.a = Autostart("discover_overlay")
|
||||
# a.set_autostart(True)
|
||||
self.create_gui()
|
||||
self.connection = DiscordConnector(
|
||||
self.text_settings, self.voice_settings,
|
||||
|
|
@ -57,6 +55,8 @@ class Discover:
|
|||
pass
|
||||
elif "--about" in data:
|
||||
pass
|
||||
elif "--configure-general" in data:
|
||||
self.show_gsettings()
|
||||
elif "--configure-voice" in data:
|
||||
self.show_vsettings()
|
||||
elif "--configure-text" in data:
|
||||
|
|
@ -64,6 +64,7 @@ class Discover:
|
|||
elif "--configure" in data:
|
||||
self.show_tsettings()
|
||||
self.show_vsettings()
|
||||
self.show_gsettings()
|
||||
elif "--close" in data:
|
||||
sys.exit(0)
|
||||
|
||||
|
|
@ -81,6 +82,7 @@ class Discover:
|
|||
self.make_sys_tray_icon(self.menu)
|
||||
self.voice_settings = VoiceSettingsWindow(self.voice_overlay)
|
||||
self.text_settings = TextSettingsWindow(self.text_overlay)
|
||||
self.general_settings = GeneralSettingsWindow(self.text_overlay, self.voice_overlay)
|
||||
|
||||
def make_sys_tray_icon(self, menu):
|
||||
# Create AppIndicator
|
||||
|
|
@ -104,25 +106,21 @@ class Discover:
|
|||
menu = Gtk.Menu()
|
||||
vsettings_opt = Gtk.MenuItem.new_with_label("Voice Settings")
|
||||
tsettings_opt = Gtk.MenuItem.new_with_label("Text Settings")
|
||||
autostart_opt = Gtk.CheckMenuItem("Start on boot")
|
||||
autostart_opt.set_active(self.a.is_auto())
|
||||
gsettings_opt = Gtk.MenuItem.new_with_label("General Settings")
|
||||
close_opt = Gtk.MenuItem.new_with_label("Close")
|
||||
|
||||
menu.append(vsettings_opt)
|
||||
menu.append(tsettings_opt)
|
||||
menu.append(autostart_opt)
|
||||
menu.append(gsettings_opt)
|
||||
menu.append(close_opt)
|
||||
|
||||
vsettings_opt.connect("activate", self.show_vsettings)
|
||||
tsettings_opt.connect("activate", self.show_tsettings)
|
||||
autostart_opt.connect("toggled", self.toggle_auto)
|
||||
gsettings_opt.connect("activate", self.show_gsettings)
|
||||
close_opt.connect("activate", self.close)
|
||||
menu.show_all()
|
||||
return menu
|
||||
|
||||
def toggle_auto(self, button):
|
||||
self.a.set_autostart(button.get_active())
|
||||
|
||||
def show_menu(self, obj, button, time):
|
||||
self.menu.show_all()
|
||||
self.menu.popup(
|
||||
|
|
@ -134,6 +132,9 @@ class Discover:
|
|||
def show_tsettings(self, obj=None, data=None):
|
||||
self.text_settings.present()
|
||||
|
||||
def show_gsettings(self, obj=None, data=None):
|
||||
self.general_settings.present()
|
||||
|
||||
def close(self, a=None, b=None, c=None):
|
||||
Gtk.main_quit()
|
||||
|
||||
|
|
|
|||
75
discover_overlay/general_settings.py
Normal file
75
discover_overlay/general_settings.py
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
import json
|
||||
from configparser import ConfigParser
|
||||
from .draggable_window import DraggableWindow
|
||||
from .settings import SettingsWindow
|
||||
from .autostart import Autostart
|
||||
from gi.repository import Gtk, Gdk, Pango
|
||||
import logging
|
||||
|
||||
|
||||
class GeneralSettingsWindow(SettingsWindow):
|
||||
def __init__(self, overlay, overlay2):
|
||||
Gtk.Window.__init__(self)
|
||||
self.overlay = overlay
|
||||
self.overlay2 = overlay
|
||||
self.set_size_request(400, 200)
|
||||
self.connect("destroy", self.close_window)
|
||||
self.connect("delete-event", self.close_window)
|
||||
self.init_config()
|
||||
self.a = Autostart("discover_overlay")
|
||||
|
||||
self.create_gui()
|
||||
|
||||
def read_config(self):
|
||||
config = ConfigParser(interpolation=None)
|
||||
config.read(self.configFile)
|
||||
self.xshape = config.getboolean("general", "xshape", fallback=False)
|
||||
|
||||
# Pass all of our config over to the overlay
|
||||
self.overlay.set_force_xshape(self.xshape)
|
||||
self.overlay2.set_force_xshape(self.xshape)
|
||||
|
||||
def save_config(self):
|
||||
config = ConfigParser(interpolation=None)
|
||||
config.read(self.configFile)
|
||||
if not config.has_section("general"):
|
||||
config.add_section("general")
|
||||
|
||||
config.set("general", "xshape", "%d" % (int(self.xshape)))
|
||||
|
||||
with open(self.configFile, 'w') as file:
|
||||
config.write(file)
|
||||
|
||||
def create_gui(self):
|
||||
box = Gtk.Grid()
|
||||
|
||||
# Auto start
|
||||
autostart_label = Gtk.Label.new("Autostart on boot")
|
||||
autostart = Gtk.CheckButton.new()
|
||||
autostart.set_active(self.a.is_auto())
|
||||
autostart.connect("toggled", self.change_autostart)
|
||||
|
||||
# Force XShape
|
||||
xshape_label = Gtk.Label.new("Force XShape")
|
||||
xshape = Gtk.CheckButton.new()
|
||||
xshape.set_active(self.xshape)
|
||||
xshape.connect("toggled", self.change_xshape)
|
||||
|
||||
box.attach(autostart_label, 0, 0, 1, 1)
|
||||
box.attach(autostart, 1, 0, 1, 1)
|
||||
box.attach(xshape_label, 0, 1, 1, 1)
|
||||
box.attach(xshape, 1, 1, 1, 1)
|
||||
|
||||
self.add(box)
|
||||
|
||||
def change_autostart(self, button):
|
||||
self.autostart = button.get_active()
|
||||
self.a.set_autostart(self.autostart)
|
||||
|
||||
def change_xshape(self, button):
|
||||
self.overlay.set_force_xshape(button.get_active())
|
||||
self.overlay2.set_force_xshape(button.get_active())
|
||||
self.xshape = button.get_active()
|
||||
self.save_config()
|
||||
|
|
@ -3,6 +3,7 @@ gi.require_version("Gtk", "3.0")
|
|||
from gi.repository import Gtk, Gdk
|
||||
import cairo
|
||||
import logging
|
||||
import sys
|
||||
|
||||
|
||||
class OverlayWindow(Gtk.Window):
|
||||
|
|
@ -36,6 +37,7 @@ class OverlayWindow(Gtk.Window):
|
|||
self.align_right = True
|
||||
self.align_vert = 1
|
||||
self.floating = False
|
||||
self.force_xshape= False
|
||||
|
||||
def draw(self, widget, context):
|
||||
pass
|
||||
|
|
@ -105,7 +107,7 @@ class OverlayWindow(Gtk.Window):
|
|||
gdkwin = self.get_window()
|
||||
|
||||
if gdkwin:
|
||||
if not self.compositing:
|
||||
if not self.compositing or self.force_xshape:
|
||||
(w, h) = self.get_size()
|
||||
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h)
|
||||
surface_ctx = cairo.Context(surface)
|
||||
|
|
@ -133,3 +135,6 @@ class OverlayWindow(Gtk.Window):
|
|||
|
||||
def col(self, c, a=1.0):
|
||||
self.context.set_source_rgba(c[0], c[1], c[2], c[3] * a)
|
||||
|
||||
def set_force_xshape(self, force):
|
||||
self.force_xshape = force
|
||||
Loading…
Add table
Add a link
Reference in a new issue