// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
/*
* Copyright (C) 2011 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authored by: Jason Smith
*/
#ifndef SWITCHERCONTROLLER_H
#define SWITCHERCONTROLLER_H
#include
#include
#include "unity-shared/Introspectable.h"
#include "unity-shared/UBusWrapper.h"
#include "SwitcherModel.h"
#include "SwitcherView.h"
#include
#include
#include
namespace unity
{
namespace launcher
{
class AbstractLauncherIcon;
}
namespace switcher
{
enum class SortMode
{
LAUNCHER_ORDER,
FOCUS_ORDER,
};
enum class ShowMode
{
ALL,
CURRENT_VIEWPORT,
};
class Controller : public debug::Introspectable, public sigc::trackable
{
public:
typedef std::shared_ptr Ptr;
Controller(unsigned int load_timeout = 20);
nux::Property timeout_length;
nux::Property detail_on_timeout;
nux::Property detail_timeout_length;
nux::Property initial_detail_timeout_length;
void Show(ShowMode show, SortMode sort, std::vector results);
void Hide(bool accept_state=true);
bool CanShowSwitcher(const std::vector& resutls) const;
bool Visible();
void Next();
void Prev();
void NextDetail();
void PrevDetail();
void Select (int index);
void SetDetail(bool detail, unsigned int min_windows = 1);
void SelectFirstItem();
void SetWorkspace(nux::Geometry geo, int monitor);
SwitcherView * GetView ();
ui::LayoutWindowList ExternalRenderTargets ();
guint GetSwitcherInputWindowId() const;
bool IsShowDesktopDisabled() const;
void SetShowDesktopDisabled(bool disabled);
int StartIndex() const;
sigc::signal view_built;
protected:
// Introspectable methods
std::string GetName() const;
void AddProperties(GVariantBuilder* builder);
virtual void ConstructWindow();
virtual void ConstructView();
virtual void ShowView();
virtual bool OnDetailTimer();
void OnModelSelectionChanged(launcher::AbstractLauncherIcon::Ptr icon);
unsigned int construct_timeout_;
private:
enum DetailMode
{
TAB_NEXT_WINDOW,
TAB_NEXT_WINDOW_LOOP,
TAB_NEXT_TILE,
};
void OnBackgroundUpdate(GVariant* data);
static bool CompareSwitcherItemsPriority(launcher::AbstractLauncherIcon::Ptr first, launcher::AbstractLauncherIcon::Ptr second);
SwitcherModel::Ptr model_;
SwitcherView::Ptr view_;
nux::Geometry workarea_;
nux::ObjectPtr view_window_;
nux::HLayout* main_layout_;
int monitor_;
bool visible_;
bool show_desktop_disabled_;
nux::Color bg_color_;
DetailMode detail_mode_;
UBusManager ubus_manager_;
glib::SourceManager sources_;
};
}
}
#endif // SWITCHERCONTROLLER_H