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

2012-07-25 Thread Thomas Funk

Thomas Adam tho...@fvwm.org wrote:
 On 25 July 2012 18:38, Thomas Funk t.f...@web.de wrote:
 Dan Espen wrote:
 Thomas Adam made some comments about using FvwmPerl.  Is that resolved?
 No -- and as such, until it starts to use perllib and/or FvwmPerl,
 it's not ready.  There is *no* reason why we wouldn't dog-food our own
 implementation of interfacing to FVWM, other than the individual
 developer concerned didn't understand it.  We _have_ a framework to do
 all of the functionality the code currently uses; it's high-time we
 use it.

 I've fixed all what Thomas suggested except the part to do the complete
 stuff with the perllib framework. That needs a little bit more time.
 But that's the entirety of this file, as far as I am concerned.  A
 pretty important part, too.

 I hope it is ok for Thomas that you want to commit it because it's only
 an interim solution.
 Until this is fixed, I would rather this wasn't put in CVS at all.  As
 I've mentioned my time is limited, but if I have to roll up my sleeves
 and take responsibility for this, I don't mind.  I'd rather not
 though, but either way, someone should let me know if I have to.

 Kindly,

 -- Thomas Adam

I would first like to say that it takes some time to understand your
writing. I am not a native English, so please forgive me if I haven't
understood it completely/correctly.

I am willing to do the job of rewriting it but I need help. If you could
take some of your spare time to give me hints and answer questions fairly
would be fine.

What I want to say is, that i want an open, honest and constructive
discussion about the programming and functionality of the module and not
RTFM - I do this every time before I asking.

So if you're willing to be a mentor in a sense I am ready to
programming it.

Kindly,

Thomas



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

2012-07-23 Thread Thomas Funk
2012/7/23 Thomas Adam tho...@fvwm.org:
 Don't destroy the same menu you're about to (re)create.
But if I don't destroy it it will be added again and again to
the root menu every time I pop it up ...



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

2012-07-23 Thread Thomas Funk
2012/7/23 Thomas Funk t.funk...@googlemail.com:
 2012/7/23 Thomas Adam tho...@fvwm.org:
 Don't destroy the same menu you're about to (re)create.
 But if I don't destroy it it will be added again and again to
 the root menu every time I pop it up ...
I've tested it on my VM and you're right! Is this because the
menu will built only once due to DynamicPopupAction?



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

2012-07-20 Thread Thomas Funk

Thomas Adam tho...@fvwm.org wrote:
 package Test;
 Will need better namespacing.
changed it to package MenuConfig;

 use File::Basename;
 use strict;
 use warnings;
added

 my $selected = `fvwm-menu-desktop --get-menus selected`;
 How long do these commands take to run in backticks?  If long, 
perhaps use

 IPC::Run?
marginal:
Backticks:
all menus: 0.63 s
selected menus: 0.29 s
both menus: 0.92 s

IPC::Run:
all menus: 0.62 s
all menus: 0.28 s
both menus: 0.90 s

Furthermore IPC::Run isn't installed by default and in older distributions
not available only on CPAN.

 my ($filename, $directories, $suffix) = fileparse($path, 
qr/\.[^.]*/);

 Why qr?
From perldoc: ... qr matched against the end of the $filename. The
matching portion is removed and becomes the $suffix.

 push (@{$all_menus{$directories}{$i}}, $filename);
 push (@{$all_menus{$directories}{$i}}, $name);
 push (@{$all_menus{$directories}{$i}}, off);
 push (@{...}, ($foo, $bar, hello));
changed

 if (exists $selected__menus{$directories}) {
  foreach my $hit (@{$selected__menus{$directories}}) {
 Better:

 foreach my $foo (...)
 {
 next if !defined $bar;
 ...
 }
changed

 You need to use FvwmPerl here for this.
In the next step with the module.
Btw. I altered the script from
ftp://ftp.fvwm.org/pub/fvwm/devel/sources/tests/perl/xmessage.fpl
and no, I don't reinvented the wheel as you see. Ok, it's not the
best way ... give me some time to put this in a correct module,
ok? But for now it is a usable approach. Or not?

Fixed script is attached.

@Dan:
I found a wrong typo in the manpage. Please change
Module FvwmPerl -l fvwm-menu-desktop-gui.fpl
to
Module FvwmPerl -l fvwm-menu-desktop-config.fpl

Thanks.
Thomas




# 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.1

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 selected`;

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, $directories, $suffix) = fileparse($path, qr/\.[^.]*/);
push (@{$selected__menus{$directories}}, $filename);
}

my $i = 1;
foreach my $path (@all_filelist) {
my $name = MEN . $i;
# qr matched against the end of the $filename. 
# The matching portion is removed and becomes the $suffix.
my ($filename, $directories, $suffix) = fileparse($path, qr/\.[^.]*/);
push (@{$all_menus{$directories}{$i}}, ($filename, $name, off));
next if !defined $selected__menus{$directories};
foreach my $hit (@{$selected__menus{$directories}}) {
 if ($filename eq $hit) {
 pop (@{$all_menus{$directories}{$i}});
 push (@{$all_menus{$directories}{$i}}, on);
 }
}
$max_length = length($filename) if ($max_length  length($filename));
$i++;
}

my $fvwmform_commands = 
DestroyModuleConfig  FvwmForm-Desktop: *
*FvwmForm-Desktop: WarpPointer
*FvwmForm-Desktop: Title\fvwm-menu-desktop options\
*FvwmForm-Desktop: Line center
*FvwmForm-Desktop: Text \-- Multiple Menu 
--\
*FvwmForm-Desktop: Line 
;

foreach my $key (sort( keys %all_menus)) {
$fvwmform_commands .= 
*FvwmForm-Desktop: Line left
*FvwmForm-Desktop: Text \Menus in $key\
*FvwmForm-Desktop: Line left
*FvwmForm-Desktop: Selection meth multiple
;
my $m_count = 0;
foreach my $count (sort(keys %{$all_menus{$key}})) {
my @menu = @{$all_menus{$key}{$count}};
my $newstring = $menu[0] . ' ' x eval($max_length-length($menu[0]));
$fvwmform_commands .= *FvwmForm-Desktop: Choice  $menu[1] $menu[1] 
$menu[2] \$newstring\
;
$m_count++;
if ($m_count == 3) {
$fvwmform_commands .= 
*FvwmForm-Desktop: Line left
*FvwmForm-Desktop: Selection meth multiple
;
$m_count = 0;
}
}
$fvwmform_commands .= 
*FvwmForm-Desktop: Line left
*FvwmForm-Desktop: Text \ \
;
}

$fvwmform_commands .= 
*FvwmForm-Desktop: Line center
*FvwmForm-Desktop: Text \-- General Options 
--\
*FvwmForm-Desktop: Line
*FvwmForm-Desktop: Line Left
*FvwmForm-Desktop: Text \Use Icons in Menus?   \
*FvwmForm-Desktop: SelectionSelItype single
*FvwmForm-Desktop: Choice   IconsOn  IconsOnon  \Yes\
*FvwmForm-Desktop: Choice   IconsOff IconsOff   off \No\

*FvwmForm-Desktop: Line left
*FvwmForm-Desktop: Text \Icon size:\
*FvwmForm-Desktop: InputSize 2 \\

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

2012-07-19 Thread Thomas Funk

Thomas Adam tho...@fvwm.org wrote:
 On 19 July 2012 22:11, Dan Espen des...@verizon.net wrote:
 I'm guessing the other fvwm developers are okay with going to asciidoc?
 No.  I have an attempt at this, but it's not finished.  We either use
 groff or nothing, and I don't mean groff backported from some
 conversion tool.  If you don't know groff, start learning.
Ok :S ... not as punishment - only as exercise

Btw I used asciidoc to show my thoughts and examples only not to
check in.

Thomas




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

2012-07-16 Thread Thomas Funk
2012/7/16 Thomas Adam tho...@fvwm.org wrote:
 Isn't this in the XDG spec as to which menus appear where, in
 categories?  I'm sure it is.
That's right. The process (the python-xdg lib) which generates the menus
follow this. But fvwm-menu-desktop only calls the methods for each menu
found in the system. The structure which sub menus appear per menu is hard
coded IN the xml menus not in the fvwm-menu-desktop code.

 One possibility could be to create the menus and then search for double
 entries, eliminate them and if a menu is empty delete it. But the actual

 No.  That's just admitting to not wanting to fix the problem.  :)
That hush me ^^

 In the next days I will present a fvwm-menu-desktop config tool based on
 FvwmPerl which shows all founded menus on the system and let the user
 decide which menu/menus she/he wants to create and how.

 That might be useful longer-term, but I think I'd rather see the
 basics of this menu generation working first of all.
The basics work - you can generate all menus, some of them, single ones.
Plus, the config tool is finished already. Needs only some tests ... On my
Debian all works. On Fedora also ...

Thomas