~mial/ubuntu/oneiric/unity/bug-791810

« back to all changes in this revision

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

  • Committer: Neil Jagdish Patel
  • Date: 2011-09-05 14:00:26 UTC
  • mto: This revision was merged to the branch mainline in revision 1489.
  • Revision ID: neil.patel@canonical.com-20110905140026-hkc3myq0ka5l5kp6
Change DashController to load lazily, clean up some bits and pieces

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
  , last_opacity_(0.0f)
45
45
  , start_time_(0)
46
46
{
47
 
  SetupWindow();
48
 
  SetupDashView();
 
47
  //SetupWindow();
 
48
  //SetupDashView();
49
49
  SetupRelayoutCallbacks();
50
50
  RegisterUBusInterests();
51
51
 
52
52
  PluginAdapter::Default()->compiz_screen_ungrabbed.connect(sigc::mem_fun(this, &DashController::OnScreenUngrabbed));
53
53
 
54
 
  Relayout();
 
54
  //Relayout();
55
55
}
56
56
 
57
57
DashController::~DashController()
58
58
{
59
 
  window_->UnReference();
 
59
  if (window_)
 
60
    window_->UnReference();
60
61
  g_source_remove(timeline_id_);
61
62
}
62
63
 
101
102
                                 sigc::mem_fun(this, &DashController::OnExternalShowDash));
102
103
  ubus_manager_.RegisterInterest(UBUS_PLACE_VIEW_CLOSE_REQUEST,
103
104
                                 sigc::mem_fun(this, &DashController::OnExternalHideDash));
 
105
  ubus_manager_.RegisterInterest(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,
 
106
                                 sigc::mem_fun(this, &DashController::OnActivateRequest));
 
107
  ubus_manager_.RegisterInterest(UBUS_DASH_ABOUT_TO_SHOW,
 
108
                                 [&] (GVariant*) { EnsureDash(); });
 
109
}
 
110
 
 
111
void DashController::EnsureDash()
 
112
{
 
113
  if (window_)
 
114
    return;
 
115
 
 
116
  LOG_DEBUG(logger) << "Initializing Dash";
 
117
 
 
118
  SetupWindow();
 
119
  SetupDashView();
 
120
  Relayout();
104
121
}
105
122
 
106
123
nux::BaseWindow* DashController::window() const
134
151
 
135
152
void DashController::Relayout(GdkScreen*screen)
136
153
{
 
154
  EnsureDash();
 
155
 
137
156
  nux::Geometry geo = GetIdealWindowGeometry();
138
157
  window_->SetGeometry(geo);
139
158
  view_->Relayout();
148
167
void DashController::OnScreenUngrabbed()
149
168
{
150
169
  if (need_show_)
 
170
  {
 
171
    EnsureDash();
151
172
    ShowDash();
 
173
  }
152
174
}
153
175
 
154
176
void DashController::OnExternalShowDash(GVariant* variant)
155
177
{
 
178
  EnsureDash();
156
179
  visible_ ? HideDash() : ShowDash();
157
180
}
158
181
 
159
182
void DashController::OnExternalHideDash(GVariant* variant)
160
183
{
 
184
  EnsureDash();
161
185
  HideDash();
162
186
}
163
187
 
164
188
void DashController::ShowDash()
165
189
{
 
190
  EnsureDash();
 
191
 
166
192
  PluginAdapter* adaptor = PluginAdapter::Default();
167
 
 
168
193
  // Don't want to show at the wrong time
169
194
  if (visible_ || adaptor->IsExpoActive() || adaptor->IsScaleActive())
170
195
    return;
203
228
{
204
229
  if (!visible_)
205
230
   return;
206
 
  
 
231
 
 
232
  EnsureDash();
 
233
 
207
234
  view_->AboutToHide();
208
235
 
209
236
  window_->CaptureMouseDownAnyWhereElse(false);
220
247
 
221
248
void DashController::StartShowHideTimeline()
222
249
{
 
250
  EnsureDash();
 
251
 
223
252
  if (timeline_id_)
224
253
    g_source_remove(timeline_id_);
225
254
 
258
287
 
259
288
    return FALSE;
260
289
  }
 
290
 
261
291
  return TRUE;
262
 
 
263
 
 
 
292
}
 
293
 
 
294
void DashController::OnActivateRequest(GVariant* variant)
 
295
{
 
296
  EnsureDash();
 
297
  ubus_manager_.UnregisterInterest(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST);
 
298
  view_->OnActivateRequest(variant);
 
299
  ShowDash();
264
300
}
265
301
 
266
302
// Introspectable