diff --git a/libdino/src/entity/encryption.vala b/libdino/src/entity/encryption.vala
index 6868def49..b820afec0 100644
--- a/libdino/src/entity/encryption.vala
+++ b/libdino/src/entity/encryption.vala
@@ -34,4 +34,46 @@ namespace Dino.Entities {
}
}
+ public enum InterfaceScale {
+ NONE,
+ SMALL,
+ MEDIUM,
+ LARGE,
+ EXTRA_LARGE;
+
+ public bool is_some() {
+ return this != NONE;
+ }
+
+ public static InterfaceScale parse(string str) {
+ switch (str) {
+ case "DINO_ENTITIES_INTERFACE_SCALE_SMALL":
+ return SMALL;
+ case "DINO_ENTITIES_INTERFACE_SCALE_MEDIUM":
+ return MEDIUM;
+ case "DINO_ENTITIES_INTERFACE_SCALE_LARGE":
+ return LARGE;
+ case "DINO_ENTITIES_INTERFACE_SCALE_EXTRA_LARGE":
+ return EXTRA_LARGE;
+ default:
+ return NONE;
+ }
+ }
+
+ public static double to_double(InterfaceScale val) {
+ switch (val) {
+ case InterfaceScale.SMALL:
+ return 0.75;
+ case InterfaceScale.MEDIUM:
+ return 1;
+ case InterfaceScale.LARGE:
+ return 1.5;
+ case InterfaceScale.EXTRA_LARGE:
+ return 2;
+ default:
+ return 1;
+ }
+ }
+ }
+
}
\ No newline at end of file
diff --git a/libdino/src/entity/settings.vala b/libdino/src/entity/settings.vala
index 9b1efa3a7..cd68df9d4 100644
--- a/libdino/src/entity/settings.vala
+++ b/libdino/src/entity/settings.vala
@@ -13,11 +13,14 @@ public class Settings : Object {
convert_utf8_smileys_ = col_to_bool_or_default("convert_utf8_smileys", true);
check_spelling = col_to_bool_or_default("check_spelling", true);
default_encryption = col_to_encryption_or_default("default_encryption", Encryption.UNKNOWN);
+ interface_scale = col_to_interface_scale_or_default("interface_scale", InterfaceScale.MEDIUM);
send_button = col_to_bool_or_default("send_button", false);
enter_newline = col_to_bool_or_default("enter_newline", false);
dark_theme = col_to_bool_or_default("dark_theme", false);
}
+ public signal void update_interface_scale();
+
private bool col_to_bool_or_default(string key, bool def) {
string? val = db.settings.select({db.settings.value}).with(db.settings.key, "=", key)[db.settings.value];
return val != null ? bool.parse(val) : def;
@@ -29,6 +32,12 @@ public class Settings : Object {
return val != null ? Encryption.parse(val) : def;
}
+ private InterfaceScale col_to_interface_scale_or_default(string key, InterfaceScale def) {
+ var sval = db.settings.value;
+ string? val = db.settings.select({sval}).with(db.settings.key, "=", key)[sval];
+ return val != null ? InterfaceScale.parse(val) : def;
+ }
+
private bool send_typing_;
public bool send_typing {
get { return send_typing_; }
@@ -103,6 +112,20 @@ public class Settings : Object {
}
}
+ private InterfaceScale interface_scale_;
+ public InterfaceScale interface_scale {
+ get { return interface_scale_; }
+ set {
+ string valstr = value.to_string();
+ db.settings.upsert()
+ .value(db.settings.key, "interface_scale", true)
+ .value(db.settings.value, valstr)
+ .perform();
+ interface_scale_ = value;
+ update_interface_scale();
+ }
+ }
+
public signal void send_button_update(bool visible);
private bool send_button_;
diff --git a/main/data/conversation_item_widget.ui b/main/data/conversation_item_widget.ui
index 3216232da..7fc0134c4 100644
--- a/main/data/conversation_item_widget.ui
+++ b/main/data/conversation_item_widget.ui
@@ -6,7 +6,7 @@
2
@@ -76,7 +76,7 @@
end
0
-
+
@@ -91,7 +91,7 @@
False
0.5
-
+
diff --git a/main/data/settings_dialog.ui b/main/data/settings_dialog.ui
index 5fafe36d2..3b8c88365 100644
--- a/main/data/settings_dialog.ui
+++ b/main/data/settings_dialog.ui
@@ -151,6 +151,49 @@
diff --git a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala
index 5d86f6c77..dc1e501bb 100644
--- a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala
+++ b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala
@@ -61,6 +61,12 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface,
set_widget(widget, Plugins.WidgetType.GTK4, 2);
}
+ Dino.Entities.Settings settings = Dino.Application.get_default().settings;
+ settings.update_interface_scale.connect(() => {
+ update_name_label();
+ update_time();
+ });
+
if (item.requires_header) {
// TODO: For MUC messags, use real jid from message if known
avatar_picture.model = new ViewModel.CompatAvatarPictureModel(stream_interactor).add_participant(conversation, item.jid);
@@ -174,7 +180,12 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface,
}
private void update_time() {
+ Dino.Entities.Settings settings = Dino.Application.get_default().settings;
+ Pango.AttrList attr_list = new Pango.AttrList();
+ attr_list.insert(Pango.attr_scale_new(InterfaceScale.to_double(settings.interface_scale)));
+
time_label.label = get_relative_time(item.time.to_local()).to_string();
+ time_label.set_attributes(attr_list);
time_update_timeout = Timeout.add_seconds((int) get_next_time_change(item.time), () => {
if (this.main_grid.parent == null) return false;
@@ -184,7 +195,11 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface,
}
private void update_name_label() {
+ Dino.Entities.Settings settings = Dino.Application.get_default().settings;
+ Pango.AttrList attr_list = new Pango.AttrList();
+ attr_list.insert(Pango.attr_scale_new(InterfaceScale.to_double(settings.interface_scale)));
name_label.label = Util.get_participant_display_name(stream_interactor, conversation, item.jid, true);
+ name_label.set_attributes(attr_list);
}
private void update_received_mark() {
diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala
index c180b6b3a..15fb68d40 100644
--- a/main/src/ui/conversation_selector/conversation_selector_row.vala
+++ b/main/src/ui/conversation_selector/conversation_selector_row.vala
@@ -39,6 +39,11 @@ public class ConversationSelectorRow : ListBoxRow {
this.conversation = conversation;
this.stream_interactor = stream_interactor;
+ Dino.Entities.Settings settings = Dino.Application.get_default().settings;
+ settings.update_interface_scale.connect(() => {
+ content_item_received();
+ });
+
switch (conversation.type_) {
case Conversation.Type.CHAT:
stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect((account, jid, roster_item) => {
@@ -103,6 +108,13 @@ public class ConversationSelectorRow : ListBoxRow {
content_item_received();
}
+ // public AttrList get_scale_attr() {
+ // Dino.Entities.Settings settings = Dino.Application.get_default().settings;
+ // Pango.AttrList attr_list = new Pango.AttrList();
+ // attr_list.insert(Pango.attr_scale_new(InterfaceScale.to_double(settings.interface_scale)));
+ // return attr_list;
+ // }
+
public void update() {
update_time_label();
}
@@ -129,6 +141,10 @@ public class ConversationSelectorRow : ListBoxRow {
protected void update_name_label() {
name_label.label = Util.get_conversation_display_name(stream_interactor, conversation);
+ Dino.Entities.Settings settings = Dino.Application.get_default().settings;
+ Pango.AttrList attr_list = new Pango.AttrList();
+ attr_list.insert(Pango.attr_scale_new(InterfaceScale.to_double(settings.interface_scale)));
+ name_label.set_attributes(attr_list);
}
private void update_pinned_icon() {
@@ -139,6 +155,10 @@ public class ConversationSelectorRow : ListBoxRow {
if (last_content_item != null) {
time_label.visible = true;
time_label.label = get_relative_time(last_content_item.time.to_local());
+ Dino.Entities.Settings settings = Dino.Application.get_default().settings;
+ Pango.AttrList attr_list = new Pango.AttrList();
+ attr_list.insert(Pango.attr_scale_new(InterfaceScale.to_double(settings.interface_scale)));
+ time_label.set_attributes(attr_list);
}
}
@@ -207,8 +227,13 @@ public class ConversationSelectorRow : ListBoxRow {
message_label.label = call.direction == Call.DIRECTION_OUTGOING ? _("Outgoing call") : _("Incoming call");
break;
}
+ Dino.Entities.Settings settings = Dino.Application.get_default().settings;
+ Pango.AttrList attr_list = new Pango.AttrList();
+ attr_list.insert(Pango.attr_scale_new(InterfaceScale.to_double(settings.interface_scale)));
nick_label.visible = true;
+ nick_label.set_attributes(attr_list);
message_label.visible = true;
+ message_label.set_attributes(attr_list);
}
}
@@ -247,6 +272,7 @@ public class ConversationSelectorRow : ListBoxRow {
} else {
unread_count_label.label = num_unread.to_string();
unread_count_label.visible = true;
+ // unread_count_label.set_attributes(get_scale_attr());
if (conversation.get_notification_setting(stream_interactor) == Conversation.NotifySetting.ON) {
unread_count_label.add_css_class("unread-count-notify");
diff --git a/main/src/ui/settings_dialog.vala b/main/src/ui/settings_dialog.vala
index 8c20a84bc..a81b1369a 100644
--- a/main/src/ui/settings_dialog.vala
+++ b/main/src/ui/settings_dialog.vala
@@ -16,6 +16,10 @@ class SettingsDialog : Adw.PreferencesWindow {
[GtkChild] private unowned Switch send_button_switch;
[GtkChild] private unowned Switch enter_newline_switch;
[GtkChild] private unowned Switch dark_theme;
+ [GtkChild] private unowned CheckButton scale_small;
+ [GtkChild] private unowned CheckButton scale_medium;
+ [GtkChild] private unowned CheckButton scale_large;
+ [GtkChild] private unowned CheckButton scale_xlarge;
Dino.Entities.Settings settings = Dino.Application.get_default().settings;
@@ -30,6 +34,11 @@ class SettingsDialog : Adw.PreferencesWindow {
encryption_radio_omemo.active = settings.default_encryption == Encryption.OMEMO;
encryption_radio_openpgp.active = settings.default_encryption == Encryption.PGP;
+ scale_small.active = settings.interface_scale == InterfaceScale.SMALL;
+ scale_medium.active = settings.interface_scale == InterfaceScale.MEDIUM;
+ scale_large.active = settings.interface_scale == InterfaceScale.LARGE;
+ scale_xlarge.active = settings.interface_scale == InterfaceScale.EXTRA_LARGE;
+
send_button_switch.active = settings.send_button;
enter_newline_switch.active = settings.enter_newline;
enter_newline_switch.sensitive = settings.send_button;
@@ -59,6 +68,30 @@ class SettingsDialog : Adw.PreferencesWindow {
}
});
+ scale_small.notify["active"].connect(() => {
+ if (scale_small.active) {
+ settings.interface_scale = InterfaceScale.SMALL;
+ }
+ });
+
+ scale_medium.notify["active"].connect(() => {
+ if (scale_medium.active) {
+ settings.interface_scale = InterfaceScale.MEDIUM;
+ }
+ });
+
+ scale_large.notify["active"].connect(() => {
+ if (scale_large.active) {
+ settings.interface_scale = InterfaceScale.LARGE;
+ }
+ });
+
+ scale_xlarge.notify["active"].connect(() => {
+ if (scale_xlarge.active) {
+ settings.interface_scale = InterfaceScale.EXTRA_LARGE;
+ }
+ });
+
send_button_switch.notify["active"].connect(() => { settings.send_button = send_button_switch.active; });
enter_newline_switch.notify["active"].connect(() => { settings.enter_newline = enter_newline_switch.active; });
settings.send_button_update.connect((visible) => {