theme.c File Reference

Reads theme XML files. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/xmlreader.h>
#include <rfb/rfb.h>
#include "xmlutil.h"
#include "display.h"
#include "theme.h"
#include "keys.h"

Include dependency graph for theme.c:


Data Structures

struct  theme_button_key_mapping
 Button -> keycode mapping entry. More...

Defines

#define THEME_XML   "theme.xml"
#define THEME_ATTR_FILE   "file"
#define THEME_ATTR_TRANSPARENCY   "transparency"
#define THEME_ATTR_TYPE   "type"
#define THEME_ATTR_X   "x"
#define THEME_ATTR_Y   "y"
#define THEME_ATTR_SCALE   "scale"
#define THEME_ATTR_WIDTH   "width"
#define THEME_ATTR_HEIGHT   "height"
#define THEME_ATTR_ROTATE   "rotate"
#define THEME_ATTR_NAME   "name"
#define THEME_ATTR_FORECOLOR   "forecolor"
#define THEME_ATTR_CODE   "code"
#define THEME_ATTR_MODIFIER   "modifier"
#define THEME_ATTR_EXEC   "exec"
#define THEME_ELEM_BITMAP   "bitmap"
#define THEME_ELEM_DISPLAY   "display"
#define THEME_ELEM_BUTTON   "button"
#define THEME_ELEM_COVER   "cover"
#define THEME_ELEM_KEY   "key"
#define THEME_BITMAP_TYPE_LAYOUT   "layout"
#define THEME_BITMAP_TYPE_BUTTONS   "buttons"

Functions

static int theme_xml_process_bitmap (xmlTextReaderPtr reader, struct theme *theme)
static int theme_xml_process_display (xmlTextReaderPtr reader, struct theme *theme)
static int theme_xml_process_cover (xmlTextReaderPtr reader, struct theme *theme)
static int theme_xml_process_button (xmlTextReaderPtr reader, struct theme *theme)
static int theme_xml_process_key (xmlTextReaderPtr reader, struct theme *theme)
static int theme_xml_process_node (xmlTextReaderPtr reader, struct theme *theme)
static int theme_check (struct theme *theme)
struct themetheme_load (char *theme_dir)
void theme_cleanup (struct theme *theme)

Variables

static struct
theme_button_key_mapping 
button_key_mapping []
const int theme_key_mapping_size

Detailed Description

Fills a theme structure with the obtained data.
Example theme file:
 <theme>
     <display x="87" y="33" forecolor="2b5774"/>
     <bitmaps>
         <bitmap type="layout"  file="layout.png"/>
         <bitmap type="buttons" file="buttons.png" transparency="000000"/>
     </bitmaps>
     <cover x="551" y="32" width="121" height="121" rotate="90"/>   
     <buttons>
         <button name="halt"     x="16"  y="24"  width="50" height="49"/>
         <button name="eject"    x="16"  y="216" width="50" height="49"/>
         <button name="back"     x="105" y="216" width="50" height="49"/>
         <button name="stop"     x="183" y="216" width="50" height="49"/>
         <button name="play"     x="263" y="216" width="50" height="49"/>
         <button name="forward"  x="343" y="216" width="50" height="49"/>
         <button name="record"   x="419" y="216" width="50" height="49"/>
         <button name="left"     x="561" y="205" width="36" height="25"/>
         <button name="up"       x="598" y="169" width="24" height="36"/>
         <button name="down"     x="598" y="230" width="24" height="36"/>
         <button name="right"    x="622" y="205" width="36" height="25"/>
         <button name="f1"       x="504" y="38"  width="30" height="30"/>
         <button name="f2"       x="504" y="78"  width="30" height="30"/>
         <button name="f3"       x="504" y="118" width="30" height="30"/>
         <button name="f4"       x="504" y="158" width="30" height="30"/>
         <button name="sleep_60" x="452" y="216" width="50" height="49"
                 exec="/opt/scripts/sleep60.sh" />
     </buttons>
     <keys>
         <key name="sleep_60" code="115" modifier="65507"
              exec="/opt/scripts/sleep60.sh" />
     </keys>
 </theme>

Define Documentation

#define THEME_XML   "theme.xml"

Filename of theme XML file.

#define THEME_ATTR_FILE   "file"

XML attribute for a filename.

#define THEME_ATTR_TRANSPARENCY   "transparency"

XML attribute for a transparency color.

#define THEME_ATTR_TYPE   "type"

XML attribute for a bitmap type.

#define THEME_ATTR_X   "x"

XML attribute for a x-coordinate.

#define THEME_ATTR_Y   "y"

XML attribute for a y-coordinate.

#define THEME_ATTR_SCALE   "scale"

XML attribute for a scale factor.

#define THEME_ATTR_WIDTH   "width"

XML attribute for a width.

#define THEME_ATTR_HEIGHT   "height"

XML attribute for a height.

#define THEME_ATTR_ROTATE   "rotate"

XML attribute for a rotation value.

#define THEME_ATTR_NAME   "name"

XML attribute for a name.

#define THEME_ATTR_FORECOLOR   "forecolor"

XML attribute for a foreground color.

#define THEME_ATTR_CODE   "code"

XML attribute for a keycode.

#define THEME_ATTR_MODIFIER   "modifier"

XML attribute for a key modifier.

#define THEME_ATTR_EXEC   "exec"

XML attribute for a shell execution command.

#define THEME_ELEM_BITMAP   "bitmap"

XML element name for a bitmap node.

#define THEME_ELEM_DISPLAY   "display"

XML element name for a display node.

#define THEME_ELEM_BUTTON   "button"

XML element name for a button node.

#define THEME_ELEM_COVER   "cover"

XML element name for a cover node.

#define THEME_ELEM_KEY   "key"

XML element name for a key node.

#define THEME_BITMAP_TYPE_LAYOUT   "layout"

XML attribute value for a layout bitmap.

#define THEME_BITMAP_TYPE_BUTTONS   "buttons"

XML attribute value for a buttons bitmap.


Function Documentation

static int theme_xml_process_bitmap ( xmlTextReaderPtr  reader,
struct theme theme 
) [static]

Processes a bitmap node in a theme XML document.

Parameters:
reader the XML reader
theme theme data
Returns:
0 on success or -1 if an error occured

static int theme_xml_process_display ( xmlTextReaderPtr  reader,
struct theme theme 
) [static]

Processes the display node in a theme XML document.

Parameters:
reader the XML reader
theme theme data
Returns:
0 on success or -1 if an error occured

static int theme_xml_process_cover ( xmlTextReaderPtr  reader,
struct theme theme 
) [static]

Processes the cover node in a theme XML document.

Parameters:
reader the XML reader
theme theme data
Returns:
0 on success or -1 if an error occured

static int theme_xml_process_button ( xmlTextReaderPtr  reader,
struct theme theme 
) [static]

Processes a button node in a theme XML document.

Parameters:
reader the XML reader
theme theme data
Returns:
0 on success or -1 if an error occured

static int theme_xml_process_key ( xmlTextReaderPtr  reader,
struct theme theme 
) [static]

Processes a key node in a theme XML document.

Parameters:
reader the XML reader
theme theme data
Returns:
0 on success or -1 if an error occured

static int theme_xml_process_node ( xmlTextReaderPtr  reader,
struct theme theme 
) [static]

Processes a node in a theme XML document.

Parameters:
reader the XML reader
theme theme data
Returns:
0 on success or -1 if an error occured

static int theme_check ( struct theme theme  )  [static]

Checks correctness of the theme data.

Parameters:
theme theme data
Returns:
0 on success or -1 if an error occured

struct theme* theme_load ( char *  theme_dir  )  [read]

Parses the data of an XML theme file and loads the necessary data.

Parameters:
theme_dir directory with theme files
Returns:
a pointer to a theme structure or NULL if an error occured

void theme_cleanup ( struct theme theme  ) 

Theme cleanup.

Frees allocated memory.

Parameters:
theme theme data


Variable Documentation

Button -> keycode mapping.

Initial value:

Size of button -> keycode mapping array.


Generated on Mon Mar 29 01:39:31 2010 for Veronica by  doxygen 1.5.8