|
@@ -339,29 +339,50 @@ class Handler:
|
339
|
339
|
if row != sc_row:
|
340
|
340
|
# If it's not the source-cap-row, leave
|
341
|
341
|
return
|
|
342
|
+
|
342
|
343
|
# Get the source capabilities
|
343
|
344
|
with pdbuddy.Sink(self.serial_port) as pdbs:
|
344
|
345
|
caps = pdbs.get_source_cap()
|
345
|
|
- s = ""
|
346
|
|
- for i, cap in enumerate(caps):
|
347
|
|
- s += "PDO {}: {}".format(i+1, cap)
|
348
|
|
- if i < len(caps) - 1:
|
349
|
|
- s += "\n"
|
350
|
|
- if not s:
|
351
|
|
- s = "No Source_Capabilities"
|
352
|
|
- flags = Gtk.DialogFlags.DESTROY_WITH_PARENT;
|
353
|
|
- window = self.builder.get_object("pdb-window")
|
354
|
|
- dialog_builder = Gtk.Builder.new_from_file("data/src-cap-dialog.ui")
|
355
|
|
- dialog = dialog_builder.get_object("src-cap-dialog")
|
356
|
|
- dialog.set_transient_for(window)
|
357
|
|
- #dialog = Gtk.MessageDialog(window,
|
358
|
|
- # flags,
|
359
|
|
- # Gtk.MessageType.INFO,
|
360
|
|
- # Gtk.ButtonsType.CLOSE,
|
361
|
|
- # None)
|
362
|
|
- #dialog.set_markup("<span font_family='monospace'>{}</span>".format(s))
|
363
|
|
- dialog.run()
|
364
|
|
- dialog.destroy()
|
|
346
|
+
|
|
347
|
+ # Create the dialog
|
|
348
|
+ window = self.builder.get_object("pdb-window")
|
|
349
|
+ dialog_builder = Gtk.Builder.new_from_file("data/src-cap-dialog.ui")
|
|
350
|
+ dialog = dialog_builder.get_object("src-cap-dialog")
|
|
351
|
+ dialog.set_transient_for(window)
|
|
352
|
+
|
|
353
|
+ # Populate PD Power
|
|
354
|
+ d_power = dialog_builder.get_object("power-label")
|
|
355
|
+ d_power.set_text("{:g} W".format(pdbuddy.calculate_pdp(caps)))
|
|
356
|
+
|
|
357
|
+ # Populate Information
|
|
358
|
+ d_info_header = dialog_builder.get_object("info-header")
|
|
359
|
+ d_info = dialog_builder.get_object("info-label")
|
|
360
|
+ # Make the string to display
|
|
361
|
+ info_str = ""
|
|
362
|
+ if not caps[0].dual_role_pwr:
|
|
363
|
+ info_str += "Dual-Role Power\n"
|
|
364
|
+ if not caps[0].usb_suspend:
|
|
365
|
+ info_str += "USB Suspend Supported\n"
|
|
366
|
+ if caps[0].unconstrained_pwr:
|
|
367
|
+ info_str += "Unconstrained Power\n"
|
|
368
|
+ if not caps[0].usb_comms:
|
|
369
|
+ info_str += "USB Communications Capable\n"
|
|
370
|
+ if not caps[0].dual_role_data:
|
|
371
|
+ info_str += "Dual-Role Data\n"
|
|
372
|
+ info_str = info_str[:-1]
|
|
373
|
+ # Set the text and label visibility
|
|
374
|
+ d_info.set_text(info_str)
|
|
375
|
+ d_info_header.set_visible(info_str)
|
|
376
|
+ d_info.set_visible(info_str)
|
|
377
|
+
|
|
378
|
+ # PDO list
|
|
379
|
+ d_list = dialog_builder.get_object("src-cap-list")
|
|
380
|
+ d_list.set_header_func(list_box_update_header_func, None)
|
|
381
|
+ # TODO
|
|
382
|
+
|
|
383
|
+ # Show the dialog
|
|
384
|
+ dialog.run()
|
|
385
|
+ dialog.destroy()
|
365
|
386
|
|
366
|
387
|
|
367
|
388
|
class Application(Gtk.Application):
|