Skip to content

Commit

Permalink
feat(ActionsRow): dedicated quote button when supported
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr committed Nov 22, 2024
1 parent 3ba391e commit 13d8fba
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-transparent-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-police-badge2-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-clock-alt-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-quotation-symbolic.svg</file>
<!-- <file preprocess="xml-stripblanks">icons/scalable/actions/tuba-language-symbolic.svg</file> -->

<file>gtk/help-overlay.ui</file>
Expand Down
2 changes: 2 additions & 0 deletions data/icons/scalable/actions/tuba-quotation-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions data/style-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
color: var(--red-2);
}

.ttl-status-action-quote:hover,
.ttl-status-action-quote.enabled {
color: var(--blue-1);
}

.ttl-status-action-quote:active {
color: var(--blue-2);
}

.ttl-post.direct:hover {
background-color: lighter(alpha(var(--warning-bg-color), .1));
}
Expand Down
9 changes: 9 additions & 0 deletions data/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ headerbar.flat.no-title .title {
color: var(--red-4);
}

.ttl-status-action-quote:hover,
.ttl-status-action-quote.enabled {
color: var(--blue-3);
}

.ttl-status-action-quote:active {
color: var(--blue-4);
}

.ttl-profile-stat-button {
padding: 8px 12px;
min-height: 32px;
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/Status.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@
}

if (prev_card != null) content_box.remove (prev_card);
if (settings.show_preview_cards && !status.formal.has_media && status.formal.card != null && status.formal.card.kind in ALLOWED_CARD_TYPES) {
if (settings.show_preview_cards && !status.formal.has_media && quoted_status_btn == null && status.formal.card != null && status.formal.card.kind in ALLOWED_CARD_TYPES) {
try {
prev_card = (Widgets.PreviewCard) status.formal.card.to_widget ();
prev_card.button.clicked.connect (open_card_url);
Expand Down
23 changes: 23 additions & 0 deletions src/Widgets/Status/ActionsRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class Tuba.Widgets.ActionsRow : Gtk.Box {
StatusActionButton reblog_button;
StatusActionButton favorite_button;
StatusActionButton bookmark_button;
StatusActionButton? quote_button = null;

public ActionsRow (API.Status t_status) {
Object (status: t_status);
Expand Down Expand Up @@ -38,6 +39,10 @@ public class Tuba.Widgets.ActionsRow : Gtk.Box {
bindings += this.status.bind_property ("favourites-count", favorite_button, "amount", GLib.BindingFlags.SYNC_CREATE);

bindings += this.status.bind_property ("bookmarked", bookmark_button, "active", GLib.BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);

if (quote_button != null) {
quote_button.visible = status.formal.can_be_quoted;
}
}

private void in_reply_to_id_notify_func () {
Expand Down Expand Up @@ -112,6 +117,18 @@ public class Tuba.Widgets.ActionsRow : Gtk.Box {
reblog_button.clicked.connect (on_boost_button_clicked);
this.append (reblog_button);

if (accounts.active.instance_info.supports_quote_posting) {
quote_button = new StatusActionButton.with_icon_name ("tuba-quotation-symbolic") {
css_classes = { "ttl-status-action-quote", "flat", "circular" },
halign = Gtk.Align.START,
hexpand = true,
tooltip_text = _("Quote"),
visible = false
};
quote_button.clicked.connect (on_quote_button_clicked);
this.append (quote_button);
}

favorite_button = new StatusActionButton.with_icon_name ("tuba-unstarred-symbolic") {
active_icon_name = "tuba-starred-symbolic",
css_classes = { "ttl-status-action-star", "flat", "circular" },
Expand Down Expand Up @@ -312,6 +329,12 @@ public class Tuba.Widgets.ActionsRow : Gtk.Box {
}
}

private void on_quote_button_clicked () {
new Dialogs.Compose (new API.Status.empty () {
visibility = settings.default_post_visibility
}, false, status.formal.id);
}

private void commit_boost (StatusActionButton status_btn, API.Status.ReblogVisibility? visibility = null) {
status_btn.active = !status_btn.active;

Expand Down

0 comments on commit 13d8fba

Please sign in to comment.