📄 prefsdialog.cpp
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: prefsdialog.cpp,v 1.18.2.10 2004/10/27 16:59:17 nhart Exp $ * * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks. You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL. Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. * * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. * * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. * * Technology Compatibility Kit Test Suite(s) Location: * http://www.helixcommunity.org/content/tck * * Contributor(s): * * ***** END LICENSE BLOCK ***** *//* This function implements hmw_preferences. It contains a number of unprefixed supporting functions. */#include "hxcom.h"#include "hxwintyp.h"#include "hxcore.h"#include <gtk/gtk.h>#include <stdlib.h>#include <string.h>#include "prefsdialog.h"#include "hxplayer.h"#include "hxgprefs.h"#include "hxgvalue.h"#include "commonapp.h"#include "mainapp.h"#include "mimetypes.h"#include "hxplayer-i18n.h"/* Helix headers (for clearing clip cache) */#include "hxcom.h"#include "hxwintyp.h"#include "hxplugn.h"#include "hxcore.h"#include "hxflche.h"// As seen in the mac player...#define BANDWIDTH_10_MBPS 10485800 #define BANDWIDTH_1_5_MBPS 1544000#define BANDWIDTH_768_KBPS 786432#define BANDWIDTH_512_KBPS 524300#define BANDWIDTH_384_KBPS 393216#define BANDWIDTH_256_KBPS 262000#define BANDWIDTH_128_KBPS 131000#define BANDWIDTH_64_KBPS 65536#define BANDWIDTH_56_KBPS 57600#define BANDWIDTH_28_8_KBPS 28800#define BANDWIDTH_14_4_KBPS 14400extern "C"{ void hpd_configure_rtsp(GtkWidget* widget); void hpd_configure_pna(GtkWidget* widget); void hpd_media_files_browse(GtkWidget* widget); void hpd_web_browser_browse(GtkWidget* widget); void hpd_clear_recent_clips(GtkWidget* widget); void hpd_auto_transport_toggled(GtkToggleButton *togglebutton); void hpd_empty_clip_cache(GtkWidget *widget); void hpd_bandwidth_changed(GtkWidget* max_bandwidth, gpointer);}typedef enum{ HX_TRANSPORT_RTSP, HX_TRANSPORT_PNA} HXTransportType;struct _HXPrefsControlInfo;typedef struct _HXPrefsControlInfo HXPrefsControlInfo;typedef struct _HXPrefsDialog HXPrefsDialog;typedef void(*prefs_read_func)(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog* dialog_info);typedef void(*prefs_write_func)(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog* dialog_info);/* Per-control information */typedef struct _HXPrefsControlInfo{ const gchar* pref_name; const gchar* default_value; const gchar* widget_name; prefs_read_func read_func; prefs_write_func write_func; } HXPrefsControlInfo;/* Per-prefs dialog information */typedef struct _HXPrefsDialog{ HXMainWindow* window; /* Can be NULL if we're being called from the embedded player. */ HXMimeTypesDialogInfo* mime_types_dialog_info; GladeXML* xml;} HXPrefsDialog;/* These lang id's are for SMIL, and shouldn't affect the whole gettext system. Some id's are commented out in the mac player's version of this, so I'm reluctantly leaving them commented out here, until someone can tell me why, as it might be some US legal thing. */static const struct{ const gchar* lang_code; const gchar* lang_name;} g_lang_id_name_map[] ={ { "af", N_("Afrikaans") }, { "sq", N_("Albanian") }, { "ar", N_("Arabic") }, { "ar-dz", N_("Arabic (Algeria)") }, { "ar-bh", N_("Arabic (Bahrain)") }, { "ar-eg", N_("Arabic (Egypt)") },/* { "ar-iq", N_("Arabic (Iraq)") }, */ { "ar-jo", N_("Arabic (Jordan)") }, { "ar-kw", N_("Arabic (Kuwait)") }, { "ar-lb", N_("Arabic (Lebanon)") },/* { "ar-ly", N_("Arabic (Libya)") }, */ { "ar-ma", N_("Arabic (Morocco)") }, { "ar-om", N_("Arabic (Oman)") }, { "ar-qa", N_("Arabic (Qatar)") }, { "ar-sa", N_("Arabic (Saudi Arabia)") },/* { "ar-se", N_("Arabic (Syria)") }, */ { "ar-tn", N_("Arabic (Tunisia)") }, { "ar-ae", N_("Arabic (U.A.E.)") }, { "ar-ye", N_("Arabic (Yemen)") }, { "hy", N_("Armenian") }, { "as", N_("Assamese") }, { "az", N_("Azeri") },/* { "az", N_("Azeri (Cyrillic)") }, *//* { "az", N_("Azeri (Latin)") }, */ { "eu", N_("Basque") }, { "be", N_("Belarusian") }, { "bn", N_("Bengali") }, { "bg", N_("Bulgarian") }, { "ca", N_("Catalan") }, { "zh", N_("Chinese") }, { "zh-cn", N_("Chinese (China)") }, { "zh-hk", N_("Chinese (Hong Kong SAR)") }, { "zh-mo", N_("Chinese (Macau SAR)") }, { "zh-sg", N_("Chinese (Singapore)") }, { "zh-tw", N_("Chinese (Taiwan)") }, { "hr", N_("Croatian") }, { "cs", N_("Czech") }, { "da", N_("Danish") }, { "nl-be", N_("Dutch (Belgium)") }, { "nl", N_("Dutch (Netherlands)") }, { "en", N_("English") }, { "en-au", N_("English (Australia)") }, { "en-bz", N_("English (Belize)") }, { "en-ca", N_("English (Canada)") },/* { "en-cb", N_("English (Caribbean)") XXXSEH: Listed as en in WIN IE 6, but en-cb in Mac IE 5.1? */ { "en-ie", N_("English (Ireland)") }, { "en-jm", N_("English (Jamaica)") }, { "en-nz", N_("English (New Zealand)") }, { "en-ph", N_("English (Philippines)") }, { "en-za", N_("English (South Africa)") }, { "en-tt", N_("English (Trinidad)") }, { "en-gb", N_("English (United Kingdom)") }, { "en-us", N_("English (United States)") }, { "en-zw", N_("English (Zimbabwe)") }, { "et", N_("Estonian") }, { "fo", N_("Faeroese") }, { "fa", N_("Farsi") }, { "fi", N_("Finnish") }, { "fr-be", N_("French (Belgium)") }, { "fr-ca", N_("French (Canada)") }, { "fr", N_("French (France)") }, { "fr-lu", N_("French (Luxembourg)") }, { "fr-mc", N_("French (Monaco)") }, { "fr-ch", N_("French (Switzerland)") }, { "mk", N_("FYRO Macedonian") }, { "ka", N_("Georgian") }, { "de-at", N_("German (Austria)") }, { "de", N_("German (Germany)") }, { "de-li", N_("German (Liechtenstein)") }, { "de-lu", N_("German (Luxembourg)") }, { "de-ch", N_("German (Switzerland)") }, { "el", N_("Greek") }, { "gu", N_("Gujarati") }, { "he", N_("Hebrew") }, { "hi", N_("Hindi") }, { "hu", N_("Hungarian") }, { "is", N_("Icelandic") }, { "id", N_("Indonesian") }, /* Mac IE 5.1 has it as 'in' */ { "it", N_("Italian (Italy)") }, { "it-ch", N_("Italian (Switzerland)") }, { "ja", N_("Japanese") }, { "kn", N_("Kannada") }, { "kk", N_("Kazakh") }, { "ko", N_("Korean") },/* { "ko-jo", N_("Korean (Johab)") */ { "lv", N_("Latvian") }, { "lt", N_("Lithuanian") }, { "ms", N_("Malay") },/* { "ms", N_("Malay (Brunei)") }, { "ms", N_("Malay (Malaysia)") */ { "ml", N_("Malayalam") }, { "mr", N_("Marathi") }, { "ne", N_("Nepali (India)") }, { "no", N_("Norwegian") }, { "nb-no", N_("Norwegian (Bokmal)") }, { "nn-no", N_("Norweigan (Nynorsk)") }, { "or", N_("Oriya") }, { "pl", N_("Polish") }, { "pt-br", N_("Portuguese (Brazil)") }, { "pt", N_("Portuguese (Portugal)") }, { "pa", N_("Punjabi") }, { "ro", N_("Romanian") }, { "ru", N_("Russian") }, { "sa", N_("Sanskrit") }, { "sr", N_("Serbian") },/* { "sr", N_("Serbian (Cyrillic)") }, { "sr", N_("Serbian (Latin)") */ { "sk", N_("Slovak") }, { "sl", N_("Slovenian") }, { "es", N_("Spanish") }, { "es-ar", N_("Spanish (Argentina)") }, { "es-bo", N_("Spanish (Bolivia)") }, { "es-cl", N_("Spanish (Chile)") }, { "es-co", N_("Spanish (Colombia)") }, { "es-cr", N_("Spanish (Costa Rica)") }, { "es-do", N_("Spanish (Dominican Republic)") }, { "es-ec", N_("Spanish (Ecuador)") }, { "es-sv", N_("Spanish (El Salvador)") }, { "es-gt", N_("Spanish (Guatemala)") }, { "es-hn", N_("Spanish (Honduras)") }, { "es-mx", N_("Spanish (Mexico)") },/* { "es-mn", N_("Spanish (Modern)") */ { "es-ni", N_("Spanish (Nicaragua)") }, { "es-pa", N_("Spanish (Panama)") }, { "es-py", N_("Spanish (Paraguay)") }, { "es-pe", N_("Spanish (Peru)") }, { "es-pr", N_("Spanish (Puerto Rico)") }, { "es-uy", N_("Spanish (Uruguay)") }, { "es-ve", N_("Spanish (Venezuela)") }, { "sw", N_("Swahili") }, { "sv", N_("Swedish") }, { "sv-fi", N_("Swedish (Finland)") }, { "ta", N_("Tamil") }, { "tt", N_("Tatar") }, { "te", N_("Telugu") }, { "th", N_("Thai") }, { "tr", N_("Turkish") }, { "uk", N_("Ukrainian") }, { "ur", N_("Urdu") }, { "uz", N_("Uzbek") },/* { "uz", N_("Uzbek (Cyrillic)") }, { "uz", N_("Uzbek (Latin)") */ { "vi", N_("Vietnamese") } };voidhpd_bandwidth_changed(GtkWidget* widget, gpointer){ /* Clamp normal bandwidth to max bandwidth */ GtkWidget* toplevel; GladeXML* xml; GtkWidget* normal_bandwidth; GtkWidget* max_bandwidth; gint normal_bandwidth_selection; gint max_bandwidth_selection; toplevel = gtk_widget_get_toplevel(widget); xml = (GladeXML*)g_object_get_data(G_OBJECT (toplevel), "hxprefs_xml"); if(xml) { normal_bandwidth = glade_xml_get_widget(xml, "hpd_normal_bandwidth"); max_bandwidth = glade_xml_get_widget(xml, "hpd_max_bandwidth"); max_bandwidth_selection = gtk_option_menu_get_history(GTK_OPTION_MENU(max_bandwidth)); normal_bandwidth_selection = gtk_option_menu_get_history(GTK_OPTION_MENU(normal_bandwidth)); if(normal_bandwidth_selection < max_bandwidth_selection) { if(widget == max_bandwidth) { gtk_option_menu_set_history(GTK_OPTION_MENU(normal_bandwidth), max_bandwidth_selection); } else { gtk_option_menu_set_history(GTK_OPTION_MENU(max_bandwidth), normal_bandwidth_selection); } } }}static ginthpd_compare(gpointer s1, gpointer s2){ return (g_utf8_collate((char*)s1, (char*)s2));}static voidhpd_populate_lang_combo(GtkCombo* combo){ guint i; GList* items = NULL; for(i = 0; i < sizeof(g_lang_id_name_map) / sizeof(*g_lang_id_name_map); i++) { items = g_list_insert_sorted(items, (gpointer)gettext(g_lang_id_name_map[i].lang_name), (GCompareFunc)hpd_compare); } gtk_combo_set_popdown_strings(GTK_COMBO(combo), items);}static const gchar*hpd_get_lang_code_from_name(const gchar* lang_name){ guint i; for(i = 0; i < sizeof(g_lang_id_name_map) / sizeof(*g_lang_id_name_map); i++) { if(strcmp(lang_name, gettext(g_lang_id_name_map[i].lang_name)) == 0) { return g_lang_id_name_map[i].lang_code; } } return NULL;}static const gchar*hpd_get_lang_name_from_code(const gchar* lang_code){ guint i; for(i = 0; i < sizeof(g_lang_id_name_map) / sizeof(*g_lang_id_name_map); i++) { if(strcmp(lang_code, g_lang_id_name_map[i].lang_code) == 0) { return gettext(g_lang_id_name_map[i].lang_name); } } return NULL;}static guintbandwidth_bytes_per_second_to_option(guint bandwidth){ guint option; if(bandwidth >= BANDWIDTH_10_MBPS) { option = 0; } else if(bandwidth >= BANDWIDTH_1_5_MBPS) { option = 1; } else if(bandwidth >= BANDWIDTH_768_KBPS) { option = 2; } else if(bandwidth >= BANDWIDTH_512_KBPS) { option = 3; } else if(bandwidth >= BANDWIDTH_384_KBPS) { option = 4; } else if(bandwidth >= BANDWIDTH_256_KBPS) { option = 5; } else if(bandwidth >= BANDWIDTH_128_KBPS) { option = 6; } else if(bandwidth >= BANDWIDTH_64_KBPS) { option = 7; } else if(bandwidth >= BANDWIDTH_56_KBPS) { option = 8;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -