Back to index

unity  6.0.0
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends
unity::indicator::Indicator Class Reference

#include <Indicator.h>

Inheritance diagram for unity::indicator::Indicator:
Inheritance graph
[legend]
Collaboration diagram for unity::indicator::Indicator:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::shared_ptr
< Indicator
Ptr
typedef std::list< Entry::PtrEntries

Public Member Functions

 Indicator (std::string const &name)
virtual ~Indicator ()
std::string const & name () const
virtual bool IsAppmenu () const
void Sync (Entries const &new_entries)
Entry::Ptr GetEntry (std::string const &entry_id) const
Entries GetEntries () const

Public Attributes

sigc::signal< void, Entry::Ptr
const & > 
on_entry_added
sigc::signal< void,
std::string const & > 
on_entry_removed
sigc::signal< void,
std::string const &, unsigned
int, int, int, unsigned int,
unsigned int > 
on_show_menu
sigc::signal< void,
std::string const &, unsigned
int > 
on_secondary_activate
sigc::signal< void,
std::string const &, int > 
on_scroll

Protected Member Functions

void OnEntryShowMenu (std::string const &entry_id, unsigned int xid, int x, int y, unsigned int button, unsigned int timestamp)
void OnEntrySecondaryActivate (std::string const &entry_id, unsigned int timestamp)
void OnEntryScroll (std::string const &entry_id, int delta)

Protected Attributes

Entries entries_
std::string name_
std::map< Entry::Ptr,
std::vector< sigc::connection > > 
entries_connections_

Friends

std::ostream & operator<< (std::ostream &out, Indicator const &i)

Detailed Description

Definition at line 36 of file Indicator.h.


Member Typedef Documentation

Definition at line 40 of file Indicator.h.

typedef std::shared_ptr<Indicator> unity::indicator::Indicator::Ptr

Definition at line 39 of file Indicator.h.


Constructor & Destructor Documentation

unity::indicator::Indicator::Indicator ( std::string const &  name)

Definition at line 32 of file Indicator.cpp.

  : name_(name)
{
}

Definition at line 37 of file Indicator.cpp.

{
  for (auto entry : entries_)
    on_entry_removed.emit(entry->id());

  entries_.clear();

  for (auto it : entries_connections_)
  {
    for (auto conn : it.second)
      conn.disconnect();

    it.second.clear();
  }
}

Member Function Documentation

Definition at line 58 of file Indicator.cpp.

{
  return entries_;
}
Entry::Ptr unity::indicator::Indicator::GetEntry ( std::string const &  entry_id) const

Definition at line 115 of file Indicator.cpp.

{
  for (auto entry : entries_)
    if (entry->id() == entry_id)
      return entry;

  return Entry::Ptr();
}

Here is the caller graph for this function:

virtual bool unity::indicator::Indicator::IsAppmenu ( ) const [inline, virtual]

Reimplemented in unity::indicator::AppmenuIndicator.

Definition at line 47 of file Indicator.h.

{ return false; }
std::string const & unity::indicator::Indicator::name ( ) const

Definition at line 53 of file Indicator.cpp.

{
  return name_;
}

Here is the caller graph for this function:

void unity::indicator::Indicator::OnEntryScroll ( std::string const &  entry_id,
int  delta 
) [protected]

Definition at line 136 of file Indicator.cpp.

{
  on_scroll.emit(entry_id, delta);
}

Here is the caller graph for this function:

void unity::indicator::Indicator::OnEntrySecondaryActivate ( std::string const &  entry_id,
unsigned int  timestamp 
) [protected]

Definition at line 130 of file Indicator.cpp.

{
  on_secondary_activate.emit(entry_id, timestamp);
}

Here is the caller graph for this function:

void unity::indicator::Indicator::OnEntryShowMenu ( std::string const &  entry_id,
unsigned int  xid,
int  x,
int  y,
unsigned int  button,
unsigned int  timestamp 
) [protected]

Definition at line 124 of file Indicator.cpp.

{
  on_show_menu.emit(entry_id, xid, x, y, button, timestamp);
}

Here is the caller graph for this function:

Definition at line 63 of file Indicator.cpp.

{
  Entries to_rm;

  if (entries_.size() == 0)
  {
    to_rm = entries_;
  }
  else
  {
    for (auto entry : entries_)
    {
      if (std::find(new_entries.begin(), new_entries.end(), entry) == new_entries.end())
      {
        to_rm.push_back(entry);
      }
    }
  }

  for (auto entry : to_rm) {
    for (auto conn : entries_connections_[entry])
      conn.disconnect();

    entries_connections_[entry].clear();

    on_entry_removed.emit(entry->id());
    entries_.remove(entry);
  }

  for (auto new_entry : new_entries)
  {
    if (GetEntry(new_entry->id()))
      continue;

    // Just add the new entry, and connect it up.
    sigc::connection conn;
    std::vector<sigc::connection>& new_entry_connections = entries_connections_[new_entry];

    conn = new_entry->on_show_menu.connect(sigc::mem_fun(this, &Indicator::OnEntryShowMenu));
    new_entry_connections.push_back(conn);

    conn = new_entry->on_secondary_activate.connect(sigc::mem_fun(this, &Indicator::OnEntrySecondaryActivate));
    new_entry_connections.push_back(conn);

    conn = new_entry->on_scroll.connect(sigc::mem_fun(this, &Indicator::OnEntryScroll));
    entries_.push_back(new_entry);
    new_entry_connections.push_back(conn);

    on_entry_added.emit(new_entry);
  }
}

Here is the call graph for this function:


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
Indicator const &  i 
) [friend]

Definition at line 141 of file Indicator.cpp.

{
  out << "<Indicator " << i.name() << std::endl;
  for (auto entry : i.entries_)
  {
    out << "\t" << entry << std::endl;
  }
  out << "\t>" << std::endl;
  return out;
}

Member Data Documentation

Definition at line 65 of file Indicator.h.

std::map<Entry::Ptr, std::vector<sigc::connection> > unity::indicator::Indicator::entries_connections_ [protected]

Definition at line 67 of file Indicator.h.

std::string unity::indicator::Indicator::name_ [protected]

Definition at line 66 of file Indicator.h.

Definition at line 54 of file Indicator.h.

sigc::signal<void, std::string const&> unity::indicator::Indicator::on_entry_removed

Definition at line 55 of file Indicator.h.

sigc::signal<void, std::string const&, int> unity::indicator::Indicator::on_scroll

Definition at line 58 of file Indicator.h.

sigc::signal<void, std::string const&, unsigned int> unity::indicator::Indicator::on_secondary_activate

Definition at line 57 of file Indicator.h.

sigc::signal<void, std::string const&, unsigned int, int, int, unsigned int, unsigned int> unity::indicator::Indicator::on_show_menu

Definition at line 56 of file Indicator.h.


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