int main(int argc, char *argv[]) { image_t * img; object_t * menu; list_item_t * quit_item; claro_base_init(); claro_graphics_init(); log_fd_set_level(CL_DEBUG, stderr); clog(CL_INFO, "%s running using Claro!", __FILE__); w = window_widget_create(0, new_bounds(100, 100, 230, 230), 0); object_addhandler(w, "destroy", window_closed); window_set_title(w, "Status Icon"); menu = menu_widget_create(w, 0); quit_item = menu_append_item(menu, NULL, stock_get_image("system-log-out"), "Quit"); object_addhandler(OBJECT(quit_item), "pushed", window_closed); img = image_load(w, "icon.png"); s = status_icon_create(w, img, 0); status_icon_set_tooltip(s, "Claro - Status Icon"); status_icon_set_menu(s, menu); object_addhandler(s, "pushed", status_icon_pushed); window_show(w); window_focus(w); block_heap_loginfo(); claro_loop(); return 0; }
void b_menu_from_xml_item( XMLItem *i, object_t *menu, list_item_t *parent, int type ) { XMLItem *curr; list_item_t *m_new; list_item_t *t_new; image_t *icon; char *icon_n; char *item_n; char *enable; char *command; char *init; XMLItem *favlist; for ( curr = i->child_head; curr != 0; curr = curr->next ) { icon = 0; if ( ( item_n = c_xml_attrib_get( curr, "title" ) ) == 0 ) continue; // can't do anything about this one if ( !strcasecmp( item_n, "-" ) ) { // separator if ( type == 4 ) menu_append_separator( menu, parent ); else if ( type == 0 ) menubar_append_separator( menu, parent ); else toolbar_append_separator( menu ); continue; } // icon? if ( ( icon_n = c_xml_attrib_get( curr, "icon" ) ) != 0 ) icon = b_icon( icon_n ); // title, is it a language element? if ( lang_str_overlap( item_n, "lang:" ) == 5 ) item_n = lang_phrase_quick( item_n + 5 ); if ( type == 0 || type == 4 ) { if ( type == 4 ) m_new = menu_append_item( menu, parent, icon, item_n ); else m_new = menubar_append_item( menu, parent, icon, item_n ); if ( ( enable = c_xml_attrib_get( curr, "enabled" ) ) != 0 ) { // disabled? if ( !strcasecmp( enable, "false" ) ) { if ( type == 4 ) menu_disable_item( menu, m_new ); else menubar_disable_item( menu, m_new ); } } if ( ( command = c_xml_attrib_get( curr, "command" ) ) != 0 ) { OBJECT(m_new)->appdata = command; object_addhandler( OBJECT(m_new), "pushed", menu_x_click ); } b_menu_from_xml_item( curr, menu, m_new, type ); if ( ( init = c_xml_attrib_get( curr, "init" ) ) != 0 ) { if ( !strcasecmp( init, "menu_setup_favorites" ) ) { favlist = c_xml_find_child( xidentity, "favorites" ); menu_setup_favorites( menu, m_new, favlist ); } } } else { t_new = toolbar_append_icon( menu, icon, 0, item_n ); if ( ( command = c_xml_attrib_get( curr, "command" ) ) != 0 ) { OBJECT(t_new)->appdata = command; object_addhandler( OBJECT(t_new), "pushed", tool_x_click ); } // we always recurse with a menu, toolbars are not toolbars in sub items //b_menu_from_xml_item( curr, menu, m_new, 0 ); // but toolbar menus are not coded yet, so leave this out for now... } } }