[libadwaita/wip/exalm/message-dialog: 2/2] message-dialog: Tweak sizing
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/message-dialog: 2/2] message-dialog: Tweak sizing
- Date: Tue, 28 Jun 2022 11:36:32 +0000 (UTC)
commit bde9c4f41e17c292001746357a5a766efe2bf9aa
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Jun 28 00:34:01 2022 +0400
message-dialog: Tweak sizing
Introduce minimum and maixmum sizes so the dialog doesn't grow too large
and uses vertical buttons instead for very long buttons, even on desktop.
width-request on the dialog of children can still stretch it.
src/adw-message-dialog.c | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)
---
diff --git a/src/adw-message-dialog.c b/src/adw-message-dialog.c
index 7cdee388..141cbf49 100644
--- a/src/adw-message-dialog.c
+++ b/src/adw-message-dialog.c
@@ -124,6 +124,8 @@
*/
#define DIALOG_MARGIN 30
+#define DIALOG_MAX_WIDTH 550
+#define DIALOG_MIN_WIDTH 300
typedef struct {
AdwMessageDialog *dialog;
@@ -490,12 +492,7 @@ adw_message_dialog_measure (GtkWidget *widget,
{
AdwMessageDialog *self = ADW_MESSAGE_DIALOG (widget);
AdwMessageDialogPrivate *priv = adw_message_dialog_get_instance_private (self);
- int parent_size, max_size, base_min, base_nat;
-
- if (min_baseline)
- *min_baseline = -1;
- if (nat_baseline)
- *nat_baseline = -1;
+ int max_size, base_min, base_nat;
GTK_WIDGET_CLASS (adw_message_dialog_parent_class)->measure (widget,
orientation,
@@ -504,26 +501,37 @@ adw_message_dialog_measure (GtkWidget *widget,
&base_nat,
NULL, NULL);
- if (min)
- *min = base_min;
+ if (orientation == GTK_ORIENTATION_HORIZONTAL) {
+ int wide_min, narrow_nat;
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- parent_size = priv->parent_width;
- else
- parent_size = priv->parent_height;
+ max_size = priv->parent_width - DIALOG_MARGIN * 2;
+ max_size = CLAMP (max_size, DIALOG_MIN_WIDTH, DIALOG_MAX_WIDTH);
- if (parent_size < 0) {
- if (nat)
- *nat = base_nat;
+ gtk_widget_measure (GTK_WIDGET (priv->wide_response_box),
+ GTK_ORIENTATION_HORIZONTAL, -1,
+ &wide_min, NULL, NULL, NULL);
+ gtk_widget_measure (GTK_WIDGET (priv->narrow_response_box),
+ GTK_ORIENTATION_HORIZONTAL, -1,
+ NULL, &narrow_nat, NULL, NULL);
- return;
+ narrow_nat = MAX (narrow_nat, DIALOG_MIN_WIDTH);
+
+ if (max_size < wide_min)
+ max_size = MIN (max_size, narrow_nat);
+ } else {
+ max_size = priv->parent_height - DIALOG_MARGIN * 2;
}
- max_size = parent_size - DIALOG_MARGIN * 2;
max_size = MAX (base_min, max_size);
+ if (min)
+ *min = base_min;
if (nat)
*nat = CLAMP (base_nat, base_min, max_size);
+ if (min_baseline)
+ *min_baseline = -1;
+ if (nat_baseline)
+ *nat_baseline = -1;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]