GNOME Bugzilla – Bug 693185
GNOME Printer Setup Tool: While printer discovery is running, printer selection is returned to the first in the list many times
Last modified: 2021-06-09 16:11:30 UTC
When I add a new printer, first the printer discovery happens. An empty list appears and at the bottom a spinner is showing that some work is done, then in the list window at first the local (USB) printers appear and several seconds later the network printers. When I want to set up a local printer I click on it as soon as it appears and do not wait for the discovery process to finish. Now during the discovery process the list is updated every few seconds and whenever this happens the selection jumps back to the first entry in the list. If this happens between selecting the desired printer and clicking the OK button, the first entry in the list gets added and not the desired one. What has to be done is keeping the selection on the entry which the user has clicked all the time, also during the updates of the list, so that if the user clicks OK at any time the entry he has selected gets used. To reproduce, connect at least two local (USB) printers and have also at least one network or Bluetooth printer. Select the second local printer before the network and/or Bluetooth printers appear. Observe the list, after some seconds the selection goes back to the first entry. Also reported at Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gnome-control-center/+bug/1115691
Created attachment 241890 [details] [review] don't move to beginning of list of new devices Attached patch preserves position of treeview between actualizations. It clears GtkListStore already present in the treeview and fills it with new list during actualization. This way we don't change internal variable "top_row_dy" of treeview (which is reset to 0 in gtk_tree_view_set_model()).
Created attachment 241891 [details] [review] preserve selection of new print device Attached patch preserves selection between actualizations of list of found devices. It stores name of selected device and select it again after the actualization.
Review of attachment 241890 [details] [review]: ::: panels/printers/pp-new-printer-dialog.c @@ +1411,3 @@ + if (model == NULL) + { + store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); Why don't you create it once and for all when creating the treeview, and be done with it?
Review of attachment 241891 [details] [review]: ::: panels/printers/pp-new-printer-dialog.c @@ +1427,3 @@ + &iter_selected)) + { + gtk_tree_model_get (GTK_TREE_MODEL (store), &iter_selected, This looks like a round about way to do things. Are you emptying the list when updating the devices? If yes, why instead of updating what's already there? If you're not, the selection shouldn't change.
Created attachment 244316 [details] [review] don't move to beginning of list of new devices (In reply to comment #3) > Review of attachment 241890 [details] [review]: > > ::: panels/printers/pp-new-printer-dialog.c > @@ +1411,3 @@ > + if (model == NULL) > + { > + store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, > G_TYPE_STRING); > > Why don't you create it once and for all when creating the treeview, and be > done with it? What about its definition in the ui file directly as in the attached patch?
(In reply to comment #4) > Review of attachment 241891 [details] [review]: > > ::: panels/printers/pp-new-printer-dialog.c > @@ +1427,3 @@ > + &iter_selected)) > + { > + gtk_tree_model_get (GTK_TREE_MODEL (store), &iter_selected, > > This looks like a round about way to do things. > > Are you emptying the list when updating the devices? If yes, why instead of > updating what's already there? Yes, I'm emptying the treeview because its items can be removed by filtering results or by search for printers on another address.
Review of attachment 244316 [details] [review]: Much better.
(In reply to comment #6) > (In reply to comment #4) > > Review of attachment 241891 [details] [review] [details]: > > > > ::: panels/printers/pp-new-printer-dialog.c > > @@ +1427,3 @@ > > + &iter_selected)) > > + { > > + gtk_tree_model_get (GTK_TREE_MODEL (store), &iter_selected, > > > > This looks like a round about way to do things. > > > > Are you emptying the list when updating the devices? If yes, why instead of > > updating what's already there? > > Yes, I'm emptying the treeview because its items can be removed by filtering > results or by search for printers on another address. Filtering results would use a GtkTreeModelFilter, you shouldn't be emptying the model for it, and when you search on a different address, you probably want the selection to be reset, no?
Comment on attachment 244316 [details] [review] don't move to beginning of list of new devices Thank you for the review. I've pushed this to master. Can I push it also to 3.8?
Sure.
(In reply to comment #10) > Sure. Done. Thanks.
(In reply to comment #8) > (In reply to comment #6) > > (In reply to comment #4) > > > Review of attachment 241891 [details] [review] [details] [details]: > > > > > > ::: panels/printers/pp-new-printer-dialog.c > > > @@ +1427,3 @@ > > > + &iter_selected)) > > > + { > > > + gtk_tree_model_get (GTK_TREE_MODEL (store), &iter_selected, > > > > > > This looks like a round about way to do things. > > > > > > Are you emptying the list when updating the devices? If yes, why instead of > > > updating what's already there? > > > > Yes, I'm emptying the treeview because its items can be removed by filtering > > results or by search for printers on another address. > > Filtering results would use a GtkTreeModelFilter, you shouldn't be emptying the > model for it, Filtering of results in the new printer dialog tries to filter current list of devices and if there is no match then it suppose that the text is not a filtering text but an address (if it is one word) and tries to find printers on it. That is why I don't use GtkTreeModelFilter. > and when you search on a different address, you probably want the > selection to be reset, no? It can happen that user has e.g. USB printer which will be in the list even when searching for additional printers on different addresses. We have to preserve selection of such printer.
Created attachment 280701 [details] [review] Preserve selection of new print device Actualized version of the patch.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new bug report at https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/ Thank you for your understanding and your help.