[geary/mjog/info-bar-cleanup: 4/6] Application.MainWindow: Construct infobars programatically



commit 14460de8983361369880bc23e8cf09cca43b6ca3
Author: Michael Gratton <mike vee net>
Date:   Tue Mar 17 15:11:13 2020 +1100

    Application.MainWindow: Construct infobars programatically
    
    Construct infobars programatically so they can derive from
    Components.Infobar and don't need to be initially part of the widget
    hierarchy.

 .../application/application-main-window.vala       |  49 +++-
 ui/application-main-window.ui                      | 308 +--------------------
 2 files changed, 43 insertions(+), 314 deletions(-)
---
diff --git a/src/client/application/application-main-window.vala 
b/src/client/application/application-main-window.vala
index aef58dbc..4498628a 100644
--- a/src/client/application/application-main-window.vala
+++ b/src/client/application/application-main-window.vala
@@ -1,6 +1,6 @@
 /*
- * Copyright 2016 Software Freedom Conservancy Inc.
- * Copyright 2016, 2019 Michael Gratton <mike vee net>
+ * Copyright © 2016 Software Freedom Conservancy Inc.
+ * Copyright © 2016, 2019-2020 Michael Gratton <mike vee net>
  *
  * This software is licensed under the GNU Lesser General Public License
  * (version 2.1 or later). See the COPYING file in this distribution.
@@ -339,13 +339,10 @@ public class Application.MainWindow :
     [GtkChild]
     private Gtk.Grid info_bar_container;
 
-    [GtkChild]
     private Gtk.InfoBar offline_infobar;
 
-    [GtkChild]
     private Gtk.InfoBar cert_problem_infobar;
 
-    [GtkChild]
     private Gtk.InfoBar auth_problem_infobar;
 
     private Components.ProblemReportInfoBar? service_problem_infobar = null;
@@ -529,6 +526,45 @@ public class Application.MainWindow :
             add_account(context);
         }
 
+        this.offline_infobar = new Components.InfoBar(
+            // Translators: An info bar status label
+            _("Working offline"),
+            // Translators: An info bar description label
+            _("You will not be able to send or receive email until re-connected.")
+        );
+        this.offline_infobar.show_close_button = true;
+        this.offline_infobar.response.connect(on_offline_infobar_response);
+
+        this.auth_problem_infobar = new Components.InfoBar(
+            // Translators: An info bar status label
+            _("Login problem"),
+            // Translators: An info bar description label
+            _("An account has reported an incorrect login or password.")
+        );
+        // Translators: An info bar button label
+        var auth_retry = new Gtk.Button.with_label(_("Login"));
+        // Translators: An info bar button tool-tip
+        auth_retry.tooltip_text = _(
+            "Retry login, you will be prompted for your password"
+        );
+        auth_retry.clicked.connect(on_auth_problem_retry);
+        this.auth_problem_infobar.get_action_area().add(auth_retry);
+
+        this.cert_problem_infobar = new Components.InfoBar(
+            // Translators: An info bar status label
+            _("Security problem"),
+            // Translators: An info bar description label
+            _("An account has reported an untrusted server..")
+        );
+        // Translators: An info bar button label
+        var cert_retry = new Gtk.Button.with_label(_("Check"));
+        // Translators: An info bar button tool-tip
+        cert_retry.tooltip_text = _(
+            "Check the security details for the connection"
+        );
+        cert_retry.clicked.connect(on_cert_problem_retry);
+        this.cert_problem_infobar.get_action_area().add(cert_retry);
+
         this.conversation_list_view.grab_focus();
     }
 
@@ -1921,7 +1957,6 @@ public class Application.MainWindow :
         return Gdk.EVENT_STOP;
     }
 
-    [GtkCallback]
     private void on_offline_infobar_response() {
         this.offline_infobar.hide();
         update_infobar_frame();
@@ -1932,14 +1967,12 @@ public class Application.MainWindow :
         retry_service_problem(Geary.ClientService.Status.CONNECTION_FAILED);
     }
 
-    [GtkCallback]
     private void on_cert_problem_retry() {
         this.cert_problem_infobar.hide();
         update_infobar_frame();
         retry_service_problem(Geary.ClientService.Status.TLS_VALIDATION_FAILED);
     }
 
-    [GtkCallback]
     private void on_auth_problem_retry() {
         this.auth_problem_infobar.hide();
         update_infobar_frame();
diff --git a/ui/application-main-window.ui b/ui/application-main-window.ui
index 2166b836..981da65f 100644
--- a/ui/application-main-window.ui
+++ b/ui/application-main-window.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.1 -->
+<!-- Generated with glade 3.22.2 -->
 <interface>
   <requires lib="gtk+" version="3.20"/>
   <template class="ApplicationMainWindow" parent="GtkApplicationWindow">
@@ -137,311 +137,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkFrame" id="info_bar_frame">
-                <property name="can_focus">False</property>
-                <property name="no_show_all">True</property>
-                <property name="label_xalign">0</property>
-                <property name="shadow_type">in</property>
-                <child>
-                  <object class="GtkGrid" id="info_bar_container">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="orientation">vertical</property>
-                    <signal name="remove" handler="on_info_bar_container_remove" swapped="no"/>
-                    <child>
-                      <object class="GtkInfoBar" id="offline_infobar">
-                        <property name="can_focus">False</property>
-                        <property name="hexpand">True</property>
-                        <property name="show_close_button">True</property>
-                        <signal name="response" handler="on_offline_infobar_response" swapped="no"/>
-                        <child internal-child="action_area">
-                          <object class="GtkButtonBox">
-                            <property name="can_focus">False</property>
-                            <property name="spacing">6</property>
-                            <property name="layout_style">end</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child internal-child="content_area">
-                          <object class="GtkBox">
-                            <property name="can_focus">False</property>
-                            <property name="spacing">16</property>
-                            <child>
-                              <object class="GtkGrid">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <child>
-                                  <object class="GtkLabel" id="offline_title">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="halign">start</property>
-                                    <property name="label" translatable="yes" comments="Infobar title when 
one or more accounts are offline">Working offline</property>
-                                    <attributes>
-                                      <attribute name="weight" value="bold"/>
-                                    </attributes>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">0</property>
-                                    <property name="top_attach">0</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkLabel" id="offline_description">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="tooltip_text" translatable="yes" comments="Label and 
tooltip for offline infobar">Your computer does not appear to be connected to the Internet.
-You will not be able to send or receive email until it is re-connected.</property>
-                                    <property name="halign">start</property>
-                                    <property name="label" translatable="yes" comments="Label and tooltip 
for offline infobar">You will not be able to send or receive email until re-connected.</property>
-                                    <property name="wrap">True</property>
-                                    <property name="ellipsize">end</property>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">0</property>
-                                    <property name="top_attach">1</property>
-                                  </packing>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <style>
-                              <class name="sigh"/>
-                            </style>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkInfoBar" id="cert_problem_infobar">
-                        <property name="can_focus">False</property>
-                        <property name="hexpand">True</property>
-                        <property name="message_type">error</property>
-                        <child internal-child="action_area">
-                          <object class="GtkButtonBox">
-                            <property name="can_focus">False</property>
-                            <property name="spacing">6</property>
-                            <property name="layout_style">end</property>
-                            <child>
-                              <object class="GtkButton">
-                                <property name="label" translatable="yes" comments="Button label for 
retrying TLS cert validation">Check</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="tooltip_text" translatable="yes" comments="Button tooltip 
for retrying TLS cert validation">Check the security details for the connection</property>
-                                <signal name="clicked" handler="on_cert_problem_retry" swapped="no"/>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child internal-child="content_area">
-                          <object class="GtkBox">
-                            <property name="can_focus">False</property>
-                            <property name="spacing">16</property>
-                            <child>
-                              <object class="GtkGrid">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <child>
-                                  <object class="GtkLabel" id="cert_problem_title">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="halign">start</property>
-                                    <property name="label" translatable="yes" comments="Infobar title when 
one or more accounts have a TLS cert validation error">Security problem</property>
-                                    <attributes>
-                                      <attribute name="weight" value="bold"/>
-                                    </attributes>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">0</property>
-                                    <property name="top_attach">0</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkLabel" id="cert_problem_description">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="tooltip_text" translatable="yes" comments="Label and 
tooltip for TLS cert validation error infobar">An account has reported an untrusted server.
-Please check the server configuration and try again.</property>
-                                    <property name="halign">start</property>
-                                    <property name="label" translatable="yes" comments="Label and tooltip 
for TLS cert validation error infobar">An account has reported an untrusted server.</property>
-                                    <property name="wrap">True</property>
-                                    <property name="ellipsize">end</property>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">0</property>
-                                    <property name="top_attach">1</property>
-                                  </packing>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <style>
-                              <class name="sigh"/>
-                            </style>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkInfoBar" id="auth_problem_infobar">
-                        <property name="can_focus">False</property>
-                        <property name="hexpand">True</property>
-                        <property name="message_type">error</property>
-                        <child internal-child="action_area">
-                          <object class="GtkButtonBox">
-                            <property name="can_focus">False</property>
-                            <property name="spacing">6</property>
-                            <property name="layout_style">end</property>
-                            <child>
-                              <object class="GtkButton">
-                                <property name="label" translatable="yes" comments="Button label for 
retrying when a login error has occurred">Login</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="tooltip_text" translatable="yes" comments="Button tooltip 
for retrying when a login error has occurred">Retry login, you will be prompted for your password</property>
-                                <signal name="clicked" handler="on_auth_problem_retry" swapped="no"/>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child internal-child="content_area">
-                          <object class="GtkBox">
-                            <property name="can_focus">False</property>
-                            <property name="spacing">16</property>
-                            <child>
-                              <object class="GtkGrid">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <child>
-                                  <object class="GtkLabel" id="auth_problem_title">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="halign">start</property>
-                                    <property name="label" translatable="yes" comments="Infobar title when 
one or more accounts have a login error">Login problem</property>
-                                    <attributes>
-                                      <attribute name="weight" value="bold"/>
-                                    </attributes>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">0</property>
-                                    <property name="top_attach">0</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkLabel" id="auth_problem_description">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="tooltip_text" translatable="yes" comments="Label and 
tooltip for authentication problem infobar">An account has reported an incorrect login or password.
-Please check your login name and try again.</property>
-                                    <property name="halign">start</property>
-                                    <property name="label" translatable="yes" comments="Label and tooltip 
for authentication problem infobar">An account has reported an incorrect login or password.</property>
-                                    <property name="wrap">True</property>
-                                    <property name="ellipsize">end</property>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">0</property>
-                                    <property name="top_attach">1</property>
-                                  </packing>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <style>
-                              <class name="sigh"/>
-                            </style>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">2</property>
-                      </packing>
-                    </child>
-                  </object>
-                </child>
-                <child type="label_item">
-                  <placeholder/>
-                </child>
-                <style>
-                  <class name="geary-info-bar-frame"/>
-                </style>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
+              <placeholder/>
             </child>
           </object>
           <packing>


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