Code

Group dock related prefs, add hidden prefs for dock bar and switcher appearance.
[inkscape.git] / src / ui / widget / page-sizer.cpp
index ac622ba41a9800117ab965bdab036ec0b86bf165..7b0fea5f558fd8b91d0397b444762ec8c24a8841 100644 (file)
@@ -240,10 +240,12 @@ PageSizer::PageSizer() : Gtk::VBox(false,4)
     pack_start (_orientationBox, false, false, 0);
     _orientationLabel.set_label(_("Page orientation:")); 
     _orientationBox.pack_start(_orientationLabel, false, false, 0);
+    _landscapeButton.set_use_underline();
     _landscapeButton.set_label(_("_Landscape"));
        _landscapeButton.set_active(true);
     Gtk::RadioButton::Group group = _landscapeButton.get_group();
     _orientationBox.pack_end (_landscapeButton, false, false, 5);
+    _portraitButton.set_use_underline();
     _portraitButton.set_label(_("_Portrait"));
        _portraitButton.set_active(true);
     _orientationBox.pack_end (_portraitButton, false, false, 5);
@@ -259,6 +261,7 @@ PageSizer::PageSizer() : Gtk::VBox(false,4)
     _customTable.set_col_spacings (4);
     _customFrame.add(_customTable);
     
+    _fitPageButton.set_use_underline();
     _fitPageButton.set_label(_("_Fit page to selection"));
     _tips.set_tip(_fitPageButton, 
        _("Resize the page to fit the current selection, or the entire drawing if there is no selection"));
@@ -358,8 +361,7 @@ PageSizer::setDim (double w, double h, bool changeList)
     
     if (changeList)
         {
-        int index = find_paper_size(w, h);
-        Gtk::TreeModel::Row row = _paperSizeListStore->children()[index];
+        Gtk::TreeModel::Row row = (*find_paper_size(w, h));
         if (row)
             _paperSizeListSelection->select(row);
         }
@@ -379,10 +381,11 @@ PageSizer::setDim (double w, double h, bool changeList)
 
 
 /** 
- * Returns an index into paperSizeTable of a paper of the specified 
- * size (specified in px), or -1 if there's no such paper.
+ * Returns an iterator pointing to a row in paperSizeListStore which
+ * contains a paper of the specified size (specified in px), or 
+ * paperSizeListStore->children().end() if no such paper exists.
  */
-int
+Gtk::ListStore::iterator
 PageSizer::find_paper_size (double w, double h) const
 {
     double smaller = w;
@@ -391,9 +394,8 @@ PageSizer::find_paper_size (double w, double h) const
         smaller = h; larger = w;
     }
 
-    g_return_val_if_fail(smaller <= larger, -1);
+    g_return_val_if_fail(smaller <= larger, _paperSizeListStore->children().end());
     
-    int index = 0;
     std::map<Glib::ustring, PaperSize>::const_iterator iter;
     for (iter = _paperSizeTable.begin() ;
             iter != _paperSizeTable.end() ; iter++) {
@@ -402,15 +404,22 @@ PageSizer::find_paper_size (double w, double h) const
         double smallX = sp_units_get_pixels(paper.smaller, i_unit);
         double largeX = sp_units_get_pixels(paper.larger,  i_unit);
         
-        g_return_val_if_fail(smallX <= largeX, -1);
+        g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end());
         
         if ((std::abs(smaller - smallX) <= 0.1) &&
-            (std::abs(larger  - largeX) <= 0.1)   )
-            return index;
-            
-        index++;
+            (std::abs(larger  - largeX) <= 0.1)   ) {
+            Gtk::ListStore::iterator p;
+            // We need to search paperSizeListStore explicitly for the
+            // specified paper size because it is sorted in a different
+            // way than paperSizeTable (which is sorted alphabetically)
+            for (p = _paperSizeListStore->children().begin(); p != _paperSizeListStore->children().end(); p++) {
+                if ((*p)[_paperSizeListColumns.nameColumn] == paper.name) {
+                    return p;
+                }
+            }
+        }
     }
-    return -1;
+    return _paperSizeListStore->children().end();
 }