Bugfix for fvwm-menu-desktop if only one XDG menu exist

2013-09-12 Thread Thomas Funk

Hi Dan,

I've found a bug in fvwm-menu-desktop if only one xdg menu exists:
- no output appears with 'fvwm-menu-desktop --get-menus all|desktop'
- No entry "Regenerate XDG menu(s)" appears with
  'fvwm-menu-desktop --insert-in-menu MenuRoot'

Therefore the output in fvwm-menu-desktop-config.fpl is completely crappy.

Another problem was if an icon not found but the path was given convert
errors occur. Fixed this with a path check.

Also I have exchanged all Tabs with spaces to prevent indention errors
with the Python interpreter.

Attached is the patch for that.

Best,
Thomas
--- fvwm-menu-desktop.in	2013-09-12 13:09:49.0 +0200
+++ fvwm-menu-desktop.in.new	2013-09-12 13:21:57.186795229 +0200
@@ -114,7 +114,7 @@
 sys.exit(2)
 global verbose, force, size, theme, icon_dir, top, install_prefix, menu_type, menu_list_length 
 global with_titles, menu_entry_count, get_menus, timestamp, set_menus, printmode, insert_in_menu
-version = "2.2"
+version = "2.2.1"
 verbose = False
 force = False
 desktop=''
@@ -274,9 +274,9 @@
 vprint("\n DE weighting search: DE => [user menus, system menus, overall]")
 weight_dict = {}
 if desktop == '':
-		# first the desktops, then debian (shouldn't appear in others) then others holding
-		# all other non DE menus e.g. tools and at the end the nones without prefixes
-		# If there're other prefixes from other WMs - should be added BEFORE debian
+# first the desktops, then debian (shouldn't appear in others) then others holding
+# all other non DE menus e.g. tools and at the end the nones without prefixes
+# If there're other prefixes from other WMs - should be added BEFORE debian
 DEs = ['gnome', 'kde', 'xfce', 'lxde', 'cinnamon', 'mate', 'debian', 'others', 'none']
 else:
 DEs = [desktop]
@@ -298,9 +298,9 @@
 filled = True
 for name in menu_names:
 menus.add(path+'/'+name)
-# delete each found DE menu from the actual path. So, the menus will be reduced loop by loop.
+# delete each found DE menu from the actual path. So, the menus will be reduced loop by loop.
 menudict[path] = menudict[path]-set(menu_names)
-# count the menus found in the users and systems menu path for later weighting
+# count the menus found in the users and systems menu path for later weighting
 if not path == '/etc/xdg/menus':
 user_menus = len(menu_names)
 else:
@@ -308,7 +308,7 @@
 if filled:
 desktop_dict[de] = menus
 filled = False
-			# fill the weight dictionary with the counts
+# fill the weight dictionary with the counts
 weight_dict[de] = [user_menus, system_menus, user_menus+system_menus]
 vprint(" %s => %s" %(de, weight_dict[de]))
 
@@ -326,18 +326,18 @@
 highest_user = weight_dict[de_highest][0]
 highest_system = weight_dict[de_highest][1]
 highest_total = weight_dict[de_highest][2]
-	# first compare the total counts
+# first compare the total counts
 if highest < de_total:
 higher = True
 elif highest == de_total:
-		# if the totals equal compare the users
+# if the totals equal compare the users
 if highest_user < de_user:
 higher = True
 elif highest_user == de_user:
-			# it the users equal compare the system menus
+# it the users equal compare the system menus
 if highest_system < de_system:
 higher = True
-			# if the systems equal the last wins
+# if the systems equal the last wins
 elif highest_system == de_system:
 higher = True # fixme, should be biunique. -but how? With atime?
 else:
@@ -352,8 +352,8 @@
 if desktop_dict.has_key('none'):
 for menu in desktop_dict['none']:
 name = menu.replace('.menu', '').split('/')
-		# the fnmatch.filter will be used to find NO match because then
-		# the menu is not in the list
+# the fnmatch.filter will be used to find NO match because then
+# the menu is not in the list
 found = fnmatch.filter(desktop_dict[de_highest], '*'+name[-1]+'*')
 if found == []:
 desktop_dict[de_highest].add(menu)
@@ -400,8 +400,12 @@
 if extension == '.svg':
 iconfile = iconfile.replace('.svg', '.png')
 
-os.system("if test \\( ! -f '%s' \\) -o \\( '%s' -nt '%s' \\) ; then convert '%s' -resize %i '%s

Re: Bugfix for fvwm-menu-desktop if only one XDG menu exist

2013-09-12 Thread Thomas Funk

Ouch! in line 144
+printmenu("$[gt.Regenerate XDG Menu(s)]", 
"system-software-update", "Module FvwmPerl -l 
fvwm-menu-desktop2-config.fpl" )


please delete the '2' in fvwm-menu-desktop2-config

Sorry ...

Am 12.09.2013 13:53, schrieb Thomas Funk:

Hi Dan,

I've found a bug in fvwm-menu-desktop if only one xdg menu exists:
- no output appears with 'fvwm-menu-desktop --get-menus all|desktop'
- No entry "Regenerate XDG menu(s)" appears with
   'fvwm-menu-desktop --insert-in-menu MenuRoot'

Therefore the output in fvwm-menu-desktop-config.fpl is completely crappy.

Another problem was if an icon not found but the path was given convert
errors occur. Fixed this with a path check.

Also I have exchanged all Tabs with spaces to prevent indention errors
with the Python interpreter.

Attached is the patch for that.

Best,
Thomas





Re: Bugfix for fvwm-menu-desktop if only one XDG menu exist

2013-09-12 Thread Dan Espen

Hmm, now everyone's top-posting.
I feel myself weakening.

I've been occupied, but I'll get to this.


Thomas Funk  writes:

> Ouch! in line 144
> +printmenu("$[gt.Regenerate XDG Menu(s)]",
> "system-software-update", "Module FvwmPerl -l 
> fvwm-menu-desktop2-config.fpl" )
>
> please delete the '2' in fvwm-menu-desktop2-config
>
> Sorry ...
>
> Am 12.09.2013 13:53, schrieb Thomas Funk:
>> Hi Dan,
>>
>> I've found a bug in fvwm-menu-desktop if only one xdg menu exists:
>> - no output appears with 'fvwm-menu-desktop --get-menus all|desktop'
>> - No entry "Regenerate XDG menu(s)" appears with
>>'fvwm-menu-desktop --insert-in-menu MenuRoot'
>>
>> Therefore the output in fvwm-menu-desktop-config.fpl is completely crappy.
>>
>> Another problem was if an icon not found but the path was given convert
>> errors occur. Fixed this with a path check.
>>
>> Also I have exchanged all Tabs with spaces to prevent indention errors
>> with the Python interpreter.
>>
>> Attached is the patch for that.
>>
>> Best,
>> Thomas
>
>
>
>

-- 
Dan Espen



Re: Bugfix for fvwm-menu-desktop if only one XDG menu exist

2013-09-12 Thread Thomas Funk

Dan Espen wrote:


Hmm, now everyone's top-posting.

Sorry for that. I was too fast and have forgotten it.

I feel myself weakening.

I've been occupied, but I'll get to this.

It doesn't greatly matter. Most systems has more than one Xdg menu.

Thomas



Re: Bugfix for fvwm-menu-desktop if only one XDG menu exist

2013-09-14 Thread Thomas Funk

Thomas Funk wrote:

Dan Espen wrote:


Hmm, now everyone's top-posting.

Sorry for that. I was too fast and have forgotten it.

I feel myself weakening.

I've been occupied, but I'll get to this.

It doesn't greatly matter. Most systems has more than one Xdg menu.

Thomas

I found another problem with unicode errors in menu names under XUbuntu. 
I will check this in the next time. So, forget the last patch. I will 
send a new one with the unicode error fix included.




Re: Bugfix for fvwm-menu-desktop if only one XDG menu exist

2013-09-14 Thread Dan Espen
Thomas Funk  writes:

> Hi Dan,
>
> I've found a bug in fvwm-menu-desktop if only one xdg menu exists:

I'd like to nominate Thomas Funk for CVS update access.
He meets all the criteria, he's been around a long time and
has contributed useful and well written patches.

If I don't get any negative feedback by Wednesday I'll notify Jason.

-- 
Dan Espen



Re: Bugfix for fvwm-menu-desktop if only one XDG menu exist

2013-09-14 Thread Thomas Adam
On 14 Sep 2013 15:27, "Dan Espen"  wrote:
>
> Thomas Funk  writes:
>
> > Hi Dan,
> >
> > I've found a bug in fvwm-menu-desktop if only one xdg menu exists:
>
> I'd like to nominate Thomas Funk for CVS update access.
> He meets all the criteria, he's been around a long time and
> has contributed useful and well written patches.
>
> If I don't get any negative feedback by Wednesday I'll notify Jason.i

I suppose so.

Thomas


Re: Bugfix for fvwm-menu-desktop if only one XDG menu exist

2013-09-14 Thread michel dominique





On sam. 14/09/13 16:41 , Thomas Funk  wrote:

> Thomas Funk wrote:
> > Dan Espen wrote:
> >>
> >> Hmm, now everyone's top-posting.
> > Sorry for that. I was too fast and have forgotten it.
> >> I feel myself weakening.
> >>
> >> I've been occupied, but I'll get to this.
> > It doesn't greatly matter. Most systems has more than one Xdg menu.

Until a certain extend. I think many experimented fvwm users will install
a minimum system, and will not get more than 1 or 2 xdg menus.

Also, many distributions don't have their own menu system like debian,
so the chances are big they will get only 1 xdg menu with a minimum
install.

> >
> > Thomas
> >
> I found another problem with unicode errors in menu names under XUbuntu. 
> I will check this in the next time. So, forget the last patch. I will 
> send a new one with the unicode error fix included.
> 
> 
> 



Re: Bugfix for fvwm-menu-desktop if only one XDG menu exist

2013-09-14 Thread michel dominique





On sam 14/09/13 19:56 , michel dominique  wrote:

> On sam. 14/09/13 16:41 , Thomas Funk  wrote:
> 
> > Thomas Funk wrote:
> > > Dan Espen wrote:
> > >>
> > >> Hmm, now everyone's top-posting.
> > > Sorry for that. I was too fast and have forgotten it.
> > >> I feel myself weakening.
> > >>
> > >> I've been occupied, but I'll get to this.
> > > It doesn't greatly matter. Most systems has more than one Xdg menu.
> 
> Until a certain extend. I think many experimented fvwm users will install
> a minimum system, and will not get more than 1 or 2 xdg menus.
> 
> Also, many distributions don't have their own menu system like debian,
> so the chances are big they will get only 1 xdg menu with a minimum
> install.

It is even worst, on a fresh gentoo install, with only fvwm, fvwm-crystal,
xorg-server, stalonetray, mc and rxvt-unicode, I get no xdg menu file at all.

It is also another issue. No xdg.menu file implementation I know are
supporting well the additional freedesktop categories. As example, In the
Multimedia categories, you get 3 main categories and no additional categories
in most distributions, which is a shame.

On Debian, I experimented a little bit with xfce by modifying its menu file 
in /etc/xdg/menus

With the following, I get the Multimedia menu with 3 sub-menus, Audio,
Video and AudioVideo. Video and AudioVideo are not changed at that time,
but in Audio, I get automatically sub-menus for all the supported
additional categories, and the programs without additional categories
are in the Audio main submenu. So for me, that's perfect. It is a
maintenance free menu out of the box for most users.


Multimedia


Audio

Audio


HamRadio
Midi
Mixer
Sequencer
AudioVideoEditing
Player
Recorder


HamRadio

HamRadio



Midi

Midi



Mixer

Mixer



Sequencer

Sequencer



AudioVideoEditing

AudioVideoEditing



Player

Player



Recorder

Recorder




Video

Video



AudioVideo>

AudioVideo




For now, this is just a prove of concept. This have to be extended to all
the other main categories. Eventually, files can be provided into 
/usr/share/desktop-directories for automatic translation. I commented
it because otherwise all the sub-menus are named Multimedia, so
files must be provided if we want to support the Directory tag.

Can someone test it and report how it work with fvwm. If it work fine,
it will be something to add to fvwm, because it will make its application
menu to work out of the box with support for the additional categories
and in any distributions. If it work as I expect, it will be worth to add a
--desktop fvwm option to fvwm-menu-desktop.


> 
> > >
> > > Thomas
> > >
> > I found another problem with unicode errors in menu names under XUbuntu.
> 
> > I will check this in the next time. So, forget the last patch. I will 
> > send a new one with the unicode error fix included.
> > 
> > 
> > 
> 
> 
> 



Re: Bugfix for fvwm-menu-desktop if only one XDG menu exist

2013-09-14 Thread michel dominique





On dim 15/09/13 01:02 , michel dominique  wrote:

> On sam 14/09/13 19:56 , michel dominique  wrote:
> 
> > On sam. 14/09/13 16:41 , Thomas Funk wrote:
> > 
> > > Thomas Funk wrote:
> > > > Dan Espen wrote:
> > > >>
> > > >> Hmm, now everyone's top-posting.
> > > > Sorry for that. I was too fast and have forgotten it.
> > > >> I feel myself weakening.
> > > >>
> > > >> I've been occupied, but I'll get to this.
> > > > It doesn't greatly matter. Most systems has more than one Xdg menu.
> > 
> > Until a certain extend. I think many experimented fvwm users will
> install
> > a minimum system, and will not get more than 1 or 2 xdg menus.
> > 
> > Also, many distributions don't have their own menu system like debian,
> > so the chances are big they will get only 1 xdg menu with a minimum
> > install.
> 
> It is even worst, on a fresh gentoo install, with only fvwm, fvwm-crystal,
> xorg-server, stalonetray, mc and rxvt-unicode, I get no xdg menu file at
> all.
> 
> It is also another issue. No xdg.menu file implementation I know are
> supporting well the additional freedesktop categories. As example, In the
> Multimedia categories, you get 3 main categories and no additional
> categories
> in most distributions, which is a shame.
> 
> On Debian, I experimented a little bit with xfce by modifying its menu
> file 
> in /etc/xdg/menus
> 
> With the following, I get the Multimedia menu with 3 sub-menus, Audio,
> Video and AudioVideo. Video and AudioVideo are not changed at that time,
> but in Audio, I get automatically sub-menus for all the supported
> additional categories, and the programs without additional categories
> are in the Audio main submenu. So for me, that's perfect. It is a
> maintenance free menu out of the box for most users.
> 
> Multimedia
> 
> Audio
> 
> Audio
> 
> HamRadio
> Midi
> Mixer
> Sequencer
> AudioVideoEditing
> Player
> Recorder
> 
> HamRadio
> 
> HamRadio
> 
> Midi
> 
> Midi
> 
> Mixer
> 
> Mixer
> 
> Sequencer
> 
> Sequencer
> 
> AudioVideoEditing
> 
> AudioVideoEditing
> 
> Player
> 
> Player
> 
> Recorder
> 
> Recorder
> 
> Video
> 
> Video
> 
> AudioVideo>
> 
> AudioVideo
> 
> For now, this is just a prove of concept. This have to be extended to all
> the other main categories. Eventually, files can be provided into 
> /usr/share/desktop-directories for automatic translation. I commented
> it because otherwise all the sub-menus are named Multimedia, so
> files must be provided if we want to support the Directory tag.
> 
> Can someone test it and report how it work with fvwm. If it work fine,
> it will be something to add to fvwm, because it will make its application
> menu to work out of the box with support for the additional categories
> and in any distributions. If it work as I expect, it will be worth to add
> a
> --desktop fvwm option to fvwm-menu-desktop.

I get it to work with fvwm. It work as well than in xfce.

> 
> > 
> > > >
> > > > Thomas
> > > >
> > > I found another problem with unicode errors in menu names under
> XUbuntu.
> > 
> > > I will check this in the next time. So, forget the last patch. I will 
> > > send a new one with the unicode error fix included.
> > > 
> > > 
> > > 
> > 
> > 
> > 
> 
> 
> 



Re: Bugfix for fvwm-menu-desktop if only one XDG menu exist

2013-09-15 Thread Thomas Funk

On 14/09/2013 15:41, Thomas Funk wrote:
> I found another problem with unicode errors in menu names under
> XUbuntu. I will check this in the next time. So, forget the last
> patch. I will send a new one with the unicode error fix included.

I have now fixed this problem.
The attached patch includes:
- if only one xdg menu exists:
- no output appears with 'fvwm-menu-desktop --get-menus all|desktop'
- No entry "Regenerate XDG menu(s)" appears with
   'fvwm-menu-desktop --insert-in-menu MenuRoot'

- if an icon not found but the path was given convert errors occur.
  Fixed this with a path check.

- if an converted icon exists the conversion process will be skipped to
  reduce progress time.

- if an DecodeEncodeError occurs in menu/menu entry/file path it will be
  encoded before printing.

- exchanged all Tabs with spaces to prevent indention errors with the
  Python interpreter.

> On sam 14/09/13 19:56 , michel dominique  wrote:
> Until a certain extend. I think many experimented fvwm users will
> install a minimum system, and will not get more than 1 or 2 xdg menus.
>
> Also, many distributions don't have their own menu system like debian,
> so the chances are big they will get only 1 xdg menu with a minimum
> install.
>
> It is even worst, on a fresh gentoo install, with only fvwm,
> fvwm-crystal, xorg-server, stalonetray, mc and rxvt-unicode, I get no
> xdg menu file at all.
>
> On Debian, I experimented a little bit with xfce by modifying its menu
> file in /etc/xdg/menus
>
> For now, this is just a prove of concept. This have to be extended to
> all the other main categories. Eventually, files can be provided into
> /usr/share/desktop-directories for automatic translation. I commented
> it because otherwise all the sub-menus are named Multimedia, so
> files must be provided if we want to support the Directory tag.

I looked into different applications.menu files and they look mostly the 
same. There're possibilities to implement a skeleton

aplications.menu:
1) this file exists in FVWM and will be copied into /etc/xdg/menus/ e.g.
   as 'fvwm-applications.menu'
2) I implement a function in fvwm-menu-desktop which creates a
   fvwm-applications.menu in /home//.config/menus. Also
   fvwm-menu-desktop-config.fpl has to be modified to set a creation
   flag and shows a fake menu until it is created.

I prefer 1) but this is only because the overhead to write a menu from
scratch will blow up fvwm-menu-desktop much (the complete xml file
structure must pictured in code).

What is the best? 1), 2) or ... 3) no fvwm-applications.menu
Feedback, please ^^
--- fvwm-menu-desktop.in	2013-09-12 13:09:49.0 +0200
+++ fvwm-menu-desktop.in.new	2013-09-15 18:05:09.074888400 +0200
@@ -2,6 +2,14 @@
  
 # Modification History
 
+# Changed on 15/09/13 by Thomas Funk:
+# Some Bugfixes:
+# - DecodeEncodeErrors in menu names
+# - no output appears with 'fvwm-menu-desktop --get-menus all|desktop'
+# - No entry "Regenerate XDG menu(s)" appears with
+#   'fvwm-menu-desktop --insert-in-menu MenuRoot'
+# -  exchange all tabs with spaces to prevent indention errors
+
 # Changed on 15/06/13 by Thomas Funk:
 # support for python-xdg > 0.19.
 # add gettext localization.
@@ -114,7 +122,7 @@
 sys.exit(2)
 global verbose, force, size, theme, icon_dir, top, install_prefix, menu_type, menu_list_length 
 global with_titles, menu_entry_count, get_menus, timestamp, set_menus, printmode, insert_in_menu
-version = "2.2"
+version = "2.3"
 verbose = False
 force = False
 desktop=''
@@ -274,9 +282,9 @@
 vprint("\n DE weighting search: DE => [user menus, system menus, overall]")
 weight_dict = {}
 if desktop == '':
-		# first the desktops, then debian (shouldn't appear in others) then others holding
-		# all other non DE menus e.g. tools and at the end the nones without prefixes
-		# If there're other prefixes from other WMs - should be added BEFORE debian
+# first the desktops, then debian (shouldn't appear in others) then others holding
+# all other non DE menus e.g. tools and at the end the nones without prefixes
+# If there're other prefixes from other WMs - should be added BEFORE debian
 DEs = ['gnome', 'kde', 'xfce', 'lxde', 'cinnamon', 'mate', 'debian', 'others', 'none']
 else:
 DEs = [desktop]
@@ -298,9 +306,9 @@
 filled = True
 for name in menu_names:
 menus.add(path+'/'+name)
-# delete each found DE menu from the actual path. So, the menus will be reduced loop by loop.
+# delete each found DE menu from the actual path. So, the menus will be reduced loop by loop.
 menudict[path] = menudict[path]-set(menu_names)
-# count the menus found in the users and systems menu path for later weighting
+# count the menus found in the users and systems menu path for later weighting