Commit 91e16299 authored by Sébastien Wilmet's avatar Sébastien Wilmet

Close crowdfunding

It didn't work well.
parent 03f2510e
......@@ -194,7 +194,6 @@
<schema id="org.gnome.gnome-latex.state" path="/org/gnome/gnome-latex/state/">
<child schema="org.gnome.gnome-latex.state.window" name="window" />
<child schema="org.gnome.gnome-latex.state.dialogs" name="dialogs" />
</schema>
<schema id="org.gnome.gnome-latex.state.window" path="/org/gnome/gnome-latex/state/window/">
......@@ -217,17 +216,4 @@
<default>100</default>
</key>
</schema>
<schema id="org.gnome.gnome-latex.state.dialogs" path="/org/gnome/gnome-latex/state/dialogs/">
<child schema="org.gnome.gnome-latex.state.dialogs.finance" name="finance" />
</schema>
<schema id="org.gnome.gnome-latex.state.dialogs.finance" path="/org/gnome/gnome-latex/state/dialogs/finance/">
<key name="last-shown-date" type="s">
<default>''</default>
</key>
<key name="remind-later" type="b">
<default>false</default>
</key>
</schema>
</schemalist>
......@@ -22,7 +22,6 @@ src/document_view.vala
src/encodings.vala
src/error_entry.vala
src/file_browser.vala
src/finance.vala
src/glatex_app.vala
src/latex_menu.vala
src/liblatexila/dh-dconf-migration.c
......
......@@ -17,7 +17,6 @@ src/document_view.c
src/encodings.c
src/error_entry.c
src/file_browser.c
src/finance.c
src/glatex_app.c
src/latex_menu.c
src/main.c
......
......@@ -39,7 +39,6 @@ vala_files = \
error_entry.vala \
factory.vala \
file_browser.vala \
finance.vala \
glatex_app.vala \
latex_menu.vala \
main.vala \
......
/*
* This file is part of GNOME LaTeX.
*
* Copyright © 2015 - Sébastien Wilmet
*
* GNOME LaTeX 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 3 of the License, or
* (at your option) any later version.
*
* GNOME LaTeX 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 GNOME LaTeX. If not, see <http://www.gnu.org/licenses/>.
*/
using Gtk;
namespace Finance
{
public void show_dialog (Window parent_window, bool startup)
{
if (startup && !should_show_dialog_on_startup ())
return;
string title;
if (startup)
title = "Welcome in GNOME LaTeX!";
else
title = "GNOME LaTeX Finance";
Dialog dialog = new Dialog.with_buttons (title,
parent_window,
DialogFlags.DESTROY_WITH_PARENT,
"_Close", ResponseType.CLOSE,
"GNOME LaTeX _Fundraising", ResponseType.ACCEPT,
null);
dialog.set_resizable (false);
dialog.set_default_response (ResponseType.ACCEPT);
unowned Box content_area = dialog.get_content_area ();
content_area.set_spacing (6);
content_area.margin = 12;
content_area.margin_top = 6;
Image image = new Image.from_icon_name ("gnome-latex", IconSize.DIALOG);
image.set_pixel_size (128);
content_area.add (image);
Label label = new Label (null);
label.set_markup ("<big>Did you know...</big>");
content_area.add (label);
label = new Label ("...that you can support GNOME LaTeX financially?");
content_area.add (label);
label = new Label (null);
label.set_markup ("GNOME LaTeX is a Free/<i>Libre</i> LaTeX editor and comes" +
" free of charge. But if you appreciate this software, you are encouraged" +
" to make a donation to help its future development.");
label.max_width_chars = 60;
label.set_line_wrap (true);
label.xalign = 0;
content_area.add (label);
if (startup)
{
label = new Label ("You can see again this information at any time by going to the Help menu.");
label.max_width_chars = 60;
label.set_line_wrap (true);
label.xalign = 0;
content_area.add (label);
}
label = new Label ("Thanks!");
label.xalign = 0;
content_area.add (label);
CheckButton remind_later_checkbutton =
new CheckButton.with_mnemonic ("_Remind me later (in one month)");
remind_later_checkbutton.set_active (false);
remind_later_checkbutton.margin_top = 12;
remind_later_checkbutton.margin_bottom = 6;
content_area.add (remind_later_checkbutton);
content_area.show_all ();
while (true)
{
int response = dialog.run ();
if (response == ResponseType.ACCEPT)
{
open_donate_page (dialog);
continue;
}
GLib.Settings settings =
new GLib.Settings ("org.gnome.gnome-latex.state.dialogs.finance");
settings.set_boolean ("remind-later", remind_later_checkbutton.get_active ());
break;
}
dialog.destroy ();
save_date ();
}
private bool should_show_dialog_on_startup ()
{
GLib.Settings settings =
new GLib.Settings ("org.gnome.gnome-latex.state.dialogs.finance");
string date = settings.get_string ("last-shown-date");
if (date == "")
return true;
if (settings.get_boolean ("remind-later"))
{
string[] ymd = date.split ("-");
if (ymd.length != 3)
return false;
int year = int.parse (ymd[0]);
int month = int.parse (ymd[1]);
int day = int.parse (ymd[2]);
DateTime last_time = new DateTime.utc (year, month, day, 0, 0, 0);
DateTime cur_time = new DateTime.now_utc ();
// Remind one month later.
DateTime time_limit = last_time.add_months (1);
if (time_limit.compare (cur_time) <= 0)
return true;
}
return false;
}
private void save_date ()
{
GLib.Settings settings =
new GLib.Settings ("org.gnome.gnome-latex.state.dialogs.finance");
DateTime time = new DateTime.now_utc ();
string date = "%d-%d-%d".printf (time.get_year (), time.get_month (),
time.get_day_of_month ());
settings.set_string ("last-shown-date", date);
}
private void open_donate_page (Widget widget)
{
try
{
string uri = "https://liberapay.com/GNOME-LaTeX/";
Latexila.utils_show_uri (widget, uri, Gdk.CURRENT_TIME);
}
catch (Error e)
{
warning ("Impossible to open the donate page: %s", e.message);
}
}
}
......@@ -29,7 +29,6 @@ public class GlatexApp : Gtk.Application
{ "preferences", preferences_cb },
{ "manage-build-tools", manage_build_tools_cb },
{ "help", help_cb },
{ "fundraising", fundraising_cb },
{ "about", about_cb },
{ "quit", quit_cb }
};
......@@ -201,11 +200,6 @@ public class GlatexApp : Gtk.Application
}
}
private void fundraising_cb ()
{
Finance.show_dialog (get_active_main_window (), false);
}
private void about_cb ()
{
string comments =
......
......@@ -538,8 +538,6 @@ migrate_latexila_to_gnome_latex_gsettings (void)
"preferences/ui/show-build-warnings",
"preferences/ui/side-panel-component",
"preferences/ui/side-panel-visible",
"state/dialogs/finance/last-shown-date",
"state/dialogs/finance/remind-later",
"state/window/documents",
"state/window/side-panel-size",
"state/window/size",
......
......@@ -65,8 +65,6 @@ public class MainWindow : ApplicationWindow
N_("Open the GNOME LaTeX documentation") },
{ "HelpLatexReference", null, N_("_LaTeX Reference"), null,
N_("The Kile LaTeX Reference"), on_help_latex_reference },
{ "HelpFinance", null, "GNOME LaTeX _Fundraising", null,
"Donate to demonstrate your appreciation of GNOME LaTeX and help its future development" },
{ "HelpAbout", "help-about", N_("_About"), null,
N_("About GNOME LaTeX") }
};
......@@ -305,8 +303,6 @@ public class MainWindow : ApplicationWindow
restore_state ();
show_or_hide_widgets ();
show ();
Finance.show_dialog (this, true);
}
// Force to show icons in the menu.
......@@ -352,8 +348,6 @@ public class MainWindow : ApplicationWindow
_action_group, "FileQuit");
Amtk.utils_bind_g_action_to_gtk_action (app, "help",
_action_group, "HelpContents");
Amtk.utils_bind_g_action_to_gtk_action (app, "fundraising",
_action_group, "HelpFinance");
Amtk.utils_bind_g_action_to_gtk_action (app, "about",
_action_group, "HelpAbout");
......
......@@ -23,10 +23,6 @@
<attribute name="label" translatable="yes">_Help</attribute>
<attribute name="action">app.help</attribute>
</item>
<item>
<attribute name="label">GNOME LaTeX _Fundraising</attribute>
<attribute name="action">app.fundraising</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_About</attribute>
<attribute name="action">app.about</attribute>
......
......@@ -394,7 +394,6 @@ along with GNOME LaTeX. If not, see <http://www.gnu.org/licenses/>.
<menu action="Help">
<menuitem action="HelpContents" />
<menuitem action="HelpLatexReference" />
<menuitem action="HelpFinance" />
<menuitem action="HelpAbout" />
</menu>
</menubar>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment