Ignore:
File:
1 edited

Legend:

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

    ra35b458 r5a6cc679  
    4444#include <codec/tga.h>
    4545#include <task.h>
    46 #include <str.h>
    4746
    4847#define NAME  "viewer"
     
    7271        kbd_event_t *event = (kbd_event_t *) data;
    7372        bool update = false;
    74 
     73       
    7574        if ((event->type == KEY_PRESS) && (event->c == 'q'))
    7675                exit(0);
    77 
     76       
    7877        if ((event->type == KEY_PRESS) && (event->key == KC_PAGE_DOWN)) {
    7978                if (imgs_current == imgs_count - 1)
     
    8180                else
    8281                        imgs_current++;
    83 
     82               
    8483                update = true;
    8584        }
    86 
     85       
    8786        if ((event->type == KEY_PRESS) && (event->key == KC_PAGE_UP)) {
    8887                if (imgs_current == 0)
     
    9089                else
    9190                        imgs_current--;
    92 
     91               
    9392                update = true;
    9493        }
    95 
     94       
    9695        if (update) {
    9796                surface_t *lsface;
     
    114113        if (rc != EOK)
    115114                return false;
    116 
    117         vfs_stat_t stat;
     115       
     116        struct stat stat;
    118117        rc = vfs_stat(fd, &stat);
    119118        if (rc != EOK) {
     
    121120                return false;
    122121        }
    123 
     122       
    124123        void *tga = malloc(stat.size);
    125124        if (tga == NULL) {
     
    135134                return false;
    136135        }
    137 
     136       
    138137        vfs_put(fd);
    139 
     138       
    140139        *p_local_surface = decode_tga(tga, stat.size, 0);
    141140        if (*p_local_surface == NULL) {
     
    143142                return false;
    144143        }
    145 
     144       
    146145        free(tga);
    147146
    148147        surface_get_resolution(*p_local_surface, &img_width, &img_height);
    149 
     148       
    150149        return true;
    151150}
     
    165164                        return false;
    166165                }
    167 
     166               
    168167                sig_connect(&canvas->keyboard_event, NULL, on_keyboard_event);
    169168        }
    170 
     169       
    171170        if (surface != NULL)
    172171                surface_destroy(surface);
    173 
     172       
    174173        surface = local_surface;
    175174        return true;
     
    188187                return 1;
    189188        }
    190 
     189       
    191190        if (argc < 3) {
    192191                printf("No image files specified.\n");
     
    200199                return 2;
    201200        }
    202 
     201       
    203202        for (int i = 0; i < argc - 2; i++) {
    204203                imgs[i] = str_dup(argv[i + 2]);
     
    226225                return 5;
    227226        }
    228 
    229 
     227       
     228       
    230229        if (!img_setup(lsface)) {
    231230                printf("Cannot setup image \"%s\".\n", imgs[imgs_current]);
     
    244243            img_height + dheight, WINDOW_PLACEMENT_ANY);
    245244        window_exec(main_window);
    246 
     245       
    247246        task_retval(0);
    248247        async_manager();
    249 
     248       
    250249        return 0;
    251250}
Note: See TracChangeset for help on using the changeset viewer.