68 lines
2.8 KiB
Diff
68 lines
2.8 KiB
Diff
From 57ec3f3a1c417c3f6d98eee6e466ad1715cbf36c Mon Sep 17 00:00:00 2001
|
|
From: yangfeng <yangfeng@kylinsec.com.cn>
|
|
Date: Fri, 19 Jan 2024 11:32:09 +0800
|
|
Subject: [PATCH] fix(power-tray):Fixed an issue where the laptop tray battery
|
|
icon is not the same size as other icons.
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
- 修复笔记本托盘电池图标与其他图标大小不一致问题
|
|
|
|
- Related #25531
|
|
---
|
|
plugins/power/tray/power-tray.cpp | 20 +++++++++++++++-----
|
|
1 file changed, 15 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/plugins/power/tray/power-tray.cpp b/plugins/power/tray/power-tray.cpp
|
|
index dee86e8..6c96069 100644
|
|
--- a/plugins/power/tray/power-tray.cpp
|
|
+++ b/plugins/power/tray/power-tray.cpp
|
|
@@ -89,9 +89,9 @@ void PowerTray::update_status_icon()
|
|
}
|
|
else
|
|
{
|
|
- // this->icon_pixbuf_ = this->get_pixbuf_by_icon_name(icon_name);
|
|
- // gtk_status_icon_set_from_pixbuf(this->status_icon_, this->icon_pixbuf_->gobj());
|
|
- gtk_status_icon_set_from_icon_name(this->status_icon_, icon_name.c_str());
|
|
+ this->icon_pixbuf_ = this->get_pixbuf_by_icon_name(icon_name);
|
|
+ gtk_status_icon_set_from_pixbuf(this->status_icon_, this->icon_pixbuf_->gobj());
|
|
+ // gtk_status_icon_set_from_icon_name(this->status_icon_, icon_name.c_str());
|
|
gtk_status_icon_set_visible(this->status_icon_, true);
|
|
}
|
|
|
|
@@ -167,8 +167,12 @@ std::shared_ptr<PowerUPowerDevice> PowerTray::get_device_for_tray(const std::vec
|
|
Glib::RefPtr<Gdk::Pixbuf> PowerTray::get_pixbuf_by_icon_name(const std::string& icon_name)
|
|
{
|
|
auto theme_name = Gtk::Settings::get_default()->property_gtk_theme_name().get_value();
|
|
- bool was_symbolic = false;
|
|
+ bool was_symbolic = true;
|
|
Gdk::RGBA fg_color;
|
|
+ Gdk::RGBA success_color;
|
|
+ Gdk::RGBA warning_color;
|
|
+ Gdk::RGBA error_color;
|
|
+
|
|
|
|
if (theme_name.empty())
|
|
{
|
|
@@ -187,9 +191,15 @@ Glib::RefPtr<Gdk::Pixbuf> PowerTray::get_pixbuf_by_icon_name(const std::string&
|
|
|
|
auto style_context = Gtk::StyleContext::create();
|
|
style_context->add_provider(provider, GTK_STYLE_PROVIDER_PRIORITY_USER);
|
|
+ style_context->lookup_color("theme_fg_color", fg_color);
|
|
+ style_context->lookup_color("success_color", success_color);
|
|
+ style_context->lookup_color("warning_color", warning_color);
|
|
+ style_context->lookup_color("error_color", error_color);
|
|
+
|
|
auto scale = Gdk::Window::get_default_root_window()->get_scale_factor();
|
|
auto icon_info = Gtk::IconTheme::get_default()->lookup_icon(icon_name, 16, scale);
|
|
- return icon_info.load_symbolic(style_context, was_symbolic);
|
|
+
|
|
+ return icon_info.load_symbolic(fg_color, success_color, warning_color, error_color, was_symbolic);
|
|
}
|
|
|
|
std::string PowerTray::get_device_icon_name(std::shared_ptr<PowerUPowerDevice> upower_device)
|
|
--
|
|
2.27.0
|
|
|