parent
b21c05c02e
commit
4d917d30c8
2 changed files with 130 additions and 28 deletions
|
|
@ -179,6 +179,10 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
self.icon_only = i
|
||||
self.redraw()
|
||||
|
||||
def set_horizontal(self, horizontal=False):
|
||||
self.horizontal = horizontal
|
||||
self.redraw()
|
||||
|
||||
def set_wind_col(self):
|
||||
"""
|
||||
Use window colour to draw
|
||||
|
|
@ -295,27 +299,48 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
pass # Not in list
|
||||
self.users_to_draw.insert(0, self_user)
|
||||
|
||||
# Calculate height needed to show overlay
|
||||
needed_height = (len(self.users_to_draw) * self.avatar_size) + \
|
||||
(len(self.users_to_draw) + 1) * self.icon_spacing
|
||||
if self.horizontal:
|
||||
needed_width = (len(self.users_to_draw) * self.avatar_size) + \
|
||||
(len(self.users_to_draw) + 1) * self.icon_spacing
|
||||
|
||||
# Choose where to start drawing
|
||||
current_y = 0 + self.vert_edge_padding
|
||||
if self.align_vert == 1:
|
||||
# Ignore padding?
|
||||
current_y = (height / 2) - (needed_height / 2)
|
||||
elif self.align_vert == 2:
|
||||
current_y = height - needed_height - self.vert_edge_padding
|
||||
current_x = 0 + self.vert_edge_padding
|
||||
if self.align_vert ==1 :
|
||||
current_x = (width/2)-(needed_width)/2
|
||||
elif self.align_vert==2:
|
||||
current_x = width - needed_width - self.vert_edge_padding
|
||||
|
||||
for user in self.users_to_draw:
|
||||
self.draw_avatar(context, user, current_y)
|
||||
# Shift the relative position down to next location
|
||||
current_y += self.avatar_size + self.icon_spacing
|
||||
for user in self.users_to_draw:
|
||||
self.draw_avatar(context, user, current_x)
|
||||
# Shift the relative position down to next location
|
||||
current_x += self.avatar_size + self.icon_spacing
|
||||
|
||||
if self.is_wayland:
|
||||
context.restore()
|
||||
# Don't hold a ref
|
||||
self.context = None
|
||||
if self.is_wayland:
|
||||
context.restore()
|
||||
# Don't hold a ref
|
||||
self.context = None
|
||||
|
||||
else:
|
||||
# Calculate height needed to show overlay
|
||||
needed_height = (len(self.users_to_draw) * self.avatar_size) + \
|
||||
(len(self.users_to_draw) + 1) * self.icon_spacing
|
||||
|
||||
# Choose where to start drawing
|
||||
current_y = 0 + self.vert_edge_padding
|
||||
if self.align_vert == 1:
|
||||
# Ignore padding?
|
||||
current_y = (height / 2) - (needed_height / 2)
|
||||
elif self.align_vert == 2:
|
||||
current_y = height - needed_height - self.vert_edge_padding
|
||||
|
||||
for user in self.users_to_draw:
|
||||
self.draw_avatar(context, user, current_y)
|
||||
# Shift the relative position down to next location
|
||||
current_y += self.avatar_size + self.icon_spacing
|
||||
|
||||
if self.is_wayland:
|
||||
context.restore()
|
||||
# Don't hold a ref
|
||||
self.context = None
|
||||
|
||||
def recv_avatar(self, identifier, pix):
|
||||
"""
|
||||
|
|
@ -362,7 +387,34 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
pix = None
|
||||
if user["id"] in self.avatars:
|
||||
pix = self.avatars[user["id"]]
|
||||
if self.align_right:
|
||||
if self.horizontal:
|
||||
if(self.align_right):
|
||||
self.draw_avatar_pix(
|
||||
context, pix,
|
||||
pos_y,
|
||||
self.height - self.avatar_size - self.horz_edge_padding,
|
||||
colour
|
||||
)
|
||||
if deaf:
|
||||
self.draw_deaf(context, pos_y, self.height - self.avatar_size -
|
||||
self.horz_edge_padding)
|
||||
elif mute:
|
||||
self.draw_mute(context, pos_y, self.height - self.avatar_size -
|
||||
self.horz_edge_padding)
|
||||
else:
|
||||
self.draw_avatar_pix(
|
||||
context, pix,
|
||||
pos_y,
|
||||
0,
|
||||
colour
|
||||
)
|
||||
if deaf:
|
||||
self.draw_deaf(context, pos_y, self.horz_edge_padding)
|
||||
elif mute:
|
||||
self.draw_mute(context, pos_y, self.horz_edge_padding)
|
||||
|
||||
|
||||
elif self.align_right:
|
||||
if not self.icon_only:
|
||||
self.draw_text(
|
||||
context, user["friendlyname"],
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
self.horz_edge_padding = None
|
||||
self.floating = None
|
||||
self.order = None
|
||||
self.horizontal = None
|
||||
self.init_config()
|
||||
|
||||
self.create_gui()
|
||||
|
|
@ -117,6 +118,7 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
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)
|
||||
|
||||
# Pass all of our config over to the overlay
|
||||
self.overlay.set_align_x(self.align_x)
|
||||
|
|
@ -141,6 +143,7 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
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_floating(
|
||||
self.floating, self.floating_x, self.floating_y, self.floating_w, self.floating_h)
|
||||
|
|
@ -148,6 +151,7 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
if self.font:
|
||||
self.overlay.set_font(self.font)
|
||||
|
||||
|
||||
def save_config(self):
|
||||
"""
|
||||
Write settings out to the 'main' section of the config file
|
||||
|
|
@ -187,6 +191,7 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
config.set("main", "floating_w", "%s" % (self.floating_w))
|
||||
config.set("main", "floating_h", "%s" % (self.floating_h))
|
||||
config.set("main", "order", "%s" % (self.order))
|
||||
config.set("main", "horizontal", "%s" % (self.horizontal))
|
||||
|
||||
with open(self.config_file, 'w') as file:
|
||||
config.write(file)
|
||||
|
|
@ -282,21 +287,21 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
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)
|
||||
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)
|
||||
|
||||
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)
|
||||
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()
|
||||
|
|
@ -387,6 +392,12 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
order.pack_start(renderer_text, True)
|
||||
order.add_attribute(renderer_text, "text", 0)
|
||||
|
||||
# Display icon horizontally
|
||||
horizontal_label = Gtk.Label.new("Display Horizontally")
|
||||
horizontal = Gtk.CheckButton.new()
|
||||
horizontal.set_active(self.horizontal)
|
||||
horizontal.connect("toggled", self.change_horizontal)
|
||||
|
||||
box.attach(autohide_label, 0, 0, 1, 1)
|
||||
box.attach(autohide, 1, 0, 1, 1)
|
||||
box.attach(font_label, 0, 1, 1, 1)
|
||||
|
|
@ -431,9 +442,14 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
box.attach(icon_only, 1, 22, 1, 1)
|
||||
box.attach(order_label, 0, 23, 1, 1)
|
||||
box.attach(order, 1, 23, 1, 1)
|
||||
box.attach(horizontal_label, 0, 24, 1, 1)
|
||||
box.attach(horizontal, 1, 24, 1, 1)
|
||||
|
||||
self.add(box)
|
||||
|
||||
self.set_orientated_names()
|
||||
|
||||
|
||||
def change_font(self, button):
|
||||
"""
|
||||
Font settings changed
|
||||
|
|
@ -609,3 +625,37 @@ class VoiceSettingsWindow(SettingsWindow):
|
|||
|
||||
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 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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue