From 59920a2d1430828e13fdbbd90e861eb4cad862a8 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Wed, 22 Jun 2005 16:57:26 +0000 Subject: [PATCH] tweaked user interface behavior in UploadFileWindow --- .../gLiveSupport/src/UploadFileWindow.cxx | 174 +++++++++--------- livesupport/products/gLiveSupport/var/es.txt | 5 +- livesupport/products/gLiveSupport/var/hu.txt | 5 +- livesupport/products/gLiveSupport/var/nl.txt | 5 +- .../products/gLiveSupport/var/root.txt | 5 +- .../products/gLiveSupport/var/sr_CS.txt | 5 +- .../gLiveSupport/var/sr_CS_CYRILLIC.txt | 5 +- 7 files changed, 108 insertions(+), 96 deletions(-) diff --git a/livesupport/products/gLiveSupport/src/UploadFileWindow.cxx b/livesupport/products/gLiveSupport/src/UploadFileWindow.cxx index cce038141..74cddd3e3 100644 --- a/livesupport/products/gLiveSupport/src/UploadFileWindow.cxx +++ b/livesupport/products/gLiveSupport/src/UploadFileWindow.cxx @@ -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::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,57 +226,56 @@ UploadFileWindow :: updateFileInfo(void) throw () Ptr::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(); - return; - } + // see if the file exists, and is readable + std::ifstream file(fileName.c_str()); + if (!file.good()) { file.close(); - isAudioClipValid = true; - - Ptr::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::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::Ref creator - = audioClip->getMetadata("dc:creator"); - creatorEntry->set_text(creator ? *creator : ""); - - Ptr::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()); + statusBar->set_text(*getResourceUstring("couldNotOpenFileMsg")); + isAudioClipValid = false; + return; } + file.close(); + + Ptr::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::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::Ref creator + = audioClip->getMetadata("dc:creator"); + creatorEntry->set_text(creator ? *creator : ""); + + Ptr::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 UploadFileWindow :: onUploadButtonClicked(void) throw () { + if (!isAudioClipValid) { + return; + } + + Ptr::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 { - updateFileInfo(); - if (!isAudioClipValid) { - // TODO: localize error message - throw std::invalid_argument("file does not exist"); - } - - // set the metadata available - Ptr::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); - - // display success in the status bar - Ptr::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(); } diff --git a/livesupport/products/gLiveSupport/var/es.txt b/livesupport/products/gLiveSupport/var/es.txt index 576921a9d..17e06b9a5 100644 --- a/livesupport/products/gLiveSupport/var/es.txt +++ b/livesupport/products/gLiveSupport/var/es.txt @@ -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 diff --git a/livesupport/products/gLiveSupport/var/hu.txt b/livesupport/products/gLiveSupport/var/hu.txt index 4bf754f1b..25e65e388 100644 --- a/livesupport/products/gLiveSupport/var/hu.txt +++ b/livesupport/products/gLiveSupport/var/hu.txt @@ -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 diff --git a/livesupport/products/gLiveSupport/var/nl.txt b/livesupport/products/gLiveSupport/var/nl.txt index dea53898e..0990f6839 100644 --- a/livesupport/products/gLiveSupport/var/nl.txt +++ b/livesupport/products/gLiveSupport/var/nl.txt @@ -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 diff --git a/livesupport/products/gLiveSupport/var/root.txt b/livesupport/products/gLiveSupport/var/root.txt index d479090e1..3c6ffa3bf 100644 --- a/livesupport/products/gLiveSupport/var/root.txt +++ b/livesupport/products/gLiveSupport/var/root.txt @@ -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 diff --git a/livesupport/products/gLiveSupport/var/sr_CS.txt b/livesupport/products/gLiveSupport/var/sr_CS.txt index 471801993..9c4982942 100644 --- a/livesupport/products/gLiveSupport/var/sr_CS.txt +++ b/livesupport/products/gLiveSupport/var/sr_CS.txt @@ -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 diff --git a/livesupport/products/gLiveSupport/var/sr_CS_CYRILLIC.txt b/livesupport/products/gLiveSupport/var/sr_CS_CYRILLIC.txt index ffd002cb7..a4e128a66 100644 --- a/livesupport/products/gLiveSupport/var/sr_CS_CYRILLIC.txt +++ b/livesupport/products/gLiveSupport/var/sr_CS_CYRILLIC.txt @@ -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