gtk3/debian/patches/gtk3_3004-gtkmessagedialog-style.patch
2025-05-08 18:10:07 -07:00

282 lines
11 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

diff -urN a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c
--- a/gtk/gtkmessagedialog.c 2025-03-05 15:31:26.000000000 -0800
+++ b/gtk/gtkmessagedialog.c 2025-05-08 17:34:23.077661286 -0700
@@ -44,7 +44,8 @@
* @Title: GtkMessageDialog
* @See_also:#GtkDialog
*
- * #GtkMessageDialog presents a dialog with some message text. Its simply a
+ * #GtkMessageDialog presents a dialog with an image representing the type of
+ * message (Error, Question, etc.) alongside some message text. Its simply a
* convenience widget; you could construct the equivalent of #GtkMessageDialog
* from #GtkDialog without too much effort, but #GtkMessageDialog saves typing.
*
@@ -171,8 +172,8 @@
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("message-border",
- P_("label border"),
- P_("Width of border around the label in the message dialog"),
+ P_("Image/label border"),
+ P_("Width of border around the label and image in the message dialog"),
0,
G_MAXINT,
12,
@@ -181,7 +182,9 @@
/**
* GtkMessageDialog:message-type:
*
- * The type of the message.
+ * The type of the message. The type is used to determine
+ * the image that is shown in the dialog, unless the image i
+ * explicitly set by the ::image property.
*/
g_object_class_install_property (gobject_class,
PROP_MESSAGE_TYPE,
@@ -269,7 +272,6 @@
* The image for this dialog.
*
* Since: 2.10
- * Deprecated: 3.12: Use #GtkDialog to create dialogs with images
*/
g_object_class_install_property (gobject_class,
PROP_IMAGE,
@@ -277,7 +279,7 @@
P_("Image"),
P_("The image"),
GTK_TYPE_WIDGET,
- GTK_PARAM_READWRITE|G_PARAM_DEPRECATED));
+ GTK_PARAM_READWRITE));
/**
* GtkMessageDialog:message-area:
@@ -298,6 +300,7 @@
/* Setup Composite data */
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtkmessagedialog.ui");
+ gtk_widget_class_bind_template_child_private (widget_class, GtkMessageDialog, image);
gtk_widget_class_bind_template_child_private (widget_class, GtkMessageDialog, label);
gtk_widget_class_bind_template_child_private (widget_class, GtkMessageDialog, secondary_label);
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkMessageDialog, message_area);
@@ -327,7 +330,7 @@
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
G_GNUC_END_IGNORE_DEPRECATIONS
- gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_EXPAND);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_END);
settings = gtk_widget_get_settings (GTK_WIDGET (dialog));
g_object_get (settings, "gtk-keynav-use-caret", &use_caret, NULL);
@@ -416,12 +419,42 @@
{
GtkMessageDialogPrivate *priv = dialog->priv;
AtkObject *atk_obj;
+ GIcon *gicon = NULL;
if (priv->message_type == type)
return;
priv->message_type = type;
+ switch (type)
+ {
+ case GTK_MESSAGE_INFO:
+ gicon = g_themed_icon_new_with_default_fallbacks ("dialog-information-symbolic");
+ break;
+
+ case GTK_MESSAGE_QUESTION:
+ gicon = g_themed_icon_new_with_default_fallbacks ("dialog-question-symbolic");
+ break;
+
+ case GTK_MESSAGE_WARNING:
+ gicon = g_themed_icon_new_with_default_fallbacks ("dialog-warning-symbolic");
+ break;
+
+ case GTK_MESSAGE_ERROR:
+ gicon = g_themed_icon_new_with_default_fallbacks ("dialog-error-symbolic");
+ break;
+
+ case GTK_MESSAGE_OTHER:
+ break;
+
+ default:
+ g_warning ("Unknown GtkMessageType %u", type);
+ break;
+ }
+
+ 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))
@@ -543,9 +576,7 @@
}
break;
case PROP_IMAGE:
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_message_dialog_set_image (dialog, g_value_get_object (value));
-G_GNUC_END_IGNORE_DEPRECATIONS
break;
default:
@@ -738,7 +769,6 @@
* Sets the dialogs image to @image.
*
* Since: 2.10
- * Deprecated: 3.12: Use #GtkDialog to create dialogs with images
**/
void
gtk_message_dialog_set_image (GtkMessageDialog *dialog,
@@ -752,22 +782,22 @@
priv = dialog->priv;
- if (priv->image)
- gtk_widget_destroy (priv->image);
-
- priv->image = image;
-
- if (priv->image)
- {
- gtk_widget_set_halign (priv->image, GTK_ALIGN_CENTER);
- gtk_widget_set_valign (priv->image, GTK_ALIGN_START);
- parent = gtk_widget_get_parent (priv->message_area);
- gtk_container_add (GTK_CONTAINER (parent), priv->image);
- gtk_box_reorder_child (GTK_BOX (parent), priv->image, 0);
+ if (image == NULL)
+ {
+ image = gtk_image_new_from_icon_name (NULL, GTK_ICON_SIZE_DIALOG);
+ gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (image, GTK_ALIGN_START);
}
-
+
priv->message_type = GTK_MESSAGE_OTHER;
+ parent = gtk_widget_get_parent (priv->image);
+ gtk_container_add (GTK_CONTAINER (parent), image);
+ gtk_container_remove (GTK_CONTAINER (parent), priv->image);
+ gtk_box_reorder_child (GTK_BOX (parent), image, 0);
+
+ priv->image = image;
+
g_object_notify (G_OBJECT (dialog), "image");
g_object_notify (G_OBJECT (dialog), "message-type");
}
@@ -781,7 +811,6 @@
* Returns: (transfer none): the dialogs image
*
* Since: 2.14
- * Deprecated: 3.12: Use #GtkDialog for dialogs with images
**/
GtkWidget *
gtk_message_dialog_get_image (GtkMessageDialog *dialog)
@@ -929,8 +958,9 @@
*
* Returns the message area of the dialog. This is the box where the
* dialogs primary and secondary labels are packed. You can add your
- * own extra content to that box and it will appear below those labels.
- * See gtk_dialog_get_content_area() for the corresponding
+ * own extra content to that box and it will appear below those labels,
+ * on the right side of the dialogs image (or on the left for right-to-left
+ * languages). See gtk_dialog_get_content_area() for the corresponding
* function in the parent #GtkDialog.
*
* Returns: (transfer none): A #GtkBox corresponding to the
@@ -1005,7 +1035,7 @@
GtkWidget *parent;
gint border_width;
- parent = gtk_widget_get_parent (dialog->priv->message_area);
+ parent = gtk_widget_get_parent (gtk_message_dialog_get_image (dialog));
if (parent)
{
diff -urN a/gtk/gtkmessagedialog.h b/gtk/gtkmessagedialog.h
--- a/gtk/gtkmessagedialog.h 2025-03-05 15:31:26.000000000 -0800
+++ b/gtk/gtkmessagedialog.h 2025-05-08 17:26:20.477242282 -0700
@@ -111,11 +111,11 @@
const gchar *message_format,
...) G_GNUC_PRINTF (5, 6);
-GDK_DEPRECATED_IN_3_12
+GDK_AVAILABLE_IN_ALL
void gtk_message_dialog_set_image (GtkMessageDialog *dialog,
GtkWidget *image);
-GDK_DEPRECATED_IN_3_12
+GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_message_dialog_get_image (GtkMessageDialog *dialog);
GDK_AVAILABLE_IN_ALL
diff -urN a/gtk/ui/gtkmessagedialog.ui b/gtk/ui/gtkmessagedialog.ui
--- a/gtk/ui/gtkmessagedialog.ui 2025-03-05 15:31:26.000000000 -0800
+++ b/gtk/ui/gtkmessagedialog.ui 2025-05-08 17:26:20.477242282 -0700
@@ -2,6 +2,7 @@
<interface domain="gtk30">
<!-- interface-requires gtk+ 3.10 -->
<template class="GtkMessageDialog" parent="GtkDialog">
+ <property name="border_width">5</property>
<property name="title"></property>
<property name="resizable">0</property>
<property name="type-hint">dialog</property>
@@ -14,24 +15,39 @@
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="orientation">vertical</property>
- <property name="spacing">20</property>
+ <property name="spacing">14</property>
<property name="border-width">0</property>
<child>
<object class="GtkBox" id="box">
<property name="visible">1</property>
- <property name="margin-start">30</property>
- <property name="margin-end">30</property>
- <property name="spacing">30</property>
+ <property name="border_width">5</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkImage" id="image">
+ <property name="visible">1</property>
+ <property name="halign">center</property>
+ <property name="valign">start</property>
+ <property name="stock">gtk-missing-image</property>
+ <property name="use_fallback">True</property>
+ <property name="icon_size">6</property>
+ <property name="xpad">6</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
<object class="GtkBox" id="message_area">
<property name="visible">1</property>
<property name="orientation">vertical</property>
- <property name="spacing">10</property>
+ <property name="spacing">12</property>
<child>
<object class="GtkLabel" id="label">
<property name="visible">1</property>
- <property name="halign">center</property>
- <property name="valign">start</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
<property name="wrap">1</property>
<property name="max-width-chars">60</property>
</object>
@@ -43,8 +59,8 @@
<object class="GtkLabel" id="secondary_label">
<property name="no-show-all">1</property>
<property name="margin-bottom">2</property>
- <property name="halign">center</property>
- <property name="valign">start</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
<property name="wrap">1</property>
<property name="max-width-chars">60</property>
</object>