[mythtv] Guide to write a plugin?
Josh Lefler
joshlefler at leflerinc.com
Thu Oct 12 17:23:04 UTC 2006
Henrik,
I recently wrote my first plugin for myth (Ticket #2482) and had much
the same dilemma as you when I got started. Here are a few bits of
information that made the process easier for me:
The menus for MythTV are created from XML files that generally, but not
always, end in menu.xml. You can manually modify one of these files to
get your plugin to show up in the menu. See Ticket 2475 to see how I
modified a few of the menus to replace an old plugin with my new one.
Secondly, know that the plugin architecture is really pretty simple.
Each plugin has three functions that Myth may run - init, run, and
config. Init is run whenever mythfrontend starts and should handle
things like upgrading gracefully, etc. Run is ran when someone actually
selects the menu item for your plugin (with the action defined something
like PLUGIN (yourpluginname). Finally, config is ran when someone
selects your plugin from within a configuration menu.
Essentially - the init is always run when mythfrontend starts. You get
the other two to run by adding the appropriate menu items in the
appropriate places.
Next, the UI for your plugin itself. Myth has an internal UI system that
is pretty easy to use once you grok it. Basically, you define your UI
with an XML file. Contained within this UI is the elements that you need
to display and interact with from code. Myth parses the XML file and
creates the appropriate GUI, then you can use some myth functions to
grab handlers for each of the UI elements so you can then interact with
them like you would a GUI object in just about any other language.
Settings: Use gContext->GetSetting and gContext->SaveSetting to save
simple bits of data to/from the database. For more complex stuff,
interact with the database using Myth's dbcon class.
I referenced the game class heavily when writing my plugin because it
was the most similar to my end-goal.
I'm available if you have any questions or I can be of any assistance.
Josh Lefler
Lefler, Inc.
Henrik Gammelmark wrote:
> I have looked around on mythtv.org, but I cannot seem to find any
> documentation / howtos / turorials / faqs on how to build a simple
> plugin for MythTV.
>
> Does anyone know of any such guide or at least some sort of
> documentation to use? For starters I wish to create simple Hello World
> plugin that appears in the main menu, and responds to a keystroke (or
> lirc key) by doing something useless.
>
> In #mythtv @ Freenode, I was told that there is no such guide or sample
> plugin, and the best way to go about it, is study an existing plugin. So
> I started taking apart mythweather, but I quickly got stuck.
>
> Any pointers would be helpful - what is the bare minimum of code
> required to accomplish the above task, and also, what is the build
> procedure? I never used qmake before, and I'm not sure I understand what
> it does.
>
> Thank you very much in advance
>
> / Henrik
> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
>
More information about the mythtv-dev
mailing list