~ubuntu-branches/debian/squeeze/f-spot/squeeze

« back to all changes in this revision

Viewing changes to src/PhotoImageView.cs

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane, Mirco Bauer, Iain Lane
  • Date: 2009-02-07 20:23:32 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: james.westby@ubuntu.com-20090207202332-oc93rfjo1st0571s
Tags: 0.5.0.3-2
[ Mirco Bauer]
* Upload to unstable.
* debian/control:
  + Lowered GNOME# build-deps to 2.0 ABI as that transition didn't happen
    yet in unstable.

[ Iain Lane ]
* debian/patches/svn-r4545_locales-import.dpatch: Patch backported from SVN
  trunk revision 4545 - initialize the translation catalog earlier (LP: #293305)
  (Closes: #514457). Thanks to Florian Heinle for finding the patch and to
  Chris Coulson for preparing the update.
* debian/control: Build-depend on libmono-dev (>= 1.2.4) to match configure
  checks.
* debian/rules: Pass CSC=/usr/bin/csc to configure for gio-sharp to fix FTBFS

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
                ProgressType load_async = ProgressType.Full;
20
20
                bool progressive_display;
21
21
                public GdkGlx.Context Glx;
22
 
                private Editor editor;
 
22
                private OldEditor editor;
23
23
 
24
24
                public PhotoImageView (IBrowsableCollection query) : this (new BrowsablePointer (query, -1))
25
25
                {
 
26
                        FSpot.ColorManagement.PhotoImageView = this;
26
27
                }
27
28
 
28
29
                public PhotoImageView (BrowsablePointer item)
31
32
                        loader.AreaUpdated += HandlePixbufAreaUpdated;
32
33
                        loader.AreaPrepared += HandlePixbufPrepared;
33
34
                        loader.Done += HandleDone;
 
35
                        
 
36
                        FSpot.ColorManagement.PhotoImageView = this;
 
37
                        this.Transform = FSpot.ColorManagement.StandartTransform (); //for preview windows
34
38
 
35
39
                        Accelerometer.OrientationChanged += HandleOrientationChanged;
36
40
 
77
81
#endif
78
82
                }
79
83
 
80
 
                public Editor Editor {
 
84
                public OldEditor Editor {
81
85
                        get { return editor; }
82
86
                        set {
83
87
                                value.Done += HandleEditorDone;
91
95
 
92
96
                private void HandleEditorDone (object sender, EventArgs args)
93
97
                {
94
 
                        Editor old = sender as Editor;
 
98
                        OldEditor old = sender as OldEditor;
95
99
 
96
100
                        old.Done -= HandleEditorDone;
97
101
                                
99
103
                                editor = null;
100
104
                }
101
105
 
102
 
 
103
106
                public Loupe Loupe {
104
107
                        get { return loupe; }
105
108
                }
117
120
 
118
121
                public void Reload ()
119
122
                {
120
 
                        if (!Item.IsValid)
 
123
                        if (Item == null || !Item.IsValid)
121
124
                                return;
122
125
                        
123
126
                        PhotoItemChanged (Item, null);
306
309
 
307
310
                private void PhotoItemChanged (BrowsablePointer item, BrowsablePointerChangedArgs args) 
308
311
                {
309
 
                        Log.Debug ("PhotoImageView::item changed");
310
312
                        // If it is just the position that changed fall out
311
313
                        if (args != null && 
312
314
                            args.PreviousItem != null &&
315
317
                            (this.Item.Current.DefaultVersionUri == args.PreviousItem.DefaultVersionUri))
316
318
                                return;
317
319
 
 
320
                        // Don't reload if the image didn't change at all.
 
321
                        if (args != null && args.Changes != null &&
 
322
                            !args.Changes.DataChanged &&
 
323
                            args.PreviousItem != null &&
 
324
                            Item.IsValid &&
 
325
                            this.Item.Current.DefaultVersionUri == args.PreviousItem.DefaultVersionUri)
 
326
                                return;
 
327
 
318
328
                        if (args != null &&
319
329
                            args.PreviousItem != null && 
320
330
                            Item.IsValid && 
370
380
                        ZoomFit (upscale);
371
381
                }
372
382
 
373
 
                private void ZoomFit (bool upscale)
 
383
                public void ZoomFit (bool upscale)
374
384
                {                       
375
385
                        Gdk.Pixbuf pixbuf = this.Pixbuf;
376
386
                        Gtk.ScrolledWindow scrolled = this.Parent as Gtk.ScrolledWindow;
379
389
                        if (pixbuf == null)
380
390
                                return;
381
391
 
382
 
                        int available_width = this.Allocation.Width;
383
 
                        int available_height = this.Allocation.Height;
384
 
                
 
392
                        if (scrolled != null)
 
393
                                scrolled.SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Never);
 
394
 
 
395
                        int available_width = (scrolled != null) ? scrolled.Allocation.Width : this.Allocation.Width;
 
396
                        int available_height = (scrolled != null) ? scrolled.Allocation.Height : this.Allocation.Height;
 
397
 
385
398
                        double zoom_to_fit = ZoomUtils.FitToScale ((uint) available_width, 
386
399
                                                                   (uint) available_height,
387
400
                                                                   (uint) pixbuf.Width, 
388
401
                                                                   (uint) pixbuf.Height, 
389
402
                                                                   upscale);
390
 
                        
 
403
 
391
404
                        double image_zoom = zoom_to_fit;
392
 
                        /*
393
 
                        System.Console.WriteLine ("Zoom = {0}, {1}, {2}", image_zoom, 
394
 
                                                  available_width, 
395
 
                                                  available_height);
396
 
                        */
397
 
 
398
 
                        if (scrolled != null)
399
 
                                scrolled.SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Never);
400
405
 
401
406
                        this.SetZoom (image_zoom, image_zoom);
402
407
                        
423
428
                        // for any of the default handlers.
424
429
                        args.RetVal = true;
425
430
                
426
 
                        // Check for KeyPad arrow keys, which scroll the window when zoomed in
427
 
                        // but should go to the next/previous photo when not zoomed (no scrollbars)
428
 
                        if (this.Fit) {
429
 
                                switch (args.Event.Key) {
 
431
                        // Scroll if image is zoomed in (scrollbars are visible)
 
432
                        Gtk.ScrolledWindow scrolled = this.Parent as Gtk.ScrolledWindow;
 
433
                        if (scrolled != null && !this.Fit) {
 
434
                                Gtk.Adjustment vadj = scrolled.Vadjustment;
 
435
                                Gtk.Adjustment hadj = scrolled.Hadjustment;
 
436
                                switch (args.Event.Key) {                                       
430
437
                                case Gdk.Key.Up:
 
438
                                case Gdk.Key.KP_Up:
 
439
                                case Gdk.Key.k:
 
440
                                case Gdk.Key.K:
 
441
                                        vadj.Value -= vadj.StepIncrement;
 
442
                                        if (vadj.Value < vadj.Lower)
 
443
                                                vadj.Value = vadj.Lower;
 
444
                                        return;
431
445
                                case Gdk.Key.Left:
432
 
                                case Gdk.Key.KP_Up:
433
446
                                case Gdk.Key.KP_Left:
434
 
                                        this.Item.MovePrevious ();
 
447
                                case Gdk.Key.h:
 
448
                                        hadj.Value -= hadj.StepIncrement;
 
449
                                        if (hadj.Value < hadj.Lower)
 
450
                                                hadj.Value = hadj.Lower;
435
451
                                        return;
436
452
                                case Gdk.Key.Down:
 
453
                                case Gdk.Key.KP_Down:
 
454
                                case Gdk.Key.j:
 
455
                                case Gdk.Key.J:
 
456
                                        vadj.Value += vadj.StepIncrement;
 
457
                                        if (vadj.Value > vadj.Upper - vadj.PageSize)
 
458
                                                vadj.Value = vadj.Upper - vadj.PageSize;
 
459
                                        return;
437
460
                                case Gdk.Key.Right:
438
 
                                case Gdk.Key.KP_Down:
439
461
                                case Gdk.Key.KP_Right:
440
 
                                        this.Item.MoveNext ();
 
462
                                case Gdk.Key.l:
 
463
                                        hadj.Value += hadj.StepIncrement;
 
464
                                        if (hadj.Value > hadj.Upper - hadj.PageSize)
 
465
                                                hadj.Value = hadj.Upper - hadj.PageSize;
441
466
                                        return;
442
467
                                }
443
468
                        }
444
 
 
 
469
                        
 
470
                        // Go to the next/previous photo when not zoomed (no scrollbars)
445
471
                        switch (args.Event.Key) {
446
472
                        case Gdk.Key.Up:
 
473
                        case Gdk.Key.KP_Up:
447
474
                        case Gdk.Key.Left:
 
475
                        case Gdk.Key.KP_Left:
448
476
                        case Gdk.Key.Page_Up:
449
477
                        case Gdk.Key.KP_Page_Up:
 
478
                        case Gdk.Key.BackSpace:
 
479
                        case Gdk.Key.h:
 
480
                        case Gdk.Key.H:
 
481
                        case Gdk.Key.k:
 
482
                        case Gdk.Key.K:
 
483
                        case Gdk.Key.b:
 
484
                        case Gdk.Key.B:
450
485
                                this.Item.MovePrevious ();
451
486
                                break;
452
 
                        case Gdk.Key.Home:
453
 
                        case Gdk.Key.KP_Home:
454
 
                                this.Item.Index = 0;
455
 
                                break;
456
 
                        case Gdk.Key.End:
457
 
                        case Gdk.Key.KP_End:
458
 
                                this.Item.Index = this.Query.Count - 1;
459
 
                                break;
460
487
                        case Gdk.Key.Down:
 
488
                        case Gdk.Key.KP_Down:
461
489
                        case Gdk.Key.Right:
 
490
                        case Gdk.Key.KP_Right:
462
491
                        case Gdk.Key.Page_Down:
463
492
                        case Gdk.Key.KP_Page_Down:
464
493
                        case Gdk.Key.space:
465
494
                        case Gdk.Key.KP_Space:
 
495
                        case Gdk.Key.j:
 
496
                        case Gdk.Key.J:
 
497
                        case Gdk.Key.l:
 
498
                        case Gdk.Key.L:
 
499
                        case Gdk.Key.n:
 
500
                        case Gdk.Key.N:
466
501
                                this.Item.MoveNext ();
467
502
                                break;
 
503
                        case Gdk.Key.Home:
 
504
                        case Gdk.Key.KP_Home:
 
505
                                this.Item.Index = 0;
 
506
                                break;
 
507
                        case Gdk.Key.End:
 
508
                        case Gdk.Key.KP_End:
 
509
                                this.Item.Index = this.Query.Count - 1;
 
510
                                break;
468
511
                        case Gdk.Key.Key_0:
469
512
                        case Gdk.Key.KP_0:
470
513
                                if (alt) 
490
533
                        case Gdk.Key.KP_Subtract:
491
534
                                ZoomOut ();
492
535
                                break;
493
 
                        case Gdk.Key.v:
494
 
                                if (loupe == null) {
495
 
                                        loupe = new Loupe (this);
496
 
                                        loupe.Destroyed += HandleLoupeDestroy;
497
 
                                        loupe.Show ();
498
 
                                } else {
499
 
                                        loupe.Destroy ();       
500
 
                                }
501
 
                                break;
502
 
                        case Gdk.Key.e:
503
 
                                Editor = new FSpot.Editors.SoftFocus (this);
504
 
                                break;
505
536
                        case Gdk.Key.equal:
506
537
                        case Gdk.Key.plus:
507
538
                        case Gdk.Key.KP_Add:
515
546
                        return;
516
547
                }
517
548
 
 
549
                public void ShowHideLoupe ()
 
550
                {
 
551
                        if (loupe == null) {
 
552
                                loupe = new Loupe (this);
 
553
                                loupe.Destroyed += HandleLoupeDestroy;
 
554
                                loupe.Show ();
 
555
                        } else {
 
556
                                loupe.Destroy ();       
 
557
                        }
 
558
                        
 
559
                }
 
560
                
518
561
                public void ShowSharpener ()
519
562
                {
520
563
                        if (sharpener == null) {