[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-gtk2-treev-trees

Back to archive index

ruby-****@sourc***** ruby-****@sourc*****
2012年 10月 9日 (火) 06:12:27 JST


-------------------------
REMOTE_ADDR = 184.145.82.7
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-trees
-------------------------
@@ -891,6 +891,21 @@
 
 You could simply pack the "pixb_renderer" into it, after initialization in which the specified renderer is also set to take the first position in the left side of the in the cell (note that packing order can not alter this positional arrangement, the text would remain to sit before the image in tree view column). We chose the other option, namely, to position the image before the text. This is why we have to manually build both renderers (one for the image and the other for text) and then pack them into a column in order we like!
 
+
+Alternatively, you could also start up with the pixbuf renderer, and instantiate its column, to which you would then have to add (pack) the text renderer:
+
+  pixb_renderer = Gtk::CellRendererPixbuf.new
+  renderer = Gtk::CellRendererText.new
+  column = Gtk::TreeViewColumn.new("Product /w icons", pixb_renderer, :pixbuf => ICON)
+  column.pack_start(renderer, false)
+  column.set_cell_data_func(pixb_renderer) do |col, renderer, model, iter|
+    renderer.stock_id = Gtk::Stock::DIALOG_ERROR if iter[ICON] == nil
+  end
+  column.add_attribute(renderer, :text, PRODUCT)
+  treeview.append_column(column)
+
+
+
 Yet another wrinkle in our column building process is handling the situations when image is not available. We chose to complain with an annoying ERROR image. This is done with the stock item as follows: 
 
  column.set_cell_data_func(pixb_renderer) do |col, renderer, model, iter|




ruby-gnome2-cvs メーリングリストの案内
Back to archive index