~cando/unity/fix_692444

« back to all changes in this revision

Viewing changes to src/LauncherIcon.cpp

  • Committer: Mirco Müller
  • Date: 2011-02-03 17:36:30 UTC
  • mfrom: (803.1.15 unity.fix-701546-2)
  • Revision ID: mirco.mueller@ubuntu.com-20110203173630-vto9fp3jtpkn1wm9
added:
  resources/round_glow_hl_62x62.png
modified:
  src/BamfLauncherIcon.cpp
  src/BamfLauncherIcon.h
  src/Launcher.cpp
  src/Launcher.h
  src/LauncherEntryRemote.h
  src/LauncherIcon.cpp
  src/LauncherIcon.h
  src/SimpleLauncherIcon.cpp
  src/SimpleLauncherIcon.h
  src/UBusMessages.h
  src/unityshell.cpp
  src/unityshell.h
  unityshell.xml.in

The first part of a11y (keyboard-navigation) support for the launcher. By
default Alt-F1 sets the input-focus on the launcher and you can use
Up/Down to move the selection around, SPACE/RETURN activates the currently
selected icon, Shift-F10/Right opens the quicklist (keyboard-navigation
for this isn't merged yet), ESC (or opening Quicklist) exits keyboard-navigation
of launcher. Fixes LP: #701546

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
  g_variant_builder_add (builder, "{sv}", "quirk-presented", g_variant_new_boolean (GetQuirk (QUIRK_PRESENTED)));
137
137
}
138
138
 
 
139
void
 
140
LauncherIcon::Activate ()
 
141
{
 
142
}
 
143
 
139
144
nux::Color LauncherIcon::BackgroundColor ()
140
145
{
141
146
  return _background_color;
330
335
  _tooltip->ShowWindow (false);
331
336
}
332
337
 
 
338
void LauncherIcon::OpenQuicklist ()
 
339
{
 
340
  _tooltip->ShowWindow (false);    
 
341
  _quicklist->RemoveAllMenuItem ();
 
342
 
 
343
  std::list<DbusmenuMenuitem *> menus = Menus ();
 
344
  if (menus.empty ())
 
345
    return;
 
346
 
 
347
  std::list<DbusmenuMenuitem *>::iterator it;
 
348
  for (it = menus.begin (); it != menus.end (); it++)
 
349
  {
 
350
    DbusmenuMenuitem *menu_item = *it;
 
351
    
 
352
    const gchar* type = dbusmenu_menuitem_property_get (menu_item, DBUSMENU_MENUITEM_PROP_TYPE);
 
353
    const gchar* toggle_type = dbusmenu_menuitem_property_get (menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE);
 
354
 
 
355
    if (g_strcmp0 (type, DBUSMENU_CLIENT_TYPES_SEPARATOR) == 0)
 
356
    {
 
357
      QuicklistMenuItemSeparator* item = new QuicklistMenuItemSeparator (menu_item, NUX_TRACKER_LOCATION);
 
358
      _quicklist->AddMenuItem (item);
 
359
    }
 
360
    else if (g_strcmp0 (toggle_type, DBUSMENU_MENUITEM_TOGGLE_CHECK) == 0)
 
361
    {
 
362
      QuicklistMenuItemCheckmark* item = new QuicklistMenuItemCheckmark (menu_item, NUX_TRACKER_LOCATION);
 
363
      _quicklist->AddMenuItem (item);
 
364
    }
 
365
    else if (g_strcmp0 (toggle_type, DBUSMENU_MENUITEM_TOGGLE_RADIO) == 0)
 
366
    {
 
367
      QuicklistMenuItemRadio* item = new QuicklistMenuItemRadio (menu_item, NUX_TRACKER_LOCATION);
 
368
      _quicklist->AddMenuItem (item);
 
369
    }
 
370
    else //(g_strcmp0 (type, DBUSMENU_MENUITEM_PROP_LABEL) == 0)
 
371
    {
 
372
      QuicklistMenuItemLabel* item = new QuicklistMenuItemLabel (menu_item, NUX_TRACKER_LOCATION);
 
373
      _quicklist->AddMenuItem (item);
 
374
    }
 
375
  }
 
376
    
 
377
  int tip_x = _launcher->GetBaseWidth () + 1; //icon_x + icon_w;
 
378
  int tip_y = _center.y + _launcher->GetParent ()->GetGeometry ().y;
 
379
  QuicklistManager::Default ()->ShowQuicklist (_quicklist, tip_x, tip_y);
 
380
  nux::GetWindowCompositor ().SetAlwaysOnFrontWindow (_quicklist);
 
381
}
 
382
 
333
383
void LauncherIcon::RecvMouseDown (int button)
334
384
{
335
385
  if (button == 3)
336
 
  {
337
 
    _tooltip->ShowWindow (false);
338
 
    
339
 
    _quicklist->RemoveAllMenuItem ();
340
 
    
341
 
    std::list<DbusmenuMenuitem *> menus = Menus ();
342
 
    if (menus.empty ())
343
 
      return;
344
 
 
345
 
    std::list<DbusmenuMenuitem *>::iterator it;
346
 
    for (it = menus.begin (); it != menus.end (); it++)
347
 
    {
348
 
      DbusmenuMenuitem *menu_item = *it;
349
 
    
350
 
      const gchar* type = dbusmenu_menuitem_property_get (menu_item, DBUSMENU_MENUITEM_PROP_TYPE);
351
 
      const gchar* toggle_type = dbusmenu_menuitem_property_get (menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE);
352
 
 
353
 
      if (g_strcmp0 (type, DBUSMENU_CLIENT_TYPES_SEPARATOR) == 0)
354
 
      {
355
 
        QuicklistMenuItemSeparator* item = new QuicklistMenuItemSeparator (menu_item, NUX_TRACKER_LOCATION);
356
 
        _quicklist->AddMenuItem (item);
357
 
      }
358
 
      else if (g_strcmp0 (toggle_type, DBUSMENU_MENUITEM_TOGGLE_CHECK) == 0)
359
 
      {
360
 
        QuicklistMenuItemCheckmark* item = new QuicklistMenuItemCheckmark (menu_item, NUX_TRACKER_LOCATION);
361
 
        _quicklist->AddMenuItem (item);
362
 
      }
363
 
      else if (g_strcmp0 (toggle_type, DBUSMENU_MENUITEM_TOGGLE_RADIO) == 0)
364
 
      {
365
 
        QuicklistMenuItemRadio* item = new QuicklistMenuItemRadio (menu_item, NUX_TRACKER_LOCATION);
366
 
        _quicklist->AddMenuItem (item);
367
 
      }
368
 
      else //(g_strcmp0 (type, DBUSMENU_MENUITEM_PROP_LABEL) == 0)
369
 
      {
370
 
        QuicklistMenuItemLabel* item = new QuicklistMenuItemLabel (menu_item, NUX_TRACKER_LOCATION);
371
 
        _quicklist->AddMenuItem (item);
372
 
      }
373
 
    } 
374
 
    
375
 
    int tip_x = _launcher->GetBaseWidth () + 1; //icon_x + icon_w;
376
 
    int tip_y = _center.y + _launcher->GetParent ()->GetGeometry ().y;
377
 
    QuicklistManager::Default ()->ShowQuicklist (_quicklist, tip_x, tip_y);
378
 
    nux::GetWindowCompositor ().SetAlwaysOnFrontWindow (_quicklist);
379
 
  }
 
386
    OpenQuicklist ();
380
387
}
381
388
 
382
389
void LauncherIcon::RecvMouseUp (int button)