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

- old
+ new

@@ -15,30 +15,22 @@ # 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 - MAX_RATING_STARS = 5 class UIManager < BuilderBase attr_accessor :main_app, :actiongroup, :appbar, :prefs, :listview, :iconview, :listview_model, :iconview_model, :filtered_model attr_reader :model include Logging include GetText GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8') - 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 # duplicated from listview.rb - end - - # The maximum number of rating stars displayed. - MAX_RATING_STARS = 5 - def initialize(parent) super('main_app__builder.glade', widget_names) @parent = parent @library_separator_iter = nil @@ -151,11 +143,11 @@ end def setup_toolbar_combobox cb = Gtk::ComboBoxText.new cb.set_row_separator_func do |model, iter| - # log.debug { "row_separator" } + # TODO: Replace with iter[0] if possible model.get_value(iter, 0) == '-' end [_('Match everything'), '-', _('Title contains'), @@ -759,11 +751,11 @@ iter[Columns::PUBLISH_DATE] = book.publishing_year.to_s iter[Columns::EDITION] = book.edition iter[Columns::NOTES] = (book.notes || '') iter[Columns::LOANED_TO] = (book.loaned_to || '') rating = (book.rating || Book::DEFAULT_RATING) - iter[Columns::RATING] = MAX_RATING_STARS - rating # ascending order is the default + iter[Columns::RATING] = Book::MAX_RATING_STARS - rating # ascending order is the default iter[Columns::OWN] = book.own? iter[Columns::REDD] = book.redd? iter[Columns::WANT] = book.want? iter[Columns::TAGS] = if book.tags book.tags.join(',') @@ -778,10 +770,10 @@ if icon.height > ICON_HEIGHT new_width = icon.width / (icon.height / ICON_HEIGHT.to_f) new_height = [ICON_HEIGHT, icon.height].min icon = cache_scaled_icon(icon, new_width, new_height) end - if rating == MAX_RATING_STARS + if rating == Book::MAX_RATING_STARS icon = icon.tag(Icons::FAVORITE_TAG) end iter[Columns::COVER_ICON] = icon log.debug { 'Full iter: ' + (0..15).map { |num| iter[num].inspect }.join(', ') } end