summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2004-02-03 19:46:43 +0000
committerFederico Mena Quintero <federico@src.gnome.org>2004-02-03 19:46:43 +0000
commitd08dd112ccda04400cdb19360903971525c24706 (patch)
tree121e980c836f7c706343d8a7904a09804a801159 /gtk
parent35efc9ba05a4f75936b434c4db934aaaa327be6d (diff)
downloadgtk+-d08dd112ccda04400cdb19360903971525c24706.tar.gz
Fix #68938.
2004-02-03 Federico Mena Quintero <federico@ximian.com> Fix #68938. * gtk/gtkdialog.c (GtkDialogPrivate): New private structure for GtkDialog; right now it only contains an ignore_separator field. (gtk_dialog_class_init): Register the private structure. (gtk_dialog_init): Initialize the priv->ignore_separator field. (_gtk_dialog_set_ignore_separator): New private function. (gtk_dialog_set_has_separator): Ignore the setting if appropriate. * gtk/gtkmessagedialog.c (gtk_message_dialog_class_init): Add a use_separator style property. (gtk_message_dialog_style_set): Change the dialog's separator based on the style property. (gtk_message_dialog_init): Set the dialog box to ignore the separator setting.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkdialog.c33
-rw-r--r--gtk/gtkdialog.h5
-rw-r--r--gtk/gtkmessagedialog.c16
3 files changed, 54 insertions, 0 deletions
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index 4785cf3616..5b05b9d80a 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -35,6 +35,12 @@
#include "gtkintl.h"
#include "gtkbindings.h"
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_DIALOG, GtkDialogPrivate))
+
+typedef struct {
+ guint ignore_separator : 1;
+} GtkDialogPrivate;
+
typedef struct _ResponseData ResponseData;
struct _ResponseData
@@ -130,6 +136,8 @@ gtk_dialog_class_init (GtkDialogClass *class)
class->close = gtk_dialog_close;
+ g_type_class_add_private (gobject_class, sizeof (GtkDialogPrivate));
+
g_object_class_install_property (gobject_class,
PROP_HAS_SEPARATOR,
g_param_spec_boolean ("has_separator",
@@ -219,6 +227,11 @@ update_spacings (GtkDialog *dialog)
static void
gtk_dialog_init (GtkDialog *dialog)
{
+ GtkDialogPrivate *priv;
+
+ priv = GET_PRIVATE (dialog);
+ 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.
@@ -766,10 +779,20 @@ void
gtk_dialog_set_has_separator (GtkDialog *dialog,
gboolean setting)
{
+ GtkDialogPrivate *priv;
+
g_return_if_fail (GTK_IS_DIALOG (dialog));
+ priv = GET_PRIVATE (dialog);
+
/* this might fail if we get called before _init() somehow */
g_assert (dialog->vbox != NULL);
+
+ if (priv->ignore_separator)
+ {
+ g_warning ("Ignoring the separator setting");
+ return;
+ }
if (setting && dialog->separator == NULL)
{
@@ -1001,3 +1024,13 @@ gtk_dialog_run (GtkDialog *dialog)
return ri.response_id;
}
+
+void
+_gtk_dialog_set_ignore_separator (GtkDialog *dialog,
+ gboolean ignore_separator)
+{
+ GtkDialogPrivate *priv;
+
+ priv = GET_PRIVATE (dialog);
+ priv->ignore_separator = ignore_separator;
+}
diff --git a/gtk/gtkdialog.h b/gtk/gtkdialog.h
index 953857c465..60c860fa47 100644
--- a/gtk/gtkdialog.h
+++ b/gtk/gtkdialog.h
@@ -159,6 +159,11 @@ void gtk_dialog_response (GtkDialog *dialog,
/* Returns response_id */
gint gtk_dialog_run (GtkDialog *dialog);
+
+/* For private use only */
+void _gtk_dialog_set_ignore_separator (GtkDialog *dialog,
+ gboolean ignore_separator);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c
index 4c74ffeb99..71c53d6833 100644
--- a/gtk/gtkmessagedialog.c
+++ b/gtk/gtkmessagedialog.c
@@ -109,6 +109,12 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class)
G_MAXINT,
8,
G_PARAM_READABLE));
+ 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,
+ G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_MESSAGE_TYPE,
g_param_spec_enum ("message_type",
@@ -153,6 +159,8 @@ gtk_message_dialog_init (GtkMessageDialog *dialog)
FALSE, FALSE, 0);
gtk_widget_show_all (hbox);
+
+ _gtk_dialog_set_ignore_separator (GTK_DIALOG (dialog), TRUE);
}
static GtkMessageType
@@ -499,6 +507,7 @@ gtk_message_dialog_style_set (GtkWidget *widget,
{
GtkWidget *parent;
gint border_width = 0;
+ gboolean use_separator;
parent = GTK_WIDGET (GTK_MESSAGE_DIALOG (widget)->image->parent);
@@ -511,6 +520,13 @@ gtk_message_dialog_style_set (GtkWidget *widget,
border_width);
}
+ 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);
+
if (GTK_WIDGET_CLASS (parent_class)->style_set)
(GTK_WIDGET_CLASS (parent_class)->style_set) (widget, prev_style);
}