Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/viewer/viewer.c

    r5a6cc679 ra35b458  
    4444#include <codec/tga.h>
    4545#include <task.h>
     46#include <str.h>
    4647
    4748#define NAME  "viewer"
     
    7172        kbd_event_t *event = (kbd_event_t *) data;
    7273        bool update = false;
    73        
     74
    7475        if ((event->type == KEY_PRESS) && (event->c == 'q'))
    7576                exit(0);
    76        
     77
    7778        if ((event->type == KEY_PRESS) && (event->key == KC_PAGE_DOWN)) {
    7879                if (imgs_current == imgs_count - 1)
     
    8081                else
    8182                        imgs_current++;
    82                
     83
    8384                update = true;
    8485        }
    85        
     86
    8687        if ((event->type == KEY_PRESS) && (event->key == KC_PAGE_UP)) {
    8788                if (imgs_current == 0)
     
    8990                else
    9091                        imgs_current--;
    91                
     92
    9293                update = true;
    9394        }
    94        
     95
    9596        if (update) {
    9697                surface_t *lsface;
     
    113114        if (rc != EOK)
    114115                return false;
    115        
    116         struct stat stat;
     116
     117        vfs_stat_t stat;
    117118        rc = vfs_stat(fd, &stat);
    118119        if (rc != EOK) {
     
    120121                return false;
    121122        }
    122        
     123
    123124        void *tga = malloc(stat.size);
    124125        if (tga == NULL) {
     
    134135                return false;
    135136        }
    136        
     137
    137138        vfs_put(fd);
    138        
     139
    139140        *p_local_surface = decode_tga(tga, stat.size, 0);
    140141        if (*p_local_surface == NULL) {
     
    142143                return false;
    143144        }
    144        
     145
    145146        free(tga);
    146147
    147148        surface_get_resolution(*p_local_surface, &img_width, &img_height);
    148        
     149
    149150        return true;
    150151}
     
    164165                        return false;
    165166                }
    166                
     167
    167168                sig_connect(&canvas->keyboard_event, NULL, on_keyboard_event);
    168169        }
    169        
     170
    170171        if (surface != NULL)
    171172                surface_destroy(surface);
    172        
     173
    173174        surface = local_surface;
    174175        return true;
     
    187188                return 1;
    188189        }
    189        
     190
    190191        if (argc < 3) {
    191192                printf("No image files specified.\n");
     
    199200                return 2;
    200201        }
    201        
     202
    202203        for (int i = 0; i < argc - 2; i++) {
    203204                imgs[i] = str_dup(argv[i + 2]);
     
    225226                return 5;
    226227        }
    227        
    228        
     228
     229
    229230        if (!img_setup(lsface)) {
    230231                printf("Cannot setup image \"%s\".\n", imgs[imgs_current]);
     
    243244            img_height + dheight, WINDOW_PLACEMENT_ANY);
    244245        window_exec(main_window);
    245        
     246
    246247        task_retval(0);
    247248        async_manager();
    248        
     249
    249250        return 0;
    250251}
Note: See TracChangeset for help on using the changeset viewer.