Skip to content

Commit a5d3a38

Browse files
committed
window: use AdwEnumModel for enum types
1 parent b4b4179 commit a5d3a38

2 files changed

Lines changed: 44 additions & 19 deletions

File tree

‎src/window.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333

3434
GObject.type_register(Exb.View)
3535
GObject.type_register(Exb.Engine)
36+
GObject.type_register(Exb.Blending)
37+
GObject.type_register(Exb.Sprites)
38+
GObject.type_register(Exb.AntiAliasing)
39+
GObject.type_register(Exb.Direction)
3640
GObject.type_register(ExhibitSettingsDialog)
3741

3842
log = logging.getLogger(__name__)
@@ -604,6 +608,10 @@ def generate_thumbnail(self, hdri_file_path, width=300, height=200):
604608

605609
return thumbnail_filepath
606610

611+
@Gtk.Template.Callback("enum_name")
612+
def enum_name (self, item):
613+
return item.get_nick().title().replace("-", " ")
614+
607615
@Gtk.Template.Callback("on_close_request")
608616
def on_close_request(self, window):
609617
log.debug("window closed, saving settings")

‎src/window.ui‎

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,19 @@
233233
<property name="hexpand-set">True</property>
234234
<property name="title" translatable="yes">Rendering</property>
235235
<child>
236-
<object class="AdwSwitchRow" id="translucency_switch">
236+
<object class="AdwComboRow" id="translucency_switch">
237237
<property name="hexpand">True</property>
238238
<property name="hexpand-set">True</property>
239-
<property name="title" translatable="yes">Translucency</property>
240-
<property name="active" bind-source="engine" bind-property="blending" bind-flags="bidirectional | sync-create"></property>
239+
<property name="title" translatable="yes">Blending</property>
240+
<property name="selected" bind-source="engine" bind-property="blending" bind-flags="bidirectional | sync-create"></property>
241+
<property name="model">
242+
<object class="AdwEnumListModel">
243+
<property name="enum-type">ExbBlending</property>
244+
</object>
245+
</property>
246+
<property name="expression">
247+
<closure type="gchararray" function="enum_name" />
248+
</property>
241249
</object>
242250
</child>
243251
<child>
@@ -259,11 +267,19 @@
259267
</object>
260268
</child>
261269
<child>
262-
<object class="AdwSwitchRow" id="anti_aliasing_switch">
270+
<object class="AdwComboRow" id="anti_aliasing_combo">
263271
<property name="hexpand">True</property>
264272
<property name="hexpand-set">True</property>
265273
<property name="title" translatable="yes">Anti Aliasing</property>
266-
<property name="active" bind-source="engine" bind-property="anti-aliasing" bind-flags="bidirectional | sync-create"></property>
274+
<property name="selected" bind-source="engine" bind-property="anti-aliasing" bind-flags="bidirectional | sync-create"></property>
275+
<property name="model">
276+
<object class="AdwEnumListModel">
277+
<property name="enum-type">ExbAntiAliasing</property>
278+
</object>
279+
</property>
280+
<property name="expression">
281+
<closure type="gchararray" function="enum_name" />
282+
</property>
267283
</object>
268284
</child>
269285
<child>
@@ -325,25 +341,18 @@
325341
</child>
326342
<child>
327343
<object class="AdwPreferencesGroup" id="points_group">
328-
<child>
329-
<object class="AdwSwitchRow" id="spheres_switch">
330-
<property name="hexpand">True</property>
331-
<property name="hexpand-set">True</property>
332-
<property name="title" translatable="yes">Show Point Sprites</property>
333-
<property name="active" bind-source="engine" bind-property="show-sprites" bind-flags="bidirectional | sync-create"></property>
334-
</object>
335-
</child>
336344
<child>
337345
<object class="AdwComboRow" id="point_sprites_type_combo">
338346
<property name="title" translatable="yes">Point Sprites Type</property>
347+
<property name="selected" bind-source="engine" bind-property="sprites" bind-flags="bidirectional | sync-create"></property>
339348
<property name="model">
340-
<object class="GtkStringList">
341-
<items>
342-
<item translatable="yes">Sphere</item>
343-
<item translatable="yes">Gaussian</item>
344-
</items>
349+
<object class="AdwEnumListModel">
350+
<property name="enum-type">ExbSprites</property>
345351
</object>
346352
</property>
353+
<property name="expression">
354+
<closure type="gchararray" function="enum_name" />
355+
</property>
347356
</object>
348357
</child>
349358
<child>
@@ -666,7 +675,15 @@
666675
<property name="hexpand">True</property>
667676
<property name="hexpand-set">True</property>
668677
<property name="title" translatable="yes">Up Direction</property>
669-
<property name="subtitle" translatable="yes">Changing it will reload the file</property>
678+
<property name="selected" bind-source="engine" bind-property="up" bind-flags="bidirectional | sync-create"></property>
679+
<property name="model">
680+
<object class="AdwEnumListModel">
681+
<property name="enum-type">ExbDirection</property>
682+
</object>
683+
</property>
684+
<property name="expression">
685+
<closure type="gchararray" function="enum_name" />
686+
</property>
670687
</object>
671688
</child>
672689
</object>

0 commit comments

Comments
 (0)