Put reloading the image as its own action

This commit is contained in:
Přemysl Eric Janouch 2022-01-12 10:58:06 +01:00
parent 05453718bb
commit f632510d2a
Signed by: p
GPG Key ID: A0420B94F92B9493
3 changed files with 22 additions and 13 deletions

View File

@ -1064,11 +1064,14 @@ fiv_view_class_init(FivViewClass *klass)
bind(bs, GDK_KEY_plus, GDK_CONTROL_MASK, FIV_VIEW_COMMAND_ZOOM_IN);
bind(bs, GDK_KEY_minus, GDK_CONTROL_MASK, FIV_VIEW_COMMAND_ZOOM_OUT);
bind(bs, GDK_KEY_p, GDK_CONTROL_MASK, FIV_VIEW_COMMAND_PRINT);
bind(bs, GDK_KEY_r, GDK_CONTROL_MASK, FIV_VIEW_COMMAND_RELOAD);
bind(bs, GDK_KEY_s, GDK_CONTROL_MASK, FIV_VIEW_COMMAND_SAVE_PAGE);
bind(bs, GDK_KEY_s, GDK_MOD1_MASK, FIV_VIEW_COMMAND_SAVE_FRAME);
bind(bs, GDK_KEY_Return, GDK_MOD1_MASK, FIV_VIEW_COMMAND_INFO);
// The scale-to-fit binding is from gThumb, which has more such modes.
bind(bs, GDK_KEY_F5, 0, FIV_VIEW_COMMAND_RELOAD);
bind(bs, GDK_KEY_r, 0, FIV_VIEW_COMMAND_RELOAD);
bind(bs, GDK_KEY_plus, 0, FIV_VIEW_COMMAND_ZOOM_IN);
bind(bs, GDK_KEY_minus, 0, FIV_VIEW_COMMAND_ZOOM_OUT);
bind(bs, GDK_KEY_w, 0, FIV_VIEW_COMMAND_FIT_WIDTH);
@ -1203,6 +1206,9 @@ fiv_view_command(FivView *self, FivViewCommand command)
return;
switch (command) {
break; case FIV_VIEW_COMMAND_RELOAD:
reload(self);
break; case FIV_VIEW_COMMAND_ROTATE_LEFT:
self->orientation = view_left[self->orientation];
gtk_widget_queue_resize(widget);

View File

@ -28,6 +28,8 @@ gboolean fiv_view_open(FivView *self, const gchar *uri, GError **error);
// And this is how you avoid glib-mkenums.
typedef enum _FivViewCommand {
#define FIV_VIEW_COMMANDS(XX) \
XX(FIV_VIEW_COMMAND_RELOAD, "reload") \
\
XX(FIV_VIEW_COMMAND_ROTATE_LEFT, "rotate-left") \
XX(FIV_VIEW_COMMAND_MIRROR, "mirror") \
XX(FIV_VIEW_COMMAND_ROTATE_RIGHT, "rotate-right") \

27
fiv.c
View File

@ -84,6 +84,7 @@ static struct key_group help_keys_browser[] = {
{"General", help_keys_general},
{"View", (struct key[]) {
{"F9", "Toggle navigation sidebar"},
{"F5 r <control>r", "Refresh"},
{"h <control>h", "Toggle hiding unsupported files"},
{}
}},
@ -94,7 +95,7 @@ static struct key_group help_keys_browser[] = {
{"<alt>Right", "Go forward in history"},
{"<alt>Up", "Go to parent directory"},
{"<alt>Home", "Go home"},
{"F5 r <control>r", "Refresh"},
{"Return", "Open selected item"},
{}
}},
{}
@ -104,6 +105,7 @@ static struct key_group help_keys_view[] = {
{"General", help_keys_general},
{"View", (struct key[]) {
{"F8", "Toggle toolbar"},
{"F5 r <control>r", "Reload"},
{}
}},
{"Navigation", (struct key[]) {
@ -1044,10 +1046,6 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
case GDK_KEY_o:
on_open();
return TRUE;
case GDK_KEY_r:
// TODO(p): Reload the image instead, if it's currently visible.
load_directory(NULL);
return TRUE;
case GDK_KEY_q:
case GDK_KEY_w:
gtk_widget_destroy(g.window);
@ -1087,16 +1085,9 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
case GDK_KEY_q:
gtk_widget_destroy(g.window);
return TRUE;
case GDK_KEY_o:
on_open();
return TRUE;
case GDK_KEY_F5:
case GDK_KEY_r:
// TODO(p): See the comment for C-r above.
load_directory(NULL);
return TRUE;
case GDK_KEY_F1:
show_help_shortcuts();
return TRUE;
@ -1104,7 +1095,6 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
gtk_widget_set_visible(g.browser_sidebar,
!gtk_widget_is_visible(g.browser_sidebar));
return TRUE;
case GDK_KEY_F11:
case GDK_KEY_f:
toggle_fullscreen();
@ -1152,6 +1142,13 @@ on_key_press_browser_paned(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
{
// TODO(p): Consider replicating more GtkFileChooserWidget bindings.
switch (event->state & gtk_accelerator_get_default_mod_mask()) {
case GDK_CONTROL_MASK:
switch (event->keyval) {
case GDK_KEY_r:
load_directory(NULL);
return TRUE;
}
break;
case GDK_MOD1_MASK:
switch (event->keyval) {
case GDK_KEY_Up: {
@ -1175,6 +1172,10 @@ on_key_press_browser_paned(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
case GDK_KEY_h:
gtk_button_clicked(GTK_BUTTON(g.funnel));
return TRUE;
case GDK_KEY_F5:
case GDK_KEY_r:
load_directory(NULL);
return TRUE;
}
}
return FALSE;