Browse Source

Mostly implemented the new mockup

To add support for the new features in firmware 1.1.0, I decided to
split the Sink screen into two sections: Configuration and Power
Delivery.  The Configuration section contains all the things the Sink
screen had before, with some layout changes (notably the Save button is
part of the Configuration section, not in the HeaderBar).  The Power
Delivery section has the new features: an Output switch, which works
perfectly, and a currently half-baked Source Capabilities list item
which will eventually open a window to show the capabilities, but for
now just prints them.
Clara Hobbs 7 years ago
parent
commit
c88988af72
2 changed files with 461 additions and 168 deletions
  1. 404
    153
      data/pd-buddy-gtk.ui
  2. 57
    15
      pd-buddy-gtk.py

+ 404
- 153
data/pd-buddy-gtk.ui View File

@@ -68,165 +68,454 @@
68 68
                     <property name="can_focus">False</property>
69 69
                     <property name="orientation">vertical</property>
70 70
                     <child>
71
-                      <object class="GtkFrame">
71
+                      <object class="GtkBox">
72 72
                         <property name="visible">True</property>
73 73
                         <property name="can_focus">False</property>
74 74
                         <property name="halign">center</property>
75
-                        <property name="margin_left">50</property>
76
-                        <property name="margin_right">50</property>
77
-                        <property name="margin_top">30</property>
78
-                        <property name="margin_bottom">22</property>
79
-                        <property name="hexpand">False</property>
80
-                        <property name="label_xalign">0</property>
81
-                        <property name="shadow_type">none</property>
75
+                        <property name="margin_left">18</property>
76
+                        <property name="margin_right">18</property>
77
+                        <property name="margin_top">18</property>
78
+                        <property name="margin_bottom">18</property>
79
+                        <property name="orientation">vertical</property>
80
+                        <property name="spacing">24</property>
82 81
                         <child>
83
-                          <object class="GtkAlignment">
82
+                          <object class="GtkBox">
84 83
                             <property name="visible">True</property>
85 84
                             <property name="can_focus">False</property>
85
+                            <property name="orientation">vertical</property>
86
+                            <property name="spacing">8</property>
86 87
                             <child>
87
-                              <object class="GtkGrid">
88
+                              <object class="GtkBox">
88 89
                                 <property name="visible">True</property>
89 90
                                 <property name="can_focus">False</property>
90
-                                <property name="row_spacing">6</property>
91
-                                <property name="column_spacing">12</property>
92
-                                <child>
93
-                                  <object class="GtkLabel">
94
-                                    <property name="visible">True</property>
95
-                                    <property name="can_focus">False</property>
96
-                                    <property name="halign">end</property>
97
-                                    <property name="label" translatable="yes">Voltage</property>
98
-                                    <property name="justify">right</property>
99
-                                    <style>
100
-                                      <class name="dim-label"/>
101
-                                    </style>
102
-                                  </object>
103
-                                  <packing>
104
-                                    <property name="left_attach">0</property>
105
-                                    <property name="top_attach">0</property>
106
-                                  </packing>
107
-                                </child>
108
-                                <child>
109
-                                  <object class="GtkLabel">
110
-                                    <property name="visible">True</property>
111
-                                    <property name="can_focus">False</property>
112
-                                    <property name="halign">end</property>
113
-                                    <property name="label" translatable="yes">Current</property>
114
-                                    <property name="justify">right</property>
115
-                                    <style>
116
-                                      <class name="dim-label"/>
117
-                                    </style>
118
-                                  </object>
119
-                                  <packing>
120
-                                    <property name="left_attach">0</property>
121
-                                    <property name="top_attach">1</property>
122
-                                  </packing>
123
-                                </child>
124
-                                <child>
125
-                                  <object class="GtkSpinButton" id="current-spinbutton">
126
-                                    <property name="visible">True</property>
127
-                                    <property name="can_focus">True</property>
128
-                                    <property name="input_purpose">number</property>
129
-                                    <property name="adjustment">current-adjustment</property>
130
-                                    <property name="digits">2</property>
131
-                                    <property name="numeric">True</property>
132
-                                    <signal name="value-changed" handler="on_current_spinbutton_changed" swapped="no"/>
133
-                                  </object>
134
-                                  <packing>
135
-                                    <property name="left_attach">1</property>
136
-                                    <property name="top_attach">1</property>
137
-                                  </packing>
138
-                                </child>
139 91
                                 <child>
140 92
                                   <object class="GtkLabel">
141 93
                                     <property name="visible">True</property>
142 94
                                     <property name="can_focus">False</property>
143 95
                                     <property name="halign">start</property>
144
-                                    <property name="label" translatable="yes">A</property>
96
+                                    <property name="label" translatable="yes">Configuration</property>
97
+                                    <attributes>
98
+                                      <attribute name="weight" value="bold"/>
99
+                                    </attributes>
145 100
                                   </object>
146 101
                                   <packing>
147
-                                    <property name="left_attach">2</property>
148
-                                    <property name="top_attach">1</property>
102
+                                    <property name="expand">True</property>
103
+                                    <property name="fill">True</property>
104
+                                    <property name="position">0</property>
149 105
                                   </packing>
150 106
                                 </child>
151 107
                                 <child>
152
-                                  <object class="GtkLabel">
108
+                                  <object class="GtkRevealer" id="sink-save-revealer">
153 109
                                     <property name="visible">True</property>
154 110
                                     <property name="can_focus">False</property>
155
-                                    <property name="halign">start</property>
156
-                                    <property name="label" translatable="yes">V</property>
111
+                                    <property name="transition_type">crossfade</property>
112
+                                    <child>
113
+                                      <object class="GtkButtonBox">
114
+                                        <property name="visible">True</property>
115
+                                        <property name="can_focus">False</property>
116
+                                        <property name="orientation">vertical</property>
117
+                                        <property name="layout_style">start</property>
118
+                                        <child>
119
+                                          <object class="GtkButton" id="sink-save">
120
+                                            <property name="label">gtk-save</property>
121
+                                            <property name="visible">True</property>
122
+                                            <property name="can_focus">True</property>
123
+                                            <property name="receives_default">True</property>
124
+                                            <property name="use_stock">True</property>
125
+                                            <signal name="clicked" handler="on_sink_save_clicked" swapped="no"/>
126
+                                            <accelerator key="s" signal="clicked" modifiers="GDK_CONTROL_MASK"/>
127
+                                            <style>
128
+                                              <class name="suggested-action"/>
129
+                                            </style>
130
+                                          </object>
131
+                                          <packing>
132
+                                            <property name="expand">True</property>
133
+                                            <property name="fill">True</property>
134
+                                            <property name="position">0</property>
135
+                                          </packing>
136
+                                        </child>
137
+                                      </object>
138
+                                    </child>
157 139
                                   </object>
158 140
                                   <packing>
159
-                                    <property name="left_attach">2</property>
160
-                                    <property name="top_attach">0</property>
141
+                                    <property name="expand">False</property>
142
+                                    <property name="fill">True</property>
143
+                                    <property name="position">1</property>
161 144
                                   </packing>
162 145
                                 </child>
146
+                              </object>
147
+                              <packing>
148
+                                <property name="expand">False</property>
149
+                                <property name="fill">True</property>
150
+                                <property name="position">0</property>
151
+                              </packing>
152
+                            </child>
153
+                            <child>
154
+                              <object class="GtkFrame">
155
+                                <property name="visible">True</property>
156
+                                <property name="can_focus">False</property>
157
+                                <property name="hexpand">False</property>
158
+                                <property name="label_xalign">0</property>
163 159
                                 <child>
164
-                                  <object class="GtkComboBoxText" id="voltage-combobox">
160
+                                  <object class="GtkListBox" id="sink-config-list">
161
+                                    <property name="width_request">342</property>
165 162
                                     <property name="visible">True</property>
166 163
                                     <property name="can_focus">False</property>
167
-                                    <items>
168
-                                      <item id="voltage-five" translatable="yes">5</item>
169
-                                      <item id="voltage-nine" translatable="yes">9</item>
170
-                                      <item id="voltage-twelve" translatable="yes">12</item>
171
-                                      <item id="voltage-fifteen" translatable="yes">15</item>
172
-                                      <item id="voltage-twenty" translatable="yes">20</item>
173
-                                    </items>
174
-                                    <signal name="changed" handler="on_voltage_combobox_changed" swapped="no"/>
164
+                                    <property name="selection_mode">none</property>
165
+                                    <child>
166
+                                      <object class="GtkListBoxRow">
167
+                                        <property name="width_request">100</property>
168
+                                        <property name="visible">True</property>
169
+                                        <property name="can_focus">True</property>
170
+                                        <property name="vexpand">False</property>
171
+                                        <property name="activatable">False</property>
172
+                                        <child>
173
+                                          <object class="GtkGrid">
174
+                                            <property name="visible">True</property>
175
+                                            <property name="can_focus">False</property>
176
+                                            <property name="valign">center</property>
177
+                                            <property name="margin_left">12</property>
178
+                                            <property name="margin_right">6</property>
179
+                                            <property name="margin_top">6</property>
180
+                                            <property name="margin_bottom">6</property>
181
+                                            <property name="column_spacing">12</property>
182
+                                            <child>
183
+                                              <object class="GtkLabel">
184
+                                                <property name="visible">True</property>
185
+                                                <property name="can_focus">False</property>
186
+                                                <property name="halign">start</property>
187
+                                                <property name="hexpand">True</property>
188
+                                                <property name="label" translatable="yes">Voltage</property>
189
+                                                <property name="justify">right</property>
190
+                                              </object>
191
+                                              <packing>
192
+                                                <property name="left_attach">0</property>
193
+                                                <property name="top_attach">0</property>
194
+                                              </packing>
195
+                                            </child>
196
+                                            <child>
197
+                                              <object class="GtkComboBoxText" id="voltage-combobox">
198
+                                                <property name="visible">True</property>
199
+                                                <property name="can_focus">False</property>
200
+                                                <items>
201
+                                                  <item id="voltage-five" translatable="yes">5</item>
202
+                                                  <item id="voltage-nine" translatable="yes">9</item>
203
+                                                  <item id="voltage-twelve" translatable="yes">12</item>
204
+                                                  <item id="voltage-fifteen" translatable="yes">15</item>
205
+                                                  <item id="voltage-twenty" translatable="yes">20</item>
206
+                                                </items>
207
+                                                <signal name="changed" handler="on_voltage_combobox_changed" swapped="no"/>
208
+                                              </object>
209
+                                              <packing>
210
+                                                <property name="left_attach">1</property>
211
+                                                <property name="top_attach">0</property>
212
+                                              </packing>
213
+                                            </child>
214
+                                            <child>
215
+                                              <object class="GtkLabel">
216
+                                                <property name="visible">True</property>
217
+                                                <property name="can_focus">False</property>
218
+                                                <property name="halign">start</property>
219
+                                                <property name="label" translatable="yes">V</property>
220
+                                              </object>
221
+                                              <packing>
222
+                                                <property name="left_attach">2</property>
223
+                                                <property name="top_attach">0</property>
224
+                                              </packing>
225
+                                            </child>
226
+                                          </object>
227
+                                        </child>
228
+                                      </object>
229
+                                    </child>
230
+                                    <child>
231
+                                      <object class="GtkListBoxRow">
232
+                                        <property name="width_request">100</property>
233
+                                        <property name="visible">True</property>
234
+                                        <property name="can_focus">True</property>
235
+                                        <property name="activatable">False</property>
236
+                                        <child>
237
+                                          <object class="GtkGrid">
238
+                                            <property name="visible">True</property>
239
+                                            <property name="can_focus">False</property>
240
+                                            <property name="valign">center</property>
241
+                                            <property name="margin_left">12</property>
242
+                                            <property name="margin_right">6</property>
243
+                                            <property name="margin_top">6</property>
244
+                                            <property name="margin_bottom">6</property>
245
+                                            <property name="column_spacing">12</property>
246
+                                            <child>
247
+                                              <object class="GtkLabel">
248
+                                                <property name="visible">True</property>
249
+                                                <property name="can_focus">False</property>
250
+                                                <property name="halign">start</property>
251
+                                                <property name="hexpand">True</property>
252
+                                                <property name="label" translatable="yes">Current</property>
253
+                                                <property name="justify">right</property>
254
+                                              </object>
255
+                                              <packing>
256
+                                                <property name="left_attach">0</property>
257
+                                                <property name="top_attach">0</property>
258
+                                              </packing>
259
+                                            </child>
260
+                                            <child>
261
+                                              <object class="GtkSpinButton" id="current-spinbutton">
262
+                                                <property name="visible">True</property>
263
+                                                <property name="can_focus">True</property>
264
+                                                <property name="margin_left">12</property>
265
+                                                <property name="input_purpose">number</property>
266
+                                                <property name="adjustment">current-adjustment</property>
267
+                                                <property name="digits">2</property>
268
+                                                <property name="numeric">True</property>
269
+                                                <signal name="value-changed" handler="on_current_spinbutton_changed" swapped="no"/>
270
+                                              </object>
271
+                                              <packing>
272
+                                                <property name="left_attach">1</property>
273
+                                                <property name="top_attach">0</property>
274
+                                              </packing>
275
+                                            </child>
276
+                                            <child>
277
+                                              <object class="GtkLabel">
278
+                                                <property name="visible">True</property>
279
+                                                <property name="can_focus">False</property>
280
+                                                <property name="halign">start</property>
281
+                                                <property name="label" translatable="yes">A</property>
282
+                                              </object>
283
+                                              <packing>
284
+                                                <property name="left_attach">2</property>
285
+                                                <property name="top_attach">0</property>
286
+                                              </packing>
287
+                                            </child>
288
+                                          </object>
289
+                                        </child>
290
+                                      </object>
291
+                                    </child>
292
+                                    <child>
293
+                                      <object class="GtkListBoxRow">
294
+                                        <property name="width_request">100</property>
295
+                                        <property name="visible">True</property>
296
+                                        <property name="can_focus">True</property>
297
+                                        <property name="activatable">False</property>
298
+                                        <child>
299
+                                          <object class="GtkGrid">
300
+                                            <property name="visible">True</property>
301
+                                            <property name="can_focus">False</property>
302
+                                            <property name="valign">center</property>
303
+                                            <property name="margin_left">12</property>
304
+                                            <property name="margin_right">6</property>
305
+                                            <property name="margin_top">6</property>
306
+                                            <property name="margin_bottom">6</property>
307
+                                            <property name="column_spacing">12</property>
308
+                                            <child>
309
+                                              <object class="GtkLabel">
310
+                                                <property name="visible">True</property>
311
+                                                <property name="can_focus">False</property>
312
+                                                <property name="halign">start</property>
313
+                                                <property name="hexpand">True</property>
314
+                                                <property name="label" translatable="yes">Flags</property>
315
+                                                <property name="justify">right</property>
316
+                                              </object>
317
+                                              <packing>
318
+                                                <property name="left_attach">0</property>
319
+                                                <property name="top_attach">0</property>
320
+                                              </packing>
321
+                                            </child>
322
+                                            <child>
323
+                                              <object class="GtkButtonBox">
324
+                                                <property name="visible">True</property>
325
+                                                <property name="can_focus">False</property>
326
+                                                <property name="halign">start</property>
327
+                                                <property name="layout_style">expand</property>
328
+                                                <child>
329
+                                                  <object class="GtkToggleButton" id="giveback-toggle">
330
+                                                    <property name="label" translatable="yes">GiveBack</property>
331
+                                                    <property name="visible">True</property>
332
+                                                    <property name="can_focus">True</property>
333
+                                                    <property name="receives_default">True</property>
334
+                                                    <signal name="toggled" handler="on_giveback_toggle_toggled" swapped="no"/>
335
+                                                  </object>
336
+                                                  <packing>
337
+                                                    <property name="expand">True</property>
338
+                                                    <property name="fill">True</property>
339
+                                                    <property name="position">0</property>
340
+                                                  </packing>
341
+                                                </child>
342
+                                              </object>
343
+                                              <packing>
344
+                                                <property name="left_attach">1</property>
345
+                                                <property name="top_attach">0</property>
346
+                                                <property name="width">2</property>
347
+                                              </packing>
348
+                                            </child>
349
+                                          </object>
350
+                                        </child>
351
+                                      </object>
352
+                                    </child>
175 353
                                   </object>
176
-                                  <packing>
177
-                                    <property name="left_attach">1</property>
178
-                                    <property name="top_attach">0</property>
179
-                                  </packing>
180 354
                                 </child>
181
-                                <child>
182
-                                  <object class="GtkLabel">
183
-                                    <property name="visible">True</property>
184
-                                    <property name="can_focus">False</property>
185
-                                    <property name="halign">end</property>
186
-                                    <property name="label" translatable="yes">Flags</property>
187
-                                    <property name="justify">right</property>
188
-                                    <style>
189
-                                      <class name="dim-label"/>
190
-                                    </style>
191
-                                  </object>
192
-                                  <packing>
193
-                                    <property name="left_attach">0</property>
194
-                                    <property name="top_attach">2</property>
195
-                                  </packing>
355
+                                <child type="label_item">
356
+                                  <placeholder/>
196 357
                                 </child>
358
+                              </object>
359
+                              <packing>
360
+                                <property name="expand">False</property>
361
+                                <property name="fill">True</property>
362
+                                <property name="position">1</property>
363
+                              </packing>
364
+                            </child>
365
+                          </object>
366
+                          <packing>
367
+                            <property name="expand">False</property>
368
+                            <property name="fill">True</property>
369
+                            <property name="position">0</property>
370
+                          </packing>
371
+                        </child>
372
+                        <child>
373
+                          <object class="GtkFrame" id="power-delivery-frame">
374
+                            <property name="visible">True</property>
375
+                            <property name="can_focus">False</property>
376
+                            <property name="label_xalign">0</property>
377
+                            <property name="shadow_type">none</property>
378
+                            <child>
379
+                              <object class="GtkFrame">
380
+                                <property name="visible">True</property>
381
+                                <property name="can_focus">False</property>
382
+                                <property name="margin_top">6</property>
383
+                                <property name="margin_bottom">6</property>
384
+                                <property name="label_xalign">0</property>
197 385
                                 <child>
198
-                                  <object class="GtkButtonBox">
386
+                                  <object class="GtkListBox" id="power-delivery-list">
199 387
                                     <property name="visible">True</property>
200 388
                                     <property name="can_focus">False</property>
201
-                                    <property name="halign">start</property>
202
-                                    <property name="layout_style">expand</property>
389
+                                    <property name="selection_mode">none</property>
390
+                                    <signal name="row-activated" handler="on_source_cap_row_activated" swapped="no"/>
203 391
                                     <child>
204
-                                      <object class="GtkToggleButton" id="giveback-toggle">
205
-                                        <property name="label" translatable="yes">GiveBack</property>
392
+                                      <object class="GtkListBoxRow">
393
+                                        <property name="width_request">100</property>
206 394
                                         <property name="visible">True</property>
207 395
                                         <property name="can_focus">True</property>
208
-                                        <property name="receives_default">True</property>
209
-                                        <signal name="toggled" handler="on_giveback_toggle_toggled" swapped="no"/>
396
+                                        <property name="vexpand">False</property>
397
+                                        <property name="activatable">False</property>
398
+                                        <child>
399
+                                          <object class="GtkGrid">
400
+                                            <property name="visible">True</property>
401
+                                            <property name="can_focus">False</property>
402
+                                            <property name="valign">center</property>
403
+                                            <property name="margin_left">12</property>
404
+                                            <property name="margin_right">6</property>
405
+                                            <property name="margin_top">6</property>
406
+                                            <property name="margin_bottom">6</property>
407
+                                            <property name="column_spacing">12</property>
408
+                                            <child>
409
+                                              <object class="GtkLabel">
410
+                                                <property name="visible">True</property>
411
+                                                <property name="can_focus">False</property>
412
+                                                <property name="halign">start</property>
413
+                                                <property name="hexpand">True</property>
414
+                                                <property name="label" translatable="yes">Output</property>
415
+                                                <property name="justify">right</property>
416
+                                              </object>
417
+                                              <packing>
418
+                                                <property name="left_attach">0</property>
419
+                                                <property name="top_attach">0</property>
420
+                                              </packing>
421
+                                            </child>
422
+                                            <child>
423
+                                              <object class="GtkSwitch" id="output-switch">
424
+                                                <property name="visible">True</property>
425
+                                                <property name="can_focus">True</property>
426
+                                                <signal name="state-set" handler="on_output_switch_state_set" swapped="no"/>
427
+                                              </object>
428
+                                              <packing>
429
+                                                <property name="left_attach">1</property>
430
+                                                <property name="top_attach">0</property>
431
+                                                <property name="width">2</property>
432
+                                              </packing>
433
+                                            </child>
434
+                                          </object>
435
+                                        </child>
436
+                                      </object>
437
+                                    </child>
438
+                                    <child>
439
+                                      <object class="GtkListBoxRow" id="source-cap-row">
440
+                                        <property name="width_request">100</property>
441
+                                        <property name="visible">True</property>
442
+                                        <property name="can_focus">True</property>
443
+                                        <child>
444
+                                          <object class="GtkGrid">
445
+                                            <property name="visible">True</property>
446
+                                            <property name="can_focus">False</property>
447
+                                            <property name="valign">center</property>
448
+                                            <property name="margin_left">12</property>
449
+                                            <property name="margin_right">6</property>
450
+                                            <property name="margin_top">6</property>
451
+                                            <property name="margin_bottom">6</property>
452
+                                            <property name="column_spacing">12</property>
453
+                                            <child>
454
+                                              <object class="GtkLabel">
455
+                                                <property name="visible">True</property>
456
+                                                <property name="can_focus">False</property>
457
+                                                <property name="halign">start</property>
458
+                                                <property name="hexpand">True</property>
459
+                                                <property name="label" translatable="yes">Source Capabilities</property>
460
+                                                <property name="justify">right</property>
461
+                                              </object>
462
+                                              <packing>
463
+                                                <property name="left_attach">0</property>
464
+                                                <property name="top_attach">0</property>
465
+                                              </packing>
466
+                                            </child>
467
+                                            <child>
468
+                                              <object class="GtkLabel" id="short-source-cap-label">
469
+                                                <property name="visible">True</property>
470
+                                                <property name="can_focus">False</property>
471
+                                                <property name="label" translatable="yes">label</property>
472
+                                                <style>
473
+                                                  <class name="dim-label"/>
474
+                                                </style>
475
+                                              </object>
476
+                                              <packing>
477
+                                                <property name="left_attach">1</property>
478
+                                                <property name="top_attach">0</property>
479
+                                              </packing>
480
+                                            </child>
481
+                                            <child>
482
+                                              <object class="GtkImage">
483
+                                                <property name="visible">True</property>
484
+                                                <property name="can_focus">False</property>
485
+                                                <property name="icon_name">go-next-symbolic</property>
486
+                                              </object>
487
+                                              <packing>
488
+                                                <property name="left_attach">2</property>
489
+                                                <property name="top_attach">0</property>
490
+                                              </packing>
491
+                                            </child>
492
+                                          </object>
493
+                                        </child>
210 494
                                       </object>
211
-                                      <packing>
212
-                                        <property name="expand">True</property>
213
-                                        <property name="fill">True</property>
214
-                                        <property name="position">0</property>
215
-                                      </packing>
216 495
                                     </child>
217 496
                                   </object>
218
-                                  <packing>
219
-                                    <property name="left_attach">1</property>
220
-                                    <property name="top_attach">2</property>
221
-                                    <property name="width">2</property>
222
-                                  </packing>
497
+                                </child>
498
+                                <child type="label_item">
499
+                                  <placeholder/>
223 500
                                 </child>
224 501
                               </object>
225 502
                             </child>
503
+                            <child type="label">
504
+                              <object class="GtkLabel">
505
+                                <property name="visible">True</property>
506
+                                <property name="can_focus">False</property>
507
+                                <property name="label" translatable="yes">Power Delivery</property>
508
+                                <attributes>
509
+                                  <attribute name="weight" value="bold"/>
510
+                                </attributes>
511
+                              </object>
512
+                            </child>
226 513
                           </object>
227
-                        </child>
228
-                        <child type="label_item">
229
-                          <placeholder/>
514
+                          <packing>
515
+                            <property name="expand">False</property>
516
+                            <property name="fill">True</property>
517
+                            <property name="position">1</property>
518
+                          </packing>
230 519
                         </child>
231 520
                       </object>
232 521
                       <packing>
@@ -290,44 +579,6 @@
290 579
                 <accelerator key="Left" signal="clicked" modifiers="GDK_MOD1_MASK"/>
291 580
               </object>
292 581
             </child>
293
-            <child>
294
-              <object class="GtkRevealer" id="header-sink-save-revealer">
295
-                <property name="visible">True</property>
296
-                <property name="can_focus">False</property>
297
-                <property name="transition_type">crossfade</property>
298
-                <child>
299
-                  <object class="GtkButtonBox">
300
-                    <property name="visible">True</property>
301
-                    <property name="can_focus">False</property>
302
-                    <property name="orientation">vertical</property>
303
-                    <property name="layout_style">start</property>
304
-                    <child>
305
-                      <object class="GtkButton" id="header-sink-save">
306
-                        <property name="label">gtk-save</property>
307
-                        <property name="visible">True</property>
308
-                        <property name="can_focus">True</property>
309
-                        <property name="receives_default">True</property>
310
-                        <property name="use_stock">True</property>
311
-                        <signal name="clicked" handler="on_header_sink_save_clicked" swapped="no"/>
312
-                        <accelerator key="s" signal="clicked" modifiers="GDK_CONTROL_MASK"/>
313
-                        <style>
314
-                          <class name="suggested-action"/>
315
-                        </style>
316
-                      </object>
317
-                      <packing>
318
-                        <property name="expand">True</property>
319
-                        <property name="fill">True</property>
320
-                        <property name="position">0</property>
321
-                      </packing>
322
-                    </child>
323
-                  </object>
324
-                </child>
325
-              </object>
326
-              <packing>
327
-                <property name="pack_type">end</property>
328
-                <property name="position">1</property>
329
-              </packing>
330
-            </child>
331 582
           </object>
332 583
           <packing>
333 584
             <property name="name">page1</property>

+ 57
- 15
pd-buddy-gtk.py View File

@@ -52,6 +52,18 @@ class SelectListStore(Gio.ListStore):
52 52
                 self.append(ListRowModel(port))
53 53
 
54 54
 
55
+def list_box_update_header_func(row, before, data):
56
+    """Add a separator header to all rows but the first one"""
57
+    if before is None:
58
+        row.set_header(None)
59
+        return
60
+
61
+    current = row.get_header()
62
+    if current is None:
63
+        current = Gtk.Separator.new(Gtk.Orientation.HORIZONTAL)
64
+        row.set_header(current)
65
+
66
+
55 67
 class SelectList(Gtk.Box):
56 68
     __gsignals__ = {
57 69
         'row-activated': (GObject.SIGNAL_RUN_FIRST, None,
@@ -70,22 +82,11 @@ class SelectList(Gtk.Box):
70 82
         sl = self._builder.get_object("select-list")
71 83
 
72 84
         # Add separators to the list
73
-        sl.set_header_func(self._update_header_func, None)
85
+        sl.set_header_func(list_box_update_header_func, None)
74 86
 
75 87
         self.pack_start(self._builder.get_object("select-stack"), True, True, 0)
76 88
         self.show_all()
77 89
 
78
-    def _update_header_func(self, row, before, data):
79
-        """Add a separator header to all rows but the first one"""
80
-        if before is None:
81
-            row.set_header(None)
82
-            return
83
-
84
-        current = row.get_header()
85
-        if current is None:
86
-            current = Gtk.Separator.new(Gtk.Orientation.HORIZONTAL)
87
-            row.set_header(current)
88
-
89 90
     def bind_model(self, model, func):
90 91
         self._builder.get_object("select-list").bind_model(model, func)
91 92
         self._model = model
@@ -163,14 +164,24 @@ class Handler:
163 164
 
164 165
         self.selectlist.connect("row-activated", self.on_select_list_row_activated)
165 166
 
167
+        # Add separators to the configuration page lists
168
+        sc_list = self.builder.get_object("sink-config-list")
169
+        sc_list.set_header_func(list_box_update_header_func, None)
170
+
171
+        pd_list = self.builder.get_object("power-delivery-list")
172
+        pd_list.set_header_func(list_box_update_header_func, None)
173
+
166 174
     def on_pdb_window_delete_event(self, *args):
167 175
         Gtk.main_quit(*args)
168 176
 
169 177
     def on_select_list_row_activated(self, selectlist, serport):
170
-        # Get voltage and current widgets
178
+        # Get relevant widgets
171 179
         voltage = self.builder.get_object("voltage-combobox")
172 180
         current = self.builder.get_object("current-spinbutton")
173 181
         giveback = self.builder.get_object("giveback-toggle")
182
+        pd_frame = self.builder.get_object("power-delivery-frame")
183
+        output = self.builder.get_object("output-switch")
184
+        cap_label = self.builder.get_object("short-source-cap-label")
174 185
 
175 186
         self.serial_port = serport
176 187
 
@@ -211,6 +222,21 @@ class Handler:
211 222
 
212 223
         current.set_value(self.cfg.i/1000)
213 224
 
225
+        # Set PD frame visibility and output switch state
226
+        try:
227
+            with pdbuddy.Sink(self.serial_port) as pdbs:
228
+                output.set_state(pdbs.output)
229
+        except KeyError:
230
+            pd_frame.set_visible(False)
231
+        else:
232
+            pd_frame.set_visible(True)
233
+
234
+            # Update the text in the capability label
235
+            # TODO: do this repeatedly
236
+            with pdbuddy.Sink(self.serial_port) as pdbs:
237
+                caps = pdbs.get_source_cap()
238
+            cap_label.set_text('{} PDOs'.format(len(caps)))
239
+
214 240
         # Show the Sink page
215 241
         hst = self.builder.get_object("header-stack")
216 242
         hsink = self.builder.get_object("header-sink")
@@ -254,7 +280,7 @@ class Handler:
254 280
         select = self.builder.get_object("select")
255 281
         st.set_visible_child(select)
256 282
 
257
-    def on_header_sink_save_clicked(self, button):
283
+    def on_sink_save_clicked(self, button):
258 284
         window = self.builder.get_object("pdb-window")
259 285
         try:
260 286
             with pdbuddy.Sink(self.serial_port) as pdbs:
@@ -274,7 +300,7 @@ class Handler:
274 300
     def _set_save_button_visibility(self):
275 301
         """Show the save button if there are new settings to save"""
276 302
         # Get relevant widgets
277
-        rev = self.builder.get_object("header-sink-save-revealer")
303
+        rev = self.builder.get_object("sink-save-revealer")
278 304
 
279 305
         # Set visibility
280 306
         rev.set_reveal_child(self.cfg != self.cfg_clean)
@@ -297,6 +323,22 @@ class Handler:
297 323
 
298 324
         self._set_save_button_visibility()
299 325
 
326
+    def on_output_switch_state_set(self, switch, state):
327
+        with pdbuddy.Sink(self.serial_port) as pdbs:
328
+            pdbs.output = state
329
+
330
+    def on_source_cap_row_activated(self, box, row):
331
+        # Find which row was clicked
332
+        sc_row = self.builder.get_object("source-cap-row")
333
+        if row != sc_row:
334
+            # If it's not the source-cap-row, leave
335
+            return
336
+        # Get the source capabilities
337
+        with pdbuddy.Sink(self.serial_port) as pdbs:
338
+            caps = pdbs.get_source_cap()
339
+            for i, cap in enumerate(caps):
340
+                print("PDO {}: {}".format(i+1, cap))
341
+
300 342
 
301 343
 class Application(Gtk.Application):
302 344
 

Loading…
Cancel
Save