mirror of
https://github.com/TakeV-Lambda/dino.git
synced 2024-10-31 21:20:23 +00:00
"Default" per-contact settings (change UI)
This commit is contained in:
parent
5fcf8e73ef
commit
a8ba4a3974
4 changed files with 55 additions and 34 deletions
|
@ -91,15 +91,17 @@ public class Conversation : Object {
|
|||
}
|
||||
|
||||
public NotifySetting get_notification_setting(StreamInteractor stream_interactor) {
|
||||
return notify_setting != NotifySetting.DEFAULT ? notify_setting : get_notification_default_setting(stream_interactor);
|
||||
}
|
||||
|
||||
public NotifySetting get_notification_default_setting(StreamInteractor stream_interactor) {
|
||||
Xmpp.Core.XmppStream? stream = stream_interactor.get_stream(account);
|
||||
if (notify_setting != NotifySetting.DEFAULT) return notify_setting;
|
||||
if (!Application.get_default().settings.notifications) return NotifySetting.OFF;
|
||||
if (type_ == Type.GROUPCHAT) {
|
||||
bool members_only = stream.get_flag(Xmpp.Xep.Muc.Flag.IDENTITY).has_room_feature(counterpart.bare_jid.to_string(), Xmpp.Xep.Muc.Feature.MEMBERS_ONLY);
|
||||
return members_only ? NotifySetting.ON : NotifySetting.HIGHLIGHT;
|
||||
} else {
|
||||
return NotifySetting.ON;
|
||||
}
|
||||
return NotifySetting.ON;
|
||||
}
|
||||
|
||||
public Setting get_send_typing_setting() {
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
<child>
|
||||
<object class="GtkLabel" id="jid_label">
|
||||
<property name="xalign">0</property>
|
||||
<property name="selectable">True</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
|
|
|
@ -16,38 +16,33 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
|
|||
public void populate(Conversation conversation, Plugins.ContactDetails contact_details, Plugins.WidgetType type) {
|
||||
if (type != Plugins.WidgetType.GTK) return;
|
||||
if (conversation.type_ == Conversation.Type.CHAT) {
|
||||
ComboBoxText[] comboboxes = new ComboBoxText[2];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
comboboxes[i] = new ComboBoxText() { visible=true };
|
||||
comboboxes[i].append("default", _("Default"));
|
||||
comboboxes[i].append("on", _("On"));
|
||||
comboboxes[i].append("off", _("Off"));
|
||||
}
|
||||
ComboBoxText combobox_typing = get_combobox(Dino.Application.get_default().settings.send_typing);
|
||||
combobox_typing.active_id = get_setting_id(conversation.send_typing);
|
||||
combobox_typing.changed.connect(() => { conversation.send_typing = get_setting(combobox_typing.active_id); } );
|
||||
contact_details.add(_("Settings"), _("Send typing notifications"), "", combobox_typing);
|
||||
|
||||
contact_details.add(_("Settings"), _("Send typing notifications"), "", comboboxes[0]);
|
||||
comboboxes[0].active_id = get_setting_id(conversation.get_send_typing_setting());
|
||||
comboboxes[0].changed.connect(() => { print("changed!\n"); conversation.send_typing = get_setting(comboboxes[0].active_id); } );
|
||||
ComboBoxText combobox_marker = get_combobox(Dino.Application.get_default().settings.send_marker);
|
||||
contact_details.add(_("Settings"), _("Send message marker"), "", combobox_marker);
|
||||
combobox_marker.active_id = get_setting_id(conversation.send_marker);
|
||||
combobox_marker.changed.connect(() => { conversation.send_marker = get_setting(combobox_marker.active_id); } );
|
||||
|
||||
contact_details.add(_("Settings"), _("Send message marker"), "", comboboxes[1]);
|
||||
comboboxes[1].active_id = get_setting_id(conversation.get_send_marker_setting());
|
||||
comboboxes[1].changed.connect(() => { conversation.send_marker = get_setting(comboboxes[1].active_id); } );
|
||||
|
||||
contact_details.add(_("Settings"), _("Notifications"), "", comboboxes[2]);
|
||||
comboboxes[2].active_id = get_notify_setting_id(conversation.get_notification_setting(stream_interactor));
|
||||
comboboxes[2].changed.connect(() => { conversation.notify_setting = get_notify_setting(comboboxes[2].active_id); } );
|
||||
ComboBoxText combobox_notifications = get_combobox(Dino.Application.get_default().settings.notifications);
|
||||
contact_details.add(_("Settings"), _("Notifications"), "", combobox_notifications);
|
||||
combobox_notifications.active_id = get_notify_setting_id(conversation.notify_setting);
|
||||
combobox_notifications.changed.connect(() => { conversation.notify_setting = get_notify_setting(combobox_notifications.active_id); } );
|
||||
} else if (conversation.type_ == Conversation.Type.GROUPCHAT) {
|
||||
ComboBoxText combobox = new ComboBoxText() { visible=true };
|
||||
combobox.append("default", _("Default"));
|
||||
combobox.append("highlight", _("Only when mentioned"));
|
||||
combobox.append("on", _("On"));
|
||||
combobox.append("off", _("Off"));
|
||||
combobox.append("default", get_notify_setting_string(Conversation.NotifySetting.DEFAULT, conversation.get_notification_default_setting(stream_interactor)));
|
||||
combobox.append("highlight", get_notify_setting_string(Conversation.NotifySetting.HIGHLIGHT));
|
||||
combobox.append("on", get_notify_setting_string(Conversation.NotifySetting.ON));
|
||||
combobox.append("off", get_notify_setting_string(Conversation.NotifySetting.OFF));
|
||||
contact_details.add(_("Local Settings"), _("Notifications"), "", combobox);
|
||||
combobox.active_id = get_notify_setting_id(conversation.get_notification_setting(stream_interactor));
|
||||
combobox.active_id = get_notify_setting_id(conversation.notify_setting);
|
||||
combobox.changed.connect(() => { conversation.notify_setting = get_notify_setting(combobox.active_id); } );
|
||||
}
|
||||
}
|
||||
|
||||
public Conversation.Setting get_setting(string id) {
|
||||
private Conversation.Setting get_setting(string id) {
|
||||
switch (id) {
|
||||
case "default":
|
||||
return Conversation.Setting.DEFAULT;
|
||||
|
@ -59,7 +54,7 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
|
|||
assert_not_reached();
|
||||
}
|
||||
|
||||
public Conversation.NotifySetting get_notify_setting(string id) {
|
||||
private Conversation.NotifySetting get_notify_setting(string id) {
|
||||
switch (id) {
|
||||
case "default":
|
||||
return Conversation.NotifySetting.DEFAULT;
|
||||
|
@ -73,7 +68,21 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
|
|||
assert_not_reached();
|
||||
}
|
||||
|
||||
public string get_setting_id(Conversation.Setting setting) {
|
||||
private string get_notify_setting_string(Conversation.NotifySetting setting, Conversation.NotifySetting? default_setting = null) {
|
||||
switch (setting) {
|
||||
case Conversation.NotifySetting.ON:
|
||||
return _("On");
|
||||
case Conversation.NotifySetting.OFF:
|
||||
return _("Off");
|
||||
case Conversation.NotifySetting.HIGHLIGHT:
|
||||
return _("Only when mentioned");
|
||||
case Conversation.NotifySetting.DEFAULT:
|
||||
return _("Default: %s").printf(get_notify_setting_string(default_setting));
|
||||
}
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
private string get_setting_id(Conversation.Setting setting) {
|
||||
switch (setting) {
|
||||
case Conversation.Setting.DEFAULT:
|
||||
return "default";
|
||||
|
@ -85,7 +94,7 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
|
|||
assert_not_reached();
|
||||
}
|
||||
|
||||
public string get_notify_setting_id(Conversation.NotifySetting setting) {
|
||||
private string get_notify_setting_id(Conversation.NotifySetting setting) {
|
||||
switch (setting) {
|
||||
case Conversation.NotifySetting.DEFAULT:
|
||||
return "default";
|
||||
|
@ -98,6 +107,16 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
|
|||
}
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
private ComboBoxText get_combobox(bool default_val) {
|
||||
ComboBoxText combobox = new ComboBoxText();
|
||||
combobox = new ComboBoxText() { visible=true };
|
||||
string default_setting = default_val ? _("On") : _("Off");
|
||||
combobox.append("default", _("Default: %s").printf(default_setting) );
|
||||
combobox.append("on", _("On"));
|
||||
combobox.append("off", _("Off"));
|
||||
return combobox;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,15 +17,14 @@ public class ContactDetailsProvider : Plugins.ContactDetailsProvider, Object {
|
|||
if (conversation.type_ == Conversation.Type.CHAT && type == WidgetType.GTK) {
|
||||
string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart);
|
||||
if (key_id != null) {
|
||||
Label label = new Label("") { use_markup=true, justify=Justification.RIGHT, selectable=true, visible=true };
|
||||
Gee.List<GPG.Key> keys = GPGHelper.get_keylist(key_id);
|
||||
if (keys.size > 0) {
|
||||
Label label = new Label(markup_colorize_id(keys[0].fpr, true)) { use_markup=true, justify=Justification.RIGHT, visible=true };
|
||||
contact_details.add(_("Encryption"), _("OpenPGP"), "", label);
|
||||
label.label = markup_colorize_id(keys[0].fpr, true);
|
||||
} else {
|
||||
string s = _("Key not in keychain") + "\n" + markup_colorize_id(key_id, false);
|
||||
Label label = new Label(s) { use_markup=true, justify=Justification.RIGHT, visible=true };
|
||||
contact_details.add(_("Encryption"), _("OpenPGP"), "", label);
|
||||
label.label = _("Key not in keychain") + "\n" + markup_colorize_id(key_id, false);
|
||||
}
|
||||
contact_details.add(_("Encryption"), _("OpenPGP"), "", label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue