~andrewsomething/ubuntu/precise/compizconfig-settings-manager/first_run_warning

« back to all changes in this revision

Viewing changes to ccm/Utils.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2007-08-10 17:01:48 UTC
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20070810170148-ccdieecssi5r9plt
Tags: upstream-0.0+git20070810
ImportĀ upstreamĀ versionĀ 0.0+git20070810

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
from ccm.Constants import *
30
30
 
 
31
import locale
 
32
import gettext
 
33
locale.setlocale(locale.LC_ALL, "")
 
34
gettext.bindtextdomain("ccsm", DataDir + "/locale")
 
35
gettext.textdomain("ccsm")
 
36
_ = gettext.gettext
 
37
 
31
38
def getScreens():
32
39
        screens = []
33
40
        display = gtk.gdk.display_get_default()
53
60
        def __init__(self, name=None, type=ImageNone, size = 32):
54
61
                gtk.Image.__init__(self)
55
62
 
56
 
                if type == ImagePlugin and name != None:
57
 
                        iconpath = "%s/plugin-%s.svg" % (PixmapDir, name)
58
 
                        if not os.path.exists(iconpath):
59
 
                                iconpath = "%s/plugin-unknown.svg"%PixmapDir
60
 
                        try:
61
 
                                pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(iconpath, size, size)
62
 
                                self.set_from_pixbuf(pixbuf)
63
 
                        except:
64
 
                                self.set_from_stock(gtk.STOCK_MISSING_IMAGE, gtk.ICON_SIZE_BUTTON)
65
 
                
66
 
                elif type == ImageCategory and name != None:
67
 
                        iconpath = "%s/category-%s.svg" % (PixmapDir, name)
68
 
                        if not os.path.exists(iconpath):
69
 
                                iconpath = "%s/category-uncategorized.svg" % PixmapDir
70
 
                        try:
71
 
                                pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(iconpath, size, size)
72
 
                                self.set_from_pixbuf(pixbuf)
73
 
                        except:
74
 
                                self.set_from_stock(gtk.STOCK_MISSING_IMAGE, gtk.ICON_SIZE_BUTTON)
 
63
                if name != None:
 
64
                        if type == ImagePlugin:
 
65
                                iconpath = "%s/plugin-%s.svg" % (PixmapDir, name)
 
66
                                if not os.path.exists(iconpath):
 
67
                                        iconpath = "%s/plugin-unknown.svg"%PixmapDir
 
68
                                try:
 
69
                                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(iconpath, size, size)
 
70
                                        self.set_from_pixbuf(pixbuf)
 
71
                                except:
 
72
                                        self.set_from_stock(gtk.STOCK_MISSING_IMAGE, gtk.ICON_SIZE_BUTTON)
 
73
 
 
74
                        elif type == ImageCategory:
 
75
                                iconpath = "%s/category-%s.svg" % (PixmapDir, name)
 
76
                                if not os.path.exists(iconpath):
 
77
                                        iconpath = "%s/category-uncategorized.svg" % PixmapDir
 
78
                                try:
 
79
                                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(iconpath, size, size)
 
80
                                        self.set_from_pixbuf(pixbuf)
 
81
                                except:
 
82
                                        self.set_from_stock(gtk.STOCK_MISSING_IMAGE, gtk.ICON_SIZE_BUTTON)
 
83
 
 
84
                        elif type == ImageThemed:
 
85
                                iconTheme = gtk.icon_theme_get_default()
 
86
                                try:
 
87
                                        pixbuf = iconTheme.load_icon(name, size, 0)
 
88
                                        self.set_from_pixbuf(pixbuf)
 
89
                                except:
 
90
                                        self.set_from_stock(gtk.STOCK_MISSING_IMAGE, gtk.ICON_SIZE_BUTTON)
 
91
 
 
92
                        elif type == ImageStock:
 
93
                                try:
 
94
                                        self.set_from_stock(name, size)
 
95
                                except:
 
96
                                        self.set_from_stock(gtk.STOCK_MISSING_IMAGE, gtk.ICON_SIZE_BUTTON)
75
97
 
76
98
class Label(gtk.Label):
77
99
        def __init__(self, value = "", wrap = 160):
81
103
                self.set_line_wrap(True)
82
104
                self.set_size_request(wrap, -1)
83
105
 
 
106
class NotFoundBox(gtk.Alignment):
 
107
        def __init__(self, value):
 
108
                gtk.Alignment.__init__(self, 0.5, 0.5, 0.0, 0.0)
 
109
                
 
110
                box = gtk.HBox()
 
111
                self.Warning = gtk.Label()
 
112
                self.Markup = _("<span size=\"large\"><b>No matches found.</b> </span><span>\n\n Your filter \"<b>%s</b>\" does not match any items.</span>")
 
113
                self.Warning.set_markup(self.Markup % value)
 
114
                image = Image("face-surprise", ImageThemed, 48)
 
115
                        
 
116
                box.pack_start(image, False, False, 0)
 
117
                box.pack_start(self.Warning, True, True, 15)
 
118
                self.add(box)
 
119
 
 
120
        def update(self, value):
 
121
                self.Warning.set_markup(self.Markup % value)
 
122
 
84
123
# Updates all registered setting when they where changed through CompizConfig
85
124
class Updater:
86
125
        def __init__(self, context):
126
165
        for setting in settings:
127
166
                if noActions and setting.Type == 'Action':
128
167
                        continue
129
 
                if setting.Name == '____plugin_enabled':
130
 
                        continue
131
168
                # First run, only search in shortDesc and name
132
169
                if run == 0 or (singleRun and run.count(0) != 0):
133
170
                        shortDesc = setting.ShortDesc.lower()
175
212
def HasOnlyType(settings, type):
176
213
        empty = True
177
214
        for setting in settings:
178
 
                        if not setting.Name == '____plugin_enabled':
179
 
                                empty = False
180
 
                                if setting.Type != type:
181
 
                                        return False
 
215
                empty = False
 
216
                if setting.Type != type:
 
217
                        return False
182
218
        return not empty