* Change xml parsing to pass the parent node, rather than the first

child.
* Add x,y co-ordinates on showmenu action so we can place menus on keypress.
This commit is contained in:
Scott Moynes 2003-07-23 01:45:44 +00:00
parent 845833226b
commit 0e69ae2b96
7 changed files with 47 additions and 13 deletions

View file

@ -28,6 +28,8 @@ static void parse_focus(xmlDocPtr doc, xmlNodePtr node, void *d)
{ {
xmlNodePtr n; xmlNodePtr n;
node = node->xmlChildrenNode;
if ((n = parse_find_node("focusNew", node))) if ((n = parse_find_node("focusNew", node)))
config_focus_new = parse_bool(doc, n); config_focus_new = parse_bool(doc, n);
if ((n = parse_find_node("followMouse", node))) if ((n = parse_find_node("followMouse", node)))
@ -44,6 +46,8 @@ static void parse_theme(xmlDocPtr doc, xmlNodePtr node, void *d)
{ {
xmlNodePtr n; xmlNodePtr n;
node = node->xmlChildrenNode;
if ((n = parse_find_node("theme", node))) { if ((n = parse_find_node("theme", node))) {
g_free(config_theme); g_free(config_theme);
config_theme = parse_string(doc, n); config_theme = parse_string(doc, n);
@ -54,6 +58,8 @@ static void parse_desktops(xmlDocPtr doc, xmlNodePtr node, void *d)
{ {
xmlNodePtr n; xmlNodePtr n;
node = node->xmlChildrenNode;
if ((n = parse_find_node("number", node))) if ((n = parse_find_node("number", node)))
config_desktops_num = parse_int(doc, n); config_desktops_num = parse_int(doc, n);
if ((n = parse_find_node("names", node))) { if ((n = parse_find_node("names", node))) {
@ -78,6 +84,8 @@ static void parse_moveresize(xmlDocPtr doc, xmlNodePtr node, void *d)
{ {
xmlNodePtr n; xmlNodePtr n;
node = node->xmlChildrenNode;
if ((n = parse_find_node("opaqueMove", node))) if ((n = parse_find_node("opaqueMove", node)))
config_opaque_move = parse_bool(doc, n); config_opaque_move = parse_bool(doc, n);
if ((n = parse_find_node("opaqueResize", node))) if ((n = parse_find_node("opaqueResize", node)))
@ -88,6 +96,8 @@ static void parse_dock(xmlDocPtr doc, xmlNodePtr node, void *d)
{ {
xmlNodePtr n; xmlNodePtr n;
node = node->xmlChildrenNode;
if ((n = parse_find_node("position", node))) { if ((n = parse_find_node("position", node))) {
if (parse_contains("TopLeft", doc, n)) if (parse_contains("TopLeft", doc, n))
config_dock_floating = FALSE, config_dock_floating = FALSE,

View file

@ -33,14 +33,22 @@ void parse_menu_full(xmlDocPtr doc, xmlNodePtr node, void *data,
ObMenu *menu = NULL, *parent; ObMenu *menu = NULL, *parent;
if (newmenu == TRUE) { if (newmenu == TRUE) {
if (!parse_attr_string("id", node->parent, &id)) if (!parse_attr_string("id", node, &id))
goto parse_menu_fail; goto parse_menu_fail;
if (!parse_attr_string("label", node->parent, &title)) if (!parse_attr_string("label", node, &title))
goto parse_menu_fail; goto parse_menu_fail;
g_message("menu label %s", title); g_message("menu label %s", title);
menu = menu_new(title, id, data ? *((ObMenu**)data) : NULL); if (parse_attr_string("plugin", node, &plugin)) {
PluginMenuCreateData data = {
.doc = doc,
.node = node,
.parent = menu
};
parent = plugin_create(plugin, &data);
g_free(plugin);
} else
menu = menu_new(title, id, data ? *((ObMenu**)data) : NULL);
if (data) if (data)
*((ObMenu**)data) = menu; *((ObMenu**)data) = menu;
@ -48,6 +56,8 @@ void parse_menu_full(xmlDocPtr doc, xmlNodePtr node, void *data,
menu = (ObMenu *)data; menu = (ObMenu *)data;
} }
node = node->xmlChildrenNode;
while (node) { while (node) {
if (!xmlStrcasecmp(node->name, (const xmlChar*) "menu")) { if (!xmlStrcasecmp(node->name, (const xmlChar*) "menu")) {
if (parse_attr_string("plugin", node, &plugin)) { if (parse_attr_string("plugin", node, &plugin)) {
@ -59,7 +69,7 @@ void parse_menu_full(xmlDocPtr doc, xmlNodePtr node, void *data,
g_free(plugin); g_free(plugin);
} else { } else {
parent = menu; parent = menu;
parse_menu(doc, node->xmlChildrenNode, &parent); parse_menu(doc, node, &parent);
menu_add_entry(menu, menu_entry_new_submenu(parent->label, menu_add_entry(menu, menu_entry_new_submenu(parent->label,
parent)); parent));
} }

View file

@ -100,7 +100,7 @@ void parse_tree(xmlDocPtr doc, xmlNodePtr node, void *nothing)
struct Callback *c = g_hash_table_lookup(callbacks, node->name); struct Callback *c = g_hash_table_lookup(callbacks, node->name);
if (c) if (c)
c->func(doc, node->xmlChildrenNode, c->data); c->func(doc, node, c->data);
node = node->next; node = node->next;
} }

View file

@ -69,7 +69,7 @@ static void parse_key(xmlDocPtr doc, xmlNodePtr node, GList *keylist)
static void parse_xml(xmlDocPtr doc, xmlNodePtr node, void *d) static void parse_xml(xmlDocPtr doc, xmlNodePtr node, void *d)
{ {
parse_key(doc, node, NULL); parse_key(doc, node->xmlChildrenNode, NULL);
} }
void plugin_setup_config() void plugin_setup_config()
@ -249,6 +249,11 @@ static void event(ObEvent *e, void *foo)
grabbed_key = p; grabbed_key = p;
} }
if (act->func == action_showmenu) {
act->data.showmenu.x = e->data.x.e->xkey.x_root;
act->data.showmenu.y = e->data.x.e->xkey.y_root;
}
act->data.any.c = focus_client; act->data.any.c = focus_client;
act->func(&act->data); act->func(&act->data);
} }

View file

@ -133,6 +133,11 @@ void plugin_destroy (ObMenu *m)
FIFO_MENU_DATA(m)->fifo = NULL; FIFO_MENU_DATA(m)->fifo = NULL;
} }
if (FIFO_MENU_DATA(m)->buf != NULL) {
g_free(FIFO_MENU_DATA(m)->buf);
FIFO_MENU_DATA(m)->buf = NULL;
}
g_free(m->plugin_data); g_free(m->plugin_data);
menu_free(m->name); menu_free(m->name);
@ -162,9 +167,11 @@ void *plugin_create(PluginMenuCreateData *data)
m = menu_new( (label != NULL ? label : ""), m = menu_new( (label != NULL ? label : ""),
(id != NULL ? id : PLUGIN_NAME), (id != NULL ? id : PLUGIN_NAME),
data->parent); data->parent);
menu_add_entry(data->parent, menu_entry_new_submenu(
(label != NULL ? label : ""), if (data->parent)
m)); menu_add_entry(data->parent, menu_entry_new_submenu(
(label != NULL ? label : ""),
m));
g_free(label); g_free(label);
g_free(id); g_free(id);

View file

@ -31,6 +31,8 @@ static void parse_xml(xmlDocPtr doc, xmlNodePtr node, void *d)
MouseAction mact; MouseAction mact;
Action *action; Action *action;
node = node->xmlChildrenNode;
if ((n = parse_find_node("dragThreshold", node))) if ((n = parse_find_node("dragThreshold", node)))
threshold = parse_int(doc, n); threshold = parse_int(doc, n);
if ((n = parse_find_node("doubleClickTime", node))) if ((n = parse_find_node("doubleClickTime", node)))

View file

@ -181,7 +181,7 @@ static void save_history()
xmlIndentTreeOutput = 1; xmlIndentTreeOutput = 1;
xmlSaveFormatFile(history_path, doc, 1); xmlSaveFormatFile(history_path, doc, 1);
xmlFree(doc); xmlFreeDoc(doc);
} }
static void load_history() static void load_history()
@ -236,7 +236,7 @@ static void load_history()
g_free(name); g_free(class); g_free(role); g_free(name); g_free(class); g_free(role);
node = parse_find_node("entry", node->next); node = parse_find_node("entry", node->next);
} }
xmlFree(doc); xmlFreeDoc(doc);
} }
void history_startup() void history_startup()