diff --git a/discover_overlay/about_settings.py b/discover_overlay/about_settings.py new file mode 100644 index 0000000..457c9f1 --- /dev/null +++ b/discover_overlay/about_settings.py @@ -0,0 +1,72 @@ +# 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 . +"""Overview setting tab on settings window""" +import json +import logging +from configparser import ConfigParser +import gi +import sys +from .settings import SettingsWindow + +gi.require_version("Gtk", "3.0") +# pylint: disable=wrong-import-position,wrong-import-order +from gi.repository import Gtk, Gdk, GLib + + +GUILD_DEFAULT_VALUE = "0" + + +class AboutSettingsWindow(Gtk.Grid): + """Basic overview and a nicer looking landing page for Steam Deck""" + + def __init__(self, discover): + Gtk.Grid.__init__(self) + self.discover = discover + self.create_gui() + + def create_gui(self): + """ + Prepare the gui + """ + spacing_box_1 = Gtk.Box() + spacing_box_1.set_size_request(60,60) + self.attach(spacing_box_1,1,0,1,1) + + icon = Gtk.Image.new_from_icon_name("discover-overlay-tray", 256) + icon.set_pixel_size(128) + self.attach(icon,1,1,1,1) + + spacing_box_2 = Gtk.Box() + spacing_box_2.set_size_request(60,60) + self.attach(spacing_box_2,1,2,1,1) + + blurb = Gtk.Label.new(None) + if self.discover.steamos: + blurb.set_markup("Welcome to Discover Overlay\n\nDiscover-Overlay is a GTK3 overlay written in Python3. It can be configured to show who is currently talking on discord. It is fully customisable and can be configured to display anywhere on the screen. We fully support X11 and wlroots based environments. We felt the need to make this project due to the shortcomings in support on Linux by the official discord client.\n\nPlease visit our discord (https://discord.gg/jRKWMuDy5V) for support. Or open an issue on our GitHub (https://github.com/trigg/Discover)\n\n\n\n\n\n") + else: + blurb.set_markup("Welcome to Discover Overlay\n\nDiscover-Overlay is a GTK3 overlay written in Python3. It can be configured to show who is currently talking on discord or it can be set to display text and images from a preconfigured channel. It is fully customisable and can be configured to display anywhere on the screen. We fully support X11 and wlroots based environments. We felt the need to make this project due to the shortcomings in support on Linux by the official discord client.\n\nPlease visit our discord (https://discord.gg/jRKWMuDy5V) for support. Or open an issue on our GitHub (https://github.com/trigg/Discover)\n\n\n\n\n\n") + blurb.set_line_wrap(True) + self.attach(blurb, 1,3,1,1) + + killapp = Gtk.Button.new_with_label("Close overlay") + killapp.connect("pressed", self.close_app) + self.attach(killapp,1,4,1,1) + + self.set_column_homogeneous(True) + + def close_app(self, button): + logging.info("Quit pressed") + sys.exit(0) + + def present_settings(self): + self.show_all() \ No newline at end of file diff --git a/discover_overlay/discover_overlay.py b/discover_overlay/discover_overlay.py index 84a59f2..3240152 100755 --- a/discover_overlay/discover_overlay.py +++ b/discover_overlay/discover_overlay.py @@ -46,6 +46,8 @@ class Discover: if "GAMESCOPE_WAYLAND_DISPLAY" in os.environ: logging.info("GameScope session detected. Enabling steam and gamescope integration") self.steamos = True + self.show_settings_delay = True + Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", Gtk.true) self.create_gui() @@ -82,6 +84,7 @@ class Discover: print(" -h, --help This screen") print(" --hide Hide overlay") print(" --show Show overlay") + print(" --nolock Do not use Lock or RPC. Helps for running in unpriviledged container") print("") print("For gamescope compatibility ensure ENV has 'GDK_BACKEND=x11'") if normal_close: @@ -107,7 +110,7 @@ class Discover: self.text_overlay.set_hidden(False) if "--debug" in data or "-v" in data: logging.getLogger().setLevel(0) - logging.basicConfig(filename=self.debug_file, level=logging.DEBUG) + logging.basicConfig(filename=self.debug_file) def rpc_changed(self, _a=None, _b=None, _c=None, _d=None): """ @@ -131,6 +134,12 @@ class Discover: self.make_sys_tray_icon(self.menu) self.settings = MainSettingsWindow(self) + if self.steamos: + # Larger fonts needed + css = Gtk.CssProvider.new() + css.load_from_data(bytes("* { font-size:20px; }", "utf-8")) + self.settings.get_style_context().add_provider(css, Gtk.STYLE_PROVIDER_PRIORITY_USER) + def make_sys_tray_icon(self, menu): """ Attempt to create an AppIndicator icon, failing that attempt to make @@ -230,9 +239,15 @@ def entrypoint(): line = "" for arg in sys.argv[1:]: line = "%s %s" % (line, arg) + pid_file = os.path.join(config_dir, "discover_overlay.pid") rpc_file = os.path.join(config_dir, "discover_overlay.rpc") debug_file = os.path.join(config_dir, "output.txt") + if "--nolock" in sys.argv: + logging.getLogger().setLevel(logging.INFO) + logging.info("Nolock mode chosen") + Discover(rpc_file, debug_file, line) + return try: with pidfile.PIDFile(pid_file): logging.getLogger().setLevel(logging.INFO) diff --git a/discover_overlay/overlay.py b/discover_overlay/overlay.py index cde3b4e..034f9fe 100644 --- a/discover_overlay/overlay.py +++ b/discover_overlay/overlay.py @@ -91,6 +91,7 @@ class OverlayWindow(Gtk.Window): self.show_all() if discover.steamos: + self.floating = False display = Display() atom = display.intern_atom("GAMESCOPE_EXTERNAL_OVERLAY") opaq = display.intern_atom("_NET_WM_WINDOW_OPACITY") @@ -100,9 +101,10 @@ class OverlayWindow(Gtk.Window): topw.change_property(atom, Xatom.CARDINAL,32, [1], X.PropModeReplace) - topw.change_property(opaq, - Xatom.CARDINAL,16, - [0xffff], X.PropModeReplace) + # Keep for reference, but appears to be unnecessary + #topw.change_property(opaq, + # Xatom.CARDINAL,16, + # [0xffff], X.PropModeReplace) logging.info("Setting STEAM_EXTERNAL_OVERLAY") display.sync() @@ -148,11 +150,14 @@ class OverlayWindow(Gtk.Window): """ Set if the window is floating and what dimensions to use """ + self.floating = floating self.pos_x = pos_x self.pos_y = pos_y self.width = width self.height = height + if self.discover.steamos: + self.floating = False self.force_location() def set_untouchable(self): diff --git a/discover_overlay/settings_window.py b/discover_overlay/settings_window.py index 1a980d8..70de00e 100644 --- a/discover_overlay/settings_window.py +++ b/discover_overlay/settings_window.py @@ -15,6 +15,7 @@ import gi from .voice_settings import VoiceSettingsWindow from .text_settings import TextSettingsWindow from .general_settings import GeneralSettingsWindow +from .about_settings import AboutSettingsWindow gi.require_version("Gtk", "3.0") # pylint: disable=wrong-import-position,wrong-import-order from gi.repository import Gtk @@ -38,17 +39,32 @@ class MainSettingsWindow(Gtk.Window): # Create notebook = Gtk.Notebook() - # nb.set_tab_pos(Gtk.POS_TOP) + + if discover.steamos: + notebook.set_tab_pos(Gtk.PositionType.LEFT) + + self.set_default_size(1280, 800) + + self.about_settings = AboutSettingsWindow(self.discover) + about_label = Gtk.Label.new("Overview") + notebook.append_page(self.about_settings) + notebook.set_tab_label(self.about_settings, about_label) self.voice_settings = VoiceSettingsWindow(self.voice_overlay) + voice_label = Gtk.Label.new("Voice") notebook.append_page(self.voice_settings) - notebook.set_tab_label_text(self.voice_settings, "Voice") + notebook.set_tab_label(self.voice_settings, voice_label) + self.text_settings = TextSettingsWindow(self.text_overlay) + text_label = Gtk.Label.new("Text") + notebook.append_page(self.text_settings) - notebook.set_tab_label_text(self.text_settings, "Text") + notebook.set_tab_label(self.text_settings, text_label) + self.core_settings = GeneralSettingsWindow(self.discover) + core_label = Gtk.Label.new("Core") notebook.append_page(self.core_settings) - notebook.set_tab_label_text(self.core_settings, "Core") + notebook.set_tab_label(self.core_settings, core_label) self.add(notebook) self.notebook = notebook @@ -66,6 +82,7 @@ class MainSettingsWindow(Gtk.Window): """ Show the settings window """ + self.about_settings.present_settings() self.voice_settings.present_settings() self.text_settings.present_settings() self.core_settings.present_settings()