Skip to content

Commit

Permalink
added option to turn off sounds in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
naxuroqa committed Aug 21, 2014
1 parent 66fc8b8 commit af55d75
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 110 deletions.
20 changes: 11 additions & 9 deletions src/core/Settings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,29 @@ namespace Venom {
public const string URGENCY_NOTIFICATION_KEY = "enable-urgency-notification";
public const string TRAY_KEY = "enable-tray";
public const string NOTIFY_KEY = "enable-notify";
public const string NOTIFY_SOUNDS_KEY = "enable-notify-sounds";
public const string DEC_BINARY_PREFIX_KEY = "dec-binary-prefix";
public const string SEND_TYPING_STATUS_KEY = "send-typing-status";
public const string SHOW_TYPING_STATUS_KEY = "show-typing-status";
public const string DEFAULT_HOST_KEY = "default-host";
public const string MIC_VOLUME_KEY = "mic-volume";

public int contactlist_height { get; set; default = 600; }
public int contactlist_width { get; set; default = 200; }
public int days_to_log { get; set; default = 180; }
public bool dec_binary_prefix { get; set; default = true; }
public string default_host { get; set; default = "toxme.se";}
public bool enable_logging { get; set; default = false; }
public bool enable_notify { get; set; default = true; }
public bool enable_notify_sounds { get; set; default = true; }
public bool enable_urgency_notification { get; set; default = true; }
public bool enable_tray { get; set; default = true; }
public bool log_indefinitely { get; set; default = true; }
public int days_to_log { get; set; default = 180; }
public bool dec_binary_prefix { get; set; default = true; }
public double mic_volume { get; set; default = 1.0; }
public bool send_typing_status { get; set; default = false; }
public bool show_typing_status { get; set; default = true; }
public int contactlist_width { get; set; default = 200; }
public int contactlist_height { get; set; default = 600; }
public int window_width { get; set; default = 600; }
public int window_height { get; set; default = 600; }
public string default_host { get; set; default = "toxme.se";}
public bool enable_tray { get; set; default = true; }
public bool enable_notify { get; set; default = true; }
public double mic_volume { get; set; default = 1.0; }
public int window_width { get; set; default = 600; }

private static Settings? _instance;
public static Settings instance {
Expand Down
21 changes: 14 additions & 7 deletions src/ui/ContactListWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -641,13 +641,16 @@ namespace Venom {
}

public void set_urgency (string? sound = null) {
if(!is_active && Settings.instance.enable_urgency_notification) {
if(is_active) {
return;
}
if(Settings.instance.enable_urgency_notification) {
this.set_urgency_hint(true);
this.set_title("* %s".printf(this.our_title));
if(sound != null) {
AVManager.instance.play_sound(sound);
}
}
if(sound != null && Settings.instance.enable_notify_sounds) {
AVManager.instance.play_sound(sound);
}
this.set_title("* %s".printf(this.our_title));
}

private bool on_treeview_key_pressed (Gtk.Widget source, Gdk.EventKey key) {
Expand Down Expand Up @@ -741,11 +744,15 @@ namespace Venom {
if(status) {
image_status.set_tooltip_text(_("Connected to the network"));
session.set_user_status(user_status);
AVManager.instance.play_sound(Path.build_filename("file://" + ResourceFactory.instance.sounds_directory, "log-in.wav"));
if(Settings.instance.enable_notify_sounds) {
AVManager.instance.play_sound(Path.build_filename("file://" + ResourceFactory.instance.sounds_directory, "log-in.wav"));
}
} else {
image_status.set_tooltip_text(_("Disconnected from the network"));
on_ownuserstatus(UserStatus.OFFLINE);
AVManager.instance.play_sound(Path.build_filename("file://" + ResourceFactory.instance.sounds_directory, "log-out.wav"));
if(Settings.instance.enable_notify_sounds) {
AVManager.instance.play_sound(Path.build_filename("file://" + ResourceFactory.instance.sounds_directory, "log-out.wav"));
}
}
image_status.show();
spinner_status.hide();
Expand Down
1 change: 1 addition & 0 deletions src/ui/SettingsWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace Venom {
#else
(builder.get_object("notify_checkbutton") as Gtk.Widget).sensitive = false;
#endif
settings.bind_property(Settings.NOTIFY_SOUNDS_KEY, builder.get_object("notify_sounds_checkbutton"), "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
settings.bind_property(Settings.DEFAULT_HOST_KEY, builder.get_object("default_host_entry"), "text", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
settings.bind_property(Settings.DEC_BINARY_PREFIX_KEY, builder.get_object("filesize_prefix_combobox"), "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL,
(binding, srcval, ref targetval) => {targetval.set_int((bool)srcval ? 0 : 1); return true;},
Expand Down

0 comments on commit af55d75

Please sign in to comment.