Back to index

unity  6.0.0
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Static Private Member Functions | Private Attributes
unity::switcher::SwitcherModel Class Reference

#include <SwitcherModel.h>

Inheritance diagram for unity::switcher::SwitcherModel:
Inheritance graph
[legend]
Collaboration diagram for unity::switcher::SwitcherModel:
Collaboration graph
[legend]

List of all members.

Public Types

typedef boost::shared_ptr
< SwitcherModel
Ptr
typedef std::vector
< launcher::AbstractLauncherIcon::Ptr
Base
typedef Base::iterator iterator
typedef Base::reverse_iterator reverse_iterator
typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 SwitcherModel (std::vector< launcher::AbstractLauncherIcon::Ptr > icons)
virtual ~SwitcherModel ()
iterator begin ()
iterator end ()
reverse_iterator rbegin ()
reverse_iterator rend ()
launcher::AbstractLauncherIcon::Ptr at (unsigned int index)
int Size ()
launcher::AbstractLauncherIcon::Ptr Selection ()
int SelectionIndex ()
launcher::AbstractLauncherIcon::Ptr LastSelection ()
int LastSelectionIndex ()
std::vector< Window > DetailXids ()
Window DetailSelectionWindow ()
void Next ()
void Prev ()
void NextDetail ()
void PrevDetail ()
void Select (launcher::AbstractLauncherIcon::Ptr selection)
void Select (unsigned int index)
GVariant * Introspect ()
void AddChild (Introspectable *child)
void RemoveChild (Introspectable *child)
virtual IntrospectableList GetIntrospectableChildren ()
guint64 GetIntrospectionId () const

Public Attributes

nux::Property< bool > detail_selection
nux::Property< unsigned int > detail_selection_index
nux::Property< bool > only_detail_on_viewport
sigc::signal< void,
launcher::AbstractLauncherIcon::Ptr
selection_changed

Protected Member Functions

std::string GetName () const
void AddProperties (GVariantBuilder *builder)
virtual std::string GetChildsName () const
 Please don't override this unless you really need to. The only valid reason is if you have a property that simply must be called 'Children'.

Static Private Member Functions

static bool CompareWindowsByActive (guint32 first, guint32 second)

Private Attributes

Base _inner
unsigned int _index
unsigned int _last_index

Detailed Description

Definition at line 38 of file SwitcherModel.h.


Member Typedef Documentation

Definition at line 44 of file SwitcherModel.h.

Definition at line 34 of file Introspectable.h.

Definition at line 45 of file SwitcherModel.h.

Definition at line 42 of file SwitcherModel.h.

typedef Base::reverse_iterator unity::switcher::SwitcherModel::reverse_iterator

Definition at line 46 of file SwitcherModel.h.


Constructor & Destructor Documentation

Definition at line 33 of file SwitcherModel.cpp.

  : _inner(icons)
  , _index(0)
  , _last_index(0)
{
  detail_selection = false;
  detail_selection_index = 0;
  only_detail_on_viewport = false;

  for (auto icon : _inner)
  {
    AddChild(icon.GetPointer());
  }
}

Here is the call graph for this function:

Definition at line 48 of file SwitcherModel.cpp.

{
  for (auto icon : _inner)
  {
    RemoveChild(icon.GetPointer());
  }
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 78 of file Introspectable.cpp.

{
  _children.push_back(child);
  child->_parents.push_back(this);
}

Here is the caller graph for this function:

void unity::switcher::SwitcherModel::AddProperties ( GVariantBuilder *  builder) [protected, virtual]

Implements unity::debug::Introspectable.

Definition at line 61 of file SwitcherModel.cpp.

{
  unity::variant::BuilderWrapper(builder)
  .add("detail-selection", detail_selection)
  .add("detail-selection-index", (int)detail_selection_index)
  .add("detail-current-count", DetailXids().size())
  .add("only-detail-on-viewport", only_detail_on_viewport)
  .add("selection-index", SelectionIndex())
  .add("last-selection-index", LastSelectionIndex());
}

Here is the call graph for this function:

Definition at line 97 of file SwitcherModel.cpp.

{
  if ((int) index >= Size ())
    return AbstractLauncherIcon::Ptr();
  return _inner[index];
}

Here is the call graph for this function:

Definition at line 73 of file SwitcherModel.cpp.

{
  return _inner.begin();
}
bool unity::switcher::SwitcherModel::CompareWindowsByActive ( guint32  first,
guint32  second 
) [static, private]

Definition at line 135 of file SwitcherModel.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 167 of file SwitcherModel.cpp.

{
  if (!detail_selection || DetailXids ().empty())
    return 0;

  if (detail_selection_index > DetailXids().size() - 1)
    return 0;

  return DetailXids()[detail_selection_index];
}

Here is the call graph for this function:

std::vector< Window > unity::switcher::SwitcherModel::DetailXids ( )

Definition at line 147 of file SwitcherModel.cpp.

{
  std::vector<Window> results;
  results = Selection()->Windows();

  if (only_detail_on_viewport)
  {
    results.erase(std::remove_if(results.begin(), results.end(), WindowOnOtherViewport), results.end());
  }

  std::sort (results.begin (), results.end (), &CompareWindowsByActive);

  // swap so we focus the last focused window first
  if (Selection()->GetQuirk (AbstractLauncherIcon::QUIRK_ACTIVE) && results.size () > 1)
    std::swap (results[0], results[1]);

  return results;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 79 of file SwitcherModel.cpp.

{
  return _inner.end();
}
std::string unity::debug::Introspectable::GetChildsName ( ) const [protected, virtual, inherited]

Please don't override this unless you really need to. The only valid reason is if you have a property that simply must be called 'Children'.

Definition at line 92 of file Introspectable.cpp.

{
  return "Children";
}

Here is the caller graph for this function:

Introspectable::IntrospectableList unity::debug::Introspectable::GetIntrospectableChildren ( ) [virtual, inherited]

Reimplemented in unity::hud::View, unity::launcher::LauncherModel, unity::QuicklistView, and unity::dash::ResultView.

Definition at line 41 of file Introspectable.cpp.

{
  return _children;
}

Here is the caller graph for this function:

guint64 unity::debug::Introspectable::GetIntrospectionId ( ) const [inherited]

Definition at line 97 of file Introspectable.cpp.

{
  return _id;
}

Here is the caller graph for this function:

std::string unity::switcher::SwitcherModel::GetName ( ) const [protected, virtual]

Implements unity::debug::Introspectable.

Definition at line 56 of file SwitcherModel.cpp.

{
  return "SwitcherModel";
}
GVariant * unity::debug::Introspectable::Introspect ( ) [inherited]

Definition at line 47 of file Introspectable.cpp.

{
  GVariantBuilder  builder;
  GVariantBuilder  child_builder;
  gint             n_children = 0;

  g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
  g_variant_builder_add(&builder, "{sv}", "id", g_variant_new_uint64(_id));

  AddProperties(&builder);

  g_variant_builder_init(&child_builder, G_VARIANT_TYPE("as"));

  auto children = GetIntrospectableChildren();
  for (auto it = children.begin(); it != children.end(); it++)
  {
    if ((*it)->GetName() != "")
    {
      g_variant_builder_add(&child_builder, "s", (*it)->GetName().c_str());
      n_children++;
    }
  }

  GVariant* child_results = g_variant_builder_end(&child_builder);

  if (n_children > 0)
    g_variant_builder_add(&builder, "{sv}", GetChildsName().c_str(), child_results);
  return g_variant_builder_end(&builder);
}

Here is the call graph for this function:

Definition at line 123 of file SwitcherModel.cpp.

{
  return _inner.at(_last_index);
}

Definition at line 129 of file SwitcherModel.cpp.

{
  return _last_index;
}

Here is the caller graph for this function:

Definition at line 179 of file SwitcherModel.cpp.

Here is the call graph for this function:

Definition at line 208 of file SwitcherModel.cpp.

Here is the call graph for this function:

Definition at line 193 of file SwitcherModel.cpp.

{
  _last_index = _index;

  if (_index > 0)
    _index--;
  else
    _index = _inner.size() - 1;

  detail_selection = false;
  detail_selection_index = 0;
  selection_changed.emit(Selection());
}

Here is the call graph for this function:

Definition at line 219 of file SwitcherModel.cpp.

{
  if (!detail_selection())
    return;

  if (detail_selection_index >= (unsigned int) 1)
    detail_selection_index = detail_selection_index - 1;
  else
    detail_selection_index = DetailXids().size() - 1;
}

Here is the call graph for this function:

Definition at line 85 of file SwitcherModel.cpp.

{
  return _inner.rbegin();
}

Definition at line 85 of file Introspectable.cpp.

{
  _children.remove(child);
  child->_parents.remove(this);
}

Here is the caller graph for this function:

Definition at line 91 of file SwitcherModel.cpp.

{
  return _inner.rend();
}
void unity::switcher::SwitcherModel::Select ( unsigned int  index)

Definition at line 254 of file SwitcherModel.cpp.

{
  unsigned int target = CLAMP(index, 0, _inner.size() - 1);

  if (target != _index)
  {
    _last_index = _index;
    _index = target;

    detail_selection = false;
    detail_selection_index = 0;
    selection_changed.emit(Selection());
  }
}

Here is the call graph for this function:

Definition at line 111 of file SwitcherModel.cpp.

{
  return _inner.at(_index);
}

Here is the caller graph for this function:

Definition at line 117 of file SwitcherModel.cpp.

{
  return _index;
}

Here is the caller graph for this function:

Definition at line 105 of file SwitcherModel.cpp.

{
  return _inner.size();
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 98 of file SwitcherModel.h.

Definition at line 97 of file SwitcherModel.h.

Definition at line 99 of file SwitcherModel.h.

Definition at line 48 of file SwitcherModel.h.

Definition at line 49 of file SwitcherModel.h.

Definition at line 50 of file SwitcherModel.h.

Definition at line 86 of file SwitcherModel.h.


The documentation for this class was generated from the following files: