diff --git a/src/panel/widgets/launchers.cpp b/src/panel/widgets/launchers.cpp index cd11fb15..16d47e7f 100644 --- a/src/panel/widgets/launchers.cpp +++ b/src/panel/widgets/launchers.cpp @@ -62,12 +62,18 @@ struct FileLauncherInfo : public LauncherInfo { std::string command; std::string icon; + std::string label; - bool load(std::string name, std::string icon) + bool load(std::string command, std::string icon, std::string label) { - command = name; + this->command = command; this->icon = icon; - + if(label == "") + { + this->label = command; + } else { + this->label = label; + } return load_icon_pixbuf_safe(icon, 24).get() != nullptr; } @@ -78,7 +84,7 @@ struct FileLauncherInfo : public LauncherInfo std::string get_text() { - return command; + return label; } void execute() @@ -104,7 +110,7 @@ void WfLauncherButton::set_size(int size) on_scale_update(); } -bool WfLauncherButton::initialize(std::string name, std::string icon) +bool WfLauncherButton::initialize(std::string name, std::string icon, std::string label) { launcher_name = name; base_size = WfOption {"panel/launcher_size"} / LAUNCHERS_ICON_SCALE; @@ -120,7 +126,7 @@ bool WfLauncherButton::initialize(std::string name, std::string icon) } else { auto fl = new FileLauncherInfo(); - if (!fl->load(name, icon)) + if (!fl->load(name, icon, label)) { std::cerr << "Failed to load icon " << icon << std::endl; return false; @@ -248,13 +254,14 @@ launcher_container WayfireLaunchers::get_launchers_from_config() const std::string desktop_prefix = "launcher_"; const std::string file_icon_prefix = "launcher_icon_"; const std::string file_cmd_prefix = "launcher_cmd_"; + const std::string file_label_prefix = "launcher_label_"; launcher_container launchers; auto try_push_launcher = [&launchers] ( - const std::string cmd, const std::string icon) + const std::string cmd, const std::string icon, const std::string label = "") { auto launcher = new WfLauncherButton(); - if (launcher->initialize(cmd, icon)) { + if (launcher->initialize(cmd, icon, label)) { launchers.push_back(std::unique_ptr(launcher)); } else { delete launcher; @@ -272,17 +279,26 @@ launcher_container WayfireLaunchers::get_launchers_from_config() auto icon_option = section->get_option_or(file_icon_prefix + launcher_name); if (icon_option) { - /* bingo, found command + icon */ - try_push_launcher(opt->get_value_str(), - icon_option->get_value_str()); + /* bingo, found command + icon + * now look for the corresponding label */ + auto label_option = section->get_option_or(file_label_prefix + launcher_name); + if(label_option) + { + /* found label */ + try_push_launcher(opt->get_value_str(), icon_option->get_value_str(), + label_option->get_value_str()); + } else { + try_push_launcher(opt->get_value_str(), icon_option->get_value_str()); + } } } /* an entry is a deskop-file entry if the it has the desktop prefix - * but not the file_icon or file_cmd prefix */ + * but not the file_icon, file_cmd or file_label prefix */ if (begins_with(opt->get_name(), desktop_prefix) && !begins_with(opt->get_name(), file_icon_prefix) && - !begins_with(opt->get_name(), file_cmd_prefix)) + !begins_with(opt->get_name(), file_cmd_prefix) && + !begins_with(opt->get_name(), file_label_prefix)) { try_push_launcher(opt->get_value_str(), "none"); } diff --git a/src/panel/widgets/launchers.hpp b/src/panel/widgets/launchers.hpp index 90ed023d..f4363a8b 100644 --- a/src/panel/widgets/launchers.hpp +++ b/src/panel/widgets/launchers.hpp @@ -49,7 +49,7 @@ struct WfLauncherButton WfLauncherButton& operator = (const WfLauncherButton&) = delete; ~WfLauncherButton(); - bool initialize(std::string name, std::string icon = "none"); + bool initialize(std::string name, std::string icon = "none", std::string label = ""); bool on_click(GdkEventButton *ev); bool on_enter(GdkEventCrossing *ev);