[prev in list] [next in list] [prev in thread] [next in thread] 

List:       klik-devel
Subject:    [klik-devel] [klikclient commit] r1271 -
From:       codesite-noreply () google ! com
Date:       2008-02-28 22:45:11
Message-ID: 00163646d90c04473fac98b98f411c52 () google ! com
[Download RAW message or body]

Author: razielmine
Date: Thu Feb 28 14:44:52 2008
New Revision: 1271

Modified:
   trunk/client/trunk/klikclient/lib/klik/cmg.py
   trunk/client/trunk/klikclient/lib/klik/integration.py

Log:
- Adapted integration to always use klik run
- Desktop file processing overhaul
- Fixed error in cmg.py when detecting cramfs magic


Modified: trunk/client/trunk/klikclient/lib/klik/cmg.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/cmg.py	(original)
+++ trunk/client/trunk/klikclient/lib/klik/cmg.py	Thu Feb 28 14:44:52 2008
@@ -201,8 +201,11 @@
 							# this should really mount and check for recipe not seek(22)
 					f.seek(0)
 					magic = str(f.read(4)).strip()
-					# FIXME: this breaks with IndexError: string index out of range (RazZziel)
-					if ord(magic[0])==69 and ord(magic[1])==61 and ord(magic[2])==205 
and ord(magic[3])==40:
+					if (len(magic)==4 and
+					    ord(magic[0])==69 and
+					    ord(magic[1])==61 and
+					    ord(magic[2])==205 and
+					    ord(magic[3])==40):
 						# cramfs
 						f.close()
 						self.__cmg_version = 1
@@ -270,7 +273,7 @@
 		else:
 			# Check if the icon belongs to the default theme
 			theme_icon = None
-			if icon[0] != "/" and self.xdg.get_is_gtk_installed():
+			if icon[0] != "/" and self.klik.xdg.get_is_gtk_installed():
 				try:
 					# never rely on gtk
 					import gtk.utils
@@ -295,33 +298,19 @@
 	def get_desktop_objects(self, fix_exec=True):

 		# Search application .desktop files
-		desktop_files = self.find_files(self.path, "/usr/share/applications/", ".desktop")
-		
 		desktop_objects = []
-		for file in desktop_files:
-
+		for file in self.find_files("/usr/share/applications/", ".desktop"):
 			# Extract and parse the .desktop file
 			temp_path = tempfile.mktemp()

-			if not self.extract_file( file, temp_path ):
-				print "\t!! Couldn't extract", file
-
-			else:
+			if self.extract_file( file, temp_path ): # TODO: extract to 
standard output instead of a file
 				do = DesktopParser( temp_path )
+				os.remove( temp_path )

-				command = do.get("Exec")
-				if do.get("Type") == "Application" and command != None:
-
-					# Parse command and change it to point to CMG
-					if fix_exec:
-						do.set( "Exec", "klik exec \"" + self.path + "\" " + command )
-					else:
-						do.set( "Exec", command )
-					do.set( "X-CMG", self.path )
-
+				if do.get("Exec") and (do.get("Type") == "Application"):
 					desktop_objects.append( do )
-
-				os.remove( temp_path )
+			else:
+				print "\t!! Couldn't extract", file

 		# Attempt to generate desktop files from debian menu
 		if len(desktop_objects) == 0:
@@ -340,11 +329,7 @@
 						do = DesktopParser()

 						do.set("Type", "Application")
-						if fix_exec:
-							do.set("Exec", "klik exec \"" + self.path + "\" " + mo.command)
-						else:
-							do.set("Exec", mo.command)
-
+						do.set("Exec", mo.command)
 						do.set( "X-CMG", self.path )
 						do.set("Name", mo.title.capitalize())
 						#do.set("Terminal", recipe.require_terminal)
@@ -358,32 +343,31 @@
 		
 			# With klik2 packages, extract information from recipe
 			# With klik1 packages, make up information
+			
 			cmg_version = self.is_valid_cmg()
 			
-			recipe = None
 			if cmg_version == 2:
 				recipe = self.get_recipe()
-		
-			do = DesktopParser()
-			
-			if fix_exec or (cmg_version == 1):
-				do.set("Exec", "klik \"" + self.path + "\"") # dont need to not 
fix this one..
 			else:
+				recipe = None
+
+			if recipe:
 				if recipe.command:
-					do.set("Exec", recipe.command)
+					command = recipe.command
 				else:
-					do.set("Exec", recipe.name)
-		
-			if recipe:
+					command = recipe.name
 				name = recipe.name.capitalize()
 				terminal = recipe.require_terminal
 			else:
+				command = ""
 				name = os.path.splitext( os.path.basename( self.path ) )[0].capitalize()
 				terminal = False
 			
+			do = DesktopParser()
+			
 			do.set("Name", name)
 			do.set("Terminal", terminal)
-			
+			do.set("Exec", command)
 			do.set("Type", "Application")
 			do.set("Icon", "/.DirIcon")
 			do.set("X-CMG", self.path)

Modified: trunk/client/trunk/klikclient/lib/klik/integration.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/integration.py	(original)
+++ trunk/client/trunk/klikclient/lib/klik/integration.py	Thu Feb 28 
14:44:52 2008
@@ -242,18 +242,25 @@
 			if is_already_registered( cmg_path ):
 				print "\t", _("Package already registered")
 				continue
+			
+			cmg = KlikCmg(self.base, cmg_path)

-			build_path = tempfile.mkdtemp( '.register.' + os.environ["USER"],
+			build_path = tempfile.mkdtemp( '.register.' + cmg.get_unique_id(),
 						       self.base.settings.temp_directory_path )
 			self.base.temp_paths.append( build_path )
 			
 			# Registering one menu entry per desktop object found/created

-			cmg = KlikCmg(self.base, cmg_path)
 			for do in cmg.get_desktop_objects():
 				# Package ID is the CMG name escaped with the specific .desktop name...
 				package_id = cmg.get_unique_id( do.get("Name") )

+				# Convert execution command
+				command = do.get("Exec") or ""
+				do.set( "Exec", "klik run %s '%s'" % (command, cmg.path) )
+				
+				do.set( "X-CMG", cmg.path )
+
  				# Icons: each menu entry can have many icons, in different sizes 
and themes
 				icon_list = cmg.scan_cmg_icons( do )
 				icon_list = filter( register_icon, icon_list )
@@ -262,9 +269,8 @@
 					if (icon_list[0][0] == "/"): # Icon is not themed
 						do.set( "Icon", package_id )
 				else:
-					# No valid icon for this entry, fallback to klik default icon
-					do.set( "Icon", os.path.join(sys.path[0], 
os.pardir, "share", "klik", "klik.png") )
-					print "\t", _("Icon does not exist")
+					# No valid icon for this entry, fallback to klik themed icon
+					do.set( "Icon", "application-x-extension-cmg" )

 				# Write .desktop file
  				temp_desktop_path = os.path.join( build_path, package_id 
+ ".desktop" )
_______________________________________________
klik-devel mailing list
klik-devel@kde.org
https://mail.kde.org/mailman/listinfo/klik-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic