After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 607230 - Smart file open
Smart file open
Status: RESOLVED OBSOLETE
Product: gnome-subtitles
Classification: Other
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Maintainers of GNOME subtitles
Maintainers of GNOME subtitles
Depends on:
Blocks:
 
 
Reported: 2010-01-17 16:10 UTC by Pedro Castro
Modified: 2018-09-21 16:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
a rough implamentation of a multiple file open dialog (40.67 KB, patch)
2011-06-10 22:45 UTC, Keith
needs-work Details | Review
Slightly Better ? (47.78 KB, patch)
2011-09-04 23:21 UTC, Keith
none Details | Review
a hopefully correct patch file (53.36 KB, patch)
2011-09-13 22:33 UTC, Keith
none Details | Review

Description Pedro Castro 2010-01-17 16:10:18 UTC
In the file open dialog, allow to select 2 files: subtitles and video. Automatically detect which is which on confirmation.
Comment 1 Keith 2011-05-20 21:42:40 UTC
Could this bug and 
>>https://bugzilla.gnome.org/show_bug.cgi?id=511166
be wrapped up into mono-develop style welcome screen.
    Starting a project would open a wizard to import video, audio, source translation and other language translations.
A project list could be maintained along side an alternative recent files list.
Comment 2 Pedro Castro 2011-05-22 21:51:36 UTC
Keith, I've added your comment in bug #511166. 

This bug actually corresponds to a different thing: in the File Open dialog, the ability to select subtitle and video files at once, instead of the current File->Open for subtitle selection and Video->Open for video selection.
Comment 3 Keith 2011-05-22 22:35:13 UTC
well that's easier half the code is already there.
   I want to allow selecting the translation file alongside (3 files)
is there any 
  -consistent meta-data in all subtitle files that will make identifying the translation easier
  - or any tools in sublib i might have missed which can auto detect language
    (the file not in the users native language is the translation.)
(assuming not all translations will be started in gsub)
(assuming that smart open shouldn't fail if google translate is unreachable)
Comment 4 Pedro Castro 2011-05-24 20:47:05 UTC
Keith, language detection is an excellent idea. I've reported it in bug #651006.

The subtitle files we support don't have metadata unfortunately. Distinguishing text from translation files, without text-based detection, could be based on the filenames. It's a very unreliable method though... example: the longest filename is for the translation, assuming users typically add some suffixes to the original filename to mark it as translation, like MyVideoTranslation.srt or MyVideo-PT.srt.
Comment 5 Keith 2011-06-10 22:45:21 UTC
Created attachment 189699 [details] [review]
a rough implamentation of a multiple file open dialog 

This patch breaks video and translation open dialogs
On attempting to open 2 subtitle files there are a few gtk errors and a momentary pause; I am aware of this.
Comment 6 Keith 2011-06-10 22:46:07 UTC
Ok so I have a rough patch

Id like some ideas on :
-best way to provide user notifications when they try 2 say open 3 videos etc.
-the Ui in general
- I've removed video auto-select but it could go back in easily, should it ? 
-would it be worth it to allow users to select from across multiple folders if so how would the possibility be expressed to users;
- The SelectedFile class calls FileTools.DetectTranslation(filepath) which currently returns a bool any further methods of determining if a file would allow a score to be returned hopefully allowing for much better auto-selection of translation files;
- I name methods classes objects and variables terribly any1 know a good book on good naming practices;  

Also I've noticed ArryLists throughout the project is this a design choice or an anachronism ?
Comment 7 Pedro Castro 2011-06-23 13:58:05 UTC
Keith, I haven't had a chance to review your patch yet, but I'll try to do so in the next few days. OTM, regarding some of your notes:

(In reply to comment #6)
> -best way to provide user notifications when they try 2 say open 3 videos etc.
IMHO I think notifications may not be necessary here. Some ideias:
a) Complex implementation: if a user selects a video having another one already selected, unselect the previous one. The same for subtitle files if selecting more than 2. In the end, the user never ends up selecting >1 video or >2 subtitle files.
b) Simple: just use the first 2 subtitle files and first video if the user selects more than that.

> - I've removed video auto-select but it could go back in easily, should it ? 
I think the most basic way to open files is to double click the subtitle file and have the video automatically open because it has the same name. So for now I'd only disable video selection if the user selects a video file directly. In the future, though, it's possible that we find the new feature so easy to use that the video selection isn't needed anymore, but I wouldn't remove it right now.

> -would it be worth it to allow users to select from across multiple folders if
> so how would the possibility be expressed to users;
I think this would require a complex UI that would hard for the users to understand. If the users have files in different places they can always open 1 file then use the Translation/video open to go after the other files.

> - I name methods classes objects and variables terribly any1 know a good book
> on good naming practices;  
I'll try to give you some feedback as I review the code. OTM, here are some references that may be useful:
http://msdn.microsoft.com/en-us/library/ms229045.aspx
http://www.csharpfriends.com/articles/getarticle.aspx?articleid=336


> Also I've noticed ArryLists throughout the project is this a design choice or
> an anachronism ?
Please share the alternatives you have in mind!

Cheers
Comment 8 Pedro Castro 2011-06-26 12:41:31 UTC
Review of attachment 189699 [details] [review]:

Some general thoughts:
- I think we should have a combo box for chosing the translation file, besides the video file, in the File Open dialog. When no file is selected, it would show all subtitle files in the current dir and the user could select it directly. If 2 subtitle files were selected, we would show only those 2 in the combo box, detect which one *should* be the translation and select it, but the user could select the other one in case our selection was wrong.
- The video file combo box should be kept, showing all files in case of no selection, and the selected video file if one was selected.

::: src/GnomeSubtitles/Core/FileTools.cs
@@ +29,3 @@
+		
+	private static Regex videoFilesRegex = new Regex(@"^.*\.((3g2)|(3gp)|(asf)|(avi)|(bdm)|(cpi)|(divx)|(flv)|(m4v)|(mkv)|(mod)|(mov)|(mp3)|(mp4)|(mpeg)|(mpg)|(mts)|(ogg)|(ogm)|(rm)|(rmvb)|(spx)|(vob)|(wav)|(wma)|(wmv)|(xvid))$");
+	private static Regex subtitleFilesRegex = new Regex(@"^.*\.((sub)|(srt)|(ssa)|(ass)|(mpl)|(aqt)|(scr)|(pjs)|(pan)|(txt)|(vsf)|(dks)|(psb)|(vkt)|(lrc))$");

It would be better / easier to maintain if this regex were built automatically based on Subtitles.AvailableTypes, similar to FileOpenDialog.SetFilters().

@@ +30,3 @@
+	private static Regex videoFilesRegex = new Regex(@"^.*\.((3g2)|(3gp)|(asf)|(avi)|(bdm)|(cpi)|(divx)|(flv)|(m4v)|(mkv)|(mod)|(mov)|(mp3)|(mp4)|(mpeg)|(mpg)|(mts)|(ogg)|(ogm)|(rm)|(rmvb)|(spx)|(vob)|(wav)|(wma)|(wmv)|(xvid))$");
+	private static Regex subtitleFilesRegex = new Regex(@"^.*\.((sub)|(srt)|(ssa)|(ass)|(mpl)|(aqt)|(scr)|(pjs)|(pan)|(txt)|(vsf)|(dks)|(psb)|(vkt)|(lrc))$");
+	private static Regex translationfilesRegex = new Regex(@"(\([a-z][a-z]*_*[a-z]*.translation\))$");

Should we look for the "translation" keyword here? It is a good ideia to have some keyword to identify translations, but this would only work with *our* saved translations (where we could use that keyword by default). Also "translation" isn't localized (i18n) and localization would make it even harder to detect. I'd use the file with the longest name as translation, which would work in this and other cases. If the detection was wrong, the user could use another translation in the combo box.
Comment 9 Keith 2011-09-04 23:21:38 UTC
Created attachment 195646 [details] [review]
Slightly Better ?
Comment 10 Keith 2011-09-13 22:33:59 UTC
Created attachment 196444 [details] [review]
a hopefully correct patch file

Smart File Open done to a working and hopefully clear standard.
-- FileTools is a  static class idk if it should be a singleton, regular object or its functions moved into another Util.
-- Function GetCleanFilename in FileTools cannot remove "translation" or its translations as I can't iterate through the catalog and i didnt want to remove the an entire match to a @"^(translation, en-uk)" style regex.
Comment 11 GNOME Infrastructure Team 2018-09-21 16:05:58 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-subtitles/issues/37.