~ubuntu-branches/ubuntu/quantal/sflphone/quantal

« back to all changes in this revision

Viewing changes to gnome/src/config/audioconf.c

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-05-27 08:22:22 UTC
  • mfrom: (4.1.15 sid)
  • Revision ID: package-import@ubuntu.com-20120527082222-fs3ojksqvt0ol6rl
Tags: 1.1.0-2
* Drop unsupported CELT codec (Build-Depends)
  - Fixes "Spurious build dependency on libcelt-dev" (Closes: #674644)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 */
30
30
 
31
31
#include <glib/gi18n.h>
 
32
#include "gtk2_wrappers.h"
 
33
#include "str_utils.h"
32
34
#include "audioconf.h"
33
35
#include "utils.h"
34
36
#include "logger.h"
69
71
/**
70
72
 * Fills the tree list with supported codecs
71
73
 */
72
 
static void preferences_dialog_fill_codec_list(account_t *a)
 
74
static void
 
75
preferences_dialog_fill_codec_list(const account_t *account)
73
76
{
74
77
    // Get model of view and clear it
75
78
    GtkListStore *codecStore = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(codecTreeView)));
76
79
    gtk_list_store_clear(codecStore);
77
80
 
78
 
    GQueue *current = a ? a->codecs : get_system_codec_list();
 
81
    GQueue *current = account ? account->codecs : get_system_codec_list();
79
82
 
80
 
    if (!a) DEBUG("Using system codec list");
 
83
    if (!account) DEBUG("Using system codec list");
81
84
 
82
85
    // Insert codecs
83
86
    for (guint i = 0; i < g_queue_get_length(current); i++) {
90
93
            gtk_list_store_set(codecStore, &iter,
91
94
                               COLUMN_CODEC_ACTIVE, c->is_active,
92
95
                               COLUMN_CODEC_NAME, c->name,
93
 
                               COLUMN_CODEC_FREQUENCY,  g_strdup_printf("%f kHz", c->sample_rate * 0.001),
 
96
                               COLUMN_CODEC_FREQUENCY, g_strdup_printf("%d kHz", (gint)(c->sample_rate * 0.001)),
94
97
                               COLUMN_CODEC_BITRATE, g_strdup_printf("%.1f kbps", c->_bitrate),
95
98
                               -1);
96
99
        }
181
184
    } while (gtk_tree_model_iter_next(model, &iter));
182
185
 
183
186
    // No index was found, select first one
184
 
    WARN("Warning : No active output device found");
 
187
    WARN("No active output device found");
185
188
    gtk_combo_box_set_active(GTK_COMBO_BOX(output), 0);
186
189
}
187
190
 
271
274
void
272
275
update_device_widget(gchar *pluginName)
273
276
{
274
 
    if (g_strcasecmp(pluginName, "default") == 0) {
 
277
    if (utf8_case_equal(pluginName, "default")) {
275
278
        gtk_widget_set_sensitive(output, FALSE);
276
279
        gtk_widget_set_sensitive(input, FALSE);
277
280
        gtk_widget_set_sensitive(ringtone, FALSE);
314
317
    do {
315
318
        gtk_tree_model_get(model, &iter, 0, &pluginname, -1);
316
319
 
317
 
        if (g_strcasecmp(tmp, pluginname) == 0) {
 
320
        if (utf8_case_equal(tmp, pluginname)) {
318
321
            // Set current iteration the active one
319
322
            gtk_combo_box_set_active_iter(GTK_COMBO_BOX(plugin), &iter);
320
323
            return;
404
407
    account_t *acc = (account_t*) data;
405
408
 
406
409
    if (!acc) {
407
 
        ERROR("Aie, no account selected");
 
410
        ERROR("no account selected");
408
411
        return;
409
412
    }
410
413
 
416
419
                       COLUMN_CODEC_NAME, &name, COLUMN_CODEC_FREQUENCY,
417
420
                       &srate, -1);
418
421
 
419
 
    DEBUG("%s, %s\n", name, srate);
420
 
    DEBUG("%i\n", g_queue_get_length(acc->codecs));
 
422
    DEBUG("Selected Codec: %s, %s", name, srate);
421
423
 
422
424
    codec_t* codec;
423
425
 
424
 
    if ((g_strcasecmp(name,"speex") == 0) && (g_strcasecmp(srate,"8 kHz") == 0))
 
426
    if (utf8_case_equal(name,"speex") && utf8_case_equal(srate,"8 kHz"))
425
427
        codec = codec_list_get_by_payload((gconstpointer) 110, acc->codecs);
426
 
    else if ((g_strcasecmp(name,"speex") ==0) && (g_strcasecmp(srate,"16 kHz") ==0))
 
428
    else if (utf8_case_equal(name,"speex") && utf8_case_equal(srate,"16 kHz"))
427
429
        codec = codec_list_get_by_payload((gconstpointer) 111, acc->codecs);
428
 
    else if ((g_strcasecmp(name,"speex") ==0) && (g_strcasecmp(srate,"32 kHz") ==0))
 
430
    else if (utf8_case_equal(name,"speex") && utf8_case_equal(srate, "32 kHz"))
429
431
        codec = codec_list_get_by_payload((gconstpointer) 112, acc->codecs);
430
432
    else
431
433
        codec = codec_list_get_by_name((gconstpointer) name, acc->codecs);
516
518
    codec_move(FALSE, data);
517
519
}
518
520
 
519
 
GtkWidget* audiocodecs_box(account_t *a)
 
521
GtkWidget* audiocodecs_box(const account_t *account)
520
522
{
521
523
    GtkWidget *audiocodecs_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
522
524
    gtk_container_set_border_width(GTK_CONTAINER(audiocodecs_hbox), 10);
528
530
    gtk_box_pack_start(GTK_BOX(audiocodecs_hbox), scrolledWindow, TRUE, TRUE, 0);
529
531
    GtkListStore *codecStore = gtk_list_store_new(CODEC_COLUMN_COUNT,
530
532
                               G_TYPE_BOOLEAN, /* Active */
531
 
                               G_TYPE_STRING,    /* Name */
532
 
                               G_TYPE_STRING,    /* Frequency */
533
 
                               G_TYPE_STRING,    /* Bit rate */
534
 
                               G_TYPE_STRING     /* Bandwith */);
 
533
                               G_TYPE_STRING,  /* Name */
 
534
                               G_TYPE_STRING,  /* Frequency */
 
535
                               G_TYPE_STRING,  /* Bit rate */
 
536
                               G_TYPE_STRING   /* Bandwidth */
 
537
                               );
535
538
 
536
539
    // Create codec tree view with list store
537
540
    codecTreeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(codecStore));
547
550
    gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn);
548
551
 
549
552
    // Toggle codec active property on clicked
550
 
    g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(codec_active_toggled),(gpointer) a);
 
553
    g_signal_connect(G_OBJECT(renderer), "toggled",
 
554
                     G_CALLBACK(codec_active_toggled), (gpointer) account);
551
555
 
552
556
    // Name column
553
557
    renderer = gtk_cell_renderer_text_new();
575
579
    codecMoveUpButton = gtk_button_new_from_stock(GTK_STOCK_GO_UP);
576
580
    gtk_widget_set_sensitive(GTK_WIDGET(codecMoveUpButton), FALSE);
577
581
    gtk_box_pack_start(GTK_BOX(buttonBox), codecMoveUpButton, FALSE, FALSE, 0);
578
 
    g_signal_connect(G_OBJECT(codecMoveUpButton), "clicked", G_CALLBACK(codec_move_up), a);
 
582
    g_signal_connect(G_OBJECT(codecMoveUpButton), "clicked",
 
583
                     G_CALLBACK(codec_move_up), (gpointer) account);
579
584
 
580
585
    codecMoveDownButton = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN);
581
586
    gtk_widget_set_sensitive(GTK_WIDGET(codecMoveDownButton), FALSE);
582
587
    gtk_box_pack_start(GTK_BOX(buttonBox), codecMoveDownButton, FALSE, FALSE, 0);
583
 
    g_signal_connect(G_OBJECT(codecMoveDownButton), "clicked", G_CALLBACK(codec_move_down), a);
 
588
    g_signal_connect(G_OBJECT(codecMoveDownButton), "clicked",
 
589
                     G_CALLBACK(codec_move_down), (gpointer) account);
584
590
 
585
 
    preferences_dialog_fill_codec_list(a);
 
591
    preferences_dialog_fill_codec_list(account);
586
592
 
587
593
    return audiocodecs_hbox;
588
594
}
610
616
 
611
617
        gtk_action_set_sensitive(volumeToggle_, FALSE);
612
618
    }
 
619
 
613
620
}
614
621
 
615
622
void
670
677
    GtkWidget *info_bar = gnome_info_bar(message, GTK_MESSAGE_INFO);
671
678
    gtk_table_attach(GTK_TABLE(table), info_bar, 1, 3, 1, 2, GTK_FILL, GTK_SHRINK, 10, 10);
672
679
 
673
 
    DEBUG("Audio: Configuration plugin");
 
680
    DEBUG("Configuration plugin");
674
681
    GtkWidget *label = gtk_label_new(_("ALSA plugin"));
675
682
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
676
683
    gtk_table_attach(GTK_TABLE(table), label, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
692
699
 
693
700
    // Device : Output device
694
701
    // Create title label
695
 
    DEBUG("Audio: Configuration output");
 
702
    DEBUG("Configuration output");
696
703
    label = gtk_label_new(_("Output"));
697
704
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
698
705
    gtk_table_attach(GTK_TABLE(table), label, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
714
721
 
715
722
    // Device : Input device
716
723
    // Create title label
717
 
    DEBUG("Audio: Configuration input");
 
724
    DEBUG("Configuration input");
718
725
    label = gtk_label_new(_("Input"));
719
726
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
720
727
    gtk_table_attach(GTK_TABLE(table), label, 1, 2, 4, 5, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
735
742
    gtk_table_attach(GTK_TABLE(table), input, 2, 3, 4, 5, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
736
743
    gtk_widget_show(input);
737
744
 
738
 
    DEBUG("Audio: Configuration rintgtone");
 
745
    DEBUG("Configuration rintgtone");
739
746
    label = gtk_label_new(_("Ringtone"));
740
747
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
741
748
    gtk_table_attach(GTK_TABLE(table), label, 1, 2, 5, 6, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
820
827
    GtkWidget *folderChooser = gtk_file_chooser_button_new(_("Select a folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
821
828
    /* Get the path where to save audio files */
822
829
    gchar *recordingPath = dbus_get_record_path();
823
 
    DEBUG("AudioConf: Load recording path %s", recordingPath);
 
830
    DEBUG("Load recording path %s", recordingPath);
824
831
    gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(folderChooser), recordingPath);
825
832
    g_free(recordingPath);
826
833