Skip to content

Commit c9eb7cb

Browse files
rbujraveit65
authored andcommitted
Read authors (updated) from engrampa.about gresource
1 parent 5ceee4c commit c9eb7cb

File tree

8 files changed

+107
-10
lines changed

8 files changed

+107
-10
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ AM_CPPFLAGS = \
2626
-I$(top_srcdir)/copy-n-paste/ \
2727
-I$(top_srcdir) \
2828
-I$(top_builddir) \
29+
-DENGRAMPA_RESOURCE_UI_PATH="\"/org/mate/Engrampa/ui\"" \
2930
-DFR_PREFIX=\"$(prefix)\" \
3031
-DFR_SYSCONFDIR=\"$(sysconfdir)\" \
3132
-DFR_DATADIR=\"$(datadir)\" \

src/actions.c

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
#include <config.h>
24+
#include <glib.h>
2425
#include <string.h>
2526
#include <math.h>
2627
#include <sys/types.h>
@@ -841,16 +842,14 @@ activate_action_manual (GtkAction *action,
841842
}
842843

843844

845+
#define ABOUT_GROUP "About"
846+
#define EMAILIFY(string) (g_strdelimit ((string), "%", '@'))
847+
844848
void
845849
activate_action_about (GtkAction *action,
846-
gpointer data)
850+
gpointer gp)
847851
{
848-
FrWindow *window = data;
849-
const char *authors[] = {
850-
"Paolo Bacchilega <paolo.bacchilega@libero.it>",
851-
"Perberos <perberos@gmail.com>",
852-
NULL
853-
};
852+
FrWindow *window = gp;
854853
const char *documenters [] = {
855854
"Alexander Kirillov",
856855
"Breda McColgan",
@@ -870,6 +869,29 @@ activate_action_about (GtkAction *action,
870869
"51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA")
871870
};
872871
char *license_text;
872+
GKeyFile *key_file;
873+
GBytes *bytes;
874+
const guint8 *data;
875+
gsize data_len;
876+
GError *error = NULL;
877+
char **authors;
878+
gsize n_authors = 0, i;
879+
880+
bytes = g_resources_lookup_data (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "engrampa.about", G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
881+
g_assert_no_error (error);
882+
883+
data = g_bytes_get_data (bytes, &data_len);
884+
key_file = g_key_file_new ();
885+
g_key_file_load_from_data (key_file, (const char *) data, data_len, 0, &error);
886+
g_assert_no_error (error);
887+
888+
authors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Authors", &n_authors, NULL);
889+
890+
g_key_file_free (key_file);
891+
g_bytes_unref (bytes);
892+
893+
for (i = 0; i < n_authors; ++i)
894+
authors[i] = EMAILIFY (authors[i]);
873895

874896
license_text = g_strjoin ("\n\n", _(license[0]), _(license[1]), _(license[2]), NULL);
875897

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

912+
g_strfreev (authors);
890913
g_free (license_text);
891914
}

src/engrampa.gresource.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<file compressed="true">ui/batch-add-files.ui</file>
77
<file compressed="true">ui/batch-password.ui</file>
88
<file compressed="true">ui/delete.ui</file>
9+
<file compressed="true">ui/engrampa.about</file>
910
<file compressed="true">ui/menus-toolbars.ui</file>
1011
<file compressed="true">ui/new.ui</file>
1112
<file compressed="true">ui/password.ui</file>

src/fr-window.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <math.h>
2424
#include <string.h>
2525

26+
#include <glib.h>
2627
#include <glib/gi18n.h>
2728
#include <gio/gio.h>
2829
#include <gdk/gdk.h>
@@ -5997,7 +5998,7 @@ fr_window_construct (FrWindow *window)
59975998
g_cclosure_new_swap (G_CALLBACK (fr_window_close), window, NULL));
59985999

59996000

6000-
if (! gtk_ui_manager_add_ui_from_resource (ui, "/org/mate/Engrampa/ui/menus-toolbars.ui", &error)) {
6001+
if (! gtk_ui_manager_add_ui_from_resource (ui, ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "menus-toolbars.ui", &error)) {
60016002
g_message ("building menus failed: %s", error->message);
60026003
g_error_free (error);
60036004
}

src/gtk-utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
#include <config.h>
2424
#include <string.h>
25+
#include <glib.h>
2526
#include <gtk/gtk.h>
2627
#include "gtk-utils.h"
2728

2829
#define LOAD_BUFFER_SIZE 65536
29-
#define ENGRAMPA_RESOURCE_UI_PATH "/org/mate/Engrampa/ui/"
3030

3131
static void
3232
count_selected (GtkTreeModel *model,
@@ -783,7 +783,7 @@ _gtk_builder_new_from_resource (const char *resource_path)
783783
GError *error = NULL;
784784

785785
builder = gtk_builder_new ();
786-
full_path = g_strconcat (ENGRAMPA_RESOURCE_UI_PATH, resource_path, NULL);
786+
full_path = g_strconcat (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S, resource_path, NULL);
787787
if (! gtk_builder_add_from_resource (builder, full_path, &error)) {
788788
g_warning ("%s\n", error->message);
789789
g_clear_error (&error);

src/ui/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ EXTRA_DIST = \
44
batch-add-files.ui \
55
batch-password.ui \
66
delete.ui \
7+
engrampa.about \
78
menus-toolbars.ui \
89
new.ui \
910
password.ui \

src/ui/engrampa.about

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[About]
2+
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>;

update-authors.pl

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/perl
2+
=pod
3+
4+
update-authors.pl is part of Engrampa.
5+
6+
Engrampa is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 2 of the License, or
9+
(at your option) any later version.
10+
11+
Engrampa is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with Engrampa. If not, see <http://www.gnu.org/licenses/>.
18+
19+
=cut
20+
use strict;
21+
use warnings;
22+
23+
sub ReplaceAuthors {
24+
my @authors = @_;
25+
$_ eq 'bl0ckeduser <bl0ckedusersoft%gmail.com>' and $_ = 'Gabriel Cormier-Affleck <bl0ckedusersoft%gmail.com>' for @authors;
26+
$_ eq 'hekel <hekel%archlinux.info>' and $_ = 'Adam Erdman <hekel%archlinux.info>' for @authors;
27+
$_ eq 'infirit <infirit%gmail.com>' and $_ = 'Sander Sweers <infirit%gmail.com>' for @authors;
28+
$_ eq 'leigh123linux <leigh123linux%googlemail.com>' and $_ = 'Leigh Scott <leigh123linux%googlemail.com>' for @authors;
29+
$_ eq 'lyokha <alexey.radkov%gmail.com>' and $_ = 'Alexey Radkov <alexey.radkov%gmail.com>' for @authors;
30+
$_ eq 'Martin Wimpress <martin%mate-desktop.org>' and $_ = 'Martin Wimpress <martin.wimpress%canonical.com>' for @authors;
31+
$_ eq 'Martin Wimpress <code%flexion.org>' and $_ = 'Martin Wimpress <martin.wimpress%canonical.com>' for @authors;
32+
$_ eq 'monsta <monsta%inbox.ru>' and $_ = 'Vlad Orlov <monsta%inbox.ru>' for @authors;
33+
$_ eq 'Monsta <monsta%inbox.ru>' and $_ = 'Vlad Orlov <monsta%inbox.ru>' for @authors;
34+
$_ eq 'Oz <nahumoz%gmail.com>' and $_ = 'Oz N Tiram <nahumoz%gmail.com>' for @authors;
35+
$_ eq 'Paolo Bacchilega <paobac%src.gnome.org>' and $_ = 'Paolo Bacchilega <paobac%gnome.org>' for @authors;
36+
$_ eq 'Paolo Bacchilega <paolo.bacchilega%libero.it>' and $_ = 'Paolo Bacchilega <paobac%gnome.org>' for @authors;
37+
$_ eq 'raveit <chat-to-me%raveit.de>' and $_ = 'Wolfgang Ulbrich <mate%raveit.de>' for @authors;
38+
$_ eq 'raveit65 <chat-to-me%raveit.de>' and $_ = 'Wolfgang Ulbrich <mate%raveit.de>' for @authors;
39+
$_ eq 'raveit65 <mate%raveit.de>' and $_ = 'Wolfgang Ulbrich <mate%raveit.de>' for @authors;
40+
$_ eq 'rbuj <robert.buj%gmail.com>' and $_ = 'Robert Buj <robert.buj%gmail.com>' for @authors;
41+
$_ eq 'Scott Balneaves <sbalneav%ltsp.org>' and $_ = 'Scott Balneaves <sbalneav%mate-desktop.org>' for @authors;
42+
$_ eq 'sc0w <scow%riseup.net>' and $_ = 'ZenWalker <scow%riseup.net>' for @authors;
43+
$_ eq 'Wolfgang Ulbrich <chat-to-me%raveit.de>' and $_ = 'Wolfgang Ulbrich <mate%raveit.de>' for @authors;
44+
return @authors;
45+
}
46+
47+
sub GetCurrentAuthors {
48+
my @authors;
49+
open(FILE,"src/ui/engrampa.about") or die "Can't open src/ui/engrampa.about";
50+
while (<FILE>) {
51+
if (/^Authors=*(.+)$/) {
52+
@authors=split(";",$1);
53+
}
54+
}
55+
close FILE;
56+
return ReplaceAuthors(@authors);
57+
}
58+
59+
sub GetNewAuthors {
60+
my @authors = `git log --pretty="%an <%ae>" --since "2012-01-01" -- . "_.h" "_.c" | sort | uniq | sed 's/@/%/g' | sed '/^mate-i18n.*/d'`;
61+
chomp @authors;
62+
return ReplaceAuthors(@authors);
63+
}
64+
65+
my @A = GetCurrentAuthors;
66+
my @B = GetNewAuthors;
67+
my @merged = sort { $a cmp $b } keys %{{map {($_ => 1)} (@A, @B)}};
68+
print join(';',@merged) . ';';

0 commit comments

Comments
 (0)