📄 prefsdialog.cpp
字号:
} else if(bandwidth >= BANDWIDTH_28_8_KBPS) { option = 9; } else { option = 10; } return option;}static guintbandwidth_option_to_bytes_per_second(guint option){ guint bandwidth; switch(option) { case 0: bandwidth = BANDWIDTH_10_MBPS; break; case 1: bandwidth = BANDWIDTH_1_5_MBPS; break; case 2: bandwidth = BANDWIDTH_768_KBPS; break; case 3: bandwidth = BANDWIDTH_512_KBPS; break; case 4: bandwidth = BANDWIDTH_384_KBPS; break; case 5: bandwidth = BANDWIDTH_256_KBPS; break; case 6: bandwidth = BANDWIDTH_128_KBPS; break; case 7: bandwidth = BANDWIDTH_64_KBPS; break; case 8: bandwidth = BANDWIDTH_56_KBPS; break; case 9: bandwidth = BANDWIDTH_28_8_KBPS; case 10: bandwidth = BANDWIDTH_14_4_KBPS; break; default: g_warning("Unknown bandwidth option"); bandwidth = BANDWIDTH_10_MBPS; } return bandwidth;}static voidprefs_bandwidth_option_menu_read(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog*){ HXEntry* entry; HXValue* value; guint bandwidth; guint bandwidth_option; GtkWidget* option_menu; option_menu = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(option_menu != NULL); entry = hx_prefs_get_entry(info->pref_name); if(entry) { value = hx_entry_get_value(entry); bandwidth = atoi(hx_value_get_string(value)); } else { bandwidth = atoi(info->default_value); } bandwidth_option = bandwidth_bytes_per_second_to_option(bandwidth); gtk_option_menu_set_history(GTK_OPTION_MENU(option_menu), bandwidth_option);}static voidprefs_bandwidth_option_menu_write(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog*){ gchar* str; guint bandwidth_option; guint bandwidth; GtkWidget* option_menu; HXValue* value; option_menu = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(option_menu != NULL); bandwidth_option = gtk_option_menu_get_history(GTK_OPTION_MENU(option_menu)); bandwidth = bandwidth_option_to_bytes_per_second(bandwidth_option); str = g_strdup_printf("%d", bandwidth); value = hx_value_new(HX_VALUE_STRING); hx_value_set_string_nocopy(value, str); hx_prefs_set_entry(info->pref_name, value); g_free(str);}static voidprefs_checkbutton_read(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog*){ HXEntry* entry; HXValue* value; gboolean checked; GtkWidget* checkbutton; checkbutton = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(checkbutton != NULL); entry = hx_prefs_get_entry(info->pref_name); if(entry) { value = hx_entry_get_value(entry); checked = atoi(hx_value_get_string(value)); } else { checked = atoi(info->default_value); } gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), checked);}static voidprefs_checkbutton_write_window(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog* dialog_info){ GtkWidget* checkbutton; GValue value; gboolean is_active; checkbutton = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(checkbutton != NULL); is_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton)); memset(&value, 0, sizeof(value)); g_value_init(&value, G_TYPE_BOOLEAN); g_value_set_boolean(&value, is_active); hxwindow_set_property(dialog_info->window, info->pref_name, &value); g_value_unset(&value);}static voidprefs_checkbutton_read_window(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog* dialog_info){ gboolean checked; GtkWidget* checkbutton; GValue value; checkbutton = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(checkbutton != NULL); memset(&value, 0, sizeof(value)); if(hxwindow_get_property(dialog_info->window, info->pref_name, &value)) { checked = g_value_get_boolean(&value); } else { checked = (info->default_value[0] == '1'); } gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), checked);}static voidprefs_checkbutton_write(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog*){ gchar* str; GtkWidget* checkbutton; HXValue* value; gboolean is_active; checkbutton = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(checkbutton != NULL); is_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton)); str = g_strdup_printf("%d", is_active? 1: 0); value = hx_value_new(HX_VALUE_STRING); hx_value_set_string_nocopy(value, str); hx_prefs_set_entry(info->pref_name, value); g_free(str);}static voidprefs_entry_read(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog*){ HXEntry* entry; HXValue* value; const gchar* str; GtkWidget* widget; widget = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(widget != NULL); entry = hx_prefs_get_entry(info->pref_name); if(entry) { value = hx_entry_get_value(entry); str = hx_value_get_string(value); } else { str = info->default_value; } gtk_entry_set_text(GTK_ENTRY(widget), str);}static voidprefs_entry_write(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog*){ const gchar* str; GtkWidget* entry; HXValue* value; entry = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(entry != NULL); str = gtk_entry_get_text(GTK_ENTRY(entry)); value = hx_value_new(HX_VALUE_STRING); hx_value_set_string_nocopy(value, g_strdup(str)); hx_prefs_set_entry(info->pref_name, value);}static voidprefs_entry_write_window(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog* dialog_info){ const gchar* str; GtkWidget* entry; GValue value; entry = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(entry != NULL); str = gtk_entry_get_text(GTK_ENTRY(entry)); if(!str) { str = info->default_value; } memset(&value, 0, sizeof(value)); g_value_init(&value, G_TYPE_STRING); g_value_set_string(&value, str); hxwindow_set_property(dialog_info->window, info->pref_name, &value); g_value_unset(&value);}static voidprefs_entry_read_window(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog* dialog_info){ GtkWidget* entry; GValue value; const gchar* str = NULL; entry = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(entry != NULL); memset(&value, 0, sizeof(value)); if(hxwindow_get_property(dialog_info->window, info->pref_name, &value)) { str = g_value_get_string(&value); } if(!str) { str = info->default_value; } gtk_entry_set_text(GTK_ENTRY(entry), str);}static voidprefs_scale_read(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog*){ HXEntry* entry; HXValue* value; const gchar* str; GtkWidget* widget; gint pos; widget = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(widget != NULL); entry = hx_prefs_get_entry(info->pref_name); if(entry) { value = hx_entry_get_value(entry); str = hx_value_get_string(value); pos = atoi(str); } else { pos = atoi(info->default_value); } gtk_range_set_value(GTK_RANGE(widget), (gdouble)pos);}static voidprefs_scale_write(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog*){ gchar* str; GtkWidget* widget; HXValue* value; gdouble pos; widget = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(widget != NULL); pos = gtk_range_get_value(GTK_RANGE(widget)); str = g_strdup_printf("%d", (gint)pos); value = hx_value_new(HX_VALUE_STRING); hx_value_set_string_nocopy(value, g_strdup(str)); hx_prefs_set_entry(info->pref_name, value); g_free(str);}static voidprefs_sampling_rate_read(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog*){ HXEntry* entry; HXValue* value; gboolean checked; GtkWidget* checkbutton; checkbutton = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(checkbutton != NULL); entry = hx_prefs_get_entry(info->pref_name); if(entry) { value = hx_entry_get_value(entry); checked = strcmp(hx_value_get_string(value), "11025") == 0; } else { checked = FALSE; } gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), checked);}static voidprefs_sampling_rate_write(GladeXML* prefs_dialog, const HXPrefsControlInfo* info, const HXPrefsDialog*){ GtkWidget* checkbutton; HXValue* value; gboolean is_active; checkbutton = glade_xml_get_widget(prefs_dialog, info->widget_name); g_return_if_fail(checkbutton != NULL); is_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton)); if(is_active) { value = hx_value_new(HX_VALUE_STRING); hx_value_set_string_nocopy(value, "11025"); hx_prefs_set_entry(info->pref_name, value); } else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -