📄 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.9 2001/02/07 17:13:42 ijr 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"
//#include "../res/relatable.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;
}
void IntroWizardUI::CheckCreateProfile(void)
{
char *text = gtk_entry_get_text(GTK_ENTRY(profileEntry));
if (text && strlen(text) > 0) {
m_context->aps->CreateProfile(text);
m_context->target->AcceptEvent(new Event(INFO_UnsignaturedTracksExist));
}
}
static void start_search_button_event(GtkWidget *widget, IntroWizardUI *p)
{
if (p->page == 1)
p->GoToPage2();
else if (p->page == 2) {
if (p->skipRelatableTwo)
p->GoToPage4();
else
p->GoToPage3();
}
else if (p->page == 3) {
p->CheckCreateProfile();
p->GoToPage4();
}
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)
{
if (p->page == 4) {
if (p->skipRelatableTwo)
p->GoToPage2();
else
p->GoToPage3();
}
if (p->page == 3)
p->GoToPage2();
else if (p->page == 2)
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::GoToPage4(void)
{
gtk_widget_hide(page1);
gtk_widget_hide(page2);
gtk_widget_hide(page3);
gtk_widget_show(page4);
gtk_widget_set_sensitive(m_backButton, TRUE);
gtk_label_set_text(GTK_LABEL(buttonLabel), " Start Search > ");
page = 4;
}
void IntroWizardUI::GoToPage3(void)
{
gtk_widget_hide(page4);
gtk_widget_hide(page2);
gtk_widget_hide(page1);
gtk_widget_show(page3);
gtk_widget_set_sensitive(m_backButton, TRUE);
gtk_label_set_text(GTK_LABEL(buttonLabel), " Next > ");
page = 3;
}
void IntroWizardUI::GoToPage2(void)
{
gtk_widget_hide(page4);
gtk_widget_hide(page1);
gtk_widget_hide(page3);
gtk_widget_show(page2);
gtk_widget_set_sensitive(m_backButton, TRUE);
gtk_label_set_text(GTK_LABEL(buttonLabel), " Next > ");
page = 2;
}
void IntroWizardUI::GoToPage1(void)
{
gtk_widget_hide(page4);
gtk_widget_hide(page2);
gtk_widget_hide(page3);
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;
}
static void opt_in_selected(GtkWidget *w, IntroWizardUI *p)
{
p->skipRelatableTwo = false;
}
static void opt_out_selected(GtkWidget *w, IntroWizardUI *p)
{
p->skipRelatableTwo = true;
}
GtkWidget *IntroWizardUI::RelatablePage(void)
{
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vbox);
/*
GtkWidget *caption = gtk_label_new("Check out Relatable's new recommendation features");
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);
*/
GtkWidget *label = gtk_label_new("This version of FreeAmp offers Relatable features that automatically recommend music playlists and streams. It's our first public test of an exciting new approach to discovering music. Relatable's system 'learns' listener preferences through FreeAmp and compares them with the preferences of like-minded listeners. Like virtual 'word of mouth', Relatable introduces you to music that people like you have enjoyed.");
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
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("Private by Design");
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("Please note that Relatable profiles are totally anonymous and individual profiles are never shared with third parties. We don't collect any personally identifiable information. Feel free to check our code on that. Each anonymous music profile is stored on Relatable's secure servers, and we're continually adding safeguards to protect our users. To enjoy these features and help us test the system, just opt in. You will never be contacted by Relatable or anyone else (unless you ask, of course!). That's Relatable's privacy promise. If you have any questions, please contact us at info@relatable.com.");
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -