Move InAppNotification class to components package

It was the last class left in notifications, so not much point keeping
it there. Also take the opportunity to add it to a package proper.
This commit is contained in:
Michael Gratton 2019-09-27 19:29:17 +10:00 committed by Michael James Gratton
parent 5d13b8e94b
commit d5e7c05cba
11 changed files with 20 additions and 16 deletions

View file

@ -28,6 +28,7 @@ src/client/application/goa-mediator.vala
src/client/application/main.vala
src/client/application/secret-mediator.vala
src/client/components/client-web-view.vala
src/client/components/components-in-app-notification.vala
src/client/components/components-inspector.vala
src/client/components/components-placeholder-pane.vala
src/client/components/components-validator.vala
@ -411,6 +412,7 @@ ui/composer-headerbar.ui
ui/composer-link-popover.ui
ui/composer-menus.ui
ui/composer-widget.ui
ui/components-in-app-notification.ui
ui/components-inspector-error-view.ui
ui/components-inspector-log-view.ui
ui/components-inspector.ui
@ -425,7 +427,6 @@ ui/conversation-viewer.ui
ui/find_bar.glade
ui/folder-popover.ui
ui/gtk/help-overlay.ui
ui/in-app-notification.ui
ui/main-toolbar.ui
ui/main-toolbar-menus.ui
ui/main-window.ui

View file

@ -298,7 +298,7 @@ internal class Accounts.EditorAddPane : Gtk.Grid, EditorPane {
}
if (message != null) {
this.editor.add_notification(
new InAppNotification(
new Components.InAppNotification(
// Translators: In-app notification label, the
// string substitution is a more detailed reason.
_("Account not created: %s").printf(message)

View file

@ -243,7 +243,8 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane, CommandPane {
private void on_execute(Application.Command command) {
if (command.executed_label != null) {
InAppNotification ian = new InAppNotification(command.executed_label);
Components.InAppNotification ian =
new Components.InAppNotification(command.executed_label);
ian.set_button(_("Undo"), "win." + GearyApplication.ACTION_UNDO);
this.editor.add_notification(ian);
}
@ -251,7 +252,8 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane, CommandPane {
private void on_undo(Application.Command command) {
if (command.undone_label != null) {
InAppNotification ian = new InAppNotification(command.undone_label);
Components.InAppNotification ian =
new Components.InAppNotification(command.undone_label);
ian.set_button(_("Redo"), "win." + GearyApplication.ACTION_REDO);
this.editor.add_notification(ian);
}

View file

@ -371,7 +371,7 @@ internal class Accounts.EditorServersPane :
if (!is_valid && message != null) {
this.editor.add_notification(
new InAppNotification(
new Components.InAppNotification(
// Translators: In-app notification label, the
// string substitution is a more detailed reason.
_("Account not updated: %s").printf(message)

View file

@ -171,7 +171,7 @@ public class Accounts.Editor : Gtk.Dialog {
}
/** Displays an in-app notification in the dialog. */
internal void add_notification(InAppNotification notification) {
internal void add_notification(Components.InAppNotification notification) {
this.notifications_pane.add_overlay(notification);
notification.show();
}
@ -197,7 +197,7 @@ public class Accounts.Editor : Gtk.Dialog {
} catch (Application.CertificateManagerError.STORE_FAILED err) {
// XXX show error info bar rather than a notification?
add_notification(
new InAppNotification(
new Components.InAppNotification(
// Translators: In-app notification label, when
// the app had a problem pinning an otherwise
// untrusted TLS certificate

View file

@ -2368,7 +2368,8 @@ public class Application.Controller : Geary.BaseObject {
if (this.main_window != null) {
if (this.revokable != null && this.revokable_description != null) {
InAppNotification ian = new InAppNotification(this.revokable_description);
Components.InAppNotification ian =
new Components.InAppNotification(this.revokable_description);
ian.set_button(_("Undo"), "win." + GearyApplication.ACTION_UNDO);
this.main_window.add_notification(ian);
}
@ -2453,7 +2454,8 @@ public class Application.Controller : Geary.BaseObject {
string message = _(
"Successfully sent mail to %s."
).printf(Util.Email.to_short_recipient_display(rfc822.to));
InAppNotification notification = new InAppNotification(message);
Components.InAppNotification notification =
new Components.InAppNotification(message);
this.main_window.add_notification(notification);
this.play_sound("message-sent-email");
}

View file

@ -9,8 +9,8 @@
*
* Following the GNOME HIG, it should only contain a label and maybe a button.
*/
[GtkTemplate (ui = "/org/gnome/Geary/in-app-notification.ui")]
public class InAppNotification : Gtk.Revealer {
[GtkTemplate (ui = "/org/gnome/Geary/components-in-app-notification.ui")]
public class Components.InAppNotification : Gtk.Revealer {
/** Length of the default timeout to close the notification. */
public const uint DEFAULT_KEEPALIVE = 5;

View file

@ -342,7 +342,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
}
}
public void add_notification(InAppNotification notification) {
public void add_notification(Components.InAppNotification notification) {
this.overlay.add_overlay(notification);
notification.show();
}

View file

@ -26,6 +26,7 @@ geary_client_vala_sources = files(
'components/client-web-view.vala',
'components/components-inspector.vala',
'components/components-in-app-notification.vala',
'components/components-inspector-error-view.vala',
'components/components-inspector-log-view.vala',
'components/components-inspector-system-view.vala',
@ -84,8 +85,6 @@ geary_client_vala_sources = files(
'folder-list/folder-list-search-branch.vala',
'folder-list/folder-list-special-grouping.vala',
'notification/in-app-notification.vala',
'plugin/plugin-notification.vala',
'sidebar/sidebar-branch.vala',

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.14"/>
<template class="InAppNotification" parent="GtkRevealer">
<template class="ComponentsInAppNotification" parent="GtkRevealer">
<property name="visible">False</property>
<property name="halign">center</property>
<property name="valign">start</property>

View file

@ -10,6 +10,7 @@
<file compressed="true" preprocess="xml-stripblanks">certificate_warning_dialog.glade</file>
<file compressed="true">client-web-view.js</file>
<file compressed="true">client-web-view-allow-remote-images.js</file>
<file compressed="true" preprocess="xml-stripblanks">components-in-app-notification.ui</file>
<file compressed="true" preprocess="xml-stripblanks">components-inspector.ui</file>
<file compressed="true" preprocess="xml-stripblanks">components-inspector-error-view.ui</file>
<file compressed="true" preprocess="xml-stripblanks">components-inspector-log-view.ui</file>
@ -33,7 +34,6 @@
<file compressed="true" preprocess="xml-stripblanks">find_bar.glade</file>
<file compressed="true" preprocess="xml-stripblanks">folder-popover.ui</file>
<file compressed="true" preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
<file compressed="true" preprocess="xml-stripblanks">in-app-notification.ui</file>
<file compressed="true" preprocess="xml-stripblanks">main-toolbar.ui</file>
<file compressed="true" preprocess="xml-stripblanks">main-toolbar-menus.ui</file>
<file compressed="true" preprocess="xml-stripblanks">main-window.ui</file>