Re: Sort Indicator in TreeView
- From: "Andrew E. Makeev" <andrew solvo ru>
- To: "Andrew E. Makeev" <andrew solvo ru>
- Cc: gtk-list <gtk-list gnome org>, Gtkmm list <gtkmm-list gnome org>
- Subject: Re: Sort Indicator in TreeView
- Date: Tue, 24 May 2005 16:58:49 +0400
Andrew E. Makeev wrote:
Hi,
I can't remove sort indicator in my TreeView widget. (GTKMM-2.4)
I am using custom widget ( HBox with label and image ) for the column
header ( column->set_widget( header ) ).
I need custom sorting behavior, so, I am setting
column->set_sort_indicator( false );
but this won't help. Once I am calling set_sort_column() function sort
indicator is appearing as well.
How to hide it?
... compilation done ... (was writing until my test compiles)
Well, I found the answer myself - I have to call set_sort_indicator(
false ) every time I call set_sort_column(). Why so?
(I wouldn't hide indicator but It doesn't appear in SORT_DESCEND state
for custom widget, however it did in GTKMM-2.2. Is it a bug?) .
The problem is solved.
My task was a creating TreeView Column with 3 states of the sorting:
ASC, DESC and NONE.
Since, TreeView itself offers only 2 states (ASC, DESC), I should code
my handler for TreeViewColumn::signal_clicked:
enum States
{
SORT_NONE,
SORT_ASC,
SORT_DESC
};
void myclass::column_clicked_cb( Gtk::TreeViewColumn* column )
{
static enum States state = SORT_NONE;
switch( state )
{
case SORT_NONE:
state = SORT_ASC;
break;
case SORT_ASC:
// Since, GTK+ 2.4. I had to move (and rename :-/, since GTKMM-2.4)
setting of sort column here, otherwise it won't show sort indicator
column->set_sort_column_id( columnModel.row_num_column );
column->set_sort_indicator( true );
// was here for Gtk+ 2.2
// column->set_sort_column( columnModel.row_num_column );
state = SORT_DESC;
break;
case SORT_DESC:
column->set_sort_column_id( columnModel.sort_column );
state = SORT_NONE;
break;
}
}
/*
columnModel.sort_column - column in Model and TreeView where I like to
apply sorting
columnModel.row_num_column - row counter, column in Model to set default
sorting (by row number)
*/
As I noted changes was caused by GTK+ new release. I found this change
in gtktreeviewcolumn.c:
static void
gtk_tree_view_column_setup_sort_column_id_callback (GtkTreeViewColumn
*tree_column)
{
GtkTreeModel *model;
if (tree_column->tree_view == NULL)
return;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_column->tree_view));
if (model == NULL)
return;
if (GTK_IS_TREE_SORTABLE (model) &&
tree_column->sort_column_id != -1)
{
gint real_sort_column_id;
GtkSortType real_order;
if (tree_column->sort_column_changed_signal == 0)
tree_column->sort_column_changed_signal =
g_signal_connect (model, "sort_column_changed",
G_CALLBACK
(gtk_tree_view_model_sort_column_changed),
tree_column);
if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model),
&real_sort_column_id,
&real_order) &&
(real_sort_column_id == tree_column->sort_column_id))
{
gtk_tree_view_column_set_sort_indicator (tree_column, TRUE);
// that causes the indicator to be shown when I am restoring sorting column
gtk_tree_view_column_set_sort_order (tree_column, real_order);
}
// begin
// added since 2.4
else
{
gtk_tree_view_column_set_sort_indicator (tree_column, FALSE);
// that causes the indicator to be hidden when I am setting sorting
column to row_num
}
// end
}
}
And it is sad, when you are going to upgrade your library version to get
new advantages and bug fixes, but in same time you could meet some
troubles for porting that could be simple but take lot of time for
researching.
Is it a really big deal to add notes in API reference?
Regards,
-andrew
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]