After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 693185 - GNOME Printer Setup Tool: While printer discovery is running, printer selection is returned to the first in the list many times
GNOME Printer Setup Tool: While printer discovery is running, printer selecti...
Status: RESOLVED OBSOLETE
Product: gnome-control-center
Classification: Core
Component: Printers
3.6.x
Other Linux
: Normal major
: ---
Assigned To: Marek Kašík
Control-Center Maintainers
3.10
Depends on:
Blocks:
 
 
Reported: 2013-02-05 08:49 UTC by Till Kamppeter
Modified: 2021-06-09 16:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
don't move to beginning of list of new devices (2.21 KB, patch)
2013-04-19 10:48 UTC, Marek Kašík
needs-work Details | Review
preserve selection of new print device (3.23 KB, patch)
2013-04-19 10:50 UTC, Marek Kašík
needs-work Details | Review
don't move to beginning of list of new devices (3.43 KB, patch)
2013-05-15 13:26 UTC, Marek Kašík
committed Details | Review
Preserve selection of new print device (3.70 KB, patch)
2014-07-15 10:55 UTC, Marek Kašík
none Details | Review

Description Till Kamppeter 2013-02-05 08:49:19 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
Comment 1 Marek Kašík 2013-04-19 10:48:38 UTC
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()).
Comment 2 Marek Kašík 2013-04-19 10:50:15 UTC
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.
Comment 3 Bastien Nocera 2013-05-13 15:23:53 UTC
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?
Comment 4 Bastien Nocera 2013-05-13 15:29:01 UTC
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.
Comment 5 Marek Kašík 2013-05-15 13:26:15 UTC
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?
Comment 6 Marek Kašík 2013-05-15 13:29:15 UTC
(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.
Comment 7 Bastien Nocera 2013-05-21 07:02:53 UTC
Review of attachment 244316 [details] [review]:

Much better.
Comment 8 Bastien Nocera 2013-05-21 07:04:52 UTC
(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 9 Marek Kašík 2013-05-21 14:25:46 UTC
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?
Comment 10 Bastien Nocera 2013-05-21 14:32:42 UTC
Sure.
Comment 11 Marek Kašík 2013-05-21 14:34:45 UTC
(In reply to comment #10)
> Sure.

Done. Thanks.
Comment 12 Marek Kašík 2013-05-21 15:12:01 UTC
(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.
Comment 13 Marek Kašík 2014-07-15 10:55:25 UTC
Created attachment 280701 [details] [review]
Preserve selection of new print device

Actualized version of the patch.
Comment 14 André Klapper 2021-06-09 16:11:30 UTC
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.