]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBranch.C
Change glob() API to accept a dir parameter.
[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 "forms/form_branch.h"
16 #include "xformsBC.h"
17
18 #include "BranchList.h"
19
20 #include "controllers/ControlBranch.h"
21
22 #include "insets/insetbranch.h"
23
24 #include "lyx_forms.h"
25
26 using std::string;
27
28 namespace lyx {
29 namespace frontend {
30
31
32 typedef FormController<ControlBranch, FormView<FD_branch> > base_class;
33
34 FormBranch::FormBranch(Dialog & parent)
35         : base_class(parent, _("Branch"))
36 {}
37
38
39 void FormBranch::build()
40 {
41         dialog_.reset(build_branch(this));
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         typedef BranchList::const_iterator const_iterator;
52
53         BranchList const & branchlist = controller().branchlist();
54         string const cur_branch = controller().params().branch;
55
56         fl_clear_choice(dialog_->choice_branch);
57
58         const_iterator const begin = branchlist.begin();
59         const_iterator const end = branchlist.end();
60         int id = 1;
61         int count = 1;
62         for (const_iterator it = begin; it != end; ++it, ++count) {
63                 string const & branch = it->getBranch();
64                 fl_addto_choice(dialog_->choice_branch, branch.c_str());
65
66                 if (cur_branch == branch)
67                         id = count;
68         }
69         fl_set_choice(dialog_->choice_branch, id);
70 }
71
72
73 void FormBranch::apply()
74 {
75         string const type = fl_get_choice_text(dialog_->choice_branch);
76         controller().params().branch = type;
77 }
78
79 } // namespace frontend
80 } // namespace lyx