diff --git a/gtk/incall_view.c b/gtk/incall_view.c index 9aaefff91..9678c3933 100644 --- a/gtk/incall_view.c +++ b/gtk/incall_view.c @@ -29,7 +29,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "linphone.h" - gboolean linphone_gtk_use_in_call_view(){ static int val=-1; if (val==-1) val=linphone_gtk_get_ui_config_int("use_incall_view",1); @@ -360,10 +359,49 @@ void linphone_gtk_enable_video_button(LinphoneCall *call, gboolean sensitive, gb gtk_widget_set_visible(GTK_WIDGET(button),sensitive); } + +typedef enum { VOLUME_CTRL_PLAYBACK, VOLUME_CTRL_RECORD } VolumeControlType; + +static void volume_control_value_changed(GtkScaleButton *button, gdouble value, gpointer user_data) { + LinphoneCall *call = (LinphoneCall *)g_object_get_data(G_OBJECT(button), "call"); + VolumeControlType type = (VolumeControlType)g_object_get_data(G_OBJECT(button), "type"); + + if(type == VOLUME_CTRL_PLAYBACK) { + linphone_call_set_speaker_volume_gain(call, value); + } else if(type == VOLUME_CTRL_RECORD) { + linphone_call_set_microphone_volume_gain(call, value); + } +} + +static void volume_control_button_update_value(GtkWidget *widget) { + LinphoneCall *call = (LinphoneCall *)g_object_get_data(G_OBJECT(widget), "call"); + VolumeControlType type = (VolumeControlType)g_object_get_data(G_OBJECT(widget), "type"); + + if(type == VOLUME_CTRL_PLAYBACK) { + gtk_scale_button_set_value(GTK_SCALE_BUTTON(widget), linphone_call_get_speaker_volume_gain(call)); + } else if(type == VOLUME_CTRL_RECORD) { + gtk_scale_button_set_value(GTK_SCALE_BUTTON(widget), linphone_call_get_microphone_volume_gain(call)); + } +} + +static gboolean volume_control_button_enter_event_handler(GtkWidget *widget) { + volume_control_button_update_value(widget); + return FALSE; +} + +static void volume_control_init(GtkWidget *vol_ctrl, VolumeControlType type, LinphoneCall *call) { + g_object_set_data(G_OBJECT(vol_ctrl), "call", call); + g_object_set_data(G_OBJECT(vol_ctrl), "type", (gpointer)type); + g_signal_connect(G_OBJECT(vol_ctrl), "enter-notify-event", G_CALLBACK(volume_control_button_enter_event_handler), NULL); + g_signal_connect(G_OBJECT(vol_ctrl), "value-changed", G_CALLBACK(volume_control_value_changed), NULL); +} + void linphone_gtk_create_in_call_view(LinphoneCall *call){ GtkWidget *call_view=linphone_gtk_create_widget("in_call_frame"); GtkWidget *main_window=linphone_gtk_get_main_window (); GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch"); + GtkWidget *spk_vol_ctrl = linphone_gtk_get_widget(call_view, "incall_spk_vol_ctrl_button"); + GtkWidget *mic_vol_ctrl = linphone_gtk_get_widget(call_view, "incall_mic_vol_ctrl_button"); static int call_index=1; int idx; GtkWidget *transfer; @@ -407,6 +445,9 @@ void linphone_gtk_create_in_call_view(LinphoneCall *call){ gtk_button_set_image(GTK_BUTTON(button),image); gtk_widget_show(image); g_signal_connect_swapped(G_OBJECT(linphone_gtk_get_widget(call_view,"quality_indicator")),"button-press-event",(GCallback)linphone_gtk_show_call_stats,call); + + volume_control_init(spk_vol_ctrl, VOLUME_CTRL_PLAYBACK, call); + volume_control_init(mic_vol_ctrl, VOLUME_CTRL_RECORD, call); } static void video_button_clicked(GtkWidget *button, LinphoneCall *call){ @@ -637,55 +678,15 @@ void linphone_gtk_uninit_audio_meter(GtkWidget *w){ } } -typedef enum { VOLUME_CTRL_PLAYBACK, VOLUME_CTRL_RECORD } VolumeControlType; - -static void volume_control_value_changed(GtkScaleButton *button, gdouble value, gpointer user_data) { - LinphoneCall *call = (LinphoneCall *)g_object_get_data(G_OBJECT(button), "call"); - VolumeControlType type = (VolumeControlType)g_object_get_data(G_OBJECT(button), "type"); - - if(type == VOLUME_CTRL_PLAYBACK) { - linphone_call_set_speaker_volume_gain(call, value); - } else if(type == VOLUME_CTRL_RECORD) { - linphone_call_set_microphone_volume_gain(call, value); - } -} - -static void volume_control_button_update_value(GtkWidget *widget) { - LinphoneCall *call = (LinphoneCall *)g_object_get_data(G_OBJECT(widget), "call"); - VolumeControlType type = (VolumeControlType)g_object_get_data(G_OBJECT(widget), "type"); - - if(type == VOLUME_CTRL_PLAYBACK) { - gtk_scale_button_set_value(GTK_SCALE_BUTTON(widget), linphone_call_get_speaker_volume_gain(call)); - } else if(type == VOLUME_CTRL_RECORD) { - gtk_scale_button_set_value(GTK_SCALE_BUTTON(widget), linphone_call_get_microphone_volume_gain(call)); - } -} - -static gboolean volume_control_button_enter_event_handler(GtkWidget *widget) { - volume_control_button_update_value(widget); - return FALSE; -} - -static void volume_control_init(GtkWidget *vol_ctrl, VolumeControlType type, LinphoneCall *call) { - g_object_set_data(G_OBJECT(vol_ctrl), "call", call); - g_object_set_data(G_OBJECT(vol_ctrl), "type", (gpointer)type); - g_signal_connect(G_OBJECT(vol_ctrl), "enter-notify-event", G_CALLBACK(volume_control_button_enter_event_handler), NULL); - g_signal_connect(G_OBJECT(vol_ctrl), "value-changed", G_CALLBACK(volume_control_value_changed), NULL); -} - void linphone_gtk_in_call_view_enable_audio_view(LinphoneCall *call, gboolean val){ GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call); GtkWidget *audio_view=linphone_gtk_get_widget(callview,"incall_audioview"); GtkWidget *mic_level=linphone_gtk_get_widget(callview,"mic_audiolevel"); GtkWidget *spk_level=linphone_gtk_get_widget(callview,"spk_audiolevel"); - GtkWidget *spk_vol_ctrl = linphone_gtk_get_widget(callview, "incall_spk_vol_ctrl_button"); - GtkWidget *mic_vol_ctrl = linphone_gtk_get_widget(callview, "incall_mic_vol_ctrl_button"); if (val){ linphone_gtk_init_audio_meter(mic_level,(get_volume_t)linphone_call_get_record_volume,call); linphone_gtk_init_audio_meter(spk_level,(get_volume_t)linphone_call_get_play_volume,call); - volume_control_init(spk_vol_ctrl, VOLUME_CTRL_PLAYBACK, call); - volume_control_init(mic_vol_ctrl, VOLUME_CTRL_RECORD, call); gtk_widget_show_all(audio_view); }else{ linphone_gtk_uninit_audio_meter(mic_level);