tweaked user interface behavior in UploadFileWindow
This commit is contained in:
parent
7e3fb629b4
commit
59920a2d14
7 changed files with 108 additions and 96 deletions
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
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 $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -127,8 +127,7 @@ UploadFileWindow :: UploadFileWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
|||
*getResourceUstring("uploadButtonLabel")));
|
||||
closeButton = Gtk::manage(wf->createButton(
|
||||
*getResourceUstring("closeButtonLabel")));
|
||||
statusBar = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("statusBar")));
|
||||
statusBar = Gtk::manage(new Gtk::Label(""));
|
||||
} catch (std::invalid_argument &e) {
|
||||
// TODO: signal error
|
||||
std::cerr << e.what() << std::endl;
|
||||
|
@ -227,17 +226,15 @@ UploadFileWindow :: updateFileInfo(void) throw ()
|
|||
Ptr<std::string>::Ref newUri(new std::string("file://"));
|
||||
newUri->append(fileName);
|
||||
|
||||
if (!isAudioClipValid ||
|
||||
*audioClip->getUri() != *newUri) {
|
||||
// see if the file exists, and is readable
|
||||
std::ifstream file(fileName.c_str());
|
||||
if (!file.good()) {
|
||||
isAudioClipValid = false;
|
||||
file.close();
|
||||
statusBar->set_text(*getResourceUstring("couldNotOpenFileMsg"));
|
||||
isAudioClipValid = false;
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
isAudioClipValid = true;
|
||||
|
||||
Ptr<time_duration>::Ref playlength;
|
||||
try {
|
||||
|
@ -277,7 +274,8 @@ UploadFileWindow :: updateFileInfo(void) throw ()
|
|||
? playlength->seconds()
|
||||
: playlength->seconds() + 1);
|
||||
lengthValueLabel->set_text(lengthStr.str());
|
||||
}
|
||||
|
||||
isAudioClipValid = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,16 +297,16 @@ UploadFileWindow :: onFileNameEntryLeave(GdkEventFocus * event)
|
|||
void
|
||||
UploadFileWindow :: onUploadButtonClicked(void) throw ()
|
||||
{
|
||||
try {
|
||||
updateFileInfo();
|
||||
if (!isAudioClipValid) {
|
||||
// TODO: localize error message
|
||||
throw std::invalid_argument("file does not exist");
|
||||
return;
|
||||
}
|
||||
|
||||
// set the metadata available
|
||||
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");
|
||||
|
@ -319,23 +317,22 @@ UploadFileWindow :: onUploadButtonClicked(void) throw ()
|
|||
audioClip->setMetadata(ustrValue, "dc:format");
|
||||
// TODO: is this really what we mean by dc:format?
|
||||
|
||||
// upload the audio clip
|
||||
try {
|
||||
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) {
|
||||
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
|
||||
UploadFileWindow :: onCloseButtonClicked(void) throw ()
|
||||
{
|
||||
fileNameEntry->set_text("");
|
||||
titleEntry->set_text("");
|
||||
creatorEntry->set_text("");
|
||||
genreEntry->set_text("");
|
||||
|
||||
statusBar->set_text("");
|
||||
|
||||
isAudioClipValid = false;
|
||||
|
||||
hide();
|
||||
}
|
||||
|
||||
|
|
|
@ -91,10 +91,11 @@ es:table
|
|||
|
||||
uploadButtonLabel:string { "Cargar" }
|
||||
closeButtonLabel:string { "Cancelar" }
|
||||
statusBar:string { "Barra de estatus" }
|
||||
|
||||
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
|
||||
|
|
|
@ -90,10 +90,11 @@ hu:table
|
|||
|
||||
uploadButtonLabel:string { "feltölt" }
|
||||
closeButtonLabel:string { "bezár" }
|
||||
statusBar:string { "állapotsor" }
|
||||
|
||||
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
|
||||
|
|
|
@ -91,10 +91,11 @@ nl:table
|
|||
|
||||
uploadButtonLabel:string { "Verzenden" }
|
||||
closeButtonLabel:string { "Annuleer" }
|
||||
statusBar:string { "status balk" }
|
||||
|
||||
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
|
||||
|
|
|
@ -91,10 +91,11 @@ root:table
|
|||
|
||||
uploadButtonLabel:string { "Upload" }
|
||||
closeButtonLabel:string { "Cancel" }
|
||||
statusBar:string { "status bar" }
|
||||
|
||||
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
|
||||
|
|
|
@ -91,10 +91,11 @@ sr_CS:table
|
|||
|
||||
uploadButtonLabel:string { "Aploud" }
|
||||
closeButtonLabel:string { "Otkaži" }
|
||||
statusBar:string { "status bar" }
|
||||
|
||||
fileChooserDialogTitle:string { "Izaberi fajl" }
|
||||
clipUploadedMessage:string { "Aploudovan klip {0}" }
|
||||
clipUploadedMsg:string { "Aploudovan klip ''{0}''." }
|
||||
couldNotOpenFileMsg:string { "*** translate me ***" }
|
||||
missingTitleMsg:string { "*** translate me ***" }
|
||||
}
|
||||
|
||||
simplePlaylistManagementWindow:table
|
||||
|
|
|
@ -90,10 +90,11 @@ sr_CS_CYRILLIC:table
|
|||
|
||||
uploadButtonLabel:string { "Аплоуд" }
|
||||
closeButtonLabel:string { "Откажи" }
|
||||
statusBar:string { "статус бар" }
|
||||
|
||||
fileChooserDialogTitle:string { "Изабери фајл" }
|
||||
clipUploadedMessage:string { "Аплоудован клип {0}" }
|
||||
clipUploadedMsg:string { "Аплоудован клип ''{0}''." }
|
||||
couldNotOpenFileMsg:string { "*** translate me ***" }
|
||||
missingTitleMsg:string { "*** translate me ***" }
|
||||
}
|
||||
|
||||
simplePlaylistManagementWindow:table
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue