📄 configdlg.c
字号:
/* * * Author: Allan <qimingos_lsk@163.com>, (C) 2005-2007 * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */#include "../include/ShowLyric.h"#include "../include/ConfigDlg.h"void ConfigDlgInit(){ GtkWidget* pConfigDlg = glade_xml_get_widget(theApp.m_xml, "ConfigDlg"); glade_xml_signal_connect_data(theApp.m_xml, "on_fcbLyricPath_file_set", G_CALLBACK(on_fcbLyricPath_file_set), pConfigDlg); glade_xml_signal_connect_data(theApp.m_xml, "on_cbBgColor_color_set", G_CALLBACK(on_cbBgColor_color_set), pConfigDlg); glade_xml_signal_connect_data(theApp.m_xml, "on_cbLyricColor_color_set", G_CALLBACK(on_cbLyricColor_color_set), pConfigDlg); glade_xml_signal_connect_data(theApp.m_xml, "on_cbCurrColor_color_set", G_CALLBACK(on_cbCurrColor_color_set), pConfigDlg); glade_xml_signal_connect_data(theApp.m_xml, "on_fbLyricFont_font_set", G_CALLBACK(on_fbLyricFont_font_set), pConfigDlg); glade_xml_signal_connect_data(theApp.m_xml, "on_cbSmartShowWindow_toggled", G_CALLBACK(on_cbSmartShowWindow_toggled), pConfigDlg); glade_xml_signal_connect_data(theApp.m_xml, "on_cbSmartDownload_toggled", G_CALLBACK(on_cbSmartDownload_toggled), pConfigDlg); glade_xml_signal_connect_data(theApp.m_xml, "on_hsOpacity_value_changed", G_CALLBACK(on_hsOpacity_value_changed), pConfigDlg); glade_xml_signal_connect_data(theApp.m_xml, "on_btnDefaultConfig_clicked", G_CALLBACK(on_btnDefaultConfig_clicked), pConfigDlg); glade_xml_signal_connect_data(theApp.m_xml, "on_btnCloseConfig_clicked", G_CALLBACK(on_btnCloseConfig_clicked), pConfigDlg); glade_xml_signal_connect_data(theApp.m_xml, "on_ConfigDlg_show", G_CALLBACK(on_ConfigDlg_show), pConfigDlg); glade_xml_signal_connect_data(theApp.m_xml, "on_ConfigDlg_delete_event", G_CALLBACK(on_ConfigDlg_delete_event), pConfigDlg); glade_xml_signal_connect_data(theApp.m_xml, "on_cbSaveLyricToSongFolder_toggled", G_CALLBACK(on_cbSaveLyricToSongFolder_toggled), pConfigDlg); }void on_ConfigDlg_show(GtkWidget *widget, gpointer user_data){ theApp.m_player.LoadConfigs(&theApp.m_configs); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(glade_xml_get_widget( theApp.m_xml, "fcbLyricPath")), theApp.m_configs.szLyricPath); gtk_color_button_set_color(GTK_COLOR_BUTTON(glade_xml_get_widget( theApp.m_xml, "cbBgColor")), &theApp.m_configs.colors.background); gtk_color_button_set_color(GTK_COLOR_BUTTON(glade_xml_get_widget( theApp.m_xml, "cbLyricColor")), &theApp.m_configs.colors.normal); gtk_color_button_set_color(GTK_COLOR_BUTTON(glade_xml_get_widget( theApp.m_xml, "cbCurrColor")), &theApp.m_configs.colors.current); gtk_font_button_set_font_name(GTK_FONT_BUTTON(glade_xml_get_widget( theApp.m_xml, "fbLyricFont")), theApp.m_configs.szLyricFontName); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget( theApp.m_xml, "cbSmartShowWindow")), theApp.m_configs.bSmartShowWin); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget( theApp.m_xml, "cbSmartDownload")), theApp.m_configs.bSmartDownLoad); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget( theApp.m_xml, "cbSaveLyricToSongFolder")), theApp.m_configs.bSaveLyricToSongFolder); gtk_widget_set_sensitive (glade_xml_get_widget(theApp.m_xml, "fcbLyricPath"), !theApp.m_configs.bSaveLyricToSongFolder); GtkWidget* phsOpacity = glade_xml_get_widget(theApp.m_xml, "hsOpacity"); gtk_range_set_range(GTK_RANGE(phsOpacity), 0, 100); gtk_range_set_value(GTK_RANGE(phsOpacity), theApp.m_configs.iOpacity);}void on_fcbLyricPath_file_set(GtkFileChooserButton *filechooserbutton, gpointer user_data){ gchar* lpszPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filechooserbutton)); if (lpszPath) { strcpy(theApp.m_configs.szLyricPath, lpszPath); g_free(lpszPath); lpszPath = NULL; }}void on_cbBgColor_color_set(GtkColorButton *widget, gpointer user_data){ gtk_color_button_get_color(widget, &theApp.m_configs.colors.background); theApp.UpdataSetting();}void on_cbLyricColor_color_set(GtkColorButton *widget, gpointer user_data){ gtk_color_button_get_color(widget, &theApp.m_configs.colors.normal); theApp.UpdataSetting();}void on_cbCurrColor_color_set(GtkColorButton *widget, gpointer user_data){ gtk_color_button_get_color(widget, &theApp.m_configs.colors.current); theApp.UpdataSetting();}void on_fbLyricFont_font_set(GtkFontButton *widget, gpointer user_data){ strcpy(theApp.m_configs.szLyricFontName, gtk_font_button_get_font_name(GTK_FONT_BUTTON(widget))); LyricDebug("FontName:%s", theApp.m_configs.szLyricFontName); theApp.UpdataSetting();}void on_cbSmartShowWindow_toggled(GtkToggleButton *togglebutton, gpointer user_data){ theApp.m_configs.bSmartShowWin = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget( theApp.m_xml, "cbSmartShowWindow"))); theApp.UpdataSetting();}void on_cbSmartDownload_toggled(GtkToggleButton *togglebutton, gpointer user_data){ theApp.m_configs.bSmartDownLoad = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget( theApp.m_xml, "cbSmartDownload"))); theApp.UpdataSetting();}void on_cbSaveLyricToSongFolder_toggled(GtkToggleButton *togglebutton, gpointer user_data){ theApp.m_configs.bSaveLyricToSongFolder = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget( theApp.m_xml, "cbSaveLyricToSongFolder"))); gtk_widget_set_sensitive (glade_xml_get_widget(theApp.m_xml, "fcbLyricPath"), !theApp.m_configs.bSaveLyricToSongFolder); theApp.UpdataSetting();}void on_hsOpacity_value_changed(GtkRange *range, gpointer user_data){ theApp.m_configs.iOpacity = (int)gtk_range_get_value(range); theApp.UpdataSetting();}void on_btnDefaultConfig_clicked(GtkButton *button, gpointer user_data){ theApp.GetDefautConfigs(&theApp.m_configs); GtkWidget* pConfigDlg = glade_xml_get_widget(theApp.m_xml, "ConfigDlg"); theApp.UpdataSetting(); on_ConfigDlg_show(GTK_WIDGET(pConfigDlg), pConfigDlg);}void on_btnCloseConfig_clicked(GtkButton *button, gpointer user_data){ gtk_widget_hide(GTK_WIDGET(user_data));}gboolean on_ConfigDlg_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data){ // 将关闭事件改成隐藏 gtk_widget_hide(GTK_WIDGET(user_data)); // 如果返回FALSE,GTK将发出"destroy"信号; // 如果返回TRUE, 则不让该窗口关闭 return TRUE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -