171 lines
6.5 KiB
Diff
171 lines
6.5 KiB
Diff
From d6faccac23ee5dd61fafded0269d8a12752be0e3 Mon Sep 17 00:00:00 2001
|
||
From: tangjie02 <tangjie02@kylinsec.com.cn>
|
||
Date: Thu, 13 Oct 2022 20:30:02 +0800
|
||
Subject: [PATCH] feature(menu): Add flat class for button to keep consistent
|
||
with the color of color block.
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
- 给按钮添加flat样式,这样在普通状态下背景是透明的,可以跟色块颜色保持一致。
|
||
|
||
Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
|
||
---
|
||
data/menu.ui.xml | 10 +++++-----
|
||
src/menu/menu-app-item.cpp | 2 ++
|
||
src/menu/menu-app-launcher-button.cpp | 1 +
|
||
src/menu/menu-applet-window.cpp | 6 ++++++
|
||
src/menu/menu-applet-window.h | 4 +++-
|
||
src/menu/menu-category-item.cpp | 1 +
|
||
src/menu/menu-new-apps-container.cpp | 4 +++-
|
||
src/menu/menu-power-button.cpp | 1 +
|
||
8 files changed, 22 insertions(+), 7 deletions(-)
|
||
|
||
diff --git a/data/menu.ui.xml b/data/menu.ui.xml
|
||
index 90193b3..ae8fb50 100644
|
||
--- a/data/menu.ui.xml
|
||
+++ b/data/menu.ui.xml
|
||
@@ -1,5 +1,5 @@
|
||
<?xml version="1.0" encoding="UTF-8"?>
|
||
-<!-- Generated with glade 3.22.1 -->
|
||
+<!-- Generated with glade 3.36.0 -->
|
||
<interface>
|
||
<requires lib="gtk+" version="3.20"/>
|
||
<object class="GtkWindow" id="menu-window">
|
||
@@ -10,9 +10,6 @@
|
||
<property name="default_height">682</property>
|
||
<property name="skip_taskbar_hint">True</property>
|
||
<property name="skip_pager_hint">True</property>
|
||
- <child>
|
||
- <placeholder/>
|
||
- </child>
|
||
<child>
|
||
<object class="GtkBox" id="menu-container">
|
||
<property name="visible">True</property>
|
||
@@ -56,7 +53,7 @@
|
||
<property name="vexpand">True</property>
|
||
<property name="orientation">vertical</property>
|
||
<child>
|
||
- <object class="GtkStackSwitcher">
|
||
+ <object class="GtkStackSwitcher" id="menu-view-stack-switcher">
|
||
<property name="visible">True</property>
|
||
<property name="can_focus">False</property>
|
||
<property name="hexpand">True</property>
|
||
@@ -358,5 +355,8 @@
|
||
</child>
|
||
</object>
|
||
</child>
|
||
+ <child type="titlebar">
|
||
+ <placeholder/>
|
||
+ </child>
|
||
</object>
|
||
</interface>
|
||
diff --git a/src/menu/menu-app-item.cpp b/src/menu/menu-app-item.cpp
|
||
index fa672c2..e0959a5 100644
|
||
--- a/src/menu/menu-app-item.cpp
|
||
+++ b/src/menu/menu-app-item.cpp
|
||
@@ -30,6 +30,8 @@ MenuAppItem::MenuAppItem(const std::shared_ptr<Kiran::App> &app_, int _icon_size
|
||
auto context = get_style_context();
|
||
|
||
context->add_class("menu-app-item");
|
||
+ // 添加flat样式,保证在普通状态下按钮时透明背景
|
||
+ context->add_class("flat");
|
||
|
||
set_text(app_->get_locale_name());
|
||
|
||
diff --git a/src/menu/menu-app-launcher-button.cpp b/src/menu/menu-app-launcher-button.cpp
|
||
index 2bb1419..8453484 100644
|
||
--- a/src/menu/menu-app-launcher-button.cpp
|
||
+++ b/src/menu/menu-app-launcher-button.cpp
|
||
@@ -28,6 +28,7 @@ MenuAppLauncherButton::MenuAppLauncherButton(const std::string &icon_name, const
|
||
Gio::APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION);
|
||
|
||
context->add_class("menu-app-launcher");
|
||
+ context->add_class("flat");
|
||
}
|
||
|
||
void MenuAppLauncherButton::on_clicked()
|
||
diff --git a/src/menu/menu-applet-window.cpp b/src/menu/menu-applet-window.cpp
|
||
index eea61c9..7cc9750 100644
|
||
--- a/src/menu/menu-applet-window.cpp
|
||
+++ b/src/menu/menu-applet-window.cpp
|
||
@@ -214,6 +214,7 @@ void MenuAppletWindow::init_ui()
|
||
builder = Gtk::Builder::create_from_resource("/kiran-menu/ui/menu");
|
||
builder->get_widget<Gtk::Box>("menu-container", main_box);
|
||
builder->get_widget<Gtk::Box>("menu-sider-container", sider_box);
|
||
+ builder->get_widget<Gtk::StackSwitcher>("menu-view-stack-switcher", menu_view_stack_switcher);
|
||
builder->get_widget<Gtk::Stack>("menu-view-stack", menu_view_stack);
|
||
builder->get_widget<Gtk::Stack>("apps-list-stack", apps_list_stack);
|
||
|
||
@@ -234,6 +235,11 @@ void MenuAppletWindow::init_ui()
|
||
sider_box->set_name("menu-left-container");
|
||
menu_view_stack->set_name("menu-mid-container");
|
||
|
||
+ for (const auto &child : menu_view_stack_switcher->get_children())
|
||
+ {
|
||
+ child->get_style_context()->add_class("flat");
|
||
+ }
|
||
+
|
||
/* 最近访问文档列表 */
|
||
auto widget = Gtk::make_managed<RecentFilesWidget>();
|
||
recent_files_view->add(*widget);
|
||
diff --git a/src/menu/menu-applet-window.h b/src/menu/menu-applet-window.h
|
||
index 0eae7d7..c9e9ad6 100644
|
||
--- a/src/menu/menu-applet-window.h
|
||
+++ b/src/menu/menu-applet-window.h
|
||
@@ -176,7 +176,9 @@ private:
|
||
Glib::RefPtr<Gtk::Builder> builder;
|
||
|
||
Gtk::SearchEntry *search_entry;
|
||
- Gtk::Stack *menu_view_stack, *apps_list_stack;
|
||
+ Gtk::StackSwitcher *menu_view_stack_switcher;
|
||
+ Gtk::Stack *menu_view_stack;
|
||
+ Gtk::Stack *apps_list_stack;
|
||
Gtk::Box *all_apps_page; /* */
|
||
Gtk::Box *compact_favorites_view; /* 紧凑模式下的收藏夹页面 */
|
||
|
||
diff --git a/src/menu/menu-category-item.cpp b/src/menu/menu-category-item.cpp
|
||
index 9c48b95..e062660 100644
|
||
--- a/src/menu/menu-category-item.cpp
|
||
+++ b/src/menu/menu-category-item.cpp
|
||
@@ -33,6 +33,7 @@ MenuCategoryItem::MenuCategoryItem(const std::string &name,
|
||
auto context = get_style_context();
|
||
|
||
context->add_class("menu-category-item");
|
||
+ context->add_class("flat");
|
||
set_clickable(clickable);
|
||
category_name = name;
|
||
}
|
||
diff --git a/src/menu/menu-new-apps-container.cpp b/src/menu/menu-new-apps-container.cpp
|
||
index bd12eed..a58e32e 100644
|
||
--- a/src/menu/menu-new-apps-container.cpp
|
||
+++ b/src/menu/menu-new-apps-container.cpp
|
||
@@ -90,9 +90,11 @@ Gtk::ToggleButton *MenuNewAppsContainer::create_expand_button()
|
||
button->set_image_position(Gtk::POS_RIGHT);
|
||
button->set_alignment(0.0, 0.5);
|
||
button->get_style_context()->add_class("menu-expand-button");
|
||
+ button->get_style_context()->add_class("flat");
|
||
|
||
button->signal_toggled().connect(
|
||
- [this]() -> void {
|
||
+ [this]() -> void
|
||
+ {
|
||
auto image = dynamic_cast<Gtk::Image *>(expand_button->get_image());
|
||
|
||
if (expand_button->get_active())
|
||
diff --git a/src/menu/menu-power-button.cpp b/src/menu/menu-power-button.cpp
|
||
index 1a5a224..0237153 100644
|
||
--- a/src/menu/menu-power-button.cpp
|
||
+++ b/src/menu/menu-power-button.cpp
|
||
@@ -27,6 +27,7 @@ MenuPowerButton::MenuPowerButton() : menu(nullptr)
|
||
set_focus_on_click(false);
|
||
|
||
context->add_class("menu-app-launcher");
|
||
+ context->add_class("flat");
|
||
}
|
||
|
||
MenuPowerButton::~MenuPowerButton()
|
||
--
|
||
2.33.0
|
||
|