/usr/share/cinnamon-screensaver/widgets/volumeSlider.py is in cinnamon-screensaver 3.2.13-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | #! /usr/bin/python3
from gi.repository import Gtk, Gdk
from util import trackers
class VolumeSlider(Gtk.Scale):
"""
Custom GtkScale widget for controlling the volume.
"""
def __init__(self):
super(VolumeSlider, self).__init__(orientation=Gtk.Orientation.HORIZONTAL)
self.set_can_focus(False)
self.muted = False
self.set_range(0, 100.0)
self.set_increments(5.0, 5.0)
self.get_style_context().remove_class("scale")
self.get_style_context().add_class("volumeslider")
self.set_round_digits(0)
self.set_draw_value(False)
self.set_size_request(130, -1)
self.set_halign(Gtk.Align.CENTER)
self.set_valign(Gtk.Align.CENTER)
trackers.con_tracker_get().connect(self,
"draw",
self.on_draw)
def set_muted(self, muted):
if muted != self.muted:
self.muted = muted
self.queue_draw()
def on_draw(self, widget, cr):
ctx = widget.get_style_context()
alloc = self.get_allocation()
padding = ctx.get_padding(Gtk.StateFlags.NORMAL)
border = ctx.get_border(Gtk.StateFlags.NORMAL)
x = padding.left + border.left
y = padding.top + border.top
width = alloc.width - padding.left - padding.right - border.left - border.right
height = alloc.height - padding.top - padding.bottom - border.top - border.bottom
floor = y + height
end = x + width
value = round(self.get_value())
value_x = x + ((value / 100) * width)
value_y = floor - ((value / 100) * height)
if self.muted:
fill_color = ctx.get_color(Gtk.StateFlags.INSENSITIVE)
bg_color = ctx.get_background_color(Gtk.StateFlags.INSENSITIVE)
else:
fill_color = ctx.get_color(Gtk.StateFlags.NORMAL)
bg_color = ctx.get_background_color(Gtk.StateFlags.NORMAL)
cr.save()
cr.new_sub_path()
cr.move_to(x, floor)
cr.line_to(end, floor)
cr.line_to(end, y)
cr.close_path()
Gdk.cairo_set_source_rgba(cr, bg_color)
cr.fill()
cr.restore()
cr.save()
cr.new_sub_path()
cr.move_to(x, floor)
cr.line_to(value_x, floor)
cr.line_to(value_x, value_y)
cr.close_path()
Gdk.cairo_set_source_rgba(cr, fill_color)
cr.fill()
cr.restore()
return True
|