Skip to content

Commit

Permalink
gtk3: TreeViewColumn#add_attribute accepts symbol key
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Feb 25, 2015
1 parent 9b3d465 commit c24beac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gtk3/lib/gtk3/tree-view-column.rb
Expand Up @@ -25,5 +25,11 @@ def initialize(title=nil, cell=nil, attributes={})
add_attribute(cell, key, value)
end
end

alias_method :add_attribute_raw, :add_attribute
def add_attribute(cell, key, value)
key = key.to_s if key.is_a?(Symbol)
add_attribute_raw(cell, key, value)
end
end
end
16 changes: 16 additions & 0 deletions gtk3/test/test_gtk_tree_view_column.rb
Expand Up @@ -27,5 +27,21 @@ class TestGtkTreeViewColumn < Test::Unit::TestCase
column = Gtk::TreeViewColumn.new("title")
assert_equal("title", column.title)
end

sub_test_case("attributes") do
test "string key" do
column = Gtk::TreeViewColumn.new
cell = Gtk::CellRendererText.new
column.pack_start(cell, true)
column.add_attribute(cell, "text", 0)
end

test "symbol key" do
column = Gtk::TreeViewColumn.new
cell = Gtk::CellRendererText.new
column.pack_start(cell, true)
column.add_attribute(cell, :text, 0)
end
end
end
end

0 comments on commit c24beac

Please sign in to comment.