[gedit] Support Ctrl+scroll to zoom in the print preview



commit 3826b15bb45bb22dc40838e80c22d10d7dcb070d
Author: Sagar Ghuge <ghugesss gmail com>
Date:   Tue Jan 20 11:23:54 2015 +0530

    Support Ctrl+scroll to zoom in the print preview
    
    Allow user to zoom in/out using the scroll up
    and scroll down.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=729011

 gedit/gedit-print-preview.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/gedit/gedit-print-preview.c b/gedit/gedit-print-preview.c
index b4cf576..1fc5960 100644
--- a/gedit/gedit-print-preview.c
+++ b/gedit/gedit-print-preview.c
@@ -545,6 +545,32 @@ close_button_clicked (GtkWidget         *button,
        gtk_widget_destroy (GTK_WIDGET (preview));
 }
 
+static gboolean
+scroll_event_activated (GtkWidget         *widget,
+                       GdkEventScroll    *event,
+                       GeditPrintPreview *preview)
+{
+       if (event->state & GDK_CONTROL_MASK)
+       {
+               if ((event->direction == GDK_SCROLL_UP) ||
+                   (event->direction == GDK_SCROLL_SMOOTH &&
+                    event->delta_y < 0))
+               {
+                       zoom_in (preview);
+               }
+               else if ((event->direction == GDK_SCROLL_DOWN) ||
+                        (event->direction == GDK_SCROLL_SMOOTH &&
+                         event->delta_y > 0))
+               {
+                       zoom_out (preview);
+               }
+
+               return GDK_EVENT_STOP;
+       }
+
+       return GDK_EVENT_PROPAGATE;
+}
+
 static gint
 get_first_page_displayed (GeditPrintPreview *preview)
 {
@@ -883,6 +909,11 @@ gedit_print_preview_init (GeditPrintPreview *preview)
                          G_CALLBACK (close_button_clicked),
                          preview);
 
+       g_signal_connect (priv->layout,
+                         "scroll-event",
+                         G_CALLBACK (scroll_event_activated),
+                         preview);
+
        g_object_set (priv->layout, "has-tooltip", TRUE, NULL);
        g_signal_connect (priv->layout,
                          "query-tooltip",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]