diff options
author | nirav <nirav@teisuu.com> | 2018-09-02 17:40:59 +0530 |
---|---|---|
committer | Dandelion <nirav@teisuu.com> | 2018-09-02 17:40:59 +0530 |
commit | a49ccb8c0731aa0bba767199dfee1e7e235aeb29 (patch) | |
tree | 727e8e1c2f40ad4d0683eaf52aeb2bd70b0e6b53 | |
parent | 8472e02a212af0be07b19127db313e8e7523711a (diff) | |
download | im-a49ccb8c0731aa0bba767199dfee1e7e235aeb29.tar.gz im-a49ccb8c0731aa0bba767199dfee1e7e235aeb29.zip |
Added option for loading first, last image, added extra key bindings
-rw-r--r-- | file.c | 22 | ||||
-rw-r--r-- | file.h | 2 | ||||
-rw-r--r-- | main.c | 14 |
3 files changed, 34 insertions, 4 deletions
@@ -52,16 +52,30 @@ int scan(const char *file_name) char *get_next_file() { - if (curr_file_index >= file_list_count - 1) { + if (curr_file_index >= file_list_count - 1) return NULL; - } return file_list[++curr_file_index]; } char *get_prev_file() { - if (curr_file_index <= 0) { + if (curr_file_index <= 0) return NULL; - } return file_list[--curr_file_index]; } + +char *get_first_file() +{ + if (curr_file_index == 0) + return NULL; + curr_file_index = 0; + return file_list[curr_file_index]; +} + +char *get_last_file() +{ + if (curr_file_index == file_list_count - 1) + return NULL; + curr_file_index = file_list_count - 1; + return file_list[curr_file_index]; +} @@ -9,5 +9,7 @@ int curr_file_index, file_list_count; int scan(const char *file_name); char *get_next_file(); char *get_prev_file(); +char *get_first_file(); +char *get_last_file(); #endif @@ -25,9 +25,11 @@ static gboolean key_press(GtkWindow *window, GdkEvent *event, gpointer data) fit_image(win_width, win_height); return FALSE; case GDK_KEY_plus: + case GDK_KEY_KP_Add: zoom(1); return FALSE; case GDK_KEY_minus: + case GDK_KEY_KP_Subtract: zoom(-1); return FALSE; case GDK_KEY_equal: @@ -35,14 +37,26 @@ static gboolean key_press(GtkWindow *window, GdkEvent *event, gpointer data) return FALSE; case GDK_KEY_n: case GDK_KEY_j: + case GDK_KEY_Right: if ((name = get_next_file()) != NULL) load_image(name, win_width, win_height); return FALSE; case GDK_KEY_p: case GDK_KEY_k: + case GDK_KEY_Left: if ((name = get_prev_file()) != NULL) load_image(name, win_width, win_height); return FALSE; + case GDK_KEY_g: + case GDK_KEY_Home: + if ((name = get_first_file()) != NULL) + load_image(name, win_width, win_height); + return FALSE; + case GDK_KEY_G: + case GDK_KEY_End: + if ((name = get_last_file()) != NULL) + load_image(name, win_width, win_height); + return FALSE; default: return TRUE; } |