Back to index

unity  6.0.0
SwitcherModel.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: Jason Smith <jason.smith@canonical.com>
00018  */
00019 
00020 #ifndef SWITCHERMODEL_H
00021 #define SWITCHERMODEL_H
00022 
00023 #include <sys/time.h>
00024 
00025 #include "AbstractLauncherIcon.h"
00026 #include "LauncherModel.h"
00027 
00028 #include "unity-shared/Introspectable.h"
00029 
00030 #include <boost/shared_ptr.hpp>
00031 #include <sigc++/sigc++.h>
00032 
00033 namespace unity
00034 {
00035 namespace switcher
00036 {
00037 
00038 class SwitcherModel : public debug::Introspectable, public sigc::trackable
00039 {
00040 
00041 public:
00042   typedef boost::shared_ptr<SwitcherModel> Ptr;
00043 
00044   typedef std::vector<launcher::AbstractLauncherIcon::Ptr> Base;
00045   typedef Base::iterator iterator;
00046   typedef Base::reverse_iterator reverse_iterator;
00047 
00048   nux::Property<bool> detail_selection;
00049   nux::Property<unsigned int> detail_selection_index;
00050   nux::Property<bool> only_detail_on_viewport;
00051 
00052   // Icons are owned externally and assumed valid for life of switcher.
00053   // When AbstractLauncherIcon is complete, it will be passed as a shared pointer and this
00054   // will no longer be a worry.
00055   SwitcherModel(std::vector<launcher::AbstractLauncherIcon::Ptr> icons);
00056   virtual ~SwitcherModel();
00057 
00058   iterator begin();
00059   iterator end();
00060 
00061   reverse_iterator rbegin();
00062   reverse_iterator rend();
00063 
00064   launcher::AbstractLauncherIcon::Ptr at(unsigned int index);
00065 
00066   int Size();
00067 
00068   launcher::AbstractLauncherIcon::Ptr Selection();
00069   int SelectionIndex();
00070 
00071   launcher::AbstractLauncherIcon::Ptr LastSelection();
00072   int LastSelectionIndex();
00073 
00074   std::vector<Window> DetailXids ();
00075   Window DetailSelectionWindow ();
00076 
00077   void Next();
00078   void Prev();
00079 
00080   void NextDetail();
00081   void PrevDetail();
00082 
00083   void Select(launcher::AbstractLauncherIcon::Ptr selection);
00084   void Select(unsigned int index);
00085 
00086   sigc::signal<void, launcher::AbstractLauncherIcon::Ptr> selection_changed;
00087 
00088 protected:
00089   // Introspectable methods
00090   std::string GetName() const;
00091   void AddProperties(GVariantBuilder* builder);
00092 
00093 private:
00094 
00095   static bool CompareWindowsByActive (guint32 first, guint32 second);
00096 
00097   Base             _inner;
00098   unsigned int     _index;
00099   unsigned int     _last_index;
00100 };
00101 
00102 }
00103 }
00104 
00105 #endif // SWITCHERMODEL_H
00106