tweaked user interface behavior in UploadFileWindow

This commit is contained in:
fgerlits 2005-06-22 16:57:26 +00:00
parent 7e3fb629b4
commit 59920a2d14
7 changed files with 108 additions and 96 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.13 $ Version : $Revision: 1.14 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/UploadFileWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/UploadFileWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -127,8 +127,7 @@ UploadFileWindow :: UploadFileWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
*getResourceUstring("uploadButtonLabel"))); *getResourceUstring("uploadButtonLabel")));
closeButton = Gtk::manage(wf->createButton( closeButton = Gtk::manage(wf->createButton(
*getResourceUstring("closeButtonLabel"))); *getResourceUstring("closeButtonLabel")));
statusBar = Gtk::manage(new Gtk::Label( statusBar = Gtk::manage(new Gtk::Label(""));
*getResourceUstring("statusBar")));
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {
// TODO: signal error // TODO: signal error
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
@ -227,57 +226,56 @@ UploadFileWindow :: updateFileInfo(void) throw ()
Ptr<std::string>::Ref newUri(new std::string("file://")); Ptr<std::string>::Ref newUri(new std::string("file://"));
newUri->append(fileName); newUri->append(fileName);
if (!isAudioClipValid || // see if the file exists, and is readable
*audioClip->getUri() != *newUri) { std::ifstream file(fileName.c_str());
// see if the file exists, and is readable if (!file.good()) {
std::ifstream file(fileName.c_str());
if (!file.good()) {
isAudioClipValid = false;
file.close();
return;
}
file.close(); file.close();
isAudioClipValid = true; statusBar->set_text(*getResourceUstring("couldNotOpenFileMsg"));
isAudioClipValid = false;
Ptr<time_duration>::Ref playlength; return;
try {
playlength = readPlaylength(fileName);
} catch (std::invalid_argument &e) {
statusBar->set_text(e.what());
playlength.reset(new time_duration(0,0,0,0));
}
Ptr<const Glib::ustring>::Ref tempTitle(new const Glib::ustring);
audioClip.reset(new AudioClip(tempTitle, playlength, newUri));
// read the id3 tags
try {
audioClip->readTag(gLiveSupport->getMetadataTypeContainer());
} catch (std::invalid_argument &e) {
statusBar->set_text(e.what());
isAudioClipValid = false;
return;
}
titleEntry->set_text(*audioClip->getTitle());
Ptr<const Glib::ustring>::Ref creator
= audioClip->getMetadata("dc:creator");
creatorEntry->set_text(creator ? *creator : "");
Ptr<const Glib::ustring>::Ref genre
= audioClip->getMetadata("dc:type");
genreEntry->set_text(genre ? *genre : "");
// display the new play length
std::ostringstream lengthStr;
lengthStr << std::setfill('0')
<< std::setw(2) << playlength->hours() << ":"
<< std::setw(2) << playlength->minutes() << ":"
<< std::setw(2) << (playlength->fractional_seconds() < 500000
? playlength->seconds()
: playlength->seconds() + 1);
lengthValueLabel->set_text(lengthStr.str());
} }
file.close();
Ptr<time_duration>::Ref playlength;
try {
playlength = readPlaylength(fileName);
} catch (std::invalid_argument &e) {
statusBar->set_text(e.what());
playlength.reset(new time_duration(0,0,0,0));
}
Ptr<const Glib::ustring>::Ref tempTitle(new const Glib::ustring);
audioClip.reset(new AudioClip(tempTitle, playlength, newUri));
// read the id3 tags
try {
audioClip->readTag(gLiveSupport->getMetadataTypeContainer());
} catch (std::invalid_argument &e) {
statusBar->set_text(e.what());
isAudioClipValid = false;
return;
}
titleEntry->set_text(*audioClip->getTitle());
Ptr<const Glib::ustring>::Ref creator
= audioClip->getMetadata("dc:creator");
creatorEntry->set_text(creator ? *creator : "");
Ptr<const Glib::ustring>::Ref genre
= audioClip->getMetadata("dc:type");
genreEntry->set_text(genre ? *genre : "");
// display the new play length
std::ostringstream lengthStr;
lengthStr << std::setfill('0')
<< std::setw(2) << playlength->hours() << ":"
<< std::setw(2) << playlength->minutes() << ":"
<< std::setw(2) << (playlength->fractional_seconds() < 500000
? playlength->seconds()
: playlength->seconds() + 1);
lengthValueLabel->set_text(lengthStr.str());
isAudioClipValid = true;
} }
@ -299,43 +297,42 @@ UploadFileWindow :: onFileNameEntryLeave(GdkEventFocus * event)
void void
UploadFileWindow :: onUploadButtonClicked(void) throw () UploadFileWindow :: onUploadButtonClicked(void) throw ()
{ {
if (!isAudioClipValid) {
return;
}
Ptr<const Glib::ustring>::Ref ustrValue(new Glib::ustring(
titleEntry->get_text() ));
if (*ustrValue == "") {
statusBar->set_text(*getResourceUstring("missingTitleMsg"));
return;
}
audioClip->setTitle(ustrValue);
ustrValue.reset(new Glib::ustring(creatorEntry->get_text()));
audioClip->setMetadata(ustrValue, "dc:creator");
ustrValue.reset(new Glib::ustring(genreEntry->get_text()));
audioClip->setMetadata(ustrValue, "dc:type");
ustrValue.reset(new Glib::ustring(
fileFormatComboBox->get_active_text()));
audioClip->setMetadata(ustrValue, "dc:format");
// TODO: is this really what we mean by dc:format?
try { try {
updateFileInfo();
if (!isAudioClipValid) {
// TODO: localize error message
throw std::invalid_argument("file does not exist");
}
// set the metadata available
Ptr<const Glib::ustring>::Ref ustrValue(new Glib::ustring(
titleEntry->get_text() ));
audioClip->setTitle(ustrValue);
ustrValue.reset(new Glib::ustring(creatorEntry->get_text()));
audioClip->setMetadata(ustrValue, "dc:creator");
ustrValue.reset(new Glib::ustring(genreEntry->get_text()));
audioClip->setMetadata(ustrValue, "dc:type");
ustrValue.reset(new Glib::ustring(
fileFormatComboBox->get_active_text()));
audioClip->setMetadata(ustrValue, "dc:format");
// TODO: is this really what we mean by dc:format?
// upload the audio clip
gLiveSupport->uploadFile(audioClip); gLiveSupport->uploadFile(audioClip);
// display success in the status bar
Ptr<Glib::ustring>::Ref statusText = formatMessage(
"clipUploadedMessage",
*audioClip->getTitle());
statusBar->set_text(*statusText);
// clean the entry fields
//titleEntry->set_text("");
//fileNameEntry->set_text("");
} catch (std::invalid_argument &e) {
statusBar->set_text(e.what());
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
statusBar->set_text(e.what()); statusBar->set_text(e.what());
return;
} }
statusBar->set_text(*formatMessage("clipUploadedMsg",
*audioClip->getTitle() ));
fileNameEntry->set_text("");
titleEntry->set_text("");
creatorEntry->set_text("");
genreEntry->set_text("");
isAudioClipValid = false;
} }
@ -345,6 +342,15 @@ UploadFileWindow :: onUploadButtonClicked(void) throw ()
void void
UploadFileWindow :: onCloseButtonClicked(void) throw () UploadFileWindow :: onCloseButtonClicked(void) throw ()
{ {
fileNameEntry->set_text("");
titleEntry->set_text("");
creatorEntry->set_text("");
genreEntry->set_text("");
statusBar->set_text("");
isAudioClipValid = false;
hide(); hide();
} }

View file

@ -91,10 +91,11 @@ es:table
uploadButtonLabel:string { "Cargar" } uploadButtonLabel:string { "Cargar" }
closeButtonLabel:string { "Cancelar" } closeButtonLabel:string { "Cancelar" }
statusBar:string { "Barra de estatus" }
fileChooserDialogTitle:string { "Seleccione un archivo" } fileChooserDialogTitle:string { "Seleccione un archivo" }
clipUploadedMessage:string { "clip cargado {0}" } clipUploadedMsg:string { "Clip ''{0}'' cargado." }
couldNotOpenFileMsg:string { "*** translate me ***" }
missingTitleMsg:string { "*** translate me ***" }
} }
simplePlaylistManagementWindow:table simplePlaylistManagementWindow:table

View file

@ -90,10 +90,11 @@ hu:table
uploadButtonLabel:string { "feltölt" } uploadButtonLabel:string { "feltölt" }
closeButtonLabel:string { "bezár" } closeButtonLabel:string { "bezár" }
statusBar:string { "állapotsor" }
fileChooserDialogTitle:string { "File Kiválasztása" } fileChooserDialogTitle:string { "File Kiválasztása" }
clipUploadedMessage:string { "hangfile {0} feltöltve" } clipUploadedMsg:string { "A ''{0}'' klip feltöltve." }
couldNotOpenFileMsg:string { "A fájl nem olvasható." }
missingTitleMsg:string { "Kérem, adjon meg egy címet." }
} }
simplePlaylistManagementWindow:table simplePlaylistManagementWindow:table

View file

@ -91,10 +91,11 @@ nl:table
uploadButtonLabel:string { "Verzenden" } uploadButtonLabel:string { "Verzenden" }
closeButtonLabel:string { "Annuleer" } closeButtonLabel:string { "Annuleer" }
statusBar:string { "status balk" }
fileChooserDialogTitle:string { "Kies een bestand" } fileChooserDialogTitle:string { "Kies een bestand" }
clipUploadedMessage:string { "clip {0} verzonden" } clipUploadedMsg:string { "Clip ''{0}'' verzonden." }
couldNotOpenFileMsg:string { "*** translate me ***" }
missingTitleMsg:string { "*** translate me ***" }
} }
simplePlaylistManagementWindow:table simplePlaylistManagementWindow:table

View file

@ -91,10 +91,11 @@ root:table
uploadButtonLabel:string { "Upload" } uploadButtonLabel:string { "Upload" }
closeButtonLabel:string { "Cancel" } closeButtonLabel:string { "Cancel" }
statusBar:string { "status bar" }
fileChooserDialogTitle:string { "Choose a File" } fileChooserDialogTitle:string { "Choose a File" }
clipUploadedMessage:string { "uploaded clip {0}" } clipUploadedMsg:string { "Uploaded clip ''{0}''." }
couldNotOpenFileMsg:string { "The file could not be opened." }
missingTitleMsg:string { "Please enter a title." }
} }
simplePlaylistManagementWindow:table simplePlaylistManagementWindow:table

View file

@ -91,10 +91,11 @@ sr_CS:table
uploadButtonLabel:string { "Aploud" } uploadButtonLabel:string { "Aploud" }
closeButtonLabel:string { "Otkaži" } closeButtonLabel:string { "Otkaži" }
statusBar:string { "status bar" }
fileChooserDialogTitle:string { "Izaberi fajl" } fileChooserDialogTitle:string { "Izaberi fajl" }
clipUploadedMessage:string { "Aploudovan klip {0}" } clipUploadedMsg:string { "Aploudovan klip ''{0}''." }
couldNotOpenFileMsg:string { "*** translate me ***" }
missingTitleMsg:string { "*** translate me ***" }
} }
simplePlaylistManagementWindow:table simplePlaylistManagementWindow:table

View file

@ -90,10 +90,11 @@ sr_CS_CYRILLIC:table
uploadButtonLabel:string { "Аплоуд" } uploadButtonLabel:string { "Аплоуд" }
closeButtonLabel:string { "Откажи" } closeButtonLabel:string { "Откажи" }
statusBar:string { "статус бар" }
fileChooserDialogTitle:string { "Изабери фајл" } fileChooserDialogTitle:string { "Изабери фајл" }
clipUploadedMessage:string { "Аплоудован клип {0}" } clipUploadedMsg:string { "Аплоудован клип ''{0}''." }
couldNotOpenFileMsg:string { "*** translate me ***" }
missingTitleMsg:string { "*** translate me ***" }
} }
simplePlaylistManagementWindow:table simplePlaylistManagementWindow:table