Make user menu actions circular & add bookmarks

This commit is contained in:
Bleak Grey 2020-07-06 19:40:17 +03:00
parent f350e60c27
commit 366af1ef49
9 changed files with 213 additions and 73 deletions

View File

@ -20,3 +20,7 @@
.app-view:not(.padded) .preferences row {
border-radius: 0px;
}
.app-action-bar .circular {
box-shadow: none;
}

View File

@ -62,7 +62,6 @@
<child type="title">
<object class="HdyViewSwitcherTitle" id="timeline_switcher">
<property name="visible">True</property>
<property name="title">Tootle</property>
<property name="policy">auto</property>
</object>
<packing>

View File

@ -139,6 +139,7 @@
<object class="GtkLabel" id="rs_button_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Follow</property>
</object>
</child>
</object>

View File

@ -35,12 +35,150 @@
</packing>
</child>
<child>
<placeholder/>
<object class="GtkSeparator">
<property name="can_focus">False</property>
<property name="margin_top">4</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<object class="GtkFlowBox" id="actions">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="homogeneous">True</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<property name="min_children_per_line">4</property>
<property name="max_children_per_line">4</property>
<property name="selection_mode">none</property>
<property name="activate_on_single_click">False</property>
<child>
<object class="GtkFlowBoxChild">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<child>
<object class="GtkButton" id="item_conversations">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Conversations</property>
<property name="halign">center</property>
<property name="valign">center</property>
<child>
<object class="GtkImage">
<property name="width_request">32</property>
<property name="height_request">32</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">user-invisible-symbolic</property>
</object>
</child>
<style>
<class name="circular"/>
<class name="image-button"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="GtkFlowBoxChild">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton" id="item_favs">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Favorites</property>
<property name="halign">center</property>
<property name="valign">center</property>
<child>
<object class="GtkImage">
<property name="width_request">32</property>
<property name="height_request">32</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">non-starred-symbolic</property>
</object>
</child>
<style>
<class name="circular"/>
<class name="image-button"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="GtkFlowBoxChild">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton" id="item_bookmarks">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Bookmarks</property>
<property name="halign">center</property>
<property name="valign">center</property>
<child>
<object class="GtkImage">
<property name="width_request">32</property>
<property name="height_request">32</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">user-bookmarks-symbolic</property>
</object>
</child>
<style>
<class name="circular"/>
<class name="image-button"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="GtkFlowBoxChild">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<child>
<object class="GtkButton" id="item_lists">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Lists</property>
<property name="halign">center</property>
<property name="valign">center</property>
<child>
<object class="GtkImage">
<property name="width_request">32</property>
<property name="height_request">32</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">view-list-symbolic</property>
</object>
</child>
<style>
<class name="circular"/>
<class name="image-button"/>
</style>
</object>
</child>
</object>
</child>
<style>
<class name="app-action-bar"/>
</style>
</object>
<packing>
<property name="expand">False</property>
@ -49,11 +187,10 @@
</packing>
</child>
<child>
<object class="GtkModelButton" id="item_favs">
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="text" translatable="yes">Favorites</property>
<property name="can_focus">False</property>
<property name="margin_bottom">4</property>
</object>
<packing>
<property name="expand">False</property>
@ -61,42 +198,6 @@
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkModelButton" id="item_conversations">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="text" translatable="yes">Conversations</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkModelButton" id="item_watchlist">
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="text" translatable="yes">Watchlist</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkModelButton" id="item_refresh">
<property name="visible">True</property>
@ -107,7 +208,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
<property name="position">4</property>
</packing>
</child>
<child>
@ -120,7 +221,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
<property name="position">5</property>
</packing>
</child>
<child>
@ -133,7 +234,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">9</property>
<property name="position">6</property>
</packing>
</child>
</object>

View File

@ -96,6 +96,7 @@ executable(
'src/Views/Federated.vala',
'src/Views/Notifications.vala',
'src/Views/Conversations.vala',
'src/Views/Bookmarks.vala',
'src/Views/ExpandedStatus.vala',
'src/Views/Profile.vala',
'src/Views/Favorites.vala',

View File

@ -15,6 +15,7 @@ public class Tootle.API.Status : Entity, Widgetizable {
public string created_at { get; set; default = "0"; }
public bool reblogged { get; set; default = false; }
public bool favourited { get; set; default = false; }
public bool bookmarked { get; set; default = false; }
public bool sensitive { get; set; default = false; }
public bool muted { get; set; default = false; }
public bool pinned { get; set; default = false; }

11
src/Views/Bookmarks.vala Normal file
View File

@ -0,0 +1,11 @@
public class Tootle.Views.Bookmarks : Views.Timeline {
public Bookmarks () {
Object (
url: "/api/v1/bookmarks",
label: _("Bookmarks"),
icon: "user-bookmarks-symbolic"
);
}
}

View File

@ -4,17 +4,17 @@ using Gtk;
public class Tootle.Widgets.AccountsButton : Gtk.MenuButton, IAccountListener {
[GtkTemplate (ui = "/com/github/bleakgrey/tootle/ui/widgets/accounts_button_item.ui")]
private class Item : Grid {
class Item : Grid {
[GtkChild]
private Widgets.Avatar avatar;
Widgets.Avatar avatar;
[GtkChild]
private Label title;
Label title;
[GtkChild]
private Label handle;
Label handle;
[GtkChild]
private Button profile;
Button profile;
[GtkChild]
private Button forget;
Button forget;
public Item (InstanceAccount acc, AccountsButton _self) {
avatar.url = acc.avatar;
@ -40,42 +40,57 @@ public class Tootle.Widgets.AccountsButton : Gtk.MenuButton, IAccountListener {
}
}
private bool invalidated = true;
bool invalidated = true;
[GtkChild]
private Widgets.Avatar avatar;
// [GtkChild]
// private Spinner spinner;
Widgets.Avatar avatar;
[GtkChild]
private ListBox account_list;
ListBox account_list;
[GtkChild]
private ModelButton item_accounts;
ModelButton item_accounts;
[GtkChild]
private ModelButton item_prefs;
ModelButton item_prefs;
[GtkChild]
private ModelButton item_refresh;
ModelButton item_refresh;
[GtkChild]
private ModelButton item_search;
ModelButton item_search;
[GtkChild]
private ModelButton item_favs;
Button item_favs;
[GtkChild]
private ModelButton item_conversations;
Button item_conversations;
[GtkChild]
Button item_bookmarks;
construct {
connect_account ();
item_refresh.clicked.connect (() => app.refresh ());
item_refresh.clicked.connect (() => {
app.refresh ();
});
Desktop.set_hotkey_tooltip (item_refresh, null, app.ACCEL_REFRESH);
item_favs.clicked.connect (() => window.open_view (new Views.Favorites ()));
item_conversations.clicked.connect (() => window.open_view (new Views.Conversations ()));
item_search.clicked.connect (() => window.open_view (new Views.Search ()));
item_prefs.clicked.connect (() => Dialogs.Preferences.open ());
// network.started.connect (() => spinner.show ());
// network.finished.connect (() => spinner.hide ());
item_favs.clicked.connect (() => {
window.open_view (new Views.Favorites ());
popover.popdown ();
});
item_conversations.clicked.connect (() => {
window.open_view (new Views.Conversations ());
popover.popdown ();
});
item_bookmarks.clicked.connect (() => {
window.open_view (new Views.Bookmarks ());
popover.popdown ();
});
item_search.clicked.connect (() => {
window.open_view (new Views.Search ());
popover.popdown ();
});
item_prefs.clicked.connect (() => {
Dialogs.Preferences.open ();
popover.popdown ();
});
on_account_changed (null);
@ -84,7 +99,7 @@ public class Tootle.Widgets.AccountsButton : Gtk.MenuButton, IAccountListener {
rebuild ();
});
account_list.row_activated.connect (on_selection_changed) ;
account_list.row_activated.connect (on_selection_changed);
}
protected void on_selection_changed (ListBoxRow r) {
@ -92,6 +107,7 @@ public class Tootle.Widgets.AccountsButton : Gtk.MenuButton, IAccountListener {
if (i >= accounts.saved.size) {
active = false;
window.open_view (new Views.NewAccount (true));
popover.popdown ();
return;
}
@ -100,6 +116,7 @@ public class Tootle.Widgets.AccountsButton : Gtk.MenuButton, IAccountListener {
return;
accounts.switch_account (i);
popover.popdown ();
}
public virtual void on_accounts_changed (Gee.ArrayList<InstanceAccount> accounts) {
@ -120,7 +137,7 @@ public class Tootle.Widgets.AccountsButton : Gtk.MenuButton, IAccountListener {
item_accounts.use_markup = true;
}
private void rebuild () {
void rebuild () {
account_list.@foreach (w => account_list.remove (w));
accounts.saved.@foreach (acc => {
var item = new Item (acc, this);

View File

@ -112,6 +112,11 @@ public class Tootle.Widgets.Status : ListBoxRow {
reblog_button.clicked.connect (() => {
status.action (status.formal.reblogged ? "unreblog" : "reblog");
});
status.formal.bind_property ("bookmarked", bookmark_button, "active", BindingFlags.SYNC_CREATE);
bookmark_button.clicked.connect (() => {
status.action (status.formal.bookmarked ? "unbookmark" : "bookmark");
});
reply_button.clicked.connect (() => new Dialogs.Compose.reply (status));