Rename the unityLauncher api to launcher and make it available on linux in general...
authorJonas Schwabe <jonas@jnugh.de>
Sun, 26 Jun 2016 09:48:58 +0000 (11:48 +0200)
committerJonas Schwabe <jonas@jnugh.de>
Wed, 29 Jun 2016 18:22:17 +0000 (20:22 +0200)
atom/browser/browser_linux.cc
docs/api/app.md
lib/browser/api/app.js

index 668da66..8e41ec8 100644 (file)
@@ -60,8 +60,10 @@ bool Browser::UnityLauncherAvailable() {
 }
 
 void Browser::UnityLauncherSetBadgeCount(int count) {
-  current_badge_count_ = count;
-  unity::SetDownloadCount(count);
+  if (UnityLauncherAvailable()) {
+    current_badge_count_ = count;
+    unity::SetDownloadCount(count);
+  }
 }
 
 int Browser::UnityLauncherGetBadgeCount() {
index 777f315..da14a50 100644 (file)
@@ -647,16 +647,26 @@ Sets the application's [dock menu][dock-menu].
 
 Sets the `image` associated with this dock icon.
 
-### `app.unityLauncher.setBadgeCount(count)` _Ubuntu Unity_
+### `app.launcher.setBadgeCount(count)` _Linux_
 * `count` Integer
 
 Sets the number to be displayed next to the app icon in the unity launcher.
 Setting count to `0` will hide the badge.
 
-### `app.unityLauncher.getBadgeCount(count)` _Ubuntu Unity_
+**Note:** This feature is currently only supported on Ubuntu Unity. Calling this function has no effect, when the application is running in a different environment.
+
+**Note:** you need to specify the .desktop file name to the desktopName field in package.json. By default, it will assume app.getName().desktop in packaged apps.
+
+### `app.launcher.getBadgeCount(count)` _Linux_
 
 Returns the current value displayed in the counter badge next to the launcher icon.
 
+**Note:** As `setBadgeCount` only supports Ubuntu Unity, the value will be 0 when the application is running in a different environment.
+
+### `app.launcher.isCounterBadgeAvailable()` _Linux_
+
+This method checks if the current desktop environment supports an app icon counter badge and returns `true` in this case.
+
 
 [dock-menu]:https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/customizing_docktile/concepts/dockconcepts.html#//apple_ref/doc/uid/TP30000986-CH2-TPXREF103
 [tasks]:http://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#tasks
index 602a7a0..466d2dd 100644 (file)
@@ -45,10 +45,11 @@ if (process.platform === 'darwin') {
   }
 }
 
-if (process.platform === 'linux' && bindings.unityLauncherAvailable()) {
-  app.unityLauncher = {
+if (process.platform === 'linux') {
+  app.launcher = {
     setBadgeCount: bindings.unityLauncherSetBadgeCount,
-    getBadgeCount: bindings.unityLauncherGetBadgeCount
+    getBadgeCount: bindings.unityLauncherGetBadgeCount,
+    isCounterBadgeAvailable: bindings.unityLauncherAvailable
   }
 }