summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 52ecaa6)
raw | patch | inline | side by side (parent: 52ecaa6)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Mon, 19 Mar 2007 23:40:46 +0000 (23:40 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Mon, 19 Mar 2007 23:40:46 +0000 (23:40 +0000) |
src/ui/widget/page-sizer.cpp | patch | blob | history | |
src/ui/widget/page-sizer.h | patch | blob | history |
index 5a2d1ebff4b5fd6ba98dc4c2c6ffe6b63cb96d64..7b0fea5f558fd8b91d0397b444762ec8c24a8841 100644 (file)
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);
}
/**
- * 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;
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++) {
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();
}
index 9efef5e64a75bf6603c30397b8adcef0b65ab787..e3d10f578829861339c8159be082d04f2043ff89 100644 (file)
/**
* Find the closest standard paper size in the table, to the
*/
- int find_paper_size (double w, double h) const;
+ Gtk::ListStore::iterator find_paper_size (double w, double h) const;
void fire_fit_canvas_to_selection_or_drawing();