diff --git a/discover_overlay/general_settings.py b/discover_overlay/general_settings.py
deleted file mode 100644
index f6aae5c..0000000
--- a/discover_overlay/general_settings.py
+++ /dev/null
@@ -1,154 +0,0 @@
-# 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 .
-"""Core Settings Tab"""
-import gettext
-from configparser import ConfigParser
-import gi
-import pkg_resources
-from .settings import SettingsWindow
-from .autostart import Autostart
-gi.require_version("Gtk", "3.0")
-# pylint: disable=wrong-import-position,wrong-import-order
-from gi.repository import Gtk # nopep8
-
-t = gettext.translation(
- 'default', pkg_resources.resource_filename('discover_overlay', 'locales'), fallback=True)
-_ = t.gettext
-
-
-class GeneralSettingsWindow(SettingsWindow):
- """Core Settings Tab"""
-
- def __init__(self, discover):
- SettingsWindow.__init__(self, discover)
- self.discover = discover
- self.xshape = None
- self.show_sys_tray_icon = None
- self.show_task = None
- self.set_size_request(400, 200)
- self.connect("destroy", self.close_window)
- self.connect("delete-event", self.close_window)
- self.init_config()
- self.autostart_helper = Autostart("discover_overlay")
- self.placement_window = None
-
- self.create_gui()
-
- def read_config(self):
- """
- Read in the 'general' section of config and set overlays
- """
- config = ConfigParser(interpolation=None)
- config.read(self.config_file)
- self.xshape = config.getboolean("general", "xshape", fallback=False)
- self.show_sys_tray_icon = config.getboolean(
- "general", "showsystray", fallback=True)
- self.show_task = config.getboolean(
- "general", "showtask", fallback=False)
-
- # Pass all of our config over to the overlay
- self.discover.set_force_xshape(self.xshape)
- self.discover.set_sys_tray_icon_visible(self.show_sys_tray_icon)
-
- def save_config(self):
- """
- Save the 'general' section of config
- """
- config = ConfigParser(interpolation=None)
- config.read(self.config_file)
- if not config.has_section("general"):
- config.add_section("general")
-
- config.set("general", "xshape", "%d" % (int(self.xshape)))
- config.set("general", "showsystray",
- "yes" if self.show_sys_tray_icon else "no")
- config.set("general", "showtask", "yes" if self.show_task else "no")
-
- with open(self.config_file, 'w') as file:
- config.write(file)
-
- def create_gui(self):
- """
- Prepare the GUI
- """
- box = Gtk.Grid()
-
- # Auto start
- autostart_label = Gtk.Label.new(_("Autostart on boot"))
- autostart_label.set_xalign(0)
- autostart = Gtk.CheckButton.new()
- autostart.set_active(self.autostart_helper.is_auto())
- autostart.connect("toggled", self.change_autostart)
-
- # Force XShape
- xshape_label = Gtk.Label.new(_("Force XShape"))
- xshape_label.set_xalign(0)
- xshape = Gtk.CheckButton.new()
- xshape.set_active(self.xshape)
- xshape.connect("toggled", self.change_xshape)
-
- # Show sys tray
- show_sys_tray_icon_label = Gtk.Label.new(_("Show tray icon"))
- show_sys_tray_icon_label.set_xalign(0)
- show_sys_tray_icon = Gtk.CheckButton.new()
- show_sys_tray_icon.set_active(self.show_sys_tray_icon)
- show_sys_tray_icon.connect("toggled", self.change_show_sys_tray_icon)
-
- # Show taskbar
- show_task_label = Gtk.Label.new(_("Show on taskbar"))
- show_task_label.set_xalign(0)
- show_task = Gtk.CheckButton.new()
- show_task.set_active(self.show_task)
- show_task.connect("toggled", self.change_show_task)
-
- 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)
- box.attach(show_sys_tray_icon_label, 0, 2, 1, 1)
- box.attach(show_sys_tray_icon, 1, 2, 1, 1)
- box.attach(show_task_label, 0, 3, 1, 1)
- box.attach(show_task, 1, 3, 1, 1)
-
- self.add(box)
-
- def change_autostart(self, button):
- """
- Autostart setting changed
- """
- autostart = button.get_active()
- self.autostart_helper.set_autostart(autostart)
-
- def change_xshape(self, button):
- """
- XShape setting changed
- """
- self.discover.set_force_xshape(button.get_active())
- self.xshape = button.get_active()
- self.save_config()
-
- def change_show_sys_tray_icon(self, button):
- """
- Show tray icon setting changed
- """
- self.discover.set_sys_tray_icon_visible(button.get_active())
- self.show_sys_tray_icon = button.get_active()
- self.save_config()
-
- def change_show_task(self, button):
- """
- Show in task bar changed
- """
- self.discover.set_show_task(button.get_active())
- self.show_task = button.get_active()
- self.save_config()
diff --git a/discover_overlay/notification_settings.py b/discover_overlay/notification_settings.py
deleted file mode 100644
index 6735c1a..0000000
--- a/discover_overlay/notification_settings.py
+++ /dev/null
@@ -1,529 +0,0 @@
-# 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 .
-"""Notification setting tab on settings window"""
-import gettext
-import json
-import pkg_resources
-from configparser import ConfigParser
-import gi
-from .settings import SettingsWindow
-
-gi.require_version("Gtk", "3.0")
-# pylint: disable=wrong-import-position,wrong-import-order
-from gi.repository import Gtk, Gdk # nopep8
-
-
-GUILD_DEFAULT_VALUE = "0"
-t = gettext.translation(
- 'default', pkg_resources.resource_filename('discover_overlay', 'locales'), fallback=True)
-_ = t.gettext
-
-
-class NotificationSettingsWindow(SettingsWindow):
- """Notification setting tab on settings window"""
-
- def __init__(self, overlay, discover):
- SettingsWindow.__init__(self, discover)
- self.overlay = overlay
-
- self.placement_window = None
- self.init_config()
- self.align_x = None
- self.align_y = None
- self.monitor = None
- self.floating = None
- self.font = None
- self.bg_col = None
- self.fg_col = None
- self.text_time = None
- self.show_icon = None
- self.enabled = None
- self.limit_width = None
- self.icon_left = None
- self.padding = None
- self.icon_padding = None
- self.icon_size = None
- self.border_radius = None
-
- self.set_size_request(400, 200)
- self.connect("destroy", self.close_window)
- self.connect("delete-event", self.close_window)
- if overlay:
- self.init_config()
- self.create_gui()
-
- def present_settings(self):
- """
- Show contents of tab and update lists
- """
- if not self.overlay:
- return
- self.show_all()
- if not self.floating:
- self.align_x_widget.show()
- self.align_y_widget.show()
- self.align_monitor_widget.show()
- self.align_placement_widget.hide()
- else:
- self.align_x_widget.hide()
- self.align_y_widget.hide()
- self.align_monitor_widget.show()
- self.align_placement_widget.show()
-
- def read_config(self):
- """
- Read in the 'text' section of the config
- """
- if not self.overlay:
- return
- config = ConfigParser(interpolation=None)
- config.read(self.config_file)
- self.enabled = config.getboolean(
- "notification", "enabled", fallback=False)
- self.align_x = config.getboolean(
- "notification", "rightalign", fallback=True)
- self.align_y = config.getint("notification", "topalign", fallback=2)
- self.monitor = config.get("notification", "monitor", fallback="None")
- self.floating = config.getboolean(
- "notification", "floating", fallback=False)
- self.floating_x = config.getint(
- "notification", "floating_x", fallback=0)
- self.floating_y = config.getint(
- "notification", "floating_y", fallback=0)
- self.floating_w = config.getint(
- "notification", "floating_w", fallback=400)
- self.floating_h = config.getint(
- "notification", "floating_h", fallback=400)
- self.font = config.get("notification", "font", fallback=None)
- self.bg_col = json.loads(config.get(
- "notification", "bg_col", fallback="[0.0,0.0,0.0,0.5]"))
- self.fg_col = json.loads(config.get(
- "notification", "fg_col", fallback="[1.0,1.0,1.0,1.0]"))
- self.text_time = config.getint(
- "notification", "text_time", fallback=10)
- self.show_icon = config.getboolean(
- "notification", "show_icon", fallback=True)
- self.reverse_order = config.getboolean(
- "notification", "rev", fallback=False)
- self.limit_width = config.getint(
- "notification", "limit_width", fallback=400)
- self.icon_left = config.getboolean(
- "notification", "icon_left", fallback=True)
- self.icon_padding = config.getint(
- "notification", "icon_padding", fallback=8)
- self.icon_size = config.getint(
- "notification", "icon_size", fallback=32)
- self.padding = config.getint(
- "notification", "padding", fallback=8)
- self.border_radius = config.getint(
- "notification", "border_radius", fallback=8)
-
- # Pass all of our config over to the overlay
- self.overlay.set_enabled(self.enabled)
- self.overlay.set_align_x(self.align_x)
- self.overlay.set_align_y(self.align_y)
- self.overlay.set_monitor(self.get_monitor_index(
- self.monitor), self.get_monitor_obj(self.monitor))
- self.overlay.set_floating(
- self.floating, self.floating_x, self.floating_y, self.floating_w, self.floating_h)
- self.overlay.set_bg(self.bg_col)
- self.overlay.set_fg(self.fg_col)
- self.overlay.set_text_time(self.text_time)
- self.overlay.set_show_icon(self.show_icon)
- self.overlay.set_reverse_order(self.reverse_order)
- self.overlay.set_limit_width(self.limit_width)
- self.overlay.set_icon_left(self.icon_left)
- self.overlay.set_icon_size(self.icon_size)
- self.overlay.set_icon_pad(self.icon_padding)
- self.overlay.set_padding(self.padding)
- self.overlay.set_border_radius(self.border_radius)
- if self.font:
- self.overlay.set_font(self.font)
-
- def save_config(self):
- """
- Save the current settings to the 'text' section of the config
- """
- config = ConfigParser(interpolation=None)
- config.read(self.config_file)
- if not config.has_section("notification"):
- config.add_section("notification")
-
- config.set("notification", "rightalign", "%d" % (int(self.align_x)))
- config.set("notification", "topalign", "%d" % (self.align_y))
- config.set("notification", "monitor", self.monitor)
- config.set("notification", "enabled", "%d" % (int(self.enabled)))
- config.set("notification", "floating", "%s" % (int(self.floating)))
- config.set("notification", "floating_x", "%s" % (int(self.floating_x)))
- config.set("notification", "floating_y", "%s" % (int(self.floating_y)))
- config.set("notification", "floating_w", "%s" % (int(self.floating_w)))
- config.set("notification", "floating_h", "%s" % (int(self.floating_h)))
- config.set("notification", "bg_col", json.dumps(self.bg_col))
- config.set("notification", "fg_col", json.dumps(self.fg_col))
- config.set("notification", "text_time", "%s" % (int(self.text_time)))
- config.set("notification", "show_icon", "%s" %
- (int(self.show_icon)))
- config.set("notification", "rev", "%s" %
- (int(self.reverse_order)))
- config.set("notification", "limit_width", "%d" %
- (int(self.limit_width)))
- config.set("notification", "icon_left", "%d" % (int(self.icon_left)))
- config.set("notification", "icon_padding", "%d" %
- (int(self.icon_padding)))
- config.set("notification", "icon_size", "%d" % (int(self.icon_size)))
- config.set("notification", "padding", "%d" % (int(self.padding)))
- config.set("notification", "border_radius", "%d" %
- (int(self.border_radius)))
-
- if self.font:
- config.set("notification", "font", self.font)
-
- with open(self.config_file, 'w') as file:
- config.write(file)
-
- def create_gui(self):
- """
- Prepare the gui
- """
- box = Gtk.Grid()
-
- # Enabled
- enabled_label = Gtk.Label.new(_("Enable"))
- enabled_label.set_xalign(0)
- enabled = Gtk.CheckButton.new()
- enabled.set_active(self.enabled)
- enabled.connect("toggled", self.change_enabled)
-
- # Enabled
- testing_label = Gtk.Label.new(_("Show test content"))
- testing_label.set_xalign(0)
- testing = Gtk.CheckButton.new()
- testing.connect("toggled", self.change_testing)
-
- # Order
- reverse_label = Gtk.Label.new(_("Reverse Order"))
- reverse_label.set_xalign(0)
- reverse = Gtk.CheckButton.new()
- reverse.set_active(self.reverse_order)
- reverse.connect("toggled", self.change_reverse_order)
-
- # Popup timer
- text_time_label = Gtk.Label.new(_("Popup timer"))
- text_time_label.set_xalign(0)
- text_time_adjustment = Gtk.Adjustment.new(
- self.text_time, 8, 9000, 1, 1, 8)
- text_time = Gtk.SpinButton.new(text_time_adjustment, 0, 0)
- text_time.connect("value-changed", self.change_text_time)
-
- # Limit width
- limit_width_label = Gtk.Label.new(_("Limit popup width"))
- limit_width_label.set_xalign(0)
- limit_width_adjustment = Gtk.Adjustment.new(
- self.limit_width, 100, 9000, 1, 1, 8)
- limit_width = Gtk.SpinButton.new(limit_width_adjustment, 0, 0)
- limit_width.connect("value-changed", self.change_limit_width)
-
- # Font chooser
- font_label = Gtk.Label.new(_("Font"))
- font_label.set_xalign(0)
- font = Gtk.FontButton()
- if self.font:
- font.set_font(self.font)
- font.connect("font-set", self.change_font)
-
- # Icon alignment
- align_icon_label = Gtk.Label.new(_("Icon position"))
- align_icon_label.set_xalign(0)
- align_icon_store = Gtk.ListStore(str)
- align_icon_store.append([_("Left")])
- align_icon_store.append([_("Right")])
- align_icon = Gtk.ComboBox.new_with_model(align_icon_store)
- align_icon.set_active(not self.icon_left)
- align_icon.connect("changed", self.change_icon_left)
- renderer_text = Gtk.CellRendererText()
- align_icon.pack_start(renderer_text, True)
- align_icon.add_attribute(renderer_text, "text", 0)
-
- # Colours
- bg_col_label = Gtk.Label.new(_("Background colour"))
- bg_col_label.set_xalign(0)
- bg_col = Gtk.ColorButton.new_with_rgba(
- Gdk.RGBA(self.bg_col[0], self.bg_col[1], self.bg_col[2], self.bg_col[3]))
- fg_col_label = Gtk.Label.new(_("Text colour"))
- fg_col_label.set_xalign(0)
- fg_col = Gtk.ColorButton.new_with_rgba(
- Gdk.RGBA(self.fg_col[0], self.fg_col[1], self.fg_col[2], self.fg_col[3]))
- bg_col.set_use_alpha(True)
- fg_col.set_use_alpha(True)
- bg_col.connect("color-set", self.change_bg)
- fg_col.connect("color-set", self.change_fg)
-
- # Monitor & Alignment
- align_label = Gtk.Label.new(_("Overlay Location"))
- align_label.set_xalign(0)
- align_type_box = Gtk.HBox()
- align_type_edge = Gtk.RadioButton.new_with_label(
- None, _("Anchor to edge"))
- align_type_floating = Gtk.RadioButton.new_with_label_from_widget(
- align_type_edge, _("Floating"))
- if self.floating:
- align_type_floating.set_active(True)
- align_type_box.add(align_type_edge)
- align_type_box.add(align_type_floating)
-
- monitor_store = Gtk.ListStore(str)
- display = Gdk.Display.get_default()
- if "get_n_monitors" in dir(display):
- for i in range(0, display.get_n_monitors()):
- monitor_store.append([display.get_monitor(i).get_model()])
- monitor = Gtk.ComboBox.new_with_model(monitor_store)
- monitor.set_active(self.get_monitor_index(self.monitor))
- monitor.connect("changed", self.change_monitor)
- renderer_text = Gtk.CellRendererText()
- monitor.pack_start(renderer_text, True)
- monitor.add_attribute(renderer_text, "text", 0)
-
- align_x_store = Gtk.ListStore(str)
- align_x_store.append([_("Left")])
- align_x_store.append([_("Right")])
- align_x = Gtk.ComboBox.new_with_model(align_x_store)
- align_x.set_active(True if self.align_x else False)
- align_x.connect("changed", self.change_align_x)
- renderer_text = Gtk.CellRendererText()
- align_x.pack_start(renderer_text, True)
- align_x.add_attribute(renderer_text, "text", 0)
-
- align_y_store = Gtk.ListStore(str)
- align_y_store.append([_("Top")])
- align_y_store.append([_("Middle")])
- align_y_store.append([_("Bottom")])
- align_y = Gtk.ComboBox.new_with_model(align_y_store)
- align_y.set_active(self.align_y)
- align_y.connect("changed", self.change_align_y)
- renderer_text = Gtk.CellRendererText()
- align_y.pack_start(renderer_text, True)
- align_y.add_attribute(renderer_text, "text", 0)
-
- align_placement_button = Gtk.Button.new_with_label(_("Place Window"))
-
- align_type_edge.connect("toggled", self.change_align_type_edge)
- align_type_floating.connect("toggled", self.change_align_type_floating)
- align_placement_button.connect("pressed", self.change_placement)
-
- # Show Icons
- show_icon_label = Gtk.Label.new(_("Show Icon"))
- show_icon_label.set_xalign(0)
- show_icon = Gtk.CheckButton.new()
- show_icon.set_active(self.show_icon)
- show_icon.connect("toggled", self.change_show_icon)
-
- # Icon Padding
- icon_padding_label = Gtk.Label.new(_("Icon padding"))
- icon_padding_label.set_xalign(0)
- icon_padding_adjustment = Gtk.Adjustment.new(
- self.icon_padding, 0, 150, 1, 1, 8)
- icon_padding = Gtk.SpinButton.new(icon_padding_adjustment, 0, 0)
- icon_padding.connect("value-changed", self.change_icon_pad)
-
- # Icon Size
- icon_size_label = Gtk.Label.new(_("Icon size"))
- icon_size_label.set_xalign(0)
- icon_size_adjustment = Gtk.Adjustment.new(
- self.icon_size, 0, 128, 1, 1, 8)
- icon_size = Gtk.SpinButton.new(icon_size_adjustment, 0, 0)
- icon_size.connect("value-changed", self.change_icon_size)
-
- # Padding
- padding_label = Gtk.Label.new(_("Notification padding"))
- padding_label.set_xalign(0)
- padding_adjustment = Gtk.Adjustment.new(
- self.padding, 0, 150, 1, 1, 8)
- padding = Gtk.SpinButton.new(padding_adjustment, 0, 0)
- padding.connect("value-changed", self.change_padding)
-
- # Border Radius
- border_radius_label = Gtk.Label.new(_("Border radius"))
- border_radius_label.set_xalign(0)
- border_radius_adjustment = Gtk.Adjustment.new(
- self.border_radius, 0, 50, 1, 1, 8)
- border_radius = Gtk.SpinButton.new(border_radius_adjustment, 0, 0)
- border_radius.connect(
- "value-changed", self.change_border_radius)
-
- self.align_x_widget = align_x
- self.align_y_widget = align_y
- self.align_monitor_widget = monitor
- self.align_placement_widget = align_placement_button
- self.text_time_widget = text_time
- self.text_time_label_widget = text_time_label
-
- box.attach(enabled_label, 0, 0, 1, 1)
- box.attach(enabled, 1, 0, 1, 1)
- box.attach(reverse_label, 0, 1, 1, 1)
- box.attach(reverse, 1, 1, 1, 1)
- box.attach(text_time_label, 0, 3, 1, 1)
- box.attach(text_time, 1, 3, 1, 1)
- box.attach(limit_width_label, 0, 4, 1, 1)
- box.attach(limit_width, 1, 4, 1, 1)
-
- box.attach(font_label, 0, 6, 1, 1)
- box.attach(font, 1, 6, 1, 1)
- box.attach(fg_col_label, 0, 7, 1, 1)
- box.attach(fg_col, 1, 7, 1, 1)
- box.attach(bg_col_label, 0, 8, 1, 1)
- box.attach(bg_col, 1, 8, 1, 1)
- box.attach(align_label, 0, 9, 1, 5)
- #box.attach(align_type_box, 1, 8, 1, 1)
- box.attach(monitor, 1, 10, 1, 1)
- box.attach(align_x, 1, 11, 1, 1)
- box.attach(align_y, 1, 12, 1, 1)
- box.attach(align_placement_button, 1, 13, 1, 1)
- box.attach(show_icon_label, 0, 14, 1, 1)
- box.attach(show_icon, 1, 14, 1, 1)
- box.attach(align_icon_label, 0, 15, 1, 1)
- box.attach(align_icon, 1, 15, 1, 1)
- box.attach(icon_padding_label, 0, 16, 1, 1)
- box.attach(icon_padding, 1, 16, 1, 1)
- box.attach(icon_size_label, 0, 17, 1, 1)
- box.attach(icon_size, 1, 17, 1, 1)
- box.attach(padding_label, 0, 18, 1, 1)
- box.attach(padding, 1, 18, 1, 1)
- box.attach(border_radius_label, 0, 19, 1, 1)
- box.attach(border_radius, 1, 19, 1, 1)
- box.attach(testing_label, 0, 20, 1, 1)
- box.attach(testing, 1, 20, 1, 1)
-
- self.add(box)
-
- def change_padding(self, button):
- """
- Padding between notifications changed
- """
- self.overlay.set_padding(button.get_value())
- self.padding = button.get_value()
-
- self.save_config()
-
- def change_border_radius(self, button):
- """
- Border radius changed
- """
- self.overlay.set_border_radius(button.get_value())
- self.border_radius = button.get_value()
-
- self.save_config()
-
- def change_icon_size(self, button):
- """
- Icon size changed
- """
- self.overlay.set_icon_size(button.get_value())
- self.icon_size = button.get_value()
-
- self.save_config()
-
- def change_icon_pad(self, button):
- """
- Icon padding changed
- """
- self.overlay.set_icon_pad(button.get_value())
- self.icon_pad = button.get_value()
-
- self.save_config()
-
- def change_icon_left(self, button):
- """
- Icon alignment changed
- """
- self.overlay.set_icon_left(button.get_active() != 1)
- self.icon_left = (button.get_active() != 1)
-
- self.save_config()
-
- def change_font(self, button):
- """
- Font settings changed
- """
- font = button.get_font()
- self.overlay.set_font(font)
-
- self.font = font
- self.save_config()
-
- def change_text_time(self, button):
- """
- Popup style setting changed
- """
- self.overlay.set_text_time(button.get_value())
-
- self.text_time = button.get_value()
- self.save_config()
-
- def change_limit_width(self, button):
- """
- Popup width limiter
- """
- self.overlay.set_limit_width(button.get_value())
- self.limit_width = button.get_value()
- self.save_config()
-
- def change_bg(self, button):
- """
- Background colour changed
- """
- colour = button.get_rgba()
- colour = [colour.red, colour.green, colour.blue, colour.alpha]
- self.overlay.set_bg(colour)
-
- self.bg_col = colour
- self.save_config()
-
- def change_fg(self, button):
- """
- Foreground colour changed
- """
- colour = button.get_rgba()
- colour = [colour.red, colour.green, colour.blue, colour.alpha]
- self.overlay.set_fg(colour)
-
- self.fg_col = colour
- self.save_config()
-
- def change_show_icon(self, button):
- """
- Icon setting changed
- """
- self.overlay.set_show_icon(button.get_active())
-
- self.show_icon = button.get_active()
- self.save_config()
-
- def change_reverse_order(self, button):
- """
- Reverse Order changed
- """
- self.overlay.set_reverse_order(button.get_active())
-
- self.reverse_order = button.get_active()
- self.save_config()
-
- def change_testing(self, button):
- self.overlay.set_testing(button.get_active())
-
- def change_enabled(self, button):
- """
- Overlay active state toggled
- """
- self.overlay.set_enabled(button.get_active())
- self.enabled = button.get_active()
- self.save_config()
diff --git a/discover_overlay/settings.py b/discover_overlay/settings.py
deleted file mode 100644
index 0d68a1a..0000000
--- a/discover_overlay/settings.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# 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 .
-"""
-Settings tab parent class. Helpful if we need more
-overlay types without copy-and-pasting too much code
-"""
-import gettext
-import os
-import logging
-import pkg_resources
-import gi
-from .draggable_window import DraggableWindow
-from .draggable_window_wayland import DraggableWindowWayland
-gi.require_version("Gtk", "3.0")
-# pylint: disable=wrong-import-position,wrong-import-order
-from gi.repository import Gtk, Gdk # nopep8
-
-
-try:
- from xdg.BaseDirectory import xdg_config_home
-except ModuleNotFoundError:
- from xdg import XDG_CONFIG_HOME as xdg_config_home
-
-log = logging.getLogger(__name__)
-t = gettext.translation(
- 'default', pkg_resources.resource_filename('discover_overlay', 'locales'), fallback=True)
-_ = t.gettext
-
-
-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, discover):
- Gtk.VBox.__init__(self)
- self.placement_window = None
- self.config_dir = None
- self.config_file = None
- self.overlay = None
- self.floating = None
- self.floating_x = None
- self.floating_y = None
- self.floating_w = None
- self.floating_h = None
- self.align_x_widget = None
- self.align_y_widget = None
- self.align_monitor_widget = None
- self.align_placement_widget = None
- self.monitor = None
- self.align_x = None
- self.align_y = None
- self.enabled = None
- self.autohide = None
- self.discover = discover
-
- def init_config(self):
- """
- Locate the config and then read
- """
- self.config_dir = os.path.join(xdg_config_home, "discover_overlay")
- os.makedirs(self.config_dir, exist_ok=True)
- self.config_file = os.path.join(self.config_dir, "config.ini")
- self.read_config()
-
- def close_window(self, _a=None, _b=None):
- """
- Helper to ensure we don't lose changes to floating windows
- Hide for later
- """
- if self.placement_window:
- (pos_x, pos_y, width, height) = self.placement_window.get_coords()
-
- self.floating_x = pos_x
- self.floating_y = pos_y
- self.floating_w = width
- self.floating_h = height
- self.overlay.set_floating(True, pos_x, pos_y, width, height)
- self.save_config()
- self.placement_window.close()
- self.placement_window = None
- self.hide()
- return True
-
- def get_monitor_index(self, name):
- """
- Helper function to find the index number of the monitor
- """
- display = Gdk.Display.get_default()
- if "get_n_monitors" in dir(display):
- for i in range(0, display.get_n_monitors()):
- if display.get_monitor(i).get_model() == name:
- return i
- return 0
-
- def get_monitor_obj(self, name):
- """
- Helper function to find the monitor object of the monitor
- """
- display = Gdk.Display.get_default()
- if "get_n_monitors" in dir(display):
- for i in range(0, display.get_n_monitors()):
- if display.get_monitor(i).get_model() == name:
- return display.get_monitor(i)
-
- return None
-
- def present_settings(self):
- """
- Show settings
- """
- self.show_all()
-
- def read_config(self):
- """
- Stub called when settings are needed to be read
- """
-
- def save_config(self):
- """
- Stub called when settings are needed to be written
- """
-
- def change_placement(self, button):
- """
- Placement window button pressed.
- """
- if self.placement_window:
- (pos_x, pos_y, width, height) = self.placement_window.get_coords()
- self.floating_x = pos_x
- self.floating_y = pos_y
- self.floating_w = width
- self.floating_h = height
-
- log.info("Positioned overlay : %s , %s %s x %s", self.floating_x,
- self.floating_y, self.floating_w, self.floating_h)
- self.overlay.set_floating(True, pos_x, pos_y, width, height)
- self.save_config()
- if button:
- button.set_label(_("Place Window"))
- self.placement_window.close()
- self.placement_window = None
- if self.discover.steamos:
- self.discover.show_settings()
- else:
- if self.discover.steamos:
- self.discover.hide_settings()
- if self.overlay.is_wayland or self.discover.steamos:
- self.placement_window = DraggableWindowWayland(
- pos_x=self.floating_x, pos_y=self.floating_y,
- width=self.floating_w, height=self.floating_h,
- message=_("Place & resize this window then press Green!"), settings=self,
- steamos=self.discover.steamos,
- monitor=self.get_monitor_obj(self.monitor))
- else:
- self.placement_window = DraggableWindow(
- pos_x=self.floating_x, pos_y=self.floating_y,
- width=self.floating_w, height=self.floating_h,
- message=_("Place & resize this window then press Save!"), settings=self)
- if button:
- button.set_label(_("Save this position"))
-
- def change_align_type_edge(self, button):
- """
- Alignment setting changed
- """
- if button.get_active():
- self.overlay.set_floating(
- False, self.floating_x, self.floating_y, self.floating_w, self.floating_h)
- self.floating = False
- self.save_config()
-
- # Re-sort the screen
- self.align_x_widget.show()
- self.align_y_widget.show()
- self.align_monitor_widget.show()
- self.align_placement_widget.hide()
-
- def change_align_type_floating(self, button):
- """
- Alignment setting changed
- """
- if button.get_active():
- self.overlay.set_floating(
- True, self.floating_x, self.floating_y, self.floating_w, self.floating_h)
- self.floating = True
- self.save_config()
- self.align_x_widget.hide()
- self.align_y_widget.hide()
- self.align_placement_widget.show()
-
- def change_monitor(self, button):
- """
- Alignment setting changed
- """
- display = Gdk.Display.get_default()
- if "get_monitor" in dir(display):
- mon = display.get_monitor(button.get_active())
- m_s = mon.get_model()
- self.overlay.set_monitor(button.get_active(), mon)
-
- self.monitor = m_s
- self.save_config()
-
- def change_align_x(self, button):
- """
- Alignment setting changed
- """
- self.overlay.set_align_x(button.get_active() == 1)
-
- self.align_x = (button.get_active() == 1)
- self.save_config()
-
- def change_align_y(self, button):
- """
- Alignment setting changed
- """
- self.overlay.set_align_y(button.get_active())
-
- self.align_y = button.get_active()
- self.save_config()
-
- def change_enabled(self, button):
- """
- Overlay active state toggled
- """
- self.overlay.set_enabled(button.get_active())
-
- self.enabled = button.get_active()
- self.save_config()
-
- def change_hide_on_mouseover(self, button):
- """
- Autohide setting changed
- """
- self.overlay.set_hide_on_mouseover(button.get_active())
- self.autohide = button.get_active()
- self.save_config()
diff --git a/discover_overlay/settings_window.py b/discover_overlay/settings_window.py
index d45a102..284845b 100644
--- a/discover_overlay/settings_window.py
+++ b/discover_overlay/settings_window.py
@@ -864,7 +864,7 @@ class MainSettingsWindow():
def core_run_on_startup_changed(self, button):
# TODO Startup
- pass
+ self.autostart_helper.set_autostart(button.get_active())
def core_force_xshape_changed(self, button):
self.config_set("general", "xshape", "%s" % (button.get_active()))
diff --git a/discover_overlay/text_settings.py b/discover_overlay/text_settings.py
deleted file mode 100644
index 71e0d8b..0000000
--- a/discover_overlay/text_settings.py
+++ /dev/null
@@ -1,620 +0,0 @@
-# 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 .
-"""Text setting tab on settings window"""
-import gettext
-import json
-import logging
-import pkg_resources
-from configparser import ConfigParser
-import gi
-from .settings import SettingsWindow
-
-gi.require_version("Gtk", "3.0")
-# pylint: disable=wrong-import-position,wrong-import-order
-from gi.repository import Gtk, Gdk # nopep8
-
-
-GUILD_DEFAULT_VALUE = "0"
-log = logging.getLogger(__name__)
-t = gettext.translation(
- 'default', pkg_resources.resource_filename('discover_overlay', 'locales'), fallback=True)
-_ = t.gettext
-
-
-class TextSettingsWindow(SettingsWindow):
- """Text setting tab on settings window"""
-
- def __init__(self, overlay, discover):
- SettingsWindow.__init__(self, discover)
- self.overlay = overlay
-
- self.placement_window = None
- self.init_config()
- self.list_channels_keys = []
- self.list_channels = {}
- self.list_guilds_keys = []
- self.list_guilds = {}
- self.ignore_channel_change = False
- self.ignore_guild_change = False
- self.channel_lookup = None
- self.channel_model = None
- self.connector = None
- self.guild_lookup = None
- self.guild_model = None
- self.guild_widget = None
- self.align_x = None
- self.align_y = None
- self.monitor = None
- self.floating = None
- self.channel = None
- self.guild = None
- self.font = None
- self.bg_col = None
- self.fg_col = None
- self.popup_style = None
- self.text_time = None
- self.show_attach = None
- self.line_limit = None
- self.enabled = None
-
- self.set_size_request(400, 200)
- self.connect("destroy", self.close_window)
- self.connect("delete-event", self.close_window)
- if overlay:
- self.init_config()
- self.create_gui()
-
- def update_channel_model(self):
- """
- Update the Channel selector.
-
- Populate with all channels from guild.
- Leave empty if guild is unselected
- """
- # Potentially organize channels by their group/parent_id
- # https://discord.com/developers/docs/resources/channel#channel-object-channel-structure
- c_model = Gtk.ListStore(str, bool)
- self.channel_lookup = []
-
- # If a guild is specified, populate channel list with every channel from *just that guild*
- if self.guild != GUILD_DEFAULT_VALUE:
- for position in self.list_channels_keys:
- chan = self.list_channels[position]
- channel_key = chan["id"]
- if chan['guild_id'] == self.guild:
- c_model.append([chan["name"], True])
- self.channel_lookup.append(channel_key)
-
- self.channel_widget.set_model(c_model)
- self.channel_model = c_model
-
- idx = 0
- for channel in self.channel_lookup:
- if channel == self.channel:
- self.ignore_channel_change = True
- self.channel_widget.set_active(idx)
- self.ignore_channel_change = False
- break
- idx += 1
- self.channel_widget.set_sensitive(True)
-
- def add_connector(self, conn):
- """
- Add the discord_connector reference
-
- If the user has previously selected a text channel then tell it to subscribe
- """
- self.connector = conn
- if self.channel:
- self.connector.set_text_channel(self.channel)
-
- def present_settings(self):
- """
- Show contents of tab and update lists
- """
- if not self.overlay:
- return
- self.show_all()
- if not self.floating:
- self.align_x_widget.show()
- self.align_y_widget.show()
- self.align_monitor_widget.show()
- self.align_placement_widget.hide()
- else:
- self.align_x_widget.hide()
- self.align_y_widget.hide()
- self.align_monitor_widget.show()
- self.align_placement_widget.show()
-
- if self.popup_style:
- self.text_time_widget.show()
- self.text_time_label_widget.show()
- else:
- self.text_time_widget.hide()
- self.text_time_label_widget.hide()
- self.update_guild_model()
-
- def update_guild_model(self):
-
- g_model = Gtk.ListStore(str, bool)
- self.guild_lookup = []
-
- for guild in self.guild_list():
- guild_id, guild_name = guild
- self.guild_lookup.append(guild_id)
- g_model.append([guild_name, True])
-
- self.guild_widget.set_model(g_model)
- self.guild_model = g_model
- self.update_channel_model()
-
- idxg = 0
- for guild_id in self.guild_lookup:
- if guild_id == self.guild:
- self.ignore_guild_change = True
- self.guild_widget.set_active(idxg)
- self.ignore_guild_change = False
- break
- idxg += 1
-
- if self.guild is not None:
- self.refresh_channel_list()
- self.guild_widget.set_sensitive(True)
-
- def guild_list(self):
- """
- Return a list of all guilds
- """
- guilds = []
- done = []
- for guild in self.list_guilds.values():
- if not guild["id"] in done:
- done.append(guild["id"])
- guilds.append([guild["id"], guild["name"]])
- return guilds
-
- def set_channels(self, in_list):
- """
- Set the contents of list_channels
- """
- self.list_channels = in_list
- self.list_channels_keys = []
- for (key, _value) in enumerate(in_list):
- # Filter for only text channels
- # https://discord.com/developers/docs/resources/channel#channel-object-channel-types
- if in_list[key] is not None and in_list[key]["type"] == 0:
- self.list_channels_keys.append(key)
- self.list_channels_keys.sort()
- self.update_channel_model()
-
- def set_guilds(self, in_list):
- """
- Set the contents of list_guilds
- """
- self.guild_widget.set_sensitive(True)
- if self.list_guilds == in_list:
- return
- self.list_guilds = in_list
- self.list_guilds_keys = []
- for key in in_list.keys():
- self.list_guilds_keys.append(key)
- self.list_guilds_keys.sort()
- self.update_guild_model()
-
- def read_config(self):
- """
- Read in the 'text' section of the config
- """
- if not self.overlay:
- return
- config = ConfigParser(interpolation=None)
- config.read(self.config_file)
- self.enabled = config.getboolean("text", "enabled", fallback=False)
- self.align_x = config.getboolean("text", "rightalign", fallback=True)
- self.align_y = config.getint("text", "topalign", fallback=2)
- self.monitor = config.get("text", "monitor", fallback="None")
- self.floating = config.getboolean("text", "floating", fallback=True)
- self.floating_x = config.getint("text", "floating_x", fallback=0)
- self.floating_y = config.getint("text", "floating_y", fallback=0)
- self.floating_w = config.getint("text", "floating_w", fallback=400)
- self.floating_h = config.getint("text", "floating_h", fallback=400)
- self.channel = config.get("text", "channel", fallback="0")
- self.guild = config.get("text", "guild", fallback=GUILD_DEFAULT_VALUE)
- self.font = config.get("text", "font", fallback=None)
- self.bg_col = json.loads(config.get(
- "text", "bg_col", fallback="[0.0,0.0,0.0,0.5]"))
- self.fg_col = json.loads(config.get(
- "text", "fg_col", fallback="[1.0,1.0,1.0,1.0]"))
- self.popup_style = config.getboolean(
- "text", "popup_style", fallback=False)
- self.text_time = config.getint("text", "text_time", fallback=30)
- self.show_attach = config.getboolean(
- "text", "show_attach", fallback=True)
- self.line_limit = config.getint("text", "line_limit", fallback=20)
- self.autohide = config.getboolean("text", "autohide", fallback=False)
-
- log.info(
- "Loading saved channel %s", self.channel)
-
- # Pass all of our config over to the overlay
- self.overlay.set_enabled(self.enabled)
- self.overlay.set_align_x(self.align_x)
- self.overlay.set_align_y(self.align_y)
- self.overlay.set_monitor(self.get_monitor_index(
- self.monitor), self.get_monitor_obj(self.monitor))
- self.overlay.set_floating(
- self.floating, self.floating_x, self.floating_y, self.floating_w, self.floating_h)
- self.overlay.set_bg(self.bg_col)
- self.overlay.set_fg(self.fg_col)
- self.overlay.set_popup_style(self.popup_style)
- self.overlay.set_text_time(self.text_time)
- self.overlay.set_show_attach(self.show_attach)
- self.overlay.set_line_limit(self.line_limit)
- self.overlay.set_hide_on_mouseover(self.autohide)
-
- if self.font:
- self.overlay.set_font(self.font)
-
- def save_config(self):
- """
- Save the current settings to the 'text' section of the config
- """
- config = ConfigParser(interpolation=None)
- config.read(self.config_file)
- if not config.has_section("text"):
- config.add_section("text")
-
- config.set("text", "rightalign", "%d" % (int(self.align_x)))
- config.set("text", "topalign", "%d" % (self.align_y))
- config.set("text", "monitor", self.monitor)
- config.set("text", "enabled", "%d" % (int(self.enabled)))
- config.set("text", "floating", "%s" % (int(self.floating)))
- config.set("text", "floating_x", "%s" % (int(self.floating_x)))
- config.set("text", "floating_y", "%s" % (int(self.floating_y)))
- config.set("text", "floating_w", "%s" % (int(self.floating_w)))
- config.set("text", "floating_h", "%s" % (int(self.floating_h)))
- config.set("text", "channel", self.channel)
- config.set("text", "guild", self.guild)
- config.set("text", "bg_col", json.dumps(self.bg_col))
- config.set("text", "fg_col", json.dumps(self.fg_col))
- config.set("text", "popup_style", "%s" % (int(self.popup_style)))
- config.set("text", "text_time", "%s" % (int(self.text_time)))
- config.set("text", "line_limit", "%s" % (int(self.line_limit)))
- config.set("text", "show_attach", "%s" % (int(self.show_attach)))
-
- if self.font:
- config.set("text", "font", self.font)
-
- with open(self.config_file, 'w') as file:
- config.write(file)
-
- def create_gui(self):
- """
- Prepare the gui
- """
- box = Gtk.Grid()
-
- # Enabled
- enabled_label = Gtk.Label.new(_("Enable"))
- enabled_label.set_xalign(0)
- enabled = Gtk.CheckButton.new()
- enabled.set_active(self.enabled)
- enabled.connect("toggled", self.change_enabled)
-
- # Autohide
- autohide_label = Gtk.Label.new(_("Hide on mouseover"))
- autohide = Gtk.CheckButton.new()
- autohide.set_active(self.autohide)
- autohide.connect("toggled", self.change_hide_on_mouseover)
-
- # Popup Style
- popup_style_label = Gtk.Label.new(_("Popup Style"))
- popup_style_label.set_xalign(0)
- popup_style = Gtk.CheckButton.new()
- popup_style.set_active(self.popup_style)
- popup_style.connect("toggled", self.change_popup_style)
-
- # Popup timer
- text_time_label = Gtk.Label.new(_("Popup timer"))
- text_time_label.set_xalign(0)
- text_time_adjustment = Gtk.Adjustment.new(
- self.text_time, 8, 9000, 1, 1, 8)
- text_time = Gtk.SpinButton.new(text_time_adjustment, 0, 0)
- text_time.connect("value-changed", self.change_text_time)
-
- # Font chooser
- font_label = Gtk.Label.new(_("Font"))
- font_label.set_xalign(0)
- font = Gtk.FontButton()
- if self.font:
- font.set_font(self.font)
- font.connect("font-set", self.change_font)
-
- # Colours
- bg_col_label = Gtk.Label.new(_("Background colour"))
- bg_col_label.set_xalign(0)
- bg_col = Gtk.ColorButton.new_with_rgba(
- Gdk.RGBA(self.bg_col[0], self.bg_col[1], self.bg_col[2], self.bg_col[3]))
- fg_col_label = Gtk.Label.new(_("Text colour"))
- fg_col_label.set_xalign(0)
- fg_col = Gtk.ColorButton.new_with_rgba(
- Gdk.RGBA(self.fg_col[0], self.fg_col[1], self.fg_col[2], self.fg_col[3]))
- bg_col.set_use_alpha(True)
- fg_col.set_use_alpha(True)
- bg_col.connect("color-set", self.change_bg)
- fg_col.connect("color-set", self.change_fg)
-
- # Monitor & Alignment
- align_label = Gtk.Label.new(_("Overlay Location"))
- align_label.set_xalign(0)
-
- align_type_box = Gtk.HBox()
- align_type_edge = Gtk.RadioButton.new_with_label(
- None, _("Anchor to edge"))
- align_type_floating = Gtk.RadioButton.new_with_label_from_widget(
- align_type_edge, _("Floating"))
- if self.floating:
- align_type_floating.set_active(True)
- align_type_box.add(align_type_edge)
- align_type_box.add(align_type_floating)
-
- monitor_store = Gtk.ListStore(str)
- display = Gdk.Display.get_default()
- if "get_n_monitors" in dir(display):
- for i in range(0, display.get_n_monitors()):
- monitor_store.append([display.get_monitor(i).get_model()])
- monitor = Gtk.ComboBox.new_with_model(monitor_store)
- monitor.set_active(self.get_monitor_index(self.monitor))
- monitor.connect("changed", self.change_monitor)
- renderer_text = Gtk.CellRendererText()
- monitor.pack_start(renderer_text, True)
- monitor.add_attribute(renderer_text, "text", 0)
-
- align_x_store = Gtk.ListStore(str)
- align_x_store.append([_("Left")])
- align_x_store.append([_("Right")])
- align_x = Gtk.ComboBox.new_with_model(align_x_store)
- align_x.set_active(True if self.align_x else False)
- align_x.connect("changed", self.change_align_x)
- renderer_text = Gtk.CellRendererText()
- align_x.pack_start(renderer_text, True)
- align_x.add_attribute(renderer_text, "text", 0)
-
- align_y_store = Gtk.ListStore(str)
- align_y_store.append([_("Top")])
- align_y_store.append([_("Middle")])
- align_y_store.append([_("Bottom")])
- align_y = Gtk.ComboBox.new_with_model(align_y_store)
- align_y.set_active(self.align_y)
- align_y.connect("changed", self.change_align_y)
- renderer_text = Gtk.CellRendererText()
- align_y.pack_start(renderer_text, True)
- align_y.add_attribute(renderer_text, "text", 0)
-
- align_placement_button = Gtk.Button.new_with_label(_("Place Window"))
-
- align_type_edge.connect("toggled", self.change_align_type_edge)
- align_type_floating.connect("toggled", self.change_align_type_floating)
- align_placement_button.connect("pressed", self.change_placement)
-
- channel_label = Gtk.Label.new(_("Channel"))
- channel_label.set_xalign(0)
- channel = Gtk.ComboBox.new()
-
- channel.connect("changed", self.change_channel)
- renderer_text = Gtk.CellRendererText()
- channel.pack_start(renderer_text, True)
- channel.add_attribute(renderer_text, "text", 0)
- channel.add_attribute(renderer_text, 'sensitive', 1)
-
- channel_refresh = Gtk.Button.new_with_label(_("Refresh list"))
- channel_refresh.connect("pressed", self.refresh_channel_list)
-
- guild_label = Gtk.Label.new(_("Server"))
- guild_label.set_xalign(0)
- guild = Gtk.ComboBox.new()
-
- guild.connect("changed", self.change_guild)
- renderer_text = Gtk.CellRendererText()
- guild.pack_start(renderer_text, True)
- guild.add_attribute(renderer_text, "text", 0)
- guild.add_attribute(renderer_text, 'sensitive', 1)
-
- guild_refresh = Gtk.Button.new_with_label(_("Refresh list"))
- guild_refresh.connect("pressed", self.refresh_guild_list)
-
- # Show Attachments
- show_attach_label = Gtk.Label.new(_("Show Attachments"))
- show_attach_label.set_xalign(0)
- show_attach = Gtk.CheckButton.new()
- show_attach.set_active(self.show_attach)
- show_attach.connect("toggled", self.change_show_attach)
-
- # Line Limit
- line_limit_label = Gtk.Label.new(_("Line limit"))
- line_limit_label.set_xalign(0)
- line_limit_adjustment = Gtk.Adjustment.new(
- self.line_limit, 10, 400, 1, 1, 8)
- line_limit = Gtk.SpinButton.new(line_limit_adjustment, 0, 0)
- line_limit.connect("value-changed", self.change_line_limit)
-
- self.align_x_widget = align_x
- self.align_y_widget = align_y
- self.align_monitor_widget = monitor
- self.align_placement_widget = align_placement_button
- self.guild_widget = guild
- self.channel_widget = channel
- self.text_time_widget = text_time
- self.text_time_label_widget = text_time_label
-
- box.attach(enabled_label, 0, 0, 1, 1)
- box.attach(enabled, 1, 0, 1, 1)
- #box.attach(autohide_label, 0, 1, 1, 1)
- #box.attach(autohide, 1, 1, 1, 1)
- box.attach(popup_style_label, 0, 2, 1, 1)
- box.attach(popup_style, 1, 2, 1, 1)
- box.attach(text_time_label, 0, 3, 1, 1)
- box.attach(text_time, 1, 3, 1, 1)
- box.attach(guild_label, 0, 4, 1, 1)
- box.attach(guild, 1, 4, 1, 1)
- box.attach(guild_refresh, 2, 4, 1, 1)
-
- box.attach(channel_label, 0, 5, 1, 1)
- box.attach(channel, 1, 5, 1, 1)
- box.attach(channel_refresh, 2, 5, 1, 1)
- box.attach(font_label, 0, 6, 1, 1)
- box.attach(font, 1, 6, 1, 1)
- box.attach(fg_col_label, 0, 7, 1, 1)
- box.attach(fg_col, 1, 7, 1, 1)
- box.attach(bg_col_label, 0, 8, 1, 1)
- box.attach(bg_col, 1, 8, 1, 1)
- box.attach(align_label, 0, 9, 1, 5)
- #box.attach(align_type_box, 1, 8, 1, 1)
- box.attach(monitor, 1, 10, 1, 1)
- box.attach(align_x, 1, 11, 1, 1)
- box.attach(align_y, 1, 12, 1, 1)
- box.attach(align_placement_button, 1, 13, 1, 1)
- box.attach(show_attach_label, 0, 14, 1, 1)
- box.attach(show_attach, 1, 14, 1, 1)
- box.attach(line_limit_label, 0, 15, 1, 1)
- box.attach(line_limit, 1, 15, 1, 1)
-
- self.add(box)
-
- def change_font(self, button):
- """
- Font settings changed
- """
- font = button.get_font()
- self.overlay.set_font(font)
-
- self.font = font
- self.save_config()
-
- def change_channel(self, button):
- """
- Channel setting changed
- """
- if self.ignore_channel_change:
- return
-
- channel = self.channel_lookup[button.get_active()]
- self.connector.set_text_channel(channel)
- self.channel = channel
- self.save_config()
-
- def change_guild(self, button):
- """
- Guild setting changed
- """
- if self.ignore_guild_change:
- return
- guild_id = self.guild_lookup[button.get_active()]
- self.guild = guild_id
- self.save_config()
- self.refresh_channel_list()
-
- def refresh_channel_list(self, _button=None):
- self.channel_widget.set_sensitive(False)
- self.connector.request_text_rooms_for_guild(self.guild)
-
- def refresh_guild_list(self, _button=None):
- self.guild_widget.set_sensitive(False)
- self.channel_widget.set_sensitive(False)
- self.connector.req_guilds()
- self.connector.request_text_rooms_for_guild(self.guild)
-
- def change_popup_style(self, button):
- """
- Popup style setting changed
- """
- self.overlay.set_popup_style(button.get_active())
-
- self.popup_style = button.get_active()
- self.save_config()
-
- if button.get_active():
- # We're using popup style
- self.text_time_widget.show()
- self.text_time_label_widget.show()
- else:
- self.text_time_widget.hide()
- self.text_time_label_widget.hide()
-
- def change_text_time(self, button):
- """
- Popup style setting changed
- """
- self.overlay.set_text_time(button.get_value())
-
- self.text_time = button.get_value()
- self.save_config()
-
- def get_channel(self):
- """
- Return selected channel
- """
- return self.channel
-
- def set_channel(self, channel="0"):
- """
- Change the stored channel
- """
- self.channel = channel
- self.save_config()
-
- def get_guild(self):
- """
- Return selected guild
- """
- return self.guild
-
- def change_bg(self, button):
- """
- Background colour changed
- """
- colour = button.get_rgba()
- colour = [colour.red, colour.green, colour.blue, colour.alpha]
- self.overlay.set_bg(colour)
-
- self.bg_col = colour
- self.save_config()
-
- def change_fg(self, button):
- """
- Foreground colour changed
- """
- colour = button.get_rgba()
- colour = [colour.red, colour.green, colour.blue, colour.alpha]
- self.overlay.set_fg(colour)
-
- self.fg_col = colour
- self.save_config()
-
- def change_show_attach(self, button):
- """
- Attachment setting changed
- """
- self.overlay.set_show_attach(button.get_active())
-
- self.show_attach = button.get_active()
- self.save_config()
-
- def change_line_limit(self, button):
- """
- Line limit setting changed
- """
- self.overlay.set_line_limit(button.get_value())
-
- self.line_limit = button.get_value()
- self.save_config()
diff --git a/discover_overlay/voice_settings.py b/discover_overlay/voice_settings.py
deleted file mode 100644
index 7f59951..0000000
--- a/discover_overlay/voice_settings.py
+++ /dev/null
@@ -1,1097 +0,0 @@
-# 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 .
-"""Voice setting tab on settings window"""
-import gettext
-import json
-import pkg_resources
-from configparser import ConfigParser
-import gi
-from .settings import SettingsWindow
-gi.require_version("Gtk", "3.0")
-# pylint: disable=wrong-import-position,wrong-import-order
-from gi.repository import Gtk, Gdk # nopep8
-
-t = gettext.translation(
- 'default', pkg_resources.resource_filename('discover_overlay', 'locales'), fallback=True)
-_ = t.gettext
-
-
-def parse_guild_ids(guild_ids_str):
- """Parse the guild_ids from a str and return them in a list"""
- guild_ids = []
- for guild_id in guild_ids_str.split(","):
- guild_id = guild_id.strip()
- if guild_id != "":
- guild_ids.append(guild_id)
- return guild_ids
-
-
-def guild_ids_to_string(guild_ids):
- """Put the guild ids into a comma seperated string."""
- return ", ".join(str(_id) for _id in guild_ids)
-
-
-class VoiceSettingsWindow(SettingsWindow):
- """Voice setting tab on settings window"""
-
- def __init__(self, overlay, discover):
- SettingsWindow.__init__(self, discover)
- self.overlay = overlay
- self.set_size_request(400, 200)
- self.connect("destroy", self.close_window)
- self.connect("delete-event", self.close_window)
- self.placement_window = None
- self.align_x = None
- self.align_y = None
- self.bg_col = None
- self.fg_col = None
- self.tk_col = None
- self.mt_col = None
- self.mute_bg_col = None
- self.hi_col = None
- self.bo_col = None
- self.avatar_bg_col = None
- self.t_hi_col = None
- self.avatar_size = None
- self.icon_spacing = None
- self.text_padding = None
- self.text_baseline_adj = None
- self.font = None
- self.title_font = None
- self.square_avatar = None
- self.only_speaking = None
- self.highlight_self = None
- self.icon_only = None
- self.monitor = None
- self.vert_edge_padding = None
- self.horz_edge_padding = None
- self.floating = None
- self.order = None
- self.horizontal = None
- self.guild_ids = None
- self.overflow = None
- self.guild_filter_string = ""
- self.warned = False
- self.show_dummy = False
- self.dummy_count = 10
- self.show_connection = None
- self.show_title = None
- self.show_disconnected = None
- self.border_width = 2
- self.icon_transparency = 1.0
- self.fancy_border = False
-
- self.show_advanced = False
-
- self.init_config()
- self.create_gui()
-
- def present_settings(self):
- """
- Show tab
- """
- self.show_all()
- if not self.floating:
- self.align_x_widget.show()
- self.align_y_widget.show()
- self.align_monitor_widget.show()
- self.align_placement_widget.hide()
- else:
- self.align_x_widget.hide()
- self.align_y_widget.hide()
- self.align_monitor_widget.show()
- self.align_placement_widget.show()
- if not self.show_advanced:
- self.avatar_box.hide()
- self.dummy_box.hide()
- self.alignment_box.hide()
-
- def read_config(self):
- """
- Read 'main' section of the config file
- """
- config = ConfigParser(interpolation=None)
- config.read(self.config_file)
- self.align_x = config.getboolean("main", "rightalign", fallback=False)
- self.align_y = config.getint("main", "topalign", fallback=1)
- self.bg_col = json.loads(config.get(
- "main", "bg_col", fallback="[0.0,0.0,0.0,0.5]"))
- self.fg_col = json.loads(config.get(
- "main", "fg_col", fallback="[1.0,1.0,1.0,1.0]"))
- self.t_hi_col = json.loads(config.get(
- "main", "fg_hi_col", fallback="[1.0,1.0,1.0,1.0]"))
- self.tk_col = json.loads(config.get(
- "main", "tk_col", fallback="[0.0,0.7,0.0,1.0]"))
- self.mt_col = json.loads(config.get(
- "main", "mt_col", fallback="[0.6,0.0,0.0,1.0]"))
- self.mute_bg_col = json.loads(config.get(
- "main", "mt_bg_col", fallback="[0.0,0.0,0.0,0.5]"))
- self.hi_col = json.loads(config.get(
- "main", "hi_col", fallback="[0.0,0.0,0.0,0.5]"))
- self.bo_col = json.loads(config.get(
- "main", "bo_col", fallback="[0.0,0.0,0.0,0.0]"))
- self.avatar_bg_col = json.loads(config.get(
- "main", "avatar_bg_col", fallback="[0.0,0.0,0.0,0.0]"))
- self.avatar_size = config.getint("main", "avatar_size", fallback=48)
- self.icon_spacing = config.getint("main", "icon_spacing", fallback=8)
- self.text_padding = config.getint("main", "text_padding", fallback=6)
- self.text_baseline_adj = config.getint(
- "main", "text_baseline_adj", fallback=0)
- self.font = config.get("main", "font", fallback=None)
- self.title_font = config.get("main", "title_font", fallback=None)
- self.square_avatar = config.getboolean(
- "main", "square_avatar", fallback=True)
- self.only_speaking = config.getboolean(
- "main", "only_speaking", fallback=False)
- self.highlight_self = config.getboolean(
- "main", "highlight_self", fallback=False)
- self.icon_only = config.getboolean(
- "main", "icon_only", fallback=False)
- self.monitor = config.get("main", "monitor", fallback="None")
- self.vert_edge_padding = config.getint(
- "main", "vert_edge_padding", fallback=0)
- self.horz_edge_padding = config.getint(
- "main", "horz_edge_padding", fallback=0)
- self.floating = config.getboolean("main", "floating", fallback=False)
- self.floating_x = config.getint("main", "floating_x", fallback=0)
- self.floating_y = config.getint("main", "floating_y", fallback=0)
- self.floating_w = config.getint("main", "floating_w", fallback=400)
- self.floating_h = config.getint("main", "floating_h", fallback=400)
- self.order = config.getint("main", "order", fallback=0)
- self.autohide = config.getboolean("text", "autohide", fallback=False)
- self.horizontal = config.getboolean(
- "main", "horizontal", fallback=False)
- self.guild_ids = parse_guild_ids(
- config.get("main", "guild_ids", fallback=""))
- self.overflow = config.getint("main", "overflow", fallback=0)
- self.show_connection = config.getboolean(
- "main", "show_connection", fallback=False)
- self.show_title = config.getboolean(
- "main", "show_title", fallback=False)
- self.show_disconnected = config.getboolean(
- "main", "show_disconnected", fallback=False)
- self.border_width = config.getint("main", "border_width", fallback=2)
- self.icon_transparency = config.getfloat(
- "main", "icon_transparency", fallback=1.0)
- self.fancy_border = config.getboolean("main",
- "fancy_border", fallback=True)
-
- # Pass all of our config over to the overlay
- self.overlay.set_align_x(self.align_x)
- self.overlay.set_align_y(self.align_y)
- self.overlay.set_bg(self.bg_col)
- self.overlay.set_fg(self.fg_col)
- self.overlay.set_tk(self.tk_col)
- self.overlay.set_mt(self.mt_col)
- self.overlay.set_mute_bg(self.mute_bg_col)
- self.overlay.set_hi(self.hi_col)
- self.overlay.set_bo(self.bo_col)
- self.overlay.set_avatar_bg_col(self.avatar_bg_col)
- self.overlay.set_fg_hi(self.t_hi_col)
- self.overlay.set_avatar_size(self.avatar_size)
- self.overlay.set_icon_spacing(self.icon_spacing)
- self.overlay.set_text_padding(self.text_padding)
- self.overlay.set_text_baseline_adj(self.text_baseline_adj)
- self.overlay.set_square_avatar(self.square_avatar)
- self.overlay.set_only_speaking(self.only_speaking)
- self.overlay.set_highlight_self(self.highlight_self)
- self.overlay.set_icon_only(self.icon_only)
- self.overlay.set_monitor(self.get_monitor_index(
- self.monitor), self.get_monitor_obj(self.monitor))
- self.overlay.set_vert_edge_padding(self.vert_edge_padding)
- self.overlay.set_horz_edge_padding(self.horz_edge_padding)
- self.overlay.set_order(self.order)
- self.overlay.set_hide_on_mouseover(self.autohide)
- self.overlay.set_horizontal(self.horizontal)
- self.overlay.set_guild_ids(self.guild_ids)
- self.overlay.set_overflow(self.overflow)
- self.overlay.set_enabled(True)
- self.overlay.set_show_connection(self.show_connection)
- self.overlay.set_show_title(self.show_title)
- self.overlay.set_show_disconnected(self.show_disconnected)
- self.overlay.set_border_width(self.border_width)
- self.overlay.set_icon_transparency(self.icon_transparency)
- self.overlay.set_fancy_border(self.fancy_border)
-
- self.overlay.set_floating(
- self.floating, self.floating_x, self.floating_y, self.floating_w, self.floating_h)
-
- if self.font:
- self.overlay.set_font(self.font)
- if self.title_font:
- self.overlay.set_title_font(self.title_font)
-
- def save_config(self):
- """
- Write settings out to the 'main' section of the config file
- """
- config = ConfigParser(interpolation=None)
- config.read(self.config_file)
- if not config.has_section("main"):
- config.add_section("main")
-
- config.set("main", "rightalign", "%d" % (int(self.align_x)))
- config.set("main", "topalign", "%d" % (self.align_y))
- config.set("main", "bg_col", json.dumps(self.bg_col))
- config.set("main", "fg_col", json.dumps(self.fg_col))
- config.set("main", "tk_col", json.dumps(self.tk_col))
- config.set("main", "mt_col", json.dumps(self.mt_col))
- config.set("main", "mt_bg_col", json.dumps(self.mute_bg_col))
- config.set("main", "hi_col", json.dumps(self.hi_col))
- config.set("main", "fg_hi_col", json.dumps(self.t_hi_col))
- config.set("main", "bo_col", json.dumps(self.bo_col))
- config.set("main", "avatar_bg_col", json.dumps(self.avatar_bg_col))
-
- config.set("main", "avatar_size", "%d" % (self.avatar_size))
- config.set("main", "icon_spacing", "%d" % (self.icon_spacing))
- config.set("main", "text_padding", "%d" % (self.text_padding))
- config.set("main", "text_baseline_adj", "%d" %
- (self.text_baseline_adj))
- if self.font:
- config.set("main", "font", self.font)
- if self.title_font:
- config.set("main", "title_font", self.title_font)
- config.set("main", "square_avatar", "%d" % (int(self.square_avatar)))
- config.set("main", "only_speaking", "%d" % (int(self.only_speaking)))
- config.set("main", "highlight_self", "%d" % (int(self.highlight_self)))
- config.set("main", "icon_only", "%d" % (int(self.icon_only)))
- config.set("main", "monitor", self.monitor)
- config.set("main", "vert_edge_padding", "%d" %
- (self.vert_edge_padding))
- config.set("main", "horz_edge_padding", "%d" %
- (self.horz_edge_padding))
- config.set("main", "floating", "%s" % (int(self.floating)))
- config.set("main", "floating_x", "%s" % (int(self.floating_x)))
- config.set("main", "floating_y", "%s" % (int(self.floating_y)))
- config.set("main", "floating_w", "%s" % (int(self.floating_w)))
- config.set("main", "floating_h", "%s" % (int(self.floating_h)))
- config.set("main", "order", "%s" % (self.order))
- config.set("main", "horizontal", "%s" % (self.horizontal))
- config.set("main", "guild_ids", "%s" %
- guild_ids_to_string(self.guild_ids))
- config.set("main", "overflow", "%s" % (int(self.overflow)))
- config.set("main", "show_connection", "%d" %
- (int(self.show_connection)))
- config.set("main", "show_title", "%d" % (int(self.show_title)))
- config.set("main", "show_disconnected", "%d" %
- (int(self.show_disconnected)))
- config.set("main", "border_width", "%s" % (int(self.border_width)))
- config.set("main", "icon_transparency", "%.2f" %
- (self.icon_transparency))
- config.set("main", "fancy_border", "%d" % (int(self.fancy_border)))
-
- with open(self.config_file, 'w') as file:
- config.write(file)
-
- def create_gui(self):
- """
- Prepare the gui
- """
- outer_box = Gtk.Grid()
- outer_box.set_row_spacing(64)
- outer_box.set_column_spacing(64)
-
- monitor_box = Gtk.Grid()
- alignment_box = Gtk.Grid(row_homogeneous=True)
- colour_box = Gtk.Grid(row_homogeneous=True, column_homogeneous=True)
- avatar_box = Gtk.Grid(row_homogeneous=True)
- dummy_box = Gtk.Grid(row_homogeneous=True)
-
- self.avatar_box = avatar_box
- self.dummy_box = dummy_box
- self.alignment_box = alignment_box
-
- colour_box.set_row_spacing(8)
- colour_box.set_column_spacing(8)
-
- avatar_box.set_column_spacing(8)
- alignment_box.set_column_spacing(8)
-
- outer_box.attach(monitor_box, 0, 0, 1, 1)
- outer_box.attach(alignment_box, 0, 1, 1, 1)
- outer_box.attach(colour_box, 1, 0, 1, 1)
- outer_box.attach(avatar_box, 1, 1, 1, 1)
- outer_box.attach(dummy_box, 0, 2, 2, 1)
-
- # Advanced
- advanced_button = Gtk.Button.new_with_label(_("Show Advanced Options"))
- advanced_button.connect("pressed", self.toggle_advanced)
-
- monitor_box.attach(advanced_button, 0, 10, 2,1)
-
- # Autohide
- # autohide_label = Gtk.Label.new("Hide on mouseover")
- # autohide = Gtk.CheckButton.new()
- # autohide.set_active(self.autohide)
- # autohide.connect("toggled", self.change_hide_on_mouseover)
-
- # Font chooser
- font_label = Gtk.Label.new(_("Font"))
- font_label.set_xalign(0)
- font = Gtk.FontButton()
- if self.font:
- font.set_font(self.font)
- font.connect("font-set", self.change_font)
- alignment_box.attach(font_label, 0, 0, 1, 1)
- alignment_box.attach(font, 1, 0, 1, 1)
-
- # Title Font chooser
- title_font_label = Gtk.Label.new(_("Title Font"))
- title_font_label.set_xalign(0)
- title_font = Gtk.FontButton()
- if self.title_font:
- title_font.set_font(self.title_font)
- title_font.connect("font-set", self.change_title_font)
- alignment_box.attach(title_font_label, 0, 1, 1, 1)
- alignment_box.attach(title_font, 1, 1, 1, 1)
-
- # Colours
- bg_col = Gtk.ColorButton.new_with_rgba(
- Gdk.RGBA(self.bg_col[0], self.bg_col[1], self.bg_col[2], self.bg_col[3]))
- fg_col = Gtk.ColorButton.new_with_rgba(
- Gdk.RGBA(self.fg_col[0], self.fg_col[1], self.fg_col[2], self.fg_col[3]))
- tk_col = Gtk.ColorButton.new_with_rgba(
- Gdk.RGBA(self.tk_col[0], self.tk_col[1], self.tk_col[2], self.tk_col[3]))
- mt_col = Gtk.ColorButton.new_with_rgba(
- Gdk.RGBA(self.mt_col[0], self.mt_col[1], self.mt_col[2], self.mt_col[3]))
- mute_bg_col = Gtk.ColorButton.new_with_rgba(
- Gdk.RGBA(self.mute_bg_col[0], self.mute_bg_col[1], self.mute_bg_col[2], self.mute_bg_col[3]))
- hi_col = Gtk.ColorButton.new_with_rgba(
- Gdk.RGBA(
- self.hi_col[0],
- self.hi_col[1],
- self.hi_col[2],
- self.hi_col[3]))
- t_hi_col = Gtk.ColorButton.new_with_rgba(
- Gdk.RGBA(
- self.t_hi_col[0],
- self.t_hi_col[1],
- self.t_hi_col[2],
- self.t_hi_col[3]))
- bo_col = Gtk.ColorButton.new_with_rgba(
- Gdk.RGBA(
- self.bo_col[0],
- self.bo_col[1],
- self.bo_col[2],
- self.bo_col[3]
- )
- )
- avatar_bg_col = Gtk.ColorButton.new_with_rgba(
- Gdk.RGBA(
- self.avatar_bg_col[0],
- self.avatar_bg_col[1],
- self.avatar_bg_col[2],
- self.avatar_bg_col[3]
-
- )
- )
- bg_col.set_use_alpha(True)
- fg_col.set_use_alpha(True)
- tk_col.set_use_alpha(True)
- mt_col.set_use_alpha(True)
- mute_bg_col.set_use_alpha(True)
- hi_col.set_use_alpha(True)
- t_hi_col.set_use_alpha(True)
- bo_col.set_use_alpha(True)
- avatar_bg_col.set_use_alpha(True)
- bg_col.connect("color-set", self.change_bg)
- fg_col.connect("color-set", self.change_fg)
- tk_col.connect("color-set", self.change_tk)
- mt_col.connect("color-set", self.change_mt)
- mute_bg_col.connect("color-set", self.change_mute_bg)
- hi_col.connect("color-set", self.change_hi)
- t_hi_col.connect("color-set", self.change_t_hi)
- bo_col.connect("color-set", self.change_bo)
- avatar_bg_col.connect("color-set", self.change_avatar_bg)
-
- text_label = Gtk.Label.new(_("Foreground"))
- background_label = Gtk.Label.new(_("Background"))
- talking_label = Gtk.Label.new(_("Talking"))
- idle_label = Gtk.Label.new(_("Idle"))
- border_label = Gtk.Label.new(_("Border"))
- mute_label = Gtk.Label.new(_("Mute"))
- avatar_label = Gtk.Label.new(_("Avatar"))
-
- colour_box.attach(text_label, 1, 0, 1, 1)
- colour_box.attach(background_label, 2, 0, 1, 1)
- colour_box.attach(border_label, 3, 0, 1, 1)
- colour_box.attach(talking_label, 0, 1, 1, 1)
- colour_box.attach(idle_label, 0, 2, 1, 1)
- colour_box.attach(mute_label, 0, 4, 1, 1)
- colour_box.attach(avatar_label, 0, 5, 1, 1)
-
- colour_box.attach(bg_col, 2, 2, 1, 1)
- colour_box.attach(hi_col, 2, 1, 1, 1)
- colour_box.attach(fg_col, 1, 2, 1, 1)
- colour_box.attach(t_hi_col, 1, 1, 1, 1)
- colour_box.attach(tk_col, 3, 1, 1, 1)
- colour_box.attach(bo_col, 3, 2, 1, 1)
- colour_box.attach(mute_bg_col, 2, 4, 1, 1)
- colour_box.attach(mt_col, 1, 4, 1, 1)
- colour_box.attach(avatar_bg_col, 2, 5, 1, 1)
-
- # Monitor & Alignment
- align_label = Gtk.Label.new(_("Overlay Location"))
-
- align_type_box = Gtk.HBox()
- align_type_edge = Gtk.RadioButton.new_with_label(
- None, _("Anchor to edge"))
- align_type_floating = Gtk.RadioButton.new_with_label_from_widget(
- align_type_edge, _("Floating"))
- if self.floating:
- align_type_floating.set_active(True)
- align_type_box.add(align_type_edge)
- align_type_box.add(align_type_floating)
-
- monitor_store = Gtk.ListStore(str)
- display = Gdk.Display.get_default()
- if "get_n_monitors" in dir(display):
- for i in range(0, display.get_n_monitors()):
- monitor_store.append([display.get_monitor(i).get_model()])
- monitor = Gtk.ComboBox.new_with_model(monitor_store)
- monitor.set_active(self.get_monitor_index(self.monitor))
- monitor.connect("changed", self.change_monitor)
- renderer_text = Gtk.CellRendererText()
- monitor.pack_start(renderer_text, True)
- monitor.add_attribute(renderer_text, "text", 0)
-
- self.align_x_store = Gtk.ListStore(str)
- self.align_x_store.append([_("Left")])
- self.align_x_store.append([_("Right")])
- align_x = Gtk.ComboBox.new_with_model(self.align_x_store)
- align_x.set_active(True if self.align_x else False)
- align_x.connect("changed", self.change_align_x)
- renderer_text = Gtk.CellRendererText()
- align_x.pack_start(renderer_text, True)
- align_x.add_attribute(renderer_text, "text", 0)
-
- self.align_y_store = Gtk.ListStore(str)
- self.align_y_store.append([_("Top")])
- self.align_y_store.append([_("Middle")])
- self.align_y_store.append([_("Bottom")])
- align_y = Gtk.ComboBox.new_with_model(self.align_y_store)
- align_y.set_active(self.align_y)
- align_y.connect("changed", self.change_align_y)
- renderer_text = Gtk.CellRendererText()
- align_y.pack_start(renderer_text, True)
- align_y.add_attribute(renderer_text, "text", 0)
-
- align_placement_button = Gtk.Button.new_with_label(_("Place Window"))
-
- align_type_edge.connect("toggled", self.change_align_type_edge)
- align_type_floating.connect("toggled", self.change_align_type_floating)
- align_placement_button.connect("pressed", self.change_placement)
-
- self.align_x_widget = align_x
- self.align_y_widget = align_y
- self.align_monitor_widget = monitor
- self.align_placement_widget = align_placement_button
-
- monitor_box.attach(align_label, 0, 0, 2, 1)
- monitor_box.attach(align_type_box, 1, 1, 1, 1)
- monitor_box.attach(monitor, 1, 2, 1, 1)
- monitor_box.attach(align_x, 1, 3, 1, 1)
- monitor_box.attach(align_y, 1, 4, 1, 1)
- monitor_box.attach(align_placement_button, 1, 5, 1, 1)
-
- # Avatar size
- avatar_size_label = Gtk.Label.new(_("Avatar size"))
- avatar_size_label.set_xalign(0)
- avatar_adjustment = Gtk.Adjustment.new(
- self.avatar_size, 8, 128, 1, 1, 8)
- avatar_size = Gtk.SpinButton.new(avatar_adjustment, 0, 0)
- avatar_size.connect("value-changed", self.change_avatar_size)
-
- avatar_box.attach(avatar_size_label, 0, 1, 1, 1)
- avatar_box.attach(avatar_size, 1, 1, 1, 1)
-
- # Avatar shape
- square_avatar_label = Gtk.Label.new(_("Square Avatar"))
- square_avatar_label.set_xalign(0)
- square_avatar = Gtk.CheckButton.new()
- square_avatar.set_active(self.square_avatar)
- square_avatar.connect("toggled", self.change_square_avatar)
-
- avatar_box.attach(square_avatar_label, 0, 3, 1, 1)
- avatar_box.attach(square_avatar, 1, 3, 1, 1)
-
- # Fancy Avatar shapes
- fancy_avatar_label = Gtk.Label.new(_("Fancy Avatar shapes"))
- fancy_avatar_label.set_xalign(0)
- fancy_avatar = Gtk.CheckButton.new()
- fancy_avatar.set_active(self.fancy_border)
- fancy_avatar.connect("toggled", self.change_fancy_avatar)
-
- avatar_box.attach(fancy_avatar_label, 0, 4, 1, 1)
- avatar_box.attach(fancy_avatar, 1 , 4, 1, 1)
-
- # Display icon only
- icon_only_label = Gtk.Label.new(_("Display Icon Only"))
- icon_only_label.set_xalign(0)
- icon_only = Gtk.CheckButton.new()
- icon_only.set_active(self.icon_only)
- icon_only.connect("toggled", self.change_icon_only)
-
- avatar_box.attach(icon_only_label, 0, 2, 1, 1)
- avatar_box.attach(icon_only, 1, 2, 1, 1)
-
- # Display Speaker only
- only_speaking_label = Gtk.Label.new(_("Display Speakers Only"))
- only_speaking_label.set_xalign(0)
- only_speaking = Gtk.CheckButton.new()
- only_speaking.set_active(self.only_speaking)
- only_speaking.connect("toggled", self.change_only_speaking)
-
- alignment_box.attach(only_speaking_label, 0, 9, 1, 1)
- alignment_box.attach(only_speaking, 1, 9, 1, 1)
-
- # Highlight self
- highlight_self_label = Gtk.Label.new(_("Highlight Self"))
- highlight_self_label.set_xalign(0)
- highlight_self = Gtk.CheckButton.new()
- highlight_self.set_active(self.highlight_self)
- highlight_self.connect("toggled", self.change_highlight_self)
-
- alignment_box.attach(highlight_self_label, 0, 8, 1, 1)
- alignment_box.attach(highlight_self, 1, 8, 1, 1)
-
- # Order avatars
- order_label = Gtk.Label.new(_("Order Avatars By"))
- order_label.set_xalign(0)
- order_store = Gtk.ListStore(str)
- order_store.append([_("Alphabetically")])
- order_store.append([_("ID")])
- order_store.append([_("Last Spoken")])
- order = Gtk.ComboBox.new_with_model(order_store)
- order.set_active(self.order)
- order.connect("changed", self.change_order)
- renderer_text = Gtk.CellRendererText()
- order.pack_start(renderer_text, True)
- order.add_attribute(renderer_text, "text", 0)
-
- avatar_box.attach(order_label, 0, 6, 1, 1)
- avatar_box.attach(order, 1, 6, 1, 1)
-
- # Icon spacing
- icon_spacing_label = Gtk.Label.new(_("Icon Spacing"))
- icon_spacing_label.set_xalign(0)
- icon_spacing_adjustment = Gtk.Adjustment.new(
- self.icon_spacing, 0, 64, 1, 1, 0)
- icon_spacing = Gtk.SpinButton.new(icon_spacing_adjustment, 0, 0)
- icon_spacing.connect("value-changed", self.change_icon_spacing)
-
- alignment_box.attach(icon_spacing_label, 0, 2, 1, 1)
- alignment_box.attach(icon_spacing, 1, 2, 1, 1)
-
- # Text padding
- text_padding_label = Gtk.Label.new(_("Text Padding"))
- text_padding_label.set_xalign(0)
- text_padding_adjustment = Gtk.Adjustment.new(
- self.text_padding, 0, 64, 1, 1, 0)
- text_padding = Gtk.SpinButton.new(text_padding_adjustment, 0, 0)
- text_padding.connect("value-changed", self.change_text_padding)
-
- alignment_box.attach(text_padding_label, 0, 3, 1, 1)
- alignment_box.attach(text_padding, 1, 3, 1, 1)
-
- # Text Baseline Adjustment
- text_baseline_label = Gtk.Label.new(_("Text Vertical Offset"))
- text_baseline_label.set_xalign(0)
- text_baseline_adjustment = Gtk.Adjustment.new(
- self.text_baseline_adj, -32, 32, 1, 1, 0)
- text_baseline = Gtk.SpinButton.new(text_baseline_adjustment, 0, 0)
- text_baseline.connect("value-changed", self.change_text_baseline)
-
- alignment_box.attach(text_baseline_label, 0, 4, 1, 1)
- alignment_box.attach(text_baseline, 1, 4, 1, 1)
-
- # Edge padding
- vert_edge_padding_label = Gtk.Label.new(_("Vertical Edge Padding"))
- vert_edge_padding_label.set_xalign(0)
- vert_edge_padding_adjustment = Gtk.Adjustment.new(
- self.vert_edge_padding, 0, 1000, 1, 1, 0)
- vert_edge_padding = Gtk.SpinButton.new(
- vert_edge_padding_adjustment, 0, 0)
- vert_edge_padding.connect(
- "value-changed", self.change_vert_edge_padding)
-
- alignment_box.attach(vert_edge_padding_label, 0, 5, 1, 1)
- alignment_box.attach(vert_edge_padding, 1, 5, 1, 1)
-
- horz_edge_padding_label = Gtk.Label.new(_("Horizontal Edge Padding"))
- horz_edge_padding_adjustment = Gtk.Adjustment.new(
- self.horz_edge_padding, 0, 1000, 1, 1, 0)
- horz_edge_padding = Gtk.SpinButton.new(
- horz_edge_padding_adjustment, 0, 0)
- horz_edge_padding.connect(
- "value-changed", self.change_horz_edge_padding)
-
- alignment_box.attach(horz_edge_padding_label, 0, 6, 1, 1)
- alignment_box.attach(horz_edge_padding, 1, 6, 1, 1)
-
- # Border width
- border_width_label = Gtk.Label.new(_("Talking border width"))
- border_width_label.set_xalign(0)
- border_width_adjustment = Gtk.Adjustment.new(
- self.border_width, 2, 100, 1, 1, 0)
- border_width = Gtk.SpinButton.new(border_width_adjustment, 0, 0)
- border_width.connect("value-changed", self.change_border_width)
-
- avatar_box.attach(border_width_label, 0, 7, 1, 1)
- avatar_box.attach(border_width, 1, 7, 1, 1)
-
- # Icon Transparency
- icon_transparency_label = Gtk.Label.new(_("Icon Opacity"))
- icon_transparency_label.set_xalign(0)
- icon_transparency_adjustment = Gtk.Adjustment.new(
- self.icon_transparency, 0.5, 1.0, 0.01, 0.1, 0.0)
- icon_transparency = Gtk.HScale.new(icon_transparency_adjustment)
- icon_transparency.connect(
- "value-changed", self.change_icon_transparency)
-
- avatar_box.attach(icon_transparency_label, 0, 0, 1, 1)
- avatar_box.attach(icon_transparency, 1, 0, 1, 1)
-
- # Display icon horizontally
- horizontal_label = Gtk.Label.new(_("Display Horizontally"))
- horizontal_label.set_xalign(0)
- horizontal = Gtk.CheckButton.new()
- horizontal.set_active(self.horizontal)
- horizontal.connect("toggled", self.change_horizontal)
-
- alignment_box.attach(horizontal_label, 0, 7, 1, 1)
- alignment_box.attach(horizontal, 1, 7, 1, 1)
-
- # Overflow
- overflow_label = Gtk.Label.new(_("Overflow style"))
- overflow_label.set_xalign(0)
- overflow_store = Gtk.ListStore(str)
- overflow_store.append([_("None")])
- overflow_store.append([_("Wrap")])
- overflow_store.append([_("Shrink")])
- overflow = Gtk.ComboBox.new_with_model(overflow_store)
- overflow.set_active(self.overflow)
- overflow.connect("changed", self.change_overflow)
- renderer_text = Gtk.CellRendererText()
- overflow.pack_start(renderer_text, True)
- overflow.add_attribute(renderer_text, "text", 0)
-
- avatar_box.attach(overflow_label, 0, 8, 1, 1)
- avatar_box.attach(overflow, 1, 8, 1, 1)
-
- # Show Title
- show_title_label = Gtk.Label.new(_("Show Title"))
- show_title_label.set_xalign(0)
- show_title = Gtk.CheckButton.new()
- show_title.set_active(self.show_title)
- show_title.connect("toggled", self.change_show_title)
-
- avatar_box.attach(show_title_label, 0, 9, 1, 1)
- avatar_box.attach(show_title, 1, 9, 1, 1)
-
- # Show Connection
- show_connection_label = Gtk.Label.new(_("Show Connection Status"))
- show_connection_label.set_xalign(0)
- show_connection = Gtk.CheckButton.new()
- show_connection.set_active(self.show_connection)
- show_connection.connect("toggled", self.change_show_connection)
-
- avatar_box.attach(show_connection_label, 0, 10, 1, 1)
- avatar_box.attach(show_connection, 1, 10, 1, 1)
-
- # Show Disconnected
- show_disconnected_label = Gtk.Label.new(_("Show while disconnected"))
- show_disconnected_label.set_xalign(0)
- show_disconnected = Gtk.CheckButton.new()
- show_disconnected.set_active(self.show_disconnected)
- show_disconnected.connect("toggled", self.change_show_disconnected)
-
- avatar_box.attach(show_disconnected_label, 0, 11, 1, 1)
- avatar_box.attach(show_disconnected, 1, 11, 1, 1)
-
- # use dummy
- dummy_label = Gtk.Label.new(_("Show test content"))
- dummy_label.set_xalign(0)
- dummy = Gtk.CheckButton.new()
- dummy.set_active(self.show_dummy)
- dummy.connect("toggled", self.change_dummy_data)
-
- dummy_box.attach(dummy_label, 0, 0, 1, 1)
- dummy_box.attach(dummy, 1, 0, 1, 1)
-
- # Dummy count
- dummy_count_label = Gtk.Label.new(_("Dummy count"))
- dummy_count_label.set_xalign(0)
- dummy_count_adjustment = Gtk.Adjustment.new(
- self.dummy_count, 0, 100, 1, 1, 0)
- dummy_count = Gtk.SpinButton.new(
- dummy_count_adjustment, 0, 0)
- dummy_count.connect(
- "value-changed", self.change_dummy_count)
-
- dummy_box.attach(dummy_count_label, 2, 0, 1, 1)
- dummy_box.attach(dummy_count, 3, 0, 1, 1)
-
- self.add(outer_box)
-
- self.set_orientated_names()
-
- def change_font(self, button):
- """
- Font settings changed
- """
- font = button.get_font()
- self.overlay.set_font(font)
-
- self.font = font
- self.save_config()
-
- def change_title_font(self, button):
- """
- Font settings changed
- """
- title_font = button.get_font()
- self.overlay.set_title_font(title_font)
-
- self.title_font = title_font
- self.save_config()
-
- def change_bg(self, button):
- """
- Background colour changed
- """
- colour = button.get_rgba()
- colour = [colour.red, colour.green, colour.blue, colour.alpha]
- self.overlay.set_bg(colour)
-
- self.bg_col = colour
- self.save_config()
-
- def change_fg(self, button):
- """
- Text colour changed
- """
- colour = button.get_rgba()
- colour = [colour.red, colour.green, colour.blue, colour.alpha]
- self.overlay.set_fg(colour)
-
- self.fg_col = colour
- self.save_config()
-
- def change_tk(self, button):
- """
- Talking colour changed
- """
- colour = button.get_rgba()
- colour = [colour.red, colour.green, colour.blue, colour.alpha]
- self.overlay.set_tk(colour)
-
- self.tk_col = colour
- self.save_config()
-
- def change_mt(self, button):
- """
- Mute colour changed
- """
- colour = button.get_rgba()
- colour = [colour.red, colour.green, colour.blue, colour.alpha]
- self.overlay.set_mt(colour)
-
- self.mt_col = colour
- self.save_config()
-
- def change_mute_bg(self, button):
- """
- Mute background colour changed
- """
- colour = button.get_rgba()
- colour = [colour.red, colour.green, colour.blue, colour.alpha]
- self.overlay.set_mute_bg(colour)
-
- self.mute_bg_col = colour
- self.save_config()
-
- def change_avatar_bg(self, button):
- """
- Avatar background colour changed
- """
- colour = button.get_rgba()
- colour = [colour.red, colour.green, colour.blue, colour.alpha]
- self.overlay.set_avatar_bg_col(colour)
-
- self.avatar_bg_col = colour
- self.save_config()
-
- def change_hi(self, button):
- """
- Speaking background colour changed
- """
- colour = button.get_rgba()
- colour = [colour.red, colour.green, colour.blue, colour.alpha]
- self.overlay.set_hi(colour)
-
- self.hi_col = colour
- self.save_config()
-
- def change_t_hi(self, button):
- """
- Speaking background colour changed
- """
- colour = button.get_rgba()
- colour = [colour.red, colour.green, colour.blue, colour.alpha]
- self.overlay.set_fg_hi(colour)
-
- self.t_hi_col = colour
- self.save_config()
-
- def change_bo(self, button):
- """
- Idle border colour changed
- """
- colour = button.get_rgba()
- colour = [colour.red, colour.green, colour.blue, colour.alpha]
- self.overlay.set_bo(colour)
-
- self.bo_col = colour
- self.save_config()
-
- def change_avatar_size(self, button):
- """
- Avatar size setting changed
- """
- self.overlay.set_avatar_size(button.get_value())
-
- self.avatar_size = button.get_value()
- self.save_config()
-
- def change_icon_spacing(self, button):
- """
- Inter-icon spacing changed
- """
- self.overlay.set_icon_spacing(button.get_value())
-
- self.icon_spacing = int(button.get_value())
- self.save_config()
-
- def change_text_padding(self, button):
- """
- Text padding changed
- """
- self.overlay.set_text_padding(button.get_value())
-
- self.text_padding = button.get_value()
- self.save_config()
-
- def change_text_baseline(self, button):
- """
- Text baseline changed
- """
- self.overlay.set_text_baseline_adj(button.get_value())
-
- self.text_baseline_adj = button.get_value()
- self.save_config()
-
- def change_vert_edge_padding(self, button):
- """
- Vertical padding changed
- """
- self.overlay.set_vert_edge_padding(button.get_value())
-
- self.vert_edge_padding = button.get_value()
- self.save_config()
-
- def change_horz_edge_padding(self, button):
- """
- Horizontal padding changed
- """
- self.overlay.set_horz_edge_padding(button.get_value())
-
- self.horz_edge_padding = button.get_value()
- self.save_config()
-
- def change_square_avatar(self, button):
- """
- Square avatar setting changed
- """
- self.overlay.set_square_avatar(button.get_active())
-
- self.square_avatar = button.get_active()
- self.save_config()
-
- def change_fancy_avatar(self, button):
- """
- Fancy avatar border shapes changed
- """
- self.overlay.set_fancy_border(button.get_active())
- self.fancy_avatar = button.get_active()
- self.save_config()
-
- def change_only_speaking(self, button):
- """
- Show only speaking users setting changed
- """
- self.overlay.set_only_speaking(button.get_active())
-
- self.only_speaking = button.get_active()
- self.save_config()
-
- def change_highlight_self(self, button):
- """
- Highlight self setting changed
- """
- self.overlay.set_highlight_self(button.get_active())
-
- self.highlight_self = button.get_active()
- self.save_config()
-
- def change_icon_only(self, button):
- """
- Icon only setting changed
- """
- self.overlay.set_icon_only(button.get_active())
-
- self.icon_only = button.get_active()
- self.save_config()
-
- def change_order(self, button):
- """
- Order user setting changed
- """
- self.overlay.set_order(button.get_active())
-
- self.order = button.get_active()
- self.save_config()
-
- def change_horizontal(self, button):
- """
- Horizontal layout setting changed
- """
- self.overlay.set_horizontal(button.get_active())
-
- self.horizontal = button.get_active()
- self.save_config()
- self.set_orientated_names()
-
- def change_dummy_data(self, button):
- self.overlay.set_show_dummy(button.get_active())
- self.show_dummy = button.get_active()
- if self.show_dummy:
- self.overlay.set_enabled(True)
- self.overlay.set_hidden(False)
-
- def change_dummy_count(self, button):
- self.overlay.set_dummy_count(int(button.get_value()))
- self.dummy_count = button.get_value()
-
- def change_overflow(self, button):
- self.overlay.set_overflow(button.get_active())
- self.overflow = button.get_active()
- self.save_config()
-
- def change_show_title(self, button):
- self.overlay.set_show_title(button.get_active())
- self.show_title = button.get_active()
- self.save_config()
-
- def change_show_connection(self, button):
- self.overlay.set_show_connection(button.get_active())
- self.show_connection = button.get_active()
- self.save_config()
-
- def change_show_disconnected(self, button):
- self.overlay.set_show_disconnected(button.get_active())
- self.show_disconnected = button.get_active()
- self.save_config()
-
- def change_border_width(self, button):
- self.overlay.set_border_width(button.get_value())
- self.border_width = button.get_value()
- self.save_config()
-
- def change_icon_transparency(self, button):
- self.overlay.set_icon_transparency(button.get_value())
- self.icon_transparency = button.get_value()
- self.save_config()
-
- def on_guild_selection_changed(self, tree, number, selection):
- model, treeiter = tree.get_selection().get_selected()
- if treeiter is not None:
- model[treeiter][0] = not model[treeiter][0]
- if model[treeiter][0]:
- self.add_guild(model[treeiter][3])
- else:
- self.remove_guild(model[treeiter][3])
-
- def add_guild(self, guild):
- self.guild_ids.append(guild)
- self.overlay.set_guild_ids(self.guild_ids)
- self.save_config()
-
- def remove_guild(self, guild):
- self.guild_ids.remove(guild)
- self.overlay.set_guild_ids(self.guild_ids)
- self.save_config()
-
- def change_guild_ids(self, input):
- """
- Guild IDs replaced
- """
- self.guild_ids = parse_guild_ids(input.get_text())
- self.overlay.set_guild_ids(self.guild_ids)
- self.save_config()
-
- def guild_filter_changed(self, entry):
- """
- Change the filter string for guilds
- """
- self.guild_filter_string = entry.get_text()
- self.guild_ids_filter.refilter()
-
- def guild_filter_func(self, model, iter, data):
- """
- Decide if a guild is shown in the list of guilds
- """
- if self.guild_filter_string in model[iter][2]:
- return True
- return False
-
- def set_orientated_names(self):
- i = self.align_x_store.get_iter_first()
- i2 = self.align_y_store.get_iter_first()
- if self.horizontal:
- self.align_x_store.set_value(i, 0, _("Top"))
- i = self.align_x_store.iter_next(i)
- self.align_x_store.set_value(i, 0, _("Bottom"))
-
- self.align_y_store.set_value(i2, 0, _("Left"))
- i2 = self.align_y_store.iter_next(i2)
- self.align_y_store.set_value(i2, 0, _("Middle"))
- i2 = self.align_y_store.iter_next(i2)
- self.align_y_store.set_value(i2, 0, _("Right"))
- else:
- self.align_x_store.set_value(i, 0, _("Left"))
- i = self.align_x_store.iter_next(i)
- self.align_x_store.set_value(i, 0, _("Right"))
-
- self.align_y_store.set_value(i2, 0, _("Top"))
- i2 = self.align_y_store.iter_next(i2)
- self.align_y_store.set_value(i2, 0, _("Middle"))
- i2 = self.align_y_store.iter_next(i2)
- self.align_y_store.set_value(i2, 0, _("Bottom"))
-
- def toggle_advanced(self, button):
- """
- Toggle advanced options
- """
- self.show_advanced = not self.show_advanced
- self.present_settings()