Back to index

unity  6.0.0
Lens.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2011 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
00018  */
00019 
00020 #ifndef UNITY_LENS_H
00021 #define UNITY_LENS_H
00022 
00023 #include <boost/noncopyable.hpp>
00024 #include <memory>
00025 #include <NuxCore/Property.h>
00026 #include <sigc++/trackable.h>
00027 
00028 #include "Variant.h"
00029 #include "Categories.h"
00030 #include "Filters.h"
00031 #include "Preview.h"
00032 #include "Results.h"
00033 
00034 namespace unity
00035 {
00036 namespace dash
00037 {
00038 
00039 enum HandledType
00040 {
00041   NOT_HANDLED=0,
00042   SHOW_DASH,
00043   HIDE_DASH,
00044   GOTO_DASH_URI
00045 };
00046 
00047 enum ViewType
00048 {
00049   HIDDEN=0,
00050   HOME_VIEW,
00051   LENS_VIEW
00052 };
00053 
00054 class Lens : public sigc::trackable, boost::noncopyable
00055 {
00056 public:
00057   typedef std::shared_ptr<Lens> Ptr;
00058   typedef std::map<std::string, unity::glib::Variant> Hints;
00059 
00060   Lens(std::string const& id,
00061        std::string const& dbus_name,
00062        std::string const& dbus_path,
00063        std::string const& name,
00064        std::string const& icon,
00065        std::string const& description = "",
00066        std::string const& search_hint = "",
00067        bool visible = true,
00068        std::string const& shortcut = "");
00069 
00070   Lens(std::string const& id,
00071          std::string const& dbus_name,
00072          std::string const& dbus_path,
00073          std::string const& name,
00074          std::string const& icon,
00075          std::string const& description,
00076          std::string const& search_hint,
00077          bool visible,
00078          std::string const& shortcut,
00079          ModelType model_type);
00080 
00081   virtual ~Lens();
00082 
00083   virtual void GlobalSearch(std::string const& search_string);
00084   virtual void Search(std::string const& search_string);
00085   virtual void Activate(std::string const& uri);
00086   virtual void Preview(std::string const& uri);
00087 
00088   nux::RWProperty<std::string> id;
00089   nux::RWProperty<std::string> dbus_name;
00090   nux::RWProperty<std::string> dbus_path;
00091   nux::RWProperty<std::string> name;
00092   nux::RWProperty<std::string> icon_hint;
00093   nux::RWProperty<std::string> description;
00094   nux::RWProperty<std::string> search_hint;
00095   nux::RWProperty<bool> visible;
00096   nux::RWProperty<bool> search_in_global;
00097   nux::RWProperty<std::string> shortcut;
00098   nux::RWProperty<Results::Ptr> results;
00099   nux::RWProperty<Results::Ptr> global_results;
00100   nux::RWProperty<Categories::Ptr> categories;
00101   nux::RWProperty<Filters::Ptr> filters;
00102   nux::RWProperty<bool> connected;
00103 
00104   nux::Property<ViewType> view_type;
00105 
00106   sigc::signal<void, Hints const&> search_finished;
00107   sigc::signal<void, Hints const&> global_search_finished;
00108   sigc::signal<void, std::string const&, HandledType, Hints const&> activated;
00109   sigc::signal<void, std::string const&, Preview::Ptr> preview_ready;
00110 
00111 private:
00112   class Impl;
00113   Impl* pimpl;
00114 };
00115 
00116 }
00117 }
00118 
00119 #endif