This page tells you about basic functionalites available in MythTV for simpler plug-in development. It's based on a series of examples which shows the basic usage of those features.
Following section tells you some basic prerequisites for MythTV plug-in development
Every plug-in has four functions, which interface with MythTV.
- int mythplugin_init(const char *libversion) - executed during the MythTV start-up
- int mythplugin_run() - executed whenever the plug-in is selected from menu
- void mythplugin_destory() - executed during MythTV exit
- int mythplugin_config() - executed whenever the plug-in configuration button is selected from menu
Before we start
The easiest way to start developing is by checking out the git. When you configure it, it provides necessarily files and creates symlinks to your MythTV's files.
git clone git://github.com/MythTV/mythtv.git cd mythpluginis ./configure --prefix=/usr/ # you might want to change the prefix and other settings
Plug-in file structure
As the MythTV is written in QT the '*.pro' files are used to create Makefile files. For UI layout the XML files are used and individual elements are then assigned in C++ code.
Most plug-ins follows this file structure (root directory '/' is the mythplugins svn folder):
$plugin_name/ # Master project folder $plugin_name/$plugin_name/ # Plug-in C++ code $plugin_name/theme/ # Theme dummy files $plugin_name/theme/default/ # Place for UI XML files in 4:3 aspect $plugin_name/theme/default-wide/ # Place for UI XML files in 16:9 aspect $plugin_name/theme/menus/ # Place for additional menus (also in XML format)
To insert your plug-in into MythTV menu you need to modify the menu file. You need to do it manually as the menu themes are statically defined. The themes are located in "$prefix/share/mythtv/themes" folder, and the default menu theme can be found in the 'defaultmenu' folder. If you use a different menu theme, be sure to select the proper one. For inserting the plug-in into the main menu you need to edit the "mainmenu.xml". More on this topic is further on this page.
MythNotes is ONLY a TRAINING plug-in which increasingly leads you from simple Hello World to a complex plug-in including SQL storage and other features.
Create the mythnotes file structure:
cd $mythplugins_root # the svn folder with another plug-ins mkdir mythnotes mkdir mythnotes/mythnotes mkdir mythnotes/theme mkdir mythnotes/theme/default mkdir mythnotes/theme/default-wide mkdir mythnotes/theme/menus
From now on the root directory ('/' at the beginning) means the $mythplugins_root/mythnotes folder.
Couple of files are always the same/similar. Let's start with them. You can copy them from another example and modify them:
The plug-in has two executable parts (mythplugin_run and mythplugin_config) which needs to be selected from the MythTV menu. The "make install" command won't create the menu item as it can't know where to put it. You need to do this manually by changing the menu files. The are located in "$prefix/share/mythtv/themes/defaultmenu/" folder. For inserting the plug-in into the main menu you need to edit (if you are using the "default" menu theme - configured in "Utilities / Setup / Setup / Appearance / Menu theme") "mainmenu.xml". Similarly you can find another menus too.
After going through previous parts you are prepared to create your very first Hello World application and even more...
It says Hello World.
- Use XML to define layout
- Write simple text
Demonstrates some of available UIs.
- Use XML to define a page with multiple UI widgets
- Create basic signals and slots to handle the UI communication
Displays how many times was the plug-in executed since mythfrontend start.
- "Invisible" initialization and clean-up parts
- Second window for plug-in configuration
Storing the information
Stores full-text notes in one big textarea.
- Internal storage gContext
- Basic SQL storage
Shows list structure of objects stored in DB.
- Popup window
Advanced SQL storage
Stores full-text notes separately
- SQL layout initialization
- SQL layout update
- Using SQL commands