From 61c2ae5e954b82dac23b16ec6770e009d8e6f237 Mon Sep 17 00:00:00 2001 From: wangxiaoqing Date: Tue, 16 Jun 2020 17:27:55 +0800 Subject: [PATCH] fix(mate-display): add the window scale changed tip with notify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 当窗口缩放发生改变时, 通过notify显示有些应用需要注销再登录才能起作用的提示。 Fixes #25310 --- plugins/xsettings/msd-xsettings-manager.c | 38 +++++++++++++++++++++++++++++++ po/zh_CN.po | 6 +++++ 2 files changed, 44 insertions(+) diff --git a/plugins/xsettings/msd-xsettings-manager.c b/plugins/xsettings/msd-xsettings-manager.c index b31288d..17d5b88 100644 --- a/plugins/xsettings/msd-xsettings-manager.c +++ b/plugins/xsettings/msd-xsettings-manager.c @@ -39,6 +39,10 @@ #include #include +#ifdef HAVE_LIBNOTIFY +#include +#endif + #include "mate-settings-profile.h" #include "msd-xsettings-manager.h" #include "xsettings-manager.h" @@ -518,6 +522,38 @@ delayed_toggle_bg_draw (gboolean value) } static void +info_message (const char *primary_text, const char *secondary_text) +{ +#ifdef HAVE_LIBNOTIFY + NotifyNotification *notification; + + notification = notify_notification_new (primary_text, + secondary_text, + "msd-xrandr"); + + notify_notification_show (notification, NULL); /* NULL-GError */ +#else + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, + "%s", primary_text); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", + secondary_text); + + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); +#endif /* HAVE_LIBNOTIFY */ +} + +static gboolean +delayed_show_info_msg (gboolean value) +{ + info_message (_("Window zooming"), _("Window zooming has changed,\nsome applications need to logout and login again to work!")); + + return FALSE; +} + +static void scale_change_workarounds (MateXSettingsManager *manager, int new_scale) { if (manager->priv->window_scale == new_scale) @@ -578,6 +614,8 @@ scale_change_workarounds (MateXSettingsManager *manager, int new_scale) g_timeout_add_seconds (1, (GSourceFunc) delayed_toggle_bg_draw, (gpointer) FALSE); g_timeout_add_seconds (2, (GSourceFunc) delayed_toggle_bg_draw, (gpointer) TRUE); } + + g_timeout_add_seconds (2, (GSourceFunc) delayed_show_info_msg, (gpointer) TRUE); } /* Store new scale value */ diff --git a/po/zh_CN.po b/po/zh_CN.po index 88573d4..e581552 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -1358,3 +1358,9 @@ msgstr "配置硬件时钟" #: ../plugins/datetime/org.mate.settingsdaemon.datetimemechanism.policy.in.h:6 msgid "Privileges are required to configure the hardware clock." msgstr "配置硬件时钟需要权限" + +msgid "Window zooming" +msgstr "窗口缩放" + +msgid "Window zooming has changed,\nsome applications need to logout and login again to work!" +msgstr "窗口缩放已经改变,\n有些应用需要注销再登录才能起作用!" -- 1.8.3.1