+void FormDocument::branch_input(FL_OBJECT * ob)
+{
+ BufferParams & params = controller().params();
+ std::vector<string> vec;
+
+ if (ob == branch_->button_add_branch) {
+ string new_branch = fl_get_input(branch_->input_all_branches);
+ if (!new_branch.empty()) {
+ params.branchlist.add(new_branch);
+ fl_set_input(branch_->input_all_branches, "");
+ // Update branch list
+ string const all_branches = params.branchlist.allBranches();
+ fl_clear_browser(branch_->browser_all_branches);
+ vec = getVectorFromString(all_branches, "|");
+ for (unsigned i = 0; i < vec.size(); ++i) {
+ fl_addto_browser(branch_->browser_all_branches,
+ vec[i].c_str());
+ }
+ LColor::color c = static_cast<LColor::color>(lcolor.size());
+ lcolor.fill(c, new_branch, lcolor.getX11Name(LColor::background));
+ }
+
+ } else if (ob == branch_->button_remove_branch) {
+ unsigned i = fl_get_browser(branch_->browser_all_branches);
+ string const current_branch =
+ fl_get_browser_line(branch_->browser_all_branches, i);
+ if (!current_branch.empty()) {
+ params.branchlist.remove(current_branch);
+ // Update branch list
+ string const all_branches = params.branchlist.allBranches();
+ fl_clear_browser(branch_->browser_all_branches);
+ vec = getVectorFromString(all_branches, "|");
+ for (unsigned i = 0; i < vec.size(); ++i) {
+ fl_addto_browser(branch_->browser_all_branches,
+ vec[i].c_str());
+ }
+ // Update selected-list...
+ string const all_selected = params.branchlist.allSelected();
+ fl_clear_browser(branch_->browser_selection);
+ vec = getVectorFromString(all_selected, "|");
+ for (unsigned i = 0; i < vec.size(); ++i) {
+ fl_addto_browser(branch_->browser_selection, vec[i].c_str());
+ }
+ }
+ } else if (ob == branch_->button_select) {
+ unsigned i = fl_get_browser(branch_->browser_all_branches);
+ string const current_branch =
+ fl_get_browser_line(branch_->browser_all_branches, i);
+ if (!current_branch.empty()) {
+ fl_clear_browser(branch_->browser_selection);
+ params.branchlist.setSelected(current_branch, true);
+ string const all_selected = params.branchlist.allSelected();
+ vec = getVectorFromString(all_selected, "|");
+ for (unsigned i = 0; i < vec.size(); ++i) {
+ fl_addto_browser(branch_->browser_selection,
+ vec[i].c_str());
+ }
+ }
+ } else if (ob == branch_->button_deselect) {
+ unsigned i = fl_get_browser(branch_->browser_selection);
+ string const current_sel =
+ fl_get_browser_line(branch_->browser_selection, i);
+ if (!current_sel.empty()) {
+ fl_clear_browser(branch_->browser_selection);
+ params.branchlist.setSelected(current_sel, false);
+ string const all_selected = params.branchlist.allSelected();
+ vec = getVectorFromString(all_selected, "|");
+ for (unsigned i = 0; i < vec.size(); ++i) {
+ fl_addto_browser(branch_->browser_selection,
+ vec[i].c_str());
+ }
+ }
+ } else if (ob == branch_->button_modify) {
+ unsigned i = fl_get_browser(branch_->browser_all_branches);
+ string const current_branch =
+ fl_get_browser_line(branch_->browser_all_branches, i);
+
+ RGBColor before;
+ string x11hexname = params.branchlist.getColor(current_branch);
+ if (x11hexname[0] == '#') {
+ before = RGBColor(x11hexname);
+ } else{
+ fl_getmcolor(FL_COL1, &before.r, &before.g, &before.b);
+ }
+
+ RGBColor col = picker_->requestColor(before);
+ if (before != col) {
+ fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
+ fl_redraw_object(branch_->button_color);
+ // Figure out here how to stash the new colour into the
+ // LyX colour database.
+
+ x11hexname = X11hexname(col);
+
+ // current_branch already in database
+ LColor::color c = lcolor.getFromLyXName(current_branch);
+ lcolor.setColor(current_branch, x11hexname);
+ // Make sure that new colour is also displayed ;-)
+ lyxColorHandler->getGCForeground(c);
+ lyxColorHandler->updateColor(c);
+ // what about system_lcolor?
+ // Here set colour in BranchList:
+ params.branchlist.setColor(current_branch, x11hexname);
+ }
+ } else if (ob == branch_->browser_all_branches) {
+ unsigned i = fl_get_browser(branch_->browser_all_branches);
+ string const current_branch =
+ fl_get_browser_line(branch_->browser_all_branches, i);
+ // make button_color track selected branch:
+
+ RGBColor rgb;
+ string x11hexname = params.branchlist.getColor(current_branch);
+ if (x11hexname[0] == '#') {
+ rgb = RGBColor(x11hexname);
+ } else {
+ fl_getmcolor(FL_COL1, &rgb.r, &rgb.g, &rgb.b);
+ }
+ fl_mapcolor(GUI_COLOR_CHOICE, rgb.r, rgb.g, rgb.b);
+ fl_redraw_object(branch_->button_color);
+ }
+ setEnabled(branch_->button_select,
+ (fl_get_browser(branch_->browser_all_branches) > 0));
+ setEnabled(branch_->button_deselect,
+ (fl_get_browser(branch_->browser_selection) > 0));
+ setEnabled(branch_->button_remove_branch,
+ (fl_get_browser(branch_->browser_all_branches) > 0));
+ setEnabled(branch_->button_modify,
+ (fl_get_browser(branch_->browser_all_branches) > 0));
+
+ branchlist_ = params.branchlist;
+}
+
+