sound: Listen to signals from GvcMixerControl only in sound panel
We should only listen to "active-input-update" and "active-output-update" in one place, and then update the combo box from there. This way we can block our own signal handler for input/output device changes on the combo box, which we'll do in the next commit.
This commit is contained in:
parent
4de79c9694
commit
2152899354
3 changed files with 49 additions and 50 deletions
|
@ -25,9 +25,6 @@ struct _CcDeviceComboBox
|
||||||
GtkListStore *device_model;
|
GtkListStore *device_model;
|
||||||
|
|
||||||
GvcMixerControl *mixer_control;
|
GvcMixerControl *mixer_control;
|
||||||
guint added_handler_id;
|
|
||||||
guint removed_handler_id;
|
|
||||||
guint active_update_handler_id;
|
|
||||||
gboolean is_output;
|
gboolean is_output;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,8 +32,8 @@ G_DEFINE_TYPE (CcDeviceComboBox, cc_device_combo_box, GTK_TYPE_COMBO_BOX)
|
||||||
|
|
||||||
static gboolean get_iter (CcDeviceComboBox *self, guint id, GtkTreeIter *iter);
|
static gboolean get_iter (CcDeviceComboBox *self, guint id, GtkTreeIter *iter);
|
||||||
|
|
||||||
static void
|
void
|
||||||
device_added_cb (CcDeviceComboBox *self,
|
cc_device_combo_box_device_added (CcDeviceComboBox *self,
|
||||||
guint id)
|
guint id)
|
||||||
{
|
{
|
||||||
GvcMixerUIDevice *device = NULL;
|
GvcMixerUIDevice *device = NULL;
|
||||||
|
@ -97,8 +94,8 @@ get_iter (CcDeviceComboBox *self,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
device_removed_cb (CcDeviceComboBox *self,
|
cc_device_combo_box_device_removed (CcDeviceComboBox *self,
|
||||||
guint id)
|
guint id)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
@ -107,8 +104,8 @@ device_removed_cb (CcDeviceComboBox *self,
|
||||||
gtk_list_store_remove (self->device_model, &iter);
|
gtk_list_store_remove (self->device_model, &iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
active_device_update_cb (CcDeviceComboBox *self,
|
cc_device_combo_box_active_device_changed (CcDeviceComboBox *self,
|
||||||
guint id)
|
guint id)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
@ -153,47 +150,12 @@ cc_device_combo_box_set_mixer_control (CcDeviceComboBox *self,
|
||||||
GvcMixerControl *mixer_control,
|
GvcMixerControl *mixer_control,
|
||||||
gboolean is_output)
|
gboolean is_output)
|
||||||
{
|
{
|
||||||
const gchar *added_signal, *removed_signal, *active_update_signal;
|
|
||||||
g_return_if_fail (CC_IS_DEVICE_COMBO_BOX (self));
|
g_return_if_fail (CC_IS_DEVICE_COMBO_BOX (self));
|
||||||
|
|
||||||
if (self->mixer_control != NULL)
|
|
||||||
{
|
|
||||||
g_signal_handler_disconnect (self->mixer_control, self->added_handler_id);
|
|
||||||
self->added_handler_id = 0;
|
|
||||||
g_signal_handler_disconnect (self->mixer_control, self->removed_handler_id);
|
|
||||||
self->removed_handler_id = 0;
|
|
||||||
g_signal_handler_disconnect (self->mixer_control, self->active_update_handler_id);
|
|
||||||
self->active_update_handler_id = 0;
|
|
||||||
}
|
|
||||||
g_clear_object (&self->mixer_control);
|
g_clear_object (&self->mixer_control);
|
||||||
|
|
||||||
self->mixer_control = g_object_ref (mixer_control);
|
self->mixer_control = g_object_ref (mixer_control);
|
||||||
self->is_output = is_output;
|
self->is_output = is_output;
|
||||||
if (is_output)
|
|
||||||
{
|
|
||||||
added_signal = "output-added";
|
|
||||||
removed_signal = "output-removed";
|
|
||||||
active_update_signal = "active-output-update";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
added_signal = "input-added";
|
|
||||||
removed_signal = "input-removed";
|
|
||||||
active_update_signal = "active-input-update";
|
|
||||||
}
|
|
||||||
|
|
||||||
self->added_handler_id = g_signal_connect_object (self->mixer_control,
|
|
||||||
added_signal,
|
|
||||||
G_CALLBACK (device_added_cb),
|
|
||||||
self, G_CONNECT_SWAPPED);
|
|
||||||
self->removed_handler_id = g_signal_connect_object (self->mixer_control,
|
|
||||||
removed_signal,
|
|
||||||
G_CALLBACK (device_removed_cb),
|
|
||||||
self, G_CONNECT_SWAPPED);
|
|
||||||
self->active_update_handler_id = g_signal_connect_object (self->mixer_control,
|
|
||||||
active_update_signal,
|
|
||||||
G_CALLBACK (active_device_update_cb),
|
|
||||||
self, G_CONNECT_SWAPPED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GvcMixerUIDevice *
|
GvcMixerUIDevice *
|
||||||
|
|
|
@ -32,4 +32,13 @@ void cc_device_combo_box_set_mixer_control (CcDeviceComboBox *
|
||||||
|
|
||||||
GvcMixerUIDevice *cc_device_combo_box_get_device (CcDeviceComboBox *combo_box);
|
GvcMixerUIDevice *cc_device_combo_box_get_device (CcDeviceComboBox *combo_box);
|
||||||
|
|
||||||
|
void cc_device_combo_box_device_added (CcDeviceComboBox *self,
|
||||||
|
guint id);
|
||||||
|
|
||||||
|
void cc_device_combo_box_device_removed (CcDeviceComboBox *self,
|
||||||
|
guint id);
|
||||||
|
|
||||||
|
void cc_device_combo_box_active_device_changed (CcDeviceComboBox *self,
|
||||||
|
guint id);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -176,6 +176,8 @@ output_device_update_cb (CcSoundPanel *self,
|
||||||
gboolean has_multi_profiles;
|
gboolean has_multi_profiles;
|
||||||
GvcMixerStream *stream = NULL;
|
GvcMixerStream *stream = NULL;
|
||||||
|
|
||||||
|
cc_device_combo_box_active_device_changed (self->output_device_combo_box, id);
|
||||||
|
|
||||||
device = cc_device_combo_box_get_device (self->output_device_combo_box);
|
device = cc_device_combo_box_get_device (self->output_device_combo_box);
|
||||||
cc_profile_combo_box_set_device (self->output_profile_combo_box, self->mixer_control, device);
|
cc_profile_combo_box_set_device (self->output_profile_combo_box, self->mixer_control, device);
|
||||||
has_multi_profiles = (cc_profile_combo_box_get_profile_count (self->output_profile_combo_box) > 1);
|
has_multi_profiles = (cc_profile_combo_box_get_profile_count (self->output_profile_combo_box) > 1);
|
||||||
|
@ -196,6 +198,8 @@ input_device_update_cb (CcSoundPanel *self,
|
||||||
gboolean has_multi_profiles;
|
gboolean has_multi_profiles;
|
||||||
GvcMixerStream *stream = NULL;
|
GvcMixerStream *stream = NULL;
|
||||||
|
|
||||||
|
cc_device_combo_box_active_device_changed (self->input_device_combo_box, id);
|
||||||
|
|
||||||
device = cc_device_combo_box_get_device (self->input_device_combo_box);
|
device = cc_device_combo_box_get_device (self->input_device_combo_box);
|
||||||
cc_profile_combo_box_set_device (self->input_profile_combo_box, self->mixer_control, device);
|
cc_profile_combo_box_set_device (self->input_profile_combo_box, self->mixer_control, device);
|
||||||
has_multi_profiles = (cc_profile_combo_box_get_profile_count (self->input_profile_combo_box) > 1);
|
has_multi_profiles = (cc_profile_combo_box_get_profile_count (self->input_profile_combo_box) > 1);
|
||||||
|
@ -354,10 +358,16 @@ cc_sound_panel_init (CcSoundPanel *self)
|
||||||
cc_subwoofer_slider_set_mixer_control (self->subwoofer_slider, self->mixer_control);
|
cc_subwoofer_slider_set_mixer_control (self->subwoofer_slider, self->mixer_control);
|
||||||
cc_device_combo_box_set_mixer_control (self->input_device_combo_box, self->mixer_control, FALSE);
|
cc_device_combo_box_set_mixer_control (self->input_device_combo_box, self->mixer_control, FALSE);
|
||||||
cc_device_combo_box_set_mixer_control (self->output_device_combo_box, self->mixer_control, TRUE);
|
cc_device_combo_box_set_mixer_control (self->output_device_combo_box, self->mixer_control, TRUE);
|
||||||
|
|
||||||
g_signal_connect_object (self->mixer_control,
|
g_signal_connect_object (self->mixer_control,
|
||||||
"active-output-update",
|
"input-added",
|
||||||
G_CALLBACK (output_device_update_cb),
|
G_CALLBACK (cc_device_combo_box_device_added),
|
||||||
self,
|
self->input_device_combo_box,
|
||||||
|
G_CONNECT_SWAPPED);
|
||||||
|
g_signal_connect_object (self->mixer_control,
|
||||||
|
"input-removed",
|
||||||
|
G_CALLBACK (cc_device_combo_box_device_removed),
|
||||||
|
self->input_device_combo_box,
|
||||||
G_CONNECT_SWAPPED);
|
G_CONNECT_SWAPPED);
|
||||||
g_signal_connect_object (self->mixer_control,
|
g_signal_connect_object (self->mixer_control,
|
||||||
"active-input-update",
|
"active-input-update",
|
||||||
|
@ -365,5 +375,23 @@ cc_sound_panel_init (CcSoundPanel *self)
|
||||||
self,
|
self,
|
||||||
G_CONNECT_SWAPPED);
|
G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
|
g_signal_connect_object (self->mixer_control,
|
||||||
|
"output-added",
|
||||||
|
G_CALLBACK (cc_device_combo_box_device_added),
|
||||||
|
self->output_device_combo_box,
|
||||||
|
G_CONNECT_SWAPPED);
|
||||||
|
g_signal_connect_object (self->mixer_control,
|
||||||
|
"output-removed",
|
||||||
|
G_CALLBACK (cc_device_combo_box_device_removed),
|
||||||
|
self->output_device_combo_box,
|
||||||
|
G_CONNECT_SWAPPED);
|
||||||
|
g_signal_connect_object (self->mixer_control,
|
||||||
|
"active-output-update",
|
||||||
|
G_CALLBACK (output_device_update_cb),
|
||||||
|
self,
|
||||||
|
G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
|
gvc_mixer_control_open (self->mixer_control);
|
||||||
|
|
||||||
update_alert_sound_label (self);
|
update_alert_sound_label (self);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue