Fix encryption button update and reduce its required GTK version
MenuButton.activate only exists since 4.4
This commit is contained in:
parent
d6afa6e8ff
commit
054d3fec16
|
@ -3,7 +3,7 @@ using Gee;
|
||||||
namespace Dino.Plugins {
|
namespace Dino.Plugins {
|
||||||
|
|
||||||
public class Registry {
|
public class Registry {
|
||||||
internal ArrayList<EncryptionListEntry> encryption_list_entries = new ArrayList<EncryptionListEntry>();
|
internal HashMap<Entities.Encryption, EncryptionListEntry> encryption_list_entries = new HashMap<Entities.Encryption, EncryptionListEntry>();
|
||||||
internal HashMap<string, CallEncryptionEntry> call_encryption_entries = new HashMap<string, CallEncryptionEntry>();
|
internal HashMap<string, CallEncryptionEntry> call_encryption_entries = new HashMap<string, CallEncryptionEntry>();
|
||||||
internal ArrayList<AccountSettingsEntry> account_settings_entries = new ArrayList<AccountSettingsEntry>();
|
internal ArrayList<AccountSettingsEntry> account_settings_entries = new ArrayList<AccountSettingsEntry>();
|
||||||
internal ArrayList<ContactDetailsProvider> contact_details_entries = new ArrayList<ContactDetailsProvider>();
|
internal ArrayList<ContactDetailsProvider> contact_details_entries = new ArrayList<ContactDetailsProvider>();
|
||||||
|
@ -17,11 +17,9 @@ public class Registry {
|
||||||
|
|
||||||
public bool register_encryption_list_entry(EncryptionListEntry entry) {
|
public bool register_encryption_list_entry(EncryptionListEntry entry) {
|
||||||
lock(encryption_list_entries) {
|
lock(encryption_list_entries) {
|
||||||
foreach(var e in encryption_list_entries) {
|
if (encryption_list_entries.has_key(entry.encryption)) return false;
|
||||||
if (e.encryption == entry.encryption) return false;
|
|
||||||
}
|
encryption_list_entries[entry.encryption] = entry;
|
||||||
encryption_list_entries.add(entry);
|
|
||||||
encryption_list_entries.sort((a,b) => b.name.collate(a.name));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,7 +242,7 @@ box.dino-input-warning label {
|
||||||
|
|
||||||
/*Chat input error*/
|
/*Chat input error*/
|
||||||
|
|
||||||
box.dino-input-error frame border {
|
box.dino-input-error frame {
|
||||||
border-color: @error_color;
|
border-color: @error_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,19 +251,20 @@ box.dino-input-error frame separator {
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
box.dino-input-error label {
|
box.dino-input-error .chat-input-status {
|
||||||
color: @error_color;
|
color: @error_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes input-error-highlight {
|
@keyframes input-error-highlight {
|
||||||
0% { color: mix(@error_color, @theme_fg_color, 0.3);}
|
0% { transform: translate(0,0); }
|
||||||
30% { color: @error_color; text-shadow: 0px 0px 2px alpha(@error_color, 0.4); }
|
25% { transform: translate(-10px,0); }
|
||||||
100% { color: mix(@error_color, @theme_fg_color, 0.3); }
|
75% { transform: translate(10px,0); }
|
||||||
|
100% { transform: translate(0,0); }
|
||||||
}
|
}
|
||||||
|
|
||||||
box.dino-input-error label.input-status-highlight-once {
|
box.dino-input-error .chat-input-status.input-status-highlight-once {
|
||||||
animation-duration: 1s;
|
animation-duration: 0.5s;
|
||||||
animation-timing-function: linear;
|
animation-timing-function: ease-in-out;
|
||||||
animation-iteration-count: 1;
|
animation-iteration-count: 1;
|
||||||
animation-name: input-error-highlight;
|
animation-name: input-error-highlight;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,11 +77,13 @@ public class ChatInputController : Object {
|
||||||
chat_input.set_file_upload_active(active);
|
chat_input.set_file_upload_active(active);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_encryption_changed(Plugins.EncryptionListEntry? encryption_entry) {
|
private void on_encryption_changed(Encryption encryption) {
|
||||||
reset_input_field_status();
|
reset_input_field_status();
|
||||||
|
|
||||||
if (encryption_entry == null) return;
|
if (encryption == Encryption.NONE) return;
|
||||||
|
|
||||||
|
Application app = GLib.Application.get_default() as Application;
|
||||||
|
var encryption_entry = app.plugin_registry.encryption_list_entries[encryption];
|
||||||
encryption_entry.encryption_activated(conversation, set_input_field_status);
|
encryption_entry.encryption_activated(conversation, set_input_field_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,15 +7,15 @@ namespace Dino.Ui {
|
||||||
|
|
||||||
public class EncryptionButton {
|
public class EncryptionButton {
|
||||||
|
|
||||||
public signal void encryption_changed(Plugins.EncryptionListEntry? encryption_entry);
|
public signal void encryption_changed(Encryption encryption);
|
||||||
|
|
||||||
private MenuButton menu_button;
|
private MenuButton menu_button;
|
||||||
private Conversation? conversation;
|
private Conversation? conversation;
|
||||||
private CheckButton? button_unencrypted;
|
private CheckButton? button_unencrypted;
|
||||||
private Map<CheckButton, Plugins.EncryptionListEntry> encryption_radios = new HashMap<CheckButton, Plugins.EncryptionListEntry>();
|
|
||||||
private string? current_icon;
|
private string? current_icon;
|
||||||
private StreamInteractor stream_interactor;
|
private StreamInteractor stream_interactor;
|
||||||
private SimpleAction action;
|
private SimpleAction action;
|
||||||
|
ulong conversation_encryption_handler_id = -1;
|
||||||
|
|
||||||
public EncryptionButton(StreamInteractor stream_interactor, MenuButton menu_button) {
|
public EncryptionButton(StreamInteractor stream_interactor, MenuButton menu_button) {
|
||||||
this.stream_interactor = stream_interactor;
|
this.stream_interactor = stream_interactor;
|
||||||
|
@ -28,8 +28,11 @@ public class EncryptionButton {
|
||||||
unencrypted_item.set_action_and_target_value("enc.encryption", new Variant.int32(Encryption.NONE));
|
unencrypted_item.set_action_and_target_value("enc.encryption", new Variant.int32(Encryption.NONE));
|
||||||
menu_model.append_item(unencrypted_item);
|
menu_model.append_item(unencrypted_item);
|
||||||
|
|
||||||
|
var encryption_entries = new ArrayList<Plugins.EncryptionListEntry>();
|
||||||
Application app = GLib.Application.get_default() as Application;
|
Application app = GLib.Application.get_default() as Application;
|
||||||
foreach (var e in app.plugin_registry.encryption_list_entries) {
|
encryption_entries.add_all(app.plugin_registry.encryption_list_entries.values);
|
||||||
|
encryption_entries.sort((a,b) => b.name.collate(a.name));
|
||||||
|
foreach (var e in encryption_entries) {
|
||||||
MenuItem item = new MenuItem(e.name, "enc.encryption");
|
MenuItem item = new MenuItem(e.name, "enc.encryption");
|
||||||
item.set_action_and_target_value("enc.encryption", new Variant.int32(e.encryption));
|
item.set_action_and_target_value("enc.encryption", new Variant.int32(e.encryption));
|
||||||
menu_model.append_item(item);
|
menu_model.append_item(item);
|
||||||
|
@ -40,7 +43,8 @@ public class EncryptionButton {
|
||||||
action = new SimpleAction.stateful("encryption", VariantType.INT32, new Variant.int32(Encryption.NONE));
|
action = new SimpleAction.stateful("encryption", VariantType.INT32, new Variant.int32(Encryption.NONE));
|
||||||
action.activate.connect((parameter) => {
|
action.activate.connect((parameter) => {
|
||||||
action.set_state(parameter);
|
action.set_state(parameter);
|
||||||
this.conversation.encryption = (Encryption) parameter.get_int32();
|
conversation.encryption = (Encryption) parameter.get_int32();
|
||||||
|
encryption_changed(conversation.encryption);
|
||||||
});
|
});
|
||||||
action_group.insert(action);
|
action_group.insert(action);
|
||||||
menu_button.insert_action_group("enc", action_group);
|
menu_button.insert_action_group("enc", action_group);
|
||||||
|
@ -54,24 +58,6 @@ public class EncryptionButton {
|
||||||
update_visibility();
|
update_visibility();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
menu_button.activate.connect(update_encryption_menu_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void encryption_button_toggled() {
|
|
||||||
foreach (CheckButton e in encryption_radios.keys) {
|
|
||||||
if (e.get_active()) {
|
|
||||||
conversation.encryption = encryption_radios[e].encryption;
|
|
||||||
encryption_changed(encryption_radios[e]);
|
|
||||||
update_encryption_menu_icon();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Selected unencrypted
|
|
||||||
conversation.encryption = Encryption.NONE;
|
|
||||||
update_encryption_menu_icon();
|
|
||||||
encryption_changed(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update_encryption_menu_state() {
|
private void update_encryption_menu_state() {
|
||||||
|
@ -109,10 +95,20 @@ public class EncryptionButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set_conversation(Conversation conversation) {
|
public void set_conversation(Conversation conversation) {
|
||||||
|
if (conversation_encryption_handler_id != -1 && this.conversation != null) {
|
||||||
|
this.conversation.disconnect(conversation_encryption_handler_id);
|
||||||
|
}
|
||||||
|
|
||||||
this.conversation = conversation;
|
this.conversation = conversation;
|
||||||
update_encryption_menu_state();
|
update_encryption_menu_state();
|
||||||
update_encryption_menu_icon();
|
update_encryption_menu_icon();
|
||||||
update_visibility();
|
update_visibility();
|
||||||
|
encryption_changed(this.conversation.encryption);
|
||||||
|
|
||||||
|
conversation_encryption_handler_id = conversation.notify["encryption"].connect(() => {
|
||||||
|
update_encryption_menu_state();
|
||||||
|
update_encryption_menu_icon();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class View : Box {
|
||||||
|
|
||||||
public void highlight_state_description() {
|
public void highlight_state_description() {
|
||||||
chat_input_status.add_css_class("input-status-highlight-once");
|
chat_input_status.add_css_class("input-status-highlight-once");
|
||||||
Timeout.add_seconds(1, () => {
|
Timeout.add(500, () => {
|
||||||
chat_input_status.remove_css_class("input-status-highlight-once");
|
chat_input_status.remove_css_class("input-status-highlight-once");
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -132,19 +132,15 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface,
|
||||||
ContentMetaItem ci = item as ContentMetaItem;
|
ContentMetaItem ci = item as ContentMetaItem;
|
||||||
if (item.encryption != Encryption.NONE && item.encryption != Encryption.UNKNOWN && ci != null) {
|
if (item.encryption != Encryption.NONE && item.encryption != Encryption.UNKNOWN && ci != null) {
|
||||||
string? icon_name = null;
|
string? icon_name = null;
|
||||||
foreach(var e in app.plugin_registry.encryption_list_entries) {
|
var encryption_entry = app.plugin_registry.encryption_list_entries[item.encryption];
|
||||||
if (e.encryption == item.encryption) {
|
icon_name = encryption_entry.get_encryption_icon_name(conversation, ci.content_item);
|
||||||
icon_name = e.get_encryption_icon_name(conversation, ci.content_item);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
encryption_image.icon_name = icon_name ?? "changes-prevent-symbolic";
|
encryption_image.icon_name = icon_name ?? "changes-prevent-symbolic";
|
||||||
encryption_image.visible = true;
|
encryption_image.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.encryption == Encryption.NONE) {
|
if (item.encryption == Encryption.NONE) {
|
||||||
if (conversation.encryption != Encryption.NONE) {
|
if (conversation.encryption != Encryption.NONE) {
|
||||||
encryption_image.icon_name = "dino-changes-allowed-symbolic";
|
encryption_image.icon_name = "changes-allow-symbolic";
|
||||||
encryption_image.tooltip_text = Util.string_if_tooltips_active(_("Unencrypted"));
|
encryption_image.tooltip_text = Util.string_if_tooltips_active(_("Unencrypted"));
|
||||||
Util.force_error_color(encryption_image);
|
Util.force_error_color(encryption_image);
|
||||||
encryption_image.visible = true;
|
encryption_image.visible = true;
|
||||||
|
|
Loading…
Reference in a new issue