Blob Blame History Raw
From b8752ab875f61a43492a3177d249fa883cacdb84 Mon Sep 17 00:00:00 2001
From: rbuj <robert.buj@gmail.com>
Date: Sat, 15 Feb 2020 17:34:52 -0500
Subject: [PATCH] Read authors (updated) from mate-calc.about

---
 src/Makefile.am                       |  1 +
 src/mate-calc.about                   |  2 +
 src/math-window.c                     | 36 +++++++++++---
 src/org.mate.calculator.gresource.xml |  1 +
 update-authors.pl                     | 71 +++++++++++++++++++++++++++
 5 files changed, 104 insertions(+), 7 deletions(-)
 create mode 100644 src/mate-calc.about
 create mode 100755 update-authors.pl

diff --git a/src/Makefile.am b/src/Makefile.am
index b6690a1..df5fccd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -190,6 +190,7 @@ EXTRA_DIST = \
 	buttons-basic.ui \
 	buttons-financial.ui \
 	buttons-programming.ui \
+	mate-calc.about \
 	mp-enums.c.template \
 	mp-enums.h.template \
 	org.mate.calculator.gresource.xml \
diff --git a/src/mate-calc.about b/src/mate-calc.about
new file mode 100644
index 0000000..ba1664a
--- /dev/null
+++ b/src/mate-calc.about
@@ -0,0 +1,2 @@
+[About]
+Authors=Abel McClendon <hcmmac%hosscomm.com>;Adam Erdman <hekel%archlinux.info>;Alexander von Gluck IV <kallisti5%unixzen.com>;Alexei Sorokin <sor.alexei%meowr.ru>;Allan Nordhøy <epost%anotheragency.no>;Christopher Fujino <christopherfujino%gmail.com>;Clement Lefebvre <clement.lefebvre%linuxmint.com>;Friedel Wolff <friedel%translate.org.za>;JP Cimalando <jp-dev%inbox.ru>;Klaus Niederkrüger <kniederk%umpa.ens-lyon.fr>;Laszlo Boros <iamsemmu%gmail.com>;Laurent Napias <tamplan%free.fr>;Marcel Dijkstra <marcel.dykstra%gmail.com>;Mark Thomas <markbt%efaref.net>;Martin Wimpress <martin%mate-desktop.org>;Michael Terry <michael.terry%canonical.com>;Mike Gabriel <mike.gabriel%das-netzwerkteam.de>;Nikolay Martynov <mar.kolya%gmail.com>;Pablo Barciela <scow%riseup.net>;Perberos <perberos%gmail.com>;Piotr Drąg <piotrdrag%gmail.com>;Rich Burridge <rich.burridge%sun.com>;Robert Ancell <robert.ancell%gmail.com>;Robert Buj <robert.buj%gmail.com>;Sander Sweers <infirit%gmail.com>;Scott Balneaves <sbalneav%mate-desktop.org>;Sorokin Alexei <sor.alexei%meowr.ru>;Stefan Tauner <stefan.tauner%gmx.at>;Stefano Karapetsas <stefano%karapetsas.com>;Stephen Krauth <sk42%stephenk.com>;Steve Zesch <stevezesch2%gmail.com>;Victor Kareh <vkareh%vkareh.net>;Vlad Orlov <monsta%inbox.ru>;Wolfgang Ulbrich <mate%raveit.de>;Wu Xiaotian <yetist%gmail.com>;
diff --git a/src/math-window.c b/src/math-window.c
index ca31f4e..9030893 100644
--- a/src/math-window.c
+++ b/src/math-window.c
@@ -221,15 +221,11 @@ static void help_cb(GtkWidget *widget, MathWindow *window)
     }
 }
 
+#define ABOUT_GROUP "About"
+#define EMAILIFY(string) (g_strdelimit ((string), "%", '@'))
+
 static void about_cb(GtkWidget* widget, MathWindow* window)
 {
-    const char* authors[] = {
-        "Rich Burridge <rich.burridge@sun.com>",
-        "Robert Ancell <robert.ancell@gmail.com>",
-        "Klaus Niederkrüger <kniederk@umpa.ens-lyon.fr>",
-        NULL
-    };
-
     const char* documenters[] = {
         N_("Sun Microsystems"),
         N_("MATE Documentation Team"),
@@ -252,6 +248,31 @@ static void about_cb(GtkWidget* widget, MathWindow* window)
     };
 
     char *license_trans = g_strjoin ("\n\n", _(license[0]), _(license[1]), _(license[2]), NULL);
+
+    GKeyFile *key_file;
+    GBytes *bytes;
+    const guint8 *data;
+    gsize data_len;
+    GError *error = NULL;
+    char **authors;
+    gsize n_authors = 0, i;
+
+    bytes = g_resources_lookup_data ("/org/mate/calculator/ui/mate-calc.about", G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
+    g_assert_no_error (error);
+
+    data = g_bytes_get_data (bytes, &data_len);
+    key_file = g_key_file_new ();
+    g_key_file_load_from_data (key_file, (const char *) data, data_len, 0, &error);
+    g_assert_no_error (error);
+
+    authors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Authors", &n_authors, NULL);
+
+    g_key_file_free (key_file);
+    g_bytes_unref (bytes);
+
+    for (i = 0; i < n_authors; ++i)
+        authors[i] = EMAILIFY (authors[i]);
+
     const char **p;
 
     for (p = documenters; *p; ++p)
@@ -274,6 +295,7 @@ static void about_cb(GtkWidget* widget, MathWindow* window)
         "logo-icon-name", "accessories-calculator",
         NULL);
 
+    g_strfreev (authors);
     g_free (license_trans);
 }
 
diff --git a/src/org.mate.calculator.gresource.xml b/src/org.mate.calculator.gresource.xml
index c31c1ba..6766402 100644
--- a/src/org.mate.calculator.gresource.xml
+++ b/src/org.mate.calculator.gresource.xml
@@ -21,6 +21,7 @@
     <file compressed="true" preprocess="xml-stripblanks">buttons-basic.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">buttons-financial.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">buttons-programming.ui</file>
+    <file compressed="true">mate-calc.about</file>
     <file compressed="true" preprocess="xml-stripblanks">preferences.ui</file>
   </gresource>
 </gresources>
diff --git a/update-authors.pl b/update-authors.pl
new file mode 100755
index 0000000..4d5ede1
--- /dev/null
+++ b/update-authors.pl
@@ -0,0 +1,71 @@
+#!/usr/bin/perl
+=pod
+
+    update-authors.pl is part of mate-calc.
+
+    mate-calc 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.
+
+    mate-calc 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 mate-calc.  If not, see <http://www.gnu.org/licenses/>.
+
+=cut
+use strict;
+use warnings;
+
+sub ReplaceAuthors {
+  my @authors = @_;
+  $_ eq 'Alexander <sanek23994%gmail.com>' and $_ = 'Alexander Ovchinnikov <sanek23994%gmail.com>' for @authors;
+  $_ eq 'bl0ckeduser <bl0ckedusersoft%gmail.com>' and $_ = 'Gabriel Cormier-Affleck <bl0ckedusersoft%gmail.com>' for @authors;
+  $_ eq 'Glorf <michal1.bien%gmail.com>' and $_ = 'Michał Bień <michal1.bien%gmail.com>' for @authors;
+  $_ eq 'hekel <hekel%archlinux.info>' and $_ = 'Adam Erdman <hekel%archlinux.info>' for @authors;
+  $_ eq 'infirit <infirit%gmail.com>' and $_ = 'Sander Sweers <infirit%gmail.com>' for @authors;
+  $_ eq 'Jason Crain <jason%inspiresomeone.us>' and $_ = 'Jason Crain <jason%aquaticape.us>' for @authors;
+  $_ eq 'José Aliste <jaliste%src.gnome.org>' and $_ = 'José Aliste <jaliste%gnome.org>' for @authors;
+  $_ eq 'leigh123linux <leigh123linux%googlemail.com>' and $_ = 'Leigh Scott <leigh123linux%googlemail.com>' for @authors;
+  $_ eq 'lyokha <alexey.radkov%gmail.com>' and $_ = 'Alexey Radkov <alexey.radkov%gmail.com>' for @authors;
+  $_ eq 'Martin Wimpress <code%flexion.org>' and $_ = 'Martin Wimpress <martin%mate-desktop.org>' for @authors;
+  $_ eq 'monsta <monsta%inbox.ru>' and $_ = 'Vlad Orlov <monsta%inbox.ru>' for @authors;
+  $_ eq 'Monsta <monsta%inbox.ru>' and $_ = 'Vlad Orlov <monsta%inbox.ru>' for @authors;
+  $_ eq 'oz123 <nahumoz%gmail.com>' and $_ = 'Oz N Tiram <nahumoz%gmail.com>' for @authors;
+  $_ eq 'Piiit <pitiz29a%gmail.com>' and $_ = 'Peter Moser <pitiz29a%gmail.com>' for @authors;
+  $_ eq 'rootavish <avishkar_gupta%outlook.com>' and $_ = 'Avishkar Gupta <rootavish%gmail.com>' for @authors;
+  $_ eq 'rootavish <rootavish%gmail.com>' and $_ = 'Avishkar Gupta <rootavish%gmail.com>' for @authors;
+  $_ eq 'raveit <chat-to-me%raveit.de>' and $_ = 'Wolfgang Ulbrich <mate%raveit.de>' for @authors;
+  $_ eq 'raveit65 <chat-to-me%raveit.de>' and $_ = 'Wolfgang Ulbrich <mate%raveit.de>' for @authors;
+  $_ eq 'raveit65 <mate%raveit.de>' and $_ = 'Wolfgang Ulbrich <mate%raveit.de>' for @authors;
+  $_ eq 'rbuj <robert.buj%gmail.com>' and $_ = 'Robert Buj <robert.buj%gmail.com>' for @authors;
+  $_ eq 'Scott Balneaves <sbalneav%ltsp.org>' and $_ = 'Scott Balneaves <sbalneav%mate-desktop.org>' for @authors;
+  $_ eq 'Wolfgang Ulbrich <chat-to-me%raveit.de>' and $_ = 'Wolfgang Ulbrich <mate%raveit.de>' for @authors;
+  return @authors;
+}
+
+sub GetCurrentAuthors {
+  my @authors;
+  open(FILE,"src/mate-calc.about") or die "Can't open src/mate-calc.about"";
+  while (<FILE>) {
+    if (/^Authors=*(.+)$/) {
+      @authors=split(";",$1);
+    }
+  }
+  close FILE;
+  return ReplaceAuthors(@authors);
+}
+
+sub GetNewAuthors {
+  my @authors = `git log --pretty="%an <%ae>" --since "2012-01-01" -- . "_.h" "_.c" | sort | uniq | sed 's/@/%/g' | sed '/^mate-i18n.*/d'`;
+  chomp @authors;
+  return ReplaceAuthors(@authors);
+}
+
+my @A = GetCurrentAuthors;
+my @B = GetNewAuthors;
+my @merged = sort { $a cmp $b } keys %{{map {($_ => 1)} (@A, @B)}};
+print join(';',@merged) . ';';
-- 
2.21.1