Re: Notifications not showing, when applet is disabled



On 2014-10-20 23:35, Dan Williams wrote:
On Sat, 2014-10-18 at 17:43 +0200, Hendrik Rosendahl wrote:
Hi everyone,

I noticed, that no notification is displayed, if the applet is
disabled
by the gsettings.

How to reproduce:

 1. Start nm-applet, if it isn't already
 2. Make sure, that you get a notification, when interacting with
    NetworkManager (e.g. connecting to a network)
 3. Execute gsettings set org.gnome.nm-applet show-applet 'false'
 4. Interact with NetworkManager (e.g. through nmtui) to repeat the
    steps in 1.
 5. Notice, that there is no notification shown

What I expected:
As the option only says "show-applet", we should still see the
notifications.

Solution?
I had a look at the source and with this diff I could produce the
expected behavior:

diff --git a/src/applet.c b/src/applet.c
index 81e2ac5..7d411c7 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -884,9 +884,6 @@ applet_do_notify (NMApplet *applet,
        g_return_if_fail (summary != NULL);
        g_return_if_fail (message != NULL);
 
-       if (!gtk_status_icon_is_embedded (applet->status_icon))
-               return;
-
        /* if we're not acting as a secret agent, don't notify either
*/
        if (!applet->agent)
                return;

It is running on my system right now, but I don't know if this breaks
anything else.
The originating commit b74deac92d8192591ddbb62f2e2b1b7101a5e95d
doesn't
say why the notification shouldn't be shown, if the applet isn't
visible. But in my opinion it doesn't make sense to not show the
notification, only because the applet isn't shown. Additionally we now
have the gsettings to control what should be shown, which wasn't the
case when this commit was made, as far as I can tell.

Please excuse any formal mistakes I made, as it is my first time using
a
mailing list.
Thanks for the report and investigation.  I believe the original intent
was that when nm-applet wasn't being shown it shouldn't provide any user
interaction other than it's secret agent, because if it's not being
shown, whatever other UI *is* shown should be providing those
notifications.  I'm not sure we ever thought about running the applet
hidden, but only providing notifications.

If that's useful to you, I'd be happy to take a patch that adds a new
GSetting called "notify-when-hidden" that turns the notifications back
on in this case.  Would you be able to work on a patch for that?

Dan



Hey, here is my first attempt.

From 49c5bc4cc3f21c7d9455188b55c913ca7e2992d1 Mon Sep 17 00:00:00 2001
From: Hendrik Rosendahl <hendrik rosendahl rwth-aachen de>
Date: Tue, 21 Oct 2014 12:00:02 +0200
Subject: [PATCH] Add GSetting "notify-when-hidden"

If this setting is set to true notifications are shown, even if the applet is hidden.
The default value is "false", as this is the current behavior.
---
 org.gnome.nm-applet.gschema.xml.in | 5 +++++
 src/applet.c                       | 2 +-
 src/applet.h                       | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/org.gnome.nm-applet.gschema.xml.in b/org.gnome.nm-applet.gschema.xml.in
index bf3b9f4..2c6e756 100644
--- a/org.gnome.nm-applet.gschema.xml.in
+++ b/org.gnome.nm-applet.gschema.xml.in
@@ -36,6 +36,11 @@
       <_summary>Show the applet in notification area</_summary>
       <_description>Set to FALSE to disable displaying the applet in the notification area.</_description>
     </key>
+    <key name="notify-when-hidden" type="b">
+      <default>false</default>
+      <_summary>Notify when hidden</_summary>
+      <_description>Set to true to receive notifications even if the applet itself is hidden.</_description>
+    </key>
   </schema>
   <schema id="org.gnome.nm-applet.eap">
     <key name="ignore-ca-cert" type="b">
diff --git a/src/applet.c b/src/applet.c
index 81e2ac5..7750226 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -884,7 +884,7 @@ applet_do_notify (NMApplet *applet,
     g_return_if_fail (summary != NULL);
     g_return_if_fail (message != NULL);
 
-    if (!gtk_status_icon_is_embedded (applet->status_icon))
+    if (!g_settings_get_boolean (applet->gsettings, PREF_NOTIFY_WHEN_HIDDEN) && !gtk_status_icon_is_embedded (applet->status_icon))
         return;
 
     /* if we're not acting as a secret agent, don't notify either */
diff --git a/src/applet.h b/src/applet.h
index cd5ac97..960b0b2 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -69,6 +69,7 @@ typedef struct
 #define PREF_DISABLE_WIFI_CREATE                  "disable-wifi-create"
 #define PREF_SUPPRESS_WIFI_NETWORKS_AVAILABLE     "suppress-wireless-networks-available"
 #define PREF_SHOW_APPLET                          "show-applet"
+#define PREF_NOTIFY_WHEN_HIDDEN                   "notify-when-hidden"
 
 #define ICON_LAYER_LINK 0
 #define ICON_LAYER_VPN 1
--
2.1.2


I am not quite sure, if !gtk_status_icon_is_embedded (applet->status_icon) should or could be replaced with the GSetting show-applet or not.

Hendrik

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]