~tualatrix/ubuntu-tweak/arb-packaging

« back to all changes in this revision

Viewing changes to src/tweak/utils/icon.py

  • Committer: TualatriX
  • Date: 2009-10-22 14:14:56 UTC
  • Revision ID: git-v1:455f01496d7149fb9832dabdf1bf0eef506a0101
WIP, make most things works

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os
2
 
import gtk
3
 
 
4
 
__all__ = (
5
 
    'get_with_name',
6
 
)
7
 
 
8
 
icontheme = gtk.icon_theme_get_default()
9
 
 
10
 
def get_with_list(list, size):
11
 
    pixbuf = None
12
 
    for name in list:
13
 
        try:
14
 
            pixbuf = icontheme.load_icon(name, size, 0)
15
 
        except:
16
 
            continue
17
 
 
18
 
    if pixbuf is None:
19
 
        return get_with_name('name', size=size)
20
 
    else:
21
 
        return pixbuf
22
 
 
23
 
def get_with_name(name, alter='gtk-execute', size=24):
24
 
    try:
25
 
        pixbuf = icontheme.load_icon(name, size, 0)
26
 
    except:
27
 
        pixbuf = icontheme.load_icon(alter, size, 0)
28
 
 
29
 
    if pixbuf.get_height() != size:
30
 
        return pixbuf.scale_simple(size, size, gtk.gdk.INTERP_BILINEAR)
31
 
 
32
 
    return pixbuf