]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkmessagedialog.c
gtkenums: correct various documentation typos
[~andy/gtk] / gtk / gtkmessagedialog.c
index cc154ee07a3a4ce906bd9114ddd49b5de39c99b5..709fcfef0c86cf9710d6bf328bda3e0f398e24e0 100644 (file)
@@ -13,9 +13,7 @@
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
  * convenience widget; you could construct the equivalent of #GtkMessageDialog
  * from #GtkDialog without too much effort, but #GtkMessageDialog saves typing.
  *
+ * One difference from #GtkDialog is that #GtkMessageDialog sets the
+ * #GtkWindow:skip-taskbar-hint property to %TRUE, so that the dialog is hidden
+ * from the taskbar by default.
+ *
  * The easiest way to do a modal message dialog is to use gtk_dialog_run(), though
  * you can also pass in the %GTK_DIALOG_MODAL flag, gtk_dialog_run() automatically
  * makes the dialog modal and waits for the user to respond to it. gtk_dialog_run()
@@ -293,7 +295,7 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class)
                                                         GTK_PARAM_READWRITE));
 
   /**
-   * GtkMessageDialog:message-area
+   * 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
@@ -339,6 +341,7 @@ gtk_message_dialog_init (GtkMessageDialog *dialog)
 
   priv->label = gtk_label_new (NULL);
   priv->image = gtk_image_new_from_stock (NULL, GTK_ICON_SIZE_DIALOG);
+  g_object_set (priv->image, "use-fallback", TRUE, NULL);
   gtk_widget_set_halign (priv->image, GTK_ALIGN_CENTER);
   gtk_widget_set_valign (priv->image, GTK_ALIGN_START);
 
@@ -352,6 +355,9 @@ gtk_message_dialog_init (GtkMessageDialog *dialog)
   gtk_widget_set_halign (priv->secondary_label, GTK_ALIGN_START);
   gtk_widget_set_valign (priv->secondary_label, GTK_ALIGN_START);
 
+  gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.0);
+  gtk_misc_set_alignment (GTK_MISC (priv->secondary_label), 0.0, 0.0);
+
   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
   priv->message_area = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
 
@@ -386,25 +392,30 @@ static void
 setup_primary_label_font (GtkMessageDialog *dialog)
 {
   GtkMessageDialogPrivate *priv = dialog->priv;
-  gint size;
-  PangoFontDescription *font_desc;
-  GtkStyleContext *context;
-  GtkStateFlags state;
 
-  /* unset the font settings */
-  gtk_widget_override_font (priv->label, NULL);
+  if (!priv->has_primary_markup)
+    {
+      PangoAttrList *attributes;
+      PangoAttribute *attr;
+
+      attributes = pango_attr_list_new ();
+
+      attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
+      pango_attr_list_insert (attributes, attr);
 
-  if (priv->has_secondary_text && !priv->has_primary_markup)
+      if (priv->has_secondary_text)
+        {
+          attr = pango_attr_scale_new (PANGO_SCALE_LARGE);
+          pango_attr_list_insert (attributes, attr);
+        }
+
+      gtk_label_set_attributes (GTK_LABEL (priv->label), attributes);
+      pango_attr_list_unref (attributes);
+    }
+  else
     {
-      context = gtk_widget_get_style_context (priv->label);
-      state = gtk_widget_get_state_flags (priv->label);
-
-      size = pango_font_description_get_size (gtk_style_context_get_font (context, state));
-      font_desc = pango_font_description_new ();
-      pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
-      pango_font_description_set_size (font_desc, size * PANGO_SCALE_LARGE);
-      gtk_widget_override_font (priv->label, font_desc);
-      pango_font_description_free (font_desc);
+      /* unset the font settings */
+      gtk_label_set_attributes (GTK_LABEL (priv->label), NULL);
     }
 }
 
@@ -415,25 +426,30 @@ setup_type (GtkMessageDialog *dialog,
   GtkMessageDialogPrivate *priv = dialog->priv;
   const gchar *stock_id = NULL;
   AtkObject *atk_obj;
+  GIcon *gicon = NULL;
+
   priv->message_type = type;
 
   switch (type)
     {
     case GTK_MESSAGE_INFO:
       stock_id = GTK_STOCK_DIALOG_INFO;
+      gicon = g_themed_icon_new_with_default_fallbacks ("dialog-information-symbolic");
       break;
 
     case GTK_MESSAGE_QUESTION:
       stock_id = GTK_STOCK_DIALOG_QUESTION;
+      gicon = g_themed_icon_new_with_default_fallbacks ("dialog-question-symbolic");
       break;
 
     case GTK_MESSAGE_WARNING:
       stock_id = GTK_STOCK_DIALOG_WARNING;
+      gicon = g_themed_icon_new_with_default_fallbacks ("dialog-warning-symbolic");
       break;
-      
+
     case GTK_MESSAGE_ERROR:
       stock_id = GTK_STOCK_DIALOG_ERROR;
+      gicon = g_themed_icon_new_with_default_fallbacks ("dialog-error-symbolic");
       break;
 
     case GTK_MESSAGE_OTHER:
@@ -444,10 +460,10 @@ setup_type (GtkMessageDialog *dialog,
       break;
     }
 
-  if (stock_id)
-    gtk_image_set_from_stock (GTK_IMAGE (priv->image), stock_id,
-                              GTK_ICON_SIZE_DIALOG);
-      
+  gtk_image_set_from_gicon (GTK_IMAGE (priv->image), gicon, GTK_ICON_SIZE_DIALOG);
+  if (gicon)
+    g_object_unref (gicon);
+
   atk_obj = gtk_widget_get_accessible (GTK_WIDGET (dialog));
   if (GTK_IS_ACCESSIBLE (atk_obj))
     {
@@ -799,9 +815,6 @@ gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog,
  * Sets the secondary text of the message dialog to be @message_format
  * (with printf()-style).
  *
- * Note that setting a secondary text makes the primary text become
- * bold, unless you have provided explicit markup.
- *
  * Since: 2.6
  */
 void
@@ -850,9 +863,6 @@ gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog,
  * printf()-style), which is marked up with the
  * <link linkend="PangoMarkupFormat">Pango text markup language</link>.
  *
- * Note that setting a secondary text makes the primary text become
- * bold, unless you have provided explicit markup.
- *
  * Due to an oversight, this function does not escape special XML characters
  * like gtk_message_dialog_new_with_markup() does. Thus, if the arguments
  * may contain special XML characters, you should use g_markup_printf_escaped()
@@ -1009,7 +1019,5 @@ gtk_message_dialog_style_updated (GtkWidget *widget)
                                       MAX (0, border_width - 7));
     }
 
-  setup_primary_label_font (dialog);
-
   GTK_WIDGET_CLASS (gtk_message_dialog_parent_class)->style_updated (widget);
 }