]> git.plutz.net Git - viper/blob - plugin.py
implemeted most basic cropping controls
[viper] / plugin.py
1 #encoding: utf-8
2 #Copyright 2009 Paul Hänsch
3
4 #This file is part of Viper.
5
6 #Viper is free software: you can redistribute it and/or modify
7 #it under the terms of the GNU General Public License as published by
8 #the Free Software Foundation, either version 3 of the License, or
9 #(at your option) any later version.
10
11 #Viper is distributed in the hope that it will be useful,
12 #but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #GNU General Public License for more details.
15
16 #You should have received a copy of the GNU General Public License
17 #along with Viper.  If not, see <http://www.gnu.org/licenses/>
18
19 from Tkinter import *
20 import Pmw
21 import os
22
23 class ViperPlugin(Frame, object):
24     """
25     Every plugin has to inherit from a class deriving from this one.
26
27     Inherit from a subclass of this class. Inheriting from this class itself will be
28     useless. Subclasses are:
29     C_Plugin - Use this to write a plugin for defining an export container format.
30     A_Plugin - Use this to write a plugin for defining an export audio format.
31     V_Plugin - Use this to write a plugin for defining an export video format.
32     F_Plugin - Base class for filter plugins (filters can be applied to video chunks).
33     E_Plugin - Base class for effect plugins (effects can only be applied to framesets).
34
35     A plugin should implement the following methods:
36     build_dialog()
37     name()
38     subcommand()
39     is_available()
40
41     See the description below.
42     """
43     def __init__(self, parent):
44         """
45         Constructor, do NOT override
46
47         The constructor creates a frame which can hold all configuration elements. It calls
48         self.build_dialog() which you can use to build interface elemnts and do
49         initialization work. The dictionary "self.subgets" can and should be used to store
50         all configuration values.
51         """
52         Frame.__init__(self, parent)
53
54         self.subgets = {}
55         self.build_dialog()
56
57     def build_dialog(self):
58         """
59         Display the plugins configuration dialog.
60
61         Override this method and store the generated data to the "self.subgets" dictionary.
62         """
63         self.subgets['warning'] = Label(self, text = 'Warning!\n' +
64                                         'This is an empty plugin. Run "pydoc plugin"' +
65                                         'to learn how to build proper plugins.')
66         self.subgets['warning'].pack(expand = True, fill = BOTH)
67
68     def name(self):
69         """
70         Return the name of this plugin.
71
72         This should be a single line function. The returned name will be used in the UI.
73         """
74         return '!!Not named!!'
75
76     def subcommand(self):
77         """
78         Return a list of mplayer command line arguments.
79
80         Depending on the nature of your plugin this will be inserted into the mplayer/mencoder
81         command line to perform the specified operation. I.e. a simple container plugin could
82         return ['-of', 'avi']
83         """
84         return []
85
86     def is_available(self):
87         """
88         Check the availability of this plugin.
89
90         Return True if your plugin is available and False if not. This method can
91         be used for running mplayer and checking the availability of output codecs etc.
92         If not overridden it will always return True making your plugin available.
93         """
94         return True
95
96 class C_Plugin(ViperPlugin): pass
97 class A_Plugin(ViperPlugin): pass
98 class V_Plugin(ViperPlugin): pass
99 class F_Plugin(ViperPlugin): pass
100 class E_Plugin(ViperPlugin): pass