/pidgin/main: 09ff1d312b2a: Remove volume option from Finch and ...

Mike Ruprecht cmaiku at gmail.com
Sat Jan 9 12:05:10 EST 2016


Changeset: 09ff1d312b2ae510e7928314486e0c755dba5153
Author:	 Mike Ruprecht <cmaiku at gmail.com>
Date:	 2016-01-07 22:27 -0600
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/09ff1d312b2a

Description:

Remove volume option from Finch and Pidgin preferences

The volume option in Pidgin and Finch both translate to GStreamer as
a range of 0.0 to 2.0. GStreamer's playbin element has a range of 0.0
to 10.0, but 1.0 is 100% volume. With PulseAudio, when using flat
volumes, it sets the system volume to the highest volumed, playing
stream. However, this only happens when explicitly setting the volume
on the GstPulseSink, which in this case happens through GstPlayBin.
With the default preference in Pidgin and Finch being 1.0,
100% volume, this causes PulseAudio to set the system volume to
100% each time a Pidgin or Finch notification sounds. It was
determined that these days, such an option probably isn't very
useful, and can always be added again if necessary. So this patch
removes the volume option.

diffstat:

 finch/gntsound.c  |  36 +---------------------------
 pidgin/gtkprefs.c |  68 -------------------------------------------------------
 pidgin/gtksound.c |   4 ---
 3 files changed, 2 insertions(+), 106 deletions(-)

diffs (278 lines):

diff --git a/finch/gntsound.c b/finch/gntsound.c
--- a/finch/gntsound.c
+++ b/finch/gntsound.c
@@ -48,7 +48,6 @@
 #include "gntentry.h"
 #include "gntcheckbox.h"
 #include "gntline.h"
-#include "gntslider.h"
 #include "gnttree.h"
 #include "gntfilesel.h"
 
@@ -65,7 +64,6 @@ typedef struct {
 	GntWidget *command;
 	GntWidget *conv_focus;
 	GntWidget *while_status;
-	GntWidget *volume;
 	GntWidget *events;
 	GntWidget *window;
 	GntWidget *selector;
@@ -319,7 +317,6 @@ initialize_profile(const char *name, Pur
 	purple_prefs_add_bool(make_pref("/mute"), FALSE);
 	purple_prefs_add_path(make_pref("/command"), "");
 	purple_prefs_add_string(make_pref("/method"), "automatic");
-	purple_prefs_add_int(make_pref("/volume"), 50);
 }
 
 static void
@@ -458,7 +455,6 @@ finch_sound_play_file(const char *filena
 {
 	const char *method;
 #if defined(USE_GSTREAMER) && !defined(_WIN32)
-	float volume;
 	char *uri;
 	GstElement *sink = NULL;
 	GstElement *play = NULL;
@@ -516,7 +512,6 @@ finch_sound_play_file(const char *filena
 #ifdef USE_GSTREAMER
 	if (gst_init_failed)  /* Perhaps do beep instead? */
 		return;
-	volume = (float)(CLAMP(purple_prefs_get_int(make_pref("/volume")), 0, 100)) / 50;
 	if (!strcmp(method, "automatic")) {
 		if (purple_running_gnome()) {
 			sink = gst_element_factory_make("gconfaudiosink", "sink");
@@ -553,7 +548,6 @@ finch_sound_play_file(const char *filena
 	uri = g_strdup_printf("file://%s", filename);
 
 	g_object_set(G_OBJECT(play), "uri", uri,
-		                     "volume", volume,
 		                     "audio-sink", sink, NULL);
 
 	bus = gst_pipeline_get_bus(GST_PIPELINE(play));
@@ -655,7 +649,6 @@ save_cb(GntWidget *button, gpointer win)
 	purple_prefs_set_path(make_pref("/command"), gnt_entry_get_text(GNT_ENTRY(pref_dialog->command)));
 	purple_prefs_set_bool(make_pref("/conv_focus"), gnt_check_box_get_checked(GNT_CHECK_BOX(pref_dialog->conv_focus)));
 	purple_prefs_set_int("/purple/sound/while_status", GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->while_status))));
-	purple_prefs_set_int(make_pref("/volume"), gnt_slider_get_value(GNT_SLIDER(pref_dialog->volume)));
 
 	for (itr = gnt_tree_get_rows(GNT_TREE(pref_dialog->events)); itr; itr = itr->next) {
 		FinchSoundEvent * event = &sounds[GPOINTER_TO_INT(itr->data)];
@@ -688,34 +681,28 @@ test_cb(GntWidget *button, gpointer null
 {
 	PurpleSoundEventID id = GPOINTER_TO_INT(gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events)));
 	FinchSoundEvent * event = &sounds[id];
-	char *enabled, *file, *tmpfile, *volpref;
+	char *enabled, *file, *tmpfile;
 	gboolean temp_value;
-	int volume;
 
 	enabled = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s",
 			finch_sound_get_active_profile(), event->pref);
 	file = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s",
 			finch_sound_get_active_profile(), event->pref);
-	volpref = g_strdup(make_pref("/volume"));
 
 	temp_value = purple_prefs_get_bool(enabled);
 	tmpfile = g_strdup(purple_prefs_get_path(file));
-	volume = purple_prefs_get_int(volpref);
 
 	purple_prefs_set_path(file, event->file);
 	if (!temp_value) purple_prefs_set_bool(enabled, TRUE);
-	purple_prefs_set_int(volpref, gnt_slider_get_value(GNT_SLIDER(pref_dialog->volume)));
 
 	purple_sound_play_event(id, NULL);
 
 	if (!temp_value) purple_prefs_set_bool(enabled, FALSE);
 	purple_prefs_set_path(file, tmpfile);
-	purple_prefs_set_int(volpref, volume);
 
 	g_free(enabled);
 	g_free(file);
 	g_free(tmpfile);
-	g_free(volpref);
 }
 
 static void
@@ -791,8 +778,6 @@ load_pref_window(const char * profile)
 
 	gnt_combo_box_set_selected(GNT_COMBO_BOX(pref_dialog->while_status), GINT_TO_POINTER(purple_prefs_get_int("/purple" "/sound/while_status")));
 
-	gnt_slider_set_value(GNT_SLIDER(pref_dialog->volume), CLAMP(purple_prefs_get_int(make_pref("/volume")), 0, 100));
-
 	for (i = 0; i < PURPLE_NUM_SOUNDS; i++) {
 		FinchSoundEvent * event = &sounds[i];
 		gchar *boolpref;
@@ -892,7 +877,7 @@ cancel_cb(GntButton *button, gpointer wi
 void
 finch_sounds_show_all(void)
 {
-	GntWidget *box, *tmpbox, *splitbox, *cmbox, *slider;
+	GntWidget *box, *tmpbox, *splitbox, *cmbox;
 	GntWidget *entry;
 	GntWidget *chkbox;
 	GntWidget *button;
@@ -1007,21 +992,6 @@ finch_sounds_show_all(void)
 	gnt_box_add_widget(GNT_BOX(tmpbox), cmbox);
 	gnt_box_add_widget(GNT_BOX(box), tmpbox);
 
-	tmpbox = gnt_hbox_new(TRUE);
-	gnt_box_set_pad(GNT_BOX(tmpbox), 0);
-	gnt_box_set_fill(GNT_BOX(tmpbox), FALSE);
-	gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new(_("Volume(0-100):")));
-
-	pref_dialog->volume = slider = gnt_slider_new(FALSE, 100, 0);
-	gnt_slider_set_step(GNT_SLIDER(slider), 5);
-	gnt_slider_set_small_step(GNT_SLIDER(slider), 1);
-	gnt_slider_set_large_step(GNT_SLIDER(slider), 20);
-	label = gnt_label_new("");
-	gnt_slider_reflect_label(GNT_SLIDER(slider), GNT_LABEL(label));
-	gnt_box_set_pad(GNT_BOX(tmpbox), 1);
-	gnt_box_add_widget(GNT_BOX(tmpbox), slider);
-	gnt_box_add_widget(GNT_BOX(tmpbox), label);
-	gnt_box_add_widget(GNT_BOX(box), tmpbox);
 	gnt_box_add_widget(GNT_BOX(splitbox), box);
 
 	gnt_box_add_widget(GNT_BOX(win), splitbox);
@@ -1090,8 +1060,6 @@ gboolean finch_sound_is_enabled(void)
 		return FALSE;
 	if (strcmp(method, "nosound") == 0)
 		return FALSE;
-	if (purple_prefs_get_int(make_pref("/volume")) <= 0)
-		return FALSE;
 
 	return TRUE;
 }
diff --git a/pidgin/gtkprefs.c b/pidgin/gtkprefs.c
--- a/pidgin/gtkprefs.c
+++ b/pidgin/gtkprefs.c
@@ -2933,23 +2933,6 @@ sound_changed2_cb(const char *name, Purp
 	gtk_widget_set_sensitive(vbox, strcmp(method, "none"));
 }
 
-#ifdef USE_GSTREAMER
-static void
-sound_changed3_cb(const char *name, PurplePrefType type,
-				  gconstpointer value, gpointer data)
-{
-	GtkWidget *hbox = data;
-	const char *method = value;
-
-	gtk_widget_set_sensitive(hbox,
-			!strcmp(method, "automatic") ||
-			!strcmp(method, "alsa") ||
-			!strcmp(method, "esd") ||
-			!strcmp(method, "waveform") ||
-			!strcmp(method, "directsound"));
-}
-#endif /* USE_GSTREAMER */
-
 
 static void
 event_toggled(GtkCellRendererToggle *cell, gchar *pth, gpointer data)
@@ -3059,35 +3042,6 @@ select_sound(GtkWidget *button, gpointer
 		GINT_TO_POINTER(sound_row_sel));
 }
 
-#ifdef USE_GSTREAMER
-static gchar *
-prefs_sound_volume_format(GtkScale *scale, gdouble val)
-{
-	if(val < 15) {
-		return g_strdup_printf(_("Quietest"));
-	} else if(val < 30) {
-		return g_strdup_printf(_("Quieter"));
-	} else if(val < 45) {
-		return g_strdup_printf(_("Quiet"));
-	} else if(val < 55) {
-		return g_strdup_printf(_("Normal"));
-	} else if(val < 70) {
-		return g_strdup_printf(_("Loud"));
-	} else if(val < 85) {
-		return g_strdup_printf(_("Louder"));
-	} else {
-		return g_strdup_printf(_("Loudest"));
-	}
-}
-
-static void
-prefs_sound_volume_changed(GtkRange *range)
-{
-	int val = (int)gtk_range_get_value(GTK_RANGE(range));
-	purple_prefs_set_int(PIDGIN_PREFS_ROOT "/sound/volume", val);
-}
-#endif
-
 static void
 prefs_sound_sel(GtkTreeSelection *sel, GtkTreeModel *model)
 {
@@ -3138,9 +3092,6 @@ sound_page(void)
 {
 	GtkWidget *ret;
 	GtkWidget *vbox, *vbox2, *button, *parent, *parent_parent, *parent_parent_parent;
-#ifdef USE_GSTREAMER
-	GtkWidget *sw;
-#endif
 	GtkSizeGroup *sg;
 	GtkTreeIter iter;
 	GtkWidget *event_view;
@@ -3217,25 +3168,6 @@ sound_page(void)
 				_("Always"), PURPLE_SOUND_STATUS_ALWAYS,
 				NULL);
 
-#ifdef USE_GSTREAMER
-	sw = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,
-		0.0, 100.0, 5.0);
-	gtk_range_set_increments(GTK_RANGE(sw), 5.0, 25.0);
-	gtk_range_set_value(GTK_RANGE(sw), purple_prefs_get_int(PIDGIN_PREFS_ROOT "/sound/volume"));
-	g_signal_connect (G_OBJECT (sw), "format-value",
-			  G_CALLBACK (prefs_sound_volume_format),
-			  NULL);
-	g_signal_connect (G_OBJECT (sw), "value-changed",
-			  G_CALLBACK (prefs_sound_volume_changed),
-			  NULL);
-	hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("V_olume:"), NULL, sw, TRUE, NULL);
-
-	purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/sound/method",
-								sound_changed3_cb, hbox);
-	sound_changed3_cb(PIDGIN_PREFS_ROOT "/sound/method", PURPLE_PREF_STRING,
-			  purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), hbox);
-#endif
-
 	gtk_widget_set_sensitive(vbox,
 			strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), "none"));
 	purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/sound/method",
diff --git a/pidgin/gtksound.c b/pidgin/gtksound.c
--- a/pidgin/gtksound.c
+++ b/pidgin/gtksound.c
@@ -311,7 +311,6 @@ pidgin_sound_init(void)
 	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/mute", FALSE);
 	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/command", "");
 	purple_prefs_add_string(PIDGIN_PREFS_ROOT "/sound/method", "automatic");
-	purple_prefs_add_int(PIDGIN_PREFS_ROOT "/sound/volume", 50);
 
 #ifdef USE_GSTREAMER
 	purple_debug_info("sound", "Initializing sound output drivers.\n");
@@ -439,7 +438,6 @@ pidgin_sound_play_file(const char *filen
 {
 	const char *method;
 #ifdef USE_GSTREAMER
-	float volume;
 	char *uri;
 	GstElement *sink = NULL;
 	GstElement *play = NULL;
@@ -522,7 +520,6 @@ pidgin_sound_play_file(const char *filen
 #ifdef USE_GSTREAMER
 	if (gst_init_failed)  /* Perhaps do gdk_beep instead? */
 		return;
-	volume = (float)(CLAMP(purple_prefs_get_int(PIDGIN_PREFS_ROOT "/sound/volume"),0,100)) / 50;
 #ifdef _WIN32
 	if (!strcmp(method, "automatic")) {
 		sink = gst_element_factory_make("directsoundsink", "sink");
@@ -568,7 +565,6 @@ pidgin_sound_play_file(const char *filen
 #endif
 
 	g_object_set(G_OBJECT(play), "uri", uri,
-		                     "volume", volume,
 		                     "audio-sink", sink, NULL);
 
 	bus = gst_pipeline_get_bus(GST_PIPELINE(play));



More information about the Commits mailing list