- Don't crash if missing dbus

- Show warning in about when exceeding guild limit
This commit is contained in:
trigg 2022-03-31 17:07:51 +00:00
parent 3e291c565e
commit 9344f59e19
4 changed files with 65612 additions and 65583 deletions

View file

@ -32,6 +32,7 @@ class AboutSettingsWindow(Gtk.Grid):
def __init__(self, discover):
Gtk.Grid.__init__(self)
self.discover = discover
self.warning = None
self.create_gui()
def create_gui(self):
@ -55,9 +56,14 @@ class AboutSettingsWindow(Gtk.Grid):
blurb.set_line_wrap(True)
self.attach(blurb, 1, 3, 1, 1)
self.warning = Gtk.Label.new(None)
self.warning.set_markup("")
self.warning.set_line_wrap(True)
self.attach(self.warning, 1, 4, 1, 1)
killapp = Gtk.Button.new_with_label("Close overlay")
killapp.connect("pressed", self.close_app)
self.attach(killapp, 1, 4, 1, 1)
self.attach(killapp, 1, 5, 1, 1)
self.set_column_homogeneous(True)
@ -67,3 +73,6 @@ class AboutSettingsWindow(Gtk.Grid):
def present_settings(self):
self.show_all()
def set_warning(self, message):
self.warning.set_markup(message)

File diff suppressed because it is too large Load diff

View file

@ -14,7 +14,14 @@
import os
import time
import sys
import dbus
try:
# pylint: disable=wrong-import-position,wrong-import-order
import dbus # nopep8
# pylint: disable=wrong-import-position,wrong-import-order
from dbus.mainloop.glib import DBusGMainLoop # nopep8
except:
dbus=None
pass
import logging
import gi
import pidfile
@ -23,7 +30,6 @@ from .voice_overlay import VoiceOverlayWindow
from .text_overlay import TextOverlayWindow
from .notification_overlay import NotificationOverlayWindow
from .discord_connector import DiscordConnector
from dbus.mainloop.glib import DBusGMainLoop # integration into the main loop
gi.require_version("Gtk", "3.0")
# pylint: disable=wrong-import-position,wrong-import-order
@ -81,8 +87,13 @@ class Discover:
monitor.connect("changed", self.rpc_changed)
Gtk.main()
def set_about_warning(self, message):
self.settings.about_settings.set_warning(message)
def set_dbus_notifications(self, enabled=False):
if not dbus:
return
if not self.bus:
DBusGMainLoop(set_as_default=True)
self.bus = dbus.SessionBus()
@ -100,7 +111,7 @@ class Discover:
if self.text_overlay and self.text_overlay.needsredraw:
self.text_overlay.redraw()
if self.notification_overlay:
if self.notification_overlay and dbus:
if self.notification_overlay.enabled:
# This doesn't really belong in overlay or settings
now = time.time()

View file

@ -793,16 +793,19 @@ class VoiceSettingsWindow(SettingsWindow):
def set_guild_list(self, guild_list):
# Uncertain about image but it's ready incase
# guild['icon_url']
if len(guild_list) > 50 and len(self.guild_ids) == 0 and not self.warned:
if len(guild_list) > 1 and len(self.guild_ids) == 0 and not self.warned:
# Trouble!
# Show warning message
d = Gtk.Window(title="Server limit exceeded")
d.set_default_size(200, 150)
label = Gtk.Label(
label="Your Discord server count is too high. Using Discover with too many servers can cause (long!) temporary Discord bans.\nPlease opt-in to servers you wish to use voice chat in.")
d.add(label)
d.show_all()
# TODO After ok, open Settings?
if self.discover.steamos:
self.discover.set_about_warning("Your Discord server count is too high. Using Discover with too many servers can cause (long!) temporary Discord bans.\nPlease opt-in to servers you wish to use voice chat in.")
else:
d = Gtk.Window(title="Server limit exceeded")
d.set_default_size(200, 150)
label = Gtk.Label(
label="Your Discord server count is too high. Using Discover with too many servers can cause (long!) temporary Discord bans.\nPlease opt-in to servers you wish to use voice chat in.")
d.add(label)
d.show_all()
# TODO After ok, open Settings?
self.warned = True
self.guild_ids_list.clear()