1919
2020namespace Network.Widgets {
2121 public class DeviceItem : Gtk .ListBoxRow {
22+ public Switchboard . SettingsPage . StatusType status_type {
23+ set {
24+ switch (value ) {
25+ case ERROR :
26+ status_image. icon_name = " emblem-error" ;
27+ break ;
28+ case OFFLINE :
29+ status_image. icon_name = " emblem-disabled" ;
30+ break ;
31+ case SUCCESS :
32+ status_image. icon_name = " emblem-enabled" ;
33+ break ;
34+ case WARNING :
35+ status_image. icon_name = " emblem-warning" ;
36+ break ;
37+ case NONE :
38+ status_image. clear ();
39+ break ;
40+ }
41+ }
42+ }
43+
2244 public NM . Device ? device { get ; construct; default = null ; }
2345 public Widgets . Page ? page { get ; set ; default = null ; }
2446 public string title { get ; set ; default = " " ; }
@@ -28,13 +50,6 @@ namespace Network.Widgets {
2850
2951 private Gtk . Image status_image;
3052
31- public DeviceItem (string title , string icon_name ) {
32- Object (
33- title: title,
34- icon: new ThemedIcon (icon_name)
35- );
36- }
37-
3853 public DeviceItem.from_page (Widgets .Page page , string icon_name = "network -wired ") {
3954 Object (
4055 device: page. device,
@@ -45,11 +60,8 @@ namespace Network.Widgets {
4560
4661 page. bind_property (" title" , this , " title" , SYNC_CREATE );
4762 page. bind_property (" icon" , this , " icon" , SYNC_CREATE );
48-
49- switch_status (Utils . CustomMode . INVALID , page. state);
50- page. notify[" state" ]. connect (() = > {
51- switch_status (Utils . CustomMode . INVALID , page. state);
52- });
63+ page. bind_property (" status-type" , this , " status-type" , SYNC_CREATE );
64+ page. bind_property (" status" , this , " subtitle" , SYNC_CREATE );
5365 }
5466
5567 construct {
@@ -70,8 +82,9 @@ namespace Network.Widgets {
7082 halign = Gtk . Align . START ,
7183 valign = Gtk . Align . START
7284 };
85+ row_description. add_css_class (Granite . STYLE_CLASS_SMALL_LABEL );
7386
74- status_image = new Gtk .Image .from_icon_name ( " user-available " ) {
87+ status_image = new Gtk .Image ( ) {
7588 halign = Gtk . Align . END ,
7689 valign = Gtk . Align . END
7790 };
@@ -92,47 +105,5 @@ namespace Network.Widgets {
92105 bind_property (" subtitle" , row_description, " label" );
93106 bind_property (" icon" , row_image, " gicon" );
94107 }
95-
96- public void switch_status (Utils .CustomMode custom_mode , NM .DeviceState ? state = null ) {
97- if (state != null ) {
98- switch (state) {
99- case NM . DeviceState . ACTIVATED:
100- status_image. icon_name = " user-available" ;
101- break ;
102- case NM . DeviceState . DISCONNECTED:
103- status_image. icon_name = " user-offline" ;
104- break ;
105- case NM . DeviceState . FAILED:
106- status_image. icon_name = " user-busy" ;
107- break ;
108- default:
109- status_image. icon_name = " user-away" ;
110- break ;
111- }
112-
113- if (device is NM . DeviceWifi && state == NM . DeviceState . UNAVAILABLE ) {
114- subtitle = _(" Disabled" );
115- } else {
116- subtitle = Utils . state_to_string (state);
117- }
118- } else if (custom_mode != Utils . CustomMode . INVALID ) {
119- switch (custom_mode) {
120- case Utils . CustomMode . PROXY_NONE:
121- subtitle = _(" Disabled" );
122- status_image. icon_name = " user-offline" ;
123- break ;
124- case Utils . CustomMode . PROXY_MANUAL:
125- subtitle = _(" Enabled (manual mode)" );
126- status_image. icon_name = " user-available" ;
127- break ;
128- case Utils . CustomMode . PROXY_AUTO:
129- subtitle = _(" Enabled (auto mode)" );
130- status_image. icon_name = " user-available" ;
131- break ;
132- }
133- }
134-
135- subtitle = " <span font_size='small'>" + subtitle + " </span>" ;
136- }
137108 }
138109}
0 commit comments