Back to index

unity  6.0.0
Hud.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: Gordon Allott <gord.allott@canonical.com>
00018  */
00019 
00020 #ifndef UNITY_HUD_H
00021 #define UNITY_HUD_H
00022 
00023 #include <deque>
00024 #include <string>
00025 #include <memory>
00026 #include <NuxCore/Property.h>
00027 #include <glib.h>
00028 
00029 namespace unity
00030 {
00031 namespace hud
00032 {
00033 
00034 
00035 class Query
00036 {
00037 public:
00038   typedef std::shared_ptr<Query> Ptr;
00039   
00040   Query(std::string const& formatted_text_, std::string const& icon_name_,
00041         std::string const& item_icon_, std::string const& completion_text_,
00042         std::string const& shortcut_, GVariant* key_)
00043   : formatted_text(formatted_text_)
00044   , icon_name(icon_name_)
00045   , item_icon(item_icon_)
00046   , completion_text(completion_text_)
00047   , shortcut(shortcut_)
00048   , key(key_)
00049   {
00050     g_variant_ref(key);
00051   }
00052   
00053   ~Query()
00054   {
00055     g_variant_unref(key);
00056   }
00057   
00058   Query(const Query &rhs);
00059   Query& operator=(Query);
00060 
00061   std::string formatted_text;   // Pango formatted text
00062   std::string icon_name;        // icon name using standard lookups
00063   std::string item_icon;        // Future API
00064   std::string completion_text;  // Non formatted text f or completion
00065   std::string shortcut;         // Shortcut key
00066   GVariant *key;
00067 };
00068 
00069 
00070 class HudImpl;
00071 class Hud
00072 {
00073 public:
00074   typedef std::shared_ptr<Hud> Ptr;
00075   typedef std::deque<Query::Ptr> Queries;
00076 
00077   /*
00078    * Constructor for the hud
00079    * \param dbus_name string that specifies the name of the hud service
00080    * \param dbus_path string that specifies the path of the hud service
00081    */
00082   Hud(std::string const& dbus_name,
00083       std::string const& dbus_path);
00084 
00085   ~Hud();
00086 
00087   Hud(const Hud &rhs);
00088   Hud& operator=(Hud);
00089 
00090   nux::Property<std::string> target;
00091   nux::Property<bool> connected;
00092 
00093   /*
00094    * Queries the service for new suggestions, will fire off the 
00095    * suggestion_search_finished signal when the suggestions are returned
00096    */
00097   void RequestQuery(std::string const& search_string);
00098   
00099   /*
00100    * Executes a Query
00101    */
00102   void ExecuteQuery(Query::Ptr query, unsigned int timestamp);
00103 
00104   /*
00105    * Executes a query that returns from a search,
00106    * Implicitly calls CloseQuery();
00107    */
00108   void ExecuteQueryBySearch(std::string execute_string, unsigned int timestamp);
00109 
00110   /*
00111    * Closes the query connection, call when the hud closes
00112    */
00113   void CloseQuery();
00114 
00115   /*
00116    * Returns a deque of Query types when the service provides them
00117    */
00118   sigc::signal<void, Queries> queries_updated;
00119 
00120 private:
00121   HudImpl *pimpl_;
00122 };
00123 
00124 }
00125 }
00126 
00127 #endif /* UNITY_HUD_H */