openbox/parser/parse.h

99 lines
3.2 KiB
C
Raw Normal View History

2003-09-17 07:44:49 +00:00
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
parse.h for the Openbox window manager
Copyright (c) 2003-2007 Dana Jansens
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
See the COPYING file for a copy of the GNU General Public License.
*/
#ifndef __parse_h
#define __parse_h
2003-10-27 20:11:14 +00:00
#include "version.h"
2003-05-24 15:35:26 +00:00
#include <libxml/parser.h>
#include <glib.h>
G_BEGIN_DECLS
typedef struct _ObParseInst ObParseInst;
typedef void (*ParseCallback)(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
gpointer data);
ObParseInst* parse_startup();
void parse_shutdown(ObParseInst *inst);
/*! Loads Openbox's rc, from the normal paths
@type The configuration type to load, or NULL to use the default.
e.g. "gnome" would load rc-gnome.xml.
*/
gboolean parse_load_rc(const gchar *type, xmlDocPtr *doc, xmlNodePtr *root);
/* Loads an Openbox menu, from the normal paths */
gboolean parse_load_menu(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root);
2007-05-12 23:18:40 +00:00
/* Loads an Openbox theme, from the normal paths */
scary commit..but here goes. YOUR THEMES ARE NOW OFFICIALLY BROKEN. Openbox has just moved it's theme format to an XML based one. The details of this format can be found in data/themerc.xsd (and http://openbox.org/themerc.xsd ALSO! This is very good and important and stuff! In the tools directory you will find THEMETOXML ! This tool takes a themerc on stdin, and spits out the same theme in theme.xml format. So this is all you need to do to update your themes. PLEASE NOTE: This themetoxml does _not_ install itself anywhere. It simply builds and then lives out in its tools/themetoxml directory, and that's it. So if you want to use it, that is where to find it. In moving to the new XML format, a number of additions/changes to the theme engine have been made. Themetoxml takes these into account and will set all the new things appropriately to make your theme look the same as it always has. New additions include.. * padding now has an horizontal and vertical component, instead of being one number * menus can have different borders than windows (color and size) * menu offset can now be negative. it's a little weird, but someone will want it no doubt * fonts are no longer controled by the theme at all, however font shadowing is, and on that note.. * font shadows are now any color you want, not just black and white * you can now set the shadow anywhere you can set the text's color, so you have more control, i.e. you can set shadow on active menu items but not inactive, or disabled, etc. * every color now has an alpha channel. at the moment they don't do anything, besides the font shadow one, but it leaves room for future explorations. it is REALLY HIGHLY RECOMMENDED that you set the alpha to 255 all the time, until such time as it could be useful. otherwise one day your theme may turn awful for people. * font colors are in the range 0-255, in case you were wondering, and they have to be specified in decimal * if you'd like to change you font's you can do so in your configuration file. this is how it is going to stay. changing the font in the theme assumes too much about peoples eye sight and locality and stuff. it doesn't belong there, sorry. the system-wide default rc.xml includes the new font settings for your viewing pleasure, and ill drop an example of it below. * shadows can now be positioned in any direction, they have both an x and a y offset which can be negative and positive. and offset of 0,0 will disable the shadow This isn't a release or anything. If someone had some good ideas about the xml theme format, I'd like to hear them. But I don't think it will be changing much right now beyond where it is. I don't even know how the new functionality will play out for themers, so we'll see. Whew.. I guess that's it. I'm not sure if I mentioned every little change or not, but oh well. Mileage may vary.. Please send any feedback. Here's the font configuration example. Hopefully ObConf will let you set this real soon. <theme> ... <font place="ActiveWindow"> <name>arial,sans</name> <size>7</size> <weight>bold</weight> <slant>normal</slant> </font> <font place="InactiveWindow"> <name>arial,sans</name> <size>7</size> <weight>bold</weight> <slant>normal</slant> </font> <font place="MenuTitle"> <name>arial,sans</name> <size>8</size> <weight>bold</weight> <slant>normal</slant> </font> <font place="MenuItem"> <name>arial,sans</name> <size>8</size> <weight>bold</weight> <slant>normal</slant> </font> </theme>
2007-03-05 15:44:17 +00:00
gboolean parse_load_theme(const gchar *name, xmlDocPtr *doc, xmlNodePtr *root,
gchar **path);
2003-05-24 15:35:26 +00:00
2003-10-15 03:59:35 +00:00
void parse_register(ObParseInst *inst, const gchar *tag,
ParseCallback func, gpointer data);
void parse_tree(ObParseInst *inst, xmlDocPtr doc, xmlNodePtr node);
2003-05-24 15:35:26 +00:00
/* open/close */
2003-10-15 03:59:35 +00:00
gboolean parse_load(const gchar *path, const gchar *rootname,
xmlDocPtr *doc, xmlNodePtr *root);
2003-10-15 03:59:35 +00:00
gboolean parse_load_mem(gpointer data, guint len, const gchar *rootname,
xmlDocPtr *doc, xmlNodePtr *root);
void parse_close(xmlDocPtr doc);
2003-05-24 15:35:26 +00:00
/* helpers */
2003-10-15 03:59:35 +00:00
xmlNodePtr parse_find_node(const gchar *tag, xmlNodePtr node);
2003-10-15 03:59:35 +00:00
gchar *parse_string(xmlDocPtr doc, xmlNodePtr node);
gint parse_int(xmlDocPtr doc, xmlNodePtr node);
2003-05-24 15:35:26 +00:00
gboolean parse_bool(xmlDocPtr doc, xmlNodePtr node);
2003-10-15 03:59:35 +00:00
gboolean parse_contains(const gchar *val, xmlDocPtr doc, xmlNodePtr node);
gboolean parse_attr_contains(const gchar *val, xmlNodePtr node,
const gchar *name);
2003-10-15 03:59:35 +00:00
gboolean parse_attr_string(const gchar *name, xmlNodePtr node, gchar **value);
gboolean parse_attr_int(const gchar *name, xmlNodePtr node, gint *value);
gboolean parse_attr_bool(const gchar *name, xmlNodePtr node, gboolean *value);
/* paths */
void parse_paths_startup();
void parse_paths_shutdown();
const gchar* parse_xdg_config_home_path();
const gchar* parse_xdg_data_home_path();
GSList* parse_xdg_config_dir_paths();
GSList* parse_xdg_data_dir_paths();
/*! Expands the ~ character to the home directory throughout the given
string */
gchar *parse_expand_tilde(const gchar *f);
/*! Makes a directory */
gboolean parse_mkdir(const gchar *path, gint mode);
/*! Makes a directory and all its parents */
gboolean parse_mkdir_path(const gchar *path, gint mode);
G_END_DECLS
#endif