~cprov/gtwitter/1.0-beta6

« back to all changes in this revision

Viewing changes to gtwitter/PreferencesWindow.cs

  • Committer: Celso Providelo
  • Date: 2008-02-15 02:26:45 UTC
  • Revision ID: celso.providelo@canonical.com-20080215022645-yj0qogflo6c6ik6g
initial import.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.IO;
 
3
using System.Diagnostics;
 
4
using Gtk;
 
5
using GConf;
 
6
using Gnome;
 
7
using Mono.Unix;
 
8
 
 
9
namespace gtwitter
 
10
{
 
11
        
 
12
        public partial class PreferencesWindow : Gtk.Dialog
 
13
        {
 
14
                public PreferencesWindow()
 
15
                {
 
16
                        this.Build();
 
17
                        
 
18
                        //read from gconf
 
19
                        UpdateFromGConf();
 
20
                        MainWindow.client.AddNotify (MainWindow.GCONF_APP_PATH, new NotifyEventHandler (GConf_Changed));
 
21
                        
 
22
                        //notifications | sensitivity
 
23
                        //notifications toggled event
 
24
                        EnableNotifyCheckButton.Toggled += new EventHandler(this.EnableNotifyCheckButtonToggled);
 
25
                        
 
26
                        if (EnableNotifyCheckButton.Active == true)
 
27
                        {
 
28
                                NotifyOnDirect.Sensitive = true;
 
29
                                NotifyOnPublicFriends.Sensitive = true;
 
30
                                NotifyOnBoth.Sensitive = true;
 
31
                        }
 
32
                        
 
33
                }
 
34
                
 
35
                //gconf update
 
36
                void UpdateFromGConf () {
 
37
                        
 
38
                        try {
 
39
                                
 
40
                                SourceCombobox.Active = (int) MainWindow.client.Get (MainWindow.SOURCE_KEY);
 
41
                                
 
42
                                UsernameEntry.Text = (string) MainWindow.client.Get (MainWindow.USERNAME_KEY);
 
43
                                PasswordEntry.Text = (string) MainWindow.client.Get (MainWindow.PASSWORD_KEY);
 
44
                                
 
45
                                RefreshCombobox.Active = (int) MainWindow.client.Get (MainWindow.REFRESH_KEY);
 
46
                                
 
47
                                HiddenCheckbutton.Active = (bool) MainWindow.client.Get (MainWindow.HIDDEN_KEY);
 
48
                                
 
49
                                //Notification options
 
50
                                EnableNotifyCheckButton.Active = (bool) MainWindow.client.Get (MainWindow.NOTIFY_KEY);
 
51
                                NotifyOnDirect.Active = (bool) MainWindow.client.Get (MainWindow.NOTIFY_DIRECT_KEY);
 
52
                                NotifyOnPublicFriends.Active = (bool) MainWindow.client.Get (MainWindow.NOTIFY_PUBFRIE_KEY);
 
53
                                NotifyOnBoth.Active = (bool) MainWindow.client.Get (MainWindow.NOTIFY_ALL_KEY);
 
54
                        }
 
55
                        catch (Exception ex)
 
56
                        {
 
57
                                if (MainClass.debug) {
 
58
                                        Console.WriteLine("Preferences Window GConf exception: PreferencesWindow.cs - UpdateFromGConf()");
 
59
                                        Console.WriteLine(ex.StackTrace);
 
60
                                }
 
61
                        }
 
62
                        
 
63
                }
 
64
                public void GConf_Changed (object sender, NotifyEventArgs args) {
 
65
                        
 
66
                        UpdateFromGConf();
 
67
                }
 
68
                
 
69
                //ok button
 
70
                protected virtual void OnOkButtonClicked(object sender, System.EventArgs e)
 
71
                {
 
72
                        MainWindow.client.Set (MainWindow.SOURCE_KEY, SourceCombobox.Active);
 
73
                        
 
74
                        MainWindow.client.Set (MainWindow.USERNAME_KEY, UsernameEntry.Text);
 
75
                        MainWindow.client.Set (MainWindow.PASSWORD_KEY, PasswordEntry.Text);
 
76
                        
 
77
                        MainWindow.client.Set (MainWindow.REFRESH_KEY, RefreshCombobox.Active);
 
78
                        
 
79
                        MainWindow.client.Set (MainWindow.HIDDEN_KEY, HiddenCheckbutton.Active);
 
80
                        
 
81
                        //notifications
 
82
                        MainWindow.client.Set (MainWindow.NOTIFY_KEY, EnableNotifyCheckButton.Active);
 
83
                        MainWindow.client.Set (MainWindow.NOTIFY_DIRECT_KEY, NotifyOnDirect.Active);
 
84
                        MainWindow.client.Set (MainWindow.NOTIFY_PUBFRIE_KEY, NotifyOnPublicFriends.Active);
 
85
                        MainWindow.client.Set (MainWindow.NOTIFY_ALL_KEY, NotifyOnBoth.Active);
 
86
                        
 
87
                        ClearCacheLabel.Text = "";
 
88
 
 
89
                        this.Hide();
 
90
                }
 
91
                
 
92
                protected virtual void OnDeleteEvent(object o, Gtk.DeleteEventArgs args)
 
93
                {
 
94
                        ClearCacheLabel.Text = "";
 
95
                        
 
96
                        this.Hide();
 
97
                        args.RetVal = true;
 
98
                }
 
99
 
 
100
                protected virtual void OnClearCacheButtonClicked(object sender, System.EventArgs e)
 
101
                {
 
102
                        Directory.Delete(gtwitter.MainWindow.configDir + "images/", true);
 
103
                        
 
104
                        Directory.CreateDirectory(gtwitter.MainWindow.configDir + "images");
 
105
                        
 
106
                        ClearCacheLabel.Text = Catalog.GetString("Done!");
 
107
                }
 
108
 
 
109
                // call the GNOME Default browser to open the Twitter.com signup url
 
110
                protected virtual void OnSignUpClicked(object sender, System.EventArgs e)
 
111
                {
 
112
                        Gnome.Url.Show ("http://twitter.com/signup");
 
113
                }
 
114
                
 
115
                //Toggle notifications event
 
116
                protected virtual void EnableNotifyCheckButtonToggled(object sender, System.EventArgs e)
 
117
                {
 
118
                        if(EnableNotifyCheckButton.Active == true)
 
119
                        {
 
120
                                MainWindow.client.Set (MainWindow.NOTIFY_KEY, EnableNotifyCheckButton.Active);
 
121
                                
 
122
                                NotifyOnDirect.Sensitive = true;
 
123
                                NotifyOnPublicFriends.Sensitive = true;
 
124
                                NotifyOnBoth.Sensitive = true;
 
125
                        }
 
126
                        else
 
127
                        {
 
128
                                MainWindow.client.Set (MainWindow.NOTIFY_KEY, EnableNotifyCheckButton.Active);
 
129
                                
 
130
                                NotifyOnDirect.Sensitive = false;
 
131
                                NotifyOnPublicFriends.Sensitive = false;
 
132
                                NotifyOnBoth.Sensitive = false;
 
133
                        }
 
134
                }
 
135
 
 
136
        }
 
137
}
 
138
 
 
139
//ghaefb
 
 
b'\\ No newline at end of file'