3
* GNOME Do is the legal property of its developers. Please refer to the
4
* COPYRIGHT file distributed with this source distribution.
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
28
namespace Do.Addins.RTM
30
public partial class Configuration : Gtk.Bin
32
private static IPreferences prefs;
33
private LinkButton rtm_ref_btn;
36
public Configuration ()
39
rtm_ref_btn = new LinkButton ("Visit Remember The Milk website for more information.",
40
"List of available operators");
41
info_hbox.Add (rtm_ref_btn);
42
Box.BoxChild wInt = info_hbox [rtm_ref_btn] as Box.BoxChild;
44
rtm_ref_btn.Clicked += OnRtmRefBtnClicked;
46
if (!System.String.IsNullOrEmpty (AuthToken)) {
51
static Configuration ()
53
prefs = Do.Platform.Services.Preferences.Get<Do.Addins.RTM.Configuration>();
56
public static string AuthToken {
57
get { return prefs.Get("Token", ""); }
58
set { prefs.Set("Token", value); }
61
public static string Username {
62
get { return prefs.Get("Username", ""); }
63
set { prefs.Set("Username",value); }
66
public static string Filter {
67
get { return prefs.Get<string> ("Filter", "status:incomplete"); }
68
set { prefs.Set<string> ("Filter", value); }
71
public static bool OverdueNotification {
72
get { return prefs.Get<bool> ("OverdueNotification", true); }
73
set { prefs.Set<bool> ("OverdueNotification", value); }
76
public static bool ActionNotification {
77
get { return prefs.Get<bool> ("ActionNotification", true); }
78
set { prefs.Set<bool> ("ActionNotification", value); }
81
protected virtual void OnConfirmChkbtnClicked (object sender, System.EventArgs e)
83
ActionNotification = confirm_chkbtn.Active;
86
protected virtual void OnOverdueChkbtnClicked (object sender, System.EventArgs e)
88
OverdueNotification = overdue_chkbtn.Active;
91
protected virtual void OnAuthBtnClicked (object sender, System.EventArgs e)
93
frob = RTM.AuthInit ();
94
authinfo_lbl.Text = Catalog.GetString ("A webpage from Remember The Milk should be opened"
95
+ " in your web browser now. Please follow the instructions there and come back to complete"
96
+ " the authrozation by clicking the button below.");
99
//notification_frm.Visible = false;
100
//filter_frm.Visible = false;
101
Widget image = auth_btn.Image;
102
auth_btn.Label = Catalog.GetString ("Complete authorization");
103
auth_btn.Image = image;
104
auth_btn.Clicked -= new EventHandler (OnAuthBtnClicked);
105
auth_btn.Clicked += new EventHandler (OnCompleteBtnClicked);
108
protected virtual void OnCompleteBtnClicked (object sender, EventArgs e)
111
auth = RTM.AuthComplete (frob);
113
AuthToken = auth.Token;
114
Username = auth.User.Username;
115
auth_btn.Clicked -= new EventHandler (OnCompleteBtnClicked);
116
auth_btn.Clicked += new EventHandler (OnAuthBtnClicked);
119
authinfo_lbl.Text = Catalog.GetString ("Fail to complete authorization.");
120
auth_btn.Clicked -= new EventHandler (OnCompleteBtnClicked);
121
auth_btn.Clicked += new EventHandler (OnAuthBtnClicked);
122
auth_btn.Label = Catalog.GetString ("Authorize again");
126
private void SetStateComplete ()
128
authinfo_lbl.Text = String.Format (Catalog.GetString ("Thank you {0}, "
129
+ "RTM plugin is now authorized to operate on your account."), Username);
130
auth_btn.Label = "Sign in as a different user";
131
notification_frm.Visible = true;
132
filter_frm.Visible = true;
133
confirm_chkbtn.Active = ActionNotification;
134
overdue_chkbtn.Active = OverdueNotification;
135
filter_entry.Text = Filter;
138
protected virtual void OnFilterEntryChanged (object sender, System.EventArgs e)
140
Filter = filter_entry.Text;
143
protected virtual void OnRtmRefBtnClicked (object sender, EventArgs e)
145
Do.Platform.Services.Environment.OpenUrl("http://www.rememberthemilk.com/help/answers/search/advanced.rtm");