static void parse_menu_item(xmlNodePtr node, gpointer data) { ObMenuParseState *state = data; gchar *label; gchar *icon; ObMenuEntry *e; if (state->parent) { /* Don't try to extract "icon" attribute if icons in user-defined menus are not enabled. */ if (obt_xml_attr_string(node, "label", &label)) { xmlNodePtr c; GSList *acts = NULL; c = obt_xml_find_node(node->children, "action"); while (c) { ObActionsAct *action = actions_parse(c); if (action) acts = g_slist_append(acts, action); c = obt_xml_find_node(node->next, "action"); } e = menu_add_normal(state->parent, -1, label, acts, TRUE); if (config_menu_show_icons && obt_xml_attr_string(node, "icon", &icon)) { RrImage *ic; ic = RrImageCacheFindName(ob_rr_icons, icon); if (ic) RrImageRef(ic); else { ic = RrImageNew(ob_rr_icons); if (!RrImageAddPictureName(ic, icon)) { RrImageUnref(ic); /* no need to keep it around */ ic = NULL; } } e->data.normal.icon = ic; if (e->data.normal.icon) e->data.normal.icon_alpha = 0xff; g_free(icon); } g_free(label); } } }
ObActionsAct* actions_parse(xmlNodePtr node) { gchar *name; ObActionsAct *act = NULL; if (obt_xml_attr_string(node, "name", &name)) { if ((act = actions_build_act_from_string(name))) { /* there is more stuff to parse here */ if (act->def->canbeinteractive) { if (act->def->setup.i) act->options = act->def->setup.i(node->children, &act->i_pre, &act->i_input, &act->i_cancel, &act->i_post); } else { if (act->def->setup.n) act->options = act->def->setup.n(node->children); } } g_free(name); } return act; }
static void parse_menu_separator(xmlNodePtr node, gpointer data) { ObMenuParseState *state = data; if (state->parent) { gchar *label; if (!obt_xml_attr_string(node, "label", &label)) label = NULL; menu_add_separator(state->parent, -1, label); g_free(label); } }
static void parse_menu(xmlNodePtr node, gpointer data) { ObMenuParseState *state = data; gchar *name = NULL, *title = NULL, *script = NULL; ObMenu *menu; if (!obt_xml_attr_string(node, "id", &name)) goto parse_menu_fail; if (!g_hash_table_lookup(menu_hash, name)) { if (!obt_xml_attr_string(node, "label", &title)) goto parse_menu_fail; if ((menu = menu_new(name, title, TRUE, NULL))) { menu->pipe_creator = state->pipe_creator; if (obt_xml_attr_string(node, "execute", &script)) { menu->execute = obt_paths_expand_tilde(script); } else { ObMenu *old; old = state->parent; state->parent = menu; obt_xml_tree(menu_parse_inst, node->children); state->parent = old; } } } if (state->parent) menu_add_submenu(state->parent, -1, name); parse_menu_fail: g_free(name); g_free(title); g_free(script); }