[gnome-software: 1/2] metered-data-dialog: Make it a GsInfoWindow and a AdwStatusPage




commit 0a5c9ea2693e5735881858e7e4e3dfeb724ba96e
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Sep 1 11:47:28 2021 +0200

    metered-data-dialog: Make it a GsInfoWindow and a AdwStatusPage
    
    This ensures it will fit on phones, makes the code simpler, and makes it
    look nicer.

 src/gs-metered-data-dialog.c  |  6 ++--
 src/gs-metered-data-dialog.h  |  4 ++-
 src/gs-metered-data-dialog.ui | 66 ++++++++++++-------------------------------
 src/gs-shell.c                |  8 ++----
 4 files changed, 25 insertions(+), 59 deletions(-)
---
diff --git a/src/gs-metered-data-dialog.c b/src/gs-metered-data-dialog.c
index 9cd66987c..7e8a35baf 100644
--- a/src/gs-metered-data-dialog.c
+++ b/src/gs-metered-data-dialog.c
@@ -16,12 +16,12 @@
 
 struct _GsMeteredDataDialog
 {
-       GtkDialog        parent_instance;
+       GsInfoWindow     parent_instance;
 
        GtkWidget       *button_network_settings;
 };
 
-G_DEFINE_TYPE (GsMeteredDataDialog, gs_metered_data_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (GsMeteredDataDialog, gs_metered_data_dialog, GS_TYPE_INFO_WINDOW)
 
 static void
 button_network_settings_clicked_cb (GtkButton *button,
@@ -60,9 +60,7 @@ gs_metered_data_dialog_new (GtkWindow *parent)
        GsMeteredDataDialog *dialog;
 
        dialog = g_object_new (GS_TYPE_METERED_DATA_DIALOG,
-                              "use-header-bar", TRUE,
                               "transient-for", parent,
-                              "modal", TRUE,
                               NULL);
 
        return GTK_WIDGET (dialog);
diff --git a/src/gs-metered-data-dialog.h b/src/gs-metered-data-dialog.h
index 8219e9dce..676783d13 100644
--- a/src/gs-metered-data-dialog.h
+++ b/src/gs-metered-data-dialog.h
@@ -12,11 +12,13 @@
 #include <glib-object.h>
 #include <gtk/gtk.h>
 
+#include "gs-info-window.h"
+
 G_BEGIN_DECLS
 
 #define GS_TYPE_METERED_DATA_DIALOG (gs_metered_data_dialog_get_type ())
 
-G_DECLARE_FINAL_TYPE (GsMeteredDataDialog, gs_metered_data_dialog, GS, METERED_DATA_DIALOG, GtkDialog)
+G_DECLARE_FINAL_TYPE (GsMeteredDataDialog, gs_metered_data_dialog, GS, METERED_DATA_DIALOG, GsInfoWindow)
 
 GtkWidget      *gs_metered_data_dialog_new     (GtkWindow      *parent);
 
diff --git a/src/gs-metered-data-dialog.ui b/src/gs-metered-data-dialog.ui
index 18e306650..02c2bdba8 100644
--- a/src/gs-metered-data-dialog.ui
+++ b/src/gs-metered-data-dialog.ui
@@ -1,60 +1,30 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="3.10"/>
-  <template class="GsMeteredDataDialog" parent="GtkDialog">
+  <template class="GsMeteredDataDialog" parent="GsInfoWindow">
     <property name="title" translatable="yes">Automatic Updates Paused</property>
-    <property name="modal">True</property>
-    <property name="destroy-with-parent">True</property>
-    <property name="resizable">False</property>
-    <property name="use-header-bar">1</property>
-    <child internal-child="headerbar">
-      <object class="GtkHeaderBar">
-        <child type="title">
-          <object class="GtkLabel">
-            <property name="label" translatable="yes">Automatic Updates Paused</property>
-            <property name="selectable">False</property>
-            <style>
-              <class name="title"/>
-            </style>
-          </object>
-        </child>
-      </object>
-    </child>
-    <child internal-child="vbox">
-          <object class="GtkBox">
-            <property name="orientation">vertical</property>
-            <property name="spacing">12</property>
-            <property name="margin-top">12</property>
-            <property name="margin-bottom">12</property>
-            <property name="margin-start">12</property>
-            <property name="margin-end">12</property>
-            <child>
-              <object class="GtkLabel">
-                <property name="justify">left</property>
-                <property name="wrap">True</property>
-                <property name="wrap-mode">word-char</property>
-                <property name="label" translatable="yes">The current network is metered. Metered 
connections have data limits or charges associated with them. To save data, automatic updates have therefore 
been paused.
+    <child>
+      <object class="AdwStatusPage">
+        <property name="title" bind-source="GsMeteredDataDialog" bind-property="title" 
bind-flags="sync-create"/>
+        <property name="description" translatable="yes">The current network is metered. Metered connections 
have data limits or charges associated with them. To save data, automatic updates have therefore been paused.
 
 Automatic updates will be resumed when an un­metered network becomes available. Until then, it is still 
possible to manually install updates.
 
 Alternatively, if the current network has been in­correctly identified as being metered, this setting can be 
changed.</property>
-                <property name="max-width-chars">50</property>
-                <property name="halign">center</property>
-              </object>
-            </child>
-            <child>
-              <object class="GtkBox">
-                <child type="center">
-                  <object class="GtkButton" id="button_network_settings">
-                    <property name="label" translatable="yes">Open Network _Settings</property>
-                    <property name="receives-default">True</property>
-                    <property name="use-underline">True</property>
-                    <signal name="clicked" handler="button_network_settings_clicked_cb"/>
-                  </object>
-                </child>
-              </object>
-            </child>
+        <property name="icon-name">network-cellular-signal-excellent-symbolic</property>
+        <child>
+          <object class="GtkButton" id="button_network_settings">
+            <property name="label" translatable="yes">Open Network _Settings</property>
+            <property name="halign">center</property>
+            <property name="receives-default">True</property>
+            <property name="use-underline">True</property>
+            <signal name="clicked" handler="button_network_settings_clicked_cb"/>
+            <style>
+              <class name="pill"/>
+            </style>
           </object>
+        </child>
+      </object>
     </child>
   </template>
 </interface>
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 6b781bb92..a7f04f123 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -263,14 +263,10 @@ gs_shell_metered_updates_bar_response_cb (GtkInfoBar *info_bar,
                                          gpointer    user_data)
 {
        GsShell *shell = GS_SHELL (user_data);
-       GtkDialog *dialog;
+       GtkWidget *dialog;
 
-       dialog = GTK_DIALOG (gs_metered_data_dialog_new (GTK_WINDOW (shell)));
+       dialog = gs_metered_data_dialog_new (GTK_WINDOW (shell));
        gs_shell_modal_dialog_present (shell, GTK_WINDOW (dialog));
-
-       /* just destroy */
-       g_signal_connect_swapped (dialog, "response",
-                                 G_CALLBACK (gtk_window_destroy), dialog);
 }
 
 static void


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