[izpack-changes] r1741 - in izpack-src/branches/3.10: . src/lib/com/izforge/izpack/installer src/lib/com/izforge/izpack/panels src/lib/com/izforge/izpack/util/os
noreply at berlios.de
noreply at berlios.de
Sat Feb 17 14:38:51 CET 2007
Author: jponge
Date: 2007-02-17 14:38:23 +0100 (Sat, 17 Feb 2007)
New Revision: 1741
Modified:
izpack-src/branches/3.10/Versions.txt
izpack-src/branches/3.10/src/lib/com/izforge/izpack/installer/UninstallData.java
izpack-src/branches/3.10/src/lib/com/izforge/izpack/panels/ShortcutPanel.java
izpack-src/branches/3.10/src/lib/com/izforge/izpack/util/os/Unix_Shortcut.java
Log:
FreeDesktop XDG standard support for Gnome and KDE shortcuts support (Vladimir Ralev via Julien Ponge)
Modified: izpack-src/branches/3.10/Versions.txt
===================================================================
--- izpack-src/branches/3.10/Versions.txt 2007-02-16 14:52:39 UTC (rev 1740)
+++ izpack-src/branches/3.10/Versions.txt 2007-02-17 13:38:23 UTC (rev 1741)
@@ -3,9 +3,11 @@
> 3.10.1 (build 2007.xx.xx)
-- Fixed NPE for pack.id == null (Fabrice Mirabile)
-- Packages that are not marked as preselected must
- also be removed from the selectedPacks (Martina Angela Albrecht, via Fabrice Mirabile)
+- Fixed NPE for pack.id == null (Fabrice Mirabile)
+- Packages that are not marked as preselected must also be removed from the selectedPacks
+ (Martina Angela Albrecht, via Fabrice Mirabile)
+- FreeDesktop XDG standard support for Gnome and KDE shortcuts support
+ (Vladimir Ralev via Julien Ponge)
> 3.10.0 (build 2007.01.29)
Modified: izpack-src/branches/3.10/src/lib/com/izforge/izpack/installer/UninstallData.java
===================================================================
--- izpack-src/branches/3.10/src/lib/com/izforge/izpack/installer/UninstallData.java 2007-02-16 14:52:39 UTC (rev 1740)
+++ izpack-src/branches/3.10/src/lib/com/izforge/izpack/installer/UninstallData.java 2007-02-17 13:38:23 UTC (rev 1741)
@@ -87,7 +87,8 @@
*/
public synchronized void addFile(String path)
{
- filesList.add(path);
+ if(path != null)
+ filesList.add(path);
}
/**
Modified: izpack-src/branches/3.10/src/lib/com/izforge/izpack/panels/ShortcutPanel.java
===================================================================
--- izpack-src/branches/3.10/src/lib/com/izforge/izpack/panels/ShortcutPanel.java 2007-02-16 14:52:39 UTC (rev 1740)
+++ izpack-src/branches/3.10/src/lib/com/izforge/izpack/panels/ShortcutPanel.java 2007-02-17 13:38:23 UTC (rev 1741)
@@ -1108,7 +1108,7 @@
*/
return true; // If there is no Condition defined, just create the shortcut.
}
-
+
/*--------------------------------------------------------------------------*/
/**
@@ -1121,6 +1121,28 @@
addToUninstaller();
}
+ private String createGnomeMenu(Vector shortcuts, String menuName)
+ {
+ String menuConfigText = "<Menu>\n" +
+ "<Name>Applications</Name>\n" +
+ "<Menu>\n" +
+ "<Name>" + menuName + "</Name>\n" +
+ "<Include>\n";
+
+ ShortcutData data;
+
+ for (int i = 0; i < shortcuts.size(); i++)
+ {
+ data = (ShortcutData) shortcuts.elementAt(i);
+ menuConfigText += "<Filename>" + data.name + ".desktop</Filename>\n";
+ }
+ menuConfigText += "</Include>\n</Menu>\n</Menu>";
+ return menuConfigText;
+
+ }
+
+ /*--------------------------------------------------------------------------*/
+
/**
* Creates all shortcuts based on the information in shortcuts.
*/
@@ -1134,7 +1156,32 @@
//fix: don't influence other shortcuts when altering group name...
String gn = groupName;
+
+ if(OsVersion.IS_UNIX)
+ {
+ String menuFile = createGnomeMenu(shortcuts, groupName);
+ String menuFolder = System.getProperty("user.home") + File.separator
+ + ".config/menus/applications-merged/";
+ File menuConfigFolder = new File(menuFolder);
+ String menuFilePath = menuFolder + groupName + ".menu";
+ menuConfigFolder.mkdirs();
+ FileWriter menuFileWriter;
+ boolean failed = false;
+ try{
+
+ menuFileWriter = new FileWriter(menuFilePath);
+ menuFileWriter.write(menuFile);
+ menuFileWriter.close();
+ }
+ catch(Exception ignore)
+ {
+ failed = true;
+ Debug.log("Failed to create menu for gnome.");
+ }
+ if(!failed) UninstallData.getInstance().addFile(menuFilePath);
+
+ }
for (int i = 0; i < shortcuts.size(); i++)
{
data = (ShortcutData) shortcuts.elementAt(i);
Modified: izpack-src/branches/3.10/src/lib/com/izforge/izpack/util/os/Unix_Shortcut.java
===================================================================
--- izpack-src/branches/3.10/src/lib/com/izforge/izpack/util/os/Unix_Shortcut.java 2007-02-16 14:52:39 UTC (rev 1740)
+++ izpack-src/branches/3.10/src/lib/com/izforge/izpack/util/os/Unix_Shortcut.java 2007-02-17 13:38:23 UTC (rev 1741)
@@ -65,6 +65,7 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Enumeration;
@@ -109,6 +110,7 @@
/** QM = "\"" : <b>Q</b>uotation<b>M</b>ark */
private final static String QM = "\"";
+ private int ShortcutType;
private static ShellScript rootScript = null;
private static ShellScript uninstallScript = null;
private static ArrayList users = UnixUsers.getUsersWithValidShellsExistingHomesAndDesktops();
@@ -168,7 +170,8 @@
hlp.append("Comment[").append(userLanguage).append("]=" + $Comment + N);
hlp.append("Encoding=" + $Encoding + N);
- hlp.append("TryExec=" + $TryExec + N);
+ // this causes too many problems
+ //hlp.append("TryExec=" + $E_QUOT + $Exec + $E_QUOT + S + $Arguments + N);
hlp.append("Exec=" + $E_QUOT + $Exec + $E_QUOT + S + $Arguments + N);
hlp.append("GenericName=" + $GenericName + N);
@@ -187,6 +190,7 @@
hlp.append("TerminalOptions=" + $Options_For_Terminal + N);
hlp.append("Type=" + $Type + N);
+
hlp.append("URL=" + $URL + N);
hlp.append("X-KDE-SubstituteUID=" + $X_KDE_SubstituteUID + N);
hlp.append("X-KDE-Username=" + $X_KDE_Username + N);
@@ -311,7 +315,7 @@
//
result = getKdeShareApplnkFolder(current_user).toString();
-
+
return result;
}
@@ -325,6 +329,12 @@
*/
private File getKdeShareApplnkFolder(int userType)
{
+ /*
+ //newer XDG system
+ File xdgPath = new File("usr" + File.separator + "share" + File.separator
+ + "applications");
+ if(xdgPath.exists()) return xdgPath;*/
+
File kdeBase = getKdeBase(userType);
File result = new File(kdeBase + File.separator + "share" + File.separator
@@ -421,11 +431,12 @@
boolean rootUser4All = this.getUserType() == Shortcut.ALL_USERS;
boolean create4All = this.getCreateForAll().booleanValue();
-
+
// Create The Desktop Shortcuts
if ("".equals(this.itsGroupName) && (this.getLinkType() == Shortcut.DESKTOP))
{
-
+ //System.out.println("this.itsGroupName: "+this.itsGroupName);
+ //System.out.println("this.getLinkType(): "+this.getLinkType());
target = myHome + FS + "Desktop" + FS + this.itsName
+ DESKTOP_EXT;
this.itsFileName = target;
@@ -546,15 +557,23 @@
// This is - or should be only a Link in the [K?]-Menu
else
{
- File kdeHomeShareApplnk = getKdeShareApplnkFolder(this.getUserType());
- target = kdeHomeShareApplnk.toString() + FS + this.itsGroupName + FS + this.itsName
+ // the following is for backwards compatibility to older versions of KDE!
+ // on newer versions of KDE the icons will appear duplicated unless you set
+ // the category=""
+ Object categoryobject = props.getProperty($Categories);
+ if(categoryobject != null && ((String)categoryobject).length()>0)
+ {
+ File kdeHomeShareApplnk = getKdeShareApplnkFolder(this.getUserType());
+ target = kdeHomeShareApplnk.toString() + FS + this.itsGroupName + FS + this.itsName
+ DESKTOP_EXT;
- this.itsFileName = target;
- writeShortCut(target, shortCutDef);
-
- if (rootUser4All)
+ this.itsFileName = target;
+ File kdemenufile = writeShortCut(target, shortCutDef);
+
+ uninstaller.addFile(kdemenufile.toString());
+ }
+
+ if (rootUser4All && create4All)
{
- if (create4All)
{
// write the icon pixmaps into /usr/share/pixmaps
@@ -581,12 +600,52 @@
uninstaller.addFile(writtenFile.toString());
}
- else
- {
- // do nothing
- }
}
+ else // create local XDG shortcuts
+ {
+ //System.out.println("Creating gnome shortcut");
+ String localApps = myHome + "/.local/share/applications/";
+ String localPixmaps = myHome + "/.local/share/pixmaps/";
+ //System.out.println("Creating "+localApps);
+ try
+ {
+ java.io.File f = new java.io.File(localApps);
+ f.mkdirs();
+
+ f = new java.io.File(localPixmaps);
+ f.mkdirs();
+ }
+ catch (Exception ignore)
+ {
+ //System.out.println("Failed creating "+localApps + " or " + localPixmaps);
+ Debug.log("Failed creating "+localApps + " or " + localPixmaps);
+ }
+
+ // write the icon pixmaps into ~/share/pixmaps
+ File theIcon = new File(this.getIconLocation());
+ File commonIcon = new File(localPixmaps + theIcon.getName());
+
+ try
+ {
+ copyTo(theIcon, commonIcon);
+ uninstaller.addFile(commonIcon.toString());
+ }
+ catch (Exception cnc)
+ {
+ Debug.log("Could Not Copy: " + theIcon + " to " + commonIcon + "( "
+ + cnc.getMessage() + " )");
+ }
+
+ // write *.desktop.file into ~/share/applications
+
+ String commonTarget = localApps + this.itsName + DESKTOP_EXT;
+ this.itsFileName = target;
+ File writtenFile = writeShortCut(commonTarget, shortCutDef);
+
+ uninstaller.addFile(writtenFile.toString());
+ }
+
}
}
@@ -767,8 +826,9 @@
*
* @see com.izforge.izpack.util.os.Shortcut#setLinkType(int)
*/
- public void setLinkType(int aType) throws IllegalArgumentException
+ public void setLinkType(int aType) throws IllegalArgumentException, UnsupportedEncodingException
{
+ ShortcutType = aType;
}
/**
@@ -1026,5 +1086,9 @@
{
props.put($TryExec, aTryExec);
}
-
+ public int getLinkType()
+ {
+ return ShortcutType;
+ //return Shortcut.DESKTOP;
+ }
}
More information about the izpack-changes
mailing list