X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fnag.cc;h=61a8e1a9a475036f839e32b42b6c8aa7266d4e24;hb=234b06a18cf3e8c07bc44fb4f8c1218e17fb65f1;hp=4dab7e69b74fbe7549229d5e3a4ae0975275051a;hpb=e0aaed6d65f160c328cb8b56d7c6552ee15d65e2;p=ardour.git diff --git a/gtk2_ardour/nag.cc b/gtk2_ardour/nag.cc index 4dab7e69b7..61a8e1a9a4 100644 --- a/gtk2_ardour/nag.cc +++ b/gtk2_ardour/nag.cc @@ -1,8 +1,33 @@ -#include +/* + Copyright (C) 2012 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifdef WAF_BUILD +#include "gtk2ardour-config.h" +#endif + +#include "pbd/gstdio_compat.h" #include -#include "ardour/ardour.h" +#include "pbd/openuri.h" + #include "ardour/filesystem_paths.h" +#include "ardour/rc_configuration.h" #include "nag.h" #include "i18n.h" @@ -12,8 +37,8 @@ using namespace std; using namespace Glib; using namespace Gtk; -NagScreen::NagScreen (std::string context, bool maybe_sub) - : ArdourDialog (_("Support Ardour Development"), true) +NagScreen::NagScreen (std::string /*context*/, bool maybe_sub) + : ArdourDialog (string_compose (_("Support %1 Development"), PROGRAM_NAME), true) , donate_button (button_group, _("I'd like to make a one-time donation")) , subscribe_button (button_group, _("Tell me more about becoming a subscriber")) , existing_button (button_group, _("I'm already a subscriber!")) @@ -36,13 +61,13 @@ its development with either a one-time donation or subscription. Nothing\n\ will happen if you choose not to do so. However Ardour's continuing development\n\ relies on a stable, sustainable income stream. Thanks for using Ardour!")); } - + button_box.pack_start (donate_button); button_box.pack_start (subscribe_button); button_box.pack_start (existing_button); button_box.pack_start (next_time_button); button_box.pack_start (never_again_button); - + get_vbox()->set_spacing (12); get_vbox()->pack_start (message); get_vbox()->pack_start (button_box); @@ -85,18 +110,18 @@ NagScreen::nag () NagScreen* NagScreen::maybe_nag (std::string why) { - Glib::ustring path; + std::string path; bool really_subscribed; bool maybe_subscribed; - path = Glib::build_filename (user_config_directory().to_string(), ".nevernag"); + path = Glib::build_filename (user_config_directory(), ".nevernag"); if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) { return 0; } maybe_subscribed = is_subscribed (really_subscribed); - + if (really_subscribed) { return 0; } @@ -107,53 +132,53 @@ NagScreen::maybe_nag (std::string why) void NagScreen::mark_never_again () { - Glib::ustring path; + std::string path; + + path = Glib::build_filename (user_config_directory(), ".nevernag"); - path = Glib::build_filename (user_config_directory().to_string(), ".nevernag"); - - ofstream nagfile (path.c_str()); + g_file_set_contents (path.c_str(), "", -1, NULL); } void NagScreen::mark_subscriber () { - Glib::ustring path; + std::string path; + + path = Glib::build_filename (user_config_directory(), ".askedaboutsub"); - path = Glib::build_filename (user_config_directory().to_string(), ".askedaboutsub"); - - ofstream subsfile (path.c_str()); + g_file_set_contents (path.c_str(), "", -1, NULL); } void NagScreen::mark_affirmed_subscriber () { - Glib::ustring path; + std::string path; - path = Glib::build_filename (user_config_directory().to_string(), ".isubscribe"); - - ofstream subsfile (path.c_str()); + path = Glib::build_filename (user_config_directory(), ".isubscribe"); + + g_file_set_contents (path.c_str(), "", -1, NULL); } bool NagScreen::is_subscribed (bool& really) { - Glib::ustring path; + std::string path; really = false; - /* what we'd really like here is a way to query paypal + /* what we'd really like here is a way to query paypal for someone's subscription status. thats a bit complicated so for now, just see if they ever told us they were subscribed. we try to trust our users :) */ - path = Glib::build_filename (user_config_directory().to_string(), ".isubscribe"); + path = Glib::build_filename (user_config_directory(), ".isubscribe"); if (file_test (path, FILE_TEST_EXISTS)) { really = true; return true; } - path = Glib::build_filename (user_config_directory().to_string(), ".askedaboutsub"); + path = Glib::build_filename (user_config_directory(), ".askedaboutsub"); if (file_test (path, FILE_TEST_EXISTS)) { /* they never said they were subscribed but they did once express an interest in it. @@ -168,11 +193,9 @@ NagScreen::is_subscribed (bool& really) void NagScreen::offer_to_donate () { - const char* uri = "http://ardour.org/donate"; - /* we don't care if it fails */ - open_uri (uri); + PBD::open_uri (Config->get_donate_url()); } void @@ -180,27 +203,8 @@ NagScreen::offer_to_subscribe () { const char* uri = "http://ardour.org/subscribe"; - if (open_uri (uri)) { + if (PBD::open_uri (uri)) { mark_subscriber (); } } -bool -NagScreen::open_uri (const char* uri) -{ -#ifdef HAVE_GTK_OPEN_URI - GError* err; - return gtk_open_uri (0, uri, GDK_CURRENT_TIME, &err); -#else -#ifdef GTKOSX - extern bool cocoa_open_url (const char*); - return cocoa_open_url (uri); -#else - std::string command = "xdg-open "; - command += uri; - spawn_command_line_async (command); - - return true; -#endif -#endif -}