mirror of
https://github.com/TakeV-Lambda/Tooth.git
synced 2024-10-31 21:20:24 +00:00
feat(status): edit history
This commit is contained in:
parent
72388cf56e
commit
5397244af9
3 changed files with 39 additions and 1 deletions
|
@ -111,6 +111,7 @@ sources = files(
|
|||
'src/Views/Bookmarks.vala',
|
||||
'src/Views/ContentBase.vala',
|
||||
'src/Views/Conversations.vala',
|
||||
'src/Views/EditHistory.vala',
|
||||
'src/Views/Favorites.vala',
|
||||
'src/Views/Federated.vala',
|
||||
'src/Views/Hashtag.vala',
|
||||
|
|
19
src/Views/EditHistory.vala
Normal file
19
src/Views/EditHistory.vala
Normal file
|
@ -0,0 +1,19 @@
|
|||
public class Tooth.Views.EditHistory : Views.Timeline {
|
||||
public EditHistory (string status_id) {
|
||||
Object (
|
||||
url: @"/api/v1/statuses/$(status_id)/history",
|
||||
label: _("Edit History"),
|
||||
icon: "tooth-edit-symbolic"
|
||||
);
|
||||
}
|
||||
|
||||
public override Gtk.Widget on_create_model_widget(Object obj) {
|
||||
var widget = base.on_create_model_widget(obj);
|
||||
var widget_status = widget as Widgets.Status;
|
||||
|
||||
widget_status.actions.visible = false;
|
||||
widget_status.sensitive = false;
|
||||
|
||||
return widget;
|
||||
}
|
||||
}
|
|
@ -81,6 +81,7 @@ public class Tooth.Widgets.Status : ListBoxRow {
|
|||
{"open-in-browser", open_in_browser}
|
||||
};
|
||||
private GLib.SimpleActionGroup action_group;
|
||||
private SimpleAction edit_history_simple_action;
|
||||
|
||||
public bool is_conversation_open { get; set; default = false; }
|
||||
|
||||
|
@ -149,8 +150,13 @@ public class Tooth.Widgets.Status : ListBoxRow {
|
|||
}
|
||||
});
|
||||
|
||||
edit_history_simple_action = new SimpleAction ("edit-history", null);
|
||||
edit_history_simple_action.activate.connect (view_edit_history);
|
||||
|
||||
action_group = new GLib.SimpleActionGroup ();
|
||||
action_group.add_action_entries (action_entries, this);
|
||||
action_group.add_action(edit_history_simple_action);
|
||||
|
||||
this.insert_action_group ("status", action_group);
|
||||
|
||||
create_context_menu();
|
||||
|
@ -187,6 +193,10 @@ public class Tooth.Widgets.Status : ListBoxRow {
|
|||
menu_model.append (_("Open in Browser"), "status.open-in-browser");
|
||||
menu_model.append (_("Copy URL"), "status.copy-url");
|
||||
|
||||
var edit_history_menu_item = new MenuItem(_("View Edit History"), "status.edit-history");
|
||||
edit_history_menu_item.set_attribute_value("hidden-when", "action-disabled");
|
||||
menu_model.append_item (edit_history_menu_item);
|
||||
|
||||
context_menu = new PopoverMenu.from_model(menu_model);
|
||||
context_menu.set_parent(this);
|
||||
}
|
||||
|
@ -199,6 +209,10 @@ public class Tooth.Widgets.Status : ListBoxRow {
|
|||
Host.open_uri (status.formal.url);
|
||||
}
|
||||
|
||||
private void view_edit_history () {
|
||||
app.main_window.open_view (new Views.EditHistory (status.formal.id));
|
||||
}
|
||||
|
||||
protected virtual void on_secondary_click () {
|
||||
gesture_click_controller.set_state(EventSequenceState.CLAIMED);
|
||||
gesture_lp_controller.set_state(EventSequenceState.CLAIMED);
|
||||
|
@ -288,7 +302,11 @@ public class Tooth.Widgets.Status : ListBoxRow {
|
|||
self_bindings.bind_property ("date", date_label, "label", BindingFlags.SYNC_CREATE);
|
||||
|
||||
formal_bindings.bind_property ("pinned", pin_indicator, "visible", BindingFlags.SYNC_CREATE);
|
||||
formal_bindings.bind_property ("is-edited", edited_indicator, "visible", BindingFlags.SYNC_CREATE);
|
||||
formal_bindings.bind_property ("is-edited", edited_indicator, "visible", BindingFlags.SYNC_CREATE, (b, src, ref target) => {
|
||||
edit_history_simple_action.set_enabled(src.get_boolean());
|
||||
target.set_boolean (src.get_boolean());
|
||||
return true;
|
||||
});
|
||||
formal_bindings.bind_property ("visibility", indicator, "icon_name", BindingFlags.SYNC_CREATE, (b, src, ref target) => {
|
||||
target.set_string (accounts.active.visibility[src.get_string ()].icon_name);
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue