get_pixbuf_from_data can return type now
This commit is contained in:
		
							parent
							
								
									528871d72c
								
							
						
					
					
						commit
						7ea9c3eac4
					
				
					 1 changed files with 8 additions and 3 deletions
				
			
		| 
						 | 
					@ -305,8 +305,9 @@ def get_abspath_for_script(scriptname, want_type = False):
 | 
				
			||||||
	else:
 | 
						else:
 | 
				
			||||||
		return path_to_script
 | 
							return path_to_script
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_pixbuf_from_data(file_data):
 | 
					def get_pixbuf_from_data(file_data, want_type = False):
 | 
				
			||||||
	'''Gets image data and returns gtk.gdk.Pixbuf'''
 | 
						'''Gets image data and returns gtk.gdk.Pixbuf
 | 
				
			||||||
 | 
						if want_type is True it also returns 'jpeg', 'png' etc'''
 | 
				
			||||||
	pixbufloader = gtk.gdk.PixbufLoader()
 | 
						pixbufloader = gtk.gdk.PixbufLoader()
 | 
				
			||||||
	try:
 | 
						try:
 | 
				
			||||||
		pixbufloader.write(file_data)
 | 
							pixbufloader.write(file_data)
 | 
				
			||||||
| 
						 | 
					@ -315,6 +316,10 @@ def get_pixbuf_from_data(file_data):
 | 
				
			||||||
	except gobject.GError: # 'unknown image format'
 | 
						except gobject.GError: # 'unknown image format'
 | 
				
			||||||
		pixbuf = None
 | 
							pixbuf = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if want_type:
 | 
				
			||||||
 | 
							typ = pixbufloader.get_format()['name']
 | 
				
			||||||
 | 
							return pixbuf, typ
 | 
				
			||||||
 | 
						else:
 | 
				
			||||||
		return pixbuf
 | 
							return pixbuf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_invisible_cursor():
 | 
					def get_invisible_cursor():
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue