GNOME Bugzilla – Bug 687875
Don't preselect the first item when adding a new account
Last modified: 2012-11-09 19:03:29 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)
Created attachment 228408 [details] Screenshot of existing dialog
Created attachment 228410 [details] [review] online-accounts: Don't preselect the first item when adding an account
Created attachment 228411 [details] Screenshot after patch
Created attachment 228412 [details] [review] online-accounts: Don't preselect the first item when adding an account
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.
(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.
Created attachment 228604 [details] [review] online-accounts: Don't preselect the first item when adding an account
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.
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.
(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",
(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?
Created attachment 228607 [details] [review] online-accounts: Don't preselect the first item when adding an account
This problem has been fixed in our software repository. The fix will go into the next software release. Thank you for your bug report.