/**
 * bonobo_ui_component_add_verb_list_with_data:
 * @component: the component
 * @list: the list of verbs
 * @user_data: the user data passed to the verb callbacks
 * 
 * This is a helper function to save registering verbs individualy
 * it allows registration of a great batch of verbs at one time
 * in a list of #BonoboUIVerb terminated by #BONOBO_UI_VERB_END
 **/
void
bonobo_ui_component_add_verb_list_with_data (BonoboUIComponent  *component,
					     const BonoboUIVerb *list,
					     gpointer            user_data)
{
	const BonoboUIVerb *l;

	g_return_if_fail (list != NULL);
	g_return_if_fail (BONOBO_IS_UI_COMPONENT (component));

	bonobo_object_ref (BONOBO_OBJECT (component));

	for (l = list; l && l->cname; l++) {
		bonobo_ui_component_add_verb (
			component, l->cname, l->cb,
			user_data ? user_data : l->user_data);
	}

	bonobo_object_unref (BONOBO_OBJECT (component));
}
static void rmenu_setup(struct app_t *app, GList *schemes)
{
    BonoboUIComponent *uic = panel_applet_get_popup_component(app->applet);
    BonoboUINode *placeholder;
    gchar namebuf[128];
    
    debug_log("rmenu_setup:\n");
    
#if 0
    show_menu(0, bonobo_ui_component_get_tree(uic, "/", TRUE, NULL));
#endif
    
    placeholder = bonobo_ui_component_get_tree(uic, "/popups/popup/Schemes List", TRUE, NULL);
    if (placeholder == NULL) {
	debug_log("no placeholder\n");
	return;
    }
    
    debug_log("has placeholder\n");
    
    // 前のを削除。
    {
	BonoboUINode *node;
	
	bonobo_ui_component_freeze(uic, NULL);
	
	for (node = bonobo_ui_node_children(placeholder);
		node != NULL; node = bonobo_ui_node_next(node)) {
	    gchar path[1024];
	    sprintf(path, "/popups/popup/Schemes List/%s",
		    bonobo_ui_node_get_attr(node, "name"));
	    debug_log("rmenu_setup: remove %s\n", path);
	    bonobo_ui_component_rm(uic, path, NULL);
	}
	
	bonobo_ui_component_thaw(uic, NULL);
    }
    
    // 最新のを追加。
    if (app->use_planet) {
	gchar xmlbuf[1024];
	
	bonobo_ui_component_freeze(uic, NULL);
	
	for ( ; schemes != NULL; schemes = g_list_next(schemes)) {
	    gchar *p = schemes->data;
	    gchar *verb = rmenu_make_verb(p);
	    gchar *name;
	    
	    name = rmenu_next_name(namebuf);
	    sprintf(xmlbuf, "<menuitem name=\"%s\" verb=\"%s\" label=\"%s\"/>", name, verb, p);
	    
	    bonobo_ui_component_add_verb(uic, verb, scheme_cb, app);
	    debug_log("rmenu_setup: add %s\n", name);
	    bonobo_ui_component_set(uic, "/popups/popup/Schemes List", xmlbuf, NULL);
	    
	    g_free(verb);
	}
	
	sprintf(xmlbuf, "<separator name=\"%s\"/>", rmenu_next_name(namebuf));
	bonobo_ui_component_set(uic, "/popups/popup/Schemes List", xmlbuf, NULL);
	
	bonobo_ui_component_thaw(uic, NULL);
    }
    
#if 0
    show_menu(0, bonobo_ui_component_get_tree(uic, "/", TRUE, NULL));
#endif
    
    debug_log("rmenu_setup: done.\n");
}