Browse Source

Add a warning icon to the capabilities dialog

If the short source capabilities shows a warning icon, surely the long
form dialog should show the same information.
Clara Hobbs 6 years ago
parent
commit
8ce53a8a8f
2 changed files with 35 additions and 5 deletions
  1. 32
    5
      data/src-cap-dialog.ui
  2. 3
    0
      pd-buddy-gtk.py

+ 32
- 5
data/src-cap-dialog.ui View File

90
                           </packing>
90
                           </packing>
91
                         </child>
91
                         </child>
92
                         <child>
92
                         <child>
93
-                          <object class="GtkLabel" id="power-label">
93
+                          <object class="GtkLabel" id="info-label">
94
                             <property name="visible">True</property>
94
                             <property name="visible">True</property>
95
                             <property name="can_focus">False</property>
95
                             <property name="can_focus">False</property>
96
                             <property name="halign">start</property>
96
                             <property name="halign">start</property>
99
                           </object>
99
                           </object>
100
                           <packing>
100
                           <packing>
101
                             <property name="left_attach">1</property>
101
                             <property name="left_attach">1</property>
102
-                            <property name="top_attach">0</property>
102
+                            <property name="top_attach">1</property>
103
                           </packing>
103
                           </packing>
104
                         </child>
104
                         </child>
105
                         <child>
105
                         <child>
106
-                          <object class="GtkLabel" id="info-label">
106
+                          <object class="GtkBox">
107
                             <property name="visible">True</property>
107
                             <property name="visible">True</property>
108
                             <property name="can_focus">False</property>
108
                             <property name="can_focus">False</property>
109
                             <property name="halign">start</property>
109
                             <property name="halign">start</property>
110
                             <property name="valign">start</property>
110
                             <property name="valign">start</property>
111
-                            <property name="label" translatable="yes">label</property>
111
+                            <property name="spacing">6</property>
112
+                            <child>
113
+                              <object class="GtkLabel" id="power-label">
114
+                                <property name="visible">True</property>
115
+                                <property name="can_focus">False</property>
116
+                                <property name="halign">start</property>
117
+                                <property name="valign">start</property>
118
+                                <property name="label" translatable="yes">label</property>
119
+                              </object>
120
+                              <packing>
121
+                                <property name="expand">False</property>
122
+                                <property name="fill">True</property>
123
+                                <property name="position">0</property>
124
+                              </packing>
125
+                            </child>
126
+                            <child>
127
+                              <object class="GtkImage" id="source-cap-warning">
128
+                                <property name="can_focus">False</property>
129
+                                <property name="tooltip_text" translatable="yes">Source violates the USB PD Power Rules</property>
130
+                                <property name="halign">start</property>
131
+                                <property name="icon_name">dialog-warning-symbolic</property>
132
+                              </object>
133
+                              <packing>
134
+                                <property name="expand">False</property>
135
+                                <property name="fill">True</property>
136
+                                <property name="position">1</property>
137
+                              </packing>
138
+                            </child>
112
                           </object>
139
                           </object>
113
                           <packing>
140
                           <packing>
114
                             <property name="left_attach">1</property>
141
                             <property name="left_attach">1</property>
115
-                            <property name="top_attach">1</property>
142
+                            <property name="top_attach">0</property>
116
                           </packing>
143
                           </packing>
117
                         </child>
144
                         </child>
118
                       </object>
145
                       </object>

+ 3
- 0
pd-buddy-gtk.py View File

443
         # Populate PD Power
443
         # Populate PD Power
444
         d_power = dialog_builder.get_object("power-label")
444
         d_power = dialog_builder.get_object("power-label")
445
         d_power.set_text("{:g} W".format(pdbuddy.calculate_pdp(caps)))
445
         d_power.set_text("{:g} W".format(pdbuddy.calculate_pdp(caps)))
446
+        # Warning icon
447
+        cap_warning = dialog_builder.get_object("source-cap-warning")
448
+        cap_warning.set_visible(not pdbuddy.follows_power_rules(caps))
446
 
449
 
447
         # Populate Information
450
         # Populate Information
448
         d_info_header = dialog_builder.get_object("info-header")
451
         d_info_header = dialog_builder.get_object("info-header")

Loading…
Cancel
Save