GNOME Bugzilla – Bug 163850
Gtk+ dialogs should use HIG spacing by default.
Last modified: 2011-02-04 16:10:27 UTC
Currently, the gtk dialogs use non standard widget padding. This has always been confusing for developers, because the HIG asks for 12 pixels around the border and 12 pixels between the vbox and action area of the dialog. To achieve HIG compliant spacing, programmers must add code to their application similar to the following: gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2); I would prefer to see the dialog spacing HIG compliant by default so no additional code is neccessary. Or, at least the dialog should actually be HIG compliant when adding the lines: gtk_container_set_border_width (GTK_CONTAINER (dialog), 12); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 12); I am opening this bug in hopes that it can be fixed in Gtk+ version 3. ;-)
See bug 163317 for an example of the confusion this problem can cause.
The most simple way to create an HIG compliant dialog should be use this code in GtkDialog init function: dialog->vbox = gtk_vbox_new (FALSE, 24); gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 12); gtk_container_add (GTK_CONTAINER (dialog), dialog->vbox); gtk_widget_show (dialog->vbox); dialog->action_area = gtk_hbutton_box_new (); gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6); gtk_box_pack_end (GTK_BOX (dialog->vbox), dialog->action_area, FALSE, TRUE, 0); gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog->action_area), GTK_BUTTONBOX_END); gtk_widget_show (dialog->action_area); Advantages: - the dialog spacing/border sizes will be HIG compliant - developers/UI designers can ignore spacing/padding of the dialog and take care only of the stuff they put inside the dialog. So when you add a container in the dialog it's well aligned (e.g. a GtkNotebook). - all dialogs will have the same spacing/border size Notes: - this will break API compatibility with 2.x series (no more separator properties/functions and no more content_area_border, button_spacing, and action_area_border styles) - dialog->vbox spacing and border width could be editable as style properties. This could be useful for LargePrint a11y themes. But ask a11y people before do it. - the gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6); call inside GtkDialog init function is bad idea too. The default spacing of a GtkButtonBox should be 6 pixel, maybe editable as style, so you don't have to change. - Do we have to put the separator for Windows(TM)? Enhancements: - Could we use a different minimum padding for Help button? [ Help ] <-24px-> [ Apply ] [ Cancel ] [ OK ] ^ ^ ^----------^---6 px - Could we add a default shortcut (F1) to activate Help button response?
About buttons spacing take a look at: http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGDialogs/chapter_9_section_3.html
Created attachment 51135 [details] [review] Proposed patch This patch makes the GtkDialog and GtkMessageDialog GNOME HIG compliant by default. Applications will no longer need to adjust the border width of the dialog, dialog->vbox, and dialog->action_area themselves. Also, it removes the dialog title from the GtkMessageDialogs per the HIG. And, it fixes the spacing between buttons in the dialog->action_area to be HIG compliant.
If the above patch (or something similar) is committed to CVS, then the following code should be removed from GNOME applications. gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2); gtk_window_set_title (GTK_WINDOW (dialog), ""); I can help remove this code from GNOME, since I am responsible for most of it anyhow.
*** Bug 165083 has been marked as a duplicate of this bug. ***
The title issue is covered by bug 310443, which also has a patch
Created attachment 51308 [details] [review] Proposed patch Same as my previous patch except I removed the title issue fix since it is covered by a patch in bug 310443.
Created attachment 51310 [details] [review] Proposed patch (Font Selection Dialog) This patch makes the Font Selection dialog HIG compliant. It assumes the previous patch for GtkDialog and GtkMessageDialog was applied.
Created attachment 51311 [details] Screenshot of the Font Selection dialog.
Created attachment 51317 [details] [review] Proposed patch (Input Dialog)
Created attachment 51318 [details] Screenshot of the Input dialog (Axes tab).
Created attachment 51319 [details] Screenshot of the Input dialog (Keys tab).
Created attachment 51346 [details] [review] Proposed patch (Color Selection Dialog)
Created attachment 51347 [details] Screenshot of the Color Selection dialog.
Created attachment 51348 [details] [review] Updated proposed patch (Font Selection Dialog) The previously proposed patch for the Font Selection dialog was missing one line.
*** Bug 328018 has been marked as a duplicate of this bug. ***
Created attachment 58589 [details] [review] all-in-one patch This patch contains all above patches (to gtkmessagedialog.c, gtkcolorsel.c gtkcolorseldialog.c gtkinputdialog.c gtkfontsel.c) in one, with the exception of the changes to gtkdialog.c. I think changing the default spacings of gtkdialog will break too much existing dialogues that rely on the default values, and make them of broken appearance. This patch instead sets the spacings/borders for each dialogue. IMHO this patch is therefore appropriate for a 2.x release.
The patch has string changes (why ?), so it will certainly not go into 2.8.x
Sorry, I meant that it's appropriate to add to an unstable gtk 2.odd.x release, as opposed to the 'gtk 3' that comment 0 speaks of :) The string changes seem to be mostly accelerator _ added/removed, not sure why it was done (I can't see the input dialogue since I have no inputs)...
Thanks for combining these patches into one. The string changes were also part of the HIG fixes. * remove trailing space from label as per HIG * add or remove mnemonics as per HIG * add missing colon to labels as per HIG * fix capitalization as per HIG
Any chance of this stuff getting fixed for GTK+ 2.10 / Project Ridley?
I think I'm fine with most of the changes, but I don't think we should just ignore the message-border style property. If I understood the code correctly, we should probably do something like if (parent) { gtk_widget_style_get (widget, "message-border", &border_width, NULL); gtk_container_set_border_width (GTK_CONTAINER (parent), MAX (0, border_width - 7)); } to account for the fact that the hbox only receives 5 of the default 12 in the default setup.
Created attachment 61020 [details] [review] Updated all-in-one proposed patch Matthais, Thanks for your feedback. I updated the all-in-one patch with the changes you recommended in comment #23.
2006-03-10 Matthias Clasen <mclasen@redhat.com> Apply a patch from Dennis Cranston to make dialogs more consistent (#163850) * gtk/gtkcolorsel.c (make_label_spinbutton): Left-align labels. * gtk/gtkfontsel.c (gtk_font_selection_init): * gtk/gtkfontsel.c (gtk_font_selection_dialog_init): * gtk/gtkcolorsel.c (gtk_color_selection_init): * gtk/gtkcolorseldialog.c (gtk_color_selection_dialog_init): * gtk/gtkinputdialog.c (gtk_input_dialog_init): Update the layout of the dialog to follow HIG recommendations. Also update labels. * gtk/gtkmessagedialog.c (gtk_message_dialog_init): HIG-compatible spacing. (gtk_message_dialog_font_size_change): Merged into gtk_message_dialog_style_set.
Created attachment 61058 [details] [review] additional patch to change default button spacing The other GtkDialog spacings can't be changed compatibly, but IMHO changing the default button spacing to HIG-default of 6px should be compatible enough; what do you think?
Created attachment 61059 [details] [review] Patch to fix a mnemonic conflict. The patch applied to CVS uses the 'O' for the "Opacity" label mnemonic which will conflict with the 'O' mnemonic for the "OK" button. This patch fixes the mnemonic conflict.
Created attachment 61069 [details] [review] Patch to fix a mnemonic conflict and missing colon. Two label fixes from the all-in-one patch were not applied to CVS. 2006-03-10 Dennis Cranston <dennis_cranston@yahoo.com> * gtk/gtkcolorsel.c: (gtk_color_selection_init): Fix a mnemonic conflict. Add a missing colon to the pallete label.
Comment on attachment 61058 [details] [review] additional patch to change default button spacing Can this patch be committed too? It's just changing the default dialog buttonbox spacing from 10 to 6 (HIG) and should be sufficiently compatible...