client: Remove mostly unused StatusBar widget
- Message are now shown in toasts - It's only used to hold a Spinner, moved in HeaderBar
This commit is contained in:
parent
d9b2174817
commit
a5e4764de5
6 changed files with 11 additions and 151 deletions
|
|
@ -992,7 +992,6 @@ internal class Application.Controller :
|
|||
account.notify["current-status"].connect(
|
||||
on_account_status_notify
|
||||
);
|
||||
account.email_removed.connect(on_account_email_removed);
|
||||
account.folders_available_unavailable.connect(on_folders_available_unavailable);
|
||||
account.report_problem.connect(on_report_problem);
|
||||
|
||||
|
|
@ -1001,8 +1000,6 @@ internal class Application.Controller :
|
|||
);
|
||||
if (smtp != null) {
|
||||
smtp.email_sent.connect(on_sent);
|
||||
smtp.sending_monitor.start.connect(on_sending_started);
|
||||
smtp.sending_monitor.finish.connect(on_sending_finished);
|
||||
}
|
||||
|
||||
// Notify before opening so that listeners have a chance to
|
||||
|
|
@ -1077,7 +1074,6 @@ internal class Application.Controller :
|
|||
on_account_status_notify
|
||||
);
|
||||
|
||||
account.email_removed.disconnect(on_account_email_removed);
|
||||
account.folders_available_unavailable.disconnect(on_folders_available_unavailable);
|
||||
|
||||
Geary.Smtp.ClientService? smtp = (
|
||||
|
|
@ -1085,8 +1081,6 @@ internal class Application.Controller :
|
|||
);
|
||||
if (smtp != null) {
|
||||
smtp.email_sent.disconnect(on_sent);
|
||||
smtp.sending_monitor.start.disconnect(on_sending_started);
|
||||
smtp.sending_monitor.finish.disconnect(on_sending_finished);
|
||||
}
|
||||
|
||||
// Now the account is not in the accounts map, reset any
|
||||
|
|
@ -1303,28 +1297,6 @@ internal class Application.Controller :
|
|||
update_account_status();
|
||||
}
|
||||
|
||||
private void on_account_email_removed(Geary.Folder folder,
|
||||
Gee.Collection<Geary.EmailIdentifier> ids) {
|
||||
if (folder.used_as == OUTBOX) {
|
||||
foreach (MainWindow window in this.application.get_main_windows()) {
|
||||
window.status_bar.deactivate_message(StatusBar.Message.OUTBOX_SEND_FAILURE);
|
||||
window.status_bar.deactivate_message(StatusBar.Message.OUTBOX_SAVE_SENT_MAIL_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void on_sending_started() {
|
||||
foreach (MainWindow window in this.application.get_main_windows()) {
|
||||
window.status_bar.activate_message(StatusBar.Message.OUTBOX_SENDING);
|
||||
}
|
||||
}
|
||||
|
||||
private void on_sending_finished() {
|
||||
foreach (MainWindow window in this.application.get_main_windows()) {
|
||||
window.status_bar.deactivate_message(StatusBar.Message.OUTBOX_SENDING);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns true if the caller should try opening the account again
|
||||
private async bool account_database_error_async(Geary.Account account) {
|
||||
bool retry = true;
|
||||
|
|
|
|||
|
|
@ -73,8 +73,6 @@ public class Application.MainWindow :
|
|||
private const string CONVERSATION_LIST = "conversation_list";
|
||||
private const string CONVERSATION_VIEWER = "conversation_viewer";
|
||||
|
||||
private const int STATUS_BAR_HEIGHT = 18;
|
||||
|
||||
private const int UPDATE_UI_INTERVAL = 60;
|
||||
|
||||
private const int MIN_CONVERSATION_COUNT = 50;
|
||||
|
|
@ -370,12 +368,8 @@ public class Application.MainWindow :
|
|||
get; private set; default = new Components.InfoBarStack(PRIORITY_QUEUE);
|
||||
}
|
||||
|
||||
public StatusBar status_bar { get; private set; default = new StatusBar(); }
|
||||
|
||||
private Controller controller;
|
||||
|
||||
private MonitoredSpinner spinner = new MonitoredSpinner();
|
||||
|
||||
private Gee.Set<AccountContext> accounts = new Gee.HashSet<AccountContext>();
|
||||
|
||||
private GLib.SimpleActionGroup edit_actions = new GLib.SimpleActionGroup();
|
||||
|
|
@ -406,7 +400,6 @@ public class Application.MainWindow :
|
|||
// Folds the folder list and the conversation list
|
||||
[GtkChild] private unowned Hdy.Leaflet inner_leaflet;
|
||||
|
||||
[GtkChild] private unowned Gtk.Box folder_box;
|
||||
[GtkChild] private unowned Gtk.ScrolledWindow folder_list_scrolled;
|
||||
|
||||
[GtkChild] private unowned Gtk.Box conversation_list_box;
|
||||
|
|
@ -607,7 +600,6 @@ public class Application.MainWindow :
|
|||
});
|
||||
|
||||
setup_layout(application.config);
|
||||
this.folder_box.pack_start(status_bar, false, false);
|
||||
|
||||
update_command_actions();
|
||||
update_conversation_actions(NONE);
|
||||
|
|
@ -1387,13 +1379,7 @@ public class Application.MainWindow :
|
|||
}
|
||||
);
|
||||
|
||||
// Status bar
|
||||
this.status_bar.set_size_request(-1, STATUS_BAR_HEIGHT);
|
||||
this.status_bar.set_border_width(2);
|
||||
this.spinner.set_size_request(STATUS_BAR_HEIGHT - 2, -1);
|
||||
this.spinner.set_progress_monitor(progress_monitor);
|
||||
this.status_bar.add(this.spinner);
|
||||
this.status_bar.show_all();
|
||||
this.application_headerbar.spinner.set_progress_monitor(progress_monitor);
|
||||
|
||||
this.conversation_list_actions.set_mark_inverted();
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
public class Components.ApplicationHeaderBar : Hdy.HeaderBar {
|
||||
|
||||
[GtkChild] private unowned Gtk.MenuButton app_menu_button;
|
||||
[GtkChild] public unowned MonitoredSpinner spinner;
|
||||
|
||||
|
||||
construct {
|
||||
|
|
|
|||
|
|
@ -1,107 +0,0 @@
|
|||
/* Copyright 2016 Software Freedom Conservancy Inc.
|
||||
*
|
||||
* This software is licensed under the GNU Lesser General Public License
|
||||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A wrapper around Gtk.Statusbar that predefines messages and context areas so
|
||||
* you don't have to keep track of them elsewhere. You can activate and
|
||||
* deactivate messages, instead of worrying about context areas and stacks.
|
||||
* Internally, activations are reference counted, and every new activation
|
||||
* pushes the message to the top of its context area's stack. Only when
|
||||
* the number of deactivations equals the number of activations is the message
|
||||
* removed from the stack entirely.
|
||||
*/
|
||||
public class StatusBar : Gtk.Statusbar {
|
||||
public enum Message {
|
||||
OUTBOX_SENDING,
|
||||
OUTBOX_SEND_FAILURE,
|
||||
OUTBOX_SAVE_SENT_MAIL_FAILED;
|
||||
|
||||
internal string get_text() {
|
||||
switch (this) {
|
||||
case Message.OUTBOX_SENDING:
|
||||
/// Displayed in the space-limited status bar while a message is in the process of being sent.
|
||||
return _("Sending…");
|
||||
case Message.OUTBOX_SEND_FAILURE:
|
||||
/// Displayed in the space-limited status bar when a message fails to be sent due to error.
|
||||
return _("Error sending email");
|
||||
case Message.OUTBOX_SAVE_SENT_MAIL_FAILED:
|
||||
// Displayed in the space-limited status bar when a message fails to be uploaded
|
||||
// to Sent Mail after being sent.
|
||||
return _("Error saving sent mail");
|
||||
default:
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
internal Context get_context() {
|
||||
switch (this) {
|
||||
case Message.OUTBOX_SENDING:
|
||||
return Context.OUTBOX;
|
||||
case Message.OUTBOX_SEND_FAILURE:
|
||||
return Context.OUTBOX;
|
||||
case Message.OUTBOX_SAVE_SENT_MAIL_FAILED:
|
||||
return Context.OUTBOX;
|
||||
default:
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal enum Context {
|
||||
OUTBOX,
|
||||
}
|
||||
|
||||
private Gee.HashMap<Context, uint> context_ids = new Gee.HashMap<Context, uint>();
|
||||
private Gee.HashMap<Message, uint> message_ids = new Gee.HashMap<Message, uint>();
|
||||
private Gee.HashMap<Message, int> message_counts = new Gee.HashMap<Message, int>();
|
||||
|
||||
public StatusBar() {
|
||||
set_context_id(Context.OUTBOX);
|
||||
}
|
||||
|
||||
private void set_context_id(Context context) {
|
||||
context_ids.set(context, get_context_id(context.to_string()));
|
||||
}
|
||||
|
||||
private int get_count(Message message) {
|
||||
return (message_counts.has_key(message) ? message_counts.get(message) : 0);
|
||||
}
|
||||
|
||||
private void push_message(Message message) {
|
||||
message_ids.set(message, push(context_ids.get(message.get_context()), message.get_text()));
|
||||
}
|
||||
|
||||
private void remove_message(Message message) {
|
||||
remove(context_ids.get(message.get_context()), message_ids.get(message));
|
||||
message_ids.unset(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the message has been activated more times than it has
|
||||
* been deactivated.
|
||||
*/
|
||||
public bool is_message_active(Message message) {
|
||||
return message_ids.has_key(message);
|
||||
}
|
||||
|
||||
public void activate_message(Message message) {
|
||||
if (is_message_active(message))
|
||||
remove_message(message);
|
||||
|
||||
push_message(message);
|
||||
message_counts.set(message, get_count(message) + 1);
|
||||
}
|
||||
|
||||
public void deactivate_message(Message message) {
|
||||
if (!is_message_active(message))
|
||||
return;
|
||||
|
||||
int count = get_count(message);
|
||||
if (count == 1)
|
||||
remove_message(message);
|
||||
message_counts.set(message, count - 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -72,7 +72,6 @@ client_vala_sources = files(
|
|||
'components/icon-factory.vala',
|
||||
'components/monitored-progress-bar.vala',
|
||||
'components/monitored-spinner.vala',
|
||||
'components/status-bar.vala',
|
||||
'components/stock.vala',
|
||||
|
||||
'composer/composer-application-interface.vala',
|
||||
|
|
|
|||
|
|
@ -5,6 +5,15 @@
|
|||
<template class="ComponentsApplicationHeaderBar" parent="HdyHeaderBar">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">Mail</property>
|
||||
<child>
|
||||
<object class="MonitoredSpinner" id="spinner">
|
||||
<property name="visible">True</property>
|
||||
<property name="margin-start">5</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton" id="app_menu_button">
|
||||
<property name="visible">True</property>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue