[hdf-compass] 111/295: merged pull request #50 (recent file menu)

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun May 8 10:35:32 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository hdf-compass.

commit 9774067167633d294bf6f1651ca904e21f72e29e
Merge: 8f4039f fbcf850
Author: jreadey <jreadey at hdfgroup.org>
Date:   Tue Oct 6 12:27:52 2015 -0700

    merged pull request #50 (recent file menu)

 hdf_compass/compass_viewer/frame.py | 52 +++++++++++++++++++++++++++++++++----
 1 file changed, 47 insertions(+), 5 deletions(-)

diff --cc hdf_compass/compass_viewer/frame.py
index 4f2279e,c3d2c92..032d495
--- a/hdf_compass/compass_viewer/frame.py
+++ b/hdf_compass/compass_viewer/frame.py
@@@ -32,10 -28,9 +32,12 @@@ from . import platfor
  ID_OPEN_RESOURCE = wx.NewId()
  ID_CLOSE_FILE = wx.NewId()
  
 -import compass_model
++MAX_RECENT_FILES = 8
++
 +from hdf_compass import compass_model
  from .events import CompassOpenEvent
  
 +
  class BaseFrame(wx.Frame):
  
      """
@@@ -54,23 -49,10 +56,25 @@@
          """ Constructor; any keywords are passed on to wx.Frame.
          """
  
--        wx.Frame.__init__(self, None, **kwds)
- 
 -        self.filehistory = wx.FileHistory(8)
++        wx.Frame.__init__(self, None, **kwds) 
++        
 +        # Frame icon
 +        ib = wx.IconBundle()
 +        icon_32 = wx.EmptyIcon()
 +        icon_32.CopyFromBitmap(imagesupport.getbitmap('compass_32'))
 +        ib.AddIcon(icon_32)
 +        icon_48 = wx.EmptyIcon()
 +        icon_48.CopyFromBitmap(imagesupport.getbitmap('compass_48'))
 +        ib.AddIcon(icon_48)
 +        self.SetIcons(ib)
 +
 +        # This is needed to display the app icon on the taskbar on Windows 7
 +        if os.name == 'nt':
 +            import ctypes
 +            ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('HDFCompass')
- 
++        self.filehistory = wx.FileHistory(MAX_RECENT_FILES)
+         self.config = wx.Config("HDFCompass", style=wx.CONFIG_USE_LOCAL_FILE)
 -        self.filehistory.Load(self.config)
++        self.filehistory.Load(self.config) 
          menubar = wx.MenuBar()
  
          # File menu
@@@ -101,7 -89,9 +111,8 @@@
          self.Bind(wx.EVT_MENU, self.on_resource_open, id=ID_OPEN_RESOURCE)
          self.Bind(wx.EVT_MENU, self.on_about, id=wx.ID_ABOUT)
          self.Bind(wx.EVT_MENU, self.on_exit, id=wx.ID_EXIT)
+         self.Bind(wx.EVT_MENU_RANGE, self.on_file_history, id=wx.ID_FILE1, id2=wx.ID_FILE9)
  
 -    
      def on_exit(self, evt):
          """ Called on "exit" event from the menu """
          wx.GetApp().Exit()
@@@ -155,16 -145,40 +166,47 @@@
          if dlg.ShowModal() != wx.ID_OK:
              return
          path = dlg.GetPath()
++
 +        if sys.platform == 'win32':
 +            url = 'file:///' + path
 +        else:
 +            url = 'file://' + path
++            
+         self.filehistory.AddFileToHistory(path)
+         self.filehistory.Save(self.config)
+         self.config.Flush()
+             
+         url = 'file://'+path
++
          if not open_store(url):
+             self.filehistory.RemoveFileToHistory(path)
+             self.filehistory.Save(self.config)
+             self.config.Flush()
              dlg = wx.MessageDialog(self, 'The following file could not be opened:\n\n%s' % path,
-                                    'No handler for file', wx.OK | wx.ICON_INFORMATION)
+                                'No handler for file', wx.OK | wx.ICON_INFORMATION)
              dlg.ShowModal()
              dlg.Destroy()
- 
+     
+     def on_file_history(self, event):
+         """ Opens file from history """
+         fileNum = event.GetId() - wx.ID_FILE1
+         path = self.filehistory.GetHistoryFile(fileNum)
+         self.filehistory.AddFileToHistory(path)  # move up the list
+         self.filehistory.Save(self.config)
+         self.config.Flush()
+         
+         # open the file
+         from . import open_store
+         url = 'file://'+path
+         if not open_store(url):
+             self.filehistory.RemoveFileToHistory(path)
+             self.filehistory.Save(self.config)
+             self.config.Flush()
+             dlg = wx.MessageDialog(self, 'The following file could not be opened:\n\n%s' % path,
 -                               'No handler for file', wx.OK | wx.ICON_INFORMATION)
++                                   'No handler for file', wx.OK | wx.ICON_INFORMATION)
+             dlg.ShowModal()
 -            dlg.Destroy()
 -        
++            dlg.Destroy() 
++            
      def on_window_close(self, evt):
          """ Close Window file event, or cmd-W """
          self.Destroy()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/hdf-compass.git



More information about the debian-science-commits mailing list