Skip to content

Commit c7bcd79

Browse files
committed
gmoccapy: add setting to disable sound
1 parent 8d4e2a3 commit c7bcd79

2 files changed

Lines changed: 44 additions & 18 deletions

File tree

src/emc/usr_intf/gmoccapy/gmoccapy.glade

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4210,7 +4210,7 @@ clicking on the DRO</property>
42104210
<property name="can-focus">False</property>
42114211
<property name="label-xalign">0.5</property>
42124212
<child>
4213-
<!-- n-columns=2 n-rows=6 -->
4213+
<!-- n-columns=2 n-rows=7 -->
42144214
<object class="GtkGrid" id="grid_themes_sound">
42154215
<property name="visible">True</property>
42164216
<property name="can-focus">False</property>
@@ -4285,37 +4285,37 @@ clicking on the DRO</property>
42854285
</packing>
42864286
</child>
42874287
<child>
4288-
<object class="GtkLabel" id="label25">
4288+
<object class="GtkFileChooserButton" id="audio_error_chooser">
42894289
<property name="visible">True</property>
42904290
<property name="can-focus">False</property>
4291-
<property name="margin-start">3</property>
4292-
<property name="margin-end">3</property>
4293-
<property name="label" translatable="yes">Warning Audio</property>
4294-
<property name="xalign">0</property>
4291+
<signal name="file-set" handler="on_change_sound" swapped="no"/>
42954292
</object>
42964293
<packing>
4297-
<property name="left-attach">0</property>
4298-
<property name="top-attach">4</property>
4294+
<property name="left-attach">1</property>
4295+
<property name="top-attach">6</property>
42994296
</packing>
43004297
</child>
43014298
<child>
4302-
<object class="GtkFileChooserButton" id="audio_alert_chooser">
4299+
<object class="GtkLabel" id="label27">
43034300
<property name="visible">True</property>
43044301
<property name="can-focus">False</property>
4305-
<signal name="file-set" handler="on_change_sound" swapped="no"/>
4302+
<property name="margin-start">3</property>
4303+
<property name="margin-end">3</property>
4304+
<property name="label" translatable="yes">Alert Audio</property>
4305+
<property name="xalign">0</property>
43064306
</object>
43074307
<packing>
4308-
<property name="left-attach">1</property>
4309-
<property name="top-attach">4</property>
4308+
<property name="left-attach">0</property>
4309+
<property name="top-attach">6</property>
43104310
</packing>
43114311
</child>
43124312
<child>
4313-
<object class="GtkLabel" id="label27">
4313+
<object class="GtkLabel" id="label25">
43144314
<property name="visible">True</property>
43154315
<property name="can-focus">False</property>
43164316
<property name="margin-start">3</property>
43174317
<property name="margin-end">3</property>
4318-
<property name="label" translatable="yes">Alert Audio</property>
4318+
<property name="label" translatable="yes">Warning Audio</property>
43194319
<property name="xalign">0</property>
43204320
</object>
43214321
<packing>
@@ -4324,7 +4324,7 @@ clicking on the DRO</property>
43244324
</packing>
43254325
</child>
43264326
<child>
4327-
<object class="GtkFileChooserButton" id="audio_error_chooser">
4327+
<object class="GtkFileChooserButton" id="audio_alert_chooser">
43284328
<property name="visible">True</property>
43294329
<property name="can-focus">False</property>
43304330
<signal name="file-set" handler="on_change_sound" swapped="no"/>
@@ -4334,6 +4334,21 @@ clicking on the DRO</property>
43344334
<property name="top-attach">5</property>
43354335
</packing>
43364336
</child>
4337+
<child>
4338+
<object class="GtkCheckButton" id="chk_en_audio">
4339+
<property name="label" translatable="yes">Enable sound</property>
4340+
<property name="visible">True</property>
4341+
<property name="can-focus">True</property>
4342+
<property name="receives-default">False</property>
4343+
<property name="draw-indicator">True</property>
4344+
<signal name="toggled" handler="on_chk_en_audio_toggled" swapped="no"/>
4345+
</object>
4346+
<packing>
4347+
<property name="left-attach">0</property>
4348+
<property name="top-attach">4</property>
4349+
<property name="width">2</property>
4350+
</packing>
4351+
</child>
43374352
</object>
43384353
</child>
43394354
<child type="label">

src/emc/usr_intf/gmoccapy/gmoccapy.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,9 +2013,16 @@ def _init_icon_themes(self):
20132013

20142014
def _init_audio(self):
20152015
# try to add ability for audio feedback to user.
2016+
audio_enabled = self.prefs.getpref('audio_enabled', True, bool)
2017+
self.widgets.chk_en_audio.set_active(audio_enabled)
20162018
if _AUDIO_AVAILABLE:
20172019
LOG.info(_("Audio available!"))
2018-
2020+
if audio_enabled:
2021+
self.audio_active = True
2022+
LOG.info(_("Audio enabled!"))
2023+
else:
2024+
self.audio_active = False
2025+
LOG.info(_("Audio disabled!"))
20192026
# the sounds to play if an error or message rises
20202027
self.alert_sound = "/usr/share/sounds/freedesktop/stereo/dialog-warning.oga"
20212028
self.error_sound = "/usr/share/sounds/freedesktop/stereo/dialog-error.oga"
@@ -2427,7 +2434,7 @@ def _show_error(self, error):
24272434
text = _("Unknown error type and no error text given")
24282435
self.notification.add_message(text, icon)
24292436

2430-
if _AUDIO_AVAILABLE:
2437+
if self.audio_active:
24312438
if kind == 1 or kind == 11:
24322439
self._on_play_sound(None, "error")
24332440
else:
@@ -5272,6 +5279,10 @@ def on_btn_run_clicked(self, widget, data=None):
52725279

52735280
def on_btn_from_line_clicked(self, widget, data=None):
52745281
self.dialogs.restart_dialog(self)
5282+
5283+
def on_chk_en_audio_toggled(self, widget, data=None):
5284+
self.prefs.putpref("audio_enabled", widget.get_active())
5285+
self.audio_active = widget.get_active()
52755286

52765287
def on_change_sound(self, widget, sound=None):
52775288
file = widget.get_filename()
@@ -5429,7 +5440,7 @@ def _on_unlock_settings_changed(self, pin):
54295440

54305441
def _on_play_sound(self, widget, sound = None):
54315442
LOG.debug("_on_play_sound {0} {1} {2}".format(self,widget,sound))
5432-
if _AUDIO_AVAILABLE and sound:
5443+
if self.audio_active and sound:
54335444
if sound == "error":
54345445
self.audio.set_sound(self.error_sound)
54355446
elif sound == "alert":

0 commit comments

Comments
 (0)