From c9eb7cba9796105a4a5196ed7ef5b1ec1f2df27b Mon Sep 17 00:00:00 2001 From: rbuj Date: Tue, 19 Feb 2019 08:58:55 +0100 Subject: Read authors (updated) from engrampa.about gresource --- src/Makefile.am | 1 + src/actions.c | 37 ++++++++++++++++++++----- src/engrampa.gresource.xml | 1 + src/fr-window.c | 3 +- src/gtk-utils.c | 4 +-- src/ui/Makefile.am | 1 + src/ui/engrampa.about | 2 ++ update-authors.pl | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 107 insertions(+), 10 deletions(-) create mode 100644 src/ui/engrampa.about create mode 100755 update-authors.pl diff --git a/src/Makefile.am b/src/Makefile.am index 49adf26..383a4c2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,6 +26,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/copy-n-paste/ \ -I$(top_srcdir) \ -I$(top_builddir) \ + -DENGRAMPA_RESOURCE_UI_PATH="\"/org/mate/Engrampa/ui\"" \ -DFR_PREFIX=\"$(prefix)\" \ -DFR_SYSCONFDIR=\"$(sysconfdir)\" \ -DFR_DATADIR=\"$(datadir)\" \ diff --git a/src/actions.c b/src/actions.c index 0287b40..974af9f 100644 --- a/src/actions.c +++ b/src/actions.c @@ -21,6 +21,7 @@ */ #include +#include #include #include #include @@ -841,16 +842,14 @@ activate_action_manual (GtkAction *action, } +#define ABOUT_GROUP "About" +#define EMAILIFY(string) (g_strdelimit ((string), "%", '@')) + void activate_action_about (GtkAction *action, - gpointer data) + gpointer gp) { - FrWindow *window = data; - const char *authors[] = { - "Paolo Bacchilega ", - "Perberos ", - NULL - }; + FrWindow *window = gp; const char *documenters [] = { "Alexander Kirillov", "Breda McColgan", @@ -870,6 +869,29 @@ activate_action_about (GtkAction *action, "51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA") }; char *license_text; + 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 (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "engrampa.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]); license_text = g_strjoin ("\n\n", _(license[0]), _(license[1]), _(license[2]), NULL); @@ -887,5 +909,6 @@ activate_action_about (GtkAction *action, "website", "http://mate-desktop.org", NULL); + g_strfreev (authors); g_free (license_text); } diff --git a/src/engrampa.gresource.xml b/src/engrampa.gresource.xml index 0b944bf..41d4c2e 100644 --- a/src/engrampa.gresource.xml +++ b/src/engrampa.gresource.xml @@ -6,6 +6,7 @@ ui/batch-add-files.ui ui/batch-password.ui ui/delete.ui + ui/engrampa.about ui/menus-toolbars.ui ui/new.ui ui/password.ui diff --git a/src/fr-window.c b/src/fr-window.c index 7162441..2fc9736 100644 --- a/src/fr-window.c +++ b/src/fr-window.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -5997,7 +5998,7 @@ fr_window_construct (FrWindow *window) g_cclosure_new_swap (G_CALLBACK (fr_window_close), window, NULL)); - if (! gtk_ui_manager_add_ui_from_resource (ui, "/org/mate/Engrampa/ui/menus-toolbars.ui", &error)) { + if (! gtk_ui_manager_add_ui_from_resource (ui, ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "menus-toolbars.ui", &error)) { g_message ("building menus failed: %s", error->message); g_error_free (error); } diff --git a/src/gtk-utils.c b/src/gtk-utils.c index 533a335..b8e3263 100644 --- a/src/gtk-utils.c +++ b/src/gtk-utils.c @@ -22,11 +22,11 @@ #include #include +#include #include #include "gtk-utils.h" #define LOAD_BUFFER_SIZE 65536 -#define ENGRAMPA_RESOURCE_UI_PATH "/org/mate/Engrampa/ui/" static void count_selected (GtkTreeModel *model, @@ -783,7 +783,7 @@ _gtk_builder_new_from_resource (const char *resource_path) GError *error = NULL; builder = gtk_builder_new (); - full_path = g_strconcat (ENGRAMPA_RESOURCE_UI_PATH, resource_path, NULL); + full_path = g_strconcat (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S, resource_path, NULL); if (! gtk_builder_add_from_resource (builder, full_path, &error)) { g_warning ("%s\n", error->message); g_clear_error (&error); diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am index 5f1cd54..84cbd90 100644 --- a/src/ui/Makefile.am +++ b/src/ui/Makefile.am @@ -4,6 +4,7 @@ EXTRA_DIST = \ batch-add-files.ui \ batch-password.ui \ delete.ui \ + engrampa.about \ menus-toolbars.ui \ new.ui \ password.ui \ diff --git a/src/ui/engrampa.about b/src/ui/engrampa.about new file mode 100644 index 0000000..a397e2c --- /dev/null +++ b/src/ui/engrampa.about @@ -0,0 +1,2 @@ +[About] +Authors=Adam Erdman ;Alexander von Gluck IV ;Balló György ;Dmitry Mikhirev ;Elias Aebi ;Iain Nicol ;Ingo Saitz ;Leigh Scott ;Martin Wimpress ;Nelson Marques ;Oz N Tiram ;Pablo Barciela ;Paolo Bacchilega ;Perberos ;Piotr Drąg ;Robert Buj ;Sander Sweers ;Scott Balneaves ;Sergey Ponomarev ;Stefano Karapetsas ;Steve Zesch ;Victor Kareh ;Vlad Orlov ;Wolfgang Ulbrich ;Wu Xiaotian ;ZenWalker ; diff --git a/update-authors.pl b/update-authors.pl new file mode 100755 index 0000000..9d7b44e --- /dev/null +++ b/update-authors.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl +=pod + + update-authors.pl is part of Engrampa. + + Engrampa 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. + + Engrampa 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 Engrampa. If not, see . + +=cut +use strict; +use warnings; + +sub ReplaceAuthors { + my @authors = @_; + $_ eq 'bl0ckeduser ' and $_ = 'Gabriel Cormier-Affleck ' for @authors; + $_ eq 'hekel ' and $_ = 'Adam Erdman ' for @authors; + $_ eq 'infirit ' and $_ = 'Sander Sweers ' for @authors; + $_ eq 'leigh123linux ' and $_ = 'Leigh Scott ' for @authors; + $_ eq 'lyokha ' and $_ = 'Alexey Radkov ' for @authors; + $_ eq 'Martin Wimpress ' and $_ = 'Martin Wimpress ' for @authors; + $_ eq 'Martin Wimpress ' and $_ = 'Martin Wimpress ' for @authors; + $_ eq 'monsta ' and $_ = 'Vlad Orlov ' for @authors; + $_ eq 'Monsta ' and $_ = 'Vlad Orlov ' for @authors; + $_ eq 'Oz ' and $_ = 'Oz N Tiram ' for @authors; + $_ eq 'Paolo Bacchilega ' and $_ = 'Paolo Bacchilega ' for @authors; + $_ eq 'Paolo Bacchilega ' and $_ = 'Paolo Bacchilega ' for @authors; + $_ eq 'raveit ' and $_ = 'Wolfgang Ulbrich ' for @authors; + $_ eq 'raveit65 ' and $_ = 'Wolfgang Ulbrich ' for @authors; + $_ eq 'raveit65 ' and $_ = 'Wolfgang Ulbrich ' for @authors; + $_ eq 'rbuj ' and $_ = 'Robert Buj ' for @authors; + $_ eq 'Scott Balneaves ' and $_ = 'Scott Balneaves ' for @authors; + $_ eq 'sc0w ' and $_ = 'ZenWalker ' for @authors; + $_ eq 'Wolfgang Ulbrich ' and $_ = 'Wolfgang Ulbrich ' for @authors; + return @authors; +} + +sub GetCurrentAuthors { + my @authors; + open(FILE,"src/ui/engrampa.about") or die "Can't open src/ui/engrampa.about"; + while () { + 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) . ';'; -- cgit v1.2.1