~3v1n0/unity/overlay-border-scale

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/LauncherModel.h

  • Committer: Daniel van Vugt
  • Date: 2012-03-14 06:24:18 UTC
  • mfrom: (2108 unity)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: daniel.van.vugt@canonical.com-20120314062418-nprucpbr0m7qky5e
MergedĀ latestĀ lp:unity

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <memory>
24
24
 
25
 
#include "LauncherIcon.h"
 
25
#include "AbstractLauncherIcon.h"
 
26
#include "Introspectable.h"
26
27
#include <sigc++/sigc++.h>
27
28
 
28
29
namespace unity
30
31
namespace launcher
31
32
{
32
33
 
33
 
class LauncherModel : public sigc::trackable
 
34
class LauncherModel : public unity::debug::Introspectable, public sigc::trackable
34
35
{
35
36
public:
36
37
  typedef std::shared_ptr<LauncherModel> Ptr;
37
 
  typedef std::list<LauncherIcon*> Base;
 
38
  typedef std::vector<AbstractLauncherIcon::Ptr> Base;
38
39
  typedef Base::iterator iterator;
 
40
  typedef Base::const_iterator const_iterator;
39
41
  typedef Base::reverse_iterator reverse_iterator;
 
42
  typedef Base::reverse_iterator const_reverse_iterator;
40
43
 
41
44
  LauncherModel();
42
45
  ~LauncherModel();
43
46
 
44
 
  void AddIcon(LauncherIcon* icon);
45
 
  void RemoveIcon(LauncherIcon* icon);
 
47
  void AddIcon(AbstractLauncherIcon::Ptr icon);
 
48
  void RemoveIcon(AbstractLauncherIcon::Ptr icon);
46
49
  void Save();
47
50
  void Sort();
48
 
  int  Size();
49
 
 
50
 
  void OnIconRemove(LauncherIcon* icon);
51
 
 
52
 
  bool IconHasSister(LauncherIcon* icon);
53
 
 
54
 
  void ReorderBefore(LauncherIcon* icon, LauncherIcon* other, bool save);
55
 
 
56
 
  void ReorderSmart(LauncherIcon* icon, LauncherIcon* other, bool save);
 
51
  int  Size() const;
 
52
 
 
53
  void OnIconRemove(AbstractLauncherIcon::Ptr icon);
 
54
 
 
55
  bool IconHasSister(AbstractLauncherIcon::Ptr icon) const;
 
56
 
 
57
  void ReorderAfter(AbstractLauncherIcon::Ptr icon, AbstractLauncherIcon::Ptr other);
 
58
  void ReorderBefore(AbstractLauncherIcon::Ptr icon, AbstractLauncherIcon::Ptr other, bool save);
 
59
 
 
60
  void ReorderSmart(AbstractLauncherIcon::Ptr icon, AbstractLauncherIcon::Ptr other, bool save);
 
61
 
 
62
  AbstractLauncherIcon::Ptr Selection() const;
 
63
  int SelectionIndex() const;
 
64
  void SetSelection(int selection);
 
65
  void SelectNext();
 
66
  void SelectPrevious();
57
67
 
58
68
  iterator begin();
59
69
  iterator end();
71
81
  reverse_iterator shelf_rbegin();
72
82
  reverse_iterator shelf_rend();
73
83
 
74
 
  sigc::signal<void, LauncherIcon*> icon_added;
75
 
  sigc::signal<void, LauncherIcon*> icon_removed;
 
84
  sigc::signal<void, AbstractLauncherIcon::Ptr> icon_added;
 
85
  sigc::signal<void, AbstractLauncherIcon::Ptr> icon_removed;
76
86
  sigc::signal<void> order_changed;
77
87
  sigc::signal<void> saved;
 
88
  sigc::signal<void, AbstractLauncherIcon::Ptr> selection_changed;
78
89
 
79
 
  // connected to from class Launcher
80
 
  sigc::connection on_icon_added_connection;
81
 
  sigc::connection on_icon_removed_connection;
82
 
  sigc::connection on_order_changed_connection;
 
90
  IntrospectableList const& GetIntrospectableChildren();
 
91
protected:
 
92
  // Introspectable methods
 
93
  std::string GetName() const;
 
94
  void AddProperties(GVariantBuilder* builder);
83
95
 
84
96
private:
85
97
  Base             _inner;
86
98
  Base             _inner_shelf;
87
99
  Base             _inner_main;
 
100
  int              selection_;
 
101
  std::list<unity::debug::Introspectable*> introspection_results_;
88
102
 
89
103
  bool Populate();
90
104
 
91
 
  bool IconShouldShelf(LauncherIcon* icon);
 
105
  bool IconShouldShelf(AbstractLauncherIcon::Ptr icon) const;
92
106
 
93
107
  static gboolean RemoveCallback(gpointer data);
94
108
 
95
 
  static bool CompareIcons(LauncherIcon* first, LauncherIcon* second);
 
109
  static bool CompareIcons(AbstractLauncherIcon::Ptr first, AbstractLauncherIcon::Ptr second);
96
110
 
97
111
  /* Template Methods */
98
112
public:
99
113
  template<class T>
100
 
  std::list<T*> GetSublist()
 
114
  std::list<AbstractLauncherIcon::Ptr> GetSublist()
101
115
  {
102
 
    std::list<T*> result;
 
116
    std::list<AbstractLauncherIcon::Ptr> result;
103
117
 
104
118
    iterator it;
105
119
    for (it = begin(); it != end(); it++)
106
120
    {
107
 
      T* var = dynamic_cast<T*>(*it);
 
121
      T* var = dynamic_cast<T*>((*it).GetPointer());
108
122
 
109
123
      if (var)
110
 
        result.push_back(var);
 
124
        result.push_back(*it);
111
125
    }
112
126
 
113
127
    return result;