lib/alexandria/ui/listview.rb in alexandria-book-collection-manager-0.7.0 vs lib/alexandria/ui/listview.rb in alexandria-book-collection-manager-0.7.1

- old
+ new

@@ -16,10 +16,12 @@ # You should have received a copy of the GNU General Public # License along with Alexandria; see the file COPYING. If not, # write to the Free Software Foundation, Inc., 51 Franklin Street, # Fifth Floor, Boston, MA 02110-1301 USA. +require 'alexandria/ui/columns' + module Alexandria module UI include Logging include GetText GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8') @@ -27,17 +29,10 @@ include Logging include GetText include DragAndDropable BOOKS_TARGET_TABLE = [['ALEXANDRIA_BOOKS', :same_app, 0]].freeze - MAX_RATING_STARS = 5 - module Columns - COVER_LIST, COVER_ICON, TITLE, TITLE_REDUCED, AUTHORS, - ISBN, PUBLISHER, PUBLISH_DATE, EDITION, RATING, IDENT, - NOTES, REDD, OWN, WANT, TAGS, LOANED_TO = (0..17).to_a - end - def initialize(_listview, parent) @parent = parent @prefs = @parent.prefs @listview = @parent.listview @listview_model = @parent.listview_model @@ -125,17 +120,17 @@ def setup_rating_column title = _('Rating') log.debug { 'Create listview column for %s...' % title } column = Gtk::TreeViewColumn.new(title) column.sizing = :fixed - width = (Icons::STAR_SET.width + 1) * MAX_RATING_STARS + width = (Icons::STAR_SET.width + 1) * Book::MAX_RATING_STARS column.fixed_width = column.min_width = column.max_width = width - MAX_RATING_STARS.times do |i| + Book::MAX_RATING_STARS.times do |i| renderer = Gtk::CellRendererPixbuf.new renderer.xalign = 0.0 column.pack_start(renderer, false) column.set_cell_data_func(renderer) do |_tree_column, cell, _tree_model, iter| - rating = (iter[Columns::RATING] - MAX_RATING_STARS).abs + rating = (iter[Columns::RATING] - Book::MAX_RATING_STARS).abs cell.pixbuf = rating >= i.succ ? Icons::STAR_SET : Icons::STAR_UNSET end end column.sort_column_id = Columns::RATING