Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Packages] AudioControl: use icon name parameter #15

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 12 additions & 27 deletions packages/ghaf-audio-control/src/app/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,19 @@

#include <glibmm/optioncontext.h>

#include <filesystem>

using namespace ghaf::AudioControl;

namespace
{

constexpr auto AppId = "Ghaf Audio Control";
constexpr auto IconName = "audio-volume-high-panel";
constexpr auto IconSize = 64;

struct AppArgs
{
Glib::ustring pulseServerAddress;
Glib::ustring indicatorIconPath;
Glib::ustring indicatorIconName;
Glib::ustring appVms;
bool isDeamonMode = false;
Glib::ustring isDeamonMode;
};

std::vector<std::string> GetAppVmsList(const std::string& appVms)
Expand All @@ -41,18 +37,6 @@ std::vector<std::string> GetAppVmsList(const std::string& appVms)
return result;
}

std::optional<std::filesystem::path> GetThemeIcon()
{
auto icon_theme = Gtk::IconTheme::get_default();

if (auto iconInfo = icon_theme->lookup_icon(IconName, IconSize, Gtk::ICON_LOOKUP_USE_BUILTIN))
return iconInfo.get_filename().c_str();

Logger::error("App::getThemeIcon: couldn't found an icon");

return std::nullopt;
}

} // namespace

App::AppMenu::AppMenu(App& app)
Expand All @@ -79,9 +63,9 @@ App::App(int argc, char** argv)
pulseServerOption.set_long_name("pulseaudio_server");
pulseServerOption.set_description("PulseAudio server address");

Glib::OptionEntry indicatorIconPathOption;
indicatorIconPathOption.set_long_name("indicator_icon_path");
indicatorIconPathOption.set_description("Tray's icon indicator path");
Glib::OptionEntry indicatorIconNameOption;
indicatorIconNameOption.set_long_name("indicator_icon_name");
indicatorIconNameOption.set_description("Tray's icon indicator name");

Glib::OptionEntry appVmsOption;
appVmsOption.set_long_name("app_vms");
Expand All @@ -93,7 +77,7 @@ App::App(int argc, char** argv)

Glib::OptionGroup options("Main", "Main");
options.add_entry(pulseServerOption, appArgs.pulseServerAddress);
options.add_entry(indicatorIconPathOption, appArgs.indicatorIconPath);
options.add_entry(indicatorIconNameOption, appArgs.indicatorIconName);
options.add_entry(appVmsOption, appArgs.appVms);
options.add_entry(deamonModeOption, appArgs.isDeamonMode);

Expand All @@ -106,6 +90,11 @@ App::App(int argc, char** argv)
throw std::runtime_error{"Couldn't parse the command line arguments"};
}

Logger::info("Parsed the option: '{}' = '{}'", pulseServerOption.get_long_name().c_str(), appArgs.pulseServerAddress.c_str());
Logger::info("Parsed the option: '{}' = '{}'", indicatorIconNameOption.get_long_name().c_str(), appArgs.indicatorIconName.c_str());
Logger::info("Parsed the option: '{}' = '{}'", appVmsOption.get_long_name().c_str(), appArgs.appVms.c_str());
Logger::info("Parsed the option: '{}' = '{}'", deamonModeOption.get_long_name().c_str(), appArgs.isDeamonMode.c_str());

m_connections += signal_command_line().connect(
[this]([[maybe_unused]] const Glib::RefPtr<Gio::ApplicationCommandLine>& args)
{
Expand All @@ -114,11 +103,7 @@ App::App(int argc, char** argv)
},
false);

if (const auto iconPath = GetThemeIcon())
{
Logger::info("Got icon path for the indicator: {}", iconPath->c_str());
app_indicator_set_icon(m_indicator.get(), iconPath->filename().c_str());
}
app_indicator_set_icon(m_indicator.get(), appArgs.indicatorIconName.c_str());

m_audioControl = std::make_unique<AudioControl>(std::make_unique<Backend::PulseAudio::AudioControlBackend>(appArgs.pulseServerAddress),
GetAppVmsList(appArgs.appVms));
Expand Down
2 changes: 0 additions & 2 deletions packages/ghaf-audio-control/src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include "App.hpp"

#include <format>

using namespace ghaf::AudioControl;

int main(int argc, char** argv)
Expand Down
2 changes: 0 additions & 2 deletions packages/ghaf-audio-control/src/lib/src/widgets/AppList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include <gtkmm/scale.h>
#include <gtkmm/switch.h>

#include <format>

namespace ghaf::AudioControl
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@

#include <glibmm/binding.h>

#include <format>

namespace ghaf::AudioControl
{

constexpr auto CssStyle = "button#AppVmNameButton { background-color: transparent; border: none; font-weight: bold; }"
"box#DeviceWidget { background: #e6e6e6; border-radius: 15px; }"
"label#EmptyListName { background: #e6e6e6; border-radius: 15px; min-height: 40px; }"
"box#DeviceWidget { border-radius: 15px; }"
"label#EmptyListName { border-radius: 15px; min-height: 40px; }"
"*:selected { background-color: transparent; color: inherit; box-shadow: none; outline: none; }";

template<class IndexT, class DevicePtrT>
Expand Down
Loading