[gnome-control-center/T20771: 36/44] info: allow defining vendor specific logos
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/T20771: 36/44] info: allow defining vendor specific logos
- Date: Tue, 23 Jan 2018 21:09:36 +0000 (UTC)
commit ad3a671f5f822a4edcd919df2e240cf1d50f8793
Author: Mario Sanchez Prada <mario endlessm com>
Date: Thu Mar 9 05:59:06 2017 +0000
info: allow defining vendor specific logos
If a configuration file in /var/lib/gnome-control-center/vendor.conf
is found, it defines the path to a branding-specific logo and such a
file exists in disk, then gnome-control-center will use that one to
override the default logo in the "info" panel.
https://phabricator.endlessm.com/T15836
configure.ac | 11 ++++++
panels/info/Makefile.am | 1 +
panels/info/cc-info-overview-panel.c | 60 ++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2f30640..ecd8de4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,6 +49,17 @@ if test x$enable_documentation = xyes; then
fi
AM_CONDITIONAL(BUILD_DOCUMENTATION, test x$enable_documentation = xyes)
+AC_ARG_WITH(vendor-conf-file,
+ AS_HELP_STRING([--with-vendor-conf-file=<file>],
+ [vendor conf file]))
+
+if ! test -z "$with_vendor_conf_file"; then
+ VENDOR_CONF_FILE=$with_vendor_conf_file
+else
+ VENDOR_CONF_FILE=${localstatedir}/lib/gnome-control-center/vendor.conf
+fi
+AC_SUBST(VENDOR_CONF_FILE)
+
dnl Region panel
savecppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $X_CFLAGS"
diff --git a/panels/info/Makefile.am b/panels/info/Makefile.am
index a8c7d47..a790459 100644
--- a/panels/info/Makefile.am
+++ b/panels/info/Makefile.am
@@ -5,6 +5,7 @@ cappletname = info
AM_CPPFLAGS = \
$(PANEL_CFLAGS) \
$(INFO_PANEL_CFLAGS) \
+ -DVENDOR_CONF_FILE="\"$(VENDOR_CONF_FILE)\"" \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DDATADIR="\"$(datadir)\"" \
-DGNOME_SESSION_DIR="\"$(gnome_session_libexecdir)\"" \
diff --git a/panels/info/cc-info-overview-panel.c b/panels/info/cc-info-overview-panel.c
index c1ddfc1..09d66f8 100644
--- a/panels/info/cc-info-overview-panel.c
+++ b/panels/info/cc-info-overview-panel.c
@@ -48,6 +48,9 @@
#include "cc-info-overview-panel.h"
+#define VENDOR_INFO_GROUP "Info"
+#define VENDOR_INFO_LOGO_KEY "logo"
+
typedef enum {
EOS_UPDATER_STATE_NONE = 0,
EOS_UPDATER_STATE_READY,
@@ -133,6 +136,61 @@ typedef struct
G_DEFINE_TYPE_WITH_PRIVATE (CcInfoOverviewPanel, cc_info_overview_panel, CC_TYPE_PANEL)
+static gchar *
+read_vendor_logo_path (void)
+{
+ g_autoptr(GKeyFile) keyfile = NULL;
+ g_autoptr(GError) error = NULL;
+ gchar *result = NULL;
+
+ /* VENDOR_CONF_FILE points to a keyfile containing vendor customization
+ * options. This panel will look for options under the "Info" group, and
+ * supports the following keys:
+ * - logo (required): absolute path to the file with a logo for the vendor.
+ *
+ * This is how this file would look on a vendor image:
+ *
+ * [Info]
+ * logo=/path/to/the/image/with/the/logo.png
+ */
+ keyfile = g_key_file_new ();
+ if (!g_key_file_load_from_file (keyfile, VENDOR_CONF_FILE, G_KEY_FILE_NONE, &error))
+ {
+ if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
+ g_warning ("Could not read file %s: %s", VENDOR_CONF_FILE, error->message);
+
+ return NULL;
+ }
+
+ result = g_key_file_get_string (keyfile, VENDOR_INFO_GROUP, VENDOR_INFO_LOGO_KEY, &error);
+ if (!result)
+ {
+ g_warning ("Could not read logo path from %s: %s", VENDOR_CONF_FILE, error->message);
+ return NULL;
+ }
+
+ return result;
+}
+
+static void
+update_vendor_specific_info (CcInfoOverviewPanel *self)
+{
+ CcInfoOverviewPanelPrivate *priv = cc_info_overview_panel_get_instance_private (self);
+ g_autofree gchar *vendor_logo_path = NULL;
+
+ vendor_logo_path = read_vendor_logo_path ();
+
+ if (!vendor_logo_path)
+ {
+ g_debug ("No vendor configuration found");
+ return;
+ }
+
+ /* Override the logo with the vendor one if it exists */
+ if (g_file_test (vendor_logo_path, G_FILE_TEST_EXISTS))
+ gtk_image_set_from_file (GTK_IMAGE (priv->system_image), vendor_logo_path);
+}
+
static gboolean
is_updater_state_spinning (EosUpdaterState state)
{
@@ -1067,6 +1125,8 @@ info_overview_panel_setup_overview (CcInfoOverviewPanel *self)
get_primary_disc_info (self);
gtk_label_set_markup (GTK_LABEL (priv->graphics_label), priv->graphics_data->hardware_string);
+
+ update_vendor_specific_info (self);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]