Exemple #1
0
static WMenuEntry *preprocess_menu(ExtlTab tab, int *n_entries)
{
    WMenuEntry *entries;
    ExtlTab entry;
    int i, n;
    
    n=extl_table_get_n(tab);
    *n_entries=n;
    
    if(n<=0)
        return NULL;

    entries=ALLOC_N(WMenuEntry, n);  
    
    if(entries==NULL)
        return NULL;
        
    init_attr();
    
    /* Initialise entries and check submenus */
    for(i=1; i<=n; i++){
        WMenuEntry *ent=&entries[i-1];
        
        ent->title=NULL;
        ent->flags=0;
        
        gr_stylespec_init(&ent->attr);
        
        if(extl_table_geti_t(tab, i, &entry)){
            char *attr;
            ExtlTab sub;
            ExtlFn fn;
            
            if(extl_table_gets_s(entry, "attr", &attr)){
                gr_stylespec_load_(&ent->attr, attr, TRUE);
                free(attr);
            }
            
            if(extl_table_gets_f(entry, "submenu_fn", &fn)){
                ent->flags|=WMENUENTRY_SUBMENU;
                extl_unref_fn(fn);
            }else if(extl_table_gets_t(entry, "submenu", &sub)){
                ent->flags|=WMENUENTRY_SUBMENU;
                extl_unref_table(sub);
            }
            
            if(ent->flags&WMENUENTRY_SUBMENU)
                gr_stylespec_set(&ent->attr, GR_ATTR(submenu));
            
            extl_unref_table(entry);
        }
    }
    
    return entries;
}
Exemple #2
0
EXTL_SAFE
EXTL_EXPORT_MEMBER
void groupws_set_initial_outputs(WGroupWS *ws, ExtlTab tab)
{
    extl_unref_table(ws->initial_outputs);
    ws->initial_outputs=extl_ref_table(tab);
}
Exemple #3
0
void extl_table_sets_rectangle(ExtlTab tab, const char *nam,
                               const WRectangle *rect)
{
    ExtlTab g=extl_table_from_rectangle(rect);
    extl_table_sets_t(tab, nam, g);
    extl_unref_table(g);
}
Exemple #4
0
static void save_history()
{
    ExtlTab tab=mod_query_history_table();
    
    extl_write_savefile("saved_queryhist", tab);
    
    extl_unref_table(tab);
}
Exemple #5
0
void groupws_deinit(WGroupWS *ws)
{
    extl_unref_table(ws->initial_outputs);

    screen_unnotify_if_workspace(ws);

    group_deinit(&(ws->grp));
}
Exemple #6
0
void de_get_extra_cgrps(WRootWin *rootwin, DEStyle *style, ExtlTab tab)
{
    
    uint i=0, nfailed=0, n=extl_table_get_n(tab);
    char *name;
    ExtlTab sub;
    
    if(n==0)
        return;
    
    style->extra_cgrps=ALLOC_N(DEColourGroup, n);
    
    if(style->extra_cgrps==NULL)
        return;

    for(i=0; i<n-nfailed; i++){
        GrStyleSpec spec;
        
        if(!extl_table_geti_t(tab, i+1, &sub))
            goto err;
        
        if(!get_spec(sub, "substyle_pattern", &spec, NULL)){
            extl_unref_table(sub);
            goto err;
        }
        
        style->extra_cgrps[i-nfailed].spec=spec;
        
        de_get_colour_group(rootwin, style->extra_cgrps+i-nfailed, sub, 
                            style);
        
        extl_unref_table(sub);
        continue;
        
    err:
        warn(TR("Corrupt substyle table %d."), i);
        nfailed++;
    }
    
    if(n-nfailed==0){
        free(style->extra_cgrps);
        style->extra_cgrps=NULL;
    }
    
    style->n_extra_cgrps=n-nfailed;
}
Exemple #7
0
static bool handle_target_winprops(WClientWin *cwin, const WManageParams *param,
                                   WScreen *scr, WPHolder **ph_ret)
{
    char *layout=NULL, *target=NULL;
    WPHolder *ph=NULL;
    bool mgd=FALSE;

    if(extl_table_gets_s(cwin->proptab, "target", &target))
        ph=try_target(cwin, param, target);

    if(ph==NULL && extl_table_gets_s(cwin->proptab, "new_group", &layout)){
        ExtlTab lo=ioncore_get_layout(layout);

        free(layout);

        if(lo!=extl_table_none()){
            WMPlexAttachParams par=MPLEXATTACHPARAMS_INIT;
            int mask=MPLEX_ATTACH_SWITCHTO;
            WRegion *reg;

            if(param->switchto)
                par.flags|=MPLEX_ATTACH_SWITCHTO;

            /*ioncore_newly_created=(WRegion*)cwin;*/

            reg=mplex_attach_new_(&scr->mplex, &par, mask, lo);

            extl_unref_table(lo);

            /*ioncore_newly_created=NULL;*/

            mgd=(region_manager((WRegion*)cwin)!=NULL);

            if(reg!=NULL && !mgd){
                if(target!=NULL)
                    ph=try_target(cwin, param, target);

                if(ph==NULL){
                    ph=region_prepare_manage(reg, cwin, param,
                                             MANAGE_PRIORITY_NONE);

                    if(ph==NULL)
                        destroy_obj((Obj*)reg);
                }
            }
        }
    }

    if(target!=NULL)
        free(target);

    *ph_ret=ph;

    return mgd;
}
Exemple #8
0
static bool extl_table_getis(ExtlTab tab, int i, const char *s, char c,
                             void *p)
{
    ExtlTab sub;
    bool ret;
    
    if(!extl_table_geti_t(tab, i, &sub))
        return FALSE;
    ret=extl_table_get(sub, 's', c, s, p);
    extl_unref_table(sub);
    return ret;
}
Exemple #9
0
bool extl_table_gets_rectangle(ExtlTab tab, const char *nam,
                               WRectangle *rect)
{
    ExtlTab g;
    bool ok;

    if(!extl_table_gets_t(tab, nam, &g))
        return FALSE;

    ok=extl_table_to_rectangle(g, rect);

    extl_unref_table(g);

    return ok;
}
Exemple #10
0
static void dock_get_tile_size(WDock *dock, WRectangle *ret)
{
    ExtlTab tile_size_table;

    ret->x=0;
    ret->y=0;
    ret->w=dock_param_tile_width.dflt;
    ret->h=dock_param_tile_height.dflt;
    if(dock->brush==NULL)
        return;
    if(grbrush_get_extra(dock->brush, "tile_size", 't', &tile_size_table)){
        extl_table_gets_i(tile_size_table, dock_param_tile_width.key, &ret->w);
        extl_table_gets_i(tile_size_table, dock_param_tile_height.key, &ret->h);
        extl_unref_table(tile_size_table);
    }

}
Exemple #11
0
void menu_deinit(WMenu *menu)
{
    menu_typeahead_clear(menu);
    
    if(menu->submenu!=NULL)
        destroy_obj((Obj*)menu->submenu);
    
    /*if(menu->cycle_bindmap!=NULL)
        bindmap_destroy(menu->cycle_bindmap);*/

    extl_unref_table(menu->tab);
    extl_unref_fn(menu->handler);
    
    deinit_entries(menu);
    
    menu_release_gr(menu);
    
    window_deinit((WWindow*)menu);
}
Exemple #12
0
static void load_history()
{
    ExtlTab tab;
    int i, n;

    if(!extl_read_savefile("saved_queryhist", &tab))
        return;
    
    n=extl_table_get_n(tab);
    
    for(i=n; i>=1; i--){
        char *s=NULL;
        if(extl_table_geti_s(tab, i, &s)){
            mod_query_history_push(s);
            free(s);
        }
    }
    
    extl_unref_table(tab);
}
Exemple #13
0
static void menu_do_finish(WMenu *menu)
{
    ExtlFn handler;
    ExtlTab tab;
    bool ok;
    WMenu *head=menu_head(menu);
    
    handler=menu->handler;
    menu->handler=extl_fn_none();
    
    ok=extl_table_geti_t(menu->tab, menu->selected_entry+1, &tab);
    
    if(!region_rqdispose((WRegion*)head)){
        if(head->submenu!=NULL)
            destroy_obj((Obj*)head->submenu);
    }
    
    if(ok)
        extl_call(handler, "t", NULL, tab);

    extl_unref_fn(handler);
    extl_unref_table(tab);
}
Exemple #14
0
int main(int argc, char*argv[])
{
    const char *mod=NULL;
    char *mod2=NULL;
    int loaded=0;
    int opt;
    bool quiet=FALSE;

#ifndef CF_NO_LOCALE
    if(setlocale(LC_ALL, "")==NULL)
        warn("setlocale() call failed.");
#endif

    configtab=extl_table_none();

    libtu_init(argv[0]);

#ifdef CF_RELOCATABLE_BIN_LOCATION
    prefix_set(argv[0], CF_RELOCATABLE_BIN_LOCATION);
#endif

    extl_init();

    if(!statusd_register_exports())
        return EXIT_FAILURE;

    prefix_wrap_simple(extl_add_searchdir, EXTRABINDIR);
    prefix_wrap_simple(extl_add_searchdir, MODULEDIR);
    prefix_wrap_simple(extl_add_searchdir, ETCDIR);
    prefix_wrap_simple(extl_add_searchdir, SHAREDIR);
    prefix_wrap_simple(extl_add_searchdir, LCDIR);
    extl_set_userdirs(CF_ION_EXECUTABLE);

    optparser_init(argc, argv, OPTP_MIDLONG, ion_opts);

    extl_read_config("ioncore_luaext", NULL, TRUE);

    while((opt=optparser_get_opt())){
        switch(opt){
        /*case OPT_ID('d'):
            display=optparser_get_arg();
            break;*/
        case 's':
            extl_add_searchdir(optparser_get_arg());
            break;
        /*case OPT_ID('s'):
            extl_set_sessiondir(optparser_get_arg());
            break;*/
        case 'h':
            help();
            return EXIT_SUCCESS;
        case 'V':
            printf("%s\n", ION_VERSION);
            return EXIT_SUCCESS;
        case OPT_ID('a'):
            printf("%s\n\n%s", statusd_copy, TR(statusd_license));
            return EXIT_SUCCESS;
        case 'c':
            {
                ExtlTab t;
                const char *f=optparser_get_arg();
                if(extl_read_savefile(f, &t)){
                    extl_unref_table(configtab);
                    configtab=t;
                }else{
                    warn(TR("Unable to load configuration file %s"), f);
                }
            }
            break;
        case 'q':
            quiet=TRUE;
            break;
        case 'm':
            mod=optparser_get_arg();
            if(strchr(mod, '/')==NULL && strchr(mod, '.')==NULL){
                mod2=scat("statusd_", mod);
                if(mod2==NULL)
                    return EXIT_FAILURE;
                mod=mod2;
            }
            if(extl_read_config(mod, NULL, !quiet))
                loaded++;
            if(mod2!=NULL)
                free(mod2);
            break;
        default:
            warn(TR("Invalid command line."));
            help();
            return EXIT_FAILURE;
        }
    }

    if(loaded==0 && !quiet){
        warn(TR("No meters loaded."));
        return EXIT_FAILURE;
    }

    mainloop();

    return EXIT_SUCCESS;
}
Exemple #15
0
WSplit *load_splitfloat(WTiling *ws, const WRectangle *geom, ExtlTab tab)
{
    WSplit *tl=NULL, *br=NULL;
    WSplitFloat *split;
    char *dir_str;
    int dir, brs, tls;
    ExtlTab subtab;
    WRectangle tlg, brg;
    int set=0;

    set+=(extl_table_gets_i(tab, "tls", &tls)==TRUE);
    set+=(extl_table_gets_i(tab, "brs", &brs)==TRUE);
    set+=(extl_table_gets_s(tab, "dir", &dir_str)==TRUE);

    if(set!=3)
        return NULL;

    if(strcmp(dir_str, "vertical")==0){
        dir=SPLIT_VERTICAL;
    }else if(strcmp(dir_str, "horizontal")==0){
        dir=SPLIT_HORIZONTAL;
    }else{
        warn(TR("Invalid direction."));
        free(dir_str);
        return NULL;
    }
    free(dir_str);

    split=create_splitfloat(geom, ws, dir);
    if(split==NULL)
        return NULL;

    if(!extl_table_is_bool_set(tab, "tls_brs_incl_handles")){
        if(split->ssplit.dir==SPLIT_HORIZONTAL){
            tls+=split->tlpwin->bdw.right;
            brs+=split->brpwin->bdw.left;
        }else{
            tls+=split->tlpwin->bdw.bottom;
            brs+=split->brpwin->bdw.top;
        }
    }

    calc_tlg_brg(geom, tls, brs, dir, &tlg, &brg);

    splitfloat_update_handles(split, &tlg, &brg);

    if(extl_table_gets_t(tab, "tl", &subtab)){
        WRectangle g=tlg;
        splitfloat_tl_pwin_to_cnt(split, &g);
        tl=tiling_load_node(ws, &g, subtab);
        extl_unref_table(subtab);
    }

    if(extl_table_gets_t(tab, "br", &subtab)){
        WRectangle g;
        if(tl==NULL){
            g=*geom;
        }else{
            g=brg;
            splitfloat_br_pwin_to_cnt(split, &g);
        }
        br=tiling_load_node(ws, &g, subtab);
        extl_unref_table(subtab);
    }

    if(tl==NULL || br==NULL){
        destroy_obj((Obj*)split);
        if(tl!=NULL){
            split_do_resize(tl, geom, PRIMN_ANY, PRIMN_ANY, FALSE);
            return tl;
        }
        if(br!=NULL){
            split_do_resize(br, geom, PRIMN_ANY, PRIMN_ANY, FALSE);
            return br;
        }
        return NULL;
    }

    tl->parent=(WSplitInner*)split;
    br->parent=(WSplitInner*)split;

    split->ssplit.tl=tl;
    split->ssplit.br=br;

    return (WSplit*)split;
}
Exemple #16
0
bool menu_init(WMenu *menu, WWindow *par, const WFitParams *fp,
               const WMenuCreateParams *params)
{
    Window win;
    int i;
    
    menu->entries=preprocess_menu(params->tab, &(menu->n_entries));
    
    if(menu->entries==NULL){
        warn(TR("Empty menu."));
        return FALSE;
    }

    menu->tab=extl_ref_table(params->tab);
    menu->handler=extl_ref_fn(params->handler);
    menu->pmenu_mode=params->pmenu_mode;
    menu->big_mode=params->big_mode;
    /*menu->cycle_bindmap=NULL;*/
    
    menu->last_fp=*fp;
    
    if(params->pmenu_mode){
        menu->selected_entry=-1;
    }else{
        menu->selected_entry=params->initial-1;
        if(menu->selected_entry<0)
           menu->selected_entry=0;
        if(params->initial > menu->n_entries)
           menu->selected_entry=0;
    }
    
    menu->max_entry_w=0;
    menu->entry_h=0;
    menu->brush=NULL;
    menu->entry_brush=NULL;
    menu->entry_spacing=0;
    menu->vis_entries=menu->n_entries;
    menu->first_entry=0;
    menu->submenu=NULL;
    menu->typeahead=NULL;
    
    menu->gm_kcb=0;
    menu->gm_state=0;
    
    if(!window_init((WWindow*)menu, par, fp))
        goto fail;

    win=menu->win.win;
    
    if(!menu_init_gr(menu, region_rootwin_of((WRegion*)par), win))
        goto fail2;
        
    init_attr();
    
    menu_firstfit(menu, params->submenu_mode, &(params->refg));
    
    window_select_input(&(menu->win), IONCORE_EVENTMASK_NORMAL);
    
    region_add_bindmap((WRegion*)menu, mod_menu_menu_bindmap);
    
    region_register((WRegion*)menu);
    
    return TRUE;

fail2:
    window_deinit((WWindow*)menu);
fail:
    extl_unref_table(menu->tab);
    extl_unref_fn(menu->handler);
    deinit_entries(menu);
    return FALSE;
}