I wrote a daemon program, for searching through recipes from Gourmet Recipe Manager's database ( that is a recipe manager for GNU/Linux )
My program reads the information that it needs for each recipe element over a loop from the sqlite database.
(Such a daemon for Ubuntu Linux is called a 'scope'.
Such scopes give ubuntu unity more sources for its searching.)
'model' has the information, which gets delivered over DBUS to Ubuntu Unity.
In theory you are able to use an URI as the source for the image in 'model' ,
but the developers said me in IRC I am not able to use data URI's.
I tested that, too, and for me it did not work.
So I cache(d) the images in /tmp.
Now you are able to see all recipes, and search for specific one's per title, but the image asociation is simply wrong. if you search for the 2.th , the recipe of the 2.th gets shown, but with the image of the fist recipe in the sqlite table.
Here are two images, to understand the problem:
The 2.th recipe gets the image of the first recipe
I already looked in some IRC rooms for help, but no one could help me...
I think you have to save the state of each image somehow.
I would be pleased, if you have a solution that does not requiere to cache images.
The full source file can be viewed here: http://bazaar.launchpad.net/~gotwig/lens-cooking/lens-cooking/view/head:/unity-scope-gourmet
So, here is the specific part of my code:
if row[14]:
open('/tmp/unity-scope-gourmet/icon' + str(i), 'wb').write(row[14])
model.append(uri, '/tmp/unity-scope-gourmet/icon' + str(i), 1, "text/html", title, comment, uri)
else:
if os.path.exists('/tmp/unity-scope-gourmet/icon' + str(i)): os.remove('/tmp/unity-scope-gourmet/icon' + str(i))
model.append(uri, '', 1, "text/html", title, comment, uri)
It sounds like you a describing a simple counter error. It's not clear to me how you are initializing your counter 'i', but if it's off by one, the simple solution is to simply add one to it before using it, ie:
open('/tmp/unity-scope-gourmet/icon' + str(i+1), 'wb').write(row[14])
^^^
I solved the problem with combining the filename of the cached image with each ID of the recipe.
Code:
i = row[0]
See the complete solution here : http://bazaar.launchpad.net/~gotwig/lens-cooking/lens-cooking/revision/32