Remove separators from dialogs

It seems more reasonable to remove this feature than to keep fighting
off every separator that pops up by accident in a dialog.
This commit is contained in:
Matthias Clasen 2010-09-02 09:11:23 -04:00
parent 97cd2500c3
commit d433a60611
14 changed files with 6 additions and 218 deletions

View File

@ -910,7 +910,6 @@ gtk_dialog_add_button
gtk_dialog_add_buttons G_GNUC_NULL_TERMINATED
gtk_dialog_get_action_area
gtk_dialog_get_content_area
gtk_dialog_get_has_separator
gtk_dialog_get_widget_for_response
gtk_dialog_get_response_for_widget
gtk_dialog_get_type G_GNUC_CONST
@ -922,7 +921,6 @@ gtk_alternative_dialog_button_order
gtk_dialog_set_alternative_button_order
gtk_dialog_set_alternative_button_order_from_array
gtk_dialog_set_default_response
gtk_dialog_set_has_separator
gtk_dialog_set_response_sensitive
#endif
#endif

View File

@ -631,7 +631,6 @@ gtk_about_dialog_init (GtkAboutDialog *about)
content_area = gtk_dialog_get_content_area (dialog);
action_area = gtk_dialog_get_action_area (dialog);
gtk_dialog_set_has_separator (dialog, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
@ -2219,7 +2218,6 @@ display_credits_dialog (GtkWidget *button,
content_area = gtk_dialog_get_content_area (credits_dialog);
action_area = gtk_dialog_get_action_area (credits_dialog);
gtk_dialog_set_has_separator (credits_dialog, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (credits_dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
@ -2302,7 +2300,6 @@ display_license_dialog (GtkWidget *button,
content_area = gtk_dialog_get_content_area (license_dialog);
action_area = gtk_dialog_get_action_area (license_dialog);
gtk_dialog_set_has_separator (license_dialog, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (license_dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);

View File

@ -151,7 +151,6 @@ gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag)
content_area = gtk_dialog_get_content_area (dialog);
action_area = gtk_dialog_get_action_area (dialog);
gtk_dialog_set_has_separator (dialog, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
@ -188,8 +187,6 @@ gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag)
gtk_window_set_title (GTK_WINDOW (colorseldiag),
_("Color Selection"));
_gtk_dialog_set_ignore_separator (dialog, TRUE);
}
GtkWidget*

View File

@ -976,7 +976,6 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog)
content_area = gtk_dialog_get_content_area (cpu_dialog);
action_area = gtk_dialog_get_action_area (cpu_dialog);
gtk_dialog_set_has_separator (cpu_dialog, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);

View File

@ -31,7 +31,6 @@
#include "gtkdialog.h"
#include "gtkhbbox.h"
#include "gtklabel.h"
#include "gtkhseparator.h"
#include "gtkmarshalers.h"
#include "gtkvbox.h"
#include "gdkkeysyms.h"
@ -46,10 +45,6 @@ struct _GtkDialogPrivate
{
GtkWidget *vbox;
GtkWidget *action_area;
GtkWidget *separator;
guint ignore_separator : 1;
};
typedef struct _ResponseData ResponseData;
@ -66,15 +61,6 @@ static void gtk_dialog_add_buttons_valist (GtkDialog *dialog,
static gboolean gtk_dialog_delete_event_handler (GtkWidget *widget,
GdkEventAny *event,
gpointer user_data);
static void gtk_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_dialog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_dialog_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gtk_dialog_map (GtkWidget *widget);
@ -124,32 +110,16 @@ gtk_dialog_class_init (GtkDialogClass *class)
GObjectClass *gobject_class;
GtkWidgetClass *widget_class;
GtkBindingSet *binding_set;
gobject_class = G_OBJECT_CLASS (class);
widget_class = GTK_WIDGET_CLASS (class);
gobject_class->set_property = gtk_dialog_set_property;
gobject_class->get_property = gtk_dialog_get_property;
widget_class->map = gtk_dialog_map;
widget_class->style_set = gtk_dialog_style_set;
class->close = gtk_dialog_close;
g_type_class_add_private (gobject_class, sizeof (GtkDialogPrivate));
/**
* GtkDialog:has-separator:
*
* When %TRUE, the dialog has a separator bar above its buttons.
*/
g_object_class_install_property (gobject_class,
PROP_HAS_SEPARATOR,
g_param_spec_boolean ("has-separator",
P_("Has separator"),
P_("The dialog has a separator bar above its buttons"),
TRUE,
GTK_PARAM_READWRITE));
g_type_class_add_private (gobject_class, sizeof (GtkDialogPrivate));
/**
* GtkDialog::response:
@ -278,8 +248,6 @@ gtk_dialog_init (GtkDialog *dialog)
GtkDialogPrivate);
priv = dialog->priv;
priv->ignore_separator = FALSE;
/* To avoid breaking old code that prevents destroy on delete event
* by connecting a handler, we have to have the FIRST signal
* connection on the dialog.
@ -303,10 +271,6 @@ gtk_dialog_init (GtkDialog *dialog)
FALSE, TRUE, 0);
gtk_widget_show (priv->action_area);
priv->separator = gtk_hseparator_new ();
gtk_box_pack_end (GTK_BOX (priv->vbox), priv->separator, FALSE, TRUE, 0);
gtk_widget_show (priv->separator);
gtk_window_set_type_hint (GTK_WINDOW (dialog),
GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
@ -340,49 +304,6 @@ gtk_dialog_buildable_get_internal_child (GtkBuildable *buildable,
childname);
}
static void
gtk_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkDialog *dialog;
dialog = GTK_DIALOG (object);
switch (prop_id)
{
case PROP_HAS_SEPARATOR:
gtk_dialog_set_has_separator (dialog, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_dialog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkDialog *dialog = GTK_DIALOG (object);
GtkDialogPrivate *priv = dialog->priv;
switch (prop_id)
{
case PROP_HAS_SEPARATOR:
g_value_set_boolean (value, priv->separator != NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
gtk_dialog_delete_event_handler (GtkWidget *widget,
GdkEventAny *event,
@ -534,13 +455,10 @@ gtk_dialog_new_empty (const gchar *title,
if (flags & GTK_DIALOG_MODAL)
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
if (flags & GTK_DIALOG_NO_SEPARATOR)
gtk_dialog_set_has_separator (dialog, FALSE);
return GTK_WIDGET (dialog);
}
@ -872,69 +790,6 @@ gtk_dialog_set_default_response (GtkDialog *dialog,
g_list_free (children);
}
/**
* gtk_dialog_set_has_separator:
* @dialog: a #GtkDialog
* @setting: %TRUE to have a separator
*
* Sets whether the dialog has a separator above the buttons.
* %TRUE by default.
**/
void
gtk_dialog_set_has_separator (GtkDialog *dialog,
gboolean setting)
{
GtkDialogPrivate *priv;
g_return_if_fail (GTK_IS_DIALOG (dialog));
priv = dialog->priv;
/* this might fail if we get called before _init() somehow */
g_assert (priv->vbox != NULL);
if (priv->ignore_separator)
{
g_warning ("Ignoring the separator setting");
return;
}
if (setting && priv->separator == NULL)
{
priv->separator = gtk_hseparator_new ();
gtk_box_pack_end (GTK_BOX (priv->vbox), priv->separator, FALSE, TRUE, 0);
/* The app programmer could screw this up, but, their own fault.
* Moves the separator just above the action area.
*/
gtk_box_reorder_child (GTK_BOX (priv->vbox), priv->separator, 1);
gtk_widget_show (priv->separator);
}
else if (!setting && priv->separator != NULL)
{
gtk_widget_destroy (priv->separator);
priv->separator = NULL;
}
g_object_notify (G_OBJECT (dialog), "has-separator");
}
/**
* gtk_dialog_get_has_separator:
* @dialog: a #GtkDialog
*
* Accessor for whether the dialog has a separator.
*
* Return value: %TRUE if the dialog has a separator
**/
gboolean
gtk_dialog_get_has_separator (GtkDialog *dialog)
{
g_return_val_if_fail (GTK_IS_DIALOG (dialog), FALSE);
return dialog->priv->separator != NULL;
}
/**
* gtk_dialog_response:
* @dialog: a #GtkDialog
@ -1136,15 +991,6 @@ gtk_dialog_run (GtkDialog *dialog)
return ri.response_id;
}
void
_gtk_dialog_set_ignore_separator (GtkDialog *dialog,
gboolean ignore_separator)
{
GtkDialogPrivate *priv = dialog->priv;
priv->ignore_separator = ignore_separator;
}
/**
* gtk_dialog_get_widget_for_response:
* @dialog: a #GtkDialog

View File

@ -41,8 +41,7 @@ G_BEGIN_DECLS
typedef enum
{
GTK_DIALOG_MODAL = 1 << 0, /* call gtk_window_set_modal (win, TRUE) */
GTK_DIALOG_DESTROY_WITH_PARENT = 1 << 1, /* call gtk_window_set_destroy_with_parent () */
GTK_DIALOG_NO_SEPARATOR = 1 << 2 /* no separator bar above buttons */
GTK_DIALOG_DESTROY_WITH_PARENT = 1 << 1 /* call gtk_window_set_destroy_with_parent () */
} GtkDialogFlags;
/* Convenience enum to use for response_id's. Positive values are
@ -150,10 +149,6 @@ GtkWidget* gtk_dialog_get_widget_for_response (GtkDialog *dialog,
gint gtk_dialog_get_response_for_widget (GtkDialog *dialog,
GtkWidget *widget);
void gtk_dialog_set_has_separator (GtkDialog *dialog,
gboolean setting);
gboolean gtk_dialog_get_has_separator (GtkDialog *dialog);
gboolean gtk_alternative_dialog_button_order (GdkScreen *screen);
void gtk_dialog_set_alternative_button_order (GtkDialog *dialog,
gint first_response_id,
@ -172,10 +167,6 @@ gint gtk_dialog_run (GtkDialog *dialog);
GtkWidget * gtk_dialog_get_action_area (GtkDialog *dialog);
GtkWidget * gtk_dialog_get_content_area (GtkDialog *dialog);
/* For private use only */
void _gtk_dialog_set_ignore_separator (GtkDialog *dialog,
gboolean ignore_separator);
G_END_DECLS
#endif /* __GTK_DIALOG_H__ */

View File

@ -92,7 +92,6 @@ gtk_file_chooser_dialog_init (GtkFileChooserDialog *dialog)
content_area = gtk_dialog_get_content_area (fc_dialog);
action_area = gtk_dialog_get_action_area (fc_dialog);
gtk_dialog_set_has_separator (fc_dialog, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (fc_dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);

View File

@ -1618,7 +1618,6 @@ gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag)
content_area = gtk_dialog_get_content_area (dialog);
action_area = gtk_dialog_get_action_area (dialog);
gtk_dialog_set_has_separator (dialog, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
@ -1660,8 +1659,6 @@ gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag)
_("Font Selection"));
gtk_widget_pop_composite_child ();
_gtk_dialog_set_ignore_separator (dialog, TRUE);
}
/**

View File

@ -187,20 +187,7 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class)
G_MAXINT,
12,
GTK_PARAM_READABLE));
/**
* GtkMessageDialog:use-separator:
*
* Whether to draw a separator line between the message label and the buttons
* in the dialog.
*
* Since: 2.4
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("use-separator",
P_("Use separator"),
P_("Whether to put a separator between the message dialog's text and the buttons"),
FALSE,
GTK_PARAM_READABLE));
/**
* GtkMessageDialog:message-type:
*
@ -386,8 +373,6 @@ gtk_message_dialog_init (GtkMessageDialog *dialog)
gtk_box_set_spacing (GTK_BOX (action_area), 6);
gtk_widget_show_all (hbox);
_gtk_dialog_set_ignore_separator (GTK_DIALOG (dialog), TRUE);
}
static void
@ -616,12 +601,6 @@ gtk_message_dialog_new (GtkWindow *parent,
NULL);
dialog = GTK_DIALOG (widget);
if (flags & GTK_DIALOG_NO_SEPARATOR)
{
g_warning ("The GTK_DIALOG_NO_SEPARATOR flag cannot be used for GtkMessageDialog");
flags &= ~GTK_DIALOG_NO_SEPARATOR;
}
if (message_format)
{
va_start (args, message_format);
@ -1001,7 +980,6 @@ gtk_message_dialog_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
GtkMessageDialog *dialog = GTK_MESSAGE_DIALOG (widget);
gboolean use_separator;
GtkWidget *parent;
gint border_width;
@ -1016,14 +994,6 @@ gtk_message_dialog_style_set (GtkWidget *widget,
MAX (0, border_width - 7));
}
gtk_widget_style_get (widget,
"use-separator", &use_separator,
NULL);
_gtk_dialog_set_ignore_separator (GTK_DIALOG (widget), FALSE);
gtk_dialog_set_has_separator (GTK_DIALOG (widget), use_separator);
_gtk_dialog_set_ignore_separator (GTK_DIALOG (widget), TRUE);
setup_primary_label_font (dialog);
GTK_WIDGET_CLASS (gtk_message_dialog_parent_class)->style_set (widget, prev_style);

View File

@ -477,7 +477,6 @@ gtk_mount_operation_ask_password (GMountOperation *mount_op,
action_area = gtk_dialog_get_action_area (dialog);
/* Set the dialog up with HIG properties */
gtk_dialog_set_has_separator (dialog, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
@ -1217,7 +1216,6 @@ create_show_processes_dialog (GMountOperation *op,
if (priv->parent_window != NULL)
gtk_window_set_transient_for (GTK_WINDOW (dialog), priv->parent_window);
gtk_window_set_title (GTK_WINDOW (dialog), "");
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
vbox = gtk_vbox_new (FALSE, 12);

View File

@ -894,7 +894,6 @@ populate_dialog (GtkPageSetupUnixDialog *ps_dialog)
content_area = gtk_dialog_get_content_area (dialog);
action_area = gtk_dialog_get_action_area (dialog);
gtk_dialog_set_has_separator (dialog, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);

View File

@ -748,7 +748,6 @@ request_password (GtkPrintBackend *backend,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
main_box = gtk_hbox_new (FALSE, 0);

View File

@ -3796,7 +3796,6 @@ populate_dialog (GtkPrintUnixDialog *print_dialog)
content_area = gtk_dialog_get_content_area (dialog);
action_area = gtk_dialog_get_action_area (dialog);
gtk_dialog_set_has_separator (dialog, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);

View File

@ -143,7 +143,6 @@ gtk_recent_chooser_dialog_init (GtkRecentChooserDialog *dialog)
content_area = gtk_dialog_get_content_area (rc_dialog);
action_area = gtk_dialog_get_action_area (rc_dialog);
gtk_dialog_set_has_separator (rc_dialog, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (rc_dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);