ruby-****@sourc*****
ruby-****@sourc*****
2012年 9月 21日 (金) 07:05:51 JST
------------------------- REMOTE_ADDR = 184.145.80.187 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-parts ------------------------- @@ -386,9 +386,11 @@ Sorting in GTK+ is defined in Gtk::TreeSortable module, or as GTK+ programmers like to say, in Gtk::TreeSortable interface. This interface is implemented by all model classes, hence views can demand that model data be sorted and as such also displayed in the view. This is accomplished by setting Gtk::ListStore#sort_column_id or Gtk::TreeStore#sort_column_id. However, in order to equip column headers with sorting visual indicators and triggers to initialize sorting processes, view also needs to be aware those columns. To give this information to tree view we employ Gtk::TreeViewColumn#sort_column_id=(sort_column_number). But if you follow the code in our example you will notice that it is sufficient to set the model's sort_column_id and that you can ignore the latter, namely Gtk::TreeViewColumn#set_sort_column_id. Also important feature for controlling sort order is set the "clicked" signal emitted by the column header when clicked. In it you can toggle the sort indicator arr ow, and indeed, the sort order on the display, by manipulating the Gtk::TreeViewColumn#sort_order flag with Gtk::SORT_ASCENDING and Gtk::SORT_DESCENDING constants. :Note: - Here,((*sort_column_number*))is the column number in model or store and not the view column number, though, often they do coincide, just like in this program. However, one thing to remember is that you never directly refer to a view column number. View column numbers are implicitly defined when Gtk::TreeView#append_column(column) is executed, and where the argument here named "column" had been assigned the proper model column numbers for all possible renderers associated with a particular view column. + Here,((*sort_column_number*))is the column number in model or store and not the view column number, though, often they do coincide, just like in this program. However, one thing to remember is that you never directly refer to a view column number. View column numbers are implicitly defined when Gtk::TreeView#append_column(column) is executed, and where the argument here named "column" had been assigned the proper model column numbers for all possible renderers associated with a particular view column that needs to be sorted. -Following is the same program as the above "liststore.rb" but here with added sorting features. Please read the comments explaining sorting features to set visual and clickable sort items in the tree view column header. +As promised, following is the same program as the above "liststore.rb" but here with added sorting features. Please read the comments explaining sorting features to set visual and clickable sort items in the tree view column header. + + ((*liststore-sorting.rb*))