~ted/ubuntu/lucid/tomboy/with-patch

« back to all changes in this revision

Viewing changes to Tomboy/Addins/ExportToHtml/ExportToHtmlDialog.cs

Tags: upstream-0.7.2
Import upstream version 0.7.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using Tomboy;
 
3
using Mono.Unix;
 
4
 
 
5
namespace Tomboy.ExportToHtml
 
6
{
 
7
        public class ExportToHtmlDialog : Gtk.FileChooserDialog
 
8
        {
 
9
                Gtk.CheckButton export_linked;
 
10
                Gtk.CheckButton export_linked_all;
 
11
 
 
12
                public ExportToHtmlDialog (string default_file) : 
 
13
                        base (Catalog.GetString ("Destination for HTML Export"),
 
14
                                  null, Gtk.FileChooserAction.Save, new object[] {})
 
15
                {
 
16
                        AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
 
17
                        AddButton (Gtk.Stock.Save, Gtk.ResponseType.Ok);
 
18
                        
 
19
                        DefaultResponse = Gtk.ResponseType.Ok;
 
20
                        
 
21
                        Gtk.Table table = new Gtk.Table (2, 2, false);
 
22
                        
 
23
                        export_linked = new Gtk.CheckButton (Catalog.GetString ("Export linked notes"));
 
24
                        export_linked.Toggled += OnExportLinkedToggled;
 
25
                        table.Attach (export_linked, 0, 2, 0, 1, Gtk.AttachOptions.Fill, 0, 0, 0);
 
26
                        
 
27
                        export_linked_all =
 
28
                                new Gtk.CheckButton (Catalog.GetString ("Include all other linked notes"));
 
29
                        table.Attach (export_linked_all,
 
30
                                        1, 2, 1, 2, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, 20, 0);
 
31
                        
 
32
                        ExtraWidget = table;
 
33
                        
 
34
                        DoOverwriteConfirmation = true;
 
35
                        LocalOnly = true;
 
36
 
 
37
                        ShowAll ();
 
38
                        LoadPreferences (default_file);
 
39
                }
 
40
 
 
41
                public bool ExportLinked 
 
42
                {
 
43
                        get { return export_linked.Active; }
 
44
                        set { export_linked.Active = value; }
 
45
                }
 
46
                
 
47
                public bool ExportLinkedAll
 
48
                {
 
49
                        get { return export_linked_all.Active; }
 
50
                        set { export_linked_all.Active = value; }
 
51
                }
 
52
                
 
53
                public void SavePreferences () 
 
54
                {
 
55
                        string dir = System.IO.Path.GetDirectoryName (Filename);
 
56
                        Preferences.Set (Preferences.EXPORTHTML_LAST_DIRECTORY, dir);
 
57
 
 
58
                        Preferences.Set (Preferences.EXPORTHTML_EXPORT_LINKED, ExportLinked);
 
59
                        Preferences.Set (Preferences.EXPORTHTML_EXPORT_LINKED_ALL, ExportLinkedAll);
 
60
                }
 
61
                
 
62
                protected void LoadPreferences (string default_file) 
 
63
                {
 
64
                        string last_dir = (string) Preferences.Get (Preferences.EXPORTHTML_LAST_DIRECTORY);
 
65
                        if (last_dir == "")
 
66
                                last_dir = Environment.GetEnvironmentVariable ("HOME");
 
67
                        SetCurrentFolder (last_dir);
 
68
                        CurrentName = default_file;
 
69
 
 
70
                        ExportLinked = (bool) Preferences.Get (Preferences.EXPORTHTML_EXPORT_LINKED);
 
71
                        ExportLinkedAll = (bool) Preferences.Get (Preferences.EXPORTHTML_EXPORT_LINKED_ALL);
 
72
                }
 
73
                
 
74
                protected void OnExportLinkedToggled (object sender, EventArgs args)
 
75
                {
 
76
                        if (export_linked.Active)
 
77
                                export_linked_all.Sensitive = true;
 
78
                        else
 
79
                                export_linked_all.Sensitive = false;
 
80
                }
 
81
        }
 
82
}