diff options
author | Matthias Clasen <matthiasc@src.gnome.org> | 2006-01-11 15:23:05 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2006-01-11 15:23:05 +0000 |
commit | 235144125fc36ee8e8590a34c3b587849c0eb460 (patch) | |
tree | 230c8b84fd5f9387f18ea69b754b391335cd73a6 /gtk/gtkmessagedialog.c | |
parent | 5453f1146495a7f8a03ed9d5300c4e70f8674be5 (diff) | |
download | gtk+-235144125fc36ee8e8590a34c3b587849c0eb460.tar.gz |
Add properties. (#311254, Johan Dahlin) (gtk_message_dialog_new): Remove
* gtk/gtkmessagedialog.c: Add properties. (#311254,
Johan Dahlin)
(gtk_message_dialog_new): Remove some redundant code, pointed
out by Gustavo Carneiro.
Diffstat (limited to 'gtk/gtkmessagedialog.c')
-rw-r--r-- | gtk/gtkmessagedialog.c | 149 |
1 files changed, 138 insertions, 11 deletions
diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c index 4995f65ad7..01fef42b41 100644 --- a/gtk/gtkmessagedialog.c +++ b/gtk/gtkmessagedialog.c @@ -73,7 +73,11 @@ static void gtk_message_dialog_font_size_change (GtkWidget *widget, enum { PROP_0, PROP_MESSAGE_TYPE, - PROP_BUTTONS + PROP_BUTTONS, + PROP_TEXT, + PROP_USE_MARKUP, + PROP_SECONDARY_TEXT, + PROP_SECONDARY_USE_MARKUP }; static gpointer parent_class; @@ -159,6 +163,70 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class) GTK_TYPE_BUTTONS_TYPE, GTK_BUTTONS_NONE, GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); + + /** + * GtkMessageDialog:text: + * + * The primary text of the message dialog. If the dialog has + * a secondary text, this will appear as the title. + * + * Since: 2.10 + */ + g_object_class_install_property (gobject_class, + PROP_TEXT, + g_param_spec_string ("text", + P_("Text"), + P_("The primary text of the message dialog"), + NULL, + GTK_PARAM_READWRITE)); + + /** + * GtkMessageDialog:use-markup: + * + * %TRUE if the primary text of the dialog includes Pango markup. + * See pango_parse_markup(). + * + * Since: 2.10 + */ + g_object_class_install_property (gobject_class, + PROP_USE_MARKUP, + g_param_spec_boolean ("use-markup", + P_("Use Markup"), + P_("The primary text of the title includes Pango markup."), + FALSE, + GTK_PARAM_READWRITE)); + + /** + * GtkMessageDialog:secondary-text: + * + * The secondary text of the message dialog. + * + * Since: 2.10 + */ + g_object_class_install_property (gobject_class, + PROP_SECONDARY_TEXT, + g_param_spec_string ("secondary-text", + P_("Secondary Text"), + P_("The secondary text of the message dialog"), + NULL, + GTK_PARAM_READWRITE)); + + /** + * GtkMessageDialog:secondary-use-markup: + * + * %TRUE if the secondary text of the dialog includes Pango markup. + * See pango_parse_markup(). + * + * Since: 2.10 + */ + g_object_class_install_property (gobject_class, + PROP_SECONDARY_USE_MARKUP, + g_param_spec_boolean ("secondary-use-markup", + P_("Use Markup in secondary"), + P_("The secondary text includes Pango markup."), + FALSE, + GTK_PARAM_READWRITE)); + g_type_class_add_private (gobject_class, sizeof (GtkMessageDialogPrivate)); } @@ -257,13 +325,10 @@ setup_primary_label_font (GtkMessageDialog *dialog) priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (dialog); - if (priv->has_primary_markup) - return; - /* unset the font settings */ gtk_widget_modify_font (dialog->label, NULL); - if (priv->has_secondary_text) + if (priv->has_secondary_text && !priv->has_primary_markup) { size = pango_font_description_get_size (dialog->label->style->font_desc); font_desc = pango_font_description_new (); @@ -321,8 +386,10 @@ gtk_message_dialog_set_property (GObject *object, GParamSpec *pspec) { GtkMessageDialog *dialog; - + GtkMessageDialogPrivate *priv; + dialog = GTK_MESSAGE_DIALOG (object); + priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (dialog); switch (prop_id) { @@ -332,6 +399,47 @@ gtk_message_dialog_set_property (GObject *object, case PROP_BUTTONS: gtk_message_dialog_add_buttons (dialog, g_value_get_enum (value)); break; + case PROP_TEXT: + if (priv->has_primary_markup) + gtk_label_set_markup (GTK_LABEL (dialog->label), + g_value_get_string (value)); + else + gtk_label_set_text (GTK_LABEL (dialog->label), + g_value_get_string (value)); + break; + case PROP_USE_MARKUP: + priv->has_primary_markup = g_value_get_boolean (value); + gtk_label_set_use_markup (GTK_LABEL (dialog->label), + priv->has_primary_markup); + setup_primary_label_font (dialog); + break; + case PROP_SECONDARY_TEXT: + { + const gchar *txt = g_value_get_string (value); + + if (gtk_label_get_use_markup (GTK_LABEL (priv->secondary_label))) + gtk_label_set_markup (GTK_LABEL (priv->secondary_label), txt); + else + gtk_label_set_text (GTK_LABEL (priv->secondary_label), txt); + + if (txt) + { + priv->has_secondary_text = TRUE; + gtk_widget_show (priv->secondary_label); + } + else + { + priv->has_secondary_text = FALSE; + gtk_widget_hide (priv->secondary_label); + } + setup_primary_label_font (dialog); + } + break; + case PROP_SECONDARY_USE_MARKUP: + gtk_label_set_use_markup (GTK_LABEL (priv->secondary_label), + g_value_get_boolean (value)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -345,14 +453,36 @@ gtk_message_dialog_get_property (GObject *object, GParamSpec *pspec) { GtkMessageDialog *dialog; - + GtkMessageDialogPrivate *priv; + dialog = GTK_MESSAGE_DIALOG (object); - + priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (dialog); + switch (prop_id) { case PROP_MESSAGE_TYPE: g_value_set_enum (value, gtk_message_dialog_get_message_type (dialog)); break; + case PROP_TEXT: + g_value_set_string (value, gtk_label_get_label (GTK_LABEL (dialog->label))); + break; + case PROP_USE_MARKUP: + g_value_set_boolean (value, priv->has_primary_markup); + break; + case PROP_SECONDARY_TEXT: + if (priv->has_secondary_text) + g_value_set_string (value, + gtk_label_get_label (GTK_LABEL (priv->secondary_label))); + else + g_value_set_string (value, NULL); + break; + case PROP_SECONDARY_USE_MARKUP: + if (priv->has_secondary_text) + g_value_set_boolean (value, + gtk_label_get_use_markup (GTK_LABEL (priv->secondary_label))); + else + g_value_set_boolean (value, FALSE); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -434,9 +564,6 @@ gtk_message_dialog_new (GtkWindow *parent, 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 widget; } |