UI: Make schema labels pretty, keep it same size
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
059111f020
commit
3c21ea52c0
6 changed files with 36 additions and 9 deletions
|
@ -27,7 +27,11 @@ class Singularity.Ui.OutboundRow : Gtk.Box {
|
|||
construct {
|
||||
}
|
||||
public void set_outbound(Outbound.Outbound outbound) {
|
||||
schema.label = outbound.type_name;
|
||||
schema.label = outbound.pretty_schema();
|
||||
descr.label = outbound.name;
|
||||
}
|
||||
|
||||
public void add_to_sizegroup(Gtk.SizeGroup group) {
|
||||
group.add_widget(schema);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,17 +39,14 @@ public class Singularity.Window : Adw.ApplicationWindow {
|
|||
}
|
||||
}
|
||||
|
||||
public Window(Gtk.Application app) {
|
||||
Object(application: app);
|
||||
|
||||
SingBox.instance.notify["singbox-status"].connect(() => on_singbox_status_change());
|
||||
SingBox.instance.singbox_message.connect((message) => singbox_log.text += "\n" + message);
|
||||
on_singbox_status_change();
|
||||
|
||||
private void setup_outbound_list() {
|
||||
var sg = new Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL); // Keep schema labels same size
|
||||
var factory = new Gtk.SignalListItemFactory();
|
||||
factory.setup.connect((obj) => {
|
||||
var item = (Gtk.ListItem) obj;
|
||||
item.set_child(new Ui.OutboundRow());
|
||||
var row = new Ui.OutboundRow();
|
||||
row.add_to_sizegroup(sg);
|
||||
item.set_child(row);
|
||||
});
|
||||
factory.bind.connect((obj) => {
|
||||
var item = (Gtk.ListItem) obj;
|
||||
|
@ -59,6 +56,16 @@ public class Singularity.Window : Adw.ApplicationWindow {
|
|||
});
|
||||
outbounds.set_model(SingBox.instance.outbound_selection);
|
||||
outbounds.set_factory(factory);
|
||||
}
|
||||
|
||||
public Window(Gtk.Application app) {
|
||||
Object(application: app);
|
||||
|
||||
SingBox.instance.notify["singbox-status"].connect(() => on_singbox_status_change());
|
||||
SingBox.instance.singbox_message.connect((message) => singbox_log.text += "\n" + message);
|
||||
on_singbox_status_change();
|
||||
|
||||
setup_outbound_list();
|
||||
|
||||
close_request.connect(() => {
|
||||
SingBox.instance.singbox.force_exit();
|
||||
|
|
|
@ -24,6 +24,10 @@ class Singularity.Outbound.Outbound : Object, Json.Serializable {
|
|||
public string tag { get; set; default = "proxy"; }
|
||||
public string name; // Not a property
|
||||
|
||||
public virtual string pretty_schema () {
|
||||
return "FIXME";
|
||||
}
|
||||
|
||||
public static Outbound parse_uri (string profile) throws UriError, ParseError {
|
||||
Uri uri = null;
|
||||
uri = Uri.parse (profile, UriFlags.HAS_PASSWORD | UriFlags.NON_DNS | UriFlags.PARSE_RELAXED);
|
||||
|
|
|
@ -40,4 +40,8 @@ class Singularity.Outbound.ShadowSocks : Dial, Json.Serializable {
|
|||
construct {
|
||||
type_name = "shadowsocks";
|
||||
}
|
||||
|
||||
public override string pretty_schema() {
|
||||
return "SSocks";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,4 +50,8 @@ class Singularity.Outbound.Trojan : Dial, Json.Serializable {
|
|||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
public override string pretty_schema () {
|
||||
return "Trojan";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,4 +51,8 @@ class Singularity.Outbound.Vless : Dial, Json.Serializable {
|
|||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
public override string pretty_schema () {
|
||||
return "Vless";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue