From alavaliant@ra09.com  Tue Mar 10 09:30:25 2015
Received: (at submit) by bugs.x2go.org; 10 Mar 2015 08:30:27 +0000
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
	ymir.das-netzwerkteam.de
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=ham
	version=3.3.2
Received: from thetower.ra09.com (ra09.com [202.124.104.240])
	by ymir.das-netzwerkteam.de (Postfix) with ESMTPS id 99FBB5E15C
	for <submit@bugs.x2go.org>; Tue, 10 Mar 2015 09:30:24 +0100 (CET)
Received: from grigorig.ra09.com ([10.1.1.8])
	by thetower.ra09.com with esmtp (Exim 4.80)
	(envelope-from <alavaliant@ra09.com>)
	id 1YVFYS-0005Ju-PK
	for submit@bugs.x2go.org; Tue, 10 Mar 2015 21:30:21 +1300
Message-ID: <54FEABB7.5090705@ra09.com>
Date: Tue, 10 Mar 2015 21:30:47 +1300
From: Jason Alavaliant <alavaliant@ra09.com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.5.0
MIME-Version: 1.0
To: submit@bugs.x2go.org
Subject: x2gogetapps should ignore NoDisplay=true desktop application entries
Content-Type: multipart/mixed;
 boundary="------------070205030900000104070706"

This is a multi-part message in MIME format.
--------------070205030900000104070706
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

Package: x2goserver
Version: 4.0.1.19
Tags: patch

Currently the x2gogetapps command prints out all .desktop application 
files irrespective of if they have the value NoDisplay=true set in the 
file or not.

This results in the hosted applications list becoming filled with 
entries that weren't intended to be listed in an application menu 
normally.    For example on my system I have;

/usr/share/applications/kde4/okularApplication_comicbook.desktop 
/usr/share/applications/kde4/okularApplication_ooo.desktop
/usr/share/applications/kde4/okularApplication_dvi.desktop 
/usr/share/applications/kde4/okularApplication_pdf.desktop
/usr/share/applications/kde4/okularApplication_fax.desktop 
/usr/share/applications/kde4/okularApplication_plucker.desktop
/usr/share/applications/kde4/okularApplication_fb.desktop 
/usr/share/applications/kde4/okularApplication_txt.desktop
/usr/share/applications/kde4/okularApplication_ghostview.desktop 
/usr/share/applications/kde4/okularApplication_xps.desktop
/usr/share/applications/kde4/okularApplication_kimgio.desktop 
/usr/share/applications/kde4/okular.desktop
/usr/share/applications/kde4/okularApplication_mobi.desktop

All of them except okular.desktop  have NoDisplay=true  set in the 
file,     a normal desktop environment menu has one entry for okular 
shown since it doesn't list all of those other entries.    The x2go 
application list currently has 13 entries for okular since it displays 
every single one of the entries.

The attached patch updates the x2gogetapps command to check the file to 
see if NoDisplay=true is set and if so doesn't print out the contents of 
that file removing all the duplicates and other entries not intended to 
be listed in a normal application launch menu.

Thanks
Jason

--------------070205030900000104070706
Content-Type: text/x-patch;
 name="x2gogetapps-hide-NoDisplay-applications.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="x2gogetapps-hide-NoDisplay-applications.patch"

--- old/x2gogetapps	2015-03-10 20:41:23.067019460 +1300
+++ new/x2gogetapps	2015-03-10 21:17:48.550954759 +1300
@@ -118,53 +118,68 @@
 	my $file=shift;
 	if (open(F,"<$file"))
 	{
-		print("<desktop>\n");
-		my $is_desktop_entry = 0;
+		my @all_lines;
+		my $nodisplay = 0;
 		while(!eof(F))
 		{
 			my $line=<F>;
-			if ( $line=~m/^\[Desktop Entry\] */ )
+			push(@all_lines, $line);
+			if ( $line=~m/NoDisplay=true/ )
 			{
-				$is_desktop_entry = 1;
-				next;
+				$nodisplay = 1;
 			}
-			if ( ! $is_desktop_entry )
-			{
-				next;
-			}
-			if ( $line=~m/^\[.*\] */ )
-			{
-				$is_desktop_entry = 0;
-				next;
-			}
-			if( $line=~m/^Categories/i || $line=~m/^Name/i || $line=~m/^Terminal/i || $line=~m/^Comment/i ||  $line=~m/^Exec/i)
-			{
-				print $line;
-			}
-			if( $line =~ m/^Icon/ )
+		}
+		close(F);
+		
+		if ( $nodisplay == 0 )
+		{
+			print("<desktop>\n");
+			my $is_desktop_entry = 0;
+			my $line = '';
+			foreach $line (@all_lines)
 			{
-				my $icon=$line;
-				$icon =~ s/Icon=//;
-				chop($icon);
-				#$line is absolute path
-				if($icon =~ m/\//)
+				if ( $line=~m/^\[Desktop Entry\] */ )
+				{
+					$is_desktop_entry = 1;
+					next;
+				}
+				if ( ! $is_desktop_entry )
+				{
+					next;
+				}
+				if ( $line=~m/^\[.*\] */ )
 				{
-					$icon=$icon;
+					$is_desktop_entry = 0;
+					next;
 				}
-				#$line have format ext.
-				elsif ($line =~ m/\./)
+				if( $line=~m/^Categories/i || $line=~m/^Name/i || $line=~m/^Terminal/i || $line=~m/^Comment/i ||  $line=~m/^Exec/i)
 				{
-					$icon=findicon_ext($icon);
+					print $line;
 				}
-				else
+				if( $line =~ m/^Icon/ )
 				{
-					$icon=findicon($icon);
+					my $icon=$line;
+					$icon =~ s/Icon=//;
+					chop($icon);
+					#$line is absolute path
+					if($icon =~ m/\//)
+					{
+						$icon=$icon;
+					}
+					#$line have format ext.
+					elsif ($line =~ m/\./)
+					{
+						$icon=findicon_ext($icon);
+					}
+					else
+					{
+						$icon=findicon($icon);
+					}
+					printicon($icon);
 				}
-				printicon($icon);
 			}
+			print("</desktop>\n");
 		}
-		close (F);
-		print("</desktop>\n");
 	}
 	else
 	{

--------------070205030900000104070706--

