コード例 #1
0
ファイル: filemanager.py プロジェクト: amolenaar/gaphor
    def update_recent_files(self, new_filename=None):
        """Updates the list of recent files.  If the new_filename
        parameter is supplied, it is added to the list of recent files.

        The default recent file placeholder actions are hidden.  The real
        actions are then built using the recent file list."""

        log.info("Updating recent files")
        log.debug("New file is %s" % new_filename)

        recent_files = self.recent_files

        if new_filename and new_filename not in recent_files:
            recent_files.insert(0, new_filename)
            recent_files = recent_files[0 : (MAX_RECENT - 1)]
            self.recent_files = recent_files

        for i in range(0, (MAX_RECENT - 1)):
            action = self.action_group.get_action("file-recent-%d" % i)
            action.set_property("visible", False)

        for i, filename in enumerate(recent_files):
            id = "file-recent%d" % i
            action = self.action_group.get_action("file-recent-%d" % i)
            action.props.label = "_%d. %s" % (i + 1, filename.replace("_", "__"))
            action.props.tooltip = "Load %s." % filename
            action.props.visible = True
コード例 #2
0
    def update_recent_files(self, new_filename=None):
        """Updates the list of recent files.  If the new_filename
        parameter is supplied, it is added to the list of recent files.
        
        The default recent file placeholder actions are hidden.  The real
        actions are then built using the recent file list."""
        
        self.logger.info('Updating recent files')
        self.logger.debug('New file is %s' % new_filename)

        recent_files = self.recent_files
        
        if new_filename and new_filename not in recent_files:
            recent_files.insert(0, new_filename)
            recent_files = recent_files[0:(MAX_RECENT-1)]
            self.recent_files = recent_files

        for i in range(0, (MAX_RECENT-1)):
            action = self.action_group.get_action('file-recent-%d' % i)
            action.set_property('visible', False)

        for i, filename in enumerate(recent_files):
            id = 'file-recent%d' % i
            action = self.action_group.get_action('file-recent-%d' % i)
            action.props.label = '_%d. %s' % (i+1, filename.replace('_', '__'))
            action.props.tooltip = 'Load %s.' % filename
            action.props.visible = True
コード例 #3
0
ファイル: filemanager.py プロジェクト: paulopperman/gaphor
    def update_recent_files(self, new_filename=None):
        """Updates the list of recent files.  If the new_filename
        parameter is supplied, it is added to the list of recent files.

        The default recent file placeholder actions are hidden.  The real
        actions are then built using the recent file list."""

        log.info("Updating recent files")
        log.debug("New file is %s" % new_filename)

        recent_files = self.recent_files

        if new_filename and new_filename not in recent_files:
            recent_files.insert(0, new_filename)
            recent_files = recent_files[0:(MAX_RECENT - 1)]
            self.recent_files = recent_files

        for i in range(0, (MAX_RECENT - 1)):
            action = self.action_group.get_action("file-recent-%d" % i)
            action.set_property("visible", False)

        for i, filename in enumerate(recent_files):
            id = "file-recent%d" % i
            action = self.action_group.get_action("file-recent-%d" % i)
            action.props.label = "_%d. %s" % (i + 1, filename.replace(
                "_", "__"))
            action.props.tooltip = "Load %s." % filename
            action.props.visible = True
コード例 #4
0
ファイル: filemanager.py プロジェクト: adamboduch/gaphor
    def update_recent_files(self, new_filename=None):
        """Updates the list of recent files.  If the new_filename
        parameter is supplied, it is added to the list of recent files.
        
        The default recent file placeholder actions are hidden.  The real
        actions are then built using the recent file list."""
        
        self.logger.info('Updating recent files')
        self.logger.debug('New file is %s' % new_filename)

        recent_files = self.recent_files
        
        if new_filename and new_filename not in recent_files:
            recent_files.insert(0, new_filename)
            recent_files = recent_files[0:(MAX_RECENT-1)]
            self.recent_files = recent_files

        for i in xrange(0, (MAX_RECENT-1)):
            action = self.action_group.get_action('file-recent-%d' % i)
            action.set_property('visible', False)

        for i, filename in enumerate(recent_files):
            id = 'file-recent%d' % i
            action = self.action_group.get_action('file-recent-%d' % i)
            action.props.label = '_%d. %s' % (i+1, filename.replace('_', '__'))
            action.props.tooltip = 'Load %s.' % filename
            action.props.visible = True
コード例 #5
0
    def init(self, app):
        """File manager service initialization.  The app parameter
        is the main application object.  This method builds the
        action group in the file menu.  The list of recent
        Gaphor files is then updated in the file menu."""
    
        self.action_group = build_action_group(self)

        for name, label in (('file-recent-files', '_Recent files'),):
            action = gtk.Action(name, label, None, None)
            action.set_property('hide-if-empty', False)
            self.action_group.add_action(action)

        for i in range(0, (MAX_RECENT-1)):
            action = gtk.Action('file-recent-%d' % i, None, None, None)
            action.set_property('visible', False)
            self.action_group.add_action(action)
            action.connect('activate', self.load_recent, i)
            
        self.update_recent_files()
コード例 #6
0
ファイル: filemanager.py プロジェクト: amolenaar/gaphor
    def init(self, app):
        """File manager service initialization.  The app parameter
        is the main application object.  This method builds the
        action group in the file menu.  The list of recent
        Gaphor files is then updated in the file menu."""

        self.action_group = build_action_group(self)

        for name, label in (("file-recent-files", "_Recent files"),):
            action = Gtk.Action.new(name, label, None, None)
            action.set_property("hide-if-empty", False)
            self.action_group.add_action(action)

        for i in range(0, (MAX_RECENT - 1)):
            action = Gtk.Action.new("file-recent-%d" % i, None, None, None)
            action.set_property("visible", False)
            self.action_group.add_action(action)
            action.connect("activate", self.load_recent, i)

        self.update_recent_files()
コード例 #7
0
    def __init__(self, event_manager, element_factory, main_window, properties):
        """File manager constructor.  There is no current filename yet."""
        self.event_manager = event_manager
        self.element_factory = element_factory
        self.main_window = main_window
        self.properties = properties
        self._filename = None
        self.action_group = build_action_group(self)

        for name, label in (("file-recent-files", "_Recent files"),):
            action = Gtk.Action.new(name, label, None, None)
            action.set_property("hide-if-empty", False)
            self.action_group.add_action(action)

        for i in range(0, (MAX_RECENT - 1)):
            action = Gtk.Action.new("file-recent-%d" % i, None, None, None)
            action.set_property("visible", False)
            self.action_group.add_action(action)
            action.connect("activate", self.load_recent, i)

        self.update_recent_files()

        event_manager.subscribe(self._on_window_close)