diff --git a/discover_overlay/discover_overlay.py b/discover_overlay/discover_overlay.py index 5810b29..714e0a8 100755 --- a/discover_overlay/discover_overlay.py +++ b/discover_overlay/discover_overlay.py @@ -223,6 +223,8 @@ class Discover: "main", "avatar_bg_col", fallback="[0.0,0.0,0.0,0.0]"))) self.voice_overlay.set_avatar_size( config.getint("main", "avatar_size", fallback=48)) + self.voice_overlay.set_nick_length( + config.getint("main", "nick_length", fallback=32)) self.voice_overlay.set_icon_spacing( config.getint("main", "icon_spacing", fallback=8)) self.voice_overlay.set_text_padding( diff --git a/discover_overlay/glade/settings.glade b/discover_overlay/glade/settings.glade index d40f707..b4bb77d 100644 --- a/discover_overlay/glade/settings.glade +++ b/discover_overlay/glade/settings.glade @@ -136,6 +136,13 @@ 1 8 + + 10 + 32 + 32 + 1 + 10 + -100 100 @@ -1267,10 +1274,30 @@ - + + voice_nick_length_label + True + False + Limit text length + 0 + + + 4 + 7 + - + + voice_nick_length + True + True + voice_nick_lenght_adj + + + + 5 + 7 + diff --git a/discover_overlay/glade/settings.glade~ b/discover_overlay/glade/settings.glade~ index 3abff46..ff43045 100644 --- a/discover_overlay/glade/settings.glade~ +++ b/discover_overlay/glade/settings.glade~ @@ -136,6 +136,13 @@ 1 8 + + 10 + 32 + 32 + 1 + 10 + -100 100 @@ -1267,10 +1274,30 @@ - + + voice_nick_length_label + True + False + Limit text length + 0 + + + 4 + 7 + - + + voice_nick_length + True + True + voice_nick_lenght_adj + + + + 5 + 7 + @@ -2091,7 +2118,7 @@ - + True False @@ -2259,12 +2286,6 @@ 5 - - - - - - 4 diff --git a/discover_overlay/settings_window.py b/discover_overlay/settings_window.py index f096438..d853792 100644 --- a/discover_overlay/settings_window.py +++ b/discover_overlay/settings_window.py @@ -313,6 +313,9 @@ class MainSettingsWindow(): self.widget['voice_avatar_opacity'].set_value(config.getfloat( "main", "icon_transparency", fallback=1.0)) + self.widget['voice_nick_length'].set_value( + config.getint("main", "nick_length", fallback=32)) + self.widget['voice_avatar_size'].set_value( config.getint("main", "avatar_size", fallback=48)) @@ -823,6 +826,10 @@ class MainSettingsWindow(): self.config_set("main", "avatar_size", "%s" % (int(button.get_value()))) + def voice_nick_length_changed(self, button): + self.config_set("main", "nick_length", "%s" % + (int(button.get_value()))) + def voice_display_icon_only_changed(self, button): self.config_set("main", "icon_only", "%s" % (button.get_active())) diff --git a/discover_overlay/voice_overlay.py b/discover_overlay/voice_overlay.py index 1bd9d35..b848982 100644 --- a/discover_overlay/voice_overlay.py +++ b/discover_overlay/voice_overlay.py @@ -63,6 +63,7 @@ class VoiceOverlayWindow(OverlayWindow): 'friendlyname': name, }) self.avatar_size = 48 + self.nick_length = 32 self.text_pad = 6 self.text_font = None self.title_font = None @@ -239,6 +240,13 @@ class VoiceOverlayWindow(OverlayWindow): self.avatar_size = size self.needsredraw = True + def set_nick_length(self, size): + """ + Set the length of nickname + """ + self.nick_length = size + self.needsredraw = True + def set_icon_spacing(self, i): """ Set the spacing between avatar icons @@ -754,6 +762,9 @@ class VoiceOverlayWindow(OverlayWindow): """ Draw username & background at given position """ + if self.nick_length < 32 and len(string) > self.nick_length: + string = string[:(self.nick_length-1)] + u"\u2026" + context.save() layout = self.create_pango_layout(string) layout.set_auto_dir(True)