~laszlok/jokosher/main

« back to all changes in this revision

Viewing changes to Jokosher/Utils.py

  • Committer: laszlop
  • Date: 2007-01-09 02:46:34 UTC
  • Revision ID: svn-v3-trunk1:8cf4620e-9a09-0410-af63-e2e309b9c8e0:JonoEdit%2Ftrunk:1139
 * Put the two tango volume icons that we use in the images folder. They will only be loaded for non GNOME users, since they don't have those icons in their icon theme (these icons are not in stock GTK).
 * Fix undo for muting instruments because I recently removed keywords support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
#-------------------------------------------------------------------------------
11
11
 
12
12
import xml.dom.minidom as xml
13
 
import math
14
 
import gtk
 
13
import math, os.path
 
14
import gtk, gobject
15
15
from subprocess import call
 
16
import Globals
16
17
 
17
18
#_____________________________________________________________________
18
19
 
52
53
        
53
54
#_____________________________________________________________________
54
55
 
 
56
def GetIconThatMayBeMissing(iconName, iconSize):
 
57
        """
 
58
        First tries to get the icon with the given name from the icon theme.
 
59
        If that fails, it will try and load it from the Jokosher image directory.
 
60
        
 
61
        Parameters:
 
62
                iconName -- the string of the icon's name
 
63
                iconSize -- an icon size from the gtk.
 
64
        
 
65
        Returns:
 
66
                an instance of gtk.gdk.Pixbuf that contains the requested image.
 
67
        """
 
68
        pixbuf = None
 
69
        try:
 
70
                pixbuf = gtk.icon_theme_get_default().load_icon(iconName, iconSize, 0)
 
71
        except gobject.GError:
 
72
                path = os.path.join(Globals.IMAGE_PATH, "%s.png" % iconName)
 
73
                try:
 
74
                        pixbuf = gtk.gdk.pixbuf_new_from_file(path)
 
75
                except:
 
76
                        pass
 
77
        
 
78
        if pixbuf:
 
79
                image = gtk.Image()
 
80
                image.set_from_pixbuf(pixbuf)
 
81
        else:
 
82
                image = gtk.image_new_from_stock(gtk.STOCK_MISSING_IMAGE, iconSize)
 
83
        
 
84
        return image
 
85
 
 
86
#_____________________________________________________________________
 
87
 
55
88
def DbToFloat(f):
56
89
        """
57
90
        Converts f from the decibel scale to a float.