Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Read authors (updated) from engrampa.about gresource
  • Loading branch information
rbuj authored and raveit65 committed Feb 19, 2019
1 parent 5ceee4c commit c9eb7cb
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/Makefile.am
Expand Up @@ -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)\" \
Expand Down
37 changes: 30 additions & 7 deletions src/actions.c
Expand Up @@ -21,6 +21,7 @@
*/

#include <config.h>
#include <glib.h>
#include <string.h>
#include <math.h>
#include <sys/types.h>
Expand Down Expand Up @@ -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 <paolo.bacchilega@libero.it>",
"Perberos <perberos@gmail.com>",
NULL
};
FrWindow *window = gp;
const char *documenters [] = {
"Alexander Kirillov",
"Breda McColgan",
Expand All @@ -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);

Expand All @@ -887,5 +909,6 @@ activate_action_about (GtkAction *action,
"website", "http://mate-desktop.org",
NULL);

g_strfreev (authors);
g_free (license_text);
}
1 change: 1 addition & 0 deletions src/engrampa.gresource.xml
Expand Up @@ -6,6 +6,7 @@
<file compressed="true">ui/batch-add-files.ui</file>
<file compressed="true">ui/batch-password.ui</file>
<file compressed="true">ui/delete.ui</file>
<file compressed="true">ui/engrampa.about</file>
<file compressed="true">ui/menus-toolbars.ui</file>
<file compressed="true">ui/new.ui</file>
<file compressed="true">ui/password.ui</file>
Expand Down
3 changes: 2 additions & 1 deletion src/fr-window.c
Expand Up @@ -23,6 +23,7 @@
#include <math.h>
#include <string.h>

#include <glib.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gdk/gdk.h>
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/gtk-utils.c
Expand Up @@ -22,11 +22,11 @@

#include <config.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include "gtk-utils.h"

#define LOAD_BUFFER_SIZE 65536
#define ENGRAMPA_RESOURCE_UI_PATH "/org/mate/Engrampa/ui/"

static void
count_selected (GtkTreeModel *model,
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/ui/Makefile.am
Expand Up @@ -4,6 +4,7 @@ EXTRA_DIST = \
batch-add-files.ui \
batch-password.ui \
delete.ui \
engrampa.about \
menus-toolbars.ui \
new.ui \
password.ui \
Expand Down
2 changes: 2 additions & 0 deletions src/ui/engrampa.about
@@ -0,0 +1,2 @@
[About]
Authors=Adam Erdman <hekel%archlinux.info>;Alexander von Gluck IV <kallisti5%unixzen.com>;Balló György <ballogyor%gmail.com>;Dmitry Mikhirev <mikhirev%users.noreply.github.com>;Elias Aebi <user142%hotmail.com>;Iain Nicol <iainn%src.gnome.org>;Ingo Saitz <Ingo.Saitz%stud.uni-hannover.de>;Leigh Scott <leigh123linux%googlemail.com>;Martin Wimpress <martin.wimpress%canonical.com>;Nelson Marques <nmo.marques%gmail.com>;Oz N Tiram <nahumoz%gmail.com>;Pablo Barciela <scow%riseup.net>;Paolo Bacchilega <paobac%gnome.org>;Perberos <perberos%gmail.com>;Piotr Drąg <piotrdrag%gmail.com>;Robert Buj <robert.buj%gmail.com>;Sander Sweers <infirit%gmail.com>;Scott Balneaves <sbalneav%alburg.net>;Sergey Ponomarev <stokito%gmail.com>;Stefano Karapetsas <stefano%karapetsas.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>;ZenWalker <scow%riseup.net>;
68 changes: 68 additions & 0 deletions 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 <http://www.gnu.org/licenses/>.
=cut
use strict;
use warnings;

sub ReplaceAuthors {
my @authors = @_;
$_ eq 'bl0ckeduser <bl0ckedusersoft%gmail.com>' and $_ = 'Gabriel Cormier-Affleck <bl0ckedusersoft%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 '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 <martin%mate-desktop.org>' and $_ = 'Martin Wimpress <martin.wimpress%canonical.com>' for @authors;
$_ eq 'Martin Wimpress <code%flexion.org>' and $_ = 'Martin Wimpress <martin.wimpress%canonical.com>' 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 'Oz <nahumoz%gmail.com>' and $_ = 'Oz N Tiram <nahumoz%gmail.com>' for @authors;
$_ eq 'Paolo Bacchilega <paobac%src.gnome.org>' and $_ = 'Paolo Bacchilega <paobac%gnome.org>' for @authors;
$_ eq 'Paolo Bacchilega <paolo.bacchilega%libero.it>' and $_ = 'Paolo Bacchilega <paobac%gnome.org>' 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 'sc0w <scow%riseup.net>' and $_ = 'ZenWalker <scow%riseup.net>' 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/ui/engrampa.about") or die "Can't open src/ui/engrampa.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) . ';';

0 comments on commit c9eb7cb

Please sign in to comment.