fixed opening of new nautilus window
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 27 Nov 2014 12:18:24 +0000 (14:18 +0200)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 27 Nov 2014 12:18:24 +0000 (14:18 +0200)
src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java

index a10dabe..f66f952 100755 (executable)
@@ -42,8 +42,9 @@ public class MultiLevelMenu implements MenuListener {
        public boolean addMenu(final File directory) {
                final int newMenuHorizontalIndex = menus.size();
 
-               if (newMenuHorizontalIndex >= VERTICAL_MENUS_COUNT)
+               if (newMenuHorizontalIndex >= VERTICAL_MENUS_COUNT) {
                        return false;
+               }
 
                final Menu menu = new Menu(directory);
                menu.addMenuListener(this);
@@ -85,8 +86,9 @@ public class MultiLevelMenu implements MenuListener {
        public int getMenuIndex(final Menu menu) {
                int i = 0;
                for (final Menu m : menus) {
-                       if (m == menu)
+                       if (m == menu) {
                                return i;
+                       }
                        i++;
                }
                return -1;
@@ -111,17 +113,19 @@ public class MultiLevelMenu implements MenuListener {
 
        @Override
        public void menuItemSelected(final Menu menu, final File chosenFile) {
-               if (chosenFile.isFile())
-                       if (chosenFile.canExecute())
+               if (chosenFile.isFile()) {
+                       if (chosenFile.canExecute()) {
                                executeCommand(chosenFile.getAbsolutePath());
-                       else {
+                       else {
                                final boolean fileOpened = FileAssociationManager.openFile(chosenFile);
-                               if (fileOpened)
+                               if (fileOpened) {
                                        InstantLauncher.exitProgram();
+                               }
                        }
+               }
 
                if (chosenFile.isDirectory()) {
-                       executeCommand("nautilus", "-n", chosenFile.getAbsolutePath());
+                       executeCommand("nautilus", "-w", chosenFile.getAbsolutePath());
                }
        }
 
@@ -137,9 +141,9 @@ public class MultiLevelMenu implements MenuListener {
 
        @Override
        public void menuItemSelectedAlternative(final Menu menu, final File chosenFile) {
-               if (chosenFile.isFile())
+               if (chosenFile.isFile()) {
                        chosenFile.setExecutable(!chosenFile.canExecute());
-               else {
+               else {
                        executeCommand("gnome-terminal", "--working-directory=" + chosenFile.getAbsolutePath());
                }
        }
@@ -151,8 +155,9 @@ public class MultiLevelMenu implements MenuListener {
                        jPanel.removeAll();
                }
 
-               while (menus.size() > fromIndex)
+               while (menus.size() > fromIndex) {
                        menus.remove(fromIndex);
+               }
        }
 
        @Override