Author Topic: RunPerlCode Documentation  (Read 8448 times)

peedanee

  • Jr. Member
  • **
  • Posts: 20
    • View Profile
RunPerlCode Documentation
« on: May 28, 2012, 13:07:18 »
Hi, I'm new here.

Are there any RunPerlCode documentation of gmusicbrowser available?

I have problem when I try to make custom MenuItem which able to import files and folders and its subfolders to library.
Because RunPerlCode(::ChooseAddPath(0,1)) just won't do the trick.

Quentin Sculo

  • Administrator
  • Hero Member
  • *****
  • Posts: 1100
    • View Profile
Re: RunPerlCode Documentation
« Reply #1 on: May 28, 2012, 22:45:00 »
There is no documentation for RunPerlCode and there will never be, because it's just there in case the existing commands don't do what you need, and you really want to do it :)
I have allowed some, at least ::ChooseAddPath(0,1), in the included layouts, but I'll replace them once I finish the new command system that should allow many more things and in a much more organized way.
What do you want to do exactly ?

peedanee

  • Jr. Member
  • **
  • Posts: 20
    • View Profile
Re: RunPerlCode Documentation
« Reply #2 on: May 28, 2012, 23:45:53 »
Hi, Quentin.  :D

I was making customize layouts. The other parts was done except this particular one.
Please take a look at this part:
Code: [Select]
BMMenu  = (icon=gtk-preferences,size=large-toolbar) LayoutItem \
  MenuItem1(command="RunPerlCode(::ChooseAddPath(0,1))",label=_"Import to library") \
  MenuItem2(command="RunPerlCode(::IdleCheck)",label=_"Check Library") \
  MenuItem3(command="RunPerlCode(::IdleScan)",label=_"Rescan Library") \
  MenuItem4(command=OpenCustom(Equalizer),label=_"Show Equalizer") SeparatorMenuItem1 \
  MenuItem5(command=OpenPref,label=_"Preferences") SeparatorMenuItem2 \
  MenuItem6(command="RunPerlCode(::AboutDialog)",label=_"About")
I want MenuItem1 to be able to "import files/folders/subfolders" to library. ::ChooseAddPath(0,1) can't do that.  :'(
When I tried to find a way to do that I read gmusicbrowser command list, I thought "AddToLibrary" command can do that.
But I was clueless. (FYI I'm not programmer)
I'm glad if you could help me.
« Last Edit: May 29, 2012, 16:30:31 by peedanee »

Quentin Sculo

  • Administrator
  • Hero Member
  • *****
  • Posts: 1100
    • View Profile
Re: RunPerlCode Documentation
« Reply #3 on: May 29, 2012, 01:02:09 »
You probably want ::ChooseAddPath(1,1) it will add the files/folder you select to the library. (if the first argument is true it will add them to the library, second argument will allow selection of files if true.)

peedanee

  • Jr. Member
  • **
  • Posts: 20
    • View Profile
ReĀ : RunPerlCode Documentation
« Reply #4 on: May 29, 2012, 18:10:46 »
Thank you.  :)

But it's strange that ::ChooseAddPath(1,1) works on multiple folders only, I can't import single folder.

Please, care to take a look at my custom layout: NoisyBox . What do you think? :)

http://forum.gmusicbrowser.org/index.php?topic=605.0

Quentin Sculo

  • Administrator
  • Hero Member
  • *****
  • Posts: 1100
    • View Profile
Re: RunPerlCode Documentation
« Reply #5 on: May 30, 2012, 00:37:35 »
Quote
But it's strange that ::ChooseAddPath(1,1) works on multiple folders only, I can't import single folder.

I think the problem is that if "selecting files" are allowed (second "1" in arguments), double clicking on a folder opens it instead of selecting it. To import a folder you have to select it and then click ok.

peedanee

  • Jr. Member
  • **
  • Posts: 20
    • View Profile
Re: RunPerlCode Documentation
« Reply #6 on: May 30, 2012, 11:07:42 »
Still, the import only works when I select multiple folders then click OK.

When I select single folder then click OK, nothing happens.  :'(

Quentin Sculo

  • Administrator
  • Hero Member
  • *****
  • Posts: 1100
    • View Profile
Re: RunPerlCode Documentation
« Reply #7 on: May 31, 2012, 00:42:01 »
It works perfectly for me.
Can you run it from a terminal and look at its output after doing this ?
It should print a line by folder scanned : ScanFolder(...)

peedanee

  • Jr. Member
  • **
  • Posts: 20
    • View Profile
Re: RunPerlCode Documentation
« Reply #8 on: May 31, 2012, 13:38:57 »
I'm sorry, but I don't know how to run it from terminal.  :-[

I tried to run this:
Code: [Select]
gmusicbrowser -cmd RunPerlCode(::ChooseAddPath(1,1))
But I got this instead:
Code: [Select]
bash: syntax error near unexpected token `('

Quentin Sculo

  • Administrator
  • Hero Member
  • *****
  • Posts: 1100
    • View Profile
Re: RunPerlCode Documentation
« Reply #9 on: June 07, 2012, 00:44:08 »
Sorry I somehow missed your reply, I meant run gmb (not the command itself) from the terminal, and see the output.
If you want to run the command from the terminal, you have to use quotes :
Code: [Select]
gmusicbrowser -cmd 'RunPerlCode(::ChooseAddPath(1,1))'
Anyway, I found the bug after upgrading my system, it is a problem with recent gtk versions.
It is now fixed on git : http://git.gmusicbrowser.org/commit/901647d67c

peedanee

  • Jr. Member
  • **
  • Posts: 20
    • View Profile
Re: RunPerlCode Documentation
« Reply #10 on: June 08, 2012, 08:28:29 »
Oh, I'm sorry I didn't understand what you meant back then.  :-[

But I'm glad you found the bug.

I'm looking forward for the next release. :)
Thank you Quentin.