~cszikszoy/do-plugins/fix-confluence

« back to all changes in this revision

Viewing changes to Dropbox/src/Config/DropboxConfig.cs

  • Committer: Chris S.
  • Date: 2009-06-10 17:32:56 UTC
  • mfrom: (599.3.32 Dropbox)
  • Revision ID: chris@szikszoy.com-20090610173256-ndhy3yztbqjc4zs0
merge Dropbox plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
// DropboxConfig.cs
 
3
// 
 
4
// GNOME Do is the legal property of its developers. Please refer to the
 
5
// COPYRIGHT file distributed with this
 
6
// source distribution.
 
7
// 
 
8
// This program is free software: you can redistribute it and/or modify
 
9
// it under the terms of the GNU General Public License as published by
 
10
// the Free Software Foundation, either version 3 of the License, or
 
11
// (at your option) any later version.
 
12
// 
 
13
// This program is distributed in the hope that it will be useful,
 
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
// GNU General Public License for more details.
 
17
// 
 
18
// You should have received a copy of the GNU General Public License
 
19
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
// 
 
21
 
 
22
using System;
 
23
using System.IO;
 
24
 
 
25
using Mono.Unix;
 
26
 
 
27
using Gtk;
 
28
 
 
29
using Do.Platform;
 
30
 
 
31
namespace Dropbox
 
32
{
 
33
        
 
34
        [System.ComponentModel.Category("File")]
 
35
        [System.ComponentModel.ToolboxItem(true)]
 
36
        public partial class DropboxConfig : Gtk.Bin
 
37
        {
 
38
                private static string home_path = Environment.GetFolderPath (Environment.SpecialFolder.Personal); 
 
39
                private static string base_path = System.IO.Path.Combine (home_path, "Dropbox");
 
40
                                
 
41
                static IPreferences prefs;
 
42
                        
 
43
                public DropboxConfig()
 
44
                {
 
45
                        Build ();
 
46
                        RefreshView ();
 
47
                }
 
48
                
 
49
                private void RefreshView ()
 
50
                {
 
51
                        base_path_entry.Text = BasePath;
 
52
                }
 
53
                
 
54
                static DropboxConfig ()
 
55
                {
 
56
                        prefs = Services.Preferences.Get<DropboxConfig> ();
 
57
                }
 
58
                
 
59
                public static string BasePath
 
60
                {
 
61
                        get { return prefs.Get<string> ("BasePath", base_path); }
 
62
                        set { prefs.Set<string> ("BasePath", value); }
 
63
                }
 
64
                
 
65
                protected virtual void OnBasePathBtnClicked (object sender, System.EventArgs e)
 
66
                {
 
67
                        FileChooserDialog chooser = new FileChooserDialog (
 
68
                            Catalog.GetString ("Select location of Dropbox folder"),
 
69
                                new Dialog (), FileChooserAction.SelectFolder,
 
70
                            Gtk.Stock.Cancel, ResponseType.Cancel,
 
71
                            Gtk.Stock.Open, ResponseType.Accept);
 
72
                        
 
73
                        chooser.SetCurrentFolder (BasePath);    
 
74
                        if (chooser.Run () == (int) ResponseType.Accept) {
 
75
                                BasePath = chooser.Filename;
 
76
                                RefreshView ();
 
77
                        }
 
78
                        
 
79
                        chooser.Destroy ();
 
80
                }
 
81
        }
 
82
}