Changeset 3999 for neercs/trunk


Ignore:
Timestamp:
Nov 22, 2009, 3:26:33 PM (11 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Added configuration getters
Location:
neercs/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/configuration.c

    r3998 r3999  
    2626
    2727
    28 struct config_line
    29 {
    30     const char name[32];
    31     int (*func_ptr) (const char *argv, struct screen_list * screen_list);
    32 };
    33 
    3428struct config_line *get_config(const char *name);
    3529int set_window_manager(const char *argv, struct screen_list *screen_list);
     
    4236int set_socket_dir(const char *argv, struct screen_list *screen_list);
    4337int set_delay(const char *argv, struct screen_list *screen_list);
     38char*  get_window_manager(struct screen_list *screen_list);
     39char*  get_cube_duration(struct screen_list *screen_list);
     40char*  get_thumbnails(struct screen_list *screen_list);
     41char*  get_status_bar(struct screen_list *screen_list);
     42char*  get_screensaver_timeout(struct screen_list *screen_list);
     43char*  get_autolock_timeout(struct screen_list *screen_list);
     44char*  get_lock_on_detach(struct screen_list *screen_list);
     45char*  get_socket_dir(struct screen_list *screen_list);
     46char*  get_delay(struct screen_list *screen_list);
     47
    4448
    4549/* Options definition and associated function pointer */
    4650struct config_line config_option[] = {
    47     {.name = "window_manager",.func_ptr = set_window_manager},
    48     {.name = "cube_duration",.func_ptr = set_cube_duration},
    49     {.name = "thumbnails",.func_ptr = set_thumbnails},
    50     {.name = "status_bar",.func_ptr = set_status_bar},
    51     {.name = "screensaver_timeout",.func_ptr = set_screensaver_timeout},
    52     {.name = "autolock_timeout",.func_ptr = set_autolock_timeout},
    53     {.name = "lock_on_detach",.func_ptr = set_lock_on_detach},
    54     {.name = "socket_dir",.func_ptr = set_socket_dir},
    55     {.name = "delay",.func_ptr = set_delay},
     51    {.name = "window_manager",.set = set_window_manager, .get = get_window_manager},
     52    {.name = "cube_duration",.set = set_cube_duration, .get = get_window_manager},
     53    {.name = "thumbnails",.set = set_thumbnails, .get = get_window_manager},
     54    {.name = "status_bar",.set = set_status_bar, .get = get_window_manager},
     55    {.name = "screensaver_timeout",.set = set_screensaver_timeout, .get = get_window_manager},
     56    {.name = "autolock_timeout",.set = set_autolock_timeout, .get = get_window_manager},
     57    {.name = "lock_on_detach",.set = set_lock_on_detach, .get = get_window_manager},
     58    {.name = "socket_dir",.set = set_socket_dir, .get = get_window_manager},
     59    {.name = "delay",.set = set_delay, .get = NULL},
    5660   
    57     {.name = "last",.func_ptr = NULL},
     61    {.name = "last",.set = NULL},
    5862};
    5963
     
    344348        if (c)
    345349        {
    346             c->func_ptr(option->value, screen_list);
     350            c->set((const char*)option->value, screen_list);
    347351        }
    348352        option = option->next;
     
    448452        return 0;
    449453}
     454
     455
     456
     457char* get_window_manager(struct screen_list *screen_list)
     458{
     459    switch(screen_list->wm_type)
     460    {
     461        case WM_FULL:
     462            return "full";
     463        case WM_CARD:
     464            return "card";
     465        case WM_VSPLIT:
     466            return "vsplit";
     467        case WM_HSPLIT:
     468            return "hsplit";
     469        case WM_CUBE:
     470            return "cube";
     471        default:
     472            return "invalid";
     473    }
     474    return NULL; /* Not reached */
     475}
     476
     477char*  get_cube_duration(struct screen_list *screen_list)
     478{
     479    char *r = malloc(100);
     480    sprintf(r, "%f", (float)screen_list->cube.duration/1000000.0f);
     481    return r;
     482}
     483
     484char*  get_thumbnails(struct screen_list *screen_list)
     485{
     486    if(screen_list->mini) return "yes";
     487    return "no";
     488}
     489
     490char*  get_status_bar(struct screen_list *screen_list)
     491{
     492    if(screen_list->status) return "yes";
     493    return "no";
     494}
     495
     496char*  get_screensaver_timeout(struct screen_list *screen_list)
     497{
     498    char *r = malloc(100);
     499    sprintf(r, "%f", (float)screen_list->screensaver_timeout/1000000.0f);
     500    return r;
     501}
     502
     503char*  get_autolock_timeout(struct screen_list *screen_list)
     504{
     505    char *r = malloc(100);
     506    sprintf(r, "%f", (float)screen_list->autolock_timeout/1000000.0f);
     507    return r;
     508}
     509
     510char*  get_lock_on_detach(struct screen_list *screen_list)
     511{
     512    if(screen_list->lock_on_detach) return "yes";
     513    else return "no";
     514}
     515
     516char*  get_socket_dir(struct screen_list *screen_list)
     517{
     518    return screen_list->socket_dir;
     519}
     520
     521char*  get_delay(struct screen_list *screen_list)
     522{
     523    char *r = malloc(100);
     524    sprintf(r, "%d", screen_list->requested_delay);
     525    return r;
     526}
     527
     528
     529
  • neercs/trunk/src/help.c

    r3998 r3999  
    7575    caca_printf(screen_list->cv, x, y++, "");
    7676    caca_printf(screen_list->cv, x, y++, "");
    77     caca_printf(screen_list->cv, x, y++, "See http://caca.zoy.org/wiki/neercs for more informations");
     77    caca_printf(screen_list->cv, x, y, "See http://caca.zoy.org/wiki/neercs for more informations");
    7878}
  • neercs/trunk/src/neercs.h

    r3998 r3999  
    2828    WM_MAX,
    2929};
    30 
    31 struct option
    32 {
    33     char *key;
    34     char *value;
    35 
    36     struct option *next;
    37 };
    38 
    3930
    4031
     
    218209};
    219210
    220 
     211/* Configuration */
     212struct option
     213{
     214    char *key;
     215    char *value;
     216   
     217    struct option *next;
     218};
     219struct config_line
     220{
     221    const char name[32];
     222    int  (*set) (const char *argv, struct screen_list * screen_list);
     223    char* (*get) (struct screen_list * screen_list);
     224};
     225
     226/* Recurrents */
    221227struct recurrent
    222228{
Note: See TracChangeset for help on using the changeset viewer.