305
305
self.section_button = section_button
306
306
self.popup = None
307
self._dark_color = Gdk.RGBA(red=0,green=0,blue=0)
308
self.connect('style-updated', self.on_style_updated)
307
#~ self._dark_color = Gdk.RGBA(red=0,green=0,blue=0)
308
#~ self.connect('style-updated', self.on_style_updated)
309
309
self.connect("button-press-event", self.on_button_press)
312
def do_draw(self, cr):
313
a = self.get_allocation()
315
cr.rectangle(-0.5, -1.5, a.width, a.height+3)
316
Gdk.cairo_set_source_rgba(cr, self._dark_color)
318
cr.rectangle(0.5, -1.5, a.width-2, a.height+3)
319
cr.set_source_rgba(1,1,1, 0.07)
322
for child in self: self.propagate_draw(child, cr)
312
#~ def do_draw(self, cr):
313
#~ a = self.get_allocation()
314
#~ cr.set_line_width(1)
315
#~ cr.rectangle(-0.5, -1.5, a.width, a.height+3)
316
#~ Gdk.cairo_set_source_rgba(cr, self._dark_color)
318
#~ cr.rectangle(0.5, -1.5, a.width-2, a.height+3)
319
#~ cr.set_source_rgba(1,1,1, 0.07)
322
#~ for child in self: self.propagate_draw(child, cr)
325
325
def on_button_press(self, button, event):
326
326
if self.popup is None:
327
327
self.build_channel_selector()
328
328
self.show_channel_sel_popup(self, event)
331
def on_style_updated(self, widget):
332
context = widget.get_style_context()
334
context.add_class("menu")
335
bgcolor = context.get_background_color(Gtk.StateFlags.NORMAL)
338
self._dark_color = darken(bgcolor, 0.5)
331
#~ def on_style_updated(self, widget):
332
#~ context = widget.get_style_context()
334
#~ context.add_class("menu")
335
#~ bgcolor = context.get_background_color(Gtk.StateFlags.NORMAL)
338
#~ self._dark_color = darken(bgcolor, 0.5)
341
341
def show_channel_sel_popup(self, widget, event):
376
376
self.label.set_name("section-selector")
377
377
self.set_name("section-selector")
378
378
self.draw_hint_has_channel_selector = False
379
self._dark_color = Gdk.RGBA(red=0,green=0,blue=0)
380
self.connect('style-updated', self.on_style_updated)
379
#~ self._dark_color = Gdk.RGBA(red=0,green=0,blue=0)
380
#~ self.connect('style-updated', self.on_style_updated)
381
381
self.label.connect("draw", self.on_label_draw)
384
384
def do_draw(self, cr):
385
385
a = self.get_allocation()
386
386
if self.get_active():
387
r, g, b = (self._dark_color.red,
388
self._dark_color.green,
389
self._dark_color.blue)
391
cr.rectangle(0, -1, a.width, a.height+2)
392
lin = cairo.LinearGradient(0, 0, 0, a.height)
393
lin.add_color_stop_rgba(0.0, r,g,b, 0.0)
394
lin.add_color_stop_rgba(0.25, r,g,b, 0.3)
395
lin.add_color_stop_rgba(0.5, r,g,b, 0.5)
396
lin.add_color_stop_rgba(0.75, r,g,b, 0.3)
397
lin.add_color_stop_rgba(1.0, r,g,b, 0.0)
400
cr.set_source_rgba(r,g,b)
403
elif self.draw_hint_has_channel_selector:
405
cr.move_to(a.width-0.5, -1)
406
cr.rel_line_to(0, a.height+2)
407
Gdk.cairo_set_source_rgba(cr, self._dark_color)
387
context = self.get_style_context()
389
state = self.get_state_flags()
390
context.set_state(state)
392
a = self.get_allocation()
397
height = a.height + 10
398
Gtk.render_background(context, cr,
400
Gtk.render_frame(context, cr,
410
404
for child in self:
411
405
self.propagate_draw(child, cr)
414
def on_style_updated(self, widget):
415
context = widget.get_style_context()
417
context.add_class("menu")
418
bgcolor = context.get_background_color(Gtk.StateFlags.NORMAL)
421
self._dark_color = darken(bgcolor, 0.5)
408
#~ def on_style_updated(self, widget):
409
#~ context = widget.get_style_context()
411
#~ context.add_class("menu")
412
#~ bgcolor = context.get_background_color(Gtk.StateFlags.NORMAL)
415
#~ self._dark_color = darken(bgcolor, 0.5)
424
418
def on_label_draw(self, label, cr):
425
419
layout = label.get_layout()