Use Adw.StatusPage instead of custom placeholders

This commit is contained in:
fiaxh 2022-12-25 18:04:26 +01:00 committed by Marvin W
parent 92aca5672d
commit 4b391f3f31
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A
6 changed files with 68 additions and 189 deletions

View file

@ -19,40 +19,13 @@
<object class="GtkStackPage"> <object class="GtkStackPage">
<property name="name">empty</property> <property name="name">empty</property>
<property name="child"> <property name="child">
<object class="GtkBox"> <object class="AdwStatusPage">
<property name="orientation">vertical</property> <style>
<property name="spacing">10</property> <class name="compact"/>
<property name="valign">center</property> </style>
<child>
<object class="GtkImage">
<property name="icon-name">system-search-symbolic</property> <property name="icon-name">system-search-symbolic</property>
<property name="icon-size">large</property> <property name="title" translatable="1">No active search</property>
<property name="pixel-size">72</property> <property name="description" translatable="1">Type to start a search</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="1">No active search</property>
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"></attribute>
<attribute name="scale" value="1.3"></attribute>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="1">Type to start a search</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object> </object>
</property> </property>
</object> </object>
@ -61,40 +34,13 @@
<object class="GtkStackPage"> <object class="GtkStackPage">
<property name="name">no-result</property> <property name="name">no-result</property>
<property name="child"> <property name="child">
<object class="GtkBox"> <object class="AdwStatusPage">
<property name="orientation">vertical</property> <style>
<property name="spacing">10</property> <class name="compact"/>
<property name="valign">center</property> </style>
<child>
<object class="GtkImage">
<property name="icon-name">face-uncertain-symbolic</property> <property name="icon-name">face-uncertain-symbolic</property>
<property name="icon-size">large</property> <property name="title" translatable="1">No matching messages</property>
<property name="pixel-size">72</property> <property name="description" translatable="1">Check the spelling or try to remove filters</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="1">No matching messages</property>
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"></attribute>
<attribute name="scale" value="1.3"></attribute>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="1">Check the spelling or try to remove filters</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object> </object>
</property> </property>
</object> </object>

View file

@ -3,6 +3,10 @@
* It provides sane defaults for things that are very Dino-specific. * It provides sane defaults for things that are very Dino-specific.
*/ */
statuspage {
opacity: 0.5;
}
window.dino-main .dino-header-right { window.dino-main .dino-header-right {
background: @theme_base_color; background: @theme_base_color;
} }

View file

@ -30,37 +30,18 @@
<object class="GtkStackPage"> <object class="GtkStackPage">
<property name="name">placeholder</property> <property name="name">placeholder</property>
<property name="child"> <property name="child">
<object class="GtkBox"> <object class="AdwStatusPage">
<style>
<class name="compact"/>
</style>
<property name="margin-start">20</property> <property name="margin-start">20</property>
<property name="margin-end">20</property> <property name="margin-end">20</property>
<property name="margin-top">20</property> <property name="margin-top">20</property>
<property name="margin-bottom">20</property> <property name="margin-bottom">20</property>
<property name="spacing">10</property>
<property name="valign">start</property>
<property name="halign">start</property>
<property name="width_request">260</property> <property name="width_request">260</property>
<child>
<object class="GtkImage" id="conversation_list_placeholder_image"> <property name="title" translatable="True">You have no open chats</property>
<property name="valign">start</property> <property name="description" translatable="True">Click + to start a conversation or join a channel</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="wrap">1</property>
<property name="margin-top">70</property>
<property name="margin-end">50</property>
<property name="xalign">0</property>
<property name="valign">end</property>
<property name="max-width-chars">0</property>
<property name="label" translatable="1">Click here to start a conversation or join a channel.</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object> </object>
</property> </property>
</object> </object>
@ -89,33 +70,10 @@
<object class="GtkStackPage"> <object class="GtkStackPage">
<property name="name">placeholder</property> <property name="name">placeholder</property>
<property name="child"> <property name="child">
<object class="GtkBox"> <object class="AdwStatusPage">
<property name="orientation">vertical</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="halign">center</property>
<property name="valign">center</property>
<child>
<object class="GtkImage">
<property name="icon-name">im.dino.Dino-symbolic</property> <property name="icon-name">im.dino.Dino-symbolic</property>
<property name="pixel-size">144</property> <property name="hexpand">True</property>
<property name="margin-bottom">30</property> <property name="vexpand">True</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="1">You have no open chats</property>
<style>
<class name="dim-label"/>
</style>
<attributes>
<attribute name="scale" value="1.2"></attribute>
</attributes>
</object>
</child>
</object> </object>
</property> </property>
</object> </object>

View file

@ -2,55 +2,31 @@
<interface> <interface>
<requires lib="gtk" version="4.0"/> <requires lib="gtk" version="4.0"/>
<template class="DinoUiMainWindowPlaceholder"> <template class="DinoUiMainWindowPlaceholder">
<property name="valign">fill</property>
<child> <child>
<object class="GtkBox" id="box"> <object class="GtkBox" id="box">
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="valign">fill</property> <property name="hexpand">True</property>
<property name="halign">fill</property> <property name="vexpand">True</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child> <child>
<object class="GtkHeaderBar"> <object class="GtkHeaderBar">
<property name="show-title-buttons">true</property> <property name="show-title-buttons">true</property>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkImage"> <object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
<object class="AdwStatusPage" id="status_page">
<property name="icon-name">im.dino.Dino-symbolic</property> <property name="icon-name">im.dino.Dino-symbolic</property>
<property name="pixel-size">144</property>
<property name="margin-start">30</property>
<property name="margin-end">30</property>
<property name="margin-top">30</property>
<property name="margin-bottom">30</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel" id="title_label">
<property name="visible">0</property>
<style>
<class name="dim-label"/>
</style>
<attributes>
<attribute name="scale" value="1.3"></attribute>
</attributes>
</object>
</child>
<child>
<object class="GtkLabel" id="label">
<property name="margin-top">5</property>
<style>
<class name="dim-label"/>
</style>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkButton" id="primary_button"> <object class="GtkButton" id="primary_button">
<property name="margin-top">15</property>
<property name="halign">center</property> <property name="halign">center</property>
<property name="visible">False</property>
<style> <style>
<class name="text-button"/> <class name="text-button"/>
<class name="suggested-action"/> <class name="suggested-action"/>
@ -61,7 +37,7 @@
<object class="GtkButton" id="secondary_button"> <object class="GtkButton" id="secondary_button">
<property name="visible">0</property> <property name="visible">0</property>
<property name="halign">center</property> <property name="halign">center</property>
<!-- <property name="no_show_all">True</property>--> <property name="visible">False</property>
<style> <style>
<class name="text-button"/> <class name="text-button"/>
</style> </style>
@ -69,5 +45,7 @@
</child> </child>
</object> </object>
</child> </child>
</object>
</child>
</template> </template>
</interface> </interface>

View file

@ -11,7 +11,7 @@ class OccupantsEntry : Plugins.ConversationTitlebarEntry, Object {
StreamInteractor stream_interactor; StreamInteractor stream_interactor;
private Conversation? conversation; private Conversation? conversation;
private MenuButton button = new MenuButton() { icon_name="system-users-symbolic", tooltip_text=Util.string_if_tooltips_active(_("Members")) }; private MenuButton button = new MenuButton() { icon_name="system-users-symbolic", tooltip_text=Util.string_if_tooltips_active(_("Members")), visible=false };
private OccupantMenu.View menu = null; private OccupantMenu.View menu = null;

View file

@ -74,9 +74,6 @@ public class MainWindow : Adw.Window {
Frame search_frame = (Frame) builder.get_object("search_frame"); Frame search_frame = (Frame) builder.get_object("search_frame");
global_search = new GlobalSearch(stream_interactor); global_search = new GlobalSearch(stream_interactor);
search_frame.set_child(global_search.get_widget()); search_frame.set_child(global_search.get_widget());
Image conversation_list_placeholder_image = (Image) builder.get_object("conversation_list_placeholder_image");
conversation_list_placeholder_image.set_from_pixbuf(new Pixbuf.from_resource("/im/dino/Dino/dino-conversation-list-placeholder-arrow.svg"));
} }
private void setup_headerbar() { private void setup_headerbar() {
@ -179,28 +176,24 @@ public class MainWindow : Adw.Window {
public class WelcomePlaceholder : MainWindowPlaceholder { public class WelcomePlaceholder : MainWindowPlaceholder {
public WelcomePlaceholder() { public WelcomePlaceholder() {
title_label.label = _("Welcome to Dino!"); status_page.title = _("Welcome to Dino!");
label.label = _("Sign in or create an account to get started."); status_page.description = _("Sign in or create an account to get started.");
primary_button.label = _("Set up account"); primary_button.label = _("Set up account");
title_label.visible = true; primary_button.visible = true;
secondary_button.visible = false;
} }
} }
public class NoAccountsPlaceholder : MainWindowPlaceholder { public class NoAccountsPlaceholder : MainWindowPlaceholder {
public NoAccountsPlaceholder() { public NoAccountsPlaceholder() {
title_label.label = _("No active accounts"); status_page.title = _("No active accounts");
primary_button.label = _("Manage accounts"); primary_button.label = _("Manage accounts");
title_label.visible = true; primary_button.visible = true;
label.visible = false;
secondary_button.visible = false;
} }
} }
[GtkTemplate (ui = "/im/dino/Dino/unified_window_placeholder.ui")] [GtkTemplate (ui = "/im/dino/Dino/unified_window_placeholder.ui")]
public class MainWindowPlaceholder : Box { public class MainWindowPlaceholder : Box {
[GtkChild] public unowned Label title_label; [GtkChild] public unowned Adw.StatusPage status_page;
[GtkChild] public unowned Label label;
[GtkChild] public unowned Button primary_button; [GtkChild] public unowned Button primary_button;
[GtkChild] public unowned Button secondary_button; [GtkChild] public unowned Button secondary_button;
} }