- Added option to hide avatars
This commit is contained in:
parent
f5aba24ddf
commit
cb412c9292
5 changed files with 75 additions and 23 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -7,3 +7,4 @@ env
|
||||||
__pycache__
|
__pycache__
|
||||||
venv
|
venv
|
||||||
.idea
|
.idea
|
||||||
|
discover_overlay/glade/settings.glade~
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,7 @@ class Discover:
|
||||||
config.getint("main", "border_width", fallback=2))
|
config.getint("main", "border_width", fallback=2))
|
||||||
self.voice_overlay.set_icon_transparency(config.getfloat(
|
self.voice_overlay.set_icon_transparency(config.getfloat(
|
||||||
"main", "icon_transparency", fallback=1.0))
|
"main", "icon_transparency", fallback=1.0))
|
||||||
|
self.voice_overlay.set_show_avatar(config.getboolean("main", "show_avatar", fallback=True))
|
||||||
self.voice_overlay.set_fancy_border(config.getboolean("main",
|
self.voice_overlay.set_fancy_border(config.getboolean("main",
|
||||||
"fancy_border", fallback=True))
|
"fancy_border", fallback=True))
|
||||||
self.voice_overlay.set_show_dummy(config.getboolean("main",
|
self.voice_overlay.set_show_dummy(config.getboolean("main",
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@
|
||||||
<property name="step-increment">1</property>
|
<property name="step-increment">1</property>
|
||||||
<property name="page-increment">8</property>
|
<property name="page-increment">8</property>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkAdjustment" id="voice_display_speakers_grace_period_adj">
|
<object class="GtkAdjustment" id="voice_display_speakers_grace_period_adj">
|
||||||
<property name="lower">0</property>
|
<property name="lower">0</property>
|
||||||
<property name="upper">360</property>
|
<property name="upper">360</property>
|
||||||
<property name="value">0</property>
|
<property name="value">0</property>
|
||||||
|
|
@ -701,7 +701,7 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<!-- n-columns=6 n-rows=8 -->
|
<!-- n-columns=6 n-rows=9 -->
|
||||||
<object class="GtkGrid">
|
<object class="GtkGrid">
|
||||||
<property name="name">voice_advanced_grid</property>
|
<property name="name">voice_advanced_grid</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
@ -1357,6 +1357,38 @@
|
||||||
<property name="top-attach">7</property>
|
<property name="top-attach">7</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="name">voice_avatar_label</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Show Avatar</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">8</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton">
|
||||||
|
<property name="name">voice_avatar</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">False</property>
|
||||||
|
<property name="draw-indicator">True</property>
|
||||||
|
<signal name="toggled" handler="voice_show_avatar_changed" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">1</property>
|
||||||
|
<property name="top-attach">8</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
|
|
|
||||||
|
|
@ -906,6 +906,9 @@ class MainSettingsWindow():
|
||||||
self.config_set("main", "dummy_count", "%s" %
|
self.config_set("main", "dummy_count", "%s" %
|
||||||
(int(button.get_value())))
|
(int(button.get_value())))
|
||||||
|
|
||||||
|
def voice_show_avatar_changed(self, button):
|
||||||
|
self.config_set("main", "show_avatar", "%s" % (button.get_active()))
|
||||||
|
|
||||||
def text_enable_changed(self, button):
|
def text_enable_changed(self, button):
|
||||||
self.config_set("text", "enabled", "%s" % (button.get_active()))
|
self.config_set("text", "enabled", "%s" % (button.get_active()))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
'lastspoken': random.randint(2000, 2100) if speaking else random.randint(10, 30),
|
'lastspoken': random.randint(2000, 2100) if speaking else random.randint(10, 30),
|
||||||
'friendlyname': name,
|
'friendlyname': name,
|
||||||
})
|
})
|
||||||
|
self.show_avatar = True
|
||||||
self.avatar_size = 48
|
self.avatar_size = 48
|
||||||
self.nick_length = 32
|
self.nick_length = 32
|
||||||
self.text_pad = 6
|
self.text_pad = 6
|
||||||
|
|
@ -154,6 +155,10 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
self.show_connection = show_connection
|
self.show_connection = show_connection
|
||||||
self.needsredraw = True
|
self.needsredraw = True
|
||||||
|
|
||||||
|
def set_show_avatar(self, show_avatar):
|
||||||
|
self.show_avatar = show_avatar
|
||||||
|
self.needsredraw = True
|
||||||
|
|
||||||
def set_show_title(self, show_title):
|
def set_show_title(self, show_title):
|
||||||
self.show_title = show_title
|
self.show_title = show_title
|
||||||
self.needsredraw = True
|
self.needsredraw = True
|
||||||
|
|
@ -511,7 +516,8 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
users_to_draw.remove(self_user)
|
users_to_draw.remove(self_user)
|
||||||
users_to_draw.insert(0, self_user)
|
users_to_draw.insert(0, self_user)
|
||||||
|
|
||||||
avatar_size = self.avatar_size
|
avatar_size = self.avatar_size if self.show_avatar else 0
|
||||||
|
line_height = self.avatar_size
|
||||||
avatars_per_row = sys.maxsize
|
avatars_per_row = sys.maxsize
|
||||||
|
|
||||||
# Calculate height needed to show overlay
|
# Calculate height needed to show overlay
|
||||||
|
|
@ -525,7 +531,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
doTitle = True
|
doTitle = True
|
||||||
|
|
||||||
if self.horizontal:
|
if self.horizontal:
|
||||||
needed_width = (len(users_to_draw) * self.avatar_size) + \
|
needed_width = (len(users_to_draw) * line_height) + \
|
||||||
(len(users_to_draw) + 1) * self.icon_spacing
|
(len(users_to_draw) + 1) * self.icon_spacing
|
||||||
|
|
||||||
if needed_width > width:
|
if needed_width > width:
|
||||||
|
|
@ -550,7 +556,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
row.append(users_to_draw.pop(0))
|
row.append(users_to_draw.pop(0))
|
||||||
rows_to_draw.append(row)
|
rows_to_draw.append(row)
|
||||||
for row in rows_to_draw:
|
for row in rows_to_draw:
|
||||||
needed_width = (len(row) * (avatar_size + self.icon_spacing))
|
needed_width = (len(row) * (line_height + self.icon_spacing))
|
||||||
current_x = 0 + self.horz_edge_padding
|
current_x = 0 + self.horz_edge_padding
|
||||||
if self.align_vert == 1:
|
if self.align_vert == 1:
|
||||||
current_x = (width / 2) - (needed_width) / 2
|
current_x = (width / 2) - (needed_width) / 2
|
||||||
|
|
@ -562,18 +568,18 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
if doTitle:
|
if doTitle:
|
||||||
doTitle = False
|
doTitle = False
|
||||||
text_width = self.draw_title(
|
text_width = self.draw_title(
|
||||||
context, current_x, current_y, avatar_size)
|
context, current_x, current_y, avatar_size, line_height)
|
||||||
elif doConnection:
|
elif doConnection:
|
||||||
text_width = self.draw_connection(
|
text_width = self.draw_connection(
|
||||||
context, current_x, current_y, avatar_size)
|
context, current_x, current_y, avatar_size, line_height)
|
||||||
doConnection = False
|
doConnection = False
|
||||||
else:
|
else:
|
||||||
self.draw_avatar(context, user, current_x,
|
self.draw_avatar(context, user, current_x,
|
||||||
current_y, avatar_size)
|
current_y, avatar_size, line_height)
|
||||||
current_x += avatar_size + self.icon_spacing
|
current_x += avatar_size + self.icon_spacing
|
||||||
current_y += offset_y
|
current_y += offset_y
|
||||||
else:
|
else:
|
||||||
needed_height = ((len(users_to_draw)+0) * self.avatar_size) + \
|
needed_height = ((len(users_to_draw)+0) * line_height) + \
|
||||||
(len(users_to_draw) + 1) * self.icon_spacing
|
(len(users_to_draw) + 1) * self.icon_spacing
|
||||||
|
|
||||||
if needed_height > height:
|
if needed_height > height:
|
||||||
|
|
@ -593,6 +599,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
offset_x_mult = -1
|
offset_x_mult = -1
|
||||||
current_x = self.width - avatar_size - self.horz_edge_padding
|
current_x = self.width - avatar_size - self.horz_edge_padding
|
||||||
|
|
||||||
|
|
||||||
# Choose where to start drawing
|
# Choose where to start drawing
|
||||||
current_y = 0 + self.vert_edge_padding
|
current_y = 0 + self.vert_edge_padding
|
||||||
if self.align_vert == 1:
|
if self.align_vert == 1:
|
||||||
|
|
@ -607,7 +614,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
col.append(users_to_draw.pop(0))
|
col.append(users_to_draw.pop(0))
|
||||||
cols_to_draw.append(col)
|
cols_to_draw.append(col)
|
||||||
for col in cols_to_draw:
|
for col in cols_to_draw:
|
||||||
needed_height = (len(col) * (avatar_size + self.icon_spacing))
|
needed_height = (len(col) * (line_height + self.icon_spacing))
|
||||||
current_y = 0 + self.vert_edge_padding
|
current_y = 0 + self.vert_edge_padding
|
||||||
if self.align_vert == 1:
|
if self.align_vert == 1:
|
||||||
current_y = (height/2) - (needed_height / 2)
|
current_y = (height/2) - (needed_height / 2)
|
||||||
|
|
@ -619,26 +626,26 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
if doTitle:
|
if doTitle:
|
||||||
# Draw header
|
# Draw header
|
||||||
text_width = self.draw_title(
|
text_width = self.draw_title(
|
||||||
context, current_x, current_y, avatar_size)
|
context, current_x, current_y, avatar_size, line_height)
|
||||||
largest_text_width = max(
|
largest_text_width = max(
|
||||||
text_width, largest_text_width)
|
text_width, largest_text_width)
|
||||||
current_y += avatar_size + self.icon_spacing
|
current_y += line_height + self.icon_spacing
|
||||||
doTitle = False
|
doTitle = False
|
||||||
elif doConnection:
|
elif doConnection:
|
||||||
# Draw header
|
# Draw header
|
||||||
text_width = self.draw_connection(
|
text_width = self.draw_connection(
|
||||||
context, current_x, current_y, avatar_size)
|
context, current_x, current_y, avatar_size, line_height)
|
||||||
largest_text_width = max(
|
largest_text_width = max(
|
||||||
text_width, largest_text_width)
|
text_width, largest_text_width)
|
||||||
current_y += avatar_size + self.icon_spacing
|
current_y += line_height + self.icon_spacing
|
||||||
doConnection = False
|
doConnection = False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
text_width = self.draw_avatar(
|
text_width = self.draw_avatar(
|
||||||
context, user, current_x, current_y, avatar_size)
|
context, user, current_x, current_y, avatar_size, line_height)
|
||||||
largest_text_width = max(
|
largest_text_width = max(
|
||||||
text_width, largest_text_width)
|
text_width, largest_text_width)
|
||||||
current_y += avatar_size + self.icon_spacing
|
current_y += line_height + self.icon_spacing
|
||||||
if largest_text_width > 0:
|
if largest_text_width > 0:
|
||||||
largest_text_width += self.text_pad
|
largest_text_width += self.text_pad
|
||||||
else:
|
else:
|
||||||
|
|
@ -670,7 +677,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
if identifier in self.avatars:
|
if identifier in self.avatars:
|
||||||
del self.avatars[identifier]
|
del self.avatars[identifier]
|
||||||
|
|
||||||
def draw_title(self, context, pos_x, pos_y, avatar_size):
|
def draw_title(self, context, pos_x, pos_y, avatar_size, line_height):
|
||||||
"""
|
"""
|
||||||
Draw title at given Y position. Includes both text and image based on settings
|
Draw title at given Y position. Includes both text and image based on settings
|
||||||
"""
|
"""
|
||||||
|
|
@ -686,6 +693,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
self.text_col,
|
self.text_col,
|
||||||
self.norm_col,
|
self.norm_col,
|
||||||
avatar_size,
|
avatar_size,
|
||||||
|
line_height,
|
||||||
self.title_font
|
self.title_font
|
||||||
)
|
)
|
||||||
if self.channel_icon:
|
if self.channel_icon:
|
||||||
|
|
@ -710,7 +718,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
_("VOICE_CONNECTING")
|
_("VOICE_CONNECTING")
|
||||||
_("VOICE_CONNECTED")
|
_("VOICE_CONNECTED")
|
||||||
|
|
||||||
def draw_connection(self, context, pos_x, pos_y, avatar_size):
|
def draw_connection(self, context, pos_x, pos_y, avatar_size, line_height):
|
||||||
"""
|
"""
|
||||||
Draw title at given Y position. Includes both text and image based on settings
|
Draw title at given Y position. Includes both text and image based on settings
|
||||||
"""
|
"""
|
||||||
|
|
@ -723,18 +731,19 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
self.text_col,
|
self.text_col,
|
||||||
self.norm_col,
|
self.norm_col,
|
||||||
avatar_size,
|
avatar_size,
|
||||||
|
line_height,
|
||||||
self.text_font
|
self.text_font
|
||||||
)
|
)
|
||||||
self.blank_avatar(context, pos_x, pos_y, avatar_size)
|
self.blank_avatar(context, pos_x, pos_y, avatar_size)
|
||||||
self.draw_connection_icon(context, pos_x, pos_y, avatar_size)
|
self.draw_connection_icon(context, pos_x, pos_y, avatar_size)
|
||||||
return tw
|
return tw
|
||||||
|
|
||||||
def draw_avatar(self, context, user, pos_x, pos_y, avatar_size):
|
def draw_avatar(self, context, user, pos_x, pos_y, avatar_size, line_height):
|
||||||
"""
|
"""
|
||||||
Draw avatar at given Y position. Includes both text and image based on settings
|
Draw avatar at given Y position. Includes both text and image based on settings
|
||||||
"""
|
"""
|
||||||
# Ensure pixbuf for avatar
|
# Ensure pixbuf for avatar
|
||||||
if user["id"] not in self.avatars and user["avatar"]:
|
if user["id"] not in self.avatars and user["avatar"] and avatar_size>0:
|
||||||
url = "https://cdn.discordapp.com/avatars/%s/%s.png" % (
|
url = "https://cdn.discordapp.com/avatars/%s/%s.png" % (
|
||||||
user['id'], user['avatar'])
|
user['id'], user['avatar'])
|
||||||
get_surface(self.recv_avatar, url, user["id"],
|
get_surface(self.recv_avatar, url, user["id"],
|
||||||
|
|
@ -778,6 +787,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
fg_col,
|
fg_col,
|
||||||
bg_col,
|
bg_col,
|
||||||
avatar_size,
|
avatar_size,
|
||||||
|
line_height,
|
||||||
self.text_font
|
self.text_font
|
||||||
)
|
)
|
||||||
self.draw_avatar_pix(context, pix, mask, pos_x,
|
self.draw_avatar_pix(context, pix, mask, pos_x,
|
||||||
|
|
@ -790,7 +800,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
self.mute_bg_col, avatar_size)
|
self.mute_bg_col, avatar_size)
|
||||||
return tw
|
return tw
|
||||||
|
|
||||||
def draw_text(self, context, string, pos_x, pos_y, tx_col, bg_col, avatar_size, font):
|
def draw_text(self, context, string, pos_x, pos_y, tx_col, bg_col, avatar_size, line_height, font):
|
||||||
"""
|
"""
|
||||||
Draw username & background at given position
|
Draw username & background at given position
|
||||||
"""
|
"""
|
||||||
|
|
@ -812,7 +822,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
text_width = logical_rect.width
|
text_width = logical_rect.width
|
||||||
|
|
||||||
self.col(tx_col)
|
self.col(tx_col)
|
||||||
height_offset = (avatar_size / 2) - (text_height / 2)
|
height_offset = (line_height / 2) - (text_height / 2)
|
||||||
text_y_offset = height_offset + self.text_baseline_adj
|
text_y_offset = height_offset + self.text_baseline_adj
|
||||||
|
|
||||||
if self.align_right:
|
if self.align_right:
|
||||||
|
|
@ -868,7 +878,8 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
"""
|
"""
|
||||||
Draw avatar image at given position
|
Draw avatar image at given position
|
||||||
"""
|
"""
|
||||||
|
if not self.show_avatar:
|
||||||
|
return
|
||||||
# Empty the space for this
|
# Empty the space for this
|
||||||
self.blank_avatar(context, pos_x, pos_y, avatar_size)
|
self.blank_avatar(context, pos_x, pos_y, avatar_size)
|
||||||
|
|
||||||
|
|
@ -941,6 +952,8 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
"""
|
"""
|
||||||
Draw Mute logo
|
Draw Mute logo
|
||||||
"""
|
"""
|
||||||
|
if avatar_size <= 0:
|
||||||
|
return
|
||||||
context.save()
|
context.save()
|
||||||
context.translate(pos_x, pos_y)
|
context.translate(pos_x, pos_y)
|
||||||
context.scale(avatar_size, avatar_size)
|
context.scale(avatar_size, avatar_size)
|
||||||
|
|
@ -1008,6 +1021,8 @@ class VoiceOverlayWindow(OverlayWindow):
|
||||||
"""
|
"""
|
||||||
Draw deaf logo
|
Draw deaf logo
|
||||||
"""
|
"""
|
||||||
|
if avatar_size <= 0:
|
||||||
|
return
|
||||||
context.save()
|
context.save()
|
||||||
context.translate(pos_x, pos_y)
|
context.translate(pos_x, pos_y)
|
||||||
context.scale(avatar_size, avatar_size)
|
context.scale(avatar_size, avatar_size)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue