Back to index

unity  6.0.0
FavoriteStore.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003 * Copyright (C) 2010 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_FAVORITE_STORE_H
00021 #define UNITY_FAVORITE_STORE_H
00022 
00023 #include <list>
00024 #include <string>
00025 
00026 #include <boost/utility.hpp>
00027 #include <sigc++/signal.h>
00028 
00029 
00030 namespace unity
00031 {
00032 
00033 // An abstract object that facilitates getting and modifying the list of favorites
00034 // Use GetDefault () to get the correct store for the session
00035 typedef std::list<std::string> FavoriteList;
00036 
00037 class FavoriteStore : public sigc::trackable, boost::noncopyable
00038 {
00039 public:
00040   FavoriteStore();
00041   virtual ~FavoriteStore();
00042 
00043   static FavoriteStore& Instance();
00044 
00045   virtual FavoriteList const& GetFavorites() = 0;
00046 
00047   // These will NOT emit the relevant signals, so bare that in mind
00048   // i.e. don't hope that you can add stuff and hook the view up to
00049   // favorite_added events to update the view. The signals only emit if
00050   // there has been a change on the GSettings object from an external
00051   // source
00052   virtual void AddFavorite(std::string const& desktop_path, int position) = 0;
00053   virtual void RemoveFavorite(std::string const& desktop_path) = 0;
00054   virtual void MoveFavorite(std::string const& desktop_path, int position) = 0;
00055   virtual void SetFavorites(FavoriteList const& desktop_paths) = 0;
00056 
00057   // Signals
00058   // These only emit if something has changed the GSettings object externally
00059 
00060   //desktop_path, position, before/after
00061   sigc::signal<void, std::string const&, std::string const&, bool> favorite_added;
00062   //desktop_path
00063   sigc::signal<void, std::string const&> favorite_removed;
00064   sigc::signal<void> reordered;
00065 };
00066 
00067 }
00068 
00069 #endif // FAVORITE_STORE_H