unity-scope-openclipart-0.1+13.10.20130723/0000755000015700001700000000000012173421423020477 5ustar pbuserpbgroup00000000000000unity-scope-openclipart-0.1+13.10.20130723/po/0000755000015700001700000000000012173421423021115 5ustar pbuserpbgroup00000000000000unity-scope-openclipart-0.1+13.10.20130723/po/POTFILES.in0000644000015700001700000000013712173420530022671 0ustar pbuserpbgroup00000000000000[encoding: UTF-8] src/unity_openclipart_daemon.py [type: gettext/ini]data/openclipart.scope.in unity-scope-openclipart-0.1+13.10.20130723/po/unity-scope-openclipart.pot0000644000015700001700000000226312173420530026437 0ustar pbuserpbgroup00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2013-02-21 01:57+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: ../src/unity_openclipart_daemon.py:32 ../data/openclipart.scope.in.h:4 msgid "Search OpenClipArt" msgstr "" #: ../src/unity_openclipart_daemon.py:33 msgid "Sorry, there are no OpenClipArt results that match your search." msgstr "" #: ../src/unity_openclipart_daemon.py:34 msgid "Powered by OpenClipArt" msgstr "" #: ../src/unity_openclipart_daemon.py:42 msgid "Images" msgstr "" #: ../data/openclipart.scope.in.h:1 msgid "openclipart;clipart;svg;vector;" msgstr "" #: ../data/openclipart.scope.in.h:2 msgid "OpenClipArt" msgstr "" #: ../data/openclipart.scope.in.h:3 msgid "Find OpenClipArt graphics" msgstr "" unity-scope-openclipart-0.1+13.10.20130723/MANIFEST.in0000644000015700001700000000007612173420530022236 0ustar pbuserpbgroup00000000000000include MANIFEST.in include src/* include data/* include po/* unity-scope-openclipart-0.1+13.10.20130723/tests/0000755000015700001700000000000012173421423021641 5ustar pbuserpbgroup00000000000000unity-scope-openclipart-0.1+13.10.20130723/tests/data/0000755000015700001700000000000012173421423022552 5ustar pbuserpbgroup00000000000000unity-scope-openclipart-0.1+13.10.20130723/tests/data/mock_openclipart_fail0000644000015700001700000000000612173420530027013 0ustar pbuserpbgroup00000000000000 unity-scope-openclipart-0.1+13.10.20130723/tests/data/mock_openclipart_pass0000644000015700001700000003763212173420530027065 0ustar pbuserpbgroup00000000000000 OpenClipart.org http://openclipart.org Download, Sample, Cut-up, Share. en-US http://openclipart.org/assets/images/images/logo-no-text.jpg http://openclipart.org OpenClipart.org 93 114 water drop http://openclipart.org/detail/237/water-drop-by-tomas_arad Sat, 30 Sep 2006 05:26:46 -0400 tomas_arad drop, blue, water Done in Skencil. http://openclipart.org/detail/237/water-drop-by-tomas_arad http://creativecommons.org/licenses/publicdomain Hot water bottle http://openclipart.org/detail/1710/hot-water-bottle-by-karderio Sat, 02 Dec 2006 01:01:20 -0400 karderio Hot water bottle, rubber http://openclipart.org/detail/1710/hot-water-bottle-by-karderio http://creativecommons.org/licenses/publicdomain Water Lily http://openclipart.org/detail/2110/water-lily-by-leland_mcinnes Fri, 15 Dec 2006 22:22:20 -0400 leland_mcinnes A water lily flower. http://openclipart.org/detail/2110/water-lily-by-leland_mcinnes http://creativecommons.org/licenses/publicdomain Water Drop http://openclipart.org/detail/4063/water-drop-by-lagartoflojo Mon, 23 Apr 2007 19:05:17 -0400 lagartoflojo A nice water drop. I made it because I couldn't find any that I liked, much less in SVG format. It uses Inkscape 0.45's blur filter. http://openclipart.org/detail/4063/water-drop-by-lagartoflojo http://creativecommons.org/licenses/publicdomain Water Tower http://openclipart.org/detail/8277/water-tower-by-gerald_g-8277 Tue, 13 Nov 2007 21:03:24 -0400 Gerald_G I snapped a photo of this water tower on a blistering cold day in January. The image was so striking, I thought it would make a cool clip art. http://openclipart.org/detail/8277/water-tower-by-gerald_g-8277 http://creativecommons.org/licenses/publicdomain Glass of water http://openclipart.org/detail/15297/glass-of-water-by-dynv Sun, 02 Mar 2008 17:50:09 -0400 DynV Transparent glass almost filled with aqua content signifying water. http://openclipart.org/detail/15297/glass-of-water-by-dynv http://creativecommons.org/licenses/publicdomain Water and Lava Filter http://openclipart.org/detail/20147/water-and-lava-filter-by-wsnaccad-20147 Thu, 13 Nov 2008 08:18:00 -0400 wsnaccad Modified Chrisdesign's Wave Filter, to create this water and lava filter. Different colors can be used also. Visit my blog to see the link to the pdf tutorial on how to use it. http://www.inkscapade.blogspot.com http://openclipart.org/detail/20147/water-and-lava-filter-by-wsnaccad-20147 http://creativecommons.org/licenses/publicdomain Water expansion in flask http://openclipart.org/detail/21693/water-expansion-in-flask-by-tom Thu, 26 Feb 2009 18:01:41 -0400 tom Measuring water expansion with heat. grayscale trace From GENERAL SCIENCE BY BERTHA M. CLARK, PH.D. (Gutenberg EBook 16593) http://openclipart.org/detail/21693/water-expansion-in-flask-by-tom http://creativecommons.org/licenses/publicdomain Water expansion in flask, colour http://openclipart.org/detail/21696/water-expansion-in-flask-colour-by-tom-21696 Thu, 26 Feb 2009 18:05:56 -0400 tom Measuring water expansion with heat. Colour re-trace. Original diagram. From GENERAL SCIENCE BY BERTHA M. CLARK, PH.D. (Gutenberg EBook 16593) http://openclipart.org/detail/21696/water-expansion-in-flask-colour-by-tom-21696 http://creativecommons.org/licenses/publicdomain Pitcher of Water http://openclipart.org/detail/30367/pitcher-of-water-by-bradpitcher Tue, 09 Mar 2010 01:35:39 -0400 bradpitcher A pitcher of water http://openclipart.org/detail/30367/pitcher-of-water-by-bradpitcher http://creativecommons.org/licenses/publicdomain Water droplet http://openclipart.org/detail/38857/water-droplet-by-mbalax Wed, 07 Apr 2010 15:21:58 -0400 mbalax Water droplet. http://openclipart.org/detail/38857/water-droplet-by-mbalax http://creativecommons.org/licenses/publicdomain Água - Water Splash http://openclipart.org/detail/63769/?gua---water-splash-by-leandrosciola@gmail.com Mon, 31 May 2010 01:20:11 -0400 leandrosciola@gmail.com ?gua - Water Splash http://openclipart.org/detail/63769/?gua---water-splash-by-leandrosciola@gmail.com http://creativecommons.org/licenses/publicdomain beacon, safe water mark http://openclipart.org/detail/65989/beacon-safe-water-mark-by-seafish Fri, 11 Jun 2010 21:16:07 -0400 seafish beacon safe-water-mark, sea chart symbol http://openclipart.org/detail/65989/beacon-safe-water-mark-by-seafish http://creativecommons.org/licenses/publicdomain beacon safe water mark http://openclipart.org/detail/65995/beacon-safe-water-mark-by-seafish-65995 Fri, 11 Jun 2010 21:17:10 -0400 seafish beacon safe water mark, symbol http://openclipart.org/detail/65995/beacon-safe-water-mark-by-seafish-65995 http://creativecommons.org/licenses/publicdomain buoy safe water mark http://openclipart.org/detail/66049/buoy-safe-water-mark-by-seafish Fri, 11 Jun 2010 21:27:38 -0400 seafish sea chart symbol, buoy, safe water mark http://openclipart.org/detail/66049/buoy-safe-water-mark-by-seafish http://creativecommons.org/licenses/publicdomain buoy safe water mark http://openclipart.org/detail/66055/buoy-safe-water-mark-by-seafish-66055 Fri, 11 Jun 2010 21:32:40 -0400 seafish bouy, symbol, safe water mark http://openclipart.org/detail/66055/buoy-safe-water-mark-by-seafish-66055 http://creativecommons.org/licenses/publicdomain spherical buoy safe water mark http://openclipart.org/detail/66253/spherical-buoy-safe-water-mark-by-seafish Fri, 11 Jun 2010 22:06:47 -0400 seafish sea chart symbol for spherical safe water mark http://openclipart.org/detail/66253/spherical-buoy-safe-water-mark-by-seafish http://creativecommons.org/licenses/publicdomain Water tap (greyscale) http://openclipart.org/detail/118135/water-tap-greyscale-by-netrat Sun, 13 Feb 2011 13:31:01 -0400 NetRat Water tap (greyscale) http://openclipart.org/detail/118135/water-tap-greyscale-by-netrat http://creativecommons.org/licenses/publicdomain Water tap (monochrome) http://openclipart.org/detail/118141/water-tap-monochrome-by-netrat Sun, 13 Feb 2011 13:31:54 -0400 NetRat Water tap (monochrome) http://openclipart.org/detail/118141/water-tap-monochrome-by-netrat http://creativecommons.org/licenses/publicdomain Water molecule http://openclipart.org/detail/174762/water-molecule-by-nunopequito-174762 Sat, 02 Feb 2013 16:46:24 -0400 NunoPequito A molecule of water http://openclipart.org/detail/174762/water-molecule-by-nunopequito-174762 http://creativecommons.org/licenses/publicdomain unity-scope-openclipart-0.1+13.10.20130723/tests/test_openclipart.py0000644000015700001700000000411412173420530025570 0ustar pbuserpbgroup00000000000000#! /usr/bin/python3 # -*- coding: utf-8 -*- from gi.repository import Unity from unittest import TestCase import imp class ResultSet(Unity.ResultSet): def __init__(self): Unity.ResultSet.__init__(self) self.results = [] def do_add_result(self, result): self.results.append({'uri':result.uri, 'title':result.title, 'comment':result.comment, 'icon':result.icon_hint}) class ScopeTestCase(TestCase): def init_scope(self, scope_path): self.scope_module = imp.load_source('scope', scope_path) self.scope = self.scope_module.load_scope() def perform_query(self, query, filter_set = Unity.FilterSet.new()): result_set = ResultSet() ctx = Unity.SearchContext.create(query, 0, filter_set, None, result_set, None) s = self.scope.create_search_for_query(ctx) s.run() return result_set class TestOpenclipart(ScopeTestCase): def setUp(self): self.init_scope('src/unity_openclipart_daemon.py') def tearDown(self): self.scope = None self.scope_module = None def test_valid_searches(self): self.scope_module.SEARCH_URI = 'file:tests/data/mock_openclipart_pass#' expected_results = ['http://openclipart.org/detail/237/water-drop-by-tomas_arad', 'http://openclipart.org/image/90px/svg_to_png/237/tomas_arad_water_drop.png', 'water drop'] results = [] for s in ['water']: result_set = self.perform_query(s) results.append(result_set.results[0]['uri']) results.append(result_set.results[0]['icon']) results.append(result_set.results[0]['title']) self.assertEqual(results, expected_results) def test_failing_search(self): self.scope_module.SEARCH_URI = 'file:tests/data/mock_openclipart_fail#' for s in ['water']: result_set = self.perform_query(s) self.assertEqual(len(result_set.results), 0) if __name__ == '__main__': unittest.main() unity-scope-openclipart-0.1+13.10.20130723/src/0000755000015700001700000000000012173421423021266 5ustar pbuserpbgroup00000000000000unity-scope-openclipart-0.1+13.10.20130723/src/unity_openclipart_daemon.py0000644000015700001700000002044512173420530026736 0ustar pbuserpbgroup00000000000000#! /usr/bin/python3 # -*- coding: utf-8 -*- # Copyright(C) 2013 Canonical, ltd. # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . from gi.repository import Unity, UnityExtras from gi.repository import Gio, GLib import urllib import feedparser import gettext import shutil APP_NAME = 'unity-scope-openclipart' LOCAL_PATH = '/usr/share/locale/' gettext.bindtextdomain(APP_NAME, LOCAL_PATH) gettext.textdomain(APP_NAME) _ = gettext.gettext GROUP_NAME = 'com.canonical.Unity.Scope.Graphics.Openclipart' UNIQUE_PATH = '/com/canonical/unity/scope/graphics/openclipart' SEARCH_URI = 'https://openclipart.org/' SEARCH_HINT = _('Search OpenClipArt') NO_RESULTS_HINT = _('Sorry, there are no OpenClipArt results that match your search.') PROVIDER_CREDITS = _('Powered by OpenClipArt') SVG_DIR = '/usr/share/icons/unity-icon-theme/places/svg/' PROVIDER_ICON = SVG_DIR+'service-openclipart.svg' DEFAULT_RESULT_ICON = SVG_DIR+'result-graphics.svg' DEFAULT_RESULT_MIMETYPE = 'text/html' DEFAULT_RESULT_TYPE = Unity.ResultType.DEFAULT c1 = {'id' :'top', 'name' :_('Images'), 'icon' :SVG_DIR+'group-installed.svg', 'renderer':Unity.CategoryRenderer.VERTICAL_TILE} CATEGORIES = [c1] FILTERS = [] m1 = {'id' :'published', 'type' :'s', 'field':Unity.SchemaFieldType.OPTIONAL} m2 = {'id' :'author', 'type' :'s', 'field':Unity.SchemaFieldType.OPTIONAL} m3 = {'id' :'resource', 'type' :'s', 'field':Unity.SchemaFieldType.OPTIONAL} EXTRA_METADATA = [m1, m2, m3] def search(search, filters): ''' Any search method returning results as a list of tuples. Available tuple fields: uri (string) icon (string) title (string) comment (string) dnd_uri (string) mimetype (string) category (int) result_type (Unity ResultType) extras metadata fields (variant) ''' results = [] if not search: return results search = urllib.parse.quote(search) uri = "%sapi/search/?query=%s" % (SEARCH_URI, search) print(uri) try: feed = feedparser.parse(uri) except Exception as error: print(error) feed = None if not feed or not 'entries' in feed: return results for f in feed['entries']: try: if f is None: continue resource = '' for link in f['links']: if link['rel'] == 'enclosure': resource = link['href'] if 'published' not in f: # support feedparser == 5.1 published = f['updated'] else: published = f['published'] results.append({'uri':f['link'], 'icon':f['media_thumbnail'][0]['url'], 'title':f['title'], 'comment':f['summary'], 'published':published, 'author':f['author'], 'resource':resource}) except Exception as error: print(error) return results # Classes below this point establish communication # with Unity, you probably shouldn't modify them. class MySearch (Unity.ScopeSearchBase): def __init__(self, search_context): super (MySearch, self).__init__() self.set_search_context (search_context) def do_run (self): ''' Adds results to the model ''' try: result_set = self.search_context.result_set for i in search(self.search_context.search_query, self.search_context.filter_state): if not 'uri' in i or not i['uri'] or i['uri'] == '': continue if not 'icon' in i or not i['icon'] or i['icon'] == '': i['icon'] = DEFAULT_RESULT_ICON if not 'mimetype' in i or not i['mimetype'] or i['mimetype'] == '': i['mimetype'] = DEFAULT_RESULT_MIMETYPE if not 'result_type' in i or not i['result_type'] or i['result_type'] == '': i['result_type'] = DEFAULT_RESULT_TYPE if not 'category' in i or not i['category'] or i['category'] == '': i['category'] = 0 if not 'title' in i or not i['title']: i['title'] = '' if not 'comment' in i or not i['comment']: i['comment'] = '' if not 'dnd_uri' in i or not i['dnd_uri'] or i['dnd_uri'] == '': i['dnd_uri'] = i['uri'] result_set.add_result(**i) except Exception as error: print (error) class Preview (Unity.ResultPreviewer): def do_run(self): resource = False if self.result.metadata and 'resource' in self.result.metadata and self.result.metadata['resource'].get_string() != '': resource = True thumb = Gio.FileIcon.new(Gio.file_new_for_uri(self.result.metadata['resource'].get_string())) else: thumb = Gio.FileIcon.new(Gio.file_new_for_uri(self.result.icon_hint)) preview = Unity.GenericPreview.new(self.result.title, self.result.comment.strip(), thumb) preview.add_info(Unity.InfoHint.new("license", _("License"), None, _("Public Domain"))) if self.result.metadata and 'author' in self.result.metadata and self.result.metadata['author'].get_string() != '': preview.props.subtitle = _("By ") + self.result.metadata['author'].get_string() icon = Gio.FileIcon.new (Gio.file_new_for_path(PROVIDER_ICON)) view_action = Unity.PreviewAction.new("view", _("View"), icon) preview.add_action(view_action) if resource and shutil.which("inkscape"): inkscape_action = Unity.PreviewAction.new("inkscape", _("Open in Inkscape"), None) preview.add_action(inkscape_action) return preview class Scope (Unity.AbstractScope): def __init__(self): Unity.AbstractScope.__init__(self) def do_get_search_hint (self): return SEARCH_HINT def do_get_schema (self): ''' Adds specific metadata fields ''' schema = Unity.Schema.new () if EXTRA_METADATA: for m in EXTRA_METADATA: schema.add_field(m['id'], m['type'], m['field']) #FIXME should be REQUIRED for credits schema.add_field('provider_credits', 's', Unity.SchemaFieldType.OPTIONAL) return schema def do_get_categories (self): ''' Adds categories ''' cs = Unity.CategorySet.new () if CATEGORIES: for c in CATEGORIES: cat = Unity.Category.new (c['id'], c['name'], Gio.ThemedIcon.new(c['icon']), c['renderer']) cs.add (cat) return cs def do_get_filters (self): ''' Adds filters ''' fs = Unity.FilterSet.new () # if FILTERS: # return fs def do_get_group_name (self): return GROUP_NAME def do_get_unique_name (self): return UNIQUE_PATH def do_create_search_for_query (self, search_context): se = MySearch (search_context) return se def do_create_previewer(self, result, metadata): rp = Preview() rp.set_scope_result(result) rp.set_search_metadata(metadata) return rp def do_activate(self, result, metadata, id): if id == 'inkscape': uri = Gio.file_new_for_uri(result.metadata['resource'].get_string()).get_uri() GLib.spawn_async([shutil.which("inkscape"), uri.replace(' ', '%20')]) return Unity.ActivationResponse(handled=Unity.HandledType.HIDE_DASH, goto_uri=None) return Unity.ActivationResponse() def load_scope(): return Scope() unity-scope-openclipart-0.1+13.10.20130723/src/__init__.py0000644000015700001700000000000012173420530023363 0ustar pbuserpbgroup00000000000000unity-scope-openclipart-0.1+13.10.20130723/setup.py0000644000015700001700000000125112173420530022206 0ustar pbuserpbgroup00000000000000#!/usr/bin/env python3 # -*- coding: utf-8 -*- from distutils.core import setup from DistUtilsExtra.command import * setup(name='unity-scope-openclipart', version='0.1', author='David CallĂ©', author_email='davidc@framli.eu', url='http://launchpad.net/ubuntu-scopes', license='GNU General Public License (GPL)', data_files=[ ('share/dbus-1/services', ['data/unity-scope-openclipart.service']), ('share/unity-scopes/openclipart', ['src/unity_openclipart_daemon.py']), ('share/unity-scopes/openclipart', ['src/__init__.py']), ], cmdclass={'build': build_extra.build_extra, 'build_i18n': build_i18n.build_i18n,}) unity-scope-openclipart-0.1+13.10.20130723/setup.cfg0000644000015700001700000000021712173420530022316 0ustar pbuserpbgroup00000000000000[build] i18n=True [build_i18n] domain=unity-scope-openclipart desktop_files=[('share/unity/scopes/graphics', ('data/openclipart.scope.in',))] unity-scope-openclipart-0.1+13.10.20130723/data/0000755000015700001700000000000012173421423021410 5ustar pbuserpbgroup00000000000000unity-scope-openclipart-0.1+13.10.20130723/data/openclipart.scope.in0000644000015700001700000000150312173420530025365 0ustar pbuserpbgroup00000000000000[Scope] DBusName=com.canonical.Unity.Scope.Graphics.Openclipart DBusPath=/com/canonical/unity/scope/graphics/openclipart Icon=/usr/share/icons/unity-icon-theme/places/svg/service-openclipart.svg _Keywords=openclipart;clipart;svg;vector; RequiredMetadata= OptionalMetadata=published[s];author[s];resource[s]; Loader=/usr/share/unity-scopes/openclipart/unity_openclipart_daemon.py Module=openclipart.unity_openclipart_daemon ModuleType=python3 RemoteContent=true Type=graphics _Name=OpenClipArt _Description=This is an Ubuntu search plugin that enables information from OpenClipArt to be searched and displayed in the Dash underneath the Graphics header. If you do not wish to search this content source, you can disable this search plugin. _SearchHint=Search OpenClipArt [Desktop Entry] X-Ubuntu-Gettext-Domain=unity-scope-openclipart unity-scope-openclipart-0.1+13.10.20130723/data/unity-scope-openclipart.service0000644000015700001700000000024512173420530027566 0ustar pbuserpbgroup00000000000000[D-BUS Service] Name=com.canonical.Unity.Scope.Graphics.Openclipart Exec=/usr/bin/python3 /usr/share/unity-scopes/scope-runner-dbus.py -s graphics/openclipart.scope unity-scope-openclipart-0.1+13.10.20130723/data/icons/0000755000015700001700000000000012173421423022523 5ustar pbuserpbgroup00000000000000unity-scope-openclipart-0.1+13.10.20130723/data/icons/service-openclipart.svg0000644000015700001700000003372112173420530027226 0ustar pbuserpbgroup00000000000000 image/svg+xml