Example #1
0
	def menuCallback(self, *result):
		if not len(result):
			return
		result = result[0]

		if result == CutListContextMenu.RET_STARTCUT:
			self.cut_start = self.context_position
		elif result == CutListContextMenu.RET_ENDCUT:
			# remove in/out marks between the new cut
			for (where, what) in self.cut_list[:]:
				if self.cut_start <= where <= self.context_position and what in (0,1):
					self.cut_list.remove((where, what))

			bisect.insort(self.cut_list, (self.cut_start, 1))
			bisect.insort(self.cut_list, (self.context_position, 0))
			self.uploadCuesheet()
			self.cut_start = None
		elif result == CutListContextMenu.RET_DELETECUT:
			out_before = None
			in_after = None

			for (where, what) in self.cut_list:
				if what == 1 and where <= self.context_position: # out
					out_before = (where, what)
				elif what == 0 and where < self.context_position: # in, before out
					out_before = None
				elif what == 0 and where >= self.context_position and in_after is None:
					in_after = (where, what)

			if out_before is not None:
				self.cut_list.remove(out_before)

			if in_after is not None:
				self.cut_list.remove(in_after)
			self.inhibit_seek = True
			self.uploadCuesheet()
			self.inhibit_seek = False
		elif result == CutListContextMenu.RET_MARK:
			self.__addMark()
		elif result == CutListContextMenu.RET_DELETEMARK:
			self.cut_list.remove(self.context_nearest_mark)
			self.inhibit_seek = True
			self.uploadCuesheet()
			self.inhibit_seek = False
		elif result == CutListContextMenu.RET_REMOVEBEFORE:
			# remove in/out marks before current position
			for (where, what) in self.cut_list[:]:
				if where <= self.context_position and what in (0,1):
					self.cut_list.remove((where, what))
			# add 'in' point
			bisect.insort(self.cut_list, (self.context_position, 0))
			self.inhibit_seek = True
			self.uploadCuesheet()
			self.inhibit_seek = False
		elif result == CutListContextMenu.RET_REMOVEAFTER:
			# remove in/out marks after current position
			for (where, what) in self.cut_list[:]:
				if where >= self.context_position and what in (0,1):
					self.cut_list.remove((where, what))
			# add 'out' point
			bisect.insort(self.cut_list, (self.context_position, 1))
			self.inhibit_seek = True
			self.uploadCuesheet()
			self.inhibit_seek = False
		elif result == CutListContextMenu.RET_GRABFRAME:
			self.grabFrame()
		elif result == CutListContextMenu.RET_TOGGLEINTRO:
			self.toggleIntro()
		elif result == CutListContextMenu.RET_MOVIECUT:
			self.inhibit_seek = True
			self.uploadCuesheet()
			self.inhibit_seek = False
			self.session.nav.playService(self.old_service, forceRestart=True) #required for actually writing the .cuts file
			self.pauseService()
			try:
				MovieCut(session=self.session, service=self.session.nav.getCurrentlyPlayingServiceReference())
			except:
				print "[CutListEditor] calling MovieCut failed"
Example #2
0
    def menuCallback(self, *result):
        if not len(result):
            return
        result = result[0]

        if result == CutListContextMenu.RET_STARTCUT:
            self.cut_start = self.context_position
        elif result == CutListContextMenu.RET_ENDCUT:
            # remove in/out marks between the new cut
            for (where, what) in self.cut_list[:]:
                if self.cut_start <= where <= self.context_position and (
                        not config.plugins.CutListEditor.keep_bookmarks.value
                        or what in (0, 1)):
                    self.cut_list.remove((where, what))

            bisect.insort(self.cut_list, (self.cut_start, 1))
            bisect.insort(self.cut_list, (self.context_position, 0))
            self.uploadCuesheet()
            self.cut_start = None
        elif result == CutListContextMenu.RET_DELETECUT:
            out_before = None
            in_after = None

            for (where, what) in self.cut_list:
                if what == 1 and where <= self.context_position:  # out
                    out_before = (where, what)
                elif what == 0 and where < self.context_position:  # in, before out
                    out_before = None
                elif what == 0 and where >= self.context_position and in_after is None:
                    in_after = (where, what)

            if out_before is not None:
                self.cut_list.remove(out_before)

            if in_after is not None:
                self.cut_list.remove(in_after)
            self.inhibit_seek = True
            self.uploadCuesheet()
            self.inhibit_seek = False
        elif result == CutListContextMenu.RET_MARK:
            self.__addMark()
        elif result == CutListContextMenu.RET_DELETEMARK:
            self.cut_list.remove(self.context_nearest_mark)
            self.inhibit_seek = True
            self.uploadCuesheet()
            self.inhibit_seek = False
        elif result == CutListContextMenu.RET_REMOVEBEFORE:
            # remove in/out marks before current position
            for (where, what) in self.cut_list[:]:
                if where <= self.context_position and (
                        not config.plugins.CutListEditor.keep_bookmarks.value
                        or what in (0, 1)):
                    self.cut_list.remove((where, what))
            # add 'in' point
            bisect.insort(self.cut_list, (self.context_position, 0))
            self.inhibit_seek = True
            self.uploadCuesheet()
            self.inhibit_seek = False
        elif result == CutListContextMenu.RET_REMOVEAFTER:
            # remove in/out marks after current position
            for (where, what) in self.cut_list[:]:
                if where >= self.context_position and (
                        not config.plugins.CutListEditor.keep_bookmarks.value
                        or what in (0, 1)):
                    self.cut_list.remove((where, what))
            # add 'out' point
            bisect.insort(self.cut_list, (self.context_position, 1))
            self.inhibit_seek = True
            self.uploadCuesheet()
            self.inhibit_seek = False
        elif result == CutListContextMenu.RET_KEEPBOOKMARKS:
            config.plugins.CutListEditor.keep_bookmarks.value = not config.plugins.CutListEditor.keep_bookmarks.value
            config.plugins.CutListEditor.keep_bookmarks.save()
        elif result == CutListContextMenu.RET_GRABFRAME:
            self.grabFrame()
        elif result == CutListContextMenu.RET_TOGGLEINTRO:
            config.plugins.CutListEditor.showIntro.value = not config.plugins.CutListEditor.showIntro.value
            config.plugins.CutListEditor.showIntro.save()
        elif result == CutListContextMenu.RET_MOVIECUT:
            self.inhibit_seek = True
            self.uploadCuesheet()
            self.inhibit_seek = False
            self.session.nav.playService(self.old_service,
                                         forceRestart=True,
                                         adjust=False)
            if self.cut_service:
                try:
                    MovieCut(session=self.session, service=self.cut_service)
                except:
                    print "[CutListEditor] calling MovieCut failed"
            self.exit()