[gnome-software/1904-incompatible-software-dialog-style-and-sizing-is-broken] gs-removal-dialog: Update look of the dialog




commit c2a95166a67fb695fb6bd36d63dce446bae3f4fb
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  | 47 ++++++++++++++++++-----
 src/gs-removal-dialog.h  |  3 +-
 src/gs-removal-dialog.ui | 97 ++++++++++++++++++++++++++++++------------------
 3 files changed, 99 insertions(+), 48 deletions(-)
---
diff --git a/src/gs-removal-dialog.c b/src/gs-removal-dialog.c
index e26b70229..5ef070395 100644
--- a/src/gs-removal-dialog.c
+++ b/src/gs-removal-dialog.c
@@ -11,18 +11,26 @@
 #include "gs-removal-dialog.h"
 #include "gs-utils.h"
 
+#include <adwaita.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 struct _GsRemovalDialog
 {
-       GtkDialog                parent_instance;
+       AdwWindow                parent_instance;
        GtkLabel                *label;
        GtkWidget               *listbox;
        GtkLabel                *secondary_label;
 };
 
-G_DEFINE_TYPE (GsRemovalDialog, gs_removal_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (GsRemovalDialog, gs_removal_dialog, ADW_TYPE_WINDOW)
+
+enum {
+       SIGNAL_RESPONSE,
+       SIGNAL_LAST
+};
+
+static guint signals [SIGNAL_LAST] = { 0 };
 
 static gint
 list_sort_func (GtkListBoxRow *a,
@@ -86,8 +94,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,20 +115,28 @@ gs_removal_dialog_show_upgrade_removals (GsRemovalDialog *self,
        }
 }
 
+static void
+cancel_clicked_cb (GtkWidget *widget,
+                  GsRemovalDialog *self)
+{
+       g_signal_emit (self, signals[SIGNAL_RESPONSE], 0, GTK_RESPONSE_CANCEL);
+}
+
+static void
+upgrade_clicked_cb (GtkWidget *widget,
+                   GsRemovalDialog *self)
+{
+       g_signal_emit (self, signals[SIGNAL_RESPONSE], 0, GTK_RESPONSE_ACCEPT);
+}
+
 static void
 gs_removal_dialog_init (GsRemovalDialog *self)
 {
-       GtkWidget *action_area;
        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);
-
        settings = gtk_widget_get_settings (GTK_WIDGET (self));
        g_object_get (settings, "gtk-keynav-use-caret", &use_caret, NULL);
        gtk_label_set_selectable (self->label, use_caret);
@@ -141,6 +157,17 @@ gs_removal_dialog_class_init (GsRemovalDialogClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsRemovalDialog, label);
        gtk_widget_class_bind_template_child (widget_class, GsRemovalDialog, listbox);
        gtk_widget_class_bind_template_child (widget_class, GsRemovalDialog, secondary_label);
+       gtk_widget_class_bind_template_callback (widget_class, cancel_clicked_cb);
+       gtk_widget_class_bind_template_callback (widget_class, upgrade_clicked_cb);
+
+       signals[SIGNAL_RESPONSE] = g_signal_new ("response",
+                                                G_OBJECT_CLASS_TYPE (klass),
+                                                G_SIGNAL_RUN_LAST,
+                                                0,
+                                                NULL, NULL,
+                                                NULL,
+                                                G_TYPE_NONE, 1,
+                                                G_TYPE_INT);
 }
 
 GtkWidget *
diff --git a/src/gs-removal-dialog.h b/src/gs-removal-dialog.h
index b603ace1a..c7f83ceee 100644
--- a/src/gs-removal-dialog.h
+++ b/src/gs-removal-dialog.h
@@ -8,6 +8,7 @@
 
 #pragma once
 
+#include <adwaita.h>
 #include <gtk/gtk.h>
 
 #include "gnome-software-private.h"
@@ -16,7 +17,7 @@ G_BEGIN_DECLS
 
 #define GS_TYPE_REMOVAL_DIALOG (gs_removal_dialog_get_type ())
 
-G_DECLARE_FINAL_TYPE (GsRemovalDialog, gs_removal_dialog, GS, REMOVAL_DIALOG, GtkDialog)
+G_DECLARE_FINAL_TYPE (GsRemovalDialog, gs_removal_dialog, GS, REMOVAL_DIALOG, AdwWindow)
 
 GtkWidget      *gs_removal_dialog_new                          (void);
 void            gs_removal_dialog_show_upgrade_removals        (GsRemovalDialog         *self,
diff --git a/src/gs-removal-dialog.ui b/src/gs-removal-dialog.ui
index 0cff1321a..cb0e98812 100644
--- a/src/gs-removal-dialog.ui
+++ b/src/gs-removal-dialog.ui
@@ -1,38 +1,49 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="GsRemovalDialog" parent="GtkDialog">
-    <property name="title" translatable="yes">Incompatible Software</property>
+  <template class="GsRemovalDialog" parent="AdwWindow">
     <property name="modal">True</property>
     <property name="destroy_with_parent">True</property>
-    <child internal-child="headerbar">
-      <object class="GtkHeaderBar">
-        <property name="show-title-buttons">False</property>
-      </object>
-    </child>
-    <style>
-      <class name="message" />
-    </style>
-    <child type="action">
-      <object class="GtkButton" id="button_cancel">
-        <property name="label" translatable="yes">_Cancel</property>
-        <property name="use_underline">True</property>
-      </object>
-    </child>
-    <child type="action">
-      <object class="GtkButton" id="button_continue">
-        <property name="label" translatable="yes">_Continue</property>
-        <property name="use_underline">True</property>
-        <property name="receives_default">True</property>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="accept" default="true">button_continue</action-widget>
-      <action-widget response="cancel">button_cancel</action-widget>
-    </action-widgets>
-    <child internal-child="content_area">
-      <object class="GtkBox" id="dialog-vbox1">
+    <property name="icon_name">dialog-question</property>
+    <property name="title" translatable="yes">Incompatible Software</property>
+    <property name="default-width">470</property>
+    <property name="default-height">400</property>
+    <property name="content">
+      <object class="GtkBox">
         <property name="orientation">vertical</property>
+        <property name="width-request">360</property>
         <property name="spacing">20</property>
+        <child>
+          <object class="AdwHeaderBar">
+            <property name="show_start_title_buttons">False</property>
+            <property name="show_end_title_buttons">False</property>
+            <property name="title-widget">
+              <object class="AdwWindowTitle">
+                <property name="title" bind-source="GsRemovalDialog" bind-property="title" 
bind-flags="sync-create"/>
+              </object>
+            </property>
+            <child type="start">
+              <object class="GtkButton" id="button_cancel">
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="label" translatable="yes">_Cancel</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="cancel_clicked_cb"/>
+              </object>
+            </child>
+            <child type="end">
+              <object class="GtkButton" id="button_continue">
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="label" translatable="yes">_Upgrade</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="upgrade_clicked_cb"/>
+                <style>
+                  <class name="destructive-action" />
+                </style>
+              </object>
+            </child>
+          </object>
+        </child>
         <child>
           <object class="GtkBox" id="box">
             <property name="margin-start">30</property>
@@ -42,24 +53,28 @@
               <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>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
                   </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="justify">center</property>
+                    <property name="wrap">True</property>
                     <property name="width-chars">40</property>
                     <property name="max-width-chars">40</property>
                   </object>
@@ -70,12 +85,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>
@@ -88,6 +111,6 @@
           </object>
         </child>
       </object>
-    </child>
+    </property>
   </template>
 </interface>


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