]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/gtk/GGraphics.C
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / gtk / GGraphics.C
index 1e4c56d446f162e8082b441dade3d2585b77ca62..9fba9d0b29c7999dc2848b90566324d55f5e2e9d 100644 (file)
 
 #include <config.h>
 
+// Too hard to make concept checks work with this file
+#ifdef _GLIBCPP_CONCEPT_CHECKS
+#undef _GLIBCPP_CONCEPT_CHECKS
+#endif
+
 #include "GGraphics.h"
 #include "ControlGraphics.h"
 
@@ -192,18 +197,6 @@ void GGraphics::doBuild()
        // Store the identifiers for later
        origins_ = getSecond(origindata);
        PopulateComboBox(origincombo_, getFirst(origindata));
-
-       // set the right default unit
-       switch (lyxrc.default_papersize) {
-               case PAPER_DEFAULT: break;
-               case PAPER_USLETTER:
-               case PAPER_LEGALPAPER:
-               case PAPER_EXECUTIVEPAPER: defaultUnit = "in"; break;
-               case PAPER_A3PAPER:
-               case PAPER_A4PAPER:
-               case PAPER_A5PAPER:
-               case PAPER_B5PAPER: defaultUnit = "cm"; break;
-       }
 }
 
 
@@ -239,28 +232,6 @@ void GGraphics::PopulateComboBox(Gtk::ComboBox * combo,
 }
 
 
-void GGraphics::updateComboFromLength(Gtk::ComboBox * combo,
-                            LyXLength const & len)
-{
-       string unit = stringFromUnit(len.unit());
-       if (unit.empty())
-               unit = defaultUnit;
-
-       Gtk::TreeModel::iterator it = combo->get_model()->children().begin();
-       Gtk::TreeModel::iterator end = combo->get_model()->children().end();
-       for (; it != end ; ++it) {
-               if ((*it)[stringcol_] == unit) {
-                       combo->set_active(it);
-                       return;
-               }
-       }
-       // Fallen through, we didn't find the target length!
-       combo->set_active(0);
-       lyxerr << "GGraphics::updateComboFromLength: couldn't find "
-               "target unit '" << unit << "'\n";
-}
-
-
 void GGraphics::apply()
 {
        // Create the parameters structure and fill the data from the dialog.
@@ -368,6 +339,9 @@ void GGraphics::apply()
 
 
 void GGraphics::update() {
+       // set the right default unit
+       defaultUnit = getDefaultUnit();
+
        // Update dialog with details from inset
        InsetGraphicsParams & igp = controller().params();
 
@@ -397,9 +371,11 @@ void GGraphics::update() {
 
        outputscalespin_->get_adjustment()->set_value(igp.scale);
        widthspin_->get_adjustment()->set_value(igp.width.value());
-       updateComboFromLength(widthunitscombo_, igp.width);
+       unitsComboFromLength(widthunitscombo_, stringcol_,
+                            igp.width, defaultUnit);
        heightspin_->get_adjustment()->set_value(igp.height.value());
-       updateComboFromLength(heightunitscombo_, igp.height);
+       unitsComboFromLength(heightunitscombo_, stringcol_,
+                            igp.height, defaultUnit);
 
        if (!float_equal(igp.scale, 0.0, 0.05)) {
                // scaling sizing mode
@@ -470,7 +446,8 @@ void GGraphics::updateBB(string const & filename, string const & bb_inset)
                        righttopxspin_->set_text("");
                        righttopyspin_->set_text("");
                }
-               updateComboFromLength(bbunitscombo_,LyXLength("bp"));
+               unitsComboFromLength(bbunitscombo_, stringcol_,
+                                    LyXLength("bp"), defaultUnit);
        } else {
                // get the values from the inset
                lyxerr[Debug::GRAPHICS]
@@ -480,7 +457,7 @@ void GGraphics::updateBB(string const & filename, string const & bb_inset)
                LyXLength anyLength;
                anyLength = LyXLength(token(bb_inset, ' ', 0));
 
-               updateComboFromLength(bbunitscombo_, anyLength);
+               unitsComboFromLength(bbunitscombo_, stringcol_, anyLength, defaultUnit);
 
                leftbottomxspin_->get_adjustment()->set_value(anyLength.value());
 
@@ -533,7 +510,8 @@ void GGraphics::onBBFromFileClicked()
                        leftbottomyspin_->set_text(token(bb, ' ', 1));
                        righttopxspin_->set_text(token(bb, ' ', 2));
                        righttopyspin_->set_text(token(bb, ' ', 3));
-                       updateComboFromLength(bbunitscombo_,LyXLength("bp"));
+                       unitsComboFromLength(bbunitscombo_, stringcol_,
+                                            LyXLength("bp"), defaultUnit);
                }
                controller().bbChanged = false;
        } else {
@@ -541,7 +519,8 @@ void GGraphics::onBBFromFileClicked()
                leftbottomyspin_->set_text("");
                righttopxspin_->set_text("");
                righttopyspin_->set_text("");
-               updateComboFromLength(bbunitscombo_,LyXLength("bp"));
+               unitsComboFromLength(bbunitscombo_, stringcol_,
+                                    LyXLength("bp"), defaultUnit);
        }
        bc().input(ButtonPolicy::SMI_VALID);
 }