From 37bbd8ceeba3c4c96199d2d114c4c8d135427486 Mon Sep 17 00:00:00 2001 From: trigg Date: Tue, 12 Jul 2022 18:57:54 +0100 Subject: [PATCH] - Left align more labels - Customisable avatar background colour --- discover_overlay/general_settings.py | 4 ++ discover_overlay/notification_settings.py | 16 +++++- discover_overlay/text_settings.py | 10 ++++ discover_overlay/voice_overlay.py | 24 +++++++-- discover_overlay/voice_settings.py | 60 +++++++++++++++++++++-- 5 files changed, 104 insertions(+), 10 deletions(-) diff --git a/discover_overlay/general_settings.py b/discover_overlay/general_settings.py index fa28d90..f6aae5c 100644 --- a/discover_overlay/general_settings.py +++ b/discover_overlay/general_settings.py @@ -85,24 +85,28 @@ class GeneralSettingsWindow(SettingsWindow): # 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) diff --git a/discover_overlay/notification_settings.py b/discover_overlay/notification_settings.py index cb24dc2..6735c1a 100644 --- a/discover_overlay/notification_settings.py +++ b/discover_overlay/notification_settings.py @@ -199,23 +199,27 @@ class NotificationSettingsWindow(SettingsWindow): # 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) @@ -223,6 +227,7 @@ class NotificationSettingsWindow(SettingsWindow): # 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) @@ -230,6 +235,7 @@ class NotificationSettingsWindow(SettingsWindow): # Font chooser font_label = Gtk.Label.new(_("Font")) + font_label.set_xalign(0) font = Gtk.FontButton() if self.font: font.set_font(self.font) @@ -237,6 +243,7 @@ class NotificationSettingsWindow(SettingsWindow): # 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")]) @@ -249,9 +256,11 @@ class NotificationSettingsWindow(SettingsWindow): # 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) @@ -261,7 +270,7 @@ class NotificationSettingsWindow(SettingsWindow): # 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")) @@ -313,12 +322,14 @@ class NotificationSettingsWindow(SettingsWindow): # 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) @@ -326,6 +337,7 @@ class NotificationSettingsWindow(SettingsWindow): # 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) @@ -333,6 +345,7 @@ class NotificationSettingsWindow(SettingsWindow): # 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) @@ -340,6 +353,7 @@ class NotificationSettingsWindow(SettingsWindow): # 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) diff --git a/discover_overlay/text_settings.py b/discover_overlay/text_settings.py index 94c6c42..71e0d8b 100644 --- a/discover_overlay/text_settings.py +++ b/discover_overlay/text_settings.py @@ -306,6 +306,7 @@ class TextSettingsWindow(SettingsWindow): # 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) @@ -318,12 +319,14 @@ class TextSettingsWindow(SettingsWindow): # 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) @@ -331,6 +334,7 @@ class TextSettingsWindow(SettingsWindow): # Font chooser font_label = Gtk.Label.new(_("Font")) + font_label.set_xalign(0) font = Gtk.FontButton() if self.font: font.set_font(self.font) @@ -338,9 +342,11 @@ class TextSettingsWindow(SettingsWindow): # 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) @@ -350,6 +356,7 @@ class TextSettingsWindow(SettingsWindow): # 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( @@ -401,6 +408,7 @@ class TextSettingsWindow(SettingsWindow): 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) @@ -413,6 +421,7 @@ class TextSettingsWindow(SettingsWindow): 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) @@ -426,6 +435,7 @@ class TextSettingsWindow(SettingsWindow): # 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) diff --git a/discover_overlay/voice_overlay.py b/discover_overlay/voice_overlay.py index ec321c9..b111117 100644 --- a/discover_overlay/voice_overlay.py +++ b/discover_overlay/voice_overlay.py @@ -96,8 +96,10 @@ class VoiceOverlayWindow(OverlayWindow): self.norm_col = [0.0, 0.0, 0.0, 0.5] self.wind_col = [0.0, 0.0, 0.0, 0.0] self.mute_col = [0.7, 0.0, 0.0, 1.0] + self.mute_bg_col = [0.0, 0.0, 0.0, 0.5] self.hili_col = [0.0, 0.0, 0.0, 0.9] self.border_col = [0.0, 0.0, 0.0, 0.0] + self.avatar_bg_col = [0.0, 0.0, 1.0, 1.0] self.userlist = [] self.connection_status = "DISCONNECTED" self.horizontal = False @@ -189,6 +191,20 @@ class VoiceOverlayWindow(OverlayWindow): self.mute_col = mute_colour self.needsredraw = True + def set_mute_bg(self, mute_bg_col): + """ + Set the background colour for mute/deafen icon + """ + self.mute_bg_col = mute_bg_col + self.needsredraw = True + + def set_avatar_bg_col(self, avatar_bg_col): + """ + Set Avatar background colour + """ + self.avatar_bg_col = avatar_bg_col + self.needsredraw = True + def set_hi(self, highlight_colour): """ Set the colour of background for speaking users @@ -716,11 +732,9 @@ class VoiceOverlayWindow(OverlayWindow): self.draw_avatar_pix(context, pix, mask, pos_x, pos_y, colour, avatar_size) if deaf: - self.draw_deaf(context, pos_x, pos_y, [ - 0.0, 0.0, 0.0, 0.5], avatar_size) + self.draw_deaf(context, pos_x, pos_y, self.mute_bg_col, avatar_size) elif mute: - self.draw_mute(context, pos_x, pos_y, [ - 0.0, 0.0, 0.0, 0.5], avatar_size) + self.draw_mute(context, pos_x, pos_y, self.mute_bg_col, avatar_size) return tw def draw_text(self, context, string, pos_x, pos_y, tx_col, bg_col, avatar_size, font): @@ -788,7 +802,7 @@ class VoiceOverlayWindow(OverlayWindow): context.arc(pos_x + (avatar_size / 2), pos_y + (avatar_size / 2), avatar_size / 2, 0, 2 * math.pi) context.clip() - self.col([0.0, 0.0, 0.0, 0.0]) + self.col(self.avatar_bg_col) context.set_operator(cairo.OPERATOR_SOURCE) context.rectangle(pos_x, pos_y, avatar_size, avatar_size) context.fill() diff --git a/discover_overlay/voice_settings.py b/discover_overlay/voice_settings.py index ea2bd08..c47cf31 100644 --- a/discover_overlay/voice_settings.py +++ b/discover_overlay/voice_settings.py @@ -57,8 +57,10 @@ class VoiceSettingsWindow(SettingsWindow): 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 @@ -126,10 +128,14 @@ class VoiceSettingsWindow(SettingsWindow): "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) @@ -181,8 +187,10 @@ class VoiceSettingsWindow(SettingsWindow): 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) @@ -232,9 +240,11 @@ class VoiceSettingsWindow(SettingsWindow): 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)) @@ -287,7 +297,7 @@ class VoiceSettingsWindow(SettingsWindow): monitor_box = Gtk.Grid() alignment_box = Gtk.Grid(row_homogeneous=True) - colour_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) @@ -311,6 +321,7 @@ class VoiceSettingsWindow(SettingsWindow): # Font chooser font_label = Gtk.Label.new(_("Font")) + font_label.set_xalign(0) font = Gtk.FontButton() if self.font: font.set_font(self.font) @@ -320,6 +331,7 @@ class VoiceSettingsWindow(SettingsWindow): # 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) @@ -336,6 +348,8 @@ class VoiceSettingsWindow(SettingsWindow): 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], @@ -356,27 +370,41 @@ class VoiceSettingsWindow(SettingsWindow): 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(_("Text")) - background_label = Gtk.Label.new(_("Label")) + 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) @@ -384,6 +412,7 @@ class VoiceSettingsWindow(SettingsWindow): 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) @@ -391,8 +420,9 @@ class VoiceSettingsWindow(SettingsWindow): 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")) @@ -763,6 +793,28 @@ class VoiceSettingsWindow(SettingsWindow): 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): """