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 { .app-view:not(.padded) .preferences row {
border-radius: 0px; border-radius: 0px;
} }
.app-action-bar .circular {
box-shadow: none;
}

View File

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

View File

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

View File

@ -35,12 +35,150 @@
</packing> </packing>
</child> </child>
<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>
<child> <child>
<object class="GtkSeparator"> <object class="GtkFlowBox" id="actions">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</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> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -49,11 +187,10 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkModelButton" id="item_favs"> <object class="GtkSeparator">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="receives_default">True</property> <property name="margin_bottom">4</property>
<property name="text" translatable="yes">Favorites</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -61,42 +198,6 @@
<property name="position">3</property> <property name="position">3</property>
</packing> </packing>
</child> </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> <child>
<object class="GtkModelButton" id="item_refresh"> <object class="GtkModelButton" id="item_refresh">
<property name="visible">True</property> <property name="visible">True</property>
@ -107,7 +208,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">7</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -120,7 +221,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">8</property> <property name="position">5</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -133,7 +234,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">9</property> <property name="position">6</property>
</packing> </packing>
</child> </child>
</object> </object>

View File

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

View File

@ -112,6 +112,11 @@ public class Tootle.Widgets.Status : ListBoxRow {
reblog_button.clicked.connect (() => { reblog_button.clicked.connect (() => {
status.action (status.formal.reblogged ? "unreblog" : "reblog"); 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)); reply_button.clicked.connect (() => new Dialogs.Compose.reply (status));