changes associated with save/restore of AutomationControl id's
[ardour2.git] / gtk2_ardour / nag.cc
blobd82d986837bb76b1747cddc6ceacdd876a736f5c
1 #ifdef WAF_BUILD
2 #include "gtk2ardour-config.h"
3 #endif
5 #include <fstream>
6 #include <gtkmm/stock.h>
8 #include "pbd/openuri.h"
10 #include "ardour/ardour.h"
11 #include "ardour/filesystem_paths.h"
13 #include "nag.h"
14 #include "i18n.h"
16 using namespace ARDOUR;
17 using namespace std;
18 using namespace Glib;
19 using namespace Gtk;
21 NagScreen::NagScreen (std::string /*context*/, bool maybe_sub)
22 : ArdourDialog (_("Support Ardour Development"), true)
23 , donate_button (button_group, _("I'd like to make a one-time donation"))
24 , subscribe_button (button_group, _("Tell me more about becoming a subscriber"))
25 , existing_button (button_group, _("I'm already a subscriber!"))
26 , next_time_button (button_group, _("Ask about this the next time I export"))
27 , never_again_button (button_group, _("Never ever ask me about this again"))
29 if (maybe_sub) {
30 message.set_text (_("Congratulations on your session export.\n\n\
31 It looks as if you may already be a subscriber. If so, thanks, and sorry\n\
32 to bother you again about this - I'm working on improving our subscriber system\n\
33 so that I don't have to keep annoying you with this message.\n\n\
34 If you're not a subscriber, perhaps you might consider supporting my work\n\
35 on Ardour with either a one-time donation or subscription. Nothing will \n\
36 happen if you choose not to do so. However Ardour's continuing development\n\
37 relies on a stable, sustainable income stream. Thanks for using Ardour!"));
38 } else {
39 message.set_text (_("Congratulations on your session export.\n\n\
40 I hope you find Ardour a useful tool. I'd like to ask you to consider supporting\n\
41 its development with either a one-time donation or subscription. Nothing\n\
42 will happen if you choose not to do so. However Ardour's continuing development\n\
43 relies on a stable, sustainable income stream. Thanks for using Ardour!"));
46 button_box.pack_start (donate_button);
47 button_box.pack_start (subscribe_button);
48 button_box.pack_start (existing_button);
49 button_box.pack_start (next_time_button);
50 button_box.pack_start (never_again_button);
52 get_vbox()->set_spacing (12);
53 get_vbox()->pack_start (message);
54 get_vbox()->pack_start (button_box);
56 set_border_width (12);
57 add_button (Stock::OK, RESPONSE_ACCEPT);
60 NagScreen::~NagScreen ()
64 void
65 NagScreen::nag ()
67 show_all ();
69 int response = run ();
71 hide ();
73 switch (response) {
74 case RESPONSE_ACCEPT:
75 break;
76 default:
77 return;
80 if (donate_button.get_active()) {
81 offer_to_donate ();
82 } else if (subscribe_button.get_active()) {
83 offer_to_subscribe ();
84 } else if (never_again_button.get_active ()) {
85 mark_never_again ();
86 } else if (existing_button.get_active ()) {
87 mark_affirmed_subscriber ();
91 NagScreen*
92 NagScreen::maybe_nag (std::string why)
94 std::string path;
95 bool really_subscribed;
96 bool maybe_subscribed;
98 path = Glib::build_filename (user_config_directory().to_string(), ".nevernag");
100 if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
101 return 0;
104 maybe_subscribed = is_subscribed (really_subscribed);
106 if (really_subscribed) {
107 return 0;
110 return new NagScreen (why, maybe_subscribed);
113 void
114 NagScreen::mark_never_again ()
116 std::string path;
118 path = Glib::build_filename (user_config_directory().to_string(), ".nevernag");
120 ofstream nagfile (path.c_str());
123 void
124 NagScreen::mark_subscriber ()
126 std::string path;
128 path = Glib::build_filename (user_config_directory().to_string(), ".askedaboutsub");
130 ofstream subsfile (path.c_str());
133 void
134 NagScreen::mark_affirmed_subscriber ()
136 std::string path;
138 path = Glib::build_filename (user_config_directory().to_string(), ".isubscribe");
140 ofstream subsfile (path.c_str());
143 bool
144 NagScreen::is_subscribed (bool& really)
146 std::string path;
148 really = false;
150 /* what we'd really like here is a way to query paypal
151 for someone's subscription status. thats a bit complicated
152 so for now, just see if they ever told us they were
153 subscribed. we try to trust our users :)
156 path = Glib::build_filename (user_config_directory().to_string(), ".isubscribe");
157 if (file_test (path, FILE_TEST_EXISTS)) {
158 really = true;
159 return true;
162 path = Glib::build_filename (user_config_directory().to_string(), ".askedaboutsub");
163 if (file_test (path, FILE_TEST_EXISTS)) {
164 /* they never said they were subscribed but they
165 did once express an interest in it.
167 really = false;
168 return true;
171 return false;
174 void
175 NagScreen::offer_to_donate ()
177 const char* uri = "http://ardour.org/donate";
179 /* we don't care if it fails */
181 PBD::open_uri (uri);
184 void
185 NagScreen::offer_to_subscribe ()
187 const char* uri = "http://ardour.org/subscribe";
189 if (PBD::open_uri (uri)) {
190 mark_subscriber ();