2
* Copyright (C) 2010 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
19
#include "IndicatorObjectProxyRemote.h"
21
#include "IndicatorObjectEntryProxyRemote.h"
23
static void on_row_added (DeeModel *model,
25
IndicatorObjectProxyRemote *remote);
27
static void on_row_changed (DeeModel *model,
29
IndicatorObjectProxyRemote *remote);
31
static void on_row_removed (DeeModel *model,
33
IndicatorObjectProxyRemote *remote);
35
IndicatorObjectProxyRemote::IndicatorObjectProxyRemote (const char *name,
36
const char *model_name)
38
_model_name (model_name)
40
_model = dee_shared_model_new_with_name (model_name);
41
g_signal_connect (_model, "row-added",
42
G_CALLBACK (on_row_added), this);
43
g_signal_connect (_model, "row-changed",
44
G_CALLBACK (on_row_changed), this);
45
g_signal_connect (_model, "row-removed",
46
G_CALLBACK (on_row_removed), this);
48
dee_shared_model_connect (DEE_SHARED_MODEL (_model));
51
IndicatorObjectProxyRemote::~IndicatorObjectProxyRemote ()
53
std::vector<IndicatorObjectEntryProxy*>::iterator it;
55
for (it = _entries.begin(); it != _entries.end(); it++)
57
IndicatorObjectEntryProxyRemote *remote = static_cast<IndicatorObjectEntryProxyRemote *> (*it);
61
_entries.erase (_entries.begin (), _entries.end ());
65
IndicatorObjectProxyRemote::GetName ()
70
std::vector<IndicatorObjectEntryProxy *>&
71
IndicatorObjectProxyRemote::GetEntries ()
77
IndicatorObjectProxyRemote::OnRowAdded (DeeModelIter *iter)
79
IndicatorObjectEntryProxyRemote *remote;
81
remote = new IndicatorObjectEntryProxyRemote (_model, iter);
82
remote->OnShowMenuRequest.connect (sigc::mem_fun (this, &IndicatorObjectProxyRemote::OnShowMenuRequestReceived));
83
_entries.push_back (remote);
85
OnEntryAdded.emit (remote);
89
IndicatorObjectProxyRemote::OnShowMenuRequestReceived (const char *id,
94
OnShowMenuRequest.emit (id, x, y, timestamp);
98
IndicatorObjectProxyRemote::OnRowChanged (DeeModelIter *iter)
100
std::vector<IndicatorObjectEntryProxy*>::iterator it;
102
for (it = _entries.begin(); it != _entries.end(); it++)
104
IndicatorObjectEntryProxyRemote *remote = static_cast<IndicatorObjectEntryProxyRemote *> (*it);
105
if (remote->_iter == iter)
111
IndicatorObjectProxyRemote::OnRowRemoved (DeeModelIter *iter)
113
std::vector<IndicatorObjectEntryProxy*>::iterator it;
115
for (it = _entries.begin(); it != _entries.end(); it++)
117
IndicatorObjectEntryProxyRemote *remote = static_cast<IndicatorObjectEntryProxyRemote *> (*it);
118
if (remote->_iter == iter)
121
OnEntryRemoved.emit (remote);
130
// C callbacks, they just link to class methods and aren't interesting
133
on_row_added (DeeModel *model, DeeModelIter *iter, IndicatorObjectProxyRemote *remote)
135
remote->OnRowAdded (iter);
139
on_row_changed (DeeModel *model, DeeModelIter *iter, IndicatorObjectProxyRemote *remote)
141
remote->OnRowChanged (iter);
145
on_row_removed (DeeModel *model, DeeModelIter *iter, IndicatorObjectProxyRemote *remote)
147
remote->OnRowRemoved (iter);