[gtk+/gtk-2-22] bgo#328069 - Add gtk_message_dialog_get_message_area()



commit ce504e221781ab49ccc8b00606a0b732decb12fc
Author: Federico Mena Quintero <federico novell com>
Date:   Tue Jun 22 13:10:52 2010 -0500

    bgo#328069 - Add gtk_message_dialog_get_message_area()
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 gtk/gtkmessagedialog.c |   57 +++++++++++++++++++++++++++++++++++++++++++----
 gtk/gtkmessagedialog.h |    2 +
 2 files changed, 54 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c
index 18adeea..f9c7282 100644
--- a/gtk/gtkmessagedialog.c
+++ b/gtk/gtkmessagedialog.c
@@ -93,6 +93,7 @@ typedef struct _GtkMessageDialogPrivate GtkMessageDialogPrivate;
 
 struct _GtkMessageDialogPrivate
 {
+  GtkWidget *message_area; /* vbox for the primary and secondary labels, and any extra content from the caller */
   GtkWidget *secondary_label;
   guint message_type : 3;
   guint has_primary_markup : 1;
@@ -121,7 +122,8 @@ enum {
   PROP_USE_MARKUP,
   PROP_SECONDARY_TEXT,
   PROP_SECONDARY_USE_MARKUP,
-  PROP_IMAGE
+  PROP_IMAGE,
+  PROP_MESSAGE_AREA
 };
 
 G_DEFINE_TYPE (GtkMessageDialog, gtk_message_dialog, GTK_TYPE_DIALOG)
@@ -264,6 +266,23 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class)
                                                         GTK_TYPE_WIDGET,
                                                         GTK_PARAM_READWRITE));
 
+  /**
+   * GtkMessageDialog:message-area
+   *
+   * The #GtkVBox that corresponds to the message area of this dialog.  See
+   * gtk_message_dialog_get_message_area() for a detailed description of this
+   * area.
+   *
+   * Since: 2.22
+   */
+  g_object_class_install_property (gobject_class,
+				   PROP_MESSAGE_AREA,
+				   g_param_spec_object ("message-area",
+							P_("Message area"),
+							P_("GtkVBox that holds the dialog's primary and secondary labels"),
+							GTK_TYPE_WIDGET,
+							GTK_PARAM_READABLE));
+
   g_type_class_add_private (gobject_class,
 			    sizeof (GtkMessageDialogPrivate));
 }
@@ -298,18 +317,18 @@ gtk_message_dialog_init (GtkMessageDialog *dialog)
   gtk_misc_set_alignment   (GTK_MISC  (priv->secondary_label), 0.0, 0.0);
 
   hbox = gtk_hbox_new (FALSE, 12);
-  vbox = gtk_vbox_new (FALSE, 12);
+  priv->message_area = gtk_vbox_new (FALSE, 12);
 
-  gtk_box_pack_start (GTK_BOX (vbox), dialog->label,
+  gtk_box_pack_start (GTK_BOX (priv->message_area), dialog->label,
                       FALSE, FALSE, 0);
 
-  gtk_box_pack_start (GTK_BOX (vbox), priv->secondary_label,
+  gtk_box_pack_start (GTK_BOX (priv->message_area), priv->secondary_label,
                       TRUE, TRUE, 0);
 
   gtk_box_pack_start (GTK_BOX (hbox), dialog->image,
                       FALSE, FALSE, 0);
 
-  gtk_box_pack_start (GTK_BOX (hbox), vbox,
+  gtk_box_pack_start (GTK_BOX (hbox), priv->message_area,
                       TRUE, TRUE, 0);
 
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
@@ -514,6 +533,9 @@ gtk_message_dialog_get_property (GObject     *object,
     case PROP_IMAGE:
       g_value_set_object (value, dialog->image);
       break;
+    case PROP_MESSAGE_AREA:
+      g_value_set_object (value, priv->message_area);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -852,6 +874,31 @@ gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog,
   setup_primary_label_font (message_dialog);
 }
 
+/**
+ * gtk_message_dialog_get_message_area:
+ * @message_dialog: a #GtkMessageDialog
+ *
+ * Return value: A #GtkVBox corresponding to the "message area" in the
+ * @message_dialog.  This is the box where the dialog's primary and secondary
+ * labels are packed.  You can add your own extra content to that box and it
+ * will appear below those labels, on the right side of the dialog's image (or
+ * on the left for right-to-left languages).  See gtk_dialog_get_content_area()
+ * for the corresponding function in the parent #GtkDialog.
+ *
+ * Since: 2.22
+ **/
+GtkWidget *
+gtk_message_dialog_get_message_area (GtkMessageDialog *message_dialog)
+{
+  GtkMessageDialogPrivate *priv;
+
+  g_return_val_if_fail (GTK_IS_MESSAGE_DIALOG (message_dialog), NULL);
+
+  priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (message_dialog);
+
+  return priv->message_area;
+}
+
 static void
 gtk_message_dialog_add_buttons (GtkMessageDialog* message_dialog,
 				GtkButtonsType buttons)
diff --git a/gtk/gtkmessagedialog.h b/gtk/gtkmessagedialog.h
index c46c7b3..3c6f2f7 100644
--- a/gtk/gtkmessagedialog.h
+++ b/gtk/gtkmessagedialog.h
@@ -128,6 +128,8 @@ void       gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message
                                                        const gchar      *message_format,
                                                        ...) G_GNUC_PRINTF (2, 3);
 
+GtkWidget *gtk_message_dialog_get_message_area (GtkMessageDialog *message_dialog);
+
 G_END_DECLS
 
 #endif /* __GTK_MESSAGE_DIALOG_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]