Browse Source

Control the Source Capabilities row's sensitivity

If there are no capabilities to show, it doesn't make sense to let the
user try to open the Source Capabilities dialog.  Now we don't, and we
say "None" instead of "0 W".
Clara Hobbs 7 years ago
parent
commit
066f0c068d
2 changed files with 11 additions and 2 deletions
  1. 1
    1
      data/pd-buddy-gtk.ui
  2. 10
    1
      pd-buddy-gtk.py

+ 1
- 1
data/pd-buddy-gtk.ui View File

473
                                               </packing>
473
                                               </packing>
474
                                             </child>
474
                                             </child>
475
                                             <child>
475
                                             <child>
476
-                                              <object class="GtkImage">
476
+                                              <object class="GtkImage" id="source-cap-arrow">
477
                                                 <property name="visible">True</property>
477
                                                 <property name="visible">True</property>
478
                                                 <property name="can_focus">False</property>
478
                                                 <property name="can_focus">False</property>
479
                                                 <property name="icon_name">go-next-symbolic</property>
479
                                                 <property name="icon_name">go-next-symbolic</property>

+ 10
- 1
pd-buddy-gtk.py View File

271
         giveback = self.builder.get_object("giveback-toggle")
271
         giveback = self.builder.get_object("giveback-toggle")
272
         pd_frame = self.builder.get_object("power-delivery-frame")
272
         pd_frame = self.builder.get_object("power-delivery-frame")
273
         output = self.builder.get_object("output-switch")
273
         output = self.builder.get_object("output-switch")
274
+        cap_row = self.builder.get_object("source-cap-row")
274
         cap_warning = self.builder.get_object("source-cap-warning")
275
         cap_warning = self.builder.get_object("source-cap-warning")
275
         cap_label = self.builder.get_object("short-source-cap-label")
276
         cap_label = self.builder.get_object("short-source-cap-label")
277
+        cap_arrow = self.builder.get_object("source-cap-arrow")
276
 
278
 
277
         self.serial_port = serport
279
         self.serial_port = serport
278
 
280
 
331
             cap_warning.set_visible(not pdbuddy.follows_power_rules(caps))
333
             cap_warning.set_visible(not pdbuddy.follows_power_rules(caps))
332
 
334
 
333
             # Update the text in the capability label
335
             # Update the text in the capability label
334
-            cap_label.set_text('{:g} W'.format(pdbuddy.calculate_pdp(caps)))
336
+            if caps:
337
+                cap_label.set_text('{:g} W'.format(pdbuddy.calculate_pdp(caps)))
338
+            else:
339
+                cap_label.set_text('None')
340
+
341
+            # Make the row insensitive if there are no capabilities
342
+            cap_row.set_activatable(caps)
343
+            cap_arrow.set_visible(caps)
335
 
344
 
336
         # Show the Sink page
345
         # Show the Sink page
337
         hst = self.builder.get_object("header-stack")
346
         hst = self.builder.get_object("header-stack")

Loading…
Cancel
Save