Back to index

unity  6.0.0
Functions
unity::shortcut::impl Namespace Reference

Functions

std::string GetMetaKey (std::string const &scut)
std::string FixShortcutFormat (std::string const &scut)
std::string GetTranslatableLabel (std::string const &scut)
std::string FixMouseShortcut (std::string const &scut)
std::string ProperCase (std::string const &str)

Function Documentation

std::string unity::shortcut::impl::FixMouseShortcut ( std::string const &  scut)

Definition at line 81 of file ShortcutHintPrivate.cpp.

{
  std::string ret(scut);
  
  boost::replace_all(ret, "Button1", _("Left Mouse"));
  boost::replace_all(ret, "Button2", _("Middle Mouse"));
  boost::replace_all(ret, "Button3", _("Right Mouse"));
      
  return ret;
}

Here is the caller graph for this function:

std::string unity::shortcut::impl::FixShortcutFormat ( std::string const &  scut)

Definition at line 43 of file ShortcutHintPrivate.cpp.

{
  std::string ret(scut.begin(), scut.end() - 1);
  
  boost::replace_all(ret, "<", "");
  boost::replace_all(ret, ">", " + ");
  
  if (scut[scut.size()-1] != '>')
    ret += scut[scut.size()-1];
    
  return ret;
}

Here is the caller graph for this function:

std::string unity::shortcut::impl::GetMetaKey ( std::string const &  scut)

Definition at line 34 of file ShortcutHintPrivate.cpp.

{
  size_t index = scut.find_last_of( ">");
  if (index >= 0)
    return std::string(scut.begin(), scut.begin() + index + 1);
  else
    return "";
}

Here is the caller graph for this function:

std::string unity::shortcut::impl::GetTranslatableLabel ( std::string const &  scut)

Definition at line 56 of file ShortcutHintPrivate.cpp.

{
  guint accelerator_key;
  GdkModifierType accelerator_mods;

  gtk_accelerator_parse(scut.c_str(),
                        &accelerator_key,
                        &accelerator_mods);

  std::string temp(glib::String(gtk_accelerator_get_label(accelerator_key, accelerator_mods)).Str());

  // gtk_accelerator_get_label adds an extra '+' at the end of the label.
  if (temp.length() > 0)
  {
    std::string::iterator it = temp.end() - 1;
    if (*it == '+')
      temp.erase(it);
  }

  // Adds an extra space around the '+'.
  boost::replace_all(temp, "+", " + ");
    
  return temp;
}

Here is the caller graph for this function:

std::string unity::shortcut::impl::ProperCase ( std::string const &  str)

Definition at line 92 of file ShortcutHintPrivate.cpp.

{
  std::string ret = str;
  
       bool cap_next = true;

       for (unsigned int i = 0; i < ret.length(); ++i)
  {
    if (cap_next and isalpha(ret[i]))
    {
      ret[i]=toupper(ret[i]);
      cap_next = false;
    }
    else
    {
      cap_next = ispunct(ret[i]) || isspace(ret[i]);
    }
  }
  
  return ret;
}

Here is the caller graph for this function: