chore: remove unused widgets & dialogs

This commit is contained in:
Evangelos Paterakis 2022-12-23 01:16:48 +02:00
parent f2111faee0
commit b489c4ca4c
No known key found for this signature in database
GPG Key ID: FE5185F095BFC8C9
6 changed files with 0 additions and 601 deletions

View File

@ -61,14 +61,12 @@
<file>ui/widgets/profile_field_row.ui</file>
<file>ui/widgets/timeline_menu.ui</file>
<file>ui/widgets/list_item.ui</file>
<file>ui/widgets/list_editor_item.ui</file>
<file>ui/widgets/compose_attachment.ui</file>
<file>ui/widgets/votebox.ui</file>
<file>ui/dialogs/new_account.ui</file>
<file>ui/dialogs/compose.ui</file>
<file>ui/dialogs/main.ui</file>
<file>ui/dialogs/preferences.ui</file>
<file>ui/dialogs/list_editor.ui</file>
<file>ui/menus.ui</file>
</gresource>
</gresources>

View File

@ -1,241 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="gtk" version="4.0"/>
<template class="ToothDialogsListEditor" parent="AdwWindow">
<property name="can_focus">False</property>
<property name="modal">True</property>
<property name="default_width">300</property>
<property name="default_height">400</property>
<property name="type_hint">dialog</property>
<child>
<object class="GtkBox">
<property name="visible">0</property>
<property name="width_request">300</property>
<property name="height_request">500</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHeaderBar">
<property name="visible">0</property>
<child type="title">
<object class="GtkBox">
<property name="visible">0</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<property name="visible">0</property>
<property name="label" translatable="yes">Name</property>
</object>
</child>
<child>
<object class="GtkEntry" id="name_entry">
<property name="visible">0</property>
<property name="sensitive">0</property>
<property name="width_chars">20</property>
<signal name="changed" handler="validate" swapped="no"/>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="cancel_btn">
<property name="visible">0</property>
<property name="label" translatable="yes">Cancel</property>
<property name="width_request">80</property>
<property name="receives_default">1</property>
<signal name="clicked" handler="on_cancel_clicked" swapped="no"/>
</object>
</child>
<child>
<object class="GtkButton" id="save_btn">
<property name="visible">0</property>
<property name="width_request">80</property>
<property name="sensitive">0</property>
<property name="receives_default">1</property>
<signal name="clicked" handler="on_save_clicked" swapped="no"/>
<child>
<object class="GtkStack" id="save_btn_stack">
<property name="visible">0</property>
<child>
<object class="GtkStackPage">
<property name="name">done</property>
<property name="child">
<object class="GtkLabel">
<property name="visible">0</property>
<property name="label" translatable="yes">Save</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">working</property>
<property name="position">1</property>
<property name="child">
<object class="GtkSpinner">
<property name="visible">0</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="active">True</property>
</object>
</property>
</object>
</child>
</object>
</child>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="pack_type">end</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">0</property>
<property name="message_type">error</property>
<property name="show_close_button">1</property>
<property name="revealed">0</property>
<signal name="response" handler="infobar_response" swapped="no"/>
<child internal-child="action_area">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</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="visible">0</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkLabel" id="infobar_label">
<property name="visible">0</property>
<property name="margin_start">6</property>
<property name="margin_end">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="hexpand">1</property>
<property name="wrap">1</property>
<property name="wrap_mode">word-char</property>
<property name="xalign">0</property>
</object>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkSearchEntry" id="search_entry">
<property name="visible">0</property>
<property name="sensitive">0</property>
<property name="can_default">True</property>
<property name="has_default">1</property>
<property name="margin_start">6</property>
<property name="margin_end">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="hexpand">1</property>
<property name="width_chars">30</property>
<property name="truncate_multiline">True</property>
<property name="caps_lock_warning">False</property>
<property name="primary_icon_name">tooth-loupe-large-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
<property name="placeholder_text" translatable="yes">Search among people you follow</property>
<signal name="search-changed" handler="on_search_changed" swapped="no"/>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">0</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="hscrollbar_policy">never</property>
<property name="child">
<object class="GtkViewport">
<property name="visible">0</property>
<property name="child">
<object class="GtkListBox" id="listbox">
<property name="visible">0</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="selection_mode">none</property>
<property name="activate_on_single_click">0</property>
<child type="placeholder">
<object class="GtkBox">
<property name="visible">0</property>
<property name="opacity">0.35</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<property name="margin_top">18</property>
<property name="margin_bottom">18</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkImage">
<property name="visible">0</property>
<property name="pixel_size">48</property>
<property name="icon_name">tooth-sentiment-dissatisfied-symbolic</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">0</property>
<property name="label" translatable="yes">Nobody here</property>
<property name="justify">center</property>
<property name="wrap">1</property>
<style>
<class name="title-2"/>
</style>
</object>
</child>
</object>
</child>
<style>
<class name="frame"/>
</style>
</object>
</property>
</object>
</property>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@ -1,72 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<template class="ToothDialogsListEditorItem" parent="GtkListBoxRow">
<property name="activatable">0</property>
<property name="child">
<object class="GtkGrid">
<property name="visible">0</property>
<property name="margin_start">8</property>
<property name="margin_end">8</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="row_spacing">8</property>
<property name="column_spacing">8</property>
<child>
<object class="ToothWidgetsRichLabel" id="label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label">Display Name</property>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"></attribute>
</attributes>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="ToothWidgetsRichLabel" id="handle">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label">@handle</property>
<property name="xalign">0</property>
<layout>
<property name="column">0</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkToggleButton" id="status">
<property name="visible">0</property>
<property name="width_request">32</property>
<property name="height_request">32</property>
<property name="sensitive">0</property>
<property name="receives_default">1</property>
<signal name="toggled" handler="on_toggled" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">0</property>
<property name="icon_name">tooth-check-round-outline-symbolic</property>
</object>
</child>
<style>
<class name="flat"/>
</style>
<layout>
<property name="column">1</property>
<property name="row">0</property>
<property name="row-span">2</property>
</layout>
</object>
</child>
</object>
</property>
</template>
</interface>

View File

@ -65,7 +65,6 @@ sources = files(
'src/Dialogs/Composer/EditorPage.vala',
'src/Dialogs/Composer/Page.vala',
'src/Dialogs/Composer/PollPage.vala',
'src/Dialogs/ListEditor.vala',
'src/Dialogs/MainWindow.vala',
'src/Dialogs/NewAccount.vala',
'src/Dialogs/Preferences.vala',

View File

@ -1,280 +0,0 @@
using Gtk;
[GtkTemplate (ui = "/dev/geopjr/tooth/ui/dialogs/list_editor.ui")]
public class Tooth.Dialogs.ListEditor: Adw.Window {
[GtkTemplate (ui = "/dev/geopjr/tooth/ui/widgets/list_editor_item.ui")]
class Item : ListBoxRow {
public ListEditor editor { get; construct set; }
public API.Account acc { get; construct set; }
public bool committed { get; construct set; }
[GtkChild] unowned Widgets.RichLabel label;
[GtkChild] unowned Widgets.RichLabel handle;
[GtkChild] unowned ToggleButton status;
public Item (ListEditor editor, API.Account acc, bool committed) {
this.editor = editor;
this.acc = acc;
this.committed = committed;
acc.bind_property ("display-name", label, "text", BindingFlags.SYNC_CREATE);
acc.bind_property ("handle", handle, "text", BindingFlags.SYNC_CREATE);
status.active = committed;
status.sensitive = true;
}
[GtkCallback]
void on_toggled () {
if (!status.sensitive)
return;
if (status.active) {
debug (@"To add: $(acc.id)");
editor.to_add.add (acc.id);
editor.to_remove.remove (acc.id);
}
else {
debug (@"To remove: $(acc.id)");
editor.to_add.remove (acc.id);
editor.to_remove.add (acc.id);
}
committed = status.active;
if (!editor.working)
editor.dirty = true;
}
}
public API.List list { get; set; }
public bool working { get; set; default = false; }
public bool exists { get; set; default = false; }
public bool dirty { get; set; default = false; }
Soup.Message? search_req = null;
public Gee.ArrayList<string> to_add = new Gee.ArrayList<string> ();
public Gee.ArrayList<string> to_remove = new Gee.ArrayList<string> ();
[GtkChild] unowned Button save_btn;
[GtkChild] unowned Stack save_btn_stack;
[GtkChild] unowned Entry name_entry;
[GtkChild] unowned SearchEntry search_entry;
[GtkChild] unowned ListBox listbox;
[GtkChild] unowned InfoBar infobar;
[GtkChild] unowned Label infobar_label;
public signal void done ();
construct {
transient_for = app.main_window;
show ();
}
public ListEditor.empty () {
var obj = new API.List () {
title = _("Untitled")
};
Object (list: obj);
init ();
}
public ListEditor (API.List list) {
Object (list: list, working: true, exists: true);
init ();
new Request.GET (@"/api/v1/lists/$(list.id)/accounts")
.with_account (accounts.active)
.with_ctx (this)
.on_error (on_error)
.then ((sess, msg) => {
Network.parse_array (msg, node => {
var acc = API.Account.from (node);
add_account (acc, true);
});
working = false;
})
.exec ();
}
void init () {
notify["working"].connect (on_state_changed);
list.bind_property ("title", name_entry, "text", BindingFlags.SYNC_CREATE);
ulong dirty_sigid = 0;
dirty_sigid = name_entry.changed.connect (() => {
dirty = true;
name_entry.disconnect (dirty_sigid);
});
on_state_changed (null);
}
void on_state_changed (ParamSpec? p) {
save_btn_stack.visible_child_name = working ? "working" : "done";
save_btn.sensitive = search_entry.sensitive = name_entry.sensitive = !working;
}
void on_error (int32 code, string msg) {
warning (msg);
infobar_label.label = msg;
infobar.revealed = true;
}
[GtkCallback]
void infobar_response (int i) {
infobar.revealed = false;
}
void request_search (string q) {
debug (@"Searching for: \"$q\"...");
if (search_req != null) {
network.cancel (search_req);
search_req = null;
}
search_req = new Request.GET ("/api/v1/accounts/search")
.with_account (accounts.active)
.with_ctx (this)
.with_param ("resolve", "false")
.with_param ("limit", "8")
.with_param ("following", "true")
.with_param ("q", q)
.then ((sess, msg) => {
Network.parse_array (msg, node => {
var acc = API.Account.from (node);
add_account (acc, false, 0);
});
})
.on_error (on_error)
.exec ();
}
void add_account (API.Account acc, bool added, int order = -1) {
var exists = false;
// listbox.@foreach (w => {
// var i = w as Item;
// if (i != null) {
// if (i.acc.id == acc.id)
// exists = true;
// }
// });
if (!exists) {
var item = new Item (this, acc, added);
listbox.insert (item, order);
}
}
void invalidate () {
// listbox.@foreach (w => {
// var i = w as Item;
// if (i != null) {
// if (!i.committed)
// i.destroy ();
// }
// });
}
[GtkCallback]
void validate () {
var has_title = name_entry.text.replace (" ", "") != "";
save_btn.sensitive = has_title;
}
[GtkCallback]
void on_cancel_clicked () {
if (dirty) {
var dlg = app.question (
_("Discard changes?"),
_("You need to save the list if you want to keep them."),
this,
_("Discard"),
Adw.ResponseAppearance.DESTRUCTIVE
);
dlg.response.connect(res => {
if (res == "yes") {
destroy ();
}
dlg.destroy();
});
dlg.present ();
}
else
destroy ();
}
[GtkCallback]
void on_search_changed () {
var q = search_entry.text.chug ().chomp ();
if (q.char_count () < 3)
invalidate ();
else if (q != "") {
invalidate ();
request_search (q);
}
}
[GtkCallback]
void on_save_clicked () {
working = true;
transaction.begin ((obj, res) => {
try {
transaction.end (res);
done ();
destroy ();
}
catch (Error e) {
working = false;
on_error (0, e.message);
}
});
}
async void transaction () throws Error {
if (!exists) {
message ("Creating list...");
var req = new Request.POST ("/api/v1/lists")
.with_account (accounts.active)
.with_param ("title", name_entry.text);
yield req.await ();
message ("Received new List entity");
var node = network.parse_node (req);
list = API.List.from (node);
}
else {
message ("Updating list title...");
yield new Request.PUT (@"/api/v1/lists/$(list.id)")
.with_account (accounts.active)
.with_param ("title", name_entry.text)
.await ();
}
if (!to_add.is_empty) {
message ("Adding accounts to list...");
var id_array = Request.array2string (to_add, "account_ids");
yield new Request.POST (@"/api/v1/lists/$(list.id)/accounts/?$id_array")
.with_account (accounts.active)
.await ();
}
if (!to_remove.is_empty) {
message ("Removing accounts from list...");
var id_array = Request.array2string (to_remove, "account_ids");
yield new Request.DELETE (@"/api/v1/lists/$(list.id)/accounts/?$id_array")
.with_account (accounts.active)
.await ();
}
message ("OK: List updated");
list.title = name_entry.text;
}
}

View File

@ -50,11 +50,6 @@ public class Tooth.Views.Lists : Views.Timeline {
}
}
[GtkCallback]
void on_edit_clicked () {
new Dialogs.ListEditor (this.list);
}
public virtual signal void remove_from_model () {}
void on_remove_clicked () {