Re: liststore issue 1 - iter points to wrong row after sort of column with cellrenderercombo

2019-03-02 Thread Mike Martin via gtk-app-devel-list
On Thu, 28 Feb 2019 at 18:05, Nicolas Soubeiran 
wrote:

> As you noticed "editing-started" is used at the beginning of editing a
> cell as the documentation states and is defined on the base class
> GtkCellRenderer:
>
> This signal gets emitted when a cell starts to be edited. The intended use
> of this signal is to do special setup on *editable* , e.g. adding a
> GtkEntryCompletion
>  or
> setting up additional columns in a GtkComboBox
> .
> https://developer.gnome.org/gtk3/stable/GtkCellRenderer.html#GtkCellRenderer-editing-started
>
> While "edited" is only available on  GtkCellRendererText and is mainly to
> be used for "simple" edition of text (called when user validates
> https://developer.gnome.org/gtk3/stable/GtkCellRendererText.html#GtkCellRendererText-edited
> In case you have a GtkCellRendererText the signals will be called like
> this:
> - editing-started
> if user validates
>- edited with new_text the string the user entered
> else (user cancel edition)
>- editing-canceled
> In all cases you only have the path of the edited row, since the
> cellrenderer does not "know" the model it is displaying : you have to pass
> it through the signal user_data (then you can build the iter and do your
> edition code)
>
>
> Le jeu. 28 févr. 2019 à 18:43, Mike Martin  a écrit :
>
>> Thanks
>> Though what I don't quite get is the difference in behaviour between
>> editing-started and edited (both using path to get the ITER)
>> On my particular scenario I use editing-started to setup some stuff so I
>> can use the iter created
>>
>> On Thu, 28 Feb 2019, 12:30 Nicolas Soubeiran via gtk-app-devel-list, <
>> gtk-app-devel-list@gnome.org> wrote:
>>
>>> Hello,
>>> after you sort the model, you shall consider that all iter and path
>>> previously stored are wrong :
>>> A path is a representation of the position of the row in the current case
>>> (which you can read by using gtk_tree_path_to_string).
>>>
>>> https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#gtk-tree-path-to-string
>>>
>>>  Iter are quite the same (but link to a particular GtkTreeModel), such as
>>> list::iterator of C++ STL : they are pointer to row that you can use to
>>> access to data or walk through the models.  You can make an iter from a
>>> path and a model :
>>>
>>> GtkTreePath *path;GtkTreeIter iter;
>>>
>>> GtkTreeModel* model;
>>>
>>> GtkListStore store = gtk_list_store_new(3, G_TYPE_INT,
>>> G_TYPE_STRING,G_TYPE_STRING)
>>>
>>> model = GTK_TREE_MODEL(store);
>>>
>>> path = gtk_tree_path_new_from_string
>>> <
>>> https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#gtk-tree-path-new-from-string
>>> >
>>> ("3"); // third rowgtk_tree_model_get_iter
>>> <
>>> https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#gtk-tree-model-get-iter
>>> >
>>> (model, , path); // may be invalid (check return value)
>>>
>>>  If you really want to keep track of a particular row, you have to use
>>> GtkTreeRowReference
>>>
>>> https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#GtkTreeRowReference
>>> But GTK will have to keep the reference up to date, so each time your
>>> model change (inserting, deleting, sorting...)
>>> GTK will triggered signal to update your GtkTreeRowReference which may
>>> cause an overhead in your application
>>>
>>> Hope this helps you to understand better the GtkTreeModel paradigm
>>> ___
>>> gtk-app-devel-list mailing list
>>> gtk-app-devel-list@gnome.org
>>> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>>>
>>

What I suspect is happening is that once a column is sorted, the column is
resorted as soon as a change is made so path never points to the current
row. Though doesn't happen with a plain text renderer.

I have tested this with my code, and this is exactly what is happening

Before the edited function is called, the liststore is sorted again, so the
path string points to the row that is now at the previous position (ie:the
next row)

If the change made does not mean the row is sorted to a different position
then the same row is referenced, example
(where the first is value in column 0 and second is a fixed row indicator)
in both cases this the first row

Sort reorders the rows
/data/staging -> /data/staging2
/data/1staging   2

Sort does not reorder row
/data/staging -> /data/1staging
/data/1staging   1


Mike
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: liststore issue 1 - iter points to wrong row after sort of column with cellrenderercombo

2019-02-28 Thread Nicolas Soubeiran via gtk-app-devel-list
As you noticed "editing-started" is used at the beginning of editing a cell
as the documentation states and is defined on the base class
GtkCellRenderer:

This signal gets emitted when a cell starts to be edited. The intended use
of this signal is to do special setup on *editable* , e.g. adding a
GtkEntryCompletion
 or
setting up additional columns in a GtkComboBox
.
https://developer.gnome.org/gtk3/stable/GtkCellRenderer.html#GtkCellRenderer-editing-started

While "edited" is only available on  GtkCellRendererText and is mainly to
be used for "simple" edition of text (called when user validates
https://developer.gnome.org/gtk3/stable/GtkCellRendererText.html#GtkCellRendererText-edited
In case you have a GtkCellRendererText the signals will be called like this:
- editing-started
if user validates
   - edited with new_text the string the user entered
else (user cancel edition)
   - editing-canceled
In all cases you only have the path of the edited row, since the
cellrenderer does not "know" the model it is displaying : you have to pass
it through the signal user_data (then you can build the iter and do your
edition code)


Le jeu. 28 févr. 2019 à 18:43, Mike Martin  a écrit :

> Thanks
> Though what I don't quite get is the difference in behaviour between
> editing-started and edited (both using path to get the ITER)
> On my particular scenario I use editing-started to setup some stuff so I
> can use the iter created
>
> On Thu, 28 Feb 2019, 12:30 Nicolas Soubeiran via gtk-app-devel-list, <
> gtk-app-devel-list@gnome.org> wrote:
>
>> Hello,
>> after you sort the model, you shall consider that all iter and path
>> previously stored are wrong :
>> A path is a representation of the position of the row in the current case
>> (which you can read by using gtk_tree_path_to_string).
>>
>> https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#gtk-tree-path-to-string
>>
>>  Iter are quite the same (but link to a particular GtkTreeModel), such as
>> list::iterator of C++ STL : they are pointer to row that you can use to
>> access to data or walk through the models.  You can make an iter from a
>> path and a model :
>>
>> GtkTreePath *path;GtkTreeIter iter;
>>
>> GtkTreeModel* model;
>>
>> GtkListStore store = gtk_list_store_new(3, G_TYPE_INT,
>> G_TYPE_STRING,G_TYPE_STRING)
>>
>> model = GTK_TREE_MODEL(store);
>>
>> path = gtk_tree_path_new_from_string
>> <
>> https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#gtk-tree-path-new-from-string
>> >
>> ("3"); // third rowgtk_tree_model_get_iter
>> <
>> https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#gtk-tree-model-get-iter
>> >
>> (model, , path); // may be invalid (check return value)
>>
>>  If you really want to keep track of a particular row, you have to use
>> GtkTreeRowReference
>>
>> https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#GtkTreeRowReference
>> But GTK will have to keep the reference up to date, so each time your
>> model change (inserting, deleting, sorting...)
>> GTK will triggered signal to update your GtkTreeRowReference which may
>> cause an overhead in your application
>>
>> Hope this helps you to understand better the GtkTreeModel paradigm
>> ___
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>>
>
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: liststore issue 1 - iter points to wrong row after sort of column with cellrenderercombo

2019-02-28 Thread Mike Martin via gtk-app-devel-list
Thanks
Though what I don't quite get is the difference in behaviour between
editing-started and edited (both using path to get the ITER)
On my particular scenario I use editing-started to setup some stuff so I
can use the iter created

On Thu, 28 Feb 2019, 12:30 Nicolas Soubeiran via gtk-app-devel-list, <
gtk-app-devel-list@gnome.org> wrote:

> Hello,
> after you sort the model, you shall consider that all iter and path
> previously stored are wrong :
> A path is a representation of the position of the row in the current case
> (which you can read by using gtk_tree_path_to_string).
>
> https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#gtk-tree-path-to-string
>
>  Iter are quite the same (but link to a particular GtkTreeModel), such as
> list::iterator of C++ STL : they are pointer to row that you can use to
> access to data or walk through the models.  You can make an iter from a
> path and a model :
>
> GtkTreePath *path;GtkTreeIter iter;
>
> GtkTreeModel* model;
>
> GtkListStore store = gtk_list_store_new(3, G_TYPE_INT,
> G_TYPE_STRING,G_TYPE_STRING)
>
> model = GTK_TREE_MODEL(store);
>
> path = gtk_tree_path_new_from_string
> <
> https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#gtk-tree-path-new-from-string
> >
> ("3"); // third rowgtk_tree_model_get_iter
> <
> https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#gtk-tree-model-get-iter
> >
> (model, , path); // may be invalid (check return value)
>
>  If you really want to keep track of a particular row, you have to use
> GtkTreeRowReference
>
> https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#GtkTreeRowReference
> But GTK will have to keep the reference up to date, so each time your
> model change (inserting, deleting, sorting...)
> GTK will triggered signal to update your GtkTreeRowReference which may
> cause an overhead in your application
>
> Hope this helps you to understand better the GtkTreeModel paradigm
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: liststore issue 1 - iter points to wrong row after sort of column with cellrenderercombo

2019-02-28 Thread Nicolas Soubeiran via gtk-app-devel-list
Hello,
after you sort the model, you shall consider that all iter and path
previously stored are wrong :
A path is a representation of the position of the row in the current case
(which you can read by using gtk_tree_path_to_string).
https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#gtk-tree-path-to-string

 Iter are quite the same (but link to a particular GtkTreeModel), such as
list::iterator of C++ STL : they are pointer to row that you can use to
access to data or walk through the models.  You can make an iter from a
path and a model :

GtkTreePath *path;GtkTreeIter iter;

GtkTreeModel* model;

GtkListStore store = gtk_list_store_new(3, G_TYPE_INT,
G_TYPE_STRING,G_TYPE_STRING)

model = GTK_TREE_MODEL(store);

path = gtk_tree_path_new_from_string

("3"); // third rowgtk_tree_model_get_iter

(model, , path); // may be invalid (check return value)

 If you really want to keep track of a particular row, you have to use
GtkTreeRowReference
https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#GtkTreeRowReference
But GTK will have to keep the reference up to date, so each time your
model change (inserting, deleting, sorting...)
GTK will triggered signal to update your GtkTreeRowReference which may
cause an overhead in your application

Hope this helps you to understand better the GtkTreeModel paradigm
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: liststore issue 1 - iter points to wrong row after sort of column with cellrenderercombo

2019-02-27 Thread Reuben Rissler




On 02/27/2019 06:46 AM, Mike Martin via gtk-app-devel-list wrote:

I have come across an issue where the iter points to the wrong row on
edited signal after sorting the column (via clicking header).

This only happens with edited signal and not editing-started (which is
correct)

I don't understand all the nuances, but I learned to get an iter from 
the path and then change the model according to the iter. It seems after 
the model changes (with sort enabled), all the paths are wrong but the 
iters seem to be right.

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


liststore issue 1 - iter points to wrong row after sort of column with cellrenderercombo

2019-02-27 Thread Mike Martin via gtk-app-devel-list
I have come across an issue where the iter points to the wrong row on
edited signal after sorting the column (via clicking header).

This only happens with edited signal and not editing-started (which is
correct)

The edited iter is obtained via
treeview->get_model->get_iter_from_string($path_str), which is obtained
from the path variable given by signal

This is pre sort (and correct)
Gtk3::CellRendererCombo=HASH(0x55938bc4f418)0
/mnt/progs/programs/DS9a-- array from edited signal
Gtk3::TreeIter=SCALAR(0x55938b3dc050) -- iter from editing-started signal
Gtk3::TreeIter=SCALAR(0x55938bc46d50)-- iter from edited signal
/mnt/progs/programs/DS9ads9_101_envs.mp41 --result using   iter
from editing-started signal
/mnt/progs/programs/DS9ads9_101_envs.mp41 --result using iter from
edited signal

This is post sort (and wrong)

Gtk3::CellRendererCombo=HASH(0x55938bc4f418)0
/mnt/progs/programs/DS9b-- array from edited signal
2836 Gtk3::TreeIter=SCALAR(0x55938b44c938) -- iter from editing-started
signal
2836a Gtk3::TreeIter=SCALAR(0x55938bc46d68) -- iter from edited signal
/mnt/progs/programs/DS9bds9_102_envs.mp42--result using   iter
from editing-started signal and is correct
/mnt/progs/programs/DS9ds9_103_envs.mp43 --result using iter from
edited signal and is wrong row

Any ideas why this is happening?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list