]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBranch.C
Get rid of trailing whitespace 'noise' in future patches for the
[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 typedef FormController<ControlBranch, FormView<FD_branch> > base_class;
26
27 FormBranch::FormBranch(Dialog & parent)
28         : base_class(parent, _("Branch"))
29 {}
30
31
32 void FormBranch::build()
33 {
34         string all_branches(controller().params().branchlist.allBranches());
35
36         dialog_.reset(build_branch(this));
37
38         fl_addto_choice(dialog_->choice_branch, all_branches.c_str());
39
40         bcview().setOK(dialog_->button_ok);
41         bcview().setApply(dialog_->button_apply);
42         bcview().setCancel(dialog_->button_cancel);
43 }
44
45
46 void FormBranch::update()
47 {
48         // Make changes in all_branches propagate within session:
49         string all_branches(controller().params().branchlist.allBranches());
50         fl_clear_choice(dialog_->choice_branch);
51         fl_addto_choice(dialog_->choice_branch, all_branches.c_str());
52
53         string branch(controller().params().branch);
54         if (all_branches.find(branch) != string::npos && branch != "none")
55                 fl_set_choice_text(dialog_->choice_branch, branch.c_str());
56 }
57
58
59 void FormBranch::apply()
60 {
61         string const type = fl_get_choice_text(dialog_->choice_branch);
62
63         controller().params().branch = type;
64 }
65