This commit is contained in:
Bleak Grey 2021-07-25 21:15:59 +03:00
parent f9e099a425
commit 1010a78c0f
3 changed files with 35 additions and 40 deletions

View File

@ -2,7 +2,7 @@ using Gtk;
public class Tootle.Views.ContentBase : Views.Base { public class Tootle.Views.ContentBase : Views.Base {
protected GLib.ListStore model; public GLib.ListStore model;
protected ListBox content; protected ListBox content;
public bool empty { public bool empty {

View File

@ -3,40 +3,36 @@ using Gtk;
public class Tootle.Views.Search : Views.TabbedBase { public class Tootle.Views.Search : Views.TabbedBase {
public string query { get; set; default = ""; } public string query { get; set; default = ""; }
// Adw.SearchBar bar; //TODO: Hdy.SearchBar no longer exists protected SearchBar bar;
Adw.Clamp bar_clamp; protected Adw.Clamp bar_clamp;
SearchEntry entry; protected SearchEntry entry;
Views.Base accounts_tab; Views.ContentBase accounts_tab;
Views.Base statuses_tab; Views.ContentBase statuses_tab;
Views.Base hashtags_tab; Views.ContentBase hashtags_tab;
public Search () { public Search () {
Object (label: _("Search")); Object (label: _("Search"));
// bar = new Adw.SearchBar (); bar = new SearchBar () {
// bar.search_mode_enabled = true; search_mode_enabled = true
// bar.show (); };
// pack_start (bar, false, false, 0); prepend (bar);
// reorder_child (bar, 2); reorder_child_after (bar, header);
entry = new SearchEntry (); entry = new SearchEntry () {
entry.width_chars = 25; width_chars = 25,
entry.text = query; text = query
entry.show (); };
bar_clamp = new Adw.Clamp (); bar_clamp = new Adw.Clamp () {
bar_clamp.child = entry; child = entry
};
// bar.add (bar_clamp); bar.child = bar_clamp;
// bar.connect_entry (entry); bar.connect_entry (entry);
entry.activate.connect (() => request ()); entry.activate.connect (() => request ());
// entry.icon_press.connect (() => {
// entry.text = "";
// request ();
// });
// entry.grab_focus_without_selecting ();
status_button.clicked.connect (request); status_button.clicked.connect (request);
accounts_tab = add_list_tab (_("Accounts"), "system-users-symbolic"); accounts_tab = add_list_tab (_("Accounts"), "system-users-symbolic");
@ -46,11 +42,10 @@ public class Tootle.Views.Search : Views.TabbedBase {
request (); request ();
} }
// bool append (Views.Base tab, owned Entity entity) { bool append_entity (Views.ContentBase tab, owned Entity entity) {
// var w = entity.to_widget (); tab.model.append (entity);
// tab.content_list.insert (w, -1); return true;
// return true; }
// }
void request () { void request () {
query = entry.text.chug ().chomp (); query = entry.text.chug ().chomp ();
@ -68,15 +63,15 @@ public class Tootle.Views.Search : Views.TabbedBase {
try { try {
var results = API.SearchResults.request.end (res); var results = API.SearchResults.request.end (res);
// if (!results.accounts.is_empty) { if (!results.accounts.is_empty) {
// results.accounts.@foreach (e => append (accounts_tab, e)); results.accounts.@foreach (e => append_entity (accounts_tab, e));
// } }
// if (!results.statuses.is_empty) { if (!results.statuses.is_empty) {
// results.statuses.@foreach (e => append (statuses_tab, e)); results.statuses.@foreach (e => append_entity (statuses_tab, e));
// } }
// if (!results.hashtags.is_empty) { if (!results.hashtags.is_empty) {
// results.hashtags.@foreach (e => append (hashtags_tab, e)); results.hashtags.@foreach (e => append_entity (hashtags_tab, e));
// } }
on_content_changed (); on_content_changed ();
} }

View File

@ -44,7 +44,7 @@ public class Tootle.Views.TabbedBase : Views.Base {
view.header.hide (); view.header.hide ();
} }
public Views.Base add_list_tab (string label, string icon) { public Views.ContentBase add_list_tab (string label, string icon) {
var tab = new Views.ContentBase (); var tab = new Views.ContentBase ();
tab.label = label; tab.label = label;
tab.icon = icon; tab.icon = icon;