355
362
gboolean is_default;
357
364
GvcMixerStream *stream;
359
367
gtk_tree_model_get (model, &iter,
361
369
ACTIVE_COLUMN, &toggled,
373
g_debug("Searching for %i in hashtable", id);
374
gpointer card_index_pointer = g_hash_table_lookup(unique_profile_index_to_card_index, GINT_TO_POINTER (id));
375
gpointer profile_index_pointer = g_hash_table_lookup(unique_profile_index_to_profile_index, GINT_TO_POINTER (id));
377
// both can be equal to 0, so can't assert
378
id = GPOINTER_TO_INT (card_index_pointer);
379
guint profile_id = GPOINTER_TO_INT (profile_index_pointer);
381
// returns a GvcMixerCard* from a card index
382
card = gvc_mixer_control_lookup_card_id (dialog->priv->mixer_control, id);
385
g_warning ("Unable to find card for id: %u", id);
389
// get the current profile, for the UI to display
390
GvcMixerCardProfile *current_profile = gvc_mixer_card_get_profile (card);
392
// now we still need to get from the profile ID to the profile
393
// const char* to set the values. To do this we have "id", which
394
// is now our target profile number. This is *not* an index, its
395
// the position of the profile in the list of profiles for that card.
396
const GList* profiles = gvc_mixer_card_get_profiles (card);
398
// cycle trough profiles, and once we hit id iterations, were
399
// pointing to the target profile.
401
while ( profiles != NULL )
403
profiles = profiles->next;
404
if ( i == profile_id )
409
GvcMixerCardProfile* p = profiles->data;
411
//gvc_mixer_card_change_profile (card, p->profile);
364
414
stream = gvc_mixer_control_lookup_stream_id (dialog->priv->mixer_control, id);
365
415
if (stream == NULL) {
366
g_warning ("Unable to find stream for id: %u", id);
416
g_warning ("OUTPUT: Unable to find stream for id: %u", id);
1297
1351
GtkTreeSelection *selection;
1298
1352
GvcMixerCardProfile *profile;
1356
// get data of the model:
1302
1357
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->hw_treeview));
1303
index = gvc_mixer_card_get_index (card);
1304
if (find_item_by_id (GTK_TREE_MODEL (model), index, HW_ID_COLUMN, &iter) == FALSE)
1305
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
1306
profile = gvc_mixer_card_get_profile (card);
1307
g_assert (profile != NULL);
1308
icon = g_themed_icon_new_with_default_fallbacks (gvc_mixer_card_get_icon_name (card));
1309
//FIXME we need the status (default for a profile?) here
1310
gtk_list_store_set (GTK_LIST_STORE (model),
1312
HW_NAME_COLUMN, gvc_mixer_card_get_name (card),
1313
HW_ID_COLUMN, index,
1314
HW_ICON_COLUMN, icon,
1315
HW_PROFILE_COLUMN, profile->profile,
1316
HW_PROFILE_HUMAN_COLUMN, profile->human_profile,
1317
HW_STATUS_COLUMN, profile->status,
1318
HW_SENSITIVE_COLUMN, g_strcmp0 (profile->profile, "off") != 0,
1321
g_object_unref (icon);
1359
// get the index of the card to retrieve info from the model
1360
card_index = gvc_mixer_card_get_index (card);
1363
g_debug("Getting list of profiles NOW!");
1364
const GList * profileList = gvc_mixer_card_get_profiles(card);
1366
g_assert(profileList);
1370
g_debug("Iterating over list of profiles...");
1371
for ( i = 0; profileList != NULL; profileList = profileList->next, i++)
1373
g_debug("itering list: current Name:");// %s, Desc: %s",gvc_mixer_card_get_name (card),profile->human_profile);
1375
if (profileList == NULL) {
1378
profile = profileList->data;
1379
if (profile == NULL) {
1383
// FIXME: we don't want to show input only profiles either,
1384
// here we can regex trough the profile->profile, and if it includes
1385
// "input" but not "output" then don't display it.
1387
// we don't want to show the "off" profile
1388
if (g_strcmp0 (profile->profile, "off") != 0) {
1390
// if the model doesn't contain info on the current index, create a new one
1391
if (find_item_by_id (GTK_TREE_MODEL (model), i , HW_ID_COLUMN, &iter) == FALSE)
1392
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
1394
icon = g_themed_icon_new_with_default_fallbacks (gvc_mixer_card_get_icon_name (card));
1395
//FIXME we need the status (default for a profile?) here
1398
gtk_list_store_set (GTK_LIST_STORE (model),
1400
HW_NAME_COLUMN, profile->human_profile, // top row
1401
HW_ID_COLUMN, card_index,
1402
HW_ICON_COLUMN, icon,
1403
HW_PROFILE_COLUMN, profile->profile,
1404
HW_PROFILE_HUMAN_COLUMN, "", // profile->profile, // bottom row
1405
HW_STATUS_COLUMN, gvc_mixer_card_get_name(card), // center row
1406
HW_SENSITIVE_COLUMN, 1, // always selectable
1409
g_object_unref (icon);
1411
// now that we've inserted this card's profile into the UI, store
1412
// the card index and the profile index, in relation to the unique
1413
// profile index: that way we can work backwards from unique profile
1414
// to the card & profile indexs when the user selects a different output
1415
g_hash_table_insert( unique_profile_index_to_card_index,
1416
GINT_TO_POINTER(unique_profile_index_counter),
1417
GINT_TO_POINTER(card_index));
1419
g_hash_table_insert( unique_profile_index_to_profile_index,
1420
GINT_TO_POINTER(unique_profile_index_counter),
1421
GINT_TO_POINTER(card_index));
1423
unique_profile_index_counter++;
1427
// here we get the selection from the HW (output tab) treeview
1323
1428
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->hw_treeview));
1324
1430
if (gtk_tree_selection_get_selected (selection, NULL, NULL) == FALSE) {
1325
1431
gtk_tree_selection_select_iter (selection, &iter);
1326
} else if (dialog->priv->hw_profile_combo != NULL) {
1433
else if (dialog->priv->hw_profile_combo != NULL)
1327
1435
GvcMixerCard *selected;
1329
1437
/* Set the current profile if it changed for the selected card */
1330
1438
selected = g_object_get_data (G_OBJECT (dialog->priv->hw_profile_combo), "card");
1331
if (gvc_mixer_card_get_index (selected) == gvc_mixer_card_get_index (card)) {
1440
if (gvc_mixer_card_get_index (selected) == gvc_mixer_card_get_index (card))
1332
1442
gvc_combo_box_set_active (GVC_COMBO_BOX (dialog->priv->hw_profile_combo),
1333
1443
profile->profile);
1334
1445
g_object_set (G_OBJECT (dialog->priv->hw_profile_combo),
1335
1446
"show-button", profile->n_sinks == 1,
1446
1560
ID_COLUMN, &id,
1447
1561
ACTIVE_COLUMN, &toggled,
1564
GvcMixerStream *streams;
1565
GvcMixerSink *sink_stream;
1567
// get a list of sinks on the system
1568
const GSList *sinkList = gvc_mixer_control_get_streams(dialog->priv->mixer_control);
1570
g_warning("on_output_selection_changed() id = %i", id);
1572
while (sinkList != NULL)
1574
streams = sinkList->data;
1575
g_warning("AllStreams index: %i, CardIndex: %i, Name: %s",
1576
gvc_mixer_stream_get_index(streams),
1577
gvc_mixer_stream_get_card_index(streams),
1578
gvc_mixer_stream_get_name(streams) );
1580
if ( gvc_mixer_stream_get_index(streams) == 0 &&
1581
gvc_mixer_stream_get_card_index(streams) == 0 )
1583
gvc_mixer_control_set_default_sink (dialog->priv->mixer_control, streams);
1586
sinkList = sinkList->next;
1452
1592
GvcMixerStream *stream;
1454
1595
g_debug ("Default output selected: %u", id);
1455
1596
stream = gvc_mixer_control_lookup_stream_id (dialog->priv->mixer_control, id);
1456
1597
if (stream == NULL) {
1457
g_warning ("Unable to find stream for id: %u", id);
1598
g_warning ("onOutputSelectionChanged():Unable to find stream for id: %u", id);
1461
gvc_mixer_control_set_default_sink (dialog->priv->mixer_control, stream);
1634
1780
gtk_tree_model_get (model, &iter,
1635
1781
HW_ID_COLUMN, &id,
1637
card = gvc_mixer_control_lookup_card_id (dialog->priv->mixer_control, id);
1639
g_warning ("Unable to find card for id: %u", id);
1643
current_profile = gvc_mixer_card_get_profile (card);
1644
profiles = gvc_mixer_card_get_profiles (card);
1645
1784
dialog->priv->hw_profile_combo = gvc_combo_box_new (_("_Profile:"));
1646
1785
g_object_set (G_OBJECT (dialog->priv->hw_profile_combo), "button-label", _("_Test Speakers"), NULL);
1647
1787
gvc_combo_box_set_profiles (GVC_COMBO_BOX (dialog->priv->hw_profile_combo), profiles);
1648
gvc_combo_box_set_active (GVC_COMBO_BOX (dialog->priv->hw_profile_combo), current_profile->profile);
1788
//gvc_combo_box_set_active (GVC_COMBO_BOX (dialog->priv->hw_profile_combo), current_profile->profile);
1650
1790
gtk_box_pack_start (GTK_BOX (dialog->priv->hw_settings_box),
1651
1791
dialog->priv->hw_profile_combo,