From 2931f2f1bc98096eb8d270ea467f8244a67e808c Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Wed, 06 Jun 2012 07:18:26 +0000 Subject: Add singular access point for getting image files; add 73% scaled images for resolution <=800 --- (limited to 'common/Util') diff --git a/common/Util/InstrumentPanel.py b/common/Util/InstrumentPanel.py index 014d794..6620031 100644 --- a/common/Util/InstrumentPanel.py +++ b/common/Util/InstrumentPanel.py @@ -164,7 +164,9 @@ class InstrumentPanel( gtk.EventBox ): if timeout >= 0 and time.time() > timeout: return False if loadStage[2] == 1: - self.loadData["btn"] = ImageRadioButton(self.firstTbBtn,Config.IMAGE_ROOT + category + '.png', Config.IMAGE_ROOT + category + 'sel.png', Config.IMAGE_ROOT + category + 'sel.png') + self.loadData["btn"] = ImageRadioButton(self.firstTbBtn, + category + '.png', category + 'sel.png', + category + 'sel.png') loadStage[2] = 2 if timeout >= 0 and time.time() > timeout: return False @@ -205,9 +207,13 @@ class InstrumentPanel( gtk.EventBox ): if loadStage[2] == 1: try: - self.loadData["instButton"] = ImageRadioButton(self.firstInstButton, Config.IMAGE_ROOT + instrument + '.png' , Config.IMAGE_ROOT + instrument + 'sel.png', Config.IMAGE_ROOT + instrument + 'sel.png') + self.loadData["instButton"] = ImageRadioButton( + self.firstInstButton, instrument + '.png', + instrument + 'sel.png', instrument + 'sel.png') except: - self.loadData["instButton"] = ImageRadioButton(self.firstInstButton, Config.IMAGE_ROOT + 'generic.png' , Config.IMAGE_ROOT + 'genericsel.png', Config.IMAGE_ROOT + 'genericsel.png') + self.loadData["instButton"] = ImageRadioButton( + self.firstInstButton, 'generic.png', + 'genericsel.png', 'genericsel.png') loadStage[2] = 2 if timeout >= 0 and time.time() > timeout: return False @@ -348,7 +354,8 @@ class DrumPanel( gtk.EventBox ): for drumkit in self.instrumentList: instBox = RoundVBox(fillcolor = Config.INST_BCK_COLOR, bordercolor = Config.PANEL_COLOR, radius = Config.PANEL_RADIUS) instBox.set_border_width(Config.PANEL_SPACING) - self.drums[drumkit] = ImageRadioButton(firstBtn, Config.IMAGE_ROOT + drumkit + '.png' , Config.IMAGE_ROOT + drumkit + 'sel.png', Config.IMAGE_ROOT + drumkit + 'sel.png') + self.drums[drumkit] = ImageRadioButton(firstBtn, drumkit + '.png', + drumkit + 'sel.png', drumkit + 'sel.png') self.drums[drumkit].clickedHandler = self.drums[drumkit].connect('clicked',self.setDrums,drumkit) if firstBtn == None: firstBtn = self.drums[drumkit] diff --git a/common/Util/Instruments.py b/common/Util/Instruments.py index 5ba8937..3fc2ecb 100644 --- a/common/Util/Instruments.py +++ b/common/Util/Instruments.py @@ -2,6 +2,7 @@ import os from gettext import gettext as _ import common.Config as Config +from common.Config import imagefile import common.Util.InstrumentDB as InstrumentDB from sugar.activity.activity import get_bundle_name @@ -19,8 +20,13 @@ INST_PERC = Config.INST_PERC instrumentDB = InstrumentDB.getRef() -def _addInstrument(name, csoundInstrumentId, instrumentRegister, category, loopStart, loopEnd, crossDur, ampScale=1, kit=None, kitStage=False, volatile=False, nameTooltip=""): - instrumentDB.addInstrumentFromArgs(name, csoundInstrumentId, instrumentRegister, loopStart, loopEnd, crossDur, ampScale, kit, name, Config.IMAGE_ROOT + "/" + name + ".png", category, kitStage=kitStage, volatile=volatile, nameTooltip=nameTooltip) +def _addInstrument(name, csoundInstrumentId, instrumentRegister, category, + loopStart, loopEnd, crossDur, ampScale=1, kit=None, kitStage=False, + volatile=False, nameTooltip=""): + instrumentDB.addInstrumentFromArgs(name, csoundInstrumentId, + instrumentRegister, loopStart, loopEnd, crossDur, ampScale, kit, + name, imagefile(name + '.png'), category, kitStage=kitStage, + volatile=volatile, nameTooltip=nameTooltip) if Config.FEATURES_MIC: _addInstrument("mic1", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1, volatile=True) diff --git a/common/Util/LoopSettings.py b/common/Util/LoopSettings.py index d672050..a36dd94 100644 --- a/common/Util/LoopSettings.py +++ b/common/Util/LoopSettings.py @@ -45,7 +45,7 @@ class LoopSettings( gtk.VBox ): loopedBox = gtk.HBox() loopedLabel = gtk.Label("Looped sound: ") loopedBox.pack_start(loopedLabel) - loopedToggle = ImageToggleButton(Config.IMAGE_ROOT+"checkOff.svg",Config.IMAGE_ROOT+"checkOn.svg") + loopedToggle = ImageToggleButton('checkOff.png', 'checkOn.png') loopedToggle.connect('button-press-event', self.handleLooped ) loopedBox.pack_start(loopedToggle) self.mainBox.pack_start(loopedBox, False, False, 5) @@ -80,7 +80,8 @@ class LoopSettings( gtk.VBox ): startBox = gtk.VBox() self.startAdjust = gtk.Adjustment( 0.01, 0, 1., .001, .001, 0) - self.GUI['startSlider'] = ImageVScale( Config.IMAGE_ROOT + "sliderEditVolume.png", self.startAdjust, 7 ) + self.GUI['startSlider'] = ImageVScale('sliderEditVolume.png', + self.startAdjust, 7) self.startAdjust.connect("value-changed", self.handleStart) self.GUI['startSlider'].set_inverted(True) self.GUI['startSlider'].set_size_request(50, 200) @@ -93,7 +94,8 @@ class LoopSettings( gtk.VBox ): endBox = gtk.VBox() self.endAdjust = gtk.Adjustment( 0.9, 0, 1, .001, .001, 0) - self.GUI['endSlider'] = ImageVScale( Config.IMAGE_ROOT + "sliderEditVolume.png", self.endAdjust, 7 ) + self.GUI['endSlider'] = ImageVScale('sliderEditVolume.png', + self.endAdjust, 7) self.endAdjust.connect("value-changed", self.handleEnd) self.GUI['endSlider'].set_inverted(True) self.GUI['endSlider'].set_size_request(50, 200) @@ -106,7 +108,8 @@ class LoopSettings( gtk.VBox ): durBox = gtk.VBox() self.durAdjust = gtk.Adjustment( 0.01, 0, 0.2, .001, .001, 0) - self.GUI['durSlider'] = ImageVScale( Config.IMAGE_ROOT + "sliderEditVolume.png", self.durAdjust, 7 ) + self.GUI['durSlider'] = ImageVScale('sliderEditVolume.png', + self.durAdjust, 7) self.durAdjust.connect("value-changed", self.handleDur) self.GUI['durSlider'].set_inverted(True) self.GUI['durSlider'].set_size_request(50, 200) @@ -120,13 +123,13 @@ class LoopSettings( gtk.VBox ): self.mainBox.pack_start(self.controlsBox, False, False, 5) previewBox = gtk.VBox() - self.playStopButton = ImageToggleButton(Config.IMAGE_ROOT + 'miniplay.png', Config.IMAGE_ROOT + 'stop.png') + self.playStopButton = ImageToggleButton('miniplay.png', 'stop.png') self.playStopButton.connect('button-press-event' , self.handlePlayButton) previewBox.pack_start(self.playStopButton) self.mainBox.pack_start(previewBox, False, False, 5) checkBox = gtk.VBox() - checkButton = ImageButton(Config.IMAGE_ROOT + 'check.png') + checkButton = ImageButton('check.png') checkButton.connect('clicked' , self.handleCheck) checkBox.pack_start(checkButton) self.mainBox.pack_start(checkBox, False, False, 5) diff --git a/common/Util/ThemeWidgets.py b/common/Util/ThemeWidgets.py index 6512655..7503d57 100644 --- a/common/Util/ThemeWidgets.py +++ b/common/Util/ThemeWidgets.py @@ -3,6 +3,7 @@ pygtk.require( '2.0' ) import gtk import logging import common.Config as Config +from common.Config import imagefile from sugar.graphics.combobox import ComboBox from sugar.graphics.palette import Palette, WidgetInvoker @@ -106,7 +107,10 @@ widget "*%s*" style "scale_style" self.set_value( round(self.snap*self.get_value())/self.snap ) class ImageVScale( gtk.VScale ): - def __init__( self, image_name, adjustment = None, slider_border = 0, insensitive_name = None, trough_color = "#3D403A", snap = False ): + def __init__(self, image_name, adjustment=None, slider_border=0, + insensitive_name=None, trough_color="#3D403A", snap=False): + image_name = imagefile(image_name) + gtk.VScale.__init__( self, adjustment ) if snap: self.snap = 1/snap @@ -726,7 +730,12 @@ class RoundFixed( gtk.Fixed ): return False class ImageButton(gtk.Button): - def __init__( self, mainImg_path, clickImg_path = None, enterImg_path = None, backgroundFill = None ): + def __init__(self, mainImg_path, clickImg_path=None, enterImg_path=None, + backgroundFill=None ): + mainImg_path = imagefile(mainImg_path) + clickImg_path = imagefile(clickImg_path) + enterImg_path = imagefile(enterImg_path) + gtk.Button.__init__(self) self.alloc = None win = gtk.gdk.get_default_root_window() @@ -869,7 +878,12 @@ class ImageButton(gtk.Button): class ImageToggleButton(gtk.ToggleButton): - def __init__(self , mainImg_path, altImg_path, enterImg_path = None, backgroundFill = None ): + def __init__(self , mainImg_path, altImg_path, enterImg_path=None, + backgroundFill=None): + mainImg_path = imagefile(mainImg_path) + altImg_path = imagefile(altImg_path) + enterImg_path = imagefile(enterImg_path) + gtk.ToggleButton.__init__(self) self.alloc = None self.within = False @@ -1028,7 +1042,12 @@ class ImageToggleButton(gtk.ToggleButton): class ImageRadioButton(gtk.RadioButton): - def __init__( self, group, mainImg_path, altImg_path, enterImg_path = None, backgroundFill = None ): + def __init__(self, group, mainImg_path, altImg_path, enterImg_path=None, + backgroundFill=None): + mainImg_path = imagefile(mainImg_path) + altImg_path = imagefile(altImg_path) + enterImg_path = imagefile(enterImg_path) + gtk.RadioButton.__init__(self, group) self.alloc = None self.within = False -- cgit v0.9.1