📄 introwizard.cpp
字号:
/*____________________________________________________________________________
FreeAmp - The Free MP3 Player
Portions Copyright (C) 1999 EMusic.com
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., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: introwizard.cpp,v 1.3 2000/02/09 21:21:27 elrod Exp $
____________________________________________________________________________*/
#include "config.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "utility.h"
#include "eventdata.h"
#include "fileselector.h"
#include "musiccatalog.h"
#include "introwizard.h"
#include "musicsearchui.h"
#include "musicbrowserui.h"
#include "../res/wizard.xpm"
void IntroWizardUI::DeleteEvent(void)
{
if (m_main)
gtk_main_quit();
m_parent->WizardClose();
}
gboolean wiz_destroy(GtkWidget *widget, IntroWizardUI *p)
{
p->DeleteEvent();
return FALSE;
}
static void start_search_button_event(GtkWidget *widget, IntroWizardUI *p)
{
if (p->page == 1)
p->GoToPage2();
else if (p->searchDone)
gtk_widget_destroy(p->m_window);
else if (p->searchInProgress)
p->EndSearch();
else
p->StartSearch();
}
static void search_cancel_button_event(GtkWidget *widget, IntroWizardUI *p)
{
if (p->searchInProgress)
p->EndSearch();
gtk_widget_destroy(p->m_window);
}
static void search_back_event(GtkWidget *widget, IntroWizardUI *p)
{
p->GoToPage1();
}
void IntroWizardUI::UpdateEntry(void)
{
gtk_widget_set_sensitive(textEntry, custom);
gtk_widget_set_sensitive(browseButton, custom);
gtk_entry_set_text(GTK_ENTRY(textEntry), searchPath.c_str());
}
static void search_select_entire(GtkWidget *widget, IntroWizardUI *p)
{
p->SetSearchPath("/");
p->custom = false;
p->UpdateEntry();
}
static void search_select_home(GtkWidget *widget, IntroWizardUI *p)
{
char *homeDir = getenv("HOME");
if (!homeDir)
p->SetSearchPath("/");
else
p->SetSearchPath(homeDir);
p->custom = false;
p->UpdateEntry();
}
static void search_select_share(GtkWidget *widget, IntroWizardUI *p)
{
p->SetSearchPath("/usr/share");
p->custom = false;
p->UpdateEntry();
}
static void search_select_custom(GtkWidget *widget, IntroWizardUI *p)
{
if (!p->custom)
p->SetSearchPath("/");
p->custom = true;
p->UpdateEntry();
}
static void search_entry_change(GtkWidget *w, IntroWizardUI *p)
{
char *text = gtk_entry_get_text(GTK_ENTRY(w));
p->SetSearchPath(text);
}
static void search_browse(GtkWidget *w, IntroWizardUI *p)
{
FileSelector *filesel = new FileSelector("Select a Directory to begin searching in..");
if (filesel->Run()) {
char *filepath = filesel->GetReturnPath();
struct stat st;
stat(filepath, &st);
if (!S_ISDIR(st.st_mode)) {
char *temp = strrchr(filepath, '/');
if (temp)
*temp = '\0';
stat(filepath, &st);
}
if (S_ISDIR(st.st_mode)) {
p->SetSearchPath(filepath);
p->UpdateEntry();
}
}
delete filesel;
}
IntroWizardUI::IntroWizardUI(FAContext *context, MusicBrowserUI *parent)
{
m_context = context;
m_parent = parent;
}
void IntroWizardUI::GoToPage2(void)
{
gtk_widget_hide(page1);
gtk_widget_show(page2);
gtk_widget_set_sensitive(m_backButton, TRUE);
gtk_label_set_text(GTK_LABEL(buttonLabel), " Start Search > ");
page = 2;
}
void IntroWizardUI::GoToPage1(void)
{
gtk_widget_hide(page2);
gtk_widget_show(page1);
gtk_widget_set_sensitive(m_backButton, FALSE);
gtk_label_set_text(GTK_LABEL(buttonLabel), " Next > ");
page = 1;
}
GtkWidget *IntroWizardUI::IntroPage(void)
{
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vbox);
GtkWidget *label = gtk_label_new("Welcome!");
gtk_label_set_line_wrap(GTK_LABEL(label), FALSE);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 2);
gtk_widget_show(label);
label = gtk_label_new("This wizard will help you begin organizing your music \ncollection and get you started playing your music.");
gtk_label_set_line_wrap(GTK_LABEL(label), FALSE);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 2);
gtk_widget_show(label);
label = gtk_label_new("What is 'My Music'?");
gtk_label_set_line_wrap(GTK_LABEL(label), FALSE);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 2);
gtk_widget_show(label);
label = gtk_label_new("My Music helps you organize the music you have on your\ncomputer. The My Music window is divided into two panes: \nMy Music Collection and Currently Listening To.");
gtk_label_set_line_wrap(GTK_LABEL(label), FALSE);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 2);
gtk_widget_show(label);
label = gtk_label_new("My Music Collection provides a convenient, organized\nview of the music you have on your computer. It might help \nto think of this pane as a CD rack for your computer.");
gtk_label_set_line_wrap(GTK_LABEL(label), FALSE);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 2);
gtk_widget_show(label);
label = gtk_label_new("Currently Listening To displays a list of the songs you have\nchosen to play. In order to listen to music, all you have to\ndo is add items to the list by dragging them from the My\nMusic Collection pane on the left to the Currently Listening\nTo pane on the right.");
gtk_label_set_line_wrap(GTK_LABEL(label), FALSE);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 2);
gtk_widget_show(label);
label = gtk_label_new("For a more detailed explanation of how to use the My Music\nwindow, you should access the application's help system\nthrough the Help menu.");
gtk_label_set_line_wrap(GTK_LABEL(label), FALSE);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 2);
gtk_widget_show(label);
return vbox;
}
GtkWidget *IntroWizardUI::SearchPage(void)
{
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vbox);
GtkWidget *label = gtk_label_new("Search Computer For Music");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -