add setCustomIcon and try to apply such when ID is known
This commit is contained in:
@ -62,6 +62,7 @@ class Item : public sigc::trackable {
|
|||||||
void proxyReady(Glib::RefPtr<Gio::AsyncResult>& result);
|
void proxyReady(Glib::RefPtr<Gio::AsyncResult>& result);
|
||||||
void setProperty(const Glib::ustring& name, Glib::VariantBase& value);
|
void setProperty(const Glib::ustring& name, Glib::VariantBase& value);
|
||||||
void setStatus(const Glib::ustring& value);
|
void setStatus(const Glib::ustring& value);
|
||||||
|
void setCustomIcon(const std::string& id);
|
||||||
void getUpdatedProperties();
|
void getUpdatedProperties();
|
||||||
void processUpdatedProperties(Glib::RefPtr<Gio::AsyncResult>& result);
|
void processUpdatedProperties(Glib::RefPtr<Gio::AsyncResult>& result);
|
||||||
void onSignal(const Glib::ustring& sender_name, const Glib::ustring& signal_name,
|
void onSignal(const Glib::ustring& sender_name, const Glib::ustring& signal_name,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "modules/sni/item.hpp"
|
#include "modules/sni/item.hpp"
|
||||||
|
#include "modules/sni/icon_manager.hpp"
|
||||||
|
|
||||||
#include <gdkmm/general.h>
|
#include <gdkmm/general.h>
|
||||||
#include <glibmm/main.h>
|
#include <glibmm/main.h>
|
||||||
@ -7,6 +8,7 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#include "gdk/gdk.h"
|
#include "gdk/gdk.h"
|
||||||
#include "util/format.hpp"
|
#include "util/format.hpp"
|
||||||
@ -138,6 +140,7 @@ void Item::setProperty(const Glib::ustring& name, Glib::VariantBase& value) {
|
|||||||
category = get_variant<std::string>(value);
|
category = get_variant<std::string>(value);
|
||||||
} else if (name == "Id") {
|
} else if (name == "Id") {
|
||||||
id = get_variant<std::string>(value);
|
id = get_variant<std::string>(value);
|
||||||
|
setCustomIcon(id);
|
||||||
} else if (name == "Title") {
|
} else if (name == "Title") {
|
||||||
title = get_variant<std::string>(value);
|
title = get_variant<std::string>(value);
|
||||||
if (tooltip.text.empty()) {
|
if (tooltip.text.empty()) {
|
||||||
@ -199,6 +202,19 @@ void Item::setStatus(const Glib::ustring& value) {
|
|||||||
style->add_class(lower);
|
style->add_class(lower);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Item::setCustomIcon(const std::string& id) {
|
||||||
|
std::string custom_icon = IconManager::instance().getIconForApp(id);
|
||||||
|
if (!custom_icon.empty()) {
|
||||||
|
if (std::filesystem::exists(custom_icon)) {
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> custom_pixbuf = Gdk::Pixbuf::create_from_file(custom_icon);
|
||||||
|
icon_name = ""; // icon_name has priority over pixmap
|
||||||
|
icon_pixmap = custom_pixbuf;
|
||||||
|
} else { // if file doesn't exist it's most likely an icon_name
|
||||||
|
icon_name = custom_icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Item::getUpdatedProperties() {
|
void Item::getUpdatedProperties() {
|
||||||
auto params = Glib::VariantContainerBase::create_tuple(
|
auto params = Glib::VariantContainerBase::create_tuple(
|
||||||
{Glib::Variant<Glib::ustring>::create(SNI_INTERFACE_NAME)});
|
{Glib::Variant<Glib::ustring>::create(SNI_INTERFACE_NAME)});
|
||||||
|
Reference in New Issue
Block a user