lib/alexandria/ui/ui_manager.rb in alexandria-book-collection-manager-0.7.4 vs lib/alexandria/ui/ui_manager.rb in alexandria-book-collection-manager-0.7.5

- old
+ new

@@ -10,12 +10,12 @@ require "alexandria/library_sort_order" module Alexandria module UI class UIManager < BuilderBase - attr_accessor :main_app, :actiongroup, :appbar, :prefs, :listview, :iconview, :listview_model, - :iconview_model, :filtered_model + 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") @@ -294,11 +294,12 @@ if event_is_right_click event log.debug { "library right click!" } library_already_selected = true if (path = widget.get_path_at_pos(event.x, event.y)) @clicking_on_sidepane = true - obj, path = widget.is_a?(Gtk::TreeView) ? [widget.selection, path.first] : [widget, path] + obj, path = + widget.is_a?(Gtk::TreeView) ? [widget.selection, path.first] : [widget, path] widget.has_focus = true unless obj.path_is_selected?(path) log.debug { "Select #{path}" } @@ -345,11 +346,12 @@ end # not a right click elsif (path = widget.get_path_at_pos(event.x, event.y)) @clicking_on_sidepane = true - obj, path = widget.is_a?(Gtk::TreeView) ? [widget.selection, path.first] : [widget, path] + obj, path = + widget.is_a?(Gtk::TreeView) ? [widget.selection, path.first] : [widget, path] obj.select_path(path) sensitize_library selected_library end end @@ -371,11 +373,12 @@ log.debug { "books_button_press_event" } if event_is_right_click event widget.grab_focus if (path = widget.get_path_at_pos(event.x.to_i, event.y.to_i)) - obj, path = widget.is_a?(Gtk::TreeView) ? [widget.selection, path.first] : [widget, path] + obj, path = + widget.is_a?(Gtk::TreeView) ? [widget.selection, path.first] : [widget, path] unless obj.path_is_selected?(path) log.debug { "Select #{path}" } widget.unselect_all obj.select_path(path) @@ -456,11 +459,13 @@ @actiongroup["Delete"].sensitive = \ @actiongroup["DeselectAll"].sensitive = \ @actiongroup["Move"].sensitive = @actiongroup["SetRating"].sensitive = !books.empty? - log.debug { "on_books_selection_changed Delete: #{@actiongroup['Delete'].sensitive?}" } + log.debug do + "on_books_selection_changed Delete: #{@actiongroup['Delete'].sensitive?}" + end if library.is_a?(SmartLibrary) @actiongroup["Delete"].sensitive = @actiongroup["Move"].sensitive = false end @@ -507,12 +512,11 @@ on_books_selection_changed end end def determine_delete_option - sensitive = (@libraries.all_regular_libraries.length > 1 || selected_library.is_a?(SmartLibrary)) - sensitive + @libraries.all_regular_libraries.length > 1 || selected_library.is_a?(SmartLibrary) end def on_close_sidepane log.debug { "on_close_sidepane" } @actiongroup["Sidepane"].active = false @@ -661,15 +665,19 @@ rescue StandardError => ex log.error { "Could not delete empty file #{filename}" } end end - log.debug { "Trying to add #{book.title}, #{cover_uri} in library ''#{library.name}'" } + log.debug do + "Trying to add #{book.title}, #{cover_uri}" \ + " in library ''#{library.name}'" + end library.save_cover(book, cover_uri) unless cover_uri.nil? library << book library.save(book) - set_status_label(format(_("Added '%s' to library '%s'"), book.title, library.name)) + set_status_label(format(_("Added '%s' to library '%s'"), + book.title, library.name)) rescue StandardError => ex log.error { "Couldn't add book #{isbn}: #{ex}" } log.error { ex.backtrace.join("\n") } end @@ -720,11 +728,12 @@ 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] = Book::MAX_RATING_STARS - rating # ascending order is the default + # ascending order is the default + iter[Columns::RATING] = Book::MAX_RATING_STARS - rating iter[Columns::OWN] = book.own? iter[Columns::REDD] = book.redd? iter[Columns::WANT] = book.want? iter[Columns::TAGS] = if book.tags book.tags.join(",") @@ -1166,10 +1175,11 @@ @main_app.icon_name = "alexandria" end ICONS_SORTS = [ Columns::TITLE, Columns::AUTHORS, Columns::ISBN, - Columns::PUBLISHER, Columns::EDITION, Columns::RATING, Columns::REDD, Columns::OWN, Columns::WANT + Columns::PUBLISHER, Columns::EDITION, Columns::RATING, + Columns::REDD, Columns::OWN, Columns::WANT ].freeze def setup_books_iconview_sorting sort_order = @prefs.reverse_icons ? :descending : :ascending mode = ICONS_SORTS[@prefs.arrange_icons_mode]