[Xfce4-commits] <ristretto:master> Add eventhandlers for interaction on mouse events - Add 'button-pressed' eventhandler - Add 'button-released' eventhandler - Add 'motion-notify' eventhandler - Add 'scroll' eventhandler

Stephan Arts noreply at xfce.org
Mon Aug 8 15:04:06 CEST 2011


Updating branch refs/heads/master
         to bd53ac198cbee5b3e4e90076e1c9739dc46840cf (commit)
       from 8b0c6156da53217712113372d804aed1d778b98d (commit)

commit bd53ac198cbee5b3e4e90076e1c9739dc46840cf
Author: Stephan Arts <stephan at xfce.org>
Date:   Thu Jul 21 07:35:56 2011 +0200

    Add eventhandlers for interaction on mouse events
     - Add 'button-pressed' eventhandler
     - Add 'button-released' eventhandler
     - Add 'motion-notify' eventhandler
     - Add 'scroll' eventhandler

 src/image_viewer.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 64 insertions(+), 1 deletions(-)

diff --git a/src/image_viewer.c b/src/image_viewer.c
index 7574698..734efd7 100644
--- a/src/image_viewer.c
+++ b/src/image_viewer.c
@@ -142,6 +142,17 @@ static gboolean
 cb_rstto_image_viewer_queued_repaint (RsttoImageViewer *viewer);
 
 static void
+cb_rstto_image_viewer_scroll_event (RsttoImageViewer *viewer, GdkEventScroll *event);
+static gboolean 
+cb_rstto_image_viewer_motion_notify_event (RsttoImageViewer *viewer,
+                                           GdkEventMotion *event,
+                                           gpointer user_data);
+static void
+cb_rstto_image_viewer_button_press_event (RsttoImageViewer *viewer, GdkEventButton *event);
+static void
+cb_rstto_image_viewer_button_release_event (RsttoImageViewer *viewer, GdkEventButton *event);
+
+static void
 rstto_image_viewer_load_image (RsttoImageViewer *viewer, GFile *file);
 static void
 rstto_image_viewer_transaction_free (RsttoImageViewerTransaction *tr);
@@ -201,6 +212,11 @@ rstto_image_viewer_init(RsttoImageViewer *viewer)
                            GDK_ENTER_NOTIFY_MASK |
                            GDK_POINTER_MOTION_MASK);
 
+    g_signal_connect(G_OBJECT(viewer), "scroll_event", G_CALLBACK(cb_rstto_image_viewer_scroll_event), NULL);
+    g_signal_connect(G_OBJECT(viewer), "button_press_event", G_CALLBACK(cb_rstto_image_viewer_button_press_event), NULL);
+    g_signal_connect(G_OBJECT(viewer), "button_release_event", G_CALLBACK(cb_rstto_image_viewer_button_release_event), NULL);
+    g_signal_connect(G_OBJECT(viewer), "motion_notify_event", G_CALLBACK(cb_rstto_image_viewer_motion_notify_event), NULL);
+
     /*
     gtk_drag_dest_set(GTK_WIDGET(viewer), 0, drop_targets, G_N_ELEMENTS(drop_targets),
                       GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE | GDK_ACTION_PRIVATE);
@@ -312,11 +328,17 @@ rstto_image_viewer_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
 
     if (GTK_WIDGET_REALIZED (widget))
     {
-         gdk_window_move_resize (widget->window,
+        gdk_window_move_resize (widget->window,
             allocation->x + border_width,
             allocation->y + border_width,
             allocation->width - border_width * 2,
             allocation->height - border_width * 2);
+
+        viewer->hadjustment->page_size = allocation->width;
+        gtk_adjustment_changed(viewer->hadjustment);
+
+        viewer->vadjustment->page_size = allocation->height;
+        gtk_adjustment_changed(viewer->vadjustment);
     }
 
     /** 
@@ -948,6 +970,21 @@ cb_rstto_image_loader_size_prepared (GdkPixbufLoader *loader, gint width, gint h
     gint s_width = gdk_screen_get_width (default_screen);
     gint s_height = gdk_screen_get_height (default_screen);
 
+    /* TODO:
+     * place these values inside the transaction 
+     * so the adjustments get adjusted at a later time
+     */
+    RsttoImageViewer *viewer = transaction->viewer;
+
+    viewer->hadjustment->upper = width;
+    viewer->hadjustment->lower = 0;
+    gtk_adjustment_changed(viewer->hadjustment);
+
+    viewer->vadjustment->upper = height;
+    viewer->vadjustment->lower = 0;
+    gtk_adjustment_changed(viewer->vadjustment);
+    /****************************/
+
     /*
      * Set the maximum size of the loaded image to the screen-size.
      * TODO: Add some 'smart-stuff' here
@@ -1089,6 +1126,10 @@ cb_rstto_image_viewer_queued_repaint (RsttoImageViewer *viewer)
                 }
             }
         }
+        /**
+         * TODO: subpixbuf stuff for zooming
+         *
+         */
 
         viewer->priv->dst_pixbuf = gdk_pixbuf_scale_simple (viewer->priv->pixbuf,
                                    (gint)((gdouble)width*viewer->priv->scale),
@@ -1105,3 +1146,25 @@ cb_rstto_image_viewer_queued_repaint (RsttoImageViewer *viewer)
     }
     rstto_image_viewer_paint (GTK_WIDGET (viewer));
 }
+
+static void
+cb_rstto_image_viewer_scroll_event (RsttoImageViewer *viewer, GdkEventScroll *event)
+{
+}
+
+static gboolean 
+cb_rstto_image_viewer_motion_notify_event (RsttoImageViewer *viewer,
+                                           GdkEventMotion *event,
+                                           gpointer user_data)
+{
+}
+
+static void
+cb_rstto_image_viewer_button_press_event (RsttoImageViewer *viewer, GdkEventButton *event)
+{
+}
+
+static void
+cb_rstto_image_viewer_button_release_event (RsttoImageViewer *viewer, GdkEventButton *event)
+{
+}


More information about the Xfce4-commits mailing list