From 199af60bcf16b99dc737302216e337066fdf5563 Mon Sep 17 00:00:00 2001 From: rbuj Date: Sun, 16 Feb 2020 10:09:54 +0100 Subject: Read authors (updated) from mate-power-manager.about --- src/Makefile.am | 10 ++++++++++ src/gpm-tray-icon.c | 36 +++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index aed9cc9..1778cef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -151,6 +151,14 @@ mate_power_preferences_CFLAGS = \ $(WARN_CFLAGS) \ $(NULL) +mate-power-manager-resources.h mate-power-manager-resources.c: $(srcdir)/../data/org.mate.power-manager.manager.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir)/../data $(srcdir)/../data/org.mate.power-manager.manager.gresource.xml) + $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir)/../data --generate --c-name preferences $< + +nodist_mate_power_manager_SOURCES = \ + mate-power-manager-resources.h \ + mate-power-manager-resources.c \ + $(NULL) + mate_power_manager_SOURCES = \ gpm-dpms.h \ gpm-dpms.c \ @@ -316,6 +324,8 @@ clean-local: CLEANFILES = \ $(BUILT_SOURCES) \ + mate-power-manager-resources.h \ + mate-power-manager-resources.c \ mate-power-preferences-resources.h \ mate-power-preferences-resources.c \ mate-power-statistics-resources.h \ diff --git a/src/gpm-tray-icon.c b/src/gpm-tray-icon.c index f87506f..56e87b4 100644 --- a/src/gpm-tray-icon.c +++ b/src/gpm-tray-icon.c @@ -165,6 +165,9 @@ gpm_tray_icon_show_preferences_cb (GtkMenuItem *item, gpointer data) egg_warning ("Couldn't execute command: %s", command); } +#define ABOUT_GROUP "About" +#define EMAILIFY(string) (g_strdelimit ((string), "%", '@')) + /** * gpm_tray_icon_show_about_cb: * @action: A valid GtkAction @@ -172,13 +175,30 @@ gpm_tray_icon_show_preferences_cb (GtkMenuItem *item, gpointer data) static void gpm_tray_icon_show_about_cb (GtkMenuItem *item, gpointer data) { - const gchar *authors[] = - { - "Perberos", - "Steve Zesch", - "Stefano Karapetsas", - NULL - }; + GKeyFile *key_file; + GBytes *bytes; + const guint8 *data_resource; + gsize data_resource_len; + GError *error = NULL; + char **authors; + gsize n_authors = 0, i; + + bytes = g_resources_lookup_data ("/org/mate/powermanager/manager/mate-power-manager.about", + G_RESOURCE_LOOKUP_FLAGS_NONE, &error); + g_assert_no_error (error); + + data_resource = g_bytes_get_data (bytes, &data_resource_len); + key_file = g_key_file_new (); + g_key_file_load_from_data (key_file, (const char *) data_resource, data_resource_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]); gtk_show_about_dialog (NULL, "program-name", _("Power Manager"), @@ -195,6 +215,8 @@ gpm_tray_icon_show_about_cb (GtkMenuItem *item, gpointer data) "logo-icon-name", "mate-power-manager", "website", "https://mate-desktop.org", NULL); + + g_strfreev (authors); } /** -- cgit v1.2.1