You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2020/02/14 22:19:11 UTC

[GitHub] [netbeans] blackleg opened a new pull request #1948: Simple linux notifications integration module

blackleg opened a new pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948
 
 
   Simple integration to use native linux notification system ([libnotify library](https://developer.gnome.org/libnotify/)).
   
   Based on @emilianbold's [OpenBeans notifications module](https://github.com/OpenBeans/OpenBeans/tree/master/pkgsrc-coolbeans/ide/files/platform/ro.emilianbold.notifications) and [Intellij libnotify wrapper](https://github.com/JetBrains/intellij-community/blob/master/platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] eirikbakke commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-591478703
 
 
   > I have no problem if you prefer to discuss this on the mailing list and wait to continue developing this or not when the mailing list get a decision.
   
   I think the need for an extended discussion occurs primarily when it comes to changing the _default_ behavior. If it's just something that interested users can enable in the Options dialog, then the stakes are much lower, and it also allows improvements to be made gradually without implementing everything at once (MacOS support etc.).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] blackleg commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
blackleg commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-586719534
 
 
   > Should this be discussed first? I.e. not just a PR, but a discussion on the mailing list? GUI changes have the tendency to introduce bikeshedding and in this case the question why implementations for windows/mac OS are not done will come up quickly. I assume this is a base for discussion as the finer parts of the api (action listener, balloon detail, priority) are currently uncovered.
   > 
   @matthiasblaesing @svenreimers @emilianbold  @eirikbakke I have no problem if you prefer to discuss this on the mailing list and wait to continue developing this or not when the mailing list get a decision.  
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] AlexFalappa commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
AlexFalappa commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-586867434
 
 
   From a user point of view it would be great if native notifications would be automatically used when the main window is minimized or not in focus. I don't know if this is feasible or not.
   
   Think of this: launch a lenghty compilation, switch to the browser to look at something, native notification popping up to warn build complete.
   
   I wouldn't mind if a first implementation does not have link clicking support, those notifications usually happen with the main window in focus.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] blackleg commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
blackleg commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379918724
 
 

 ##########
 File path: ide/notifications.linux/src/org/netbeans/modules/notifications/linux/LinuxNotificationDisplayer.java
 ##########
 @@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.notifications.linux;
+
+import com.sun.jna.Native;
+import com.sun.jna.Pointer;
+import java.awt.event.ActionListener;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.Icon;
+import javax.swing.JComponent;
+import org.openide.awt.Notification;
+import org.openide.awt.NotificationDisplayer;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+import org.netbeans.modules.notifications.linux.jna.Libnotify;
+
+/**
+ *
+ * @author Hector Espert
+ */
+@ServiceProvider(service = LinuxNotificationDisplayer.class, position = 50)
+public class LinuxNotificationDisplayer extends NotificationDisplayer {
+
+    private static final Logger LOG = Logger.getLogger(LinuxNotificationDisplayer.class.getName());
+
+    private static final String LIBNOTIFY = "libnotify.so.4";
+
+    private static final String APP_NAME = "netbeans";
+
+    private Optional<Libnotify> optionalLibnotify;
+
+    public LinuxNotificationDisplayer() {
+        try {
+            this.optionalLibnotify = Optional.of(Native.load(LIBNOTIFY, Libnotify.class));
 
 Review comment:
   @svenreimers Is there an example of ModuleInstall that I can use?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] emilianbold commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
emilianbold commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379766582
 
 

 ##########
 File path: ide/notifications.linux/src/org/netbeans/modules/notifications/linux/LinuxNotificationDisplayer.java
 ##########
 @@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.notifications.linux;
+
+import com.sun.jna.Native;
+import com.sun.jna.Pointer;
+import java.awt.event.ActionListener;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.Icon;
+import javax.swing.JComponent;
+import org.openide.awt.Notification;
+import org.openide.awt.NotificationDisplayer;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+import org.netbeans.modules.notifications.linux.jna.Libnotify;
+
+/**
+ *
+ * @author Hector Espert
+ */
+@ServiceProvider(service = LinuxNotificationDisplayer.class, position = 50)
 
 Review comment:
   Shouldn't this be `service = NotificationDisplayer` ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] svenreimers commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
svenreimers commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-586699847
 
 
   Due to the fact that interaction of the notification with the IDE (think click on link) is not possible from the outside, i.e. the os native part of the world, I think the native notifications may be nice but can only be an add on to the in application notification (read Swing based in IDE notification). So what is probably needed from my point of view is the possibility to have some (all?) notifications be sent to the OS notification as well, if desired by the user (with the possibility to link back to the real notification in the IDE if supported by the OS). Sounds like a long shot to get this done right??? I think the hook provided so far is especially useful for notifying inside the IDE (in whatever way), but a notification outside may just be another level e.g. (if native notifying module available forward to this as well, if configured by user).
   
   Comments?
   
   Thanks to @blackleg for kicking this off.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] blackleg commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
blackleg commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-586720005
 
 
   > For the libnotify bindings: Is the native encoding of the java platform the right encoding? Or does it need to be UTF-8 or something like that? By default JNA maps strings to (C) char by using the default platform encoding.
   > 
   @matthiasblaesing I'm not sure at this point but IntelliJ implementation of libnotify binding use the native encoding of the java platform.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] emilianbold commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
emilianbold commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-586671550
 
 
   > On default behavior: Users frequently get annoyed when apps reach "outside their sandbox"--e.g. Acrobat Reader begging to be updated, web pages asking permission to send notifications, Chrome tabs playing audio, or Spotify showing an album cover overlay when you try to adjust volume for a different app. For this reason I think NetBeans notifications should be shown within NetBeans only, at least by default.
   
   Many users like it when an app behaves like the other apps and uses what the OS offers: notification center, keychains, configuration settings, etc.
   
   And I think such OS-level notifications are a good, visual, bullet point to put in some release notes.
   
   > Should this be discussed first? I.e. not just a PR, but a discussion on the mailing list?
   
   I think passing this through dev@ and extensive API review severely decreases the chances of this PR going anywhere.
   
   I will remove myself from this PR and leave you to it.
   
   Good job @blackleg, the module is quite well done!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] emilianbold commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
emilianbold commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379766685
 
 

 ##########
 File path: ide/notifications.linux/src/org/netbeans/modules/notifications/linux/LinuxNotificationDisplayer.java
 ##########
 @@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.notifications.linux;
+
+import com.sun.jna.Native;
+import com.sun.jna.Pointer;
+import java.awt.event.ActionListener;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.Icon;
+import javax.swing.JComponent;
+import org.openide.awt.Notification;
+import org.openide.awt.NotificationDisplayer;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+import org.netbeans.modules.notifications.linux.jna.Libnotify;
+
+/**
+ *
+ * @author Hector Espert
+ */
+@ServiceProvider(service = LinuxNotificationDisplayer.class, position = 50)
+public class LinuxNotificationDisplayer extends NotificationDisplayer {
+
+    private static final Logger LOG = Logger.getLogger(LinuxNotificationDisplayer.class.getName());
+
+    private static final String LIBNOTIFY = "libnotify.so.4";
+
+    private static final String APP_NAME = "netbeans";
+
+    private Optional<Libnotify> optionalLibnotify;
+
+    public LinuxNotificationDisplayer() {
+        try {
+            this.optionalLibnotify = Optional.of(Native.load(LIBNOTIFY, Libnotify.class));
+            LOG.log(Level.FINE, "Libnotify library loaded");
+        } catch (UnsatisfiedLinkError unsatisfiedLinkError) {
+            LOG.log(Level.WARNING, "Libnotify library not found", unsatisfiedLinkError);
+            this.optionalLibnotify = Optional.empty();
+        }
+    }
+
+    public boolean isStarted() {
+        return optionalLibnotify.map(libnotify -> libnotify.notify_is_initted()).orElse(false);
+    }
+
+    public boolean notStarted() {
+        return !isStarted();
+    }
+
+    public void start() {
+        optionalLibnotify.filter(libnotify -> !libnotify.notify_is_initted())
 
 Review comment:
   I am impressed by your mastery of `Optional`. Honestly.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] eirikbakke commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379845028
 
 

 ##########
 File path: ide/notifications.linux/src/org/netbeans/modules/notifications/linux/FallbackNotification.java
 ##########
 @@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.notifications.linux;
+
+import org.openide.awt.Notification;
+
+/**
+ *
+ * @author Hector Espert
+ */
+public class FallbackNotification extends Notification {
 
 Review comment:
   The fallback should probably be the existing notification system, rather than a null implementation.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] svenreimers commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
svenreimers commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379898291
 
 

 ##########
 File path: ide/notifications.linux/src/org/netbeans/modules/notifications/linux/LinuxNotificationDisplayer.java
 ##########
 @@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.notifications.linux;
+
+import com.sun.jna.Native;
+import com.sun.jna.Pointer;
+import java.awt.event.ActionListener;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.Icon;
+import javax.swing.JComponent;
+import org.openide.awt.Notification;
+import org.openide.awt.NotificationDisplayer;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+import org.netbeans.modules.notifications.linux.jna.Libnotify;
+
+/**
+ *
+ * @author Hector Espert
+ */
+@ServiceProvider(service = LinuxNotificationDisplayer.class, position = 50)
+public class LinuxNotificationDisplayer extends NotificationDisplayer {
+
+    private static final Logger LOG = Logger.getLogger(LinuxNotificationDisplayer.class.getName());
+
+    private static final String LIBNOTIFY = "libnotify.so.4";
+
+    private static final String APP_NAME = "netbeans";
+
+    private Optional<Libnotify> optionalLibnotify;
+
+    public LinuxNotificationDisplayer() {
+        try {
+            this.optionalLibnotify = Optional.of(Native.load(LIBNOTIFY, Libnotify.class));
 
 Review comment:
   I know we typically do not use module installer these days, but I think putting the loading of the native library in a module install to let the install fail if the library is not available may be worth a try - with this I can imagine all other if / else / optional  stuff may not be needed anymore.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] neilcsmith-net commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-586720372
 
 
   Not sure how many people here know GObject system that well, and the libnotify docs are a little unforthcoming on ownership rules, but I think the lack of `g_object_unref` mapping might be a sign of a memory leak in this.
   
    > Due to the fact that interaction of the notification with the IDE (think click on link) is not possible from the outside
   
   @svenreimers why not?  eg. libnotify allows for registering a callback function, although I have a feeling there may be a little more integration with GLib required than just passing that to get it working.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] emilianbold commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
emilianbold commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-586613078
 
 
   I will not be the one merging anyhow, I was planning on adding @eirikbakke
   for the review.
   
   Of course, all you said can be discussed, I just gave my input.
   
   I think it is hard to do all OSes at once because people have one OS where
   they need this. Having to require at least 2 involved people means it never
   gets done.
   
   I also don't write code like that and find that sometimes an if and a null
   check is more readable but I did find the style of using Optional so much
   intriguing. Reminded me of nodejs for some reason.
   
   --emi
   
   sâm., 15 feb. 2020, 17:35 Matthias Bläsing <no...@github.com> a
   scris:
   
   > Should this be discussed first? I.e. not just a PR, but a discussion on
   > the mailing list? GUI changes have the tendency to introduce bikeshedding
   > and in this case the question why implementations for windows/mac OS are
   > not done will come up quickly. I assume this is a base for discussion as
   > the finer parts of the api (action listener, balloon detail, priority) are
   > currently uncovered.
   >
   > For the libnotify bindings: Is the native encoding of the java platform
   > the right encoding? Or does it need to be UTF-8 or something like that? By
   > default JNA maps strings to (C) char by using the default platform encoding.
   >
   > Personal comment: For me I don't like the Optional style programming here.
   > Maybe I'm getting old, but simple null checks look much more straight
   > forward and are IMHO more readable.
   >
   > —
   > You are receiving this because you were mentioned.
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/netbeans/pull/1948?email_source=notifications&email_token=AAHSCQWK7U2JPPTPLN6D24DRDADTJA5CNFSM4KVQZNHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL3PF2Y#issuecomment-586609387>,
   > or unsubscribe
   > <https://github.com/notifications/unsubscribe-auth/AAHSCQS5NWIHZ3TE2ZABIHLRDADTJANCNFSM4KVQZNHA>
   > .
   >
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] emilianbold commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
emilianbold commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379768390
 
 

 ##########
 File path: ide/notifications.linux/src/org/netbeans/modules/notifications/linux/LinuxNotificationDisplayer.java
 ##########
 @@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.notifications.linux;
+
+import com.sun.jna.Native;
+import com.sun.jna.Pointer;
+import java.awt.event.ActionListener;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.Icon;
+import javax.swing.JComponent;
+import org.openide.awt.Notification;
+import org.openide.awt.NotificationDisplayer;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+import org.netbeans.modules.notifications.linux.jna.Libnotify;
+
+/**
+ *
+ * @author Hector Espert
+ */
+@ServiceProvider(service = LinuxNotificationDisplayer.class, position = 50)
+public class LinuxNotificationDisplayer extends NotificationDisplayer {
+
+    private static final Logger LOG = Logger.getLogger(LinuxNotificationDisplayer.class.getName());
+
+    private static final String LIBNOTIFY = "libnotify.so.4";
+
+    private static final String APP_NAME = "netbeans";
+
+    private Optional<Libnotify> optionalLibnotify;
+
+    public LinuxNotificationDisplayer() {
+        try {
+            this.optionalLibnotify = Optional.of(Native.load(LIBNOTIFY, Libnotify.class));
+            LOG.log(Level.FINE, "Libnotify library loaded");
+        } catch (UnsatisfiedLinkError unsatisfiedLinkError) {
+            LOG.log(Level.WARNING, "Libnotify library not found", unsatisfiedLinkError);
+            this.optionalLibnotify = Optional.empty();
+        }
+    }
+
+    public boolean isStarted() {
+        return optionalLibnotify.map(libnotify -> libnotify.notify_is_initted()).orElse(false);
+    }
+
+    public boolean notStarted() {
+        return !isStarted();
+    }
+
+    public void start() {
+        optionalLibnotify.filter(libnotify -> !libnotify.notify_is_initted())
+                .ifPresent(libnotify -> {
+                    if (libnotify.notify_init(APP_NAME)) {
+                        LOG.log(Level.FINE, "Libnotify initted");
+                    } else {
+                        LOG.log(Level.WARNING, "Unable to init libnotify");
+                    }
+                });
+    }
+
+    public void stop() {
+        optionalLibnotify.filter(libnotify -> libnotify.notify_is_initted())
+                .ifPresent(libnotify -> {
+                    libnotify.notify_uninit();
+                    LOG.log(Level.FINE, "Libnotify uninit");
+                });
+    }
+
+    @Override
+    public Notification notify(String title, Icon icon, String detailsText, ActionListener detailsAction, Priority priority) {
+        optionalLibnotify.filter(libnotify -> libnotify.notify_is_initted())
+                .ifPresent(libnotify -> {
+                    Pointer notification = libnotify.notify_notification_new(title, detailsText, null);
+                    libnotify.notify_notification_show(notification, null);
+                });
+
+        return getDefaultNotificationDisplayer()
+                .map(diplayer -> diplayer.notify(title, icon, detailsText, detailsAction, priority))
+                .orElseGet(FallbackNotification::new);
+    }
+
+    @Override
+    public Notification notify(String title, Icon icon, JComponent balloonDetails, JComponent popupDetails, Priority priority) {
+        return getDefaultNotificationDisplayer()
+                .map(diplayer -> diplayer.notify(title, icon, balloonDetails, popupDetails, priority))
+                .orElseGet(FallbackNotification::new);
 
 Review comment:
   Using `FallbackNotification` is easy but in practice the notification will not be shown at all, correct?
   
   It would have been nice for the fallback to imply just letting the IDE display the notification using the existing Swing pipeline.
   
   Actually, I wonder if there's a way for the module to just disable itself if some runtime conditions are not met?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-586609387
 
 
   Should this be discussed first? I.e. not just a PR, but a discussion on the mailing list? GUI changes have the tendency to introduce bikeshedding and in this case the question why implementations for windows/mac OS are not done will come up quickly. I assume this is a base for discussion as the finer parts of the api (action listener, balloon detail, priority) are currently uncovered.
   
   For the libnotify bindings: Is the native encoding of the java platform the right encoding? Or does it need to be UTF-8 or something like that? By default JNA maps strings to (C) char by using the default platform encoding.
   
   Personal comment: For me I don't like the Optional style programming here. Maybe I'm getting old, but simple null checks look much more straight forward and are IMHO more readable. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] blackleg commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
blackleg commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379922266
 
 

 ##########
 File path: ide/notifications.linux/src/org/netbeans/modules/notifications/linux/FallbackNotification.java
 ##########
 @@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.notifications.linux;
+
+import org.openide.awt.Notification;
+
+/**
+ *
+ * @author Hector Espert
+ */
+public class FallbackNotification extends Notification {
 
 Review comment:
   Fallback is the existing notification system, `FallbackNotification` was the fallback of the fallback, but I removed this because it creates confusion.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] eirikbakke commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-586621703
 
 
   I don't have a running Linux system to test on, unfortunately.
   
   OS-level notifications should probably not be the default behavior--though it could certainly be an option. And yes, if such an option is added, it would be lovely for it to work on for instance MacOS as well. I think that could be added later, though.
   
   On default behavior: Users frequently get annoyed when apps reach "outside their sandbox"--e.g. Acrobat Reader begging to be updated, web pages asking permission to send notifications, Chrome tabs playing audio, or Spotify showing an album cover overlay when you try to adjust volume for a different app. For this reason I think NetBeans notifications should be shown within NetBeans only, at least by default.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] eirikbakke commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379855436
 
 

 ##########
 File path: ide/notifications.linux/src/org/netbeans/modules/notifications/linux/jna/Libnotify.java
 ##########
 @@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.notifications.linux.jna;
+
+import com.sun.jna.Library;
+import com.sun.jna.Pointer;
+
+/**
+ *
+ * @author Hector Espert
+ */
+public interface Libnotify extends Library {
+    
+    boolean notify_is_initted();
+    
+    boolean notify_init(String app_name);
+    
+    void notify_uninit();
+    
+    Pointer notify_notification_new(String summary, String body, String icon);
+    
+    boolean notify_notification_show(Pointer notification, Pointer error);
 
 Review comment:
   Yep, that's fine.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] eirikbakke commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379844961
 
 

 ##########
 File path: .travis.yml
 ##########
 @@ -261,6 +261,8 @@ matrix:
             #- ant $OPTS -f ide/localhistory test
             - ant $OPTS -f ide/lsp.client test
             - ant $OPTS -f ide/notifications test
+            #- ant $OPTS -f ide/notifications.linux test
+            - ant -Dcluster.config=minimal -Djavac.compilerargs=-nowarn -Dbuild.compiler.deprecation=false -Dtest-unit-sys-prop.ignore.random.failures=true -f ide/notifications.linux test
 
 Review comment:
   Was there already some notifications.linux module in the NetBeans repo at some point? Where did the commented-out reference to this module come from?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] svenreimers commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
svenreimers commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379898399
 
 

 ##########
 File path: ide/notifications.linux/src/org/netbeans/modules/notifications/linux/LinuxNotificationDisplayer.java
 ##########
 @@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.notifications.linux;
+
+import com.sun.jna.Native;
+import com.sun.jna.Pointer;
+import java.awt.event.ActionListener;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.Icon;
+import javax.swing.JComponent;
+import org.openide.awt.Notification;
+import org.openide.awt.NotificationDisplayer;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+import org.netbeans.modules.notifications.linux.jna.Libnotify;
+
+/**
+ *
+ * @author Hector Espert
+ */
+@ServiceProvider(service = LinuxNotificationDisplayer.class, position = 50)
+public class LinuxNotificationDisplayer extends NotificationDisplayer {
+
+    private static final Logger LOG = Logger.getLogger(LinuxNotificationDisplayer.class.getName());
+
+    private static final String LIBNOTIFY = "libnotify.so.4";
+
+    private static final String APP_NAME = "netbeans";
+
+    private Optional<Libnotify> optionalLibnotify;
+
+    public LinuxNotificationDisplayer() {
+        try {
+            this.optionalLibnotify = Optional.of(Native.load(LIBNOTIFY, Libnotify.class));
+            LOG.log(Level.FINE, "Libnotify library loaded");
+        } catch (UnsatisfiedLinkError unsatisfiedLinkError) {
+            LOG.log(Level.WARNING, "Libnotify library not found", unsatisfiedLinkError);
+            this.optionalLibnotify = Optional.empty();
+        }
+    }
+
+    public boolean isStarted() {
+        return optionalLibnotify.map(libnotify -> libnotify.notify_is_initted()).orElse(false);
+    }
+
+    public boolean notStarted() {
+        return !isStarted();
+    }
+
+    public void start() {
+        optionalLibnotify.filter(libnotify -> !libnotify.notify_is_initted())
+                .ifPresent(libnotify -> {
+                    if (libnotify.notify_init(APP_NAME)) {
+                        LOG.log(Level.FINE, "Libnotify initted");
+                    } else {
+                        LOG.log(Level.WARNING, "Unable to init libnotify");
+                    }
+                });
+    }
+
+    public void stop() {
+        optionalLibnotify.filter(libnotify -> libnotify.notify_is_initted())
+                .ifPresent(libnotify -> {
+                    libnotify.notify_uninit();
+                    LOG.log(Level.FINE, "Libnotify uninit");
+                });
+    }
+
+    @Override
+    public Notification notify(String title, Icon icon, String detailsText, ActionListener detailsAction, Priority priority) {
+        optionalLibnotify.filter(libnotify -> libnotify.notify_is_initted())
+                .ifPresent(libnotify -> {
+                    Pointer notification = libnotify.notify_notification_new(title, detailsText, null);
+                    libnotify.notify_notification_show(notification, null);
+                });
+
+        return getDefaultNotificationDisplayer()
+                .map(diplayer -> diplayer.notify(title, icon, detailsText, detailsAction, priority))
+                .orElseGet(FallbackNotification::new);
+    }
+
+    @Override
+    public Notification notify(String title, Icon icon, JComponent balloonDetails, JComponent popupDetails, Priority priority) {
+        return getDefaultNotificationDisplayer()
+                .map(diplayer -> diplayer.notify(title, icon, balloonDetails, popupDetails, priority))
+                .orElseGet(FallbackNotification::new);
 
 Review comment:
   Maybe using module install (see above)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] blackleg commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
blackleg commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379921717
 
 

 ##########
 File path: ide/notifications.linux/src/org/netbeans/modules/notifications/linux/LinuxNotificationDisplayer.java
 ##########
 @@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.notifications.linux;
+
+import com.sun.jna.Native;
+import com.sun.jna.Pointer;
+import java.awt.event.ActionListener;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.Icon;
+import javax.swing.JComponent;
+import org.openide.awt.Notification;
+import org.openide.awt.NotificationDisplayer;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+import org.netbeans.modules.notifications.linux.jna.Libnotify;
+
+/**
+ *
+ * @author Hector Espert
+ */
+@ServiceProvider(service = LinuxNotificationDisplayer.class, position = 50)
+public class LinuxNotificationDisplayer extends NotificationDisplayer {
+
+    private static final Logger LOG = Logger.getLogger(LinuxNotificationDisplayer.class.getName());
+
+    private static final String LIBNOTIFY = "libnotify.so.4";
+
+    private static final String APP_NAME = "netbeans";
+
+    private Optional<Libnotify> optionalLibnotify;
+
+    public LinuxNotificationDisplayer() {
+        try {
+            this.optionalLibnotify = Optional.of(Native.load(LIBNOTIFY, Libnotify.class));
+            LOG.log(Level.FINE, "Libnotify library loaded");
+        } catch (UnsatisfiedLinkError unsatisfiedLinkError) {
+            LOG.log(Level.WARNING, "Libnotify library not found", unsatisfiedLinkError);
+            this.optionalLibnotify = Optional.empty();
+        }
+    }
+
+    public boolean isStarted() {
+        return optionalLibnotify.map(libnotify -> libnotify.notify_is_initted()).orElse(false);
+    }
+
+    public boolean notStarted() {
+        return !isStarted();
+    }
+
+    public void start() {
+        optionalLibnotify.filter(libnotify -> !libnotify.notify_is_initted())
+                .ifPresent(libnotify -> {
+                    if (libnotify.notify_init(APP_NAME)) {
+                        LOG.log(Level.FINE, "Libnotify initted");
+                    } else {
+                        LOG.log(Level.WARNING, "Unable to init libnotify");
+                    }
+                });
+    }
+
+    public void stop() {
+        optionalLibnotify.filter(libnotify -> libnotify.notify_is_initted())
+                .ifPresent(libnotify -> {
+                    libnotify.notify_uninit();
+                    LOG.log(Level.FINE, "Libnotify uninit");
+                });
+    }
+
+    @Override
+    public Notification notify(String title, Icon icon, String detailsText, ActionListener detailsAction, Priority priority) {
+        optionalLibnotify.filter(libnotify -> libnotify.notify_is_initted())
+                .ifPresent(libnotify -> {
+                    Pointer notification = libnotify.notify_notification_new(title, detailsText, null);
+                    libnotify.notify_notification_show(notification, null);
+                });
+
+        return getDefaultNotificationDisplayer()
+                .map(diplayer -> diplayer.notify(title, icon, detailsText, detailsAction, priority))
+                .orElseGet(FallbackNotification::new);
+    }
+
+    @Override
+    public Notification notify(String title, Icon icon, JComponent balloonDetails, JComponent popupDetails, Priority priority) {
+        return getDefaultNotificationDisplayer()
+                .map(diplayer -> diplayer.notify(title, icon, balloonDetails, popupDetails, priority))
+                .orElseGet(FallbackNotification::new);
 
 Review comment:
   I tried to do it using a ModuleInstall, but I couldn't.  
   Instead I'm using a [OnStart](http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/OnStart.html)/[OnStop](http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/OnStop.html) classes to do a similar behavior, but module can't disable itself.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] blackleg closed pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
blackleg closed pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] emilianbold commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
emilianbold commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379768636
 
 

 ##########
 File path: ide/notifications.linux/manifest.mf
 ##########
 @@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+OpenIDE-Module: org.netbeans.modules.notifications.linux
+OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/notifications/linux/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+OpenIDE-Module-Requires: org.openide.modules.os.Linux
 
 Review comment:
   Good, only activates on Linux.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] eirikbakke commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379845263
 
 

 ##########
 File path: ide/notifications.linux/src/org/netbeans/modules/notifications/linux/jna/Libnotify.java
 ##########
 @@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.notifications.linux.jna;
+
+import com.sun.jna.Library;
+import com.sun.jna.Pointer;
+
+/**
+ *
+ * @author Hector Espert
+ */
+public interface Libnotify extends Library {
+    
+    boolean notify_is_initted();
+    
+    boolean notify_init(String app_name);
+    
+    void notify_uninit();
+    
+    Pointer notify_notification_new(String summary, String body, String icon);
+    
+    boolean notify_notification_show(Pointer notification, Pointer error);
 
 Review comment:
   These method names do not follow the Java naming conventions--I take it this is because they need to match names in native libraries?
   
   (As long as the class does not get exposed outside of this module, that's fine. I assume it's just a ServiceProvider module.)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] neilcsmith-net commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-591542817
 
 
   Well, -1 from me until the memory handling question above is answered.  Test files definitely show expected use of `g_object_unref` - eg. https://github.com/GNOME/libnotify/blob/mainline/tests/test-basic.c

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-586690205
 
 
   @emilianbold I did not reject it, I raised potential problems. As it is only an incomplete implementation of the `NotificationDisplayer` api we need to address what happens when features outside the supported range are requested, how adapters could be implemented and how the feature should be exposed to the user. I don't see as unreasonable to point that out. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] blackleg commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
blackleg commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-586572668
 
 
   @emilianbold  I updated my first comment in this pull request to add two screenshots to show how this integration looks. 
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379845832
 
 

 ##########
 File path: ide/notifications.linux/src/org/netbeans/modules/notifications/linux/jna/Libnotify.java
 ##########
 @@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.notifications.linux.jna;
+
+import com.sun.jna.Library;
+import com.sun.jna.Pointer;
+
+/**
+ *
+ * @author Hector Espert
+ */
+public interface Libnotify extends Library {
+    
+    boolean notify_is_initted();
+    
+    boolean notify_init(String app_name);
+    
+    void notify_uninit();
+    
+    Pointer notify_notification_new(String summary, String body, String icon);
+    
+    boolean notify_notification_show(Pointer notification, Pointer error);
 
 Review comment:
   These are JNA library bindings. If you don't want to provide a function name mapper JNA requires the java method name to match the native method name.
   The whole jna-platform (bindings for several default libraries on various osses) is bound that way. While other styles might be more in line with the java naming conventions, keeping the native name helps finding documentation, so I strongly suggest to keep the binding like this.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] blackleg commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
blackleg commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379920138
 
 

 ##########
 File path: .travis.yml
 ##########
 @@ -261,6 +261,8 @@ matrix:
             #- ant $OPTS -f ide/localhistory test
             - ant $OPTS -f ide/lsp.client test
             - ant $OPTS -f ide/notifications test
+            #- ant $OPTS -f ide/notifications.linux test
+            - ant -Dcluster.config=minimal -Djavac.compilerargs=-nowarn -Dbuild.compiler.deprecation=false -Dtest-unit-sys-prop.ignore.random.failures=true -f ide/notifications.linux test
 
 Review comment:
   > Was there already some notifications.linux module in the NetBeans repo at some point? 
   > Where did the commented-out reference to this module come from?
   No, it is only commented for debug propurses.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] blackleg commented on issue #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
blackleg commented on issue #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#issuecomment-591639707
 
 
   I'm going to close this pull request. I will change the approach because IMHO implement this require a lot of modifications in the current implementation of notifications module.
   
   To compensate this, there are two pull requests to improve testing for the notifications system.
   
   [Add tests in notifications module](https://github.com/apache/netbeans/pull/1979)
   [Test SimpleNotificationDisplayer implementation](https://github.com/apache/netbeans/pull/1953)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] blackleg commented on a change in pull request #1948: Simple linux notifications integration module

Posted by GitBox <gi...@apache.org>.
blackleg commented on a change in pull request #1948: Simple linux notifications integration module
URL: https://github.com/apache/netbeans/pull/1948#discussion_r379920138
 
 

 ##########
 File path: .travis.yml
 ##########
 @@ -261,6 +261,8 @@ matrix:
             #- ant $OPTS -f ide/localhistory test
             - ant $OPTS -f ide/lsp.client test
             - ant $OPTS -f ide/notifications test
+            #- ant $OPTS -f ide/notifications.linux test
+            - ant -Dcluster.config=minimal -Djavac.compilerargs=-nowarn -Dbuild.compiler.deprecation=false -Dtest-unit-sys-prop.ignore.random.failures=true -f ide/notifications.linux test
 
 Review comment:
   > Was there already some notifications.linux module in the NetBeans repo at some point? 
   > Where did the commented-out reference to this module come from?
   
   No, it is only commented for debug propurses.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists