generated from itdominator/Python-With-Gtk-Template
Improved CSS styling setup; fixed bug where highlighting something scroled the list
This commit is contained in:
parent
98ffd7c6b0
commit
54eada6c07
@ -31,10 +31,8 @@ class BaseContainer(Gtk.Box):
|
|||||||
|
|
||||||
def _setup_styling(self):
|
def _setup_styling(self):
|
||||||
self.set_orientation(Gtk.Orientation.VERTICAL)
|
self.set_orientation(Gtk.Orientation.VERTICAL)
|
||||||
self.set_margin_top(10)
|
ctx = self.get_style_context()
|
||||||
self.set_margin_bottom(10)
|
ctx.add_class("base-container")
|
||||||
self.set_margin_left(10)
|
|
||||||
self.set_margin_right(10)
|
|
||||||
|
|
||||||
def _setup_signals(self):
|
def _setup_signals(self):
|
||||||
...
|
...
|
||||||
@ -50,7 +48,10 @@ class BaseContainer(Gtk.Box):
|
|||||||
label2 = Gtk.Label("Playback")
|
label2 = Gtk.Label("Playback")
|
||||||
label2.set_xalign(0.0)
|
label2.set_xalign(0.0)
|
||||||
for sink_input in self.sink_inputs:
|
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(label2)
|
||||||
self.add(scroll)
|
self.add(scroll)
|
||||||
@ -61,13 +62,20 @@ class BaseContainer(Gtk.Box):
|
|||||||
label1 = Gtk.Label("Output Devices")
|
label1 = Gtk.Label("Output Devices")
|
||||||
pulse = pulsectl.Pulse()
|
pulse = pulsectl.Pulse()
|
||||||
self.pulse_events = pulsectl.Pulse('event-printer')
|
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)
|
self.add(label1)
|
||||||
label1.set_xalign(0.0)
|
label1.set_xalign(0.0)
|
||||||
logger.debug(f"\n\nServer Info\n{si}\n\nSink Inputs:")
|
logger.debug(f"\n\nServer Info\n{si}\n\nSink Inputs:")
|
||||||
for sink in sink_list:
|
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.pulse = pulse
|
||||||
self.sink_inputs = sink_inputs
|
self.sink_inputs = sink_inputs
|
||||||
|
@ -28,11 +28,8 @@ class SinkInputList(Gtk.ScrolledWindow):
|
|||||||
def _setup_styling(self):
|
def _setup_styling(self):
|
||||||
ctx = self.get_style_context()
|
ctx = self.get_style_context()
|
||||||
ctx.add_class("sink-list-container")
|
ctx.add_class("sink-list-container")
|
||||||
|
|
||||||
self.set_vexpand(True)
|
self.set_vexpand(True)
|
||||||
self.set_overlay_scrolling(False)
|
self.set_overlay_scrolling(False)
|
||||||
self.set_margin_top(20)
|
|
||||||
self.set_margin_bottom(10)
|
|
||||||
|
|
||||||
def _setup_signals(self):
|
def _setup_signals(self):
|
||||||
...
|
...
|
||||||
@ -49,7 +46,6 @@ class SinkInputList(Gtk.ScrolledWindow):
|
|||||||
self._vadjust = self.get_vadjustment()
|
self._vadjust = self.get_vadjustment()
|
||||||
|
|
||||||
box.set_orientation(Gtk.Orientation.VERTICAL)
|
box.set_orientation(Gtk.Orientation.VERTICAL)
|
||||||
self._vadjust.connect("changed", self._scroll_to_bottom)
|
|
||||||
|
|
||||||
viewport.add(box)
|
viewport.add(box)
|
||||||
self.add(viewport)
|
self.add(viewport)
|
||||||
@ -58,10 +54,17 @@ class SinkInputList(Gtk.ScrolledWindow):
|
|||||||
for child in self._box.get_children():
|
for child in self._box.get_children():
|
||||||
if index == child.sink.index:
|
if index == child.sink.index:
|
||||||
child.do_update()
|
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):
|
def _handle_new_sync_input(self, index):
|
||||||
sink_input = self.pulse.sink_input_list()[-1]
|
sink_input = self.pulse.sink_input_list()[-1]
|
||||||
self._box.add( AudioSink(self.pulse, sink_input) )
|
self._box.add( AudioSink(self.pulse, sink_input) )
|
||||||
|
self._scroll_to_bottom(self._vadjust)
|
||||||
|
|
||||||
def _handle_del_sync_input(self, index):
|
def _handle_del_sync_input(self, index):
|
||||||
parent = self.get_parent()
|
parent = self.get_parent()
|
||||||
@ -72,6 +75,7 @@ class SinkInputList(Gtk.ScrolledWindow):
|
|||||||
for child in self._box.get_children():
|
for child in self._box.get_children():
|
||||||
if index == child.sink.index:
|
if index == child.sink.index:
|
||||||
child.destroy()
|
child.destroy()
|
||||||
|
self._scroll_to_bottom(self._vadjust)
|
||||||
|
|
||||||
def _scroll_to_bottom(self, adjustment):
|
def _scroll_to_bottom(self, adjustment):
|
||||||
self._vadjust.set_value( adjustment.get_upper() )
|
self._vadjust.set_value( adjustment.get_upper() )
|
||||||
|
@ -4,11 +4,20 @@
|
|||||||
border: 2px solid rgba(0, 0, 0, 0.0);
|
border: 2px solid rgba(0, 0, 0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.sink-list-container {
|
.base-container {
|
||||||
/* Neon Blue 00e8ff border */
|
margin: 10px;
|
||||||
/* border: 2px solid rgba(0, 232, 255, 0.25); */
|
}
|
||||||
/* Dark Bergundy */
|
|
||||||
/* border: 2px solid rgba(116, 0, 0, 0.64); */
|
.sink-list-container {
|
||||||
/* Snow White */
|
margin-bottom: 10px;
|
||||||
border: 2px solid rgba(255, 255, 255, 0.34);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.sink-device {
|
||||||
|
border-bottom: 2px solid rgba(255, 255, 255, 0.34);
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sink-input {
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user