]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBranch.C
The std::string mammoth path.
[lyx.git] / src / frontends / xforms / FormBranch.C
1 /**
2  * \file FormBranch.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Martin Vermeer
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11
12 #include <config.h>
13
14 #include "FormBranch.h"
15 #include "ControlBranch.h"
16 #include "forms/form_branch.h"
17
18 #include "xformsBC.h"
19
20 #include "insets/insetbranch.h"
21
22 #include "lyx_forms.h"
23
24
25 using std::string;
26
27
28 typedef FormController<ControlBranch, FormView<FD_branch> > base_class;
29
30 FormBranch::FormBranch(Dialog & parent)
31         : base_class(parent, _("Branch"))
32 {}
33
34
35 void FormBranch::build()
36 {
37         string all_branches(controller().params().branchlist.allBranches());
38
39         dialog_.reset(build_branch(this));
40
41         fl_addto_choice(dialog_->choice_branch, all_branches.c_str());
42
43         bcview().setOK(dialog_->button_ok);
44         bcview().setApply(dialog_->button_apply);
45         bcview().setCancel(dialog_->button_cancel);
46 }
47
48
49 void FormBranch::update()
50 {
51         // Make changes in all_branches propagate within session:
52         string all_branches(controller().params().branchlist.allBranches());
53         fl_clear_choice(dialog_->choice_branch);
54         fl_addto_choice(dialog_->choice_branch, all_branches.c_str());
55
56         string branch(controller().params().branch);
57         if (all_branches.find(branch) != string::npos && branch != "none")
58                 fl_set_choice_text(dialog_->choice_branch, branch.c_str());
59 }
60
61
62 void FormBranch::apply()
63 {
64         string const type = fl_get_choice_text(dialog_->choice_branch);
65
66         controller().params().branch = type;
67 }