~ubuntu-branches/ubuntu/quantal/shotwell/quantal

« back to all changes in this revision

Viewing changes to src/Page.vala

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2012-02-21 13:52:58 UTC
  • mto: This revision was merged to the branch mainline in revision 47.
  • Revision ID: package-import@ubuntu.com-20120221135258-ao9jiib5qicomq7q
Tags: upstream-0.11.92
ImportĀ upstreamĀ versionĀ 0.11.92

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2009-2011 Yorba Foundation
 
1
/* Copyright 2009-2012 Yorba Foundation
2
2
 *
3
3
 * This software is licensed under the GNU LGPL (version 2.1 or later).
4
4
 * See the COPYING file in this distribution. 
380
380
        
381
381
        int x, y;
382
382
        Gdk.ModifierType mask;
383
 
        AppWindow.get_instance().get_window().get_pointer(out x, out y, out mask);
 
383
        AppWindow.get_instance().get_window().get_device_position(Gdk.Display.get_default().
 
384
            get_device_manager().get_client_pointer(), out x, out y, out mask);
384
385
        
385
386
        ctrl = (mask & Gdk.ModifierType.CONTROL_MASK) != 0;
386
387
        alt = (mask & Gdk.ModifierType.MOD1_MASK) != 0;
678
679
            return false;
679
680
        }
680
681
        
681
 
        event_source.get_window().get_pointer(out x, out y, out mask);
 
682
        event_source.get_window().get_device_position(Gdk.Display.get_default().get_device_manager()
 
683
            .get_client_pointer(), out x, out y, out mask);
682
684
        
683
685
        if (last_down.x < 0 || last_down.y < 0)
684
686
            return true;
1004
1006
    private bool on_motion_internal(Gdk.EventMotion event) {
1005
1007
        int x, y;
1006
1008
        Gdk.ModifierType mask;
1007
 
        if (event.is_hint) {
 
1009
        if (event.is_hint == 1) {
1008
1010
            get_event_source_pointer(out x, out y, out mask);
1009
1011
        } else {
1010
1012
            x = (int) event.x;
1908
1910
        viewport.add(canvas);
1909
1911
        
1910
1912
        add(viewport);
 
1913
 
 
1914
        // Work around an Ubuntu Ambiance style change that causes GtkDrawingAreas to have
 
1915
        // transparent backgrounds, causing odd display quirks.  The color we set here is
 
1916
        // arbitrary.
 
1917
        // See https://bugs.launchpad.net/light-themes/+bug/931630 .
 
1918
        canvas.override_background_color(Gtk.StateFlags.NORMAL, parse_color("#000"));
1911
1919
        
1912
 
        // turn off double-buffering because all painting happens in pixmap, and is sent to the window
1913
 
        // wholesale in on_canvas_expose
 
1920
        // all painting happens in pixmap, and is sent to the window wholesale in on_canvas_expose
1914
1921
        canvas.set_double_buffered(false);
 
1922
        
1915
1923
        canvas.add_events(Gdk.EventMask.EXPOSURE_MASK | Gdk.EventMask.STRUCTURE_MASK 
1916
1924
            | Gdk.EventMask.SUBSTRUCTURE_MASK);
1917
1925
        
1981
1989
        assert(is_zoom_supported());
1982
1990
        Cairo.Context canvas_ctx = Gdk.cairo_create(canvas.get_window());
1983
1991
        
1984
 
        Gdk.cairo_set_source_color(pixmap_ctx, canvas.get_style().black);
 
1992
        set_source_color_from_string(pixmap_ctx, "#000");
1985
1993
        pixmap_ctx.paint();
1986
1994
        
1987
1995
        bool old_quality_setting = zoom_high_quality;
1997
2005
        assert(is_zoom_supported());
1998
2006
        Cairo.Context canvas_ctx = Gdk.cairo_create(canvas.get_window());
1999
2007
        
2000
 
        Gdk.cairo_set_source_color(pixmap_ctx, canvas.style.black);
 
2008
        set_source_color_from_string(pixmap_ctx, "#000");
2001
2009
        pixmap_ctx.paint();
2002
2010
        
2003
2011
        bool old_quality_setting = zoom_high_quality;
2015
2023
 
2016
2024
    protected virtual void cancel_zoom() {
2017
2025
        if (pixmap != null) {
2018
 
            Gdk.cairo_set_source_color(pixmap_ctx, canvas.style.black);
 
2026
            set_source_color_from_string(pixmap_ctx, "#000");
2019
2027
            pixmap_ctx.paint();
2020
2028
        }
2021
2029
    }
2172
2180
        if (pixmap != null)
2173
2181
            exposed_ctx.set_source_surface(pixmap, 0, 0);
2174
2182
        else
2175
 
            Gdk.cairo_set_source_color(exposed_ctx, canvas.style.black);
 
2183
            set_source_color_from_string(exposed_ctx, "#000");
2176
2184
        
2177
2185
        exposed_ctx.rectangle(0, 0, get_allocated_width(), get_allocated_height());
2178
2186
        exposed_ctx.paint();
2188
2196
    
2189
2197
    protected virtual void paint(Cairo.Context ctx, Dimensions ctx_dim) {
2190
2198
        if (is_zoom_supported() && (!static_zoom_state.is_default())) {
2191
 
            Gdk.cairo_set_source_color(ctx, canvas.style.black);
 
2199
            set_source_color_from_string(ctx, "#000");
2192
2200
            ctx.rectangle(0, 0, pixmap_dim.width, pixmap_dim.height);
2193
2201
            ctx.fill();
2194
2202
            
2195
2203
            render_zoomed_to_pixmap(static_zoom_state);
2196
2204
        } else if (!transition_clock.paint(ctx, ctx_dim.width, ctx_dim.height)) {
2197
2205
            // transition is not running, so paint the full image on a black background
2198
 
            Gdk.cairo_set_source_color(ctx, canvas.style.black);
 
2206
            set_source_color_from_string(ctx, "#000");
 
2207
            
2199
2208
            ctx.rectangle(0, 0, pixmap_dim.width, pixmap_dim.height);
2200
2209
            ctx.fill();
2201
2210
            
2299
2308
        
2300
2309
        if (direction != null && !transition_clock.is_in_progress()) {
2301
2310
            Spit.Transitions.Visuals visuals = new Spit.Transitions.Visuals(old_scaled,
2302
 
                old_scaled_pos, scaled, scaled_pos, canvas.style.black);
 
2311
                old_scaled_pos, scaled, scaled_pos, parse_color("#000"));
2303
2312
            
2304
2313
            transition_clock.start(visuals, direction.to_transition_direction(), transition_duration_msec,
2305
2314
                repaint_pixmap);
2325
2334
        
2326
2335
        // Cairo context for drawing text on the pixmap
2327
2336
        text_ctx = new Cairo.Context(pixmap);
2328
 
        Gdk.cairo_set_source_color(text_ctx, canvas.style.white);
 
2337
        set_source_color_from_string(text_ctx, "#fff");
 
2338
        
2329
2339
        
2330
2340
        // no need to resize canvas, viewport does that automatically
2331
2341
        
2398
2408
    
2399
2409
    private static Gdk.Atom? XDS_ATOM = null;
2400
2410
    private static Gdk.Atom? TEXT_ATOM = null;
2401
 
    private static uchar[]? XDS_FAKE_TARGET = null;
 
2411
    private static uint8[]? XDS_FAKE_TARGET = null;
2402
2412
    
2403
2413
    private weak Page page;
2404
2414
    private Gtk.Widget event_source;
2466
2476
        
2467
2477
        // set the XDS property to indicate an XDS save is available
2468
2478
        Gdk.property_change(context.get_source_window(), XDS_ATOM, TEXT_ATOM, 8, Gdk.PropMode.REPLACE,
2469
 
            XDS_FAKE_TARGET, XDS_FAKE_TARGET.length);
 
2479
            XDS_FAKE_TARGET);
2470
2480
    }
2471
2481
    
2472
2482
    private void on_drag_data_get(Gdk.DragContext context, Gtk.SelectionData selection_data,