Improved CSS styling setup; fixed bug where highlighting something scroled the list

This commit is contained in:
itdominator 2023-06-22 20:54:45 -05:00
parent 98ffd7c6b0
commit 54eada6c07
3 changed files with 39 additions and 18 deletions

View File

@ -31,10 +31,8 @@ class BaseContainer(Gtk.Box):
def _setup_styling(self):
self.set_orientation(Gtk.Orientation.VERTICAL)
self.set_margin_top(10)
self.set_margin_bottom(10)
self.set_margin_left(10)
self.set_margin_right(10)
ctx = self.get_style_context()
ctx.add_class("base-container")
def _setup_signals(self):
...
@ -50,7 +48,10 @@ class BaseContainer(Gtk.Box):
label2 = Gtk.Label("Playback")
label2.set_xalign(0.0)
for sink_input in self.sink_inputs:
box.add( AudioSink(self.pulse, sink_input) )
sink = AudioSink(self.pulse, sink_input)
ctx = sink.get_style_context()
ctx.add_class("sink-input")
box.add(sink)
self.add(label2)
self.add(scroll)
@ -61,13 +62,20 @@ class BaseContainer(Gtk.Box):
label1 = Gtk.Label("Output Devices")
pulse = pulsectl.Pulse()
self.pulse_events = pulsectl.Pulse('event-printer')
si, sink_inputs, modules, clients, sink_list = pulse.server_info(), pulse.sink_input_list(), pulse.module_list(), pulse.client_list(), pulse.sink_list()
si, sink_inputs, modules, clients, sink_list = pulse.server_info(), \
pulse.sink_input_list(), \
pulse.module_list(), \
pulse.client_list(), \
pulse.sink_list()
self.add(label1)
label1.set_xalign(0.0)
logger.debug(f"\n\nServer Info\n{si}\n\nSink Inputs:")
for sink in sink_list:
self.add( AudioSink(pulse, sink) )
sink = AudioSink(pulse, sink)
ctx = sink.get_style_context()
ctx.add_class("sink-device")
self.add(sink)
self.pulse = pulse
self.sink_inputs = sink_inputs

View File

@ -28,11 +28,8 @@ class SinkInputList(Gtk.ScrolledWindow):
def _setup_styling(self):
ctx = self.get_style_context()
ctx.add_class("sink-list-container")
self.set_vexpand(True)
self.set_overlay_scrolling(False)
self.set_margin_top(20)
self.set_margin_bottom(10)
def _setup_signals(self):
...
@ -49,7 +46,6 @@ class SinkInputList(Gtk.ScrolledWindow):
self._vadjust = self.get_vadjustment()
box.set_orientation(Gtk.Orientation.VERTICAL)
self._vadjust.connect("changed", self._scroll_to_bottom)
viewport.add(box)
self.add(viewport)
@ -58,10 +54,17 @@ class SinkInputList(Gtk.ScrolledWindow):
for child in self._box.get_children():
if index == child.sink.index:
child.do_update()
# If sink out of view in list just scroll fully down.
# Most cases will scroll b/c most recently added sink volume changed elsewhere.
# (Edge case is we update the volume of a sink in between and overshoot.)
# I don't personally care and this isn't a pain point for me.
if not child.get_mapped():
self._scroll_to_bottom(self._vadjust)
def _handle_new_sync_input(self, index):
sink_input = self.pulse.sink_input_list()[-1]
self._box.add( AudioSink(self.pulse, sink_input) )
self._scroll_to_bottom(self._vadjust)
def _handle_del_sync_input(self, index):
parent = self.get_parent()
@ -72,6 +75,7 @@ class SinkInputList(Gtk.ScrolledWindow):
for child in self._box.get_children():
if index == child.sink.index:
child.destroy()
self._scroll_to_bottom(self._vadjust)
def _scroll_to_bottom(self, adjustment):
self._vadjust.set_value( adjustment.get_upper() )

View File

@ -4,11 +4,20 @@
border: 2px solid rgba(0, 0, 0, 0.0);
}
.sink-list-container {
/* Neon Blue 00e8ff border */
/* border: 2px solid rgba(0, 232, 255, 0.25); */
/* Dark Bergundy */
/* border: 2px solid rgba(116, 0, 0, 0.64); */
/* Snow White */
border: 2px solid rgba(255, 255, 255, 0.34);
.base-container {
margin: 10px;
}
.sink-list-container {
margin-bottom: 10px;
}
.sink-device {
border-bottom: 2px solid rgba(255, 255, 255, 0.34);
margin-bottom: 20px;
padding-bottom: 10px;
}
.sink-input {
}