[PC-BSD Commits] r2406 - pbibuild/pbi-source/PBIsource

svn at pcbsd.org svn at pcbsd.org
Mon Jul 21 12:53:31 PDT 2008


Author: kris
Date: 2008-07-21 12:53:31 -0700 (Mon, 21 Jul 2008)
New Revision: 2406

Modified:
   pbibuild/pbi-source/PBIsource/PBI.pro
   pbibuild/pbi-source/PBIsource/pbi.cpp
Log:

Updated PBI installer to version 4.6, which creates kmenu  icons in a different
way which can be used by KDE4 properly, including the favorites list



Modified: pbibuild/pbi-source/PBIsource/PBI.pro
===================================================================
--- pbibuild/pbi-source/PBIsource/PBI.pro	2008-07-21 16:42:24 UTC (rev 2405)
+++ pbibuild/pbi-source/PBIsource/PBI.pro	2008-07-21 19:53:31 UTC (rev 2406)
@@ -5,6 +5,8 @@
 
 LIBS	+= -L/usr/local/kde4/lib -lkdecore -lkio -lkdeui -Ikdelibs 
 
+INCLUDEPATH += /usr/local/kde4/include
+
 HEADERS += pbi.h
 
 SOURCES	+= main.cpp pbi.cpp

Modified: pbibuild/pbi-source/PBIsource/pbi.cpp
===================================================================
--- pbibuild/pbi-source/PBIsource/pbi.cpp	2008-07-21 16:42:24 UTC (rev 2405)
+++ pbibuild/pbi-source/PBIsource/pbi.cpp	2008-07-21 19:53:31 UTC (rev 2406)
@@ -11,10 +11,10 @@
 *****************************************************************************/
 /****************************************************************************
 *     Name: PBI-Wizard
-*  Version: 3.1 
+*  Version: 4.6 
 *   Author: Kris Moore
 *  License: BSD (See LICENSE file for more detail)
-*     Date: 4-2-07
+*     Date: 7-22-08
 *****************************************************************************/
 
 #include <iostream>
@@ -649,7 +649,7 @@
 void PBI::CreateIconsSlot( int exenum )
 {
     QString ExeTemp = ExePath[exenum];
-    
+    QString tmp;
      //StatusLabel->setText("Creating Icons...");
      
      // Get the binary name
@@ -661,14 +661,20 @@
         Binary = "web" + Binary;
 	
     } else {
-    
+        // Remove a trailing /
         if ( ExeTemp.lastIndexOf("/" ) != -1 )
         {
-	    Binary = ExeTemp.remove(0, ExeTemp.lastIndexOf("/") );
+	   Binary = ExeTemp.remove(0, ExeTemp.lastIndexOf("/") );
         } else {
 	   Binary = ExeTemp;  
         }
 	
+       // Check for a starting / and remove it also
+       if ( Binary.indexOf("/") == 0 )
+       {
+          tmp = Binary;
+	  Binary = tmp.remove(0,1);
+       }
     }
 	
      // Get the right icon	
@@ -689,37 +695,16 @@
         
     if(LaunchCheckBox->isChecked() && NoMenu[exenum] == "0"  )
     {
-	// Create the app directory / icon
-	QString SubDir;
-	
-	// Find if we are installing in a subdir, or not
-	if ( ExeOwndir[exenum] == 0 )
-	{
-	    SubDir = "";  
-	} else if (ExeOwndir[exenum] == 1) {
-            if ( ExeKdeCat[exenum].indexOf("Edutainment") != -1 ) {
-	      SubDir = "/Edutainment/";
-            } else {
-	      SubDir =  "/"  + ExeKdeCat[exenum] + "/";
-            }
-	} else {
-	    SubDir="";
-	}
-	
-	
-        QDir LaunchDir;
-        LaunchDir.mkpath("/usr/local/share/applnk/" +SubDir + ProgramName);
-	
-	QFile diricon("/usr/local/share/applnk/" + SubDir + ProgramName + "/.directory");
-               if ( diricon.open( IO_WriteOnly) ) {
-                QTextStream dirstream( &diricon );
-	     dirstream << "[Desktop Entry]\n";
-	     dirstream << "Icon=" << MainIcon;
-	     diricon.close();
-	 }
-	
-	QFile file( "/usr/local/share/applnk/" + SubDir + ProgramName + "/" + Binary + ".desktop");
-	
+	tmp = "/usr/local/share/applications/kde/PBI-" + 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 );
+
+
 	// Regular Program Application
 	if ( ExeLink[exenum] == "0" && ExeWebLink[exenum] == "0" && ExeLink[exenum] == "0" ) {
 	
@@ -727,28 +712,212 @@
        	     bindir.mkpath ( "/Programs/bin");
              runCommand("ln -fs /Programs/" + ProgDirName + "/.sbin/" + Binary + " /Programs/bin/" + Binary+ " >/dev/null 2>/dev/null");
 
-               if ( file.open( IO_WriteOnly) ) {
-                QTextStream stream( &file );
 	     stream << "[Desktop Entry]\n";
-	     stream << "Name=" + ExeDescr[exenum] + "\n";
+	     stream << "GenericName=" + ExeDescr[exenum] + "\n";
+	     stream << "Name=" + Binary + "\n";
 	     stream << "Exec=/Programs/bin/" + Binary + "\n";
 	     stream << "Type=Application\n";
 	     stream << "Path=/Programs/" + ProgDirName + "/\n";
 	     stream << "Icon=" + Icon + "\n";
-	     if ( RunRoot[exenum] == "1" )
+
+        } else {
+
+	     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";
+         }
+   
+	 if ( RunRoot[exenum] == "1" )
+	 {
 		 stream << "X-KDE-SubstituteUID=true\nX-KDE-Username=root\n";
-	     }
-	     if ( RunShell[exenum] == "1" )
-	     {
-		 stream << "Terminal=true\nTerminalOptions=\n";
-	     }
+	 }
+	 if ( RunShell[exenum] == "1" )
+	 {
+	   stream << "Terminal=true\nTerminalOptions=\n";
+	 }
 	     if ( Notify[exenum] == "0" )
 	     {
-		 stream << "StartupNotify=false\n";
+		 stream << "X-KDE-StartupNotify=false\n";
+	     } else {
+		 stream << "X-KDE-StartupNotify=true\n";
 	     }
-	     
-	     // Add entry to place in KDE default directories
+	    
+             // 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();
+                 }
+
+		 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";
+
+                      xdgfile.close();
+                 }
+
+                 stream << "Categories=Qt;KDE;X-" + ProgDirName + ";\n";
+	     } 
+
+             // 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();
+                 }
+
+		 tmp = "/usr/local/etc/xdg/menus/applications-merged/PBI-" + ProgDirName + ".merge.menu";
+	         QFile xdgfile( tmp );
+                 if ( xdgfile.open( QIODevice::WriteOnly | QIODevice::Text) ) {
+
+                   QString ParentCat;
+		   if ( ExeKdeCat[exenum] == "Development")
+		   {
+		       ParentCat = "Development";
+		   }
+		   if ( ExeKdeCat[exenum] == "Editors")
+		   {
+		       ParentCat = "Editors";
+		   }
+		   if ( ExeKdeCat[exenum] == "Edutainment")
+		   {
+		       ParentCat = "Education";
+		   }
+		   if ( ExeKdeCat[exenum] == "Edutainment/Languages")
+		   {
+		       ParentCat = "Languages";
+		   }
+		   if ( ExeKdeCat[exenum] == "Edutainment/Math")
+		   {
+		       ParentCat = "Mathmatics";
+		   }
+		   if ( ExeKdeCat[exenum] == "Edutainment/Misc")
+		   {
+		       ParentCat = "Edutainment";
+		   }
+		   if ( ExeKdeCat[exenum] == "Edutainment/Science")
+		   {
+		       ParentCat = "Science";
+		   }
+		   if ( ExeKdeCat[exenum] == "Edutainment/Teaching")
+		   {
+		       ParentCat = "Edutainment";
+		   }
+		   if ( ExeKdeCat[exenum] == "Games/Arcade")
+		   {
+		       ParentCat = "Arcade";
+		   }
+		   if ( ExeKdeCat[exenum] == "Games/Board")
+		   {
+		       ParentCat = "Board";
+		   }
+		   if ( ExeKdeCat[exenum] == "Games/Card")
+		   {
+		       ParentCat = "Card";
+		   }
+		   if ( ExeKdeCat[exenum] == "Games/Kidsgames")
+		   {
+		       ParentCat = "Kidsgames";
+		   }
+		   if ( ExeKdeCat[exenum] == "Games/TacticStrategy")
+		   {
+		       ParentCat = "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 = "Toys";
+		   }
+		   if ( ExeKdeCat[exenum] == "Utilities")
+		   {
+		       ParentCat = "Utility";
+		   }
+
+                      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";
+		      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";
+		      streamxdg << "</Menu>\n";
+
+                      xdgfile.close();
+                 }
+
+		 stream << "Categories=Qt;KDE;X-" + ProgDirName + ";\n";
+	     }
+
+             // Add entry to place in KDE default directories
 	     if ( ExeOwndir[exenum] == 2 )
 	     {
 		 if ( ExeKdeCat[exenum] == "Development")
@@ -835,122 +1004,8 @@
 	     }
 	     
                        
-                    file.close();
-                 }
-	       // If Link = 1, then make a program link instead
-	   } else {
-	       
-	       
-	       QString link;
-	       
-	       if ( ExeWebLink[exenum] == "1" )
-	       {
-		   link = ExePath[exenum];
-	       } else {
-		   link = "/Programs/" + ProgDirName + "/" +ExePath[exenum];
-	       }
-	       
-	     if ( file.open( IO_WriteOnly) ) {
-                    QTextStream stream( &file );
-	     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";
-	     
-                        // 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/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;Multimedia;\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" )
@@ -968,7 +1023,7 @@
         runCommand("ln -fs /Programs/" + ProgDirName + "/.sbin/" + Binary + " /Programs/bin/" + Binary+ " >/dev/null 2>/dev/null");
 
 	
-               if ( file2.open( IO_WriteOnly) ) {
+               if ( file2.open( QIODevice::WriteOnly | QIODevice::Text) ) {
                 QTextStream stream2( &file2 );
 	     stream2 << "[Desktop Entry]\n";
 	     stream2 << "Name=" + ExeDescr[exenum] + "\n";
@@ -1006,7 +1061,7 @@
 	       }
 		    
 		    
-	     if ( file2.open( IO_WriteOnly) ) {
+	     if ( file2.open( QIODevice::WriteOnly | QIODevice::Text) ) {
                     QTextStream stream2( &file2 );
 	     stream2 << "[Desktop Entry]\n";
 	     stream2 << "Exec=kfmclient exec '" << link << "'\n";
@@ -2231,6 +2286,8 @@
 	     stream << "then\n";
 	     stream << "   sh /Programs/" + ProgDirName + "/PBI.RemoveScript2.sh \"${@}\"\n";
 	     stream << "fi\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 << "rm -rf '" + InstallDirPath + "'\n";
 
              // Check if we need to put any Mime removal code into the uninstall script



More information about the Commits mailing list