diff --git a/src/desktop/unity-lens-recoll/Makefile.am b/src/desktop/unity-lens-recoll/Makefile.am index b948e2d3..efc03cf9 100644 --- a/src/desktop/unity-lens-recoll/Makefile.am +++ b/src/desktop/unity-lens-recoll/Makefile.am @@ -4,7 +4,6 @@ EXTRA_DIST = \ bin/unity-recoll-daemon.in \ data/recoll.lens.in \ data/recoll-lens.svg \ - data/unity-lens-recoll.menu.in \ data/unity-lens-recoll.service.in \ $(docs_DATA) \ $(NULL) @@ -28,10 +27,10 @@ docs_DATA = \ ###################################################### # Lens code ###################################################### -lensdir = $(datadir)/unity-lens-recoll/recoll +lensdir = $(datadir)/unity-lens-recoll/recollscope lens_PYTHON = \ - recoll/__init__.py \ - recoll/apps.py \ + recollscope/__init__.py \ + recollscope/rclsearch.py \ $(NULL) libexec_SCRIPTS = \ @@ -61,12 +60,3 @@ dbusdir = $(datadir)/dbus-1/services dbus_DATA = \ data/unity-lens-recoll.service \ $(NULL) - -###################################################### -# XDG .menu file -###################################################### -menudir = $(sysconfdir)/xdg/menus -menu_DATA = \ - data/unity-lens-recoll.menu \ - $(NULL) - diff --git a/src/desktop/unity-lens-recoll/Makefile.in b/src/desktop/unity-lens-recoll/Makefile.in index ecc6d0ae..a4909b3c 100644 --- a/src/desktop/unity-lens-recoll/Makefile.in +++ b/src/desktop/unity-lens-recoll/Makefile.in @@ -38,7 +38,6 @@ DIST_COMMON = README $(am__configure_deps) $(lens_PYTHON) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(top_srcdir)/bin/unity-recoll-daemon.in \ $(top_srcdir)/configure $(top_srcdir)/data/recoll.lens.in \ - $(top_srcdir)/data/unity-lens-recoll.menu.in \ $(top_srcdir)/data/unity-lens-recoll.service.in AUTHORS \ COPYING ChangeLog INSTALL NEWS install-sh missing py-compile ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -50,7 +49,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = bin/unity-recoll-daemon data/recoll.lens \ - data/unity-lens-recoll.menu data/unity-lens-recoll.service + data/unity-lens-recoll.service CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ @@ -75,14 +74,12 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(lensdir)" \ "$(DESTDIR)$(dbusdir)" "$(DESTDIR)$(docsdir)" \ - "$(DESTDIR)$(dotlensdir)" "$(DESTDIR)$(iconsdir)" \ - "$(DESTDIR)$(menudir)" + "$(DESTDIR)$(dotlensdir)" "$(DESTDIR)$(iconsdir)" SCRIPTS = $(libexec_SCRIPTS) SOURCES = DIST_SOURCES = py_compile = $(top_srcdir)/py-compile -DATA = $(dbus_DATA) $(docs_DATA) $(dotlens_DATA) $(icons_DATA) \ - $(menu_DATA) +DATA = $(dbus_DATA) $(docs_DATA) $(dotlens_DATA) $(icons_DATA) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -183,7 +180,6 @@ EXTRA_DIST = \ bin/unity-recoll-daemon.in \ data/recoll.lens.in \ data/recoll-lens.svg \ - data/unity-lens-recoll.menu.in \ data/unity-lens-recoll.service.in \ $(docs_DATA) \ $(NULL) @@ -207,10 +203,10 @@ docs_DATA = \ ###################################################### # Lens code ###################################################### -lensdir = $(datadir)/unity-lens-recoll/recoll +lensdir = $(datadir)/unity-lens-recoll/recollscope lens_PYTHON = \ - recoll/__init__.py \ - recoll/apps.py \ + recollscope/__init__.py \ + recollscope/rclsearch.py \ $(NULL) libexec_SCRIPTS = \ @@ -244,15 +240,6 @@ dbus_DATA = \ data/unity-lens-recoll.service \ $(NULL) - -###################################################### -# XDG .menu file -###################################################### -menudir = $(sysconfdir)/xdg/menus -menu_DATA = \ - data/unity-lens-recoll.menu \ - $(NULL) - all: all-am .SUFFIXES: @@ -294,8 +281,6 @@ bin/unity-recoll-daemon: $(top_builddir)/config.status $(top_srcdir)/bin/unity-r cd $(top_builddir) && $(SHELL) ./config.status $@ data/recoll.lens: $(top_builddir)/config.status $(top_srcdir)/data/recoll.lens.in cd $(top_builddir) && $(SHELL) ./config.status $@ -data/unity-lens-recoll.menu: $(top_builddir)/config.status $(top_srcdir)/data/unity-lens-recoll.menu.in - cd $(top_builddir) && $(SHELL) ./config.status $@ data/unity-lens-recoll.service: $(top_builddir)/config.status $(top_srcdir)/data/unity-lens-recoll.service.in cd $(top_builddir) && $(SHELL) ./config.status $@ install-libexecSCRIPTS: $(libexec_SCRIPTS) @@ -450,26 +435,6 @@ uninstall-iconsDATA: test -n "$$files" || exit 0; \ echo " ( cd '$(DESTDIR)$(iconsdir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(iconsdir)" && rm -f $$files -install-menuDATA: $(menu_DATA) - @$(NORMAL_INSTALL) - test -z "$(menudir)" || $(MKDIR_P) "$(DESTDIR)$(menudir)" - @list='$(menu_DATA)'; test -n "$(menudir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(menudir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(menudir)" || exit $$?; \ - done - -uninstall-menuDATA: - @$(NORMAL_UNINSTALL) - @list='$(menu_DATA)'; test -n "$(menudir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(menudir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(menudir)" && rm -f $$files tags: TAGS TAGS: @@ -628,7 +593,7 @@ check-am: all-am check: check-am all-am: Makefile $(SCRIPTS) $(DATA) installdirs: - for dir in "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(lensdir)" "$(DESTDIR)$(dbusdir)" "$(DESTDIR)$(docsdir)" "$(DESTDIR)$(dotlensdir)" "$(DESTDIR)$(iconsdir)" "$(DESTDIR)$(menudir)"; do \ + for dir in "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(lensdir)" "$(DESTDIR)$(dbusdir)" "$(DESTDIR)$(docsdir)" "$(DESTDIR)$(dotlensdir)" "$(DESTDIR)$(iconsdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -679,7 +644,7 @@ info: info-am info-am: install-data-am: install-dbusDATA install-docsDATA install-dotlensDATA \ - install-iconsDATA install-lensPYTHON install-menuDATA + install-iconsDATA install-lensPYTHON install-dvi: install-dvi-am @@ -727,7 +692,7 @@ ps-am: uninstall-am: uninstall-dbusDATA uninstall-docsDATA \ uninstall-dotlensDATA uninstall-iconsDATA uninstall-lensPYTHON \ - uninstall-libexecSCRIPTS uninstall-menuDATA + uninstall-libexecSCRIPTS .MAKE: install-am install-strip @@ -740,14 +705,13 @@ uninstall-am: uninstall-dbusDATA uninstall-docsDATA \ install-dotlensDATA install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-iconsDATA \ install-info install-info-am install-lensPYTHON \ - install-libexecSCRIPTS install-man install-menuDATA \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \ - uninstall-dbusDATA uninstall-docsDATA uninstall-dotlensDATA \ - uninstall-iconsDATA uninstall-lensPYTHON \ - uninstall-libexecSCRIPTS uninstall-menuDATA + install-libexecSCRIPTS install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am uninstall uninstall-am uninstall-dbusDATA \ + uninstall-docsDATA uninstall-dotlensDATA uninstall-iconsDATA \ + uninstall-lensPYTHON uninstall-libexecSCRIPTS # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/src/desktop/unity-lens-recoll/bin/unity-recoll-daemon.in b/src/desktop/unity-lens-recoll/bin/unity-recoll-daemon.in index 48373dd7..0a1470c3 100755 --- a/src/desktop/unity-lens-recoll/bin/unity-recoll-daemon.in +++ b/src/desktop/unity-lens-recoll/bin/unity-recoll-daemon.in @@ -8,10 +8,10 @@ if os.path.isfile(os.path.join(execpath, "..", "configure.ac")): print "Running from source tree" sys.path.insert (0, os.path.join(execpath, "..")) else: - sys.path.insert (0, os.path.join("@DATADIR@", "unity-lens-bliss")) + sys.path.insert (0, os.path.join("@DATADIR@", "unity-lens-recoll")) del execpath -import bliss.apps +import recollscope.rclsearch from gi.repository import GLib, GObject, Gio # NOTE: If we used the normal 'dbus' module for Python we'll get @@ -26,7 +26,7 @@ from gi.repository import GLib, GObject, Gio # # The primary bus name we grab *must* match what we specify in our .lens file # -BUS_NAME = "net.launchpad.UnityLensBliss.Lens" +BUS_NAME = "org.recoll.UnityLensRecoll.Lens" session_bus_connection = Gio.bus_get_sync (Gio.BusType.SESSION, None) session_bus = Gio.DBusProxy.new_sync (session_bus_connection, 0, None, @@ -47,13 +47,13 @@ if result != 1 : def create_lens (): # The path for the Lens *must* also match the one in our .lens file from gi.repository import Unity - lens = Unity.Lens.new ("/net/launchpad/unitylensbliss/lens", "bliss") + lens = Unity.Lens.new ("/org/recoll/unitylensrecoll/lens", "recoll") - lens.props.search_hint = "Search for apps" + lens.props.search_hint = "Recoll search string" lens.props.visible = True; lens.props.search_in_global = True; - # Populate categories + # Populate categories TODO FIX THIS cats = [] cats.append (Unity.Category.new ("Applications", Gio.ThemedIcon.new("keyboard"), @@ -66,7 +66,7 @@ def create_lens (): return lens lens = create_lens () -lens.add_local_scope (bliss.apps.Scope()) +lens.add_local_scope (recollscope.rclsearch.Scope()) # add more local scopes here (remote dbus scopes added automagically) lens.export () diff --git a/src/desktop/unity-lens-recoll/configure b/src/desktop/unity-lens-recoll/configure index e05b66db..a14f36b9 100755 --- a/src/desktop/unity-lens-recoll/configure +++ b/src/desktop/unity-lens-recoll/configure @@ -1,8 +1,8 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for unity-lens-bliss 0.1.3. +# Generated by GNU Autoconf 2.68 for unity-lens-recoll 0.1.1. # -# Report bugs to . +# Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -238,10 +238,10 @@ fi $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and -$0: https://launchpad.net/unity-lens-bliss about your -$0: system, including any error possibly output before this -$0: message. Then install a modern shell, or manually run -$0: the script under such a shell if you do have one." +$0: https://www.recoll.org about your system, including any +$0: error possibly output before this message. Then install +$0: a modern shell, or manually run the script under such a +$0: shell if you do have one." fi exit 1 fi @@ -557,11 +557,11 @@ MFLAGS= MAKEFLAGS= # Identity of this package. -PACKAGE_NAME='unity-lens-bliss' -PACKAGE_TARNAME='unity-lens-bliss' -PACKAGE_VERSION='0.1.3' -PACKAGE_STRING='unity-lens-bliss 0.1.3' -PACKAGE_BUGREPORT='https://launchpad.net/unity-lens-bliss' +PACKAGE_NAME='unity-lens-recoll' +PACKAGE_TARNAME='unity-lens-recoll' +PACKAGE_VERSION='0.1.1' +PACKAGE_STRING='unity-lens-recoll 0.1.1' +PACKAGE_BUGREPORT='https://www.recoll.org' PACKAGE_URL='' ac_subst_vars='LTLIBOBJS @@ -1188,7 +1188,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures unity-lens-bliss 0.1.3 to adapt to many kinds of systems. +\`configure' configures unity-lens-recoll 0.1.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1237,7 +1237,7 @@ Fine tuning of the installation directories: --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root - [DATAROOTDIR/doc/unity-lens-bliss] + [DATAROOTDIR/doc/unity-lens-recoll] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] @@ -1255,11 +1255,11 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of unity-lens-bliss 0.1.3:";; + short | recursive ) echo "Configuration of unity-lens-recoll 0.1.1:";; esac cat <<\_ACEOF -Report bugs to . +Report bugs to . _ACEOF ac_status=$? fi @@ -1322,7 +1322,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -unity-lens-bliss configure 0.1.3 +unity-lens-recoll configure 0.1.1 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1339,7 +1339,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by unity-lens-bliss $as_me 0.1.3, which was +It was created by unity-lens-recoll $as_me 0.1.1, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2153,8 +2153,8 @@ fi # Define the identity of the package. - PACKAGE='unity-lens-bliss' - VERSION='0.1.3' + PACKAGE='unity-lens-recoll' + VERSION='0.1.1' cat >>confdefs.h <<_ACEOF @@ -2462,7 +2462,7 @@ $as_echo "$am_cv_python_pyexecdir" >&6; } -ac_config_files="$ac_config_files bin/unity-bliss-daemon data/bliss.lens data/unity-lens-bliss.menu data/unity-lens-bliss.service Makefile" +ac_config_files="$ac_config_files bin/unity-recoll-daemon data/recoll.lens data/unity-lens-recoll.service Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -3019,7 +3019,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by unity-lens-bliss $as_me 0.1.3, which was +This file was extended by unity-lens-recoll $as_me 0.1.1, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -3066,13 +3066,13 @@ Usage: $0 [OPTION]... [TAG]... Configuration files: $config_files -Report bugs to ." +Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -unity-lens-bliss config.status 0.1.3 +unity-lens-recoll config.status 0.1.1 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" @@ -3185,10 +3185,9 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 for ac_config_target in $ac_config_targets do case $ac_config_target in - "bin/unity-bliss-daemon") CONFIG_FILES="$CONFIG_FILES bin/unity-bliss-daemon" ;; - "data/bliss.lens") CONFIG_FILES="$CONFIG_FILES data/bliss.lens" ;; - "data/unity-lens-bliss.menu") CONFIG_FILES="$CONFIG_FILES data/unity-lens-bliss.menu" ;; - "data/unity-lens-bliss.service") CONFIG_FILES="$CONFIG_FILES data/unity-lens-bliss.service" ;; + "bin/unity-recoll-daemon") CONFIG_FILES="$CONFIG_FILES bin/unity-recoll-daemon" ;; + "data/recoll.lens") CONFIG_FILES="$CONFIG_FILES data/recoll.lens" ;; + "data/unity-lens-recoll.service") CONFIG_FILES="$CONFIG_FILES data/unity-lens-recoll.service" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; @@ -3653,7 +3652,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: - unity-lens-bliss + unity-lens-recoll -------------------- Prefix : ${prefix} @@ -3661,7 +3660,7 @@ fi " >&5 $as_echo "$as_me: - unity-lens-bliss + unity-lens-recoll -------------------- Prefix : ${prefix} diff --git a/src/desktop/unity-lens-recoll/configure.ac b/src/desktop/unity-lens-recoll/configure.ac index dedef571..0890d0de 100644 --- a/src/desktop/unity-lens-recoll/configure.ac +++ b/src/desktop/unity-lens-recoll/configure.ac @@ -18,7 +18,6 @@ AC_SUBST(LIBEXECDIR) AC_OUTPUT([ bin/unity-recoll-daemon data/recoll.lens -data/unity-lens-recoll.menu data/unity-lens-recoll.service Makefile ]) diff --git a/src/desktop/unity-lens-recoll/data/recoll.lens.in b/src/desktop/unity-lens-recoll/data/recoll.lens.in index 71bc50e9..6e7ac97a 100644 --- a/src/desktop/unity-lens-recoll/data/recoll.lens.in +++ b/src/desktop/unity-lens-recoll/data/recoll.lens.in @@ -1,12 +1,11 @@ [Lens] -DBusName=net.launchpad.UnityLensBliss.Lens -DBusPath=/net/launchpad/unitylensbliss/lens -Name=Apps Lens -Icon=@DATADIR@/unity-lens-bliss/bliss-lens.svg -Description=Easily find and launch apps +DBusName=org.recoll.UnityLensRecoll.Lens +DBusPath=/org/recoll/unitylensrecoll/lens +Name=Recoll Lens +Icon=@DATADIR@/unity-lens-recoll/recoll-lens.svg +Description=Search documents indexed by Recoll SearchHint=Type to search Shortcut=a [Desktop Entry] -X-Ubuntu-Gettext-Domain=unity-lens-bliss - +X-Ubuntu-Gettext-Domain=unity-lens-recoll diff --git a/src/desktop/unity-lens-recoll/data/unity-lens-recoll.menu.in b/src/desktop/unity-lens-recoll/data/unity-lens-recoll.menu.in deleted file mode 100644 index 77e91f18..00000000 --- a/src/desktop/unity-lens-recoll/data/unity-lens-recoll.menu.in +++ /dev/null @@ -1,173 +0,0 @@ - - - - - Applications - X-GNOME-Menu-Applications.directory - - - /etc/X11/applnk - /usr/share/gnome/apps - - - - - - - - - - - gnomecc.desktop - - - - - All Applications - X-GNOME-Menu-Applications.directory - - - - Settings - System - Screensaver - - - - - - Accessories - Utility.directory - - - Utility - Accessibility - - - - - - - Universal Access - Utility-Accessibility.directory - - - Accessibility - Settings - - - - - - - Developer Tools - - - Development - - emacs.desktop - - - - - - Education - Education.directory - - - Education - Science - - - - - - - Science & Engineering - - - Science - Engineering - - - - - - Games - Game.directory - - - Game - - - - - - - Graphics - Graphics.directory - - - Graphics - - - - - - Internet - Network.directory - - - Network - - - - - - - Multimedia - AudioVideo.directory - - - AudioVideo - - - - - - - Office - Office.directory - - - Office - - - - - - Themes & Tweaks - Settings - - - - - - System - System.directory - Settings.directory - Settings-System.directory - - - System - Security - gnomecc.desktop - - - - - diff --git a/src/desktop/unity-lens-recoll/data/unity-lens-recoll.service.in b/src/desktop/unity-lens-recoll/data/unity-lens-recoll.service.in index bdb1f2c6..cee922ae 100644 --- a/src/desktop/unity-lens-recoll/data/unity-lens-recoll.service.in +++ b/src/desktop/unity-lens-recoll/data/unity-lens-recoll.service.in @@ -1,3 +1,3 @@ [D-BUS Service] -Name=net.launchpad.UnityLensBliss.Lens -Exec=@LIBEXECDIR@/unity-bliss-daemon +Name=org.recoll.UnityLensRecoll.Lens +Exec=@LIBEXECDIR@/unity-recoll-daemon diff --git a/src/desktop/unity-lens-recoll/recoll/rclsearch.py b/src/desktop/unity-lens-recoll/recoll/rclsearch.py deleted file mode 100755 index e612b122..00000000 --- a/src/desktop/unity-lens-recoll/recoll/rclsearch.py +++ /dev/null @@ -1,334 +0,0 @@ -# -# IDEAS AND COMMENTS -# -# - We should probably cache all App instances on startup to avoid recreating -# themon each search. Listen to the "changed" signal on the GMenu tree to -# update -# -# - Matching and scoring algorithm is really lame. Could be more efficient, -# and calculate the scores better -# -# - Bear in mind when looking at this code that this is *meant* to be simple :-) -# - -import sys -from gi.repository import GLib, GObject, Gio -from gi.repository import Dee -from gi.repository import GMenu -from gi.repository import Unity - -# These category ids must match the order in which we add them to the lens -CATEGORY_ALL = 0 - -class App: - """Simple representation of an item in the result model. - This class implements simple comparisons, sorting, and hashing - methods to integrate with the Python routines for these things - """ - def __init__ (self, uri, icon, cat_id, mime, - display_name, comment, dnd_uri, score = 0): - self.uri = uri - self.icon = icon - self.cat_id = cat_id - self.mime = mime - self.display_name = display_name - self.comment = comment - self.dnd_uri = dnd_uri - self.score = score - - def __lt__ (self, other): - if self.score : - return self.score > other.score # scores sort reverse - return self.display_name < other.display_name - - def __gt__ (self, other): - if other.score : - return self.score < other.score # scores sort reverse - return self.display_name < other.display_name - - def __eq__ (self, other): - return self.uri == other.uri - - def __ne__ (self, other): - return self.uri != other.uri - - def __hash__ (self): - return hash(self.uri) - -class Scope (Unity.Scope): - - def __init__ (self): - Unity.Scope.__init__ (self, dbus_path="/net/launchpad/unitylensbliss/scope/main") - - # Listen for changes and requests - self.connect ("notify::active-search", self._on_search_changed) - self.connect ("notify::active-global-search", self._on_global_search_changed) - self.connect ("activate-uri", self.activate_uri) - - self.apps_tree = GMenu.Tree.new ("unity-lens-bliss.menu", GMenu.TreeFlags.NONE) - self.apps_tree.load_sync () - - self._current_browse_node = None - - def get_search_string (self): - search = self.props.active_search - return search.props.search_string if search else None - - def get_global_search_string (self): - search = self.props.active_global_search - return search.props.search_string if search else None - - def search_finished (self): - search = self.props.active_search - if search: - search.emit("finished") - - def global_search_finished (self): - search = self.props.active_global_search - if search: - search.emit("finished") - - def activate_uri (self, scope, uri): - """Activation handler to enable browsing of app directories""" - - print "Activate: %s" % uri - - # For all else than appdir:// uris we defer launching to Unity - if not uri.startswith ("appdir://"): - # Reset browsing state when an app is launched - self.reset () - return Unity.ActivationResponse.new (Unity.HandledType.NOT_HANDLED, - uri) - - if self._current_browse_node is None: - print >> sys.stderr, "Error: Unexpected browsing request for %s", uri - return Unity.ActivationResponse.new (Unity.HandledType.NOT_HANDLED, - uri) - - # Extract directory id from the uri and find the corresponding - # item in the currently browsed node - menu_id = uri[9:] - - if menu_id == "..": - self._current_browse_node = self._current_browse_node.get_parent () - self._do_browse (self.props.results_model) # FIXME: Broken for global search - return Unity.ActivationResponse.new (Unity.HandledType.SHOW_DASH, - uri) - - tree_iter = self._current_browse_node.iter () - item_type = tree_iter.next (); - while (item_type != GMenu.TreeItemType.INVALID): - if item_type == GMenu.TreeItemType.DIRECTORY: - d = tree_iter.get_directory () - if menu_id == d.get_menu_id (): - self._current_browse_node = d - self._do_browse (self.props.results_model) # FIXME: Broken for global search - return Unity.ActivationResponse.new (Unity.HandledType.SHOW_DASH, - uri) - else: - pass - item_type = tree_iter.next (); - - # We didn't find the expected folder. Reset the browsing state - self.reset () - print >> sys.stderr, "Error: Unable to browse appdir '%s'", menu_id - return Unity.ActivationResponse.new (Unity.HandledType.NOT_HANDLED, - uri) - - def reset (self): - self._current_browse_node = None - self._do_browse (self.props.results_model) - self._do_browse (self.props.global_results_model) - - def _on_search_changed (self, scope, param_spec): - search = self.get_search_string() - results = scope.props.results_model - - print "Search changed to: '%s'" % search - - self._update_results_model (search, results) - self.search_finished() - - def _on_global_search_changed (self, scope, param_spec): - search = self.get_global_search_string() - results = scope.props.global_results_model - - print "Global search changed to: '%s'" % search - - self._update_results_model (search, results) - self.global_search_finished() - - def _update_results_model (self, search_string, model): - if search_string: - self._do_search (search_string, model) - else: - self._do_browse (model) - - def _do_browse (self, model): - model.clear () - - collector = set () - - if self._current_browse_node is None: - self._current_browse_node = self.apps_tree.get_root_directory () - elif self._current_browse_node.get_parent (): - self._collect_back_dir (collector) - - tree_iter = self._current_browse_node.iter () - item_type = tree_iter.next (); - while (item_type != GMenu.TreeItemType.INVALID): - if item_type == GMenu.TreeItemType.ENTRY: - self._collect_app (collector, tree_iter.get_entry ()) - elif item_type == GMenu.TreeItemType.DIRECTORY: - self._collect_dir (collector, tree_iter.get_directory ()) - else: - pass # we skip separators and other stuff - item_type = tree_iter.next (); - - # Sort alphabetically - results = sorted (collector) - - for app in results: - model.append (app.uri, - app.icon, - app.cat_id, - app.mime, - app.display_name, - app.comment, - app.dnd_uri) - - def _do_search (self, search_string, model): - model.clear () - - # Reset browsing mode - self._current_browse_node = None - - # Use a set to collect results to avoid duplicates - # Apps are compared by app.uri to make this work - collector = set () - self._search_visit_directory (search_string, - collector, - self.apps_tree.get_root_directory ()) - # Sort by score - results = sorted (collector) - - for app in results: - model.append (app.uri, - app.icon, - app.cat_id, - app.mime, - app.display_name, - app.comment, - app.dnd_uri) - - - def _search_visit_directory (self, search_string, collector, tree_dir): - tree_iter = tree_dir.iter () - item_type = tree_iter.next (); - while (item_type != GMenu.TreeItemType.INVALID): - if item_type == GMenu.TreeItemType.ENTRY: - self._search_visit_entry (search_string, - collector, - tree_iter.get_entry ()) - elif item_type == GMenu.TreeItemType.DIRECTORY: - self._search_visit_directory (search_string, - collector, - tree_iter.get_directory()) - else: - pass # we skip separators and other stuff - item_type = tree_iter.next (); - - def _search_visit_entry (self, search_string, collector, tree_entry): - if not search_string: - self._collect_app (collector, tree_entry) - return - - app_info = tree_entry.get_app_info () - search_string = search_string.lower().strip() - - score = 1.0 - score *= self._test_string (search_string, - app_info.get_description (), - 1.1) - - score *= self._test_string (search_string, - app_info.get_display_name (), - 2.0) - - score *= self._test_string (search_string, - app_info.get_name (), - 2.0) - - score *= self._test_string (search_string, - app_info.get_executable (), - 3.0) - - if score > 1.0: - self._collect_app (collector, tree_entry, score) - - def _test_string (self, search_string, target_string, boost): - """Tests if search_string matches target_string and returns a - boost factor calculated from the input boost and the quality of - the match. - Returns 1.0 on no match""" - if not target_string: - return 1 - - target_string = target_string.lower() - - if target_string.startswith(search_string): - return boost * 2 - elif search_string in target_string: - return boost - - return 1 - - def _collect_app (self, collector, tree_entry, score = 0): - app_info = tree_entry.get_app_info () - app = App ("application://" + tree_entry.get_desktop_file_id (), # uri - app_info.get_icon().to_string (), # string formatted GIcon - CATEGORY_ALL, # numeric category id - "application/x-desktop", # mimetype - app_info.get_display_name () or "???", # display name - app_info.get_description () or "No description", # comment - tree_entry.get_desktop_file_path () or "", # dnd uri - score) # score - - collector.add (app) - - def _collect_dir (self, collector, tree_dir, score = 0): - # Create folder icon with app category emblem if the dir has an icon, - # else just use a folder icon - if tree_dir.get_icon (): - emblem = Gio.Emblem.new (tree_dir.get_icon ()) - icon = Gio.EmblemedIcon.new (Gio.ThemedIcon.new ("folder"), - emblem) - else: - emblem = Gio.Emblem.new (Gio.ThemedIcon.new ("gtk-execute")) - icon = Gio.EmblemedIcon.new (Gio.ThemedIcon.new ("folder"), - emblem) - - app = App ("appdir://" + tree_dir.get_menu_id (), # uri - icon.to_string (), # string formatted GIcon - CATEGORY_ALL, # numeric category id - "application/x-desktop", # mimetype - tree_dir.get_name () or "???", # display name - tree_dir.get_comment () or "No description", # comment - tree_dir.get_desktop_file_path () or "", # dnd uri - score) # score - - collector.add (app) - - def _collect_back_dir (self, collector): - icon = Gio.ThemedIcon.new ("gtk-go-back-ltr") - app = App ("appdir://..", # uri - icon.to_string (), # string formatted GIcon - CATEGORY_ALL, # numeric category id - "application/x-desktop", # mimetype - "Back", # display name - "Back to previous application directory", # comment - "", # dnd uri - 100000) # score - - collector.add (app) - diff --git a/src/desktop/unity-lens-recoll/recoll/__init__.py b/src/desktop/unity-lens-recoll/recollscope/__init__.py similarity index 100% rename from src/desktop/unity-lens-recoll/recoll/__init__.py rename to src/desktop/unity-lens-recoll/recollscope/__init__.py diff --git a/src/desktop/unity-lens-recoll/recollscope/rclsearch.py b/src/desktop/unity-lens-recoll/recollscope/rclsearch.py new file mode 100755 index 00000000..ee05115a --- /dev/null +++ b/src/desktop/unity-lens-recoll/recollscope/rclsearch.py @@ -0,0 +1,113 @@ + +import sys +from gi.repository import GLib, GObject, Gio +from gi.repository import Unity + +import recoll + +# These category ids must match the order in which we add them to the lens +CATEGORY_ALL = 0 + +class Scope (Unity.Scope): + + def __init__ (self): + Unity.Scope.__init__ (self, dbus_path="/org/recoll/unitylensrecoll/scope/main") + + # Listen for changes and requests + self.connect ("notify::active-search", self._on_search_changed) + self.connect ("notify::active-global-search", self._on_global_search_changed) + self.connect ("activate-uri", self.activate_uri) + + # Bliss loaded the apps_tree menu here, let's connect to + # the index + self.db = recoll.connect() + + self._current_browse_node = None + + def get_search_string (self): + search = self.props.active_search + return search.props.search_string if search else None + + def get_global_search_string (self): + search = self.props.active_global_search + return search.props.search_string if search else None + + def search_finished (self): + search = self.props.active_search + if search: + search.emit("finished") + + def global_search_finished (self): + search = self.props.active_global_search + if search: + search.emit("finished") + + def activate_uri (self, scope, uri): + """Activation handler to enable browsing of app directories""" + + print "Activate: %s" % uri + + # Defer all activations to Unity + # Reset browsing state when an app is launched + self.reset () + return Unity.ActivationResponse.new (Unity.HandledType.NOT_HANDLED, + uri) + + + def reset (self): + self._current_browse_node = None + self._do_browse (self.props.results_model) + self._do_browse (self.props.global_results_model) + + def _on_search_changed (self, scope, param_spec): + search = self.get_search_string() + results = scope.props.results_model + + print "Search changed to: '%s'" % search + + self._update_results_model (search, results) + self.search_finished() + + def _on_global_search_changed (self, scope, param_spec): + search = self.get_global_search_string() + results = scope.props.global_results_model + + print "Global search changed to: '%s'" % search + + self._update_results_model (search, results) + self.global_search_finished() + + def _update_results_model (self, search_string, model): + if search_string: + self._do_search (search_string, model) + else: + self._do_browse (model) + + def _do_browse (self, model): + model.clear () + self.search_finished() + + def _do_search (self, search_string, model): + model.clear () + + # Reset browsing mode + self._current_browse_node = None + + # Do the recoll thing + query = self.db.query() + nres = query.execute(search_string) + if nres > 20: + nres = 20 + while query.next >= 0 and query.next < nres: + doc = query.fetchone() + titleorfilename = doc.title + if titleorfilename == "": + titleorfilename = doc.filename + model.append (doc.url, + "", + CATEGORY_ALL, + doc.mimetype, + titleorfilename, + titleorfilename, + doc.url) +