[gnome-software/1904-incompatible-software-dialog-style-and-sizing-is-broken] gs-removal-dialog: Update look of the dialog
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1904-incompatible-software-dialog-style-and-sizing-is-broken] gs-removal-dialog: Update look of the dialog
- Date: Mon, 19 Sep 2022 14:01:34 +0000 (UTC)
commit f2f81340dee4968797cd25c792209df7448c2e46
Author: Milan Crha <mcrha redhat com>
Date: Mon Sep 19 16:00:05 2022 +0200
gs-removal-dialog: Update look of the dialog
The look of the dialog (probably) changed during the move to the gtk4.
This makes it look more accurate.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1904
src/gs-removal-dialog.c | 63 ++++++++++++++++++++++++++++++++++++++++++------
src/gs-removal-dialog.ui | 33 ++++++++++++++++++-------
2 files changed, 80 insertions(+), 16 deletions(-)
---
diff --git a/src/gs-removal-dialog.c b/src/gs-removal-dialog.c
index e26b70229..b3df18fbc 100644
--- a/src/gs-removal-dialog.c
+++ b/src/gs-removal-dialog.c
@@ -86,8 +86,8 @@ gs_removal_dialog_show_upgrade_removals (GsRemovalDialog *self,
gs_app_get_version (upgrade));
/* TRANSLATORS: This is a text displayed during a distro upgrade. %s
will be replaced by the name and version of distro, e.g. 'Fedora 23'. */
- secondary_text = g_strdup_printf (_("Some of the currently installed software is not compatible with
%s. "
- "If you continue, the following will be automatically removed
during the upgrade:"),
+ secondary_text = g_strdup_printf (_("Installed software is incompatible with %s, "
+ "and will be automatically removed during the upgrade."),
name_version);
gtk_widget_add_css_class (GTK_WIDGET (self->label), "title");
@@ -107,19 +107,65 @@ gs_removal_dialog_show_upgrade_removals (GsRemovalDialog *self,
}
}
+static void
+update_title (GObject *dialog,
+ GParamSpec *pspec,
+ GtkWidget *label)
+{
+ const gchar *title;
+
+ title = gtk_window_get_title (GTK_WINDOW (dialog));
+ gtk_label_set_label (GTK_LABEL (label), title);
+ gtk_widget_set_visible (label, title && title[0]);
+}
+
+static void
+gs_removal_dialog_constructed (GObject *object)
+{
+ GsRemovalDialog *dialog = GS_REMOVAL_DIALOG (object);
+ gboolean use_header;
+
+ G_OBJECT_CLASS (gs_removal_dialog_parent_class)->constructed (object);
+
+ g_object_get (gtk_widget_get_settings (GTK_WIDGET (dialog)),
+ "gtk-dialogs-use-header", &use_header,
+ NULL);
+
+ if (use_header) {
+ GtkWidget *box;
+ GtkWidget *label;
+
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_widget_show (box);
+ gtk_widget_set_size_request (box, -1, 16);
+ label = gtk_label_new ("");
+ gtk_widget_hide (label);
+ gtk_widget_set_margin_top (label, 6);
+ gtk_widget_set_margin_bottom (label, 6);
+ gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
+ gtk_widget_set_hexpand (label, TRUE);
+ gtk_widget_add_css_class (label, "title");
+ gtk_box_append (GTK_BOX (box), label);
+ g_signal_connect_object (dialog, "notify::title", G_CALLBACK (update_title), label, 0);
+
+ gtk_window_set_titlebar (GTK_WINDOW (dialog), box);
+ }
+}
+
static void
gs_removal_dialog_init (GsRemovalDialog *self)
{
- GtkWidget *action_area;
+ GtkWidget *widget;
GtkSettings *settings;
gboolean use_caret;
gtk_widget_init_template (GTK_WIDGET (self));
- action_area = gtk_dialog_get_content_area (GTK_DIALOG (self));
- action_area = gtk_widget_get_next_sibling (action_area);
- gtk_widget_set_halign (action_area, GTK_ALIGN_FILL);
- gtk_box_set_homogeneous (GTK_BOX (action_area), TRUE);
+ widget = gtk_dialog_get_widget_for_response (GTK_DIALOG (self), GTK_RESPONSE_ACCEPT);
+ widget = gtk_widget_get_parent (widget);
+ gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
+ gtk_widget_set_hexpand (widget, TRUE);
+ gtk_box_set_homogeneous (GTK_BOX (widget), TRUE);
settings = gtk_widget_get_settings (GTK_WIDGET (self));
g_object_get (settings, "gtk-keynav-use-caret", &use_caret, NULL);
@@ -134,8 +180,11 @@ gs_removal_dialog_init (GsRemovalDialog *self)
static void
gs_removal_dialog_class_init (GsRemovalDialogClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ object_class->constructed = gs_removal_dialog_constructed;
+
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Software/gs-removal-dialog.ui");
gtk_widget_class_bind_template_child (widget_class, GsRemovalDialog, label);
diff --git a/src/gs-removal-dialog.ui b/src/gs-removal-dialog.ui
index 0cff1321a..951c96ce5 100644
--- a/src/gs-removal-dialog.ui
+++ b/src/gs-removal-dialog.ui
@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GsRemovalDialog" parent="GtkDialog">
- <property name="title" translatable="yes">Incompatible Software</property>
+ <property name="title"></property>
<property name="modal">True</property>
<property name="destroy_with_parent">True</property>
+ <property name="use-header-bar">True</property>
<child internal-child="headerbar">
<object class="GtkHeaderBar">
<property name="show-title-buttons">False</property>
+ <property name="visible">False</property>
</object>
</child>
<style>
@@ -16,13 +18,18 @@
<object class="GtkButton" id="button_cancel">
<property name="label" translatable="yes">_Cancel</property>
<property name="use_underline">True</property>
+ <property name="halign">fill</property>
</object>
</child>
<child type="action">
<object class="GtkButton" id="button_continue">
- <property name="label" translatable="yes">_Continue</property>
+ <property name="label" translatable="yes">_Remove & Upgrade</property>
+ <property name="halign">fill</property>
<property name="use_underline">True</property>
<property name="receives_default">True</property>
+ <style>
+ <class name="destructive-action" />
+ </style>
</object>
</child>
<action-widgets>
@@ -42,24 +49,24 @@
<object class="GtkBox" id="message_area">
<property name="orientation">vertical</property>
<property name="spacing">10</property>
- <property name="hexpand">1</property>
+ <property name="hexpand">True</property>
<child>
<object class="GtkLabel" id="label">
<property name="halign">center</property>
+ <property name="hexpand">True</property>
<property name="valign">start</property>
- <property name="wrap">1</property>
- <property name="width-chars">40</property>
- <property name="max-width-chars">40</property>
+ <property name="wrap">False</property>
+ <property name="label" translatable="yes">Remove Incompatible Software?</property>
</object>
</child>
<child>
<object class="GtkLabel" id="secondary_label">
<property name="visible">False</property>
<property name="margin-bottom">2</property>
- <property name="halign">center</property>
+ <property name="halign">fill</property>
<property name="valign">start</property>
- <property name="vexpand">1</property>
- <property name="wrap">1</property>
+ <property name="vexpand">False</property>
+ <property name="wrap">True</property>
<property name="width-chars">40</property>
<property name="max-width-chars">40</property>
</object>
@@ -70,12 +77,20 @@
<property name="min_content_height">160</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property>
+ <property name="halign">fill</property>
+ <property name="hexpand">True</property>
+ <property name="valign">fill</property>
+ <property name="vexpand">True</property>
<child>
<object class="GtkListBox" id="listbox">
<property name="halign">fill</property>
<property name="valign">start</property>
<property name="selection_mode">none</property>
<property name="valign">start</property>
+ <property name="margin-start">4</property>
+ <property name="margin-end">4</property>
+ <property name="margin-top">4</property>
+ <property name="margin-bottom">4</property>
<style>
<class name="boxed-list" />
</style>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]