[latexila/wip/finance] Finance: show dialog on start-up



commit 27be90130ae77350bfa3d77cfa00995e2daa8357
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Jan 22 16:53:00 2015 +0100

    Finance: show dialog on start-up

 po/POTFILES.in       |    1 +
 src/Makefile.am      |    1 +
 src/finance.vala     |   92 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/main_window.vala |   20 ++++-------
 src/ui/ui.xml        |    2 +-
 5 files changed, 102 insertions(+), 14 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 78100b4..dd7c1bf 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -22,6 +22,7 @@ src/document_view.vala
 src/encodings.vala
 src/error_entry.vala
 src/file_browser.vala
+src/finance.vala
 src/latexila_app.vala
 src/latex_menu.vala
 src/liblatexila/latexila-build-job.c
diff --git a/src/Makefile.am b/src/Makefile.am
index bdd5b42..4c32300 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,6 +33,7 @@ vala_files =                          \
        encodings.vala                  \
        error_entry.vala                \
        file_browser.vala               \
+       finance.vala                    \
        latexila_app.vala               \
        latex_menu.vala                 \
        main.vala                       \
diff --git a/src/finance.vala b/src/finance.vala
new file mode 100644
index 0000000..239cd25
--- /dev/null
+++ b/src/finance.vala
@@ -0,0 +1,92 @@
+/*
+ * This file is part of LaTeXila.
+ *
+ * Copyright © 2015 - Sébastien Wilmet
+ *
+ * LaTeXila 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.
+ *
+ * LaTeXila 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 LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+using Gtk;
+
+namespace Finance
+{
+    public void show_dialog (MainWindow window)
+    {
+        Dialog dialog = new Dialog.with_buttons ("LaTeXila Finance",
+            window,
+            DialogFlags.DESTROY_WITH_PARENT,
+            "_Close", ResponseType.CLOSE,
+            "_More Information", 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_file (Config.DATA_DIR + "/images/app/logo.png");
+        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 financially LaTeXila?");
+        content_area.add (label);
+
+        label = new Label (null);
+        label.set_markup ("LaTeXila 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);
+
+        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);
+
+        content_area.show_all ();
+
+        int response = dialog.run ();
+
+        if (response == ResponseType.ACCEPT)
+            open_donate_page (window);
+
+        dialog.destroy ();
+    }
+
+    private void open_donate_page (MainWindow window)
+    {
+        try
+        {
+            string uri = "https://wiki.gnome.org/Apps/LaTeXila/donate";;
+            show_uri (window.get_screen (), uri, Gdk.CURRENT_TIME);
+        }
+        catch (Error e)
+        {
+            warning ("Impossible to open the donate page: %s", e.message);
+        }
+    }
+}
diff --git a/src/main_window.vala b/src/main_window.vala
index 14b4bd7..949d34b 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -64,9 +64,9 @@ public class MainWindow : Window
             N_("Open the LaTeXila documentation"), on_help_contents },
         { "HelpLatexReference", null, N_("_LaTeX Reference"), null,
             N_("The Kile LaTeX Reference"), on_help_latex_reference },
-        { "HelpDonate", null, N_("_Donate"), null,
-            N_("Donate to demonstrate your appreciation of LaTeXila and help its future development"),
-            on_help_donate },
+        { "HelpFinance", null, "LaTeXila Finance", null,
+            "Donate to demonstrate your appreciation of LaTeXila and help its future development",
+            on_help_finance },
         { "HelpAbout", "help-about", N_("_About"), null,
             N_("About LaTeXila"), on_about_dialog }
     };
@@ -267,6 +267,8 @@ public class MainWindow : Window
         restore_state ();
         show_or_hide_widgets ();
         show ();
+
+        Finance.show_dialog (this);
     }
 
     // Force to show icons in the menu.
@@ -1161,17 +1163,9 @@ public class MainWindow : Window
         }
     }
 
-    public void on_help_donate ()
+    public void on_help_finance ()
     {
-        try
-        {
-            string uri = "https://wiki.gnome.org/Apps/LaTeXila/donate";;
-            show_uri (this.get_screen (), uri, Gdk.CURRENT_TIME);
-        }
-        catch (Error e)
-        {
-            warning ("Impossible to open the donate page: %s", e.message);
-        }
+        Finance.show_dialog (this);
     }
 
     public void on_about_dialog ()
diff --git a/src/ui/ui.xml b/src/ui/ui.xml
index 88f7b7b..faf0fdd 100644
--- a/src/ui/ui.xml
+++ b/src/ui/ui.xml
@@ -387,7 +387,7 @@ along with LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
     <menu action="Help">
       <menuitem action="HelpContents" />
       <menuitem action="HelpLatexReference" />
-      <menuitem action="HelpDonate" />
+      <menuitem action="HelpFinance" />
       <menuitem action="HelpAbout" />
     </menu>
   </menubar>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]