/usr/share/doc/freevo/plugin_writing/x69.html is in freevo-doc 1.9.2b2-4.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>The Menu System</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="Freevo Plugin Writing HOWTO"
HREF="index.html"><LINK
REL="UP"
TITLE="Internal Structure"
HREF="c50.html"><LINK
REL="PREVIOUS"
TITLE="Events"
HREF="x55.html"><LINK
REL="NEXT"
TITLE="GUI Objects"
HREF="x105.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Freevo Plugin Writing HOWTO: Writing your own plugins for Freevo</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x55.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 2. Internal Structure</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x105.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="AEN69"
>2.3. The Menu System</A
></H1
><P
> Menu's in freevo are done using the classes described below. But in general they are essential lists of items which have their names displayed in the list. Each item then has actions associated with them. The first action is the one used when selected and you can use enter to see the others. Menu's also have actions that can be associated with them to perform actions or updates.
</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN72"
>2.3.1. Menu</A
></H2
><P
> Menu is essentially a class wrapped around an array of choices. It has several methods but the constructor is the most commonly used. It takes a title, then an array of options, and then some optional parameters. The reload_func is the most commonly used. The reload_func is used when you come back from executing an item. It's only used when you want to show something other than the menu you started with when you come back.
</P
><PRE
CLASS="PROGRAMLISTING"
>
# make the command menu using the command_items array and when we call refresh with the reload arg we go back to the main menu.
command_menu = menu.Menu(_('Commands'), command_items, reload_func=menuwidget.goto_main_menu)
#make a basic menu with the string variable name for its name and items the array of choices.
mymenu = menu.Menu(name, items)
</PRE
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN77"
>2.3.2. Item</A
></H2
><P
>Item is the base class for anything that appears in the Menu. Generally you create a subclass of Item and then create an actions method to tell the menu what to do when the item is clicked. The name property is what the Menu object uses to display on the screen. You can then create other variables to hold important data points in.</P
><PRE
CLASS="PROGRAMLISTING"
>class CoolItem(Item):
def __init__(self, command):
Item.__init__(self)
self.name = command
self.image = util.getimage(self.cmd)
def actions(self):
"""
return a list of actions for this item
"""
items = [ ( self.runMyCommand , _('Run Command') ) ]
return items
def runMyCommand(self, arg=None, menuw=None):
# do some real cool stuff..
</PRE
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN82"
>2.3.3. MenuItem</A
></H2
><P
>This is a convenience class it is useful in two different situations. The first and most common is for creating Menus to display error conditions. The second use is for when you only need a very simple item with a single easy action.</P
><P
>To use MenuItem in the error condition case you call the constructor with three parameters. The first parameter is what to display in the menu, the second is the action to take when the item to select and the third is put the arg to the action function. In this case you typically wrap the constructor call into an append to your list of items to be given to menu.</P
><P
>To use MenuItem as a simple Item and not bother with creating your own sub item class, you again call the constructor with the set of three parameters. The first parameter is what to display in the menu, the second is the action to take when the item to select and the third is put the arg to the action function. But typically you save a reference to this item and set a few additional parameters manually.</P
><PRE
CLASS="PROGRAMLISTING"
># you would then create a menu like normal and then push it onto the stack
command_items += [menu.MenuItem(_('No Commands found'), menuwidget.goto_prev_page, 0)]
# generic item use for things that are simple
# you would then create a menu like normal and then push it onto the stack
if item.info.has_key('audio'):
items.append(menu.MenuItem(_('Audio selection'), audio_selection_menu, item))
if item.info.has_key('subtitles'):
items.append(menu.MenuItem(_('Subtitle selection'), subtitle_selection_menu, item))
if item.info.has_key('chapters'):
items.append(menu.MenuItem(_('Chapter selection'), chapter_selection_menu, item))
</PRE
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN89"
>2.3.4. MenuWidget</A
></H2
><P
>MenuWidget or menuw as it is often labelled in the code. Is a handy utility class where most of the menu magic happens. It has most of the default utility actions for menus as well as the methods to manage the menu stack.</P
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>Common Menu Actions:</I
></SPAN
></P
><P
>back_one_menu -- goes to the previous menu. Typically used after deleteing the current menu. see cdbackup.py for an example.</P
><P
>goto_main_menu -- jumps all the way back to the main menu.</P
><P
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>List of menu stack actions:</I
></SPAN
></P
><P
>pushmenu -- used after constructing a menu, then typically a call to refresh to display the menu.</P
><P
>refresh -- redraw the top item on the menu stack. It is usually called after a pushmenu call.</P
><P
>delete_menu -- remove the currently displayed menu.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN101"
>2.3.5. A full example to bring it all together</A
></H2
><PRE
CLASS="PROGRAMLISTING"
># list of items to go in the menu
mylistofitems = []
# a call to a function that returns an array of objects you would create
# your menu from. for example a call to os.listdir to return a list of strings
# containing filenames
mylistofobjects = some_func_that_returns_you_list()
# loop through our object list and add each item to the list for the menu
for myobject in mylistofobjects:
img_item = ImageItem(myobject, self)
mylistofitems += [ img_item ]
# handle the no objects found case if we get an empty list
# this uses a single menu item
if (len(mylistofitems) == 0):
mylistofitems += [menu.MenuItem(_('No Objects found'),
menuw.back_one_menu, 0)]
# create the menu using your menu list
myobjectmenu = menu.Menu(_('My Image Objects'), mylistofitems,
reload_func=menuw.back_one_menu )
# tells freevo to give rc control to the menu
rc.app(None)
# now we push our menu on the top of the stack and tell it to display
menuw.pushmenu(myobjectmenu)
menuw.refresh()
</PRE
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x55.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x105.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Events</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c50.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>GUI Objects</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
|