changeset 26408:ee0282fe3673

Move volume levels for media to the media window.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Fri, 03 Apr 2009 02:25:30 +0000
parents 440e999c27ca
children 7f252e261870
files pidgin/gtkmedia.c pidgin/gtkprefs.c
diffstat 2 files changed, 47 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkmedia.c	Fri Apr 03 00:26:41 2009 +0000
+++ b/pidgin/gtkmedia.c	Fri Apr 03 02:25:30 2009 +0000
@@ -583,6 +583,24 @@
 }
 
 static void
+pidgin_media_input_volume_changed(GtkRange *range, PurpleMedia *media)
+{
+	double val = (double)gtk_range_get_value(GTK_RANGE(range));
+	purple_prefs_set_int("/purple/media/audio/volume/input", val);
+	val /= 10.0;
+	purple_media_set_input_volume(media, NULL, val);
+}
+
+static void
+pidgin_media_output_volume_changed(GtkRange *range, PurpleMedia *media)
+{
+	double val = (double)gtk_range_get_value(GTK_RANGE(range));
+	purple_prefs_set_int("/purple/media/audio/volume/output", val);
+	val /= 10.0;
+	purple_media_set_output_volume(media, NULL, NULL, val);
+}
+
+static void
 pidgin_media_ready_cb(PurpleMedia *media, PidginMedia *gtkmedia, const gchar *sid)
 {
 	PurpleMediaManager *manager = purple_media_get_manager(media);
@@ -695,6 +713,19 @@
 	}
 
 	if (type & PURPLE_MEDIA_RECV_AUDIO) {
+		GtkWidget *volume = gtk_hscale_new_with_range(0.0, 100.0, 5.0);
+		gtk_range_set_increments(GTK_RANGE(volume), 5.0, 25.0);
+		gtk_range_set_value(GTK_RANGE(volume),
+				purple_prefs_get_int(
+				"/purple/media/audio/volume/output"));
+		gtk_scale_set_draw_value(GTK_SCALE(volume), FALSE);
+		g_signal_connect (G_OBJECT(volume), "value-changed",
+				G_CALLBACK(pidgin_media_output_volume_changed),
+				media);
+		gtk_box_pack_end(GTK_BOX(recv_widget),
+				volume, FALSE, FALSE, 0);
+		gtk_widget_show(volume);
+
 		gtkmedia->priv->recv_progress = gtk_progress_bar_new();
 		gtk_widget_set_size_request(gtkmedia->priv->recv_progress, 320, 10);
 		gtk_box_pack_end(GTK_BOX(recv_widget),
@@ -702,7 +733,22 @@
 		gtk_widget_show(gtkmedia->priv->recv_progress);
 	}
 	if (type & PURPLE_MEDIA_SEND_AUDIO) {
-		GstElement *media_src = purple_media_get_src(media, sid);
+		GstElement *media_src;
+		GtkWidget *volume = gtk_hscale_new_with_range(0.0, 100.0, 5.0);
+		gtk_range_set_increments(GTK_RANGE(volume), 5.0, 25.0);
+		gtk_range_set_value(GTK_RANGE(volume),
+				purple_prefs_get_int(
+				"/purple/media/audio/volume/input"));
+				gtk_scale_set_draw_value(volume, FALSE);
+		gtk_scale_set_draw_value(GTK_SCALE(volume), FALSE);
+		g_signal_connect (G_OBJECT(volume), "value-changed",
+				G_CALLBACK (pidgin_media_input_volume_changed),
+				media);
+		gtk_box_pack_end(GTK_BOX(send_widget),
+				volume, FALSE, FALSE, 0);
+		gtk_widget_show(volume);
+
+		media_src = purple_media_get_src(media, sid);
 		gtkmedia->priv->send_level = gst_bin_get_by_name(
 				GST_BIN(media_src), "sendlevel");
 
--- a/pidgin/gtkprefs.c	Fri Apr 03 00:26:41 2009 +0000
+++ b/pidgin/gtkprefs.c	Fri Apr 03 02:25:30 2009 +0000
@@ -2634,34 +2634,6 @@
 	gtk_widget_show_all(hbox);
 }
 
-static void
-prefs_media_input_volume_changed(GtkRange *range)
-{
-	double val = (double)gtk_range_get_value(GTK_RANGE(range));
-	GList *medias = purple_media_manager_get_media(purple_media_manager_get());
-	purple_prefs_set_int("/purple/media/audio/volume/input", val);
-
-	val /= 10.0;
-	for (; medias; medias = g_list_next(medias)) {
-		PurpleMedia *media = PURPLE_MEDIA(medias->data);
-		purple_media_set_input_volume(media, NULL, val);
-	}
-}
-
-static void
-prefs_media_output_volume_changed(GtkRange *range)
-{
-	double val = (double)gtk_range_get_value(GTK_RANGE(range));
-	GList *medias = purple_media_manager_get_media(purple_media_manager_get());
-	purple_prefs_set_int("/purple/media/audio/volume/output", val);
-
-	val /= 10.0;
-	for (; medias; medias = g_list_next(medias)) {
-		PurpleMedia *media = PURPLE_MEDIA(medias->data);
-		purple_media_set_output_volume(media, NULL, NULL, val);
-	}
-}
-
 static GtkWidget *
 media_page()
 {
@@ -2739,38 +2711,6 @@
 	gtk_size_group_add_widget(sg, dd);
 	gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5);
 
-	hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
-	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
-
-	/* Input Volume */
-	sw = gtk_hscale_new_with_range(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("/purple/media/audio/volume/input"));
-	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_media_input_volume_changed),
-			  NULL);
-	pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Volume:"), sg, sw, TRUE, NULL);
-
-	vbox = pidgin_make_frame (ret, _("Audio Output"));
-	gtk_size_group_add_widget(sg2, vbox);
-
-	/* Output Volume */
-	sw = gtk_hscale_new_with_range(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("/purple/media/audio/volume/output"));
-	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_media_output_volume_changed),
-			  NULL);
-	pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Volume:"), sg, sw, TRUE, NULL);
-
 	gtk_widget_show_all(ret);
 
 	return ret;