ソースを参照

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年前
コミット
066f0c068d
2個のファイルの変更11行の追加2行の削除
  1. 1
    1
      data/pd-buddy-gtk.ui
  2. 10
    1
      pd-buddy-gtk.py

+ 1
- 1
data/pd-buddy-gtk.ui ファイルの表示

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

+ 10
- 1
pd-buddy-gtk.py ファイルの表示

@@ -271,8 +271,10 @@ class Handler:
271 271
         giveback = self.builder.get_object("giveback-toggle")
272 272
         pd_frame = self.builder.get_object("power-delivery-frame")
273 273
         output = self.builder.get_object("output-switch")
274
+        cap_row = self.builder.get_object("source-cap-row")
274 275
         cap_warning = self.builder.get_object("source-cap-warning")
275 276
         cap_label = self.builder.get_object("short-source-cap-label")
277
+        cap_arrow = self.builder.get_object("source-cap-arrow")
276 278
 
277 279
         self.serial_port = serport
278 280
 
@@ -331,7 +333,14 @@ class Handler:
331 333
             cap_warning.set_visible(not pdbuddy.follows_power_rules(caps))
332 334
 
333 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 345
         # Show the Sink page
337 346
         hst = self.builder.get_object("header-stack")

読み込み中…
キャンセル
保存