Skip to content

Commit

Permalink
Merge pull request #542 from mjakeman/oscfdezdz/zoom-shortcuts
Browse files Browse the repository at this point in the history
detail-view: Add zoom shortcuts
  • Loading branch information
mjakeman authored Mar 13, 2024
2 parents 9114556 + a37c462 commit 34bddc2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
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 @@ -609,6 +610,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 @@ -639,9 +644,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

0 comments on commit 34bddc2

Please sign in to comment.