📄 preferences.cpp
字号:
/* * The contents of this file are subject to the Mozilla Public * License Version 1.1(the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is MPEG4IP. * * The Initial Developer of the Original Code is Cisco Systems Inc. * Portions created by Cisco Systems Inc. are * Copyright(C) Cisco Systems Inc. 2001-2005. All Rights Reserved. * * Contributor(s): * Dave Mackie dmackie@cisco.com * Bill May wmay@cisco.com *//* * gui_main.cpp - Contains the gtk based gui */#define __STDC_LIMIT_MACROS#include "mp4live.h"#include "mp4live_gui.h"#include "mp4live_common.h"#include "support.h"static void on_stream_directory_clicked (GtkWidget *widget, gpointer data){ GtkWidget *wid = GTK_WIDGET(data), *entry; entry = lookup_widget(wid, "StreamDirectory"); FileBrowser(entry, wid, NULL);}static void on_profile_directory_clicked (GtkWidget *widget, gpointer data){ GtkWidget *wid = GTK_WIDGET(data), *entry; entry = lookup_widget(wid, "ProfileDirectory"); FileBrowser(entry, wid, NULL);}static void on_raw_file_clicked (GtkWidget *widget, gpointer data){ GtkWidget *dialog = GTK_WIDGET(data); GtkWidget *entry = lookup_widget(dialog, "RawFileName"); FileBrowser(entry, dialog, NULL);}static bool check_dir (const char *newdir, const char *old, const char *suffix){ char olddirname[PATH_MAX], newdirname[PATH_MAX]; if (old != NULL) { strcpy(olddirname, old); } else { GetHomeDirectory(olddirname); strcat(olddirname, suffix); } char *temp = olddirname + strlen(olddirname); while (*temp == '/' && temp >= olddirname) { *temp = '\0'; temp--; } if (temp < olddirname) return false; strcpy(newdirname, newdir); temp = newdirname + strlen(newdirname); while (*temp == '/' && temp >= newdirname) { *temp = '\0'; temp--; } if (temp < newdirname) return false; if (strcmp(olddirname, newdirname) == 0) return false; return true;}static voidon_PreferencesDialog_response (GtkWidget *dialog, gint response_id, gpointer user_data){ GtkWidget *w; if(GTK_RESPONSE_OK == response_id) { w = lookup_widget(dialog, "LogLevelSpinner"); MyConfig->SetIntegerValue(CONFIG_APP_LOGLEVEL, gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w))); w = lookup_widget(dialog, "MtuSpinButton"); MyConfig->SetIntegerValue(CONFIG_RTP_PAYLOAD_SIZE, gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w))); w = lookup_widget(dialog, "DebugCheckButton"); MyConfig->SetBoolValue(CONFIG_APP_DEBUG, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); PrintDebugMessages = MyConfig->GetBoolValue(CONFIG_APP_DEBUG); w = lookup_widget(dialog, "MulticastTtlMenu"); uint ix = gtk_option_menu_get_history(GTK_OPTION_MENU(w)); static const uint ttls[] = { 1, 15, 64, 127}; MyConfig->SetIntegerValue(CONFIG_RTP_MCAST_TTL, ttls[ix]); w = lookup_widget(dialog, "AllowRtcpCheck"); MyConfig->SetBoolValue(CONFIG_RTP_NO_B_RR_0, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); w = lookup_widget(dialog, "AllowSSMCheck"); MyConfig->SetBoolValue(CONFIG_RTP_USE_SSM, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); config_integer_t value = FILE_MP4_OVERWRITE; w = lookup_widget(dialog, "FileStatus2"); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) { value = FILE_MP4_APPEND; } else { w = lookup_widget(dialog, "FileStatus3"); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) { value = FILE_MP4_CREATE_NEW; } } MyConfig->SetIntegerValue(CONFIG_RECORD_MP4_FILE_STATUS, value); w = lookup_widget(dialog, "RecordRawDataButton"); MyConfig->SetBoolValue(CONFIG_RECORD_RAW_IN_MP4, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); w = lookup_widget(dialog, "RawFileName"); MyConfig->SetStringValue(CONFIG_RECORD_RAW_MP4_FILE_NAME, gtk_entry_get_text(GTK_ENTRY(w))); w = lookup_widget(dialog, "RecordHintTrackButton"); MyConfig->SetBoolValue(CONFIG_RECORD_MP4_HINT_TRACKS, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); w = lookup_widget(dialog, "OptimizeMP4FileButton"); MyConfig->SetBoolValue(CONFIG_RECORD_MP4_OPTIMIZE, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); bool have_dir_change = false; w = lookup_widget(dialog, "StreamDirectory"); if (check_dir(gtk_entry_get_text(GTK_ENTRY(w)), MyConfig->GetStringValue(CONFIG_APP_STREAM_DIRECTORY), ".mp4live_d/Streams/")) { MyConfig->SetStringValue(CONFIG_APP_STREAM_DIRECTORY, gtk_entry_get_text(GTK_ENTRY(w))); have_dir_change = true; } w = lookup_widget(dialog, "ProfileDirectory"); if (check_dir(gtk_entry_get_text(GTK_ENTRY(w)), MyConfig->GetStringValue(CONFIG_APP_PROFILE_DIRECTORY), ".mp4live_d/")) { MyConfig->SetStringValue(CONFIG_APP_PROFILE_DIRECTORY, gtk_entry_get_text(GTK_ENTRY(w))); have_dir_change = true; } if (have_dir_change) { StartFlowLoadWindow(); } } gtk_widget_destroy(GTK_WIDGET(dialog));}void create_PreferencesDialog(void){ GtkWidget *PreferencesDialog; GtkWidget *dialog_vbox9; GtkWidget *notebook1; GtkWidget *GenericTable; GtkWidget *label173; GtkObject *LogLevelSpinner_adj; GtkWidget *LogLevelSpinner; GtkWidget *DebugCheckButton; GtkWidget *label174; GtkWidget *StreamDirectoryHbox; GtkWidget *StreamDirectory; GtkWidget *StreamDirectoryButton; GtkWidget *alignment24; GtkWidget *hbox84; GtkWidget *image24; GtkWidget *label175; GtkWidget *label176; GtkWidget *ProfileDirectoryHbox; GtkWidget *ProfileDirectory; GtkWidget *ProfileDirectoryButton; GtkWidget *alignment25; GtkWidget *hbox86; GtkWidget *image25; GtkWidget *label177; GtkWidget *label169; GtkWidget *NetworkVbox; GtkWidget *NetworkTable; GtkWidget *label178; GtkWidget *label179; GtkWidget *MulticastTtlMenu; GtkWidget *menu16; GtkWidget *ttl_lan; GtkWidget *ttl_organization; GtkWidget *ttl_regional; GtkWidget *ttl_worldwide; GtkObject *MtuSpinButton_adj; GtkWidget *MtuSpinButton; GtkWidget *vbox39; GtkWidget *hbox89; GtkWidget *AllowRtcpCheck; GtkWidget *hbox87; GtkWidget *AllowSSMCheck; GtkWidget *label170; GtkWidget *MP4FileSettingsVbox; GtkWidget *FileStatusFrame; GtkWidget *FileStatusVbox; GtkWidget *hbox90; GtkWidget *FileStatus1; GSList *FileStatus1_group = NULL; GtkWidget *hbox91; GtkWidget *FileStatus2; GtkWidget *hbox92; GtkWidget *FileStatus3; GtkWidget *label180; GtkWidget *hbox93; GtkWidget *RecordHintTrackButton; GtkWidget *hbox94; GtkWidget *OptimizeMP4FileButton; GtkWidget *hbox95; GtkWidget *RecordRawDataButton; GtkWidget *RawFileName; GtkWidget *RawFileNameBrowse; GtkWidget *alignment26; GtkWidget *hbox96; GtkWidget *image26; GtkWidget *label181; GtkWidget *label171; GtkWidget *dialog_action_area8; GtkWidget *cancelbutton6; GtkWidget *okbutton8; GtkTooltips *tooltips; tooltips = gtk_tooltips_new(); PreferencesDialog = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(PreferencesDialog), _("Preferences")); gtk_window_set_modal(GTK_WINDOW(PreferencesDialog), TRUE); gtk_window_set_resizable(GTK_WINDOW(PreferencesDialog), FALSE); gtk_window_set_transient_for(GTK_WINDOW(PreferencesDialog), GTK_WINDOW(MainWindow)); dialog_vbox9 = GTK_DIALOG(PreferencesDialog)->vbox; gtk_widget_show(dialog_vbox9); notebook1 = gtk_notebook_new(); gtk_widget_show(notebook1); gtk_box_pack_start(GTK_BOX(dialog_vbox9), notebook1, TRUE, TRUE, 0); GenericTable = gtk_table_new(4, 2, FALSE); gtk_widget_show(GenericTable); gtk_container_add(GTK_CONTAINER(notebook1), GenericTable); gtk_table_set_row_spacings(GTK_TABLE(GenericTable), 9); gtk_table_set_col_spacings(GTK_TABLE(GenericTable), 36); label173 = gtk_label_new(_("Log Level")); gtk_widget_show(label173); gtk_table_attach(GTK_TABLE(GenericTable), label173, 0, 1, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label173), 0, 0.5); LogLevelSpinner_adj = gtk_adjustment_new(MyConfig->GetIntegerValue(CONFIG_APP_LOGLEVEL), 0, 7, 1, 10, 10); LogLevelSpinner = gtk_spin_button_new(GTK_ADJUSTMENT(LogLevelSpinner_adj), 1, 0); gtk_widget_show(LogLevelSpinner); gtk_table_attach(GTK_TABLE(GenericTable), LogLevelSpinner, 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0); DebugCheckButton = gtk_check_button_new_with_mnemonic(_("Debug")); gtk_widget_show(DebugCheckButton); gtk_table_attach(GTK_TABLE(GenericTable), DebugCheckButton, 0, 2, 0, 1, (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0); label174 = gtk_label_new(_("Stream Directory")); gtk_widget_show(label174); gtk_table_attach(GTK_TABLE(GenericTable), label174, 0, 1, 2, 3, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label174), 0, 0.5); StreamDirectoryHbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(StreamDirectoryHbox); gtk_table_attach(GTK_TABLE(GenericTable), StreamDirectoryHbox, 1, 2, 2, 3, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0); StreamDirectory = gtk_entry_new(); gtk_widget_show(StreamDirectory); gtk_box_pack_start(GTK_BOX(StreamDirectoryHbox), StreamDirectory, TRUE, TRUE, 0); StreamDirectoryButton = gtk_button_new(); gtk_widget_show(StreamDirectoryButton); gtk_box_pack_start(GTK_BOX(StreamDirectoryHbox), StreamDirectoryButton, FALSE, FALSE, 0); alignment24 = gtk_alignment_new(0.5, 0.5, 0, 0); gtk_widget_show(alignment24); gtk_container_add(GTK_CONTAINER(StreamDirectoryButton), alignment24); hbox84 = gtk_hbox_new(FALSE, 2); gtk_widget_show(hbox84); gtk_container_add(GTK_CONTAINER(alignment24), hbox84); image24 = gtk_image_new_from_stock("gtk-open", GTK_ICON_SIZE_BUTTON); gtk_widget_show(image24); gtk_box_pack_start(GTK_BOX(hbox84), image24, FALSE, FALSE, 0); label175 = gtk_label_new_with_mnemonic(_("Browse")); gtk_widget_show(label175); gtk_box_pack_start(GTK_BOX(hbox84), label175, FALSE, FALSE, 0); label176 = gtk_label_new(_("Profiles Directory")); gtk_widget_show(label176); gtk_table_attach(GTK_TABLE(GenericTable), label176, 0, 1, 3, 4, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label176), 0, 0.5); ProfileDirectoryHbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(ProfileDirectoryHbox); gtk_table_attach(GTK_TABLE(GenericTable), ProfileDirectoryHbox, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0); ProfileDirectory = gtk_entry_new(); gtk_widget_show(ProfileDirectory); gtk_box_pack_start(GTK_BOX(ProfileDirectoryHbox), ProfileDirectory, TRUE, TRUE, 0); ProfileDirectoryButton = gtk_button_new(); gtk_widget_show(ProfileDirectoryButton); gtk_box_pack_start(GTK_BOX(ProfileDirectoryHbox), ProfileDirectoryButton, FALSE, FALSE, 0); alignment25 = gtk_alignment_new(0.5, 0.5, 0, 0); gtk_widget_show(alignment25); gtk_container_add(GTK_CONTAINER(ProfileDirectoryButton), alignment25); hbox86 = gtk_hbox_new(FALSE, 2); gtk_widget_show(hbox86); gtk_container_add(GTK_CONTAINER(alignment25), hbox86); image25 = gtk_image_new_from_stock("gtk-open", GTK_ICON_SIZE_BUTTON); gtk_widget_show(image25); gtk_box_pack_start(GTK_BOX(hbox86), image25, FALSE, FALSE, 0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -