[PC-BSD Commits] r2407 - pbibuild/pbi-source/PBItext

svn at pcbsd.org svn at pcbsd.org
Mon Jul 21 12:54:06 PDT 2008


Author: kris
Date: 2008-07-21 12:54:06 -0700 (Mon, 21 Jul 2008)
New Revision: 2407

Modified:
   pbibuild/pbi-source/PBItext/main.cpp
Log:

Update the PBItext install to version 4.6 as well, with the same kmenu enhancments



Modified: pbibuild/pbi-source/PBItext/main.cpp
===================================================================
--- pbibuild/pbi-source/PBItext/main.cpp	2008-07-21 19:53:31 UTC (rev 2406)
+++ pbibuild/pbi-source/PBItext/main.cpp	2008-07-21 19:54:06 UTC (rev 2407)
@@ -593,8 +593,8 @@
 
 void CreateIconsSlot( int exenum )
 {
-    QString ExeTemp = ExePath[exenum];
-    
+   QString ExeTemp = ExePath[exenum];
+    QString tmp;
      //StatusLabel->setText("Creating Icons...");
      
      // Get the binary name
@@ -606,14 +606,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	
@@ -634,66 +640,229 @@
         
     if( 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(  QIODevice::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))
+        {
+	  printf("Failed to open " + tmp.toLatin1() + " for writing!\n");
+	  return;
+        }
+        QTextStream stream( &file );
+
+
 	// Regular Program Application
 	if ( ExeLink[exenum] == "0" && ExeWebLink[exenum] == "0" && ExeLink[exenum] == "0" ) {
 	
              QDir bindir;
-             bindir.mkpath( "/Programs/bin");
+       	     bindir.mkpath ( "/Programs/bin");
              runCommand("ln -fs /Programs/" + ProgDirName + "/.sbin/" + Binary + " /Programs/bin/" + Binary+ " >/dev/null 2>/dev/null");
 
-
-               if ( file.open(  QIODevice::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")
@@ -704,143 +873,30 @@
 		 {
 		       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")
+		 if ( ExeKdeCat[exenum] == "Edutainment")
 		 {
-		       stream << "Categories=Qt;KDE;Game;ArcadeGame;\n";
+		       stream << "Categories=Qt;KDE;Education;\n";
 		 }
-		 if ( ExeKdeCat[exenum] == "Games/Board")
+		 if ( ExeKdeCat[exenum] == "Edutainment/Languages")
 		 {
-		       stream << "Categories=Qt;KDE;Game;BoardGame;\n";
+		       stream << "Categories=Qt;KDE;Education;Languages;\n";
 		 }
-		 if ( ExeKdeCat[exenum] == "Games/Card")
+		 if ( ExeKdeCat[exenum] == "Edutainment/Math")
 		 {
-		       stream << "Categories=Qt;KDE;Game;CardGame;\n";
+		       stream << "Categories=Qt;KDE;Education;Math;\n";
 		 }
-		 if ( ExeKdeCat[exenum] == "Games/Kidsgames")
+		 if ( ExeKdeCat[exenum] == "Edutainment/Misc")
 		 {
-		       stream << "Categories=Qt;KDE;Game;X-KDE-KidsGame;\n";
+		       stream << "Categories=Qt;KDE;Education;\n";
 		 }
-		 if ( ExeKdeCat[exenum] == "Games/TacticStrategy")
+		 if ( ExeKdeCat[exenum] == "Edutainment/Science")
 		 {
-		       stream << "Categories=Qt;KDE;Game;StrategyGame;\n";
+		       stream << "Categories=Qt;KDE;Education;Science;\n";
 		 }
-		 if ( ExeKdeCat[exenum] == "Graphics")
+		 if ( ExeKdeCat[exenum] == "Edutainment/Teaching")
 		 {
-		       stream << "Categories=Qt;KDE;Graphics;\n";
+		       stream << "Categories=Qt;KDE;Education;Teaching;\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();
-                 }
-	       // 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(  QIODevice::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";
@@ -871,7 +927,7 @@
 		 }
 		 if ( ExeKdeCat[exenum] == "Multimedia")
 		 {
-		       stream << "Categories=Qt;KDE;Multimedia;\n";
+		       stream << "Categories=Qt;KDE;AudioVideo;Audio;Player;\n";
 		 }
 		 if ( ExeKdeCat[exenum] == "Office")
 		 {
@@ -889,15 +945,12 @@
 		 {
 		       stream << "Categories=Qt;KDE;Utility;\n";
 		 }
+				 
 	     }
-                    file.close();
-                 }
-	       
-	   }
-	
-        // change permissions of the directory
-	//runCommand("chmod -R 755 /Programs/" + ProgramDirName);
-	
+	     
+                       
+        file.close();
+             
     }
     
     if (NoDesktop[exenum] == "0" && ExeWebLink[exenum] != "1" )
@@ -1064,6 +1117,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";
 
              // Check if we need to put any Mime removal code into the uninstall script
              if ( createdMimeFiles == 1 )



More information about the Commits mailing list