feat(Base): make the status box match AdwStatusPage style
and split the messages into title and description
This commit is contained in:
parent
b3f8e943f0
commit
4aa033f496
|
@ -71,8 +71,32 @@
|
|||
<object class="GtkStackPage">
|
||||
<property name="name">message</property>
|
||||
<property name="child">
|
||||
<object class="GtkLabel" id="status_message_label">
|
||||
<property name="use_markup">1</property>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="status_title_label">
|
||||
<property name="wrap">1</property>
|
||||
<property name="wrap-mode">word-char</property>
|
||||
<property name="justify">center</property>
|
||||
<style>
|
||||
<class name="title"/>
|
||||
<class name="title-1"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="status_message_label">
|
||||
<property name="wrap">1</property>
|
||||
<property name="wrap-mode">word-char</property>
|
||||
<property name="justify">center</property>
|
||||
<style>
|
||||
<class name="body"/>
|
||||
<class name="description"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
|
@ -88,9 +112,6 @@
|
|||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -98,7 +119,7 @@
|
|||
<property name="visible">0</property>
|
||||
<property name="halign">center</property>
|
||||
<style>
|
||||
<class name="flat"/>
|
||||
<class name="pill"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
|
|
|
@ -27,9 +27,11 @@ public class Tooth.Views.Base : Box {
|
|||
[GtkChild] protected unowned Box content_box;
|
||||
[GtkChild] protected unowned Button status_button;
|
||||
[GtkChild] unowned Stack status_stack;
|
||||
[GtkChild] unowned Label status_title_label;
|
||||
[GtkChild] unowned Label status_message_label;
|
||||
|
||||
public string state { get; set; default = "status"; }
|
||||
public string status_title { get; set; default = STATUS_EMPTY; }
|
||||
public string status_message { get; set; default = STATUS_EMPTY; }
|
||||
|
||||
construct {
|
||||
|
@ -38,10 +40,17 @@ public class Tooth.Views.Base : Box {
|
|||
|
||||
status_button.label = _("Reload");
|
||||
bind_property ("state", states, "visible-child-name", BindingFlags.SYNC_CREATE);
|
||||
bind_property ("status-message", status_message_label, "label", BindingFlags.SYNC_CREATE, (b, src, ref target) => {
|
||||
var src_s = src.get_string ();
|
||||
target.set_string (src_s);
|
||||
status_message_label.visible = src_s != STATUS_EMPTY && src_s != "";
|
||||
return true;
|
||||
});
|
||||
|
||||
notify["status-message"].connect (() => {
|
||||
status_message_label.label = @"<span size='large'>$status_message</span>";
|
||||
status_stack.visible_child_name = status_message == STATUS_LOADING ? "spinner" : "message";
|
||||
notify["status-title"].connect (() => {
|
||||
status_title_label.label = status_title;
|
||||
status_message = STATUS_EMPTY;
|
||||
status_stack.visible_child_name = status_title == STATUS_LOADING ? "spinner" : "message";
|
||||
});
|
||||
|
||||
notify["current"].connect (() => {
|
||||
|
@ -86,6 +95,7 @@ public class Tooth.Views.Base : Box {
|
|||
public virtual void on_content_changed () {}
|
||||
|
||||
public virtual void on_error (int32 code, string reason) {
|
||||
status_title = _("An Error Occurred");
|
||||
status_message = reason;
|
||||
status_button.visible = true;
|
||||
status_button.sensitive = true;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class Tooth.Views.ContentBase : Views.Base {
|
|||
|
||||
public override void on_content_changed () {
|
||||
if (empty) {
|
||||
status_message = STATUS_EMPTY;
|
||||
status_title = STATUS_EMPTY;
|
||||
state = "status";
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -52,13 +52,13 @@ public class Tooth.Views.Search : Views.TabbedBase {
|
|||
if (query == "") {
|
||||
clear ();
|
||||
state = "status";
|
||||
status_message = _("Enter query");
|
||||
status_title = _("Enter Query");
|
||||
return;
|
||||
}
|
||||
|
||||
clear ();
|
||||
state = "status";
|
||||
status_message = STATUS_LOADING;
|
||||
status_title = STATUS_LOADING;
|
||||
API.SearchResults.request.begin (query, accounts.active, (obj, res) => {
|
||||
try {
|
||||
var results = API.SearchResults.request.end (res);
|
||||
|
|
|
@ -88,7 +88,7 @@ public class Tooth.Views.TabbedBase : Views.Base {
|
|||
|
||||
// if (empty) {
|
||||
// state = "status";
|
||||
// status_message = STATUS_EMPTY;
|
||||
// status_title = STATUS_EMPTY;
|
||||
// }
|
||||
// else {
|
||||
// state = "content";
|
||||
|
|
|
@ -9,7 +9,7 @@ public class Tooth.Views.Thread : Views.ContentBase, AccountHolder {
|
|||
public Thread (API.Status status) {
|
||||
Object (
|
||||
root_status: status,
|
||||
status_message: STATUS_LOADING,
|
||||
status_title: STATUS_LOADING,
|
||||
label: _("Conversation")
|
||||
);
|
||||
construct_account_holder ();
|
||||
|
|
|
@ -106,7 +106,7 @@ public class Tooth.Views.Timeline : AccountHolder, Streamable, Views.ContentBase
|
|||
scrolled.vadjustment.value = 0;
|
||||
status_button.sensitive = false;
|
||||
clear ();
|
||||
status_message = STATUS_LOADING;
|
||||
status_title = STATUS_LOADING;
|
||||
GLib.Idle.add (request);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue