Back to index

unity  6.0.0
Indicator.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2010-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  *              Marco Trevisan (TreviƱo) <mail@3v1n0.net>
00019  */
00020 
00021 #ifndef UNITY_INDICATOR_H
00022 #define UNITY_INDICATOR_H
00023 
00024 #include <vector>
00025 #include <boost/utility.hpp>
00026 #include <sigc++/connection.h>
00027 
00028 #include "IndicatorEntry.h"
00029 
00030 
00031 namespace unity
00032 {
00033 namespace indicator
00034 {
00035 
00036 class Indicator : public sigc::trackable, boost::noncopyable
00037 {
00038 public:
00039   typedef std::shared_ptr<Indicator> Ptr;
00040   typedef std::list<Entry::Ptr> Entries;
00041 
00042   Indicator(std::string const& name);
00043   virtual ~Indicator();
00044 
00045   std::string const& name() const;
00046 
00047   virtual bool IsAppmenu() const { return false; }
00048 
00049   void Sync(Entries const& new_entries);
00050   Entry::Ptr GetEntry(std::string const& entry_id) const;
00051   Entries GetEntries() const;
00052 
00053   // Signals
00054   sigc::signal<void, Entry::Ptr const&> on_entry_added;
00055   sigc::signal<void, std::string const&> on_entry_removed;
00056   sigc::signal<void, std::string const&, unsigned int, int, int, unsigned int, unsigned int> on_show_menu;
00057   sigc::signal<void, std::string const&, unsigned int> on_secondary_activate;
00058   sigc::signal<void, std::string const&, int> on_scroll;
00059 
00060 protected:
00061   void OnEntryShowMenu(std::string const& entry_id, unsigned int xid, int x, int y, unsigned int button, unsigned int timestamp);
00062   void OnEntrySecondaryActivate(std::string const& entry_id, unsigned int timestamp);
00063   void OnEntryScroll(std::string const& entry_id, int delta);
00064 
00065   Entries entries_;
00066   std::string name_;
00067   std::map<Entry::Ptr, std::vector<sigc::connection>> entries_connections_;
00068 
00069   friend std::ostream& operator<<(std::ostream& out, Indicator const& i);
00070 };
00071 
00072 
00073 }
00074 }
00075 
00076 #endif // UNITY_INDICATOR_H