📄 audio_dialog.cpp
字号:
GtkWidget *temp; temp = lookup_widget(dialog, "AudioProfileName"); const char *name = gtk_entry_get_text(GTK_ENTRY(temp)); if (name == NULL || *name == '\0') return false; profile->SetConfigName(name); if (AVFlow->m_audio_profile_list->FindProfile(name) != NULL) { return false; } AVFlow->m_audio_profile_list->AddEntryToList(profile); return true;}// This is called when the audio profile dialog is changedstatic void on_AudioProfileDialog_response (GtkWidget *dialog, gint response_id, gpointer user_data){ CAudioProfile *profile = (CAudioProfile *)user_data; CAudioProfile *pass_profile = NULL; GtkWidget *temp; bool do_copy = true; if (response_id == GTK_RESPONSE_OK) { // we had created a profile with no attachments if we started as Add if (profile->GetName() == NULL) { do_copy = CreateNewProfile(dialog, profile); if (do_copy == false) { delete profile; } else { pass_profile = profile; } } if (do_copy) { // read the settings out fo the dialog temp = lookup_widget(dialog, "AudioProfileEncoder"); uint index = gtk_option_menu_get_history(GTK_OPTION_MENU(temp)); profile->SetStringValue(CFG_AUDIO_ENCODER, audio_encoder_table[index]->audio_encoder); profile->SetStringValue(CFG_AUDIO_ENCODING, audio_encoder_table[index]->audio_encoding); temp = lookup_widget(dialog, "ChannelMenu"); profile->SetIntegerValue(CFG_AUDIO_CHANNELS, gtk_option_menu_get_history(GTK_OPTION_MENU(temp)) + 1); temp = lookup_widget(dialog, "AudioBitRateMenu"); profile->SetIntegerValue(CFG_AUDIO_BIT_RATE, bitRateValues[gtk_option_menu_get_history(GTK_OPTION_MENU(temp))]); temp = lookup_widget(dialog, "SampleRateMenu"); profile->SetIntegerValue(CFG_AUDIO_SAMPLE_RATE, samplingRateValues[gtk_option_menu_get_history(GTK_OPTION_MENU(temp))]); profile->Update(); profile->WriteToFile(); // set up profile } } else { if (profile->GetName() == NULL) { delete profile; } } if (pass_profile == NULL) { debug_message("No pass profile"); } else { debug_message("pass profile %s", pass_profile->GetName()); } // tell the mainwindow what we've done. If they said "Add", we select // the new profile. OnAudioProfileFinished(pass_profile); gtk_widget_destroy(GTK_WIDGET(dialog));}void CreateAudioProfileDialog (CAudioProfile *profile){ GtkWidget *dialog_vbox5; GtkWidget *AudioProfileTable; GtkWidget *label96; GtkWidget *ChannelMenu; GtkWidget *SampleRateMenu; GtkWidget *AudioBitRateMenu; GtkWidget *AudioEncoderSettingsButton; GtkWidget *alignment19; GtkWidget *hbox73; GtkWidget *image19; GtkWidget *label146; GtkWidget *AudioProfileEncoder; GtkWidget *label98; GtkWidget *label99; GtkWidget *label100; GtkWidget *label101; GtkWidget *label103; GtkWidget *AudioProfileName; GtkWidget *dialog_action_area4; GtkWidget *cancelbutton4; GtkWidget *AudioProfileOk; GtkTooltips *tooltips; bool new_profile = profile == NULL; if (new_profile) { profile = new CAudioProfile(NULL, NULL); profile->LoadConfigVariables(); profile->Initialize(false); } tooltips = gtk_tooltips_new(); AudioProfileDialog = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(AudioProfileDialog), _("Audio Profile Settings")); gtk_window_set_modal(GTK_WINDOW(AudioProfileDialog), TRUE); gtk_window_set_transient_for(GTK_WINDOW(AudioProfileDialog), GTK_WINDOW(MainWindow)); dialog_vbox5 = GTK_DIALOG(AudioProfileDialog)->vbox; gtk_widget_show(dialog_vbox5); AudioProfileTable = gtk_table_new(7, 2, FALSE); gtk_widget_show(AudioProfileTable); gtk_box_pack_start(GTK_BOX(dialog_vbox5), AudioProfileTable, TRUE, TRUE, 0); gtk_table_set_row_spacings(GTK_TABLE(AudioProfileTable), 3); label96 = gtk_label_new(_("Audio Profile")); gtk_widget_show(label96); gtk_table_attach(GTK_TABLE(AudioProfileTable), label96, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 8); gtk_misc_set_alignment(GTK_MISC(label96), 0, 0.5); ChannelMenu = gtk_option_menu_new(); gtk_widget_show(ChannelMenu); gtk_table_attach(GTK_TABLE(AudioProfileTable), ChannelMenu, 1, 2, 2, 3, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_tooltips_set_tip(tooltips, ChannelMenu, _("Number of Channels"), NULL); SampleRateMenu = gtk_option_menu_new(); gtk_widget_show(SampleRateMenu); gtk_table_attach(GTK_TABLE(AudioProfileTable), SampleRateMenu, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_tooltips_set_tip(tooltips, SampleRateMenu, _("Output Sample Rate"), NULL); AudioBitRateMenu = gtk_option_menu_new(); gtk_widget_show(AudioBitRateMenu); gtk_table_attach(GTK_TABLE(AudioProfileTable), AudioBitRateMenu, 1, 2, 4, 5, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_tooltips_set_tip(tooltips, AudioBitRateMenu, _("Output Bit Rate"), NULL); AudioEncoderSettingsButton = gtk_button_new(); gtk_widget_show(AudioEncoderSettingsButton); gtk_table_attach(GTK_TABLE(AudioProfileTable), AudioEncoderSettingsButton, 1, 2, 5, 6, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_widget_set_sensitive(AudioEncoderSettingsButton, FALSE); gtk_tooltips_set_tip(tooltips, AudioEncoderSettingsButton, _("Audio Encoder Specific Settings"), NULL); alignment19 = gtk_alignment_new(0.5, 0.5, 0, 0); gtk_widget_show(alignment19); gtk_container_add(GTK_CONTAINER(AudioEncoderSettingsButton), alignment19); hbox73 = gtk_hbox_new(FALSE, 2); gtk_widget_show(hbox73); gtk_container_add(GTK_CONTAINER(alignment19), hbox73); image19 = gtk_image_new_from_stock("gtk-preferences", GTK_ICON_SIZE_BUTTON); gtk_widget_show(image19); gtk_box_pack_start(GTK_BOX(hbox73), image19, FALSE, FALSE, 0); label146 = gtk_label_new_with_mnemonic(_("Settings")); gtk_widget_show(label146); gtk_box_pack_start(GTK_BOX(hbox73), label146, FALSE, FALSE, 0); AudioProfileEncoder = gtk_option_menu_new(); gtk_widget_show(AudioProfileEncoder); gtk_table_attach(GTK_TABLE(AudioProfileTable), AudioProfileEncoder, 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_tooltips_set_tip(tooltips, AudioProfileEncoder, _("Audio Encoder/Encoding"), NULL); // uint encoderIndex = 0; //uint i; encodingNames = (const char **)malloc(sizeof(char *) * audio_encoder_table_size); const char *audioEncoder = profile->GetStringValue(CFG_AUDIO_ENCODER); uint table_index = 0; for (uint32_t ix = 0; ix < audio_encoder_table_size; ix++) { encodingNames[ix] = strdup(audio_encoder_table[ix]->dialog_selection_name); if ((strcasecmp(audioEncoder, audio_encoder_table[ix]->audio_encoder) == 0) && (strcasecmp(profile->GetStringValue(CFG_AUDIO_ENCODING), audio_encoder_table[ix]->audio_encoding) == 0)) { table_index = ix; } } CreateOptionMenu(AudioProfileEncoder, encodingNames, audio_encoder_table_size, table_index); bool enable_settings; if (audio_encoder_table[table_index]->get_gui_options == NULL) { enable_settings = false; } else { enable_settings = (audio_encoder_table[table_index]->get_gui_options)(NULL, NULL); } gtk_widget_set_sensitive(AudioEncoderSettingsButton, enable_settings); label98 = gtk_label_new(_("Encoding:")); gtk_widget_show(label98); gtk_table_attach(GTK_TABLE(AudioProfileTable), label98, 0, 1, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label98), 0, 0.5); label99 = gtk_label_new(_("Channels:")); gtk_widget_show(label99); gtk_table_attach(GTK_TABLE(AudioProfileTable), label99, 0, 1, 2, 3, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label99), 0, 0.5); label100 = gtk_label_new(_("Sample Rate(Hz):")); gtk_widget_show(label100); gtk_table_attach(GTK_TABLE(AudioProfileTable), label100, 0, 1, 3, 4, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label100), 0, 0.5); label101 = gtk_label_new(_("Bit Rate(bps):")); gtk_widget_show(label101); gtk_table_attach(GTK_TABLE(AudioProfileTable), label101, 0, 1, 4, 5, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label101), 0, 0.5); label103 = gtk_label_new(_("Encoder Settings:")); gtk_widget_show(label103); gtk_table_attach(GTK_TABLE(AudioProfileTable), label103, 0, 1, 5, 6, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label103), 0, 0.5); AudioProfileName = gtk_entry_new(); gtk_widget_show(AudioProfileName); if (new_profile == false) { gtk_entry_set_text(GTK_ENTRY(AudioProfileName), profile->GetName()); gtk_widget_set_sensitive(AudioProfileName, false); } gtk_table_attach(GTK_TABLE(AudioProfileTable), AudioProfileName, 1, 2, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0); dialog_action_area4 = GTK_DIALOG(AudioProfileDialog)->action_area; gtk_widget_show(dialog_action_area4); gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area4), GTK_BUTTONBOX_END); cancelbutton4 = gtk_button_new_from_stock("gtk-cancel"); gtk_widget_show(cancelbutton4); gtk_dialog_add_action_widget(GTK_DIALOG(AudioProfileDialog), cancelbutton4, GTK_RESPONSE_CANCEL); GTK_WIDGET_SET_FLAGS(cancelbutton4, GTK_CAN_DEFAULT); AudioProfileOk = gtk_button_new_from_stock("gtk-ok"); gtk_widget_show(AudioProfileOk); gtk_dialog_add_action_widget(GTK_DIALOG(AudioProfileDialog), AudioProfileOk, GTK_RESPONSE_OK); GTK_WIDGET_SET_FLAGS(AudioProfileOk, GTK_CAN_DEFAULT); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF(AudioProfileDialog, AudioProfileDialog, "AudioProfileDialog"); GLADE_HOOKUP_OBJECT_NO_REF(AudioProfileDialog, dialog_vbox5, "dialog_vbox5"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, AudioProfileTable, "AudioProfileTable"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, label96, "label96"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, ChannelMenu, "ChannelMenu"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, SampleRateMenu, "SampleRateMenu"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, AudioBitRateMenu, "AudioBitRateMenu"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, AudioEncoderSettingsButton, "AudioEncoderSettingsButton"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, alignment19, "alignment19"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, hbox73, "hbox73"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, image19, "image19"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, label146, "label146"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, AudioProfileEncoder, "AudioProfileEncoder"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, label98, "label98"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, label99, "label99"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, label100, "label100"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, label101, "label101"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, label103, "label103"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, AudioProfileName, "AudioProfileName"); GLADE_HOOKUP_OBJECT_NO_REF(AudioProfileDialog, dialog_action_area4, "dialog_action_area4"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, cancelbutton4, "cancelbutton4"); GLADE_HOOKUP_OBJECT(AudioProfileDialog, AudioProfileOk, "AudioProfileOk"); GLADE_HOOKUP_OBJECT_NO_REF(AudioProfileDialog, tooltips, "tooltips"); CreateChannelMenu(ChannelMenu, true, profile->GetIntegerValue(CFG_AUDIO_CHANNELS)); CreateSamplingRateMenu((CAudioCapabilities *)MyConfig->m_audioCapabilities, true, profile->GetIntegerValue(CFG_AUDIO_SAMPLE_RATE)); CreateBitRateMenu(AudioBitRateMenu, true, profile->GetIntegerValue(CFG_AUDIO_BIT_RATE)); g_signal_connect((gpointer) AudioProfileDialog, "response", G_CALLBACK(on_AudioProfileDialog_response), profile); g_signal_connect((gpointer) AudioProfileEncoder, "changed", G_CALLBACK(on_AudioProfileEncoder_changed), NULL); g_signal_connect((gpointer) SampleRateMenu, "changed", G_CALLBACK(on_SamplingRateMenu_changed), NULL); g_signal_connect((gpointer) ChannelMenu, "changed", G_CALLBACK(on_SamplingRateMenu_changed), NULL); g_signal_connect((gpointer)AudioEncoderSettingsButton, "clicked", G_CALLBACK(on_AudioEncoderSettingsButton), profile); gtk_widget_show(AudioProfileDialog);}/* end audio_dialog.cpp */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -