Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detail-view: Add zoom shortcuts #542

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/exm-detail-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct _ExmDetailView

GSimpleAction *zoom_in;
GSimpleAction *zoom_out;
GSimpleAction *zoom_reset;

gchar *shell_version;
gchar *uuid;
Expand Down Expand Up @@ -599,6 +600,10 @@ exm_detail_view_class_init (ExmDetailViewClass *klass)

gtk_widget_class_install_action (widget_class, "detail.open-extensions", NULL, open_link);
gtk_widget_class_install_action (widget_class, "detail.open-homepage", NULL, open_link);

gtk_widget_class_add_binding_action (widget_class, GDK_KEY_plus, GDK_CONTROL_MASK, "detail.zoom-in", NULL);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_minus, GDK_CONTROL_MASK, "detail.zoom-out", NULL);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_0, GDK_CONTROL_MASK, "detail.zoom-reset", NULL);
}

static void
Expand Down Expand Up @@ -628,9 +633,13 @@ exm_detail_view_init (ExmDetailView *self)
self->zoom_out = g_simple_action_new ("zoom-out", NULL);
g_signal_connect_swapped (self->zoom_out, "activate", G_CALLBACK (exm_zoom_picture_zoom_out), self->overlay_screenshot);

self->zoom_reset = g_simple_action_new ("zoom-reset", NULL);
g_signal_connect_swapped (self->zoom_reset, "activate", G_CALLBACK (exm_zoom_picture_zoom_reset), self->overlay_screenshot);

group = g_simple_action_group_new ();
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (self->zoom_in));
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (self->zoom_out));
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (self->zoom_reset));
gtk_widget_insert_action_group (GTK_WIDGET (self), "detail", G_ACTION_GROUP (group));

// Update action state on zoom change
Expand Down
6 changes: 6 additions & 0 deletions src/exm-zoom-picture.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ exm_zoom_picture_zoom_out (ExmZoomPicture *self)
exm_zoom_picture_set_zoom_level (self, self->zoom_level -= ZOOM_STEP);
}

void
exm_zoom_picture_zoom_reset (ExmZoomPicture *self)
{
exm_zoom_picture_set_zoom_level (self, 1);
}

void
compute_scaled_dimensions (ExmZoomPicture *self)
{
Expand Down
3 changes: 3 additions & 0 deletions src/exm-zoom-picture.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ exm_zoom_picture_zoom_in (ExmZoomPicture *self);
void
exm_zoom_picture_zoom_out (ExmZoomPicture *self);

void
exm_zoom_picture_zoom_reset (ExmZoomPicture *self);

void
exm_zoom_picture_set_zoom_level (ExmZoomPicture *self,
float zoom_level);
Expand Down