lib/alexandria/ui/listview.rb in alexandria-book-collection-manager-0.7.4 vs lib/alexandria/ui/listview.rb in alexandria-book-collection-manager-0.7.5
- old
+ new
@@ -126,52 +126,52 @@
def setup_check_column(title, iterid)
renderer = CellRendererToggle.new
renderer.activatable = true
renderer.signal_connect("toggled") do |_rndrr, path|
- begin
- tree_path = Gtk::TreePath.new(path)
- child_path = @listview_model.convert_path_to_child_path(tree_path)
- if child_path
- unfiltered_path = @filtered_model.convert_path_to_child_path(child_path)
- # FIX this sometimes returns a nil path for iconview...
- if unfiltered_path
- iter = @model.get_iter(unfiltered_path)
- if iter
- book = @parent.book_from_iter(@parent.selected_library, iter)
- toggle_state = case iterid
- when Columns::REDD then book.redd
- when Columns::OWN then book.own
- when Columns::WANT then book.want
- end
- # invert toggle_state
- unless iterid == Columns::WANT && book.own
- toggle_state = !toggle_state
- case iterid
- when Columns::REDD then book.redd = toggle_state
- when Columns::OWN then book.own = toggle_state
- when Columns::WANT then book.want = toggle_state
- end
- iter[iterid] = toggle_state
- lib = @parent.selected_library
- lib.save(book)
+ tree_path = Gtk::TreePath.new(path)
+ child_path = @listview_model.convert_path_to_child_path(tree_path)
+ if child_path
+ unfiltered_path = @filtered_model.convert_path_to_child_path(child_path)
+ # FIX this sometimes returns a nil path for iconview...
+ if unfiltered_path
+ iter = @model.get_iter(unfiltered_path)
+ if iter
+ book = @parent.book_from_iter(@parent.selected_library, iter)
+ toggle_state = case iterid
+ when Columns::REDD then book.redd
+ when Columns::OWN then book.own
+ when Columns::WANT then book.want
+ end
+ # invert toggle_state
+ unless iterid == Columns::WANT && book.own
+ toggle_state = !toggle_state
+ case iterid
+ when Columns::REDD then book.redd = toggle_state
+ when Columns::OWN then book.own = toggle_state
+ when Columns::WANT then book.want = toggle_state
end
+ iter[iterid] = toggle_state
+ lib = @parent.selected_library
+ lib.save(book)
end
end
-
end
- rescue StandardError => ex
- log.error { "toggle failed for path #{path} #{ex}\n" + e.backtrace.join("\n") }
+
end
+ rescue StandardError => ex
+ log.error { "toggle failed for path #{path} #{ex}\n" + e.backtrace.join("\n") }
end
column = Gtk::TreeViewColumn.new(title, renderer, text: iterid)
column.sort_column_id = iterid
column.resizable = true
log.debug { format("Create listview column for %s...", title) }
column.add_attribute(renderer, "active", iterid)
- column.add_attribute(renderer, "inconsistent", Columns::OWN) if iterid == Columns::WANT
+ if iterid == Columns::WANT
+ column.add_attribute(renderer, "inconsistent", Columns::OWN)
+ end
log.debug { "append_column #{column}" }
@listview.append_column(column)
end
@@ -204,10 +204,13 @@
]
cols = @listview.columns[1..-1] # skip "Title"
cols.each_index do |i|
cols[i].visible = !!cols_visibility[i]
end
- log.debug { "Columns visibility: " + cols.map { |col| "#{col.title} #{col.visible?}" }.join(", ") }
+ log.debug do
+ "Columns visibility: " +
+ cols.map { |col| "#{col.title} #{col.visible?}" }.join(", ")
+ end
end
# Sets the width of each column based on any respective
# preference value stored.
def setup_listview_columns_width