[PC-BSD Commits] r4254 - pbibuild/pbi-source/PBIsource
svn at pcbsd.org
svn at pcbsd.org
Mon Jul 20 13:08:30 PDT 2009
Author: kris
Date: 2009-07-20 13:08:30 -0700 (Mon, 20 Jul 2009)
New Revision: 4254
Modified:
pbibuild/pbi-source/PBIsource/pbi.cpp
pbibuild/pbi-source/PBIsource/pbi.h
Log:
A very LARGE update to the PBI installer:
* Switched us to using xdg-desktop-menu, xdg-mime, etc for our
icon creation / management
* Fixed bugs with KDE 4.3 warnings on desktop shortcuts
* Fixed support for installing mime icons
* Cleaned up obsolete code
Still needs some testing and graphical UI refinement, but seems to be functional.
Also needs to be ported to PBItext.
Modified: pbibuild/pbi-source/PBIsource/pbi.cpp
===================================================================
--- pbibuild/pbi-source/PBIsource/pbi.cpp 2009-07-17 21:55:00 UTC (rev 4253)
+++ pbibuild/pbi-source/PBIsource/pbi.cpp 2009-07-20 20:08:30 UTC (rev 4254)
@@ -35,10 +35,6 @@
// Lets the app know if the file-extraction has begun
ExtractStarted = 0;
- // Set our flag that we have not created any Mime files yet
- createdMimeFiles = 0;
-
-
gridLayout->setMargin(0);
gridLayout->setSpacing(0);
gridLayout_2->setMargin(0);
@@ -88,6 +84,8 @@
ChecksumPassed = 1;
startChecksumTest();
+ IconScript << "#!/bin/sh" << "# Script which installs xdg data";
+
}
@@ -322,7 +320,6 @@
}
-
if ( line.indexOf("MimeExt:") == 0)
{
j++;
@@ -698,9 +695,6 @@
// Start creating the Icons now
CreateIconsSlot(i);
-
-
-
i++;
}
@@ -710,34 +704,89 @@
runCommand("kdialog --passivepopup \"" + ProgramName + " menu entry created in " + pathLoc + "\" 10 &");
}
+ // Install the XDG data
+ doDesktopInstallScript();
+
+ // Check if there is a custom script to be run
+ CheckScriptSlot();
+
- // Check if we need to create any mime icons
- if ( ! MimeExt[0].isEmpty() )
+
+}
+
+void PBI::doDesktopInstallScript()
+{
+ // Make sure our .sbin directory exists
+ QString binDir = "/Programs/" + ProgDirName + "/.sbin";
+ QString tmp;
+ QDir bindir;
+ bindir.mkpath ( binDir );
+
+ // Write the install script
+ //////////////////////////////////////////////////
+ tmp = binDir + "/install-xdg-icons.sh";
+ QFile file( tmp );
+ if(!file.open( QIODevice::WriteOnly))
{
- workingMime = 0;
- createdMimeFiles=1;
- CreateMimeSlot(0);
- } else {
- // Check if there is a custom script to be run
- CheckScriptSlot();
+ QMessageBox::information( this, tr("Error!"), "Failed to open " + tmp + " for writing!" );
+ return;
}
+ QTextStream stream( &file );
-
+ // Read through the install script list, and write it now
+ for (int i = 0; i < IconScript.size(); ++i) {
+ stream << IconScript.at(i) + "\n";
+ }
+ file.close();
+ // Chmod 755 on this script
+ system("chmod 755 " + tmp.toLatin1() );
-}
+ // Now run the install script
+ system( tmp.toLatin1() );
+ // Write the uninstall script
+ //////////////////////////////////////////////////
+ tmp = binDir + "/uninstall-xdg-icons.sh";
+ QFile unfile( tmp );
+ if(!unfile.open( QIODevice::WriteOnly))
+ {
+ QMessageBox::information( this, tr("Error!"), "Failed to open " + tmp + " for writing!" );
+ return;
+ }
+ QTextStream unstream( &unfile );
+ // Read through the install script list, and write it now
+ for (int i = 0; i < IconUnScript.size(); ++i) {
+ unstream << IconUnScript.at(i) + "\n";
+ }
+ unfile.close();
+ // Chmod 755 on this script
+ system("chmod 755 " + tmp.toLatin1() );
+}
+
void PBI::CreateIconsSlot( int exenum )
{
QString ExeTemp = ExePath[exenum];
QString tmp;
- //StatusLabel->setText("Creating Icons...");
-
- // Get the binary name
QString Binary;
+ QString Icon;
+ QString MainIcon;
+ //StatusLabel->setText("Creating Icons...");
+
+
+ // Define our kmenu / desktop file directories
+ QString DesktopDir = "/Programs/" + ProgDirName + "/.desktop-icons";
+ QString MenuDir = "/Programs/" + ProgDirName + "/.kmenu-icons";
+ QDir deskdir;
+ deskdir.mkpath ( DesktopDir );
+ deskdir.mkpath ( MenuDir );
+
+
+ // Get the binary name / info
+ ///////////////////////////////////////////////////////////////
if ( ExeWebLink[exenum] == "1" )
{
Binary.setNum(exenum);
@@ -745,7 +794,7 @@
} else {
// Remove a trailing /
- if ( ExeTemp.lastIndexOf("/" ) != -1 )
+ if ( ExeTemp.lastIndexOf("/") != -1 )
{
Binary = ExeTemp.remove(0, ExeTemp.lastIndexOf("/") );
} else {
@@ -759,11 +808,12 @@
Binary = tmp.remove(0,1);
}
}
-
- // Get the right icon
- QString Icon;
- QString MainIcon;
-
+ ///////////////////////////////////////////////////////////////
+
+
+
+ // Get the right icon
+ ///////////////////////////////////////////////////////////////
MainIcon = "/Programs/" + ProgDirName + "/" + DefaultIcon;
if ( ExeIcon[exenum].isEmpty() && DefaultIcon.isEmpty() )
@@ -774,349 +824,342 @@
} else {
Icon = "/Programs/" + ProgDirName + "/" + ExeIcon[exenum];
}
+ ///////////////////////////////////////////////////////////////
+ // Make our PATH links for this binary
+ ///////////////////////////////////////////////////////////////
+ QDir bindir;
+ bindir.mkpath ( "/Programs/bin");
+ runCommand("ln -fs /Programs/" + ProgDirName + "/.sbin/" + Binary \
+ + " /Programs/bin/" + Binary+ " >/dev/null 2>/dev/null");
+ ///////////////////////////////////////////////////////////////
- if(LaunchCheckBox->isChecked() && NoMenu[exenum] == "0" )
+
+
+ // Menu Icon Creation
+ ///////////////////////////////////////////////////////////////
+ tmp = MenuDir + "/PBI-" + ProgDirName + "-" + Binary + ".desktop";
+ QFile file( tmp );
+ if(!file.open( QIODevice::WriteOnly))
{
- tmp = "/usr/local/share/applications/kde/PBI-" + ProgramName + "-" + Binary + ".desktop";
- QFile file( tmp );
- if(!file.open( QIODevice::WriteOnly))
+ QMessageBox::information( this, tr("Error!"), "Failed to open " + tmp + " for writing!" );
+ return;
+ }
+
+ QTextStream stream( &file );
+
+
+ stream << "[Desktop Entry]\n";
+ stream << "Value=1.0\n";
+ stream << "Type=Application\n";
+
+ if( NoMenu[exenum] != "0" )
+ {
+ stream << "Hidden=true\n";
+ }
+
+ // Regular Program Application
+ if ( ExeLink[exenum] == "0" && ExeWebLink[exenum] == "0" ) {
+ stream << "Name=" + Binary + "\n";
+ stream << "GenericName=" + ExeDescr[exenum] + "\n";
+ stream << "Exec=/Programs/bin/" + Binary + "\n";
+ } else {
+ // We are working on a link of some type
+ QString link;
+ if ( ExeWebLink[exenum] == "1" )
{
- QMessageBox::information( this, tr("Error!"), "Failed to open " + tmp + " for writing!" );
- return;
- }
- QTextStream stream( &file );
+ link = ExePath[exenum];
+ } else {
+ link = "/Programs/" + ProgDirName + "/" +ExePath[exenum];
+ }
+ stream << "Name=" + ExeDescr[exenum] + "\n";
+ stream << "GenericName=" + ExeDescr[exenum] + "\n";
+ stream << "Exec=kfmclient exec '" << link << "'\n";
+ }
- // Regular Program Application
- if ( ExeLink[exenum] == "0" && ExeWebLink[exenum] == "0" && ExeLink[exenum] == "0" ) {
-
- QDir bindir;
- bindir.mkpath ( "/Programs/bin");
- runCommand("ln -fs /Programs/" + ProgDirName + "/.sbin/" + Binary + " /Programs/bin/" + Binary+ " >/dev/null 2>/dev/null");
+ stream << "Path=/Programs/" + ProgDirName + "/\n";
+ stream << "Icon=" + Icon + "\n";
- stream << "[Desktop Entry]\n";
- stream << "GenericName=" + ExeDescr[exenum] + "\n";
- stream << "Name=" + Binary + "\n";
- //stream << "Exec=/Programs/" + ProgDirName + "/.sbin/" + Binary + "\n";
- stream << "Exec=/Programs/bin/" + Binary + "\n";
- stream << "Type=Application\n";
- stream << "Path=/Programs/" + ProgDirName + "/\n";
- stream << "Icon=" + Icon + "\n";
+ // Check if we have any mime types for this binary
+ if ( ! MimeExt[exenum].isEmpty() )
+ {
+ stream << "MimeType=application/x-" + Binary + "\n";
- } else {
+ QString mimetmp = MenuDir + "/PBI-" + ProgDirName + "-" + Binary + ".xml";
+ QFile mimefile( mimetmp );
+ if(!mimefile.open( QIODevice::WriteOnly))
+ {
+ QMessageBox::information( this, tr("Error!"), "Failed to open " + mimetmp + " for writing!" );
+ return;
+ }
- QString link;
-
- if ( ExeWebLink[exenum] == "1" )
- {
- link = ExePath[exenum];
- } else {
- link = "/Programs/" + ProgDirName + "/" +ExePath[exenum];
- }
-
- stream << "[Desktop Entry]\n";
- stream << "Exec=kfmclient exec '" << link << "'\n";
- stream << "Icon=" + Icon + "\n";
- stream << "Name=" + ExeDescr[exenum] + "\n";
- stream << "Path=\n";
- stream << "Type=Application\n";
- stream << "StartupNotify=false\n";
- stream << "X-KDE-SubstituteUID=false\n";
+ QTextStream mimestream( &mimefile );
+
+
+ mimestream << "<?xml version=\"1.0\"?>\n";
+ mimestream << "<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n";
+ mimestream << " <mime-type type=\"application/x-" + Binary + "\">\n";
+ mimestream << " <comment>" + ExeDescr[exenum] + "</comment>\n";
+
+ // Read through the extensions and write them
+ QStringList extensions = MimeExt[exenum].split(";", QString::SkipEmptyParts);
+ for (int i = 0; i < extensions.size(); ++i) {
+ QString tmpmime = extensions.at(i).simplified();
+ tmpmime.replace(QString(" "), QString(""));
+ mimestream << " <glob pattern=\"" + tmpmime + "\"/>\n";
}
-
- if ( RunRoot[exenum] == "1" )
- {
- stream << "X-KDE-SubstituteUID=true\nX-KDE-Username=root\n";
- }
- if ( RunShell[exenum] == "1" )
- {
- stream << "Terminal=true\nTerminalOptions=\n";
- }
- if ( Notify[exenum] == "0" )
- {
- stream << "X-KDE-StartupNotify=false\n";
- } else {
- stream << "X-KDE-StartupNotify=true\n";
- }
+
+ mimestream << " </mime-type>\n";
+ mimestream << "</mime-info>\n";
+
+ // Add the icons
+ IconScript << " " << "xdg-icon-resource install --context mimetypes /Programs/" \
+ + ProgDirName + "/" + MimeIcon[exenum] + " --size 64 application-x-" \
+ + Binary;
+ IconUnScript << " " << "xdg-icon-resource uninstall --context mimetypes /Programs/" \
+ + ProgDirName + "/" + MimeIcon[exenum] + " --size 64 application-x-" \
+ + Binary;
+
+ // Add the mime info now
+ IconScript << " " << "xdg-mime install " + mimetmp;
+ IconUnScript << "xdg-mime uninstall " + mimetmp;
+
+ } // End of mime additition
+
+ if ( RunRoot[exenum] == "1" )
+ {
+ stream << "X-KDE-SubstituteUID=true\nX-KDE-Username=root\n";
+ }
+ if ( RunShell[exenum] == "1" )
+ {
+ stream << "Terminal=true\nTerminalOptions=\n";
+ }
+ if ( Notify[exenum] == "0" )
+ {
+ stream << "X-KDE-StartupNotify=false\n";
+ } else {
+ stream << "X-KDE-StartupNotify=true\n";
+ }
- // Create a directory directly in the top menu
- if ( ExeOwndir[exenum] == 0 ) {
- // Create our desktop-directories entry
- tmp = "/usr/local/share/desktop-directories/PBI-" + ProgDirName + ".directory";
- QFile desktopdirfile( tmp );
- if ( desktopdirfile.open( QIODevice::WriteOnly | QIODevice::Text) ) {
- QTextStream streamdd( &desktopdirfile );
- streamdd << "[Desktop Entry]\n";
- streamdd << "Comment=" << ProgDirName << "\n";
- streamdd << "GenericName=" << ProgramName << "\n";
- streamdd << "Icon=" << MainIcon << "\n";
- streamdd << "Name=" << ProgramName << "\n";
- desktopdirfile.close();
- }
+ // Create a subdirectory in the top level or a sub menu
+ if ( ExeOwndir[exenum] == 0 || ExeOwndir[exenum] == 1 ) {
+ // Create our desktop-directories entry
+ tmp = MenuDir + "/PBI-" + ProgDirName + ".directory";
+ QFile desktopdirfile( tmp );
+ if ( desktopdirfile.open( QIODevice::WriteOnly | QIODevice::Text) ) {
+ QTextStream streamdd( &desktopdirfile );
+ streamdd << "[Desktop Entry]\n";
+ streamdd << "Value=1.0\n";
+ streamdd << "Type=Directory\n";
+ streamdd << "Name=" << ProgramName << "\n";
+ streamdd << "Comment=" << ProgDirName << "\n";
+ streamdd << "Icon=" << MainIcon << "\n";
+ desktopdirfile.close();
+ }
- tmp = "/usr/local/etc/xdg/menus/applications-merged/PBI-" + ProgDirName + ".merge.menu";
- QFile xdgfile( tmp );
- if ( xdgfile.open( QIODevice::WriteOnly | QIODevice::Text) ) {
- QTextStream streamxdg( &xdgfile );
- streamxdg << "<!DOCTYPE Menu PUBLIC \"-//freedesktop//DTD Menu 1.0//EN\" \"http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd\">\n";
- streamxdg << "<Menu>\n";
- streamxdg << " <Menu>\n";
- streamxdg << " <Name>" << ProgramName << "</Name>\n";
- streamxdg << " <Directory>PBI-" << ProgDirName << ".directory</Directory>\n";
- streamxdg << " <Include>\n";
- streamxdg << " <Category>X-" << ProgDirName << "</Category>\n";
- streamxdg << " </Include>\n";
- streamxdg << " </Menu>\n";
- streamxdg << "</Menu>\n";
+ // Add this desktop file to our install script
+ IconScript << " " << "xdg-desktop-menu install " + MenuDir + "/PBI-" + ProgDirName + ".directory " \
+ + MenuDir + "/PBI-" + ProgDirName + "-" + Binary + ".desktop";
+ IconUnScript << " " << "xdg-desktop-menu uninstall " + MenuDir + "/PBI-" + ProgDirName + ".directory " \
+ + MenuDir + "/PBI-" + ProgDirName + "-" + Binary + ".desktop";
+
+ // Create a directory in a KDE sub-menu
+ if (ExeOwndir[exenum] == 1) {
+ QDir xdgdir;
+ xdgdir.mkpath ( "/usr/local/etc/xdg/menus/applications-merged");
+ tmp = "/usr/local/etc/xdg/menus/applications-merged/PBI-" + ProgDirName + ".merge.menu";
- xdgfile.close();
- }
+ // Make sure we cleanup and remove this file during uninstall
+ IconUnScript << " " << "rm " + tmp;
- stream << "Categories=Qt;KDE;X-" + ProgDirName + ";\n";
- }
+ QFile xdgfile( tmp );
+ if ( xdgfile.open( QIODevice::WriteOnly | QIODevice::Text) ) {
+ QString ParentCat, SubCat;
+ if ( ExeKdeCat[exenum] == "Development")
+ ParentCat = "Development";
+ if ( ExeKdeCat[exenum] == "Editors")
+ ParentCat = "Editors";
+ if ( ExeKdeCat[exenum] == "Edutainment")
+ ParentCat = "Education";
+ if ( ExeKdeCat[exenum] == "Edutainment/Languages") {
+ ParentCat = "Education";
+ SubCat = "Languages";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment/Math") {
+ ParentCat = "Education";
+ SubCat = "Mathmatics";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment/Misc") {
+ ParentCat = "Education";
+ SubCat = "Misc";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment/Science") {
+ ParentCat = "Education";
+ SubCat = "Science";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment/Teaching") {
+ ParentCat = "Education";
+ SubCat = "Teaching";
+ }
+ if ( ExeKdeCat[exenum] == "Games/Arcade") {
+ ParentCat = "Games";
+ SubCat = "Arcade";
+ }
+ if ( ExeKdeCat[exenum] == "Games/Board") {
+ ParentCat = "Games";
+ SubCat = "Board";
+ }
+ if ( ExeKdeCat[exenum] == "Games/Card") {
+ ParentCat = "Games";
+ SubCat = "Card";
+ }
+ if ( ExeKdeCat[exenum] == "Games/Kidsgames") {
+ ParentCat = "Games";
+ SubCat = "Kidsgames";
+ }
+ if ( ExeKdeCat[exenum] == "Games/TacticStrategy") {
+ ParentCat = "Games";
+ SubCat = "TacticStrategy";
+ }
+ if ( ExeKdeCat[exenum] == "Games")
+ ParentCat = "Games";
+ if ( ExeKdeCat[exenum] == "Graphics")
+ ParentCat = "Graphics";
+ if ( ExeKdeCat[exenum] == "Internet")
+ ParentCat = "Internet";
+ if ( ExeKdeCat[exenum] == "Multimedia")
+ ParentCat = "Multimedia";
+ if ( ExeKdeCat[exenum] == "Office")
+ ParentCat = "Office";
+ if ( ExeKdeCat[exenum] == "System")
+ ParentCat = "System";
+ if ( ExeKdeCat[exenum] == "Toys") {
+ ParentCat = "Games";
+ SubCat = "Toys";
+ }
+ if ( ExeKdeCat[exenum] == "Utilities") {
+ ParentCat = "Utilities";
+ }
- // Create a directory in a KDE sub-menu
- if (ExeOwndir[exenum] == 1) {
- tmp = "/usr/local/share/desktop-directories/PBI-" + ProgDirName + ".directory";
- QFile desktopdirfile( tmp );
- if ( desktopdirfile.open( QIODevice::WriteOnly | QIODevice::Text) ) {
- QTextStream streamdd( &desktopdirfile );
- streamdd << "[Desktop Entry]\n";
- streamdd << "Comment=" << ProgDirName << "\n";
- streamdd << "GenericName=" << ProgramName << "\n";
- streamdd << "Icon=" << MainIcon << "\n";
- streamdd << "Name=" + ProgramName + "\n";
- desktopdirfile.close();
- }
+ QTextStream streamxdg( &xdgfile );
+ streamxdg << "<!DOCTYPE Menu PUBLIC \"-//freedesktop//DTD Menu 1.0//EN\" \"http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd\">\n";
+ streamxdg << "<Menu>\n";
+ streamxdg << " <Menu>\n";
+ streamxdg << " <Name>" << ParentCat << "</Name>\n";
+ if ( ! SubCat.isEmpty() )
+ {
+ streamxdg << " <Menu>\n";
+ streamxdg << " <Name>" << SubCat << "</Name>\n";
+ }
+ streamxdg << " <Menu>\n";
+ streamxdg << " <Name>" << ProgramName << "</Name>\n";
+ streamxdg << " <Directory>PBI-" << ProgDirName << ".directory</Directory>\n";
+ streamxdg << " <Include>\n";
+ streamxdg << " <Category>X-" << ProgDirName << "</Category>\n";
+ streamxdg << " </Include>\n";
+ streamxdg << " </Menu>\n";
+ if ( ! SubCat.isEmpty() )
+ {
+ streamxdg << " </Menu>\n";
+ }
+ streamxdg << " </Menu>\n";
+ streamxdg << "</Menu>\n";
- tmp = "/usr/local/etc/xdg/menus/applications-merged/PBI-" + ProgDirName + ".merge.menu";
- QFile xdgfile( tmp );
- if ( xdgfile.open( QIODevice::WriteOnly | QIODevice::Text) ) {
+ xdgfile.close();
- QString ParentCat, SubCat;
- if ( ExeKdeCat[exenum] == "Development")
- {
- ParentCat = "Development";
- }
- if ( ExeKdeCat[exenum] == "Editors")
- {
- ParentCat = "Editors";
- }
- if ( ExeKdeCat[exenum] == "Edutainment")
- {
- ParentCat = "Education";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Languages")
- {
- ParentCat = "Education";
- SubCat = "Languages";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Math")
- {
- ParentCat = "Education";
- SubCat = "Mathmatics";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Misc")
- {
- ParentCat = "Education";
- SubCat = "Misc";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Science")
- {
- ParentCat = "Education";
- SubCat = "Science";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Teaching")
- {
- ParentCat = "Education";
- SubCat = "Teaching";
- }
- if ( ExeKdeCat[exenum] == "Games/Arcade")
- {
- ParentCat = "Games";
- SubCat = "Arcade";
- }
- if ( ExeKdeCat[exenum] == "Games/Board")
- {
- ParentCat = "Games";
- SubCat = "Board";
- }
- if ( ExeKdeCat[exenum] == "Games/Card")
- {
- ParentCat = "Games";
- SubCat = "Card";
- }
- if ( ExeKdeCat[exenum] == "Games/Kidsgames")
- {
- ParentCat = "Games";
- SubCat = "Kidsgames";
- }
- if ( ExeKdeCat[exenum] == "Games/TacticStrategy")
- {
- ParentCat = "Games";
- SubCat = "TacticStrategy";
- }
- if ( ExeKdeCat[exenum] == "Games")
- {
- ParentCat = "Games";
- }
- if ( ExeKdeCat[exenum] == "Graphics")
- {
- ParentCat = "Graphics";
- }
- if ( ExeKdeCat[exenum] == "Internet")
- {
- ParentCat = "Internet";
- }
- if ( ExeKdeCat[exenum] == "Multimedia")
- {
- ParentCat = "Multimedia";
- }
- if ( ExeKdeCat[exenum] == "Office")
- {
- ParentCat = "Office";
- }
- if ( ExeKdeCat[exenum] == "System")
- {
- ParentCat = "System";
- }
- if ( ExeKdeCat[exenum] == "Toys")
- {
- ParentCat = "Games";
- SubCat = "Toys";
- }
- if ( ExeKdeCat[exenum] == "Utilities")
- {
- ParentCat = "Utilities";
- }
+ }
- QTextStream streamxdg( &xdgfile );
- streamxdg << "<!DOCTYPE Menu PUBLIC \"-//freedesktop//DTD Menu 1.0//EN\" \"http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd\">\n";
- streamxdg << "<Menu>\n";
- streamxdg << " <Menu>\n";
- streamxdg << " <Name>" << ParentCat << "</Name>\n";
- if ( ! SubCat.isEmpty() )
- {
- streamxdg << " <Menu>\n";
- streamxdg << " <Name>" << SubCat << "</Name>\n";
- }
- streamxdg << " <Menu>\n";
- streamxdg << " <Name>" << ProgramName << "</Name>\n";
- streamxdg << " <Directory>PBI-" << ProgDirName << ".directory</Directory>\n";
- streamxdg << " <Include>\n";
- streamxdg << " <Category>X-" << ProgDirName << "</Category>\n";
- streamxdg << " </Include>\n";
- streamxdg << " </Menu>\n";
- if ( ! SubCat.isEmpty() )
- {
- streamxdg << " </Menu>\n";
- }
- streamxdg << " </Menu>\n";
- streamxdg << "</Menu>\n";
+ // Add this category to our list
+ stream << "Categories=Qt;KDE;X-" + ProgDirName + ";\n";
+ } // End of check for placing within a subdir
- xdgfile.close();
- }
+ } // End of creation for Icons in a subdir, both in top level and submenu
- stream << "Categories=Qt;KDE;X-" + ProgDirName + ";\n";
- }
- // Add entry to place in KDE default directories
- if ( ExeOwndir[exenum] == 2 )
- {
- if ( ExeKdeCat[exenum] == "Development")
- {
- stream << "Categories=Qt;KDE;Development;\n";
- }
- if ( ExeKdeCat[exenum] == "Editors")
- {
- stream << "Categories=Qt;KDE;Editors;\n";
- }
- if ( ExeKdeCat[exenum] == "Edutainment")
- {
- stream << "Categories=Qt;KDE;Education;\n";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Languages")
- {
- stream << "Categories=Qt;KDE;Education;Languages;\n";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Math")
- {
- stream << "Categories=Qt;KDE;Education;Math;\n";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Misc")
- {
- stream << "Categories=Qt;KDE;Education;\n";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Science")
- {
- stream << "Categories=Qt;KDE;Education;Science;\n";
- }
- if ( ExeKdeCat[exenum] == "Edutainment/Teaching")
- {
- stream << "Categories=Qt;KDE;Education;Teaching;\n";
- }
- if ( ExeKdeCat[exenum] == "Games")
- {
- stream << "Categories=Qt;KDE;Game;\n";
- }
- if ( ExeKdeCat[exenum] == "Games/Arcade")
- {
- stream << "Categories=Qt;KDE;Game;ArcadeGame;\n";
- }
- if ( ExeKdeCat[exenum] == "Games/Board")
- {
- stream << "Categories=Qt;KDE;Game;BoardGame;\n";
- }
- if ( ExeKdeCat[exenum] == "Games/Card")
- {
- stream << "Categories=Qt;KDE;Game;CardGame;\n";
- }
- if ( ExeKdeCat[exenum] == "Games/Kidsgames")
- {
- stream << "Categories=Qt;KDE;Game;X-KDE-KidsGame;\n";
- }
- if ( ExeKdeCat[exenum] == "Games/TacticStrategy")
- {
- stream << "Categories=Qt;KDE;Game;StrategyGame;\n";
- }
- if ( ExeKdeCat[exenum] == "Graphics")
- {
- stream << "Categories=Qt;KDE;Graphics;\n";
- }
- if ( ExeKdeCat[exenum] == "Internet")
- {
- stream << "Categories=Qt;KDE;Network;\n";
- }
- if ( ExeKdeCat[exenum] == "Multimedia")
- {
- stream << "Categories=Qt;KDE;AudioVideo;Audio;Player;\n";
- }
- if ( ExeKdeCat[exenum] == "Office")
- {
- stream << "Categories=Qt;KDE;Office;\n";
- }
- if ( ExeKdeCat[exenum] == "System")
- {
- stream << "Categories=Qt;KDE;System;\n";
- }
- if ( ExeKdeCat[exenum] == "Toys")
- {
- stream << "Categories=Qt;KDE;Toys;\n";
- }
- if ( ExeKdeCat[exenum] == "Utilities")
- {
- stream << "Categories=Qt;KDE;Utility;\n";
- }
+ // Add entry to place in KDE default directories
+ /////////////////////////////////////////////////////////////////
+ if ( ExeOwndir[exenum] == 2 )
+ {
+
+ // Add this desktop file to our install script
+ IconScript << " " << "xdg-desktop-menu install " + MenuDir + "/PBI-" + ProgDirName + "-" + Binary + ".desktop";
+ IconUnScript << " " << "xdg-desktop-menu uninstall " + MenuDir + "/PBI-" + ProgDirName + "-" + Binary + ".desktop";
+
+ if ( ExeKdeCat[exenum] == "Development") {
+ stream << "Categories=Qt;KDE;Development;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Editors") {
+ stream << "Categories=Qt;KDE;Editors;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment") {
+ stream << "Categories=Qt;KDE;Education;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment/Languages") {
+ stream << "Categories=Qt;KDE;Education;Languages;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment/Math") {
+ stream << "Categories=Qt;KDE;Education;Math;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment/Misc") {
+ stream << "Categories=Qt;KDE;Education;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment/Science") {
+ stream << "Categories=Qt;KDE;Education;Science;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Edutainment/Teaching") {
+ stream << "Categories=Qt;KDE;Education;Teaching;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Games") {
+ stream << "Categories=Qt;KDE;Game;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Games/Arcade") {
+ stream << "Categories=Qt;KDE;Game;ArcadeGame;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Games/Board") {
+ stream << "Categories=Qt;KDE;Game;BoardGame;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Games/Card") {
+ stream << "Categories=Qt;KDE;Game;CardGame;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Games/Kidsgames") {
+ stream << "Categories=Qt;KDE;Game;X-KDE-KidsGame;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Games/TacticStrategy") {
+ stream << "Categories=Qt;KDE;Game;StrategyGame;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Graphics") {
+ stream << "Categories=Qt;KDE;Graphics;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Internet") {
+ stream << "Categories=Qt;KDE;Network;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Multimedia") {
+ stream << "Categories=Qt;KDE;AudioVideo;Audio;Player;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Office") {
+ stream << "Categories=Qt;KDE;Office;\n";
+ }
+ if ( ExeKdeCat[exenum] == "System") {
+ stream << "Categories=Qt;KDE;System;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Toys") {
+ stream << "Categories=Qt;KDE;Toys;\n";
+ }
+ if ( ExeKdeCat[exenum] == "Utilities") {
+ stream << "Categories=Qt;KDE;Utility;\n";
+ }
- }
-
-
- file.close();
-
}
+
+ file.close();
+ ///////////////////////////////////////////////////////////////
- if (DesktopCheckBox->isChecked() && NoDesktop[exenum] == "0" && ExeWebLink[exenum] != "1" )
+
+
+ // Make the desktop files now if we need them
+ ///////////////////////////////////////////////////////////////
+ if ( NoDesktop[exenum] == "0" && ExeWebLink[exenum] != "1" && DesktopCheckBox->isChecked() )
{
QFile file2( "/home/" + RealUserName + "/Desktop/" + Binary + ".desktop");
@@ -1133,6 +1176,7 @@
if ( file2.open( QIODevice::WriteOnly | QIODevice::Text) ) {
QTextStream stream2( &file2 );
+ stream2 << "#!/usr/bin/env xdg-open\n";
stream2 << "[Desktop Entry]\n";
stream2 << "Name=" + ExeDescr[exenum] + "\n";
//stream2 << "Exec=/Programs/" + ProgDirName + "/.sbin/" + Binary + "\n";
@@ -1187,49 +1231,22 @@
}
// change owner of file
- chown = new QProcess(this);
+ Chown = new QProcess(this);
QString program = "chown";
QStringList arguments;
arguments << "-R" << RealUserName + ":" + RealUserName << "/home/" + RealUserName + "/Desktop/" + Binary + ".desktop";
- chown->start(program, arguments);
-
- }
-
- if (TaskbarCheckBox->isChecked() && ExeTaskbar[exenum] == "1" && ExeWebLink[exenum] != "1" )
- {
-
- QString ShellOption;
-
- if ( RunShell[exenum] == "1" )
- {
- ShellOption = "TRUE";
- } else {
- ShellOption = "FALSE";
- }
-
-
- QFile file3( "dcop.sh");
- if ( file3.open( QIODevice::WriteOnly) ) {
- QTextStream stream3( &file3 );
- stream3 << "#!/bin/sh\n";
- stream3 << "dcop --user " + RealUserName + " kicker Panel addNonKDEAppButton \"" + ExeDescr[exenum] + "\" \"" + ExeDescr[exenum] + "\" \"/Programs/" + ProgDirName + "/.sbin/" + Binary + "\" \"" + Icon + "\" \"\" " + ShellOption + "\n";
-
- }
-
- file3.close();
-
- // Now run the dcop command
- chown = new QProcess(this);
- QString program = "sh";
- QStringList arguments;
- arguments << "dcop.sh";
+ Chown->start(program, arguments);
- chown->start(program, arguments);
+ // Set the file to 744 to avoid KDE warnings
+ Chmod = new QProcess(this);
+ program = "chmod";
+ arguments.clear();
+ arguments << "744" << "/home/" + RealUserName + "/Desktop/" + Binary + ".desktop";
+ Chmod->start(program, arguments);
-
+
}
-
}
@@ -1237,17 +1254,6 @@
void PBI::FinishedInstallSlot()
{
- // Install is finished! Check if we need to recreate the mime database before we exit
- if ( createdMimeFiles == 1)
- {
- // Chmod the new file
- Chmod2 = new QProcess(this);
- QString program2 = "update-mime-database";
- QStringList arguments2;
- arguments2 << "/usr/local/share/mime";
- Chmod2->start(program2, arguments2);
- }
-
installProgress->setValue(installProgress->maximum());
StatusLabel->setText(tr("Installation Finished!"));
progressTextDialog->setText("");
@@ -1342,82 +1348,7 @@
}
-void PBI::CreateMimeSlot( int MimeNum )
-{
- if ( MimeExt[MimeNum].isEmpty() )
- {
- // All finished with Mime Files, lets move on to checking for custom scripts now
- CheckScriptSlot();
- return;
- }
-
- StatusLabel->setText(tr("Registering file associations..."));
- QString MimeNumString;
- MimeNumString.setNum(MimeNum);
-
- // Get the binary name
- QString Binary;
- if ( ExePath[MimeProg[MimeNum]].lastIndexOf("/" ) != -1 )
- {
- Binary = ExePath[MimeProg[MimeNum]].remove(0, ExePath[MimeProg[MimeNum]].lastIndexOf("/") );
- } else {
- Binary = ExePath[MimeProg[MimeNum]];
- }
-
-
- // Set the right icon for this mime entry
- QString Icon;
- QString MainIcon;
-
- MainIcon = "/Programs/" + ProgDirName + "/" + DefaultIcon;
-
- if ( MimeIcon[MimeProg[MimeNum]].isEmpty() && DefaultIcon.isEmpty() )
- {
- Icon = "/Programs/.config/application.png";
- }else if (MimeIcon[MimeNum].isEmpty() ) {
- Icon = "/Programs/" + ProgDirName + "/" + DefaultIcon;
- } else {
- Icon = "/Programs/" + ProgDirName + "/" + MimeIcon[MimeProg[MimeNum]];
- }
-
-
- // Setup our variables we will use for the argument list
- QString MimeName = ProgramName + MimeNumString;
- QString ProgEXE = "/Programs/" + ProgDirName + "/.sbin/" + Binary;
- QString Terminal = "0";
- if ( RunShell[MimeProg[MimeNum]] == "1" )
- {
- Terminal = "1";
- }
- QString Location;
- if ( RealUserName == "root" )
- {
- Location="/root/.PBItmp";
- } else {
- Location = "/home/" + RealUserName + "/.PBItmp";
- }
-
- // Create the mime entry by calling addpbimime.sh
- MimeProc = new QProcess(this);
- QString program = "bash";
- QStringList arguments;
- //arguments << Location + "/addpbimime.sh" << MimeName << MimeExt[MimeNum] << ProgEXE << Icon << Terminal ;
- arguments << "./addpbimime.sh" << MimeName << MimeExt[MimeNum] << ProgEXE << Icon << Terminal << ProgDirName ;
- connect( MimeProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotMimeProcFinished(int, QProcess::ExitStatus) ) );
- MimeProc->start(program, arguments);
- //QMessageBox::information( this, ProgramName, arguments.join(",") );
-
-}
-
-// Slot to grab the exit status of a mime creation, and kick off the next one
-void PBI::slotMimeProcFinished(int exitCode, QProcess::ExitStatus exitStatus)
-{
- workingMime++;
- CreateMimeSlot(workingMime);
-}
-
-
void PBI::runCommand( QString Command )
{
FILE *file = popen(Command.toLatin1(),"r");
@@ -2194,71 +2125,14 @@
QTextStream stream( &file );
stream << "#!/bin/sh\n";
- // Check if we need to put any Mime removal code into the uninstall script
- if ( createdMimeFiles == 1 )
- {
- int i = 0;
- while ( ! MimeExt[i].isEmpty() )
- {
- stream << "# Check if we have a different pcbsdbase conf\n";
- stream << "if [ -e \"/PCBSD/conf/pcbsdbase\" ]\n";
- stream << "then\n";
- stream << " BASE=`cat /PCBSD/conf/pcbsdbase`\n";
- stream << "else\n";
- stream << " BASE=/usr/local\n";
- stream << "fi\n";
+ stream << "\nsh /Programs/" + ProgDirName + "/.sbin/uninstall-xdg-icons.sh >/dev/null 2>/dev/null\n";
- // Remove the xml files from the mime package database
- stream << "rm -f \"${BASE}/share/mime/packages/" << ProgramName << i << "-\"*\n";
-
- // Remove the hidden applnk files
- stream << "rm -f \"${BASE}/share/applnk/.hidden/" << ProgramName << i << "-\"*\n";
-
- // Remove any mentions of this entry from mimeapps.list
- stream << "cat ${BASE}/share/applications/mimeapps.list | grep -v '=" << ProgramName << i << "-' >/tmp/.mimeapps.list\n";
- stream << "mv /tmp/.mimeapps.list ${BASE}/share/applications/mimeapps.list\n";
-
- i++;
- }
-
- // Remove any created mimetypes/<icons>
- stream << "for i in `cat /Programs/" + ProgDirName + "/.iconmime`\n";
- stream << "do\n";
- stream << "if [ -h \"${BASE}/kde4/share/icons/oxygen/16x16/mimetypes/${i}\" ]\n";
- stream << "then\n";
- stream << " rm ${BASE}/kde4/share/icons/oxygen/16x16/mimetypes/${i}\n";
-
- stream << "fi\n";
- stream << "if [ -h \"${BASE}/kde4/share/icons/oxygen/48x48/mimetypes/${i}\" ]\n";
- stream << "then\n";
- stream << " rm ${BASE}/kde4/share/icons/oxygen/48x48/mimetypes/${i}\n";
-
- stream << "fi\n";
- stream << "if [ -h \"${BASE}/kde4/share/icons/oxygen/64x64/mimetypes/${i}\" ]\n";
- stream << "then\n";
- stream << " rm ${BASE}/kde4/share/icons/oxygen/64x64/mimetypes/${i}\n";
-
- stream << "fi\n";
- stream << "if [ -h \"${BASE}/kde4/share/icons/oxygen/128x128/mimetypes/${i}\" ]\n";
- stream << "then\n";
- stream << " rm ${BASE}/kde4/share/icons/oxygen/128x128/mimetypes/${i}\n";
-
- stream << "fi\n";
- stream << "done\n";
-
- // Recreate the mime database
- stream << "update-mime-database ${BASE}/share/mime\n";
-
- }
-
// Run the provided removal script now
stream << "\nif [ -e '/Programs/" + ProgDirName + "/PBI.RemoveScript2.sh' ]\n";
stream << "then\n";
stream << " sh /Programs/" + ProgDirName + "/PBI.RemoveScript2.sh \"${@}\"\n";
stream << "fi\n";
- stream << "rm /usr/local/share/applications/kde/PBI-" + ProgramName+ "-* >/dev/null 2>/dev/null\n";
- stream << "rm /usr/local/share/desktop-directories/PBI-" + ProgDirName + ".directory >/dev/null 2>/dev/null\n";
- stream << "rm /usr/local/etc/xdg/menus/applications-merged/PBI-" + ProgDirName + ".merge.menu >/dev/null 2>/dev/null\n";
+ stream << "\n";
stream << "rm -rf '" + InstallDirPath + "'\n";
Modified: pbibuild/pbi-source/PBIsource/pbi.h
===================================================================
--- pbibuild/pbi-source/PBIsource/pbi.h 2009-07-17 21:55:00 UTC (rev 4253)
+++ pbibuild/pbi-source/PBIsource/pbi.h 2009-07-20 20:08:30 UTC (rev 4254)
@@ -38,7 +38,6 @@
void CheckRootSlot();
void CheckScriptSlot();
void setProgressSlot();
- void CreateMimeSlot( int MimeNum );
void runCommand( QString Command );
void startInstallSlot();
void startInstallFirstRunCheck();
@@ -59,7 +58,6 @@
void slotRecheckChecksumFinished();
void slotSetupScriptFinished(int exitCode, QProcess::ExitStatus exitStatus);
void slotUnTarFinished(int exitCode, QProcess::ExitStatus exitStatus);
- void slotMimeProcFinished(int exitCode, QProcess::ExitStatus exitStatus);
void slotExtractProcFinished(int exitCode, QProcess::ExitStatus exitStatus);
void slotChecksumProcFinished(int exitCode, QProcess::ExitStatus exitStatus);
void readFirstRunOutput(int exitCode, QProcess::ExitStatus exitStatus);
@@ -67,6 +65,7 @@
void slotCheckExistingProgram();
private:
+ void doDesktopInstallScript();
QString ProgramName;
QString ProgramVer;
QString ProgramAuthor;
@@ -80,9 +79,8 @@
QProcess *CopyLibs;
QProcess *Chmod;
QProcess *Chmod2;
- QProcess *MimeProc;
QProcess *Link;
- QProcess *chown;
+ QProcess *Chown;
QProcess *CheckRoot;
QProcess *SetupScript;
QProcess *FirstRunScript;
@@ -121,8 +119,8 @@
QString InstallDirPath;
int ChecksumFinished;
int ChecksumPassed;
- int createdMimeFiles;
- int workingMime;
+ QStringList IconScript;
+ QStringList IconUnScript;
signals:
More information about the Commits
mailing list