From cba807893069bf680adb74dfb66b637a9c868fdf Mon Sep 17 00:00:00 2001 From: Evangelos Paterakis Date: Sun, 19 Feb 2023 17:57:55 +0200 Subject: [PATCH] feat(AttachmentsPage): mark media as sensitive --- data/gresource.xml | 2 ++ .../tooth-eye-not-looking-symbolic.svg | 2 ++ ...ooth-eye-open-negative-filled-symbolic.svg | 2 ++ src/Dialogs/Composer/AttachmentsPage.vala | 25 +++++++++++++++++-- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 data/icons/scalable/actions/tooth-eye-not-looking-symbolic.svg create mode 100644 data/icons/scalable/actions/tooth-eye-open-negative-filled-symbolic.svg diff --git a/data/gresource.xml b/data/gresource.xml index 1903a60..3fee5a3 100644 --- a/data/gresource.xml +++ b/data/gresource.xml @@ -48,6 +48,8 @@ icons/scalable/actions/tooth-minus-large-symbolic.svg icons/scalable/actions/tooth-cross-large-symbolic.svg icons/scalable/actions/tooth-address-book-new-symbolic.svg + icons/scalable/actions/tooth-eye-open-negative-filled-symbolic.svg + icons/scalable/actions/tooth-eye-not-looking-symbolic.svg gtk/dropdown/icon.ui gtk/dropdown/full.ui diff --git a/data/icons/scalable/actions/tooth-eye-not-looking-symbolic.svg b/data/icons/scalable/actions/tooth-eye-not-looking-symbolic.svg new file mode 100644 index 0000000..3dfa654 --- /dev/null +++ b/data/icons/scalable/actions/tooth-eye-not-looking-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/data/icons/scalable/actions/tooth-eye-open-negative-filled-symbolic.svg b/data/icons/scalable/actions/tooth-eye-open-negative-filled-symbolic.svg new file mode 100644 index 0000000..e904ea3 --- /dev/null +++ b/data/icons/scalable/actions/tooth-eye-open-negative-filled-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/src/Dialogs/Composer/AttachmentsPage.vala b/src/Dialogs/Composer/AttachmentsPage.vala index 1d5e306..7a436f1 100644 --- a/src/Dialogs/Composer/AttachmentsPage.vala +++ b/src/Dialogs/Composer/AttachmentsPage.vala @@ -32,6 +32,7 @@ public class Tooth.AttachmentsPage : ComposerPage { public GLib.ListStore attachments; public Adw.ToastOverlay toast_overlay; public bool can_publish { get; set; default = false; } + public bool media_sensitive { get; set; default = false; } public AttachmentsPage () { Object ( @@ -75,12 +76,28 @@ public class Tooth.AttachmentsPage : ComposerPage { icon_name = "tooth-plus-large-symbolic", valign = Gtk.Align.CENTER, halign = Gtk.Align.CENTER, - tooltip_text = _("Add Media") + tooltip_text = _("Add Media"), + css_classes = {"flat"} }; - add_media_action_button.add_css_class ("flat"); add_media_action_button.clicked.connect(show_file_selector); + var sensitive_media_button = new Gtk.ToggleButton() { + icon_name = "tooth-eye-open-negative-filled-symbolic", + valign = Gtk.Align.CENTER, + halign = Gtk.Align.CENTER, + tooltip_text = _("Mark media as sensitive"), + css_classes = {"flat"} + }; + sensitive_media_button.bind_property ("active", this, "media_sensitive", GLib.BindingFlags.SYNC_CREATE, (b, src, ref target) => { + var sensitive_media_button_active = src.get_boolean (); + target.set_boolean (sensitive_media_button_active); + sensitive_media_button.icon_name = sensitive_media_button_active ? "tooth-eye-not-looking-symbolic" : "tooth-eye-open-negative-filled-symbolic"; + sensitive_media_button.tooltip_text = sensitive_media_button_active ? _("Unmark media as sensitive") : _("Mark media as sensitive"); + return true; + }); + bottom_bar.pack_start (add_media_action_button); + bottom_bar.pack_start (sensitive_media_button); // State stack stack = new Adw.ViewStack (); @@ -215,6 +232,10 @@ public class Tooth.AttachmentsPage : ComposerPage { var attachment = attachments.get_item (i) as API.Attachment; req.with_form_data ("media_ids[]", attachment.id); } + + if (media_sensitive) { + req.with_form_data ("sensitive", "true"); + } } } }