]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormToc.C
Bugfixes: checkboxes to radiobuttons (from J�rgen S) and remove a little
[lyx.git] / src / frontends / xforms / FormToc.C
index 2971305078bf91a8a11482088739722ddedba0f9..c165545e79cddb6eeac2e30d521bce06b46ae2c5 100644 (file)
  */
 
 #include <config.h>
-#include <vector>
 
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
+#include "FormToc.h"
 #include "xformsBC.h"
 #include "ControlToc.h"
-#include "FormToc.h"
 #include "form_toc.h"
 #include "helper_funcs.h" // getStringFromVector
 #include "support/lstrings.h" // frontStrip, strip
+#include "debug.h"
+#include "gettext.h"
+
+#include <vector>
+
+using std::endl;
 
 
 typedef FormCB<ControlToc, FormDB<FD_form_toc> > base_class;
@@ -53,13 +58,18 @@ void FormToc::update()
 }
 
 
-ButtonPolicy::SMInput FormToc::input(FL_OBJECT *, long)
+ButtonPolicy::SMInput FormToc::input(FL_OBJECT * ob, long)
 {
+       if (ob != dialog_->choice_toc_type) {
+               updateType();
+       }
        updateContents();
 
        unsigned int const choice = fl_get_browser( dialog_->browser_toc );
-       if (0 < choice && choice - 1 < toclist_.size()) {
-               controller().Goto(toclist_[choice-1].par->id());
+
+       if (choice - 1 < toclist_.size() && choice >= 1) {
+               controller().Goto(toclist_[choice - 1].par->id());
        }
 
        return ButtonPolicy::SMI_VALID;
@@ -68,6 +78,13 @@ ButtonPolicy::SMInput FormToc::input(FL_OBJECT *, long)
 
 void FormToc::updateType()
 {
+       // Update the choice list from scratch
+       fl_clear_choice(dialog_->choice_toc_type);
+       string const choice = getStringFromVector(controller().getTypes(), "|");
+       lyxerr << "choice " << choice << endl; 
+       fl_addto_choice(dialog_->choice_toc_type, choice.c_str());
+
+       // And select the correct one
        string const type = toc::getType(controller().params().getCmdName());
        
        fl_set_choice(dialog_->choice_toc_type, 1);
@@ -86,11 +103,25 @@ void FormToc::updateType()
 
 void FormToc::updateContents()
 {
-       string const type =
-               frontStrip(strip(fl_get_choice_text(dialog_->choice_toc_type)));
+       char const * tmp = fl_get_choice_text(dialog_->choice_toc_type);
+       if (!tmp) {
+               fl_clear_browser(dialog_->browser_toc);
+               fl_add_browser_line(dialog_->browser_toc,
+                                   _("*** No Lists ***"));
+               return;
+       }
+       string const type = frontStrip(strip(tmp));
 
        Buffer::SingleList const contents = controller().getContents(type);
 
+       if (contents.empty()) {
+               fl_clear_browser(dialog_->browser_toc);
+               fl_add_browser_line(dialog_->browser_toc,
+                                   _("*** No Lists ***"));
+       }
+       
        // Check if all elements are the same.
        if (toclist_ == contents) {
                return;