Projects
home:Eustace:branches:Eulaceura:Factory
kiran-cc-daemon
_service:obs_scm:0006-feature-appearance-Add-su...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0006-feature-appearance-Add-support-reset-default-font.patch of Package kiran-cc-daemon
From f393efb6424a9d8f7352d2dbc0a6df174d8a2e55 Mon Sep 17 00:00:00 2001 From: meizhigang <meizhigang@kylinsec.com.cn> Date: Wed, 21 Feb 2024 10:50:01 +0800 Subject: [PATCH] feature(appearance):Add support reset default font MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加支持重置默认字体功能 Related #20203 --- include/error-i.h | 2 + lib/base/error.cpp | 2 + plugins/appearance/appearance-manager.cpp | 14 +++++++ plugins/appearance/appearance-manager.h | 2 + ...ylinsec.Kiran.SessionDaemon.Appearance.xml | 7 ++++ plugins/appearance/font/appearance-font.cpp | 40 +++++++++++++++++++ plugins/appearance/font/appearance-font.h | 1 + 7 files changed, 68 insertions(+) diff --git a/include/error-i.h b/include/error-i.h index 9a81d3c..1b73db5 100644 --- a/include/error-i.h +++ b/include/error-i.h @@ -104,7 +104,9 @@ extern "C" ERROR_APPEARANCE_THEME_TYPE_INVALID = 0xA0100, ERROR_APPEARANCE_FONT_TYPE_INVALID_1, ERROR_APPEARANCE_FONT_TYPE_INVALID_2, + ERROR_APPEARANCE_FONT_TYPE_INVALID_3, ERROR_APPEARANCE_FONT_TYPE_UNSUPPORTED, + ERROR_APPEARANCE_RESET_FONT_FAILED, ERROR_APPEARANCE_SET_BACKGROUND_FAILED, ERROR_APPEARANCE_SET_LOCKSCREEN_BACKGROUND_FAILED, diff --git a/lib/base/error.cpp b/lib/base/error.cpp index 341dfb5..e98d173 100644 --- a/lib/base/error.cpp +++ b/lib/base/error.cpp @@ -239,6 +239,7 @@ std::string CCError::get_error_desc(CCErrorCode error_code, bool attach_error_co break; case CCErrorCode::ERROR_APPEARANCE_FONT_TYPE_INVALID_1: case CCErrorCode::ERROR_APPEARANCE_FONT_TYPE_INVALID_2: + case CCErrorCode::ERROR_APPEARANCE_FONT_TYPE_INVALID_3: error_desc = _("Invalid font type."); break; case CCErrorCode::ERROR_APPEARANCE_FONT_TYPE_UNSUPPORTED: @@ -402,6 +403,7 @@ std::string CCError::get_error_desc(CCErrorCode error_code, bool attach_error_co case CCErrorCode::ERROR_DISPLAY_SAVE_CREATE_FILE_FAILED: case CCErrorCode::ERROR_DISPLAY_WRITE_CONF_FILE_FAILED: case CCErrorCode::ERROR_DISPLAY_NO_ENABLED_MONITOR: + case CCErrorCode::ERROR_APPEARANCE_RESET_FONT_FAILED: case CCErrorCode::ERROR_APPEARANCE_SET_BACKGROUND_FAILED: case CCErrorCode::ERROR_APPEARANCE_SET_LOCKSCREEN_BACKGROUND_FAILED: case CCErrorCode::ERROR_SYSTEMINFO_JSON_ASSIGN_FAILED: diff --git a/plugins/appearance/appearance-manager.cpp b/plugins/appearance/appearance-manager.cpp index 4b67205..f1fc6fa 100644 --- a/plugins/appearance/appearance-manager.cpp +++ b/plugins/appearance/appearance-manager.cpp @@ -113,6 +113,20 @@ void AppearanceManager::SetFont(gint32 type, const Glib::ustring& font, MethodIn invocation.ret(); } +void AppearanceManager::ResetFont(gint32 type, MethodInvocation& invocation) +{ + if (type < 0 || type >= int32_t(AppearanceFontType::APPEARANCE_FONT_TYPE_LAST)) + { + DBUS_ERROR_REPLY_AND_RET(CCErrorCode::ERROR_APPEARANCE_FONT_TYPE_INVALID_3); + } + + if (!this->appearance_font_.reset_font(AppearanceFontType(type))) + { + DBUS_ERROR_REPLY_AND_RET(CCErrorCode::ERROR_APPEARANCE_RESET_FONT_FAILED); + } + invocation.ret(); +} + void AppearanceManager::SetDesktopBackground(const Glib::ustring& desktop_background, MethodInvocation& invocation) { if (desktop_background != this->desktop_background_get() && diff --git a/plugins/appearance/appearance-manager.h b/plugins/appearance/appearance-manager.h index 89ed9df..e6c4ab5 100644 --- a/plugins/appearance/appearance-manager.h +++ b/plugins/appearance/appearance-manager.h @@ -48,6 +48,8 @@ protected: virtual void GetFont(gint32 type, MethodInvocation& invocation); // 设置类型为type的字体 virtual void SetFont(gint32 type, const Glib::ustring& font, MethodInvocation& invocation); + // 重置默认字体 + virtual void ResetFont(gint32 type, MethodInvocation& invocation); // 设置桌面背景 virtual void SetDesktopBackground(const Glib::ustring& desktop_background, MethodInvocation& invocation); // 设置锁屏背景 diff --git a/plugins/appearance/com.kylinsec.Kiran.SessionDaemon.Appearance.xml b/plugins/appearance/com.kylinsec.Kiran.SessionDaemon.Appearance.xml index 889ee87..71a67bc 100644 --- a/plugins/appearance/com.kylinsec.Kiran.SessionDaemon.Appearance.xml +++ b/plugins/appearance/com.kylinsec.Kiran.SessionDaemon.Appearance.xml @@ -58,6 +58,13 @@ <description>Set the font for the type.</description> </method> + <method name="ResetFont"> + <arg type="i" name="type" direction="in"> + <summary>The font type that contains application font, document font, desktop font and monospace font, etc.</summary> + </arg> + <description>Reset the font for the type.</description> + </method> + <method name="SetDesktopBackground"> <arg type="s" name="desktop_background" direction="in"> <summary>File path of desktop background.</summary> diff --git a/plugins/appearance/font/appearance-font.cpp b/plugins/appearance/font/appearance-font.cpp index cb169d4..e56d572 100644 --- a/plugins/appearance/font/appearance-font.cpp +++ b/plugins/appearance/font/appearance-font.cpp @@ -129,6 +129,46 @@ bool AppearanceFont::set_font(AppearanceFontType type, const std::string& font) return true; } +bool AppearanceFont::reset_font(AppearanceFontType type) +{ + switch (type) + { + case APPEARANCE_FONT_TYPE_APPLICATION: + { + RETURN_VAL_IF_FALSE(this->xsettings_settings_, false); + this->xsettings_settings_->reset(XSETTINGS_SCHEMA_GTK_FONT_NAME); + break; + } + case APPEARANCE_FONT_TYPE_DOCUMENT: + { + RETURN_VAL_IF_FALSE(this->interface_settings_, false); + this->interface_settings_->reset(INTERFACE_KEY_DOCUMENT_FONT_NAME); + break; + } + case APPEARANCE_FONT_TYPE_DESKTOP: + { + RETURN_VAL_IF_FALSE(this->caja_settings_, false); + this->caja_settings_->reset(CAJA_SCHEMA_KEY_FONT); + break; + } + case APPEARANCE_FONT_TYPE_WINDOW_TITLE: + { + RETURN_VAL_IF_FALSE(this->marco_settings_, false); + this->marco_settings_->reset(MARCO_SCHAME_KEY_TITLEBAR_FONT); + break; + } + case APPEARANCE_FONT_TYPE_MONOSPACE: + { + RETURN_VAL_IF_FALSE(this->interface_settings_, false); + this->interface_settings_->reset(INTERFACE_KEY_MONOSPACE_FONT_NAME); + break; + } + default: + return false; + } + return true; +} + void AppearanceFont::on_font_changed_cb(const Glib::ustring& key) { switch (shash(key.c_str())) diff --git a/plugins/appearance/font/appearance-font.h b/plugins/appearance/font/appearance-font.h index 2d04d96..cbb712d 100644 --- a/plugins/appearance/font/appearance-font.h +++ b/plugins/appearance/font/appearance-font.h @@ -29,6 +29,7 @@ public: std::string get_font(AppearanceFontType type); bool set_font(AppearanceFontType type, const std::string& font); + bool reset_font(AppearanceFontType type); // 字体变化信号 sigc::signal<void, AppearanceFontType, const std::string&> signal_font_changed() { return this->font_changed_; }; -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2