[geary/wip/problem-report-logs: 16/22] Convert MainWindow to use MainWindowInfoBars for status problems
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/problem-report-logs: 16/22] Convert MainWindow to use MainWindowInfoBars for status problems
- Date: Fri, 5 Jul 2019 01:59:36 +0000 (UTC)
commit b9aa433855adf578e73128c0288472f023a3b381
Author: Michael Gratton <mike vee net>
Date: Fri Jul 5 09:41:27 2019 +1000
Convert MainWindow to use MainWindowInfoBars for status problems
Sysnthesise a problem report and use a MainWindowInfoBar for displaying
account service status problems rather than using a custom info bar.
This lets us use the same infrastructure for displaying problem reports
and will enable capturing relevant logs at the time that the error
occurred.
src/client/components/main-window.vala | 64 ++++++------------
ui/main-window.ui | 115 +--------------------------------
2 files changed, 23 insertions(+), 156 deletions(-)
---
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 133acff1..695a6096 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -77,19 +77,13 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
[GtkChild]
private Gtk.InfoBar offline_infobar;
- [GtkChild]
- private Gtk.InfoBar service_problem_infobar;
-
- [GtkChild]
- private Gtk.Button service_problem_details;
-
[GtkChild]
private Gtk.InfoBar cert_problem_infobar;
[GtkChild]
private Gtk.InfoBar auth_problem_infobar;
- private Geary.Account? service_problem_account = null;
+ private MainWindowInfoBar? service_problem_infobar = null;
/** Fired when the user requests an account status be retried. */
public signal void retry_service_problem(Geary.ClientService.Status problem);
@@ -143,7 +137,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
public void update_account_status(Geary.Account.Status status,
bool has_auth_error,
bool has_cert_error,
- Geary.Account? service_problem) {
+ Geary.Account? problem_source) {
// Only ever show one at a time. Offline is primary since
// nothing else can happen when offline. Service problems are
// secondary since auth and cert problems can't be resolved
@@ -164,11 +158,25 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
show_auth = true;
}
- this.service_problem_account = service_problem;
+ if (show_service && this.service_problem_infobar == null) {
+ Geary.ClientService? service = (
+ problem_source.incoming.last_error != null
+ ? problem_source.incoming
+ : problem_source.outgoing
+ );
+ this.service_problem_infobar = new MainWindowInfoBar.for_problem(
+ new Geary.ServiceProblemReport(
+ problem_source.information,
+ service.configuration,
+ service.last_error.thrown
+ )
+ );
+ this.service_problem_infobar.retry.connect(on_service_problem_retry);
+
+ show_infobar(this.service_problem_infobar);
+ }
this.offline_infobar.set_visible(show_offline);
- this.service_problem_infobar.set_visible(show_service);
- this.service_problem_details.set_visible(get_problem_service() != null);
this.cert_problem_infobar.set_visible(show_cert);
this.auth_problem_infobar.set_visible(show_auth);
update_infobar_frame();
@@ -703,7 +711,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
// Ensure the info bar frame is shown only when it has visible
// children
bool show_frame = false;
- info_bar_container.foreach((child) => {
+ this.info_bar_container.foreach((child) => {
if (child.visible) {
show_frame = true;
}
@@ -724,18 +732,6 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
}
}
- private Geary.ClientService? get_problem_service() {
- Geary.ClientService? service = null;
- if (this.service_problem_account != null) {
- if (this.service_problem_account.incoming.last_error != null) {
- service = this.service_problem_account.incoming;
- } else if (this.service_problem_account.outgoing.last_error != null) {
- service = this.service_problem_account.outgoing;
- }
- }
- return service;
- }
-
private SimpleAction get_action(string name) {
return (SimpleAction) lookup_action(name);
}
@@ -801,29 +797,11 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
update_infobar_frame();
}
- [GtkCallback]
private void on_service_problem_retry() {
- this.service_problem_infobar.hide();
- update_infobar_frame();
+ this.service_problem_infobar = null;
retry_service_problem(Geary.ClientService.Status.CONNECTION_FAILED);
}
- [GtkCallback]
- private void on_service_problem_details() {
- Geary.ClientService? service = get_problem_service();
- if (service != null) {
- Dialogs.ProblemDetailsDialog dialog =
- new Dialogs.ProblemDetailsDialog(
- this,
- service.last_error,
- this.service_problem_account.information,
- service.configuration
- );
- dialog.run();
- dialog.destroy();
- }
- }
-
[GtkCallback]
private void on_cert_problem_retry() {
this.cert_problem_infobar.hide();
diff --git a/ui/main-window.ui b/ui/main-window.ui
index 428f40f7..bbd330d7 100644
--- a/ui/main-window.ui
+++ b/ui/main-window.ui
@@ -234,117 +234,6 @@ You will not be able to send or receive email until it is re-connected.</propert
<property name="top_attach">0</property>
</packing>
</child>
- <child>
- <object class="GtkInfoBar" id="service_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" id="service_problem_details">
- <property name="label" translatable="yes" comments="Button label for
displaying technical details about an account problem">Details</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" comments="Button tooltip
for displaying technical details about an account problem">View technical details about the error</property>
- <signal name="clicked" handler="on_service_problem_details" swapped="no"/>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton">
- <property name="label" translatable="yes" comments="Button label for
retrying an account problem">Retry</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 an account problem">Try reconnecting</property>
- <signal name="clicked" handler="on_service_problem_retry" swapped="no"/>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</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="service_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 encounted an error">Account 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="service_problem_description">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes" comments="Label and
tooltip for account service problem infobar">Geary encountered a problem connecting to an account.
-Please check your Internet connection, the server configuration and try again.</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes" comments="Label and tooltip
for account service problem infobar">Geary encountered a problem connecting to an account.</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="cert_problem_infobar">
<property name="can_focus">False</property>
@@ -439,7 +328,7 @@ Please check the server configuration and try again.</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">1</property>
</packing>
</child>
<child>
@@ -536,7 +425,7 @@ Please check your login name and try again.</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">2</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]