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 687875 - Don't preselect the first item when adding a new account
Don't preselect the first item when adding a new account
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Online Accounts
3.6.x
Other All
: Normal normal
: ---
Assigned To: GNOME Online Accounts maintainer(s)
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-11-07 18:30 UTC by Debarshi Ray
Modified: 2012-11-09 19:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot of existing dialog (16.72 KB, image/png)
2012-11-07 18:31 UTC, Debarshi Ray
  Details
online-accounts: Don't preselect the first item when adding an account (3.95 KB, patch)
2012-11-07 18:33 UTC, Debarshi Ray
none Details | Review
Screenshot after patch (16.77 KB, image/png)
2012-11-07 18:34 UTC, Debarshi Ray
  Details
online-accounts: Don't preselect the first item when adding an account (3.17 KB, patch)
2012-11-07 18:37 UTC, Debarshi Ray
needs-work Details | Review
online-accounts: Don't preselect the first item when adding an account (1.42 KB, patch)
2012-11-09 18:18 UTC, Debarshi Ray
accepted-commit_now Details | Review
online-accounts: Don't preselect the first item when adding an account (1.68 KB, patch)
2012-11-09 18:35 UTC, Debarshi Ray
rejected Details | Review
online-accounts: Don't preselect the first item when adding an account (1.43 KB, patch)
2012-11-09 19:02 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2012-11-07 18:30:19 UTC
Currently the first item is preselected when adding a new account. It should not be the case because we are trying to mimic the behaviour of the control center shell.

(In the future we might replace the tree view with a list of buttons or something)
Comment 1 Debarshi Ray 2012-11-07 18:31:00 UTC
Created attachment 228408 [details]
Screenshot of existing dialog
Comment 2 Debarshi Ray 2012-11-07 18:33:13 UTC
Created attachment 228410 [details] [review]
online-accounts: Don't preselect the first item when adding an account
Comment 3 Debarshi Ray 2012-11-07 18:34:34 UTC
Created attachment 228411 [details]
Screenshot after patch
Comment 4 Debarshi Ray 2012-11-07 18:37:52 UTC
Created attachment 228412 [details] [review]
online-accounts: Don't preselect the first item when adding an account
Comment 5 Rui Matos 2012-11-09 15:40:27 UTC
Review of attachment 228412 [details] [review]:

That's a workaround right?

GTK_SELECTION_BROWSE is fine. The first row is still getting selected because the tree view is getting the keyboard focus by default. If you force the keyboard focus on the Cancel button it should work as you intended.
Comment 6 Debarshi Ray 2012-11-09 18:17:36 UTC
(In reply to comment #5)
> Review of attachment 228412 [details] [review]:
> 
> That's a workaround right?

I was trying to have it such that pressing the down arrow key starts navigating throw the treeview, because the down arrow key is the one you will first think of using if you want to go through a list. However, it is not working so well, because sometimes the first entry in the tree view still has this dotted box around it, and sometimes not. Possibly due to the idle getting interleaved with something else.

> GTK_SELECTION_BROWSE is fine. The first row is still getting selected because
> the tree view is getting the keyboard focus by default. If you force the
> keyboard focus on the Cancel button it should work as you intended.

Yes, you are right. That is much better.
Comment 7 Debarshi Ray 2012-11-09 18:18:20 UTC
Created attachment 228604 [details] [review]
online-accounts: Don't preselect the first item when adding an account
Comment 8 Rui Matos 2012-11-09 18:25:04 UTC
Review of attachment 228604 [details] [review]:

Looks fine.

(In reply to comment #6)
> (In reply to comment #5)
> > Review of attachment 228412 [details] [review] [details]:
> > 
> > That's a workaround right?
> 
> I was trying to have it such that pressing the down arrow key starts navigating
> throw the treeview, because the down arrow key is the one you will first think
> of using if you want to go through a list. However, it is not working so well,
> because sometimes the first entry in the tree view still has this dotted box
> around it, and sometimes not. Possibly due to the idle getting interleaved with
> something else.

Well, people can Tab or use the Up arrow to focus the tree view.
Comment 9 Debarshi Ray 2012-11-09 18:35:01 UTC
Created attachment 228605 [details] [review]
online-accounts: Don't preselect the first item when adding an account

Since what the documentation says about gtk_widget_grab_focus:
"The widget also needs to be realized and mapped. This is indicated by the related signals. Grabbing the focus immediately after creating the widget will likely fail and cause critical warnings."
... does not seem to hold in this case, this looks like a cleaner way.
Comment 10 Rui Matos 2012-11-09 18:45:50 UTC
(In reply to comment #9)
> Created an attachment (id=228605) [details] [review]
> online-accounts: Don't preselect the first item when adding an account
> 
> Since what the documentation says about gtk_widget_grab_focus:
> "The widget also needs to be realized and mapped. This is indicated by the
> related signals. Grabbing the focus immediately after creating the widget will
> likely fail and cause critical warnings."
> ... does not seem to hold in this case, this looks like a cleaner way.

I didn't see any warnings though. But in that case, this would be worse, because at _init() time the widget is certainly not realized.

I guess this is the simplest (and safest?) form:

diff --git a/panels/online-accounts/cc-online-accounts-add-account-dialog.c b/panels/online-accounts/cc-online-accounts-ad
index 5f68871..74c023c 100644
--- a/panels/online-accounts/cc-online-accounts-add-account-dialog.c
+++ b/panels/online-accounts/cc-online-accounts-add-account-dialog.c
@@ -284,7 +284,8 @@ goa_panel_add_account_dialog_init (GoaPanelAddAccountDialog *add_account)
   gtk_tree_view_column_pack_start (column, renderer, TRUE);
   gtk_tree_view_column_set_attributes (column, renderer, "markup", COLUMN_MARKUP, NULL);
 
-  gtk_dialog_add_button (GTK_DIALOG (add_account), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+  gtk_window_set_focus (GTK_WINDOW (add_account),
+                        gtk_dialog_add_button (GTK_DIALOG (add_account), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL));
   gtk_dialog_set_default_response (GTK_DIALOG (add_account), GTK_RESPONSE_CANCEL);
 
   g_signal_connect (priv->tree_view, "button-press-event",
Comment 11 Debarshi Ray 2012-11-09 19:00:33 UTC
(In reply to comment #10)
> (In reply to comment #9)

I am not sure if we can trust gtk_window_set_focus either because the docs say that gtk_widget_grab_focus is easier to use. We have a realize handler anyway, so lets use it and grab the focus after chaining up to the parent. What say?
Comment 12 Debarshi Ray 2012-11-09 19:02:41 UTC
Created attachment 228607 [details] [review]
online-accounts: Don't preselect the first item when adding an account
Comment 13 Debarshi Ray 2012-11-09 19:03:29 UTC
This problem has been fixed in our software repository. The fix will go into the next software release. Thank you for your bug report.