~3v1n0/unity/overlay-border-scale

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/SwitcherModel.cpp

  • 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:
30
30
namespace switcher
31
31
{
32
32
 
33
 
SwitcherModel::SwitcherModel(std::vector<AbstractLauncherIcon*> icons)
 
33
SwitcherModel::SwitcherModel(std::vector<AbstractLauncherIcon::Ptr> icons)
34
34
  : _inner(icons)
35
35
  , _index(0)
36
36
  , _last_index(0)
40
40
  only_detail_on_viewport = false;
41
41
 
42
42
  for (auto icon : _inner)
43
 
    icon->Reference();
 
43
  {
 
44
    AddChild(icon.GetPointer());
 
45
  }
44
46
}
45
47
 
46
48
SwitcherModel::~SwitcherModel()
47
49
{
48
50
  for (auto icon : _inner)
49
 
    icon->UnReference();
 
51
  {
 
52
    RemoveChild(icon.GetPointer());
 
53
  }
50
54
}
51
55
 
52
56
std::string SwitcherModel::GetName() const
56
60
 
57
61
void SwitcherModel::AddProperties(GVariantBuilder* builder)
58
62
{
59
 
  GVariantBuilder children_builder;
60
 
  g_variant_builder_init(&children_builder, G_VARIANT_TYPE("a(sv)"));
61
 
 
62
 
  for (auto icon : _inner)
63
 
  {
64
 
    if (icon->GetName() != "")
65
 
      g_variant_builder_add(&children_builder, "(sv)", icon->GetName().c_str(), icon->Introspect());
66
 
  }
67
 
 
68
63
  unity::variant::BuilderWrapper(builder)
69
64
  .add("detail-selection", detail_selection)
70
65
  .add("detail-selection-index", (int)detail_selection_index)
71
66
  .add("only-detail-on-viewport", only_detail_on_viewport)
72
67
  .add("selection-index", SelectionIndex())
73
 
  .add("last-selection-index", LastSelectionIndex())
74
 
  .add("children-of-men", g_variant_builder_end(&children_builder));
 
68
  .add("last-selection-index", LastSelectionIndex());
75
69
}
76
70
 
77
71
SwitcherModel::iterator
98
92
  return _inner.rend();
99
93
}
100
94
 
101
 
AbstractLauncherIcon*
 
95
AbstractLauncherIcon::Ptr
102
96
SwitcherModel::at(unsigned int index)
103
97
{
104
98
  if ((int) index >= Size ())
105
 
    return 0;
 
99
    return AbstractLauncherIcon::Ptr();
106
100
  return _inner[index];
107
101
}
108
102
 
112
106
  return _inner.size();
113
107
}
114
108
 
115
 
AbstractLauncherIcon*
 
109
AbstractLauncherIcon::Ptr
116
110
SwitcherModel::Selection()
117
111
{
118
112
  return _inner.at(_index);
124
118
  return _index;
125
119
}
126
120
 
127
 
AbstractLauncherIcon*
 
121
AbstractLauncherIcon::Ptr
128
122
SwitcherModel::LastSelection()
129
123
{
130
124
  return _inner.at(_last_index);
152
146
SwitcherModel::DetailXids()
153
147
{
154
148
  std::vector<Window> results;
155
 
  results = Selection()->RelatedXids ();
 
149
  results = Selection()->Windows();
156
150
 
157
151
  if (only_detail_on_viewport)
158
152
  {
233
227
}
234
228
 
235
229
void
236
 
SwitcherModel::Select(AbstractLauncherIcon* selection)
 
230
SwitcherModel::Select(AbstractLauncherIcon::Ptr selection)
237
231
{
238
232
  int i = 0;
239
233
  for (iterator it = begin(), e = end(); it != e; ++it)