mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-14 18:33:46 +01:00
Merge branch 'zathura-zoom-gesture' into develop (fixes #243)
This commit is contained in:
commit
fb3831b3fa
@ -808,3 +808,29 @@ cb_window_update_icon(ZathuraRenderRequest* GIRARA_UNUSED(request), cairo_surfac
|
|||||||
gtk_window_set_icon(GTK_WINDOW(zathura->ui.session->gtk.window), pixbuf);
|
gtk_window_set_icon(GTK_WINDOW(zathura->ui.session->gtk.window), pixbuf);
|
||||||
g_object_unref(pixbuf);
|
g_object_unref(pixbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cb_gesture_zoom_begin(GtkGesture* UNUSED(self), GdkEventSequence* UNUSED(sequence), void* data)
|
||||||
|
{
|
||||||
|
zathura_t* zathura = data;
|
||||||
|
if (zathura == NULL || zathura->document == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const double current_zoom = zathura_document_get_zoom(zathura->document);
|
||||||
|
zathura->gesture.initial_zoom = current_zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cb_gesture_zoom_scale_changed(GtkGestureZoom* UNUSED(self), gdouble scale, void* data)
|
||||||
|
{
|
||||||
|
zathura_t* zathura = data;
|
||||||
|
if (zathura == NULL || zathura->document == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const double next_zoom = zathura->gesture.initial_zoom * scale;
|
||||||
|
const double corrected_zoom = zathura_correct_zoom_value(zathura->ui.session, next_zoom);
|
||||||
|
zathura_document_set_zoom(zathura->document, corrected_zoom);
|
||||||
|
render_all(zathura);
|
||||||
|
refresh_view(zathura);
|
||||||
|
}
|
||||||
|
@ -281,5 +281,8 @@ void update_visible_pages(zathura_t* zathura);
|
|||||||
*/
|
*/
|
||||||
void cb_window_update_icon(ZathuraRenderRequest* request, cairo_surface_t* surface, void* data);
|
void cb_window_update_icon(ZathuraRenderRequest* request, cairo_surface_t* surface, void* data);
|
||||||
|
|
||||||
|
void cb_gesture_zoom_begin(GtkGesture* self, GdkEventSequence* sequence, void* data);
|
||||||
|
|
||||||
|
void cb_gesture_zoom_scale_changed(GtkGestureZoom* self, gdouble scale, void* data);
|
||||||
|
|
||||||
#endif // CALLBACKS_H
|
#endif // CALLBACKS_H
|
||||||
|
@ -221,6 +221,13 @@ init_ui(zathura_t* zathura)
|
|||||||
zathura->ui.session->events.buffer_changed = cb_buffer_changed;
|
zathura->ui.session->events.buffer_changed = cb_buffer_changed;
|
||||||
zathura->ui.session->events.unknown_command = cb_unknown_command;
|
zathura->ui.session->events.unknown_command = cb_unknown_command;
|
||||||
|
|
||||||
|
/* gestures */
|
||||||
|
|
||||||
|
GtkGesture* zoom = gtk_gesture_zoom_new(GTK_WIDGET(zathura->ui.session->gtk.view));
|
||||||
|
g_signal_connect(zoom, "scale-changed", G_CALLBACK(cb_gesture_zoom_scale_changed), zathura);
|
||||||
|
g_signal_connect(zoom, "begin", G_CALLBACK(cb_gesture_zoom_begin), zathura);
|
||||||
|
gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER(zathura->ui.session->gtk.view), GTK_PHASE_BUBBLE);
|
||||||
|
|
||||||
/* zathura signals */
|
/* zathura signals */
|
||||||
zathura->signals.refresh_view = g_signal_new(
|
zathura->signals.refresh_view = g_signal_new(
|
||||||
"refresh-view", GTK_TYPE_WIDGET, G_SIGNAL_RUN_LAST, 0, NULL, NULL,
|
"refresh-view", GTK_TYPE_WIDGET, G_SIGNAL_RUN_LAST, 0, NULL, NULL,
|
||||||
|
@ -226,6 +226,14 @@ struct zathura_s
|
|||||||
} toggle_presentation_mode;
|
} toggle_presentation_mode;
|
||||||
} shortcut;
|
} shortcut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Storage for gestures.
|
||||||
|
*/
|
||||||
|
struct {
|
||||||
|
double initial_zoom;
|
||||||
|
} gesture;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Context for MIME type detection
|
* Context for MIME type detection
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user