]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GBranch.C
Extracted from r14281
[lyx.git] / src / frontends / gtk / GBranch.C
1 /**
2  * \file GBranch.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Bernhard Reiter
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
16 #endif
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
19 #endif
20
21 #include "GBranch.h"
22 #include "ControlBranch.h"
23
24 #include "BranchList.h"
25 #include "insets/insetbranch.h"
26
27 #include "ghelpers.h"
28
29 #include <libglademm.h>
30
31 using std::string;
32
33 namespace lyx {
34 namespace frontend {
35
36
37 GBranch::GBranch(Dialog & parent)
38         : GViewCB<ControlBranch, GViewGladeB>(parent, _("Branch Settings"), false)
39 {}
40
41
42 void GBranch::doBuild()
43 {
44         string const gladeName = findGladeFile("branch");
45         xml_ = Gnome::Glade::Xml::create(gladeName);
46
47         xml_->get_widget("Cancel", cancelbutton_);
48         setCancel(cancelbutton_);
49         xml_->get_widget("OK", okbutton_);
50         setOK(okbutton_);
51
52         Gtk::Box * box = NULL;
53         xml_->get_widget("innerbox", box);
54         box->pack_start(branchescombo_, true, true, 0);
55         box->show_all();
56
57         // Set shortcut target
58         xml_->get_widget("BranchesLabel", brancheslabel_);
59         brancheslabel_->set_mnemonic_widget(branchescombo_);
60
61         // Single click in branches list
62         branchescombo_.signal_changed().connect(
63                 sigc::mem_fun(*this, &GBranch::selection_changed));
64
65 }
66
67
68 void GBranch::update()
69 {
70         applylock_ = true;
71
72         typedef BranchList::const_iterator const_iterator;
73
74         BranchList const branchlist = controller().branchlist();
75         string const cur_branch = controller().params().branch;
76
77         // FIXME: deprecated in favor of clear_items since gtkmm 2.8
78         branchescombo_.clear();
79
80         const_iterator const begin = branchlist.begin();
81         const_iterator const end = branchlist.end();
82         for (const_iterator it = begin; it != end; ++it)
83                 branchescombo_.append_text(it->getBranch());
84         branchescombo_.set_active_text(cur_branch);
85
86         applylock_ = false;
87 }
88
89
90 void GBranch::apply()
91 {
92         controller().params().branch = branchescombo_.get_active_text();;
93 }
94
95
96 void GBranch::selection_changed()
97 {
98         if (!applylock_)
99                 bc().valid(true);
100 }
101
102
103 } // namespace frontend
104 } // namespace lyx