accessing project options in Export::register::build_config_ui

Added by Matthew Leingang about 6 years ago

Hello,

I am trying to write an export plugin. For the configuration GUI panel, I want to have a checkbox for the user to select a key from the names file. But I don't know how to access this file from the scope of the build_config_ui function.

Here is my non-working example:

  my $students_list = $project{'options'}->{'listeetudiants'};
  $students_list =~ s/%HOME/$ENV{'HOME'}/;
  my $names = AMC::NamesFile::new($students_list);
  for ($names->heads_for_keys) {
      $amc_key_cb->append_text($_);
  }
  $t->attach($amc_key_cb,1,$y,1,1);

I was kind of hoping that $project{'options"] would be in scope, since I see it in a lot of the .pl files. But this gives an error Use of uninitialized value $students_list in substitution (s///), which seems to indicate that $students_list is undef. So what's the right way to do this?


Replies (3)

RE: accessing project options in Export::register::build_config_ui - Added by Matthew Leingang about 6 years ago

OK, I have made some progress here, but still not finding it. I noticed that one of the arguments to the AMC::Export::register::build_config_gui is $prefs, an object of class AMC::Gui::Prefs. And prefs->{'config'} is an object of class AMC::Config. So it seems like project options should be in $prefs->{'config'}->{'project'}.

But after dumping that reference to the console, it seems $prefs->{'config'}->{'project'} is empty.

RE: accessing project options in Export::register::build_config_ui - Added by Alexis Bienvenüe about 6 years ago

For the configuration GUI panel, I want to have a checkbox for the user to select a key from the names file.

This would require an updating mechanism at times when the project is changed, or when the names file is changed or updated, that is currently not coded in AMC.
So I'm afraid you must use a plain entry widget for that, and check for validity while exporting.

RE: accessing project options in Export::register::build_config_ui - Added by Matthew Leingang about 6 years ago

Thanks for confirming that. After a couple more hours of poking around I came to the same conclusion. The register object doesn't know the name of the project.

The plugin I'm attempting isn't really for exporting anyway, so I'll probably figure out another way.

(1-3/3)