~3v1n0/unity/scale-window-cast-protection

« back to all changes in this revision

Viewing changes to launcher/ExpoLauncherIcon.cpp

  • Committer: Marco Trevisan (Treviño)
  • Date: 2016-03-07 18:51:47 UTC
  • mfrom: (4080 unity)
  • mto: This revision was merged to the branch mainline in revision 4085.
  • Revision ID: mail@3v1n0.net-20160307185147-0p1m89up4tqfb6w1
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
  SetQuirk(Quirk::VISIBLE, (WindowManager::Default().WorkspaceCount() > 1));
100
100
}
101
101
 
 
102
AbstractLauncherIcon::MenuItemsVector ExpoLauncherIcon::GetMenus()
 
103
{
 
104
  MenuItemsVector result;
 
105
  glib::Object<DbusmenuMenuitem> menu_item;
 
106
  typedef glib::Signal<void, DbusmenuMenuitem*, int> ItemSignal;
 
107
 
 
108
  auto& wm = WindowManager::Default();
 
109
  int h_size = wm.GetViewportHSize();
 
110
  int v_size = wm.GetViewportVSize();
 
111
  auto const& current_vp = wm.GetCurrentViewport();
 
112
 
 
113
  for (int h = 0; h < h_size; ++h)
 
114
  {
 
115
    for (int v = 0; v < v_size; ++v)
 
116
    {
 
117
      menu_item = dbusmenu_menuitem_new();
 
118
      glib::String label((v_size < 2) ? g_strdup_printf(_("Workspace %d"), (h+1)) :
 
119
                                        g_strdup_printf(_("Workspace %dx%d"), (h+1), (v+1)));
 
120
      dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, label);
 
121
      dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
 
122
      dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
 
123
 
 
124
      if (current_vp.x == h && current_vp.y == v)
 
125
      {
 
126
        dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, DBUSMENU_MENUITEM_TOGGLE_RADIO);
 
127
        dbusmenu_menuitem_property_set_int(menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED);
 
128
      }
 
129
 
 
130
      signals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [h, v] (DbusmenuMenuitem*, int) {
 
131
        WindowManager::Default().SetCurrentViewport({h, v});
 
132
      }));
 
133
      result.push_back(menu_item);
 
134
    }
 
135
  }
 
136
 
 
137
  return result;
 
138
}
 
139
 
102
140
std::string ExpoLauncherIcon::GetName() const
103
141
{
104
142
  return "ExpoLauncherIcon";