diff --git a/ocarina/body/button.py b/ocarina/body/button.py index 1ccebf5b..c5c62c96 100644 --- a/ocarina/body/button.py +++ b/ocarina/body/button.py @@ -27,9 +27,11 @@ def make_text(text): def default_button_attrs(button, img, tooltip, show): button.set_relief(gtk.RELIEF_NONE) - img.show() - button.add(img) - button.set_tooltip_text(tooltip) + if img != None: + img.show() + button.add(img) + if tooltip != None: + button.set_tooltip_text(tooltip) if show == True: button.show() @@ -118,3 +120,21 @@ def dislike_button(show): like = None controls.set_like(like) return make_toggle("images/thumbs_down.png", set_dislike, "I don't like this", False, show) + +def volume_button(volume, show): + b = gtk.VolumeButton() + default_button_attrs(b, None, None, show) + b.get_adjustment().set_page_increment(0.05) + b.set_value(volume) + + def resize(button): + image = b.get_children()[0] + icon = image.get_icon_name()[0] + image.set_from_icon_name(icon, gtk.ICON_SIZE_MENU) + + def changed(button, value): + controls.set_volume(value) + resize(button) + b.connect("value-changed", changed) + resize(b) + return b diff --git a/ocarina/body/header/__init__.py b/ocarina/body/header/__init__.py index 259e4f26..1e3998aa 100644 --- a/ocarina/body/header/__init__.py +++ b/ocarina/body/header/__init__.py @@ -27,6 +27,7 @@ header_body.pack_start(sep, False, False) add_button( "GOTO", button.goto_button(True)) add_button( "CLEAR", button.clear_button(True)) add_button("RANDOM", button.random_button(libsaria.prefs.get_pref("libsaria.random"), True)) +add_button("VOLUME", button.volume_button(libsaria.prefs.get_pref("libsaria.audio.volume"), True)) #import ocarina #from ocarina.components import button