~markjtully/icon-library/gtk3

« back to all changes in this revision

Viewing changes to trunk/custom_widgets.py

  • Committer: Matthew McGowan
  • Date: 2009-09-27 11:31:55 UTC
  • Revision ID: matthew.joseph.mcgowan@gmail.com-20090927113155-1bvwq76xp4daem6f
on loading of iconset properties actually check the filesystem for discoverable icons as some themes report more (or less) than actually exists.  A note is displayed at the bottom of the properties dialog if there is a mismatch between reported and discoverable icons in the set

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
 
132
132
 
133
133
class IconPreview(gtk.DrawingArea):
134
 
    def __init__(self, path, size):
 
134
    def __init__(self, pixbuf):
135
135
        gtk.DrawingArea.__init__(self)
136
 
        self.path = path
137
 
 
138
 
        if size == 'scalable':
139
 
            self.pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(path, 64, 64)
140
 
        else:
141
 
            self.pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(path, size, size)
142
 
 
143
 
        x, y = self.pixbuf.get_width(), self.pixbuf.get_height()
 
136
 
 
137
        x, y = pixbuf.get_width(), pixbuf.get_height()
144
138
        if max(x,y) >= 72:
145
139
            self.set_size_request(
146
140
                x + 8,
149
143
        else:
150
144
            self.set_size_request(72, 72)
151
145
 
152
 
        self.set_events(gtk.gdk.BUTTON_PRESS_MASK)
153
 
        self.connect("expose_event", self.expose)
 
146
        self.connect("expose_event", self.expose, pixbuf)
154
147
        return
155
148
 
156
 
    def expose(self, widget, event):
 
149
    def expose(self, widget, event, pixbuf):
157
150
        cr = widget.window.cairo_create()
158
151
        cr.rectangle(event.area)
159
152
        cr.clip()
160
153
        alloc = self.get_allocation()
161
 
        self.draw(cr, alloc, self.pixbuf)
 
154
        self.draw(cr, alloc, pixbuf)
162
155
        del cr
163
156
        return False
164
157