~njpatel/unity/nicer-gobject-signals

« back to all changes in this revision

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

  • Committer: Neil Jagdish Patel
  • Date: 2011-07-07 20:42:57 UTC
  • mfrom: (1255.1.15 unity)
  • Revision ID: neil.patel@canonical.com-20110707204257-t4lnftykpft24a37
[merge] trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
139
139
        return "PlacesSearchBar";
140
140
}
141
141
 
142
 
const gchar *
143
 
PlacesSearchBar::GetChildsName ()
 
142
const gchar* PlacesSearchBar::GetChildsName ()
144
143
{
145
144
  return "";
146
145
}
150
149
  unity::variant::BuilderWrapper(builder).add(GetGeometry());
151
150
}
152
151
 
153
 
long
154
 
PlacesSearchBar::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
 
152
long PlacesSearchBar::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, 
 
153
                                    long ProcessEventInfo)
155
154
{
156
155
  long ret = TraverseInfo;
157
156
  ret = _layout->ProcessEvent (ievent, ret, ProcessEventInfo);
159
158
  return ret;
160
159
}
161
160
 
162
 
void
163
 
PlacesSearchBar::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)
 
161
void PlacesSearchBar::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)
164
162
{
165
163
  nux::Geometry geo = GetGeometry ();
166
164
 
178
176
  GfxContext.PopClippingRectangle ();
179
177
}
180
178
 
181
 
void
182
 
PlacesSearchBar::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
 
179
void PlacesSearchBar::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
183
180
{
184
181
  nux::Geometry geo = GetGeometry ();
185
182
 
193
190
  GfxContext.PopClippingRectangle();
194
191
}
195
192
 
196
 
void
197
 
PlacesSearchBar::SetActiveEntry (PlaceEntry *entry,
198
 
                                 guint       section_id,
199
 
                                 const char *search_string)
 
193
void PlacesSearchBar::SetActiveEntry (PlaceEntry *entry,
 
194
                                      guint       section_id,
 
195
                                      const char *search_string)
200
196
{
201
197
   std::map<gchar *, gchar *> hints;
202
198
 
232
228
  }
233
229
}
234
230
 
235
 
void
236
 
PlacesSearchBar::OnSectionAdded (PlaceEntry *entry, PlaceEntrySection& section)
 
231
void PlacesSearchBar::OnSectionAdded (PlaceEntry *entry, PlaceEntrySection& section)
237
232
{
238
233
  char *tmp = g_markup_escape_text (section.GetName (), -1);
239
234
 
243
238
  g_free (tmp);
244
239
}
245
240
 
246
 
void
247
 
PlacesSearchBar::OnComboChanged (nux::ComboBoxSimple *simple)
 
241
void PlacesSearchBar::OnComboChanged (nux::ComboBoxSimple *simple)
248
242
{
249
243
  _entry->SetActiveSection (_combo->GetSelectionIndex());
250
244
  OnMenuClosing (NULL, 0, 0);
251
245
}
252
246
 
253
 
void
254
 
PlacesSearchBar::OnMenuClosing (nux::MenuPage *menu, int x, int y)
 
247
void PlacesSearchBar::OnMenuClosing (nux::MenuPage *menu, int x, int y)
255
248
{
256
249
  ubus_server_send_message (ubus_server_get_default (),
257
250
                            UBUS_PLACE_VIEW_QUEUE_DRAW,
258
251
                            NULL);
259
252
}
260
253
 
261
 
void
262
 
PlacesSearchBar::OnSearchChanged (nux::TextEntry *text_entry)
 
254
void PlacesSearchBar::OnSearchChanged (nux::TextEntry *text_entry)
263
255
{
264
256
  bool is_empty;
265
257
 
283
275
  QueueDraw ();
284
276
}
285
277
 
286
 
bool
287
 
PlacesSearchBar::OnLiveSearchTimeout (PlacesSearchBar *self)
 
278
bool PlacesSearchBar::OnLiveSearchTimeout (PlacesSearchBar *self)
288
279
{
289
280
  self->EmitLiveSearch ();
290
281
  self->_live_search_timeout = 0;
292
283
  return FALSE;
293
284
}
294
285
 
295
 
void
296
 
PlacesSearchBar::EmitLiveSearch ()
 
286
void PlacesSearchBar::EmitLiveSearch ()
297
287
{
298
288
  if (_entry)
299
289
  {
303
293
  }
304
294
}
305
295
 
306
 
void
307
 
PlacesSearchBar::OnClearClicked (int x, int y, unsigned long button_flags, unsigned long key_flags)
 
296
void PlacesSearchBar::OnClearClicked (int x, int y, unsigned long button_flags,
 
297
                                      unsigned long key_flags)
308
298
{
 
299
  gchar*                   markup;
 
300
  gchar*                   tmp;
 
301
  std::map<gchar*, gchar*> hints;
 
302
 
 
303
  tmp = g_markup_escape_text (_entry->GetSearchHint (), -1);
 
304
  markup  = g_strdup_printf ("<span font_size='x-small' font_style='italic'> %s </span>", tmp);
 
305
 
 
306
  _hint->SetText (markup);
309
307
  if (_pango_entry->GetText () != "")
310
308
  {
311
309
    _pango_entry->SetText ("");
314
312
  }
315
313
}
316
314
 
317
 
void
318
 
PlacesSearchBar::OnEntryActivated ()
 
315
void PlacesSearchBar::OnEntryActivated ()
319
316
{
320
317
  activated.emit ();
321
318
}
322
319
 
323
 
void
324
 
PlacesSearchBar::OnLayeredLayoutQueueDraw (int i)
 
320
void PlacesSearchBar::OnLayeredLayoutQueueDraw (int i)
325
321
{
326
322
  QueueDraw ();
327
323
}
332
328
  _spinner->SetState (STATE_CLEAR);
333
329
}
334
330
 
335
 
void
336
 
PlacesSearchBar::OnFontChanged (GObject *object, GParamSpec *pspec, PlacesSearchBar *self)
 
331
void PlacesSearchBar::OnFontChanged (GObject *object, GParamSpec *pspec, 
 
332
                                     PlacesSearchBar *self)
337
333
{
338
334
#define HOW_LARGE 8
339
335
  GtkSettings          *settings;
370
366
  g_free (font_desc);
371
367
}
372
368
 
373
 
void
374
 
PlacesSearchBar::OnPlacesClosed (GVariant *variant, PlacesSearchBar *self)
 
369
void PlacesSearchBar::OnPlacesClosed (GVariant *variant, PlacesSearchBar *self)
375
370
{
376
371
  self->_combo->GetMenuPage ()->StopMenu ();
377
372
}
378
373
 
379
 
static void
380
 
draw_rounded_rect (cairo_t* cr,
381
 
                   double   aspect,
382
 
                   double   x,
383
 
                   double   y,
384
 
                   double   cornerRadius,
385
 
                   double   width,
386
 
                   double   height)
 
374
static void draw_rounded_rect (cairo_t* cr,
 
375
                               double   aspect,
 
376
                               double   x,
 
377
                               double   y,
 
378
                               double   cornerRadius,
 
379
                               double   width,
 
380
                               double   height)
387
381
{
388
382
    double radius = cornerRadius / aspect;
389
383
 
433
427
  cairo_close_path (cr);
434
428
}
435
429
 
436
 
void
437
 
PlacesSearchBar::UpdateBackground ()
 
430
void PlacesSearchBar::UpdateBackground ()
438
431
{
439
432
#define PADDING 14
440
433
#define RADIUS  6
505
498
 
506
499
  texture2D->UnReference ();
507
500
}
 
501
 
 
502
void PlacesSearchBar::RecvMouseDownFromWindow (int x, int y, 
 
503
                                               unsigned long button_flags, 
 
504
                                               unsigned long key_flags)
 
505
{
 
506
  if (_pango_entry->GetGeometry ().IsPointInside (x, y))
 
507
  {
 
508
    _hint->SetText ("");
 
509
  }
 
510
}