From 62cbe91e1907a8cc82d71bd5189d63b4c44a40e3 Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 26 Oct 2015 20:06:26 +0100 Subject: [PATCH] Temporary fix to Ubuntu menu bug. --- src/menu.cc | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/src/menu.cc b/src/menu.cc index e3711a1..673cce3 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -10,27 +10,39 @@ Menu::Menu() { //TODO: if Ubuntu ever gets fixed, move to constructor, also cleanup the rest of the Ubuntu specific code void Menu::init() { + bool ubuntu_bugged_menu_system=false; //TODO: move to CMakeLists.txt and set -DUBUNTU_BUGGED_MENU +#ifdef __linux + if(boost::filesystem::exists("/usr/bin/lsb_release")) { + std::stringstream stdin_stream, stdout_stream; + Singleton::terminal()->execute(stdin_stream, stdout_stream, "lsb_release -is"); + if(stdout_stream.str()=="Ubuntu\n") + ubuntu_bugged_menu_system=true; + } +#else + ubuntu_bugged_menu_system=false; +#endif + auto accels=Singleton::Config::menu()->keys; for(auto &accel: accels) { -#ifdef __linux //Ubuntu... - size_t pos=0; - std::string second=accel.second; - while((pos=second.find('<', pos))!=std::string::npos) { - second.replace(pos, 1, "<"); - pos+=4; + if(ubuntu_bugged_menu_system) { + size_t pos=0; + std::string second=accel.second; + while((pos=second.find('<', pos))!=std::string::npos) { + second.replace(pos, 1, "<"); + pos+=4; + } + pos=0; + while((pos=second.find('>', pos))!=std::string::npos) { + second.replace(pos, 1, ">"); + pos+=4; + } + if(second.size()>0) + accel.second=""+second+""; + else + accel.second=""; } - pos=0; - while((pos=second.find('>', pos))!=std::string::npos) { - second.replace(pos, 1, ">"); - pos+=4; - } - if(second.size()>0) - accel.second=""+second+""; else accel.second=""; -#else - accel.second=""; -#endif } ui_xml =