Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

gtklib: add get_icon_pixbuf() function

Changeset 4e5aab7faa7d

Parent a50fb34c9e85

by Yuki KODAMA

Changes to one file · Browse files at 4e5aab7faa7d Showing diff from parent a50fb34c9e85 Diff from another changeset...

 
124
125
126
 
 
 
 
 
 
 
 
 
 
127
128
129
130
131
132
133
134
135
136
137
138
139
140
 
 
 
141
142
143
 
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
 
 
 
 
 
 
 
 
 
142
143
144
145
146
147
@@ -124,20 +124,24 @@
  selection.select_iter(selected)   treeview.set_cursor(model.get_path(selected))   +def get_icon_pixbuf(name, size=gtk.ICON_SIZE_MENU): + path = paths.get_tortoise_icon(name) + if path: + try: + w, h = gtk.icon_size_lookup(size) + return gtk.gdk.pixbuf_new_from_file_at_size(path, w, h) + except: + pass + return None +  def get_icon_image(name):   if name.startswith('gtk'):   img = gtk.image_new_from_stock(name, gtk.ICON_SIZE_MENU)   else:   img = gtk.Image() - path = paths.get_tortoise_icon(name) - if not path: - return img - try: - width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU) - buf = gtk.gdk.pixbuf_new_from_file_at_size(path, width, height) - img.set_from_pixbuf(buf) - except: - pass + pixbuf = get_icon_pixbuf(name) + if pixbuf: + img.set_from_pixbuf(pixbuf)   return img    class MessageDialog(gtk.Dialog):