Skip to content

Commit

Permalink
temporary workarounds to allow display in gtk 3.18 and later - only w…
Browse files Browse the repository at this point in the history
…orks with left arranged spectrum at the moment - issue #8
  • Loading branch information
fossfreedom committed Jul 10, 2016
1 parent 90a93f2 commit 25e0dfe
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion spectrum.py
Expand Up @@ -135,8 +135,10 @@ def _connect_signals(self):

def _get_rb_location(self):
if self.position == 1:
print ("sidebar")
new_location = RB.ShellUILocation.SIDEBAR
else:
print ("bottom")
new_location = RB.ShellUILocation.MAIN_BOTTOM

return new_location
Expand Down Expand Up @@ -183,7 +185,9 @@ def _make_visible(self, playing):

self.current_location = self._get_rb_location()
self.shell.add_widget(self.scroll,
self.current_location, expand=False, fill=True)
self.current_location, expand=True, fill=True)
# temporarily change expand to True - something has happened in latest GTK 3,18 and later that
# fails to give the right size allocation to new objects
self.scroll.show_all()
elif self.scroll:
self.scroll.hide()
Expand Down Expand Up @@ -254,6 +258,7 @@ def initialise(self, shell):

self.shell = shell

Gst.init([])
self.spectrum = Gst.ElementFactory.make("spectrum", "spectrum")
self.spectrum.set_property("bands", int(self.spect_bands))
self.spectrum.set_property("threshold", self.threshold) # default -60
Expand Down Expand Up @@ -400,6 +405,10 @@ def on_configure_event(self, widget, event):
else:
self.spect_bands = self.max_bands

print (int(self.spect_bands))
if int(self.spect_bands) == 0:
return False

self.spectrum.set_property("bands", int(self.spect_bands))

self.max_magnitude = []
Expand All @@ -417,6 +426,8 @@ def draw_spectrum(self, cr):
data = self.spect_data
if data:
for i in range(int(self.spect_bands)):
if i < 2:
continue # ignore the bottom end of the spectrum
cr.push_group()
cr.set_source_rgb(0, 1, 1)
rect = Rect(start, -data[i], self.band_width, self.spect_height + data[i])
Expand Down

0 comments on commit 25e0dfe

Please sign in to comment.