~matteo-collina/+junk/todo

« back to all changes in this revision

Viewing changes to TodoGui/MainWindow.cs

  • Committer: Matteo Collina
  • Date: 2008-05-21 16:47:35 UTC
  • Revision ID: matteo.collina@gmail.com-20080521164735-yrec3tnesmpxn0u2
The GUI gets its TodoListViewer. Updated MainWindow to actually use it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// MainWindow.cs created with MonoDevelop
2
 
// User: matteo at 11:53 13/04/2008
3
 
//
4
 
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
5
 
//
6
1
using System;
7
2
using Gtk;
 
3
using Todo;
8
4
 
9
5
namespace TodoGui
10
6
{
11
7
        public partial class MainWindow: Gtk.Window
12
8
        {       
13
 
                public MainWindow (): base (Gtk.WindowType.Toplevel)
 
9
                private TodoListViewer _viewer;
 
10
                
 
11
                public MainWindow (TodoListElement element): base (Gtk.WindowType.Toplevel)
14
12
                {
15
13
                        Build ();
 
14
                        Element = element;
 
15
                }
 
16
                
 
17
                public TodoListElement Element
 
18
                {
 
19
                        get
 
20
                        {
 
21
                                return _viewer.Element;
 
22
                        }
 
23
                        
 
24
                        set
 
25
                        {
 
26
                                if(value == null)
 
27
                                        throw new ArgumentNullException();
 
28
                                
 
29
                                if(_viewer != null)
 
30
                                {
 
31
                                        _vbox.Remove(_viewer);
 
32
                                        _viewer.Destroy();
 
33
                                        _viewer.ChildActivated -= OnChildActivated;
 
34
                                }
 
35
                        
 
36
                                _viewer = new TodoListViewer(value);
 
37
                                _viewer.ChildActivated += OnChildActivated;
 
38
                                _viewer.Visible = true;
 
39
                                _vbox.Add(_viewer);
 
40
                        }
16
41
                }
17
42
                
18
43
                protected void OnDeleteEvent (object sender, DeleteEventArgs a)
25
50
                {
26
51
                        Application.Quit ();
27
52
                }
 
53
                
 
54
                protected virtual void OnChildActivated(object sender, ChildActivatedArgs args)
 
55
                {
 
56
                        Element = args.Child;
 
57
                }
28
58
        }
29
59
}
 
 
b'\\ No newline at end of file'