]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBranch.C
The 'Branches' mega-patch.
[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 "xformsBC.h"
15 #include "ControlBranch.h"
16 #include "FormBranch.h"
17 #include "forms/form_branch.h"
18 #include "xforms_helpers.h" // formatted
19 #include "lyx_forms.h"
20 #include "insets/insetbranch.h"
21 #include "debug.h"
22
23 typedef FormController<ControlBranch, FormView<FD_branch> > base_class;
24
25 FormBranch::FormBranch(Dialog & parent)
26         : base_class(parent, _("Branch"))
27 {}
28
29
30 void FormBranch::build()
31 {
32         string all_branches(controller().params().branchlist.allBranches());
33
34         dialog_.reset(build_branch(this));
35
36         fl_addto_choice(dialog_->choice_branch, all_branches.c_str());
37         
38         bcview().setOK(dialog_->button_ok);
39         bcview().setApply(dialog_->button_apply);
40         bcview().setCancel(dialog_->button_cancel);
41 }
42
43
44 void FormBranch::update()
45 {
46         // Make changes in all_branches propagate within session:
47         string all_branches(controller().params().branchlist.allBranches());
48         fl_clear_choice(dialog_->choice_branch);
49         fl_addto_choice(dialog_->choice_branch, all_branches.c_str());
50
51         string branch(controller().params().branch);
52         if (all_branches.find(branch) != string::npos && branch != "none")
53                 fl_set_choice_text(dialog_->choice_branch, branch.c_str());
54 }
55
56
57 void FormBranch::apply()
58 {
59         string const type = fl_get_choice_text(dialog_->choice_branch);
60
61         controller().params().branch = type;
62 }
63