Re: FVWM: howto conditionally add menu entries?

2019-08-02 Thread Stuart Longland
On 3/8/19 1:56 pm, hw wrote:
> If I was to write some program to create the root menu, I would always
> need to modify the program when new optional configurations are to be
> added so it could recognize them.  That is something I would prefer to
> avoid.

Well no, the program will need to store its state somewhere, and have
that state updated so that next time it is called by FVWM, its output
reflects the new state.
-- 
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
  ...it's backed up on a tape somewhere.



Re: FVWM: howto conditionally add menu entries?

2019-08-02 Thread hw
Dan Espen  writes:

> hw  writes:
>
>> Hi,
>>
>> how can I conditionally add menu entries?  For example:
>>
>>
>> [...]
>> Read fvwm-functions-starters-common.fvwm
>> Read fvwm-functions-starters-games.fvwm quiet
>> Read fvwm-functions-starters-local.fvwm quiet
>> [...]
>>
>>
>> DestroyMenu Main
>> AddToMenu Main
>> + "Main"Title
>> + "Common"  PopUp Common
>> + "Games"   PopUp Games
>> + "Local"   PopUp Local
>>
>>
>> I want the "Common" and "Games" entries in the menu only when the files
>> defining them (like fvwm-functions-starters-games.fvwm) can be read.
>>
>> I thought I could use something like
>>
>> DestroyMenu Main
>> AddToMenu Main
>> + Test (f fvwm-functions-starters-games.fvwm) AddToMenu Main "Games" PopUp 
>> Games
>>
>>
>> and that doesn't work in that the menu entry doesn't show up regardless
>> of the existance of the file.  There doesn't seem to be a way to test
>> whether something is defined or not; if there was, I could test if a
>> menu has been defined and only then add it to another menu.
>
> Try PipeRead.  Use shell, Perl, Python, your choice.

How would that work?  I'm trying to make a kinda dynamic configuration,
meaning that there is supposed to be a basic configuration accompanied
by optional configurations.  An optional configuration needs to make an
entry for its sub-menu into the root menu if the optional configuration
is available.

If I was to write some program to create the root menu, I would always
need to modify the program when new optional configurations are to be
added so it could recognize them.  That is something I would prefer to
avoid.

Hm, having that said, I can make it so that the optional configurations
add themselves to the root menu.  All they need is a line like


AddToMenu Main "Games" PopUp Games


Unfortunately, that raises the question how I can make it so that the
entries in the root menu appear in a desired order and with the title at
the top rather than somewhere in between the entries ...  Is there a way
to sort menu entries once no more entries are being added?

I'm probably not the first one to try this.  It can't be this difficult,
can it?



Re: FVWM: howto conditionally add menu entries?

2019-08-02 Thread hw
Thomas Adam  writes:

> On Fri, 2 Aug 2019 at 20:34, hw  wrote:
>> DestroyMenu Main
>> AddToMenu Main
>> + Test (f fvwm-functions-starters-games.fvwm) AddToMenu Main "Games" PopUp 
>> Games
>
> That's not going to work, because when the '+' command is run for a
> menu-context, the menu code doesn't understand/execute things like the
> 'Test' command.
>
> In your case, you need to wrap the menu definitions in a function:
>
> DestroyFunc foo
> AddToFunc.  foo
> + Test () AddToMenu .


AddToFunc StartFunction
+ Test (F fvwm-functions-starters-games.fvwm) AddToMenu Main "Games" PopUp Games


... doesn't work

However, I can't tell if the test is successful or not.  Yet


AddToFunc StartFunction
+ AddToMenu Main "Games" PopUp Games


... doesn't work, either.  Otherwise, how would I make sure that the
function that adds the menu entry is being exectued only once, and at
the right time?



Re: FVWM: howto conditionally add menu entries?

2019-08-02 Thread Thomas Adam
On Fri, 2 Aug 2019 at 20:34, hw  wrote:
> DestroyMenu Main
> AddToMenu Main
> + Test (f fvwm-functions-starters-games.fvwm) AddToMenu Main "Games" PopUp 
> Games

That's not going to work, because when the '+' command is run for a
menu-context, the menu code doesn't understand/execute things like the
'Test' command.

In your case, you need to wrap the menu definitions in a function:

DestroyFunc foo
AddToFunc.  foo
+ Test () AddToMenu .

-- Thomas Adam



Re: FVWM: howto conditionally add menu entries?

2019-08-02 Thread Dan Espen
hw  writes:

> Hi,
>
> how can I conditionally add menu entries?  For example:
>
>
> [...]
> Read fvwm-functions-starters-common.fvwm
> Read fvwm-functions-starters-games.fvwm quiet
> Read fvwm-functions-starters-local.fvwm quiet
> [...]
>
>
> DestroyMenu Main
> AddToMenu Main
> + "Main"Title
> + "Common"  PopUp Common
> + "Games"   PopUp Games
> + "Local"   PopUp Local
>
>
> I want the "Common" and "Games" entries in the menu only when the files
> defining them (like fvwm-functions-starters-games.fvwm) can be read.
>
> I thought I could use something like
>
> DestroyMenu Main
> AddToMenu Main
> + Test (f fvwm-functions-starters-games.fvwm) AddToMenu Main "Games" PopUp 
> Games
>
>
> and that doesn't work in that the menu entry doesn't show up regardless
> of the existance of the file.  There doesn't seem to be a way to test
> whether something is defined or not; if there was, I could test if a
> menu has been defined and only then add it to another menu.

Try PipeRead.  Use shell, Perl, Python, your choice.

-- 
Dan Espen



Re: FVWM: meaning of '+ I', '+ M', '+ D'?

2019-08-02 Thread hw
Dan Espen  writes:

> hw  writes:
>
>> Hi,
>>
>> what is the meaning of '+ I', '+ M', '+ D' when adding stuff to
>> functions or menues?  That doesn't seem to be explained in the man page
>> ...
>>
>> Why does '+ I' work and '+I' doesn't?
>
> The description of plus from the man page:
>
> +
> Used to continue adding to the last specified decor, function or menu.
> See the discussion for AddToDecor, AddToFunc, and AddToMenu. 
>
> So this lets you do:
>
> AddToFunc   ExecWarp
> + I $1
> + I Wait $0
> + I Warp $0
>
> which is the same as:
>
> AddToFunc ExecWarp I $1
> AddToFunc ExecWarp I Wait $0
> AddToFunc ExecWarp I Warp $0
>
> The reason "+I" is invalid, is because the "+" is a command and
> must be space separated from it's arguments.
>
> The letters are explained in the description of AddToFunc:
>
>   The letter before the action tells what kind of action triggers the
>   command which follows it. 'I' stands for "Immediate", and is executed as
>   soon as the function is invoked. 'M' stands for "Motion", i.e. if the
>   user starts moving the mouse. 'C' stands for "Click", i.e., if the user
>   presses and releases the mouse button. 'H' stands for "Hold", i.e. if
>   the user presses a mouse button and holds it down for more than
>   ClickTime milliseconds. 'D' stands for "Double-click". The action 'I'
>   causes an action to be performed on the button-press, if the function is
>   invoked with prior knowledge of which window to act on.
>
> These letters are only used in functions, menus have a different syntax.

Thanks!



FVWM: howto conditionally add menu entries?

2019-08-02 Thread hw
Hi,

how can I conditionally add menu entries?  For example:


[...]
Read fvwm-functions-starters-common.fvwm
Read fvwm-functions-starters-games.fvwm quiet
Read fvwm-functions-starters-local.fvwm quiet
[...]


DestroyMenu Main
AddToMenu Main
+ "Main"Title
+ "Common"  PopUp Common
+ "Games"   PopUp Games
+ "Local"   PopUp Local


I want the "Common" and "Games" entries in the menu only when the files
defining them (like fvwm-functions-starters-games.fvwm) can be read.

I thought I could use something like

DestroyMenu Main
AddToMenu Main
+ Test (f fvwm-functions-starters-games.fvwm) AddToMenu Main "Games" PopUp Games


and that doesn't work in that the menu entry doesn't show up regardless
of the existance of the file.  There doesn't seem to be a way to test
whether something is defined or not; if there was, I could test if a
menu has been defined and only then add it to another menu.