Re: First try of fvwm-menu-desktop which creates a full menu

2012-07-23 Thread Thomas Funk
2012/7/23 Dan Espen des...@verizon.net:
 I don't understand.
 If you do this:

  + I Test (f  $[FVWM_USERDIR]/.menu) Read $[FVWM_USERDIR]/.menu
  + I TestRC (!Match) PipeRead 'fvwm-menu-desktop --insert-in-menu MenuRoot \\
 $[FVWM_USERDIR]/.menu \\
 +   echo Read $[FVWM_USERDIR]/.menu'

 Then the menu only gets regenerated when the file
 $[FVWM_USERDIR]/.menu goes away.

 I don't see how that helps at all.
This is not the important part. With

AddToMenu MenuRoot Root Menu Title
+ FuncXdgMenusInRoot

you must restart because the root menu and the entry + FuncXdgMenusInRoot
generates a static menu. But if you use a dynamic root menu like this:
AddToMenu MenuRoot DynamicPopupAction FuncMenuRoot

DestroyFunc FuncMenuRoot
AddToFunc FuncMenuRoot
+ I DestroyMenu MenuRoot
+ I AddToMenu MenuRoot DynamicPopupAction FuncMenuRoot
+ I AddToMenu MenuRoot Root Menu Title
+ I Popup XdgMenus

and also a dynamic XdgMenus menu:

AddToMenu XdgMenus DynamicPopupAction FuncXdgMenusInRoot

DestroyFunc FuncXdgMenusInRoot
AddToFunc FuncXdgMenusInRoot
+ I DestroyMenu XdgMenus
+ I AddToMenu XdgMenus DynamicPopupAction FuncXdgMenusInRoot

then you can execute Regenerate menus without a restart. The trick is,
that Regenerate menus does a Read after execution of fvwm-menu-desktop.
so the new generated menu is instantly available if the user pops up the
root menu.

The two Test lines are only to guarantee that a .menu is red and if not
exist generated and red while poping up the root menu.

I gave a thought at night to the patch and discovered that the example with
+ FuncXdgMenusInRoot should be deleted because it shows a way the
user doesn't use anymore if he read the example below. Or should we let
it for the sake of completness?

Thomas



Re: First try of fvwm-menu-desktop which creates a full menu

2012-07-23 Thread Thomas Adam
On Mon, Jul 23, 2012 at 10:08:05AM +0200, Thomas Funk wrote:
 2012/7/23 Dan Espen des...@verizon.net:
  I don't understand.
  If you do this:
 
   + I Test (f  $[FVWM_USERDIR]/.menu) Read $[FVWM_USERDIR]/.menu
   + I TestRC (!Match) PipeRead 'fvwm-menu-desktop --insert-in-menu MenuRoot 
  \\
  $[FVWM_USERDIR]/.menu \\
  +   echo Read $[FVWM_USERDIR]/.menu'
 
  Then the menu only gets regenerated when the file
  $[FVWM_USERDIR]/.menu goes away.
 
  I don't see how that helps at all.
 This is not the important part. With
 
 AddToMenu MenuRoot Root Menu Title
 + FuncXdgMenusInRoot
 
 you must restart because the root menu and the entry + FuncXdgMenusInRoot
 generates a static menu. But if you use a dynamic root menu like this:
 AddToMenu MenuRoot DynamicPopupAction FuncMenuRoot

Don't destroy the same menu you're about to (re)create.

-- Thomas Adam



Re: First try of fvwm-menu-desktop which creates a full menu

2012-07-23 Thread Dan Espen
Thomas Funk t.funk...@googlemail.com writes:

 2012/7/23 Dan Espen des...@verizon.net:
 I don't understand.
 If you do this:

  + I Test (f  $[FVWM_USERDIR]/.menu) Read $[FVWM_USERDIR]/.menu
  + I TestRC (!Match) PipeRead 'fvwm-menu-desktop --insert-in-menu MenuRoot 
 \\
 $[FVWM_USERDIR]/.menu \\
 +   echo Read $[FVWM_USERDIR]/.menu'

 Then the menu only gets regenerated when the file
 $[FVWM_USERDIR]/.menu goes away.

 I don't see how that helps at all.
 This is not the important part. With

 AddToMenu MenuRoot Root Menu Title
 + FuncXdgMenusInRoot

 you must restart because the root menu and the entry + FuncXdgMenusInRoot
 generates a static menu. But if you use a dynamic root menu like this:
 AddToMenu MenuRoot DynamicPopupAction FuncMenuRoot

 DestroyFunc FuncMenuRoot
 AddToFunc FuncMenuRoot
 + I DestroyMenu MenuRoot
 + I AddToMenu MenuRoot DynamicPopupAction FuncMenuRoot
 + I AddToMenu MenuRoot Root Menu Title
 + I Popup XdgMenus

 and also a dynamic XdgMenus menu:

 AddToMenu XdgMenus DynamicPopupAction FuncXdgMenusInRoot

 DestroyFunc FuncXdgMenusInRoot
 AddToFunc FuncXdgMenusInRoot
 + I DestroyMenu XdgMenus
 + I AddToMenu XdgMenus DynamicPopupAction FuncXdgMenusInRoot

 then you can execute Regenerate menus without a restart. The trick is,
 that Regenerate menus does a Read after execution of fvwm-menu-desktop.
 so the new generated menu is instantly available if the user pops up the
 root menu.

 The two Test lines are only to guarantee that a .menu is red and if not
 exist generated and red while poping up the root menu.

 I gave a thought at night to the patch and discovered that the example with
 + FuncXdgMenusInRoot should be deleted because it shows a way the
 user doesn't use anymore if he read the example below. Or should we let
 it for the sake of completness?

Using --insert-in-menu MyMenu, I get this:

AddToMenu MyMenu
+ Kde4-applications Popup FvwmKde4-applications
+ Preferences Popup FvwmPreferences
+ Settings Popup FvwmSettings
+ Start-here Popup FvwmStart-here
+ System-settings Popup FvwmSystem-settings
+  Nop
+ Regenerate XDG Menu(s) Module FvwmPerl -l fvwm-menu-desktop-config.fpl


If I run this twice, MyMenu will have all these entries appended to
MyMenu twice.  I'd have to destroy the menu and recreate it to get any
other outcome.

-- 
Dan Espen



Re: First try of fvwm-menu-desktop which creates a full menu

2012-07-23 Thread Thomas Funk
Dan Espen des...@verizon.net wrote
Using --insert-in-menu MyMenu, I get this:

AddToMenu MyMenu
+ Kde4-applications Popup FvwmKde4-applications
+ Preferences Popup FvwmPreferences
+ Settings Popup FvwmSettings
+ Start-here Popup FvwmStart-here
+ System-settings Popup FvwmSystem-settings
+  Nop
+ Regenerate XDG Menu(s) Module FvwmPerl -l fvwm-menu-desktop-config.fpl

If I run this twice, MyMenu will have all these entries appended to
MyMenu twice. I'd have to destroy the menu and recreate it to get any
other outcome.
Can you post how you've implemented it in the MyMenu? If you've deleted
+ I DestroyMenu XdgMenus
because of my last email to Thomas then do it back. I have problems on my
VM with creating menus and must check this first. On my Debian system at
home all works fine with the new snippet.

Thomas



Re: First try of fvwm-menu-desktop which creates a full menu

2012-07-23 Thread Dan Espen
Thomas Funk t.funk...@googlemail.com writes:

 Dan Espen des...@verizon.net wrote
Using --insert-in-menu MyMenu, I get this:

AddToMenu MyMenu
+ Kde4-applications Popup FvwmKde4-applications
+ Preferences Popup FvwmPreferences
+ Settings Popup FvwmSettings
+ Start-here Popup FvwmStart-here
+ System-settings Popup FvwmSystem-settings
+  Nop
+ Regenerate XDG Menu(s) Module FvwmPerl -l fvwm-menu-desktop-config.fpl

If I run this twice, MyMenu will have all these entries appended to
MyMenu twice. I'd have to destroy the menu and recreate it to get any
other outcome.
 Can you post how you've implemented it in the MyMenu? If you've deleted
 + I DestroyMenu XdgMenus
 because of my last email to Thomas then do it back. I have problems on my
 VM with creating menus and must check this first. On my Debian system at
 home all works fine with the new snippet.

I typed in the command:

python fvwm-menu-desktop.in --insert-in-menu MyMenu

I then searched the output for MyMenu.
The lines above are the only references to MyMenu.

If I paste the lines above into FvwmTalk twice
and then enter PopUp MyMenu
I see a menu with all it's entries duplicated.

-- 
Dan Espen



Re: First try of fvwm-menu-desktop which creates a full menu

2012-07-23 Thread Thomas Funk

Dan Espen des...@verizon.net wrote:
 Thomas Funk t.funk...@googlemail.com writes:

 Dan Espen des...@verizon.net wrote
 Using --insert-in-menu MyMenu, I get this:

 AddToMenu MyMenu
 + Kde4-applications Popup FvwmKde4-applications
 + Preferences Popup FvwmPreferences
 + Settings Popup FvwmSettings
 + Start-here Popup FvwmStart-here
 + System-settings Popup FvwmSystem-settings
 +  Nop
 + Regenerate XDG Menu(s) Module FvwmPerl -l 
fvwm-menu-desktop-config.fpl


 If I run this twice, MyMenu will have all these entries appended to
 MyMenu twice. I'd have to destroy the menu and recreate it to get any
 other outcome.
 Can you post how you've implemented it in the MyMenu? If you've deleted
 + I DestroyMenu XdgMenus
 because of my last email to Thomas then do it back. I have problems 
on my

 VM with creating menus and must check this first. On my Debian system at
 home all works fine with the new snippet.
 I typed in the command:

 python fvwm-menu-desktop.in --insert-in-menu MyMenu

 I then searched the output for MyMenu.
 The lines above are the only references to MyMenu.

 If I paste the lines above into FvwmTalk twice
 and then enter PopUp MyMenu
 I see a menu with all it's entries duplicated.

Yes, that's correct cause no DestroyMenu MyMenu exists in the generated
menu. But that has to be. If you have a static/normal menu called
MyMenu then you create it like this in .config:

DestroyMenu MyMenu
AddToMenu   MyMenu
+ A_Title Title
+ Entry1 FuncSomething
+ Entry2 Popup SomeMenu

If you want to add something to MyMenu you do it like
AddToMenu MyMenu
+ Another_Entry1 Popup SomeOtherMenu
+ Another_App Exec exec foo

If you add this part again like you do with FvwmTalk you've duplicated
entries.

But if you use the dynamic example all works fine. I've added the patch
again but without + I DestroyMenu XdgMenus in FuncXdgMenusInRoot as
Thomas pointed out. Thanks Thomas :-)

Also a fixed fvwm-menu-desktop-config.fpl because there were some
missing double quotes (I don't know why they were absent ... shit happens)

Thomas




--- /media/daten/shared/sourcen/cvs/fvwm/bin/fvwm-menu-desktop.1.in	2012-07-22 12:25:57.772773990 +0200
+++ fvwm-menu-desktop.1	2012-07-23 22:31:40.817613594 +0200
@@ -86,9 +86,10 @@
 .IP \fB\-\-insert\-in\-menu\fR \fINAME\fR
 Option to insert generated menu(s) \fBIN\fR a menu \fINAME\fR (its
 top title).  Note that this 0ption does not work correctly with the
-Regnerate Menus menu entry since items insserted into a menu cannot be
-removed (currently).  If you use this option and want to update your menus,
-restart fvwm.
+Regnerate Menus menu entry in a normal built menu since items insserted 
+into such a menu cannot be removed (currently). If you use this option
+there and want to update your menus, you have to restart fvwm. A better
+way is to use dynamic menus (see the example in the USAGE section).
 
 .IP \fB\-\-get\-menus\fR \fIall\fR|\fIdesktop\fR
 Prints a space separated list of full menu paths. \fIall\fR is all menus
@@ -213,7 +214,8 @@
 .EE
 .RE
 
-or if you want to show the menus directly in the Root menu use this:
+or if you want to show the menus directly in a normal Root menu use
+this:
 
 .RS
 .EX
@@ -226,6 +228,32 @@
 + I Test (f  $[FVWM_USERDIR]/.menu) Read $[FVWM_USERDIR]/.menu
 + I TestRC (!Match) PipeRead 'fvwm-menu-desktop --insert-in-menu MenuRoot \\
$[FVWM_USERDIR]/.menu \\
+   echo Read $[FVWM_USERDIR]/.menu'
+.EE
+.RE
+
+The problem here is, that you have to restart fvwm because items insserted 
+into such a menu cannot be removed. For that BOTH menus must be dynamically:
+
+.RS
+.EX
+AddToMenu MenuRoot DynamicPopupAction FuncMenuRoot
+
+DestroyFunc FuncMenuRoot
+AddToFunc FuncMenuRoot
++ I DestroyMenu MenuRoot
++ I AddToMenu MenuRoot DynamicPopupAction FuncMenuRoot
++ I AddToMenu MenuRoot Root Menu Title
++ I Popup XdgMenus
+
+AddToMenu XdgMenus DynamicPopupAction FuncXdgMenusInRoot
+
+DestroyFunc FuncXdgMenusInRoot
+AddToFunc FuncXdgMenusInRoot
++ I AddToMenu XdgMenus DynamicPopupAction FuncXdgMenusInRoot
++ I Test (f  $[FVWM_USERDIR]/.menu) Read $[FVWM_USERDIR]/.menu
++ I TestRC (!Match) PipeRead 'fvwm-menu-desktop --insert-in-menu MenuRoot \\
+   $[FVWM_USERDIR]/.menu \\
echo Read $[FVWM_USERDIR]/.menu'
 .EE
 .RE
# This script generates a FvwmForm similar to the FvwmForm-Desktop by
# Dan Espen but insert the found xdg menus dynamically into the Form
# before processed.
# Author: Thomas Funk t.f...@web.de
# Version: 1.2

package MenuConfig;
use File::Basename;
use strict;
use warnings;

#open(MSG ,[path]/log.txt) || die Error $!;

my $all = `fvwm-menu-desktop --get-menus all`;
my $selected = `fvwm-menu-desktop --get-menus desktop`;

my @all_filelist = split(/ /,$all);
my @selected_filelist = split(/ /,$selected);

my %all_menus = ();
my %selected__menus = ();
my $max_length = 0;
foreach my $path (@selected_filelist) {
my ($filename,