summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2021-02-01 17:24:48 +0100
committerBenjamin Berg <bberg@redhat.com>2021-02-01 17:24:48 +0100
commit7e5eb2ff2ff13671e70acc38defbf012fb9b5880 (patch)
treea4c4525b8751610dc47847fb19ed9a6db8a55fa4
parent3d6ad43960e315cf46e4b1bda39477346d48ad44 (diff)
downloadgnome-control-center-benzea/energy-star.tar.gz
power: Add ENERGY STAR logo based on udev informationbenzea/energy-star
For ENERGY STAR certification purposes, the ENERGY STAR logo must be shown, there are three ways to do so: * Sticker on the chassis * Show logo for 5 seconds at boot * Show logo in power settings panel The first two options are both undesirable (expensive sticker, longer boot). As such, it makes sense to add support for this in g-c-c.
-rw-r--r--panels/power/cc-power-panel.c16
-rw-r--r--panels/power/cc-power-panel.ui27
-rw-r--r--panels/power/energy-star-logo.svg2
-rw-r--r--panels/power/meson.build6
-rw-r--r--panels/power/power.gresource.xml1
5 files changed, 50 insertions, 2 deletions
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index c9c4705da..4bd9e6765 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -22,6 +22,7 @@
#include <config.h>
#include <libupower-glib/upower.h>
+#include <gudev/gudev.h>
#include <glib/gi18n.h>
#include <gnome-settings-daemon/gsd-enums.h>
#include <handy.h>
@@ -84,6 +85,7 @@ struct _CcPowerPanel
GtkBox *device_section;
GtkListBoxRow *dim_screen_row;
GtkSwitch *dim_screen_switch;
+ GtkBox *energystar_section;
GtkLabel *general_heading;
GtkListBox *general_listbox;
GtkBox *general_section;
@@ -1708,6 +1710,7 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, device_section);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, dim_screen_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, dim_screen_switch);
+ gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, energystar_section);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, general_heading);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, general_listbox);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, general_section);
@@ -1755,11 +1758,14 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
static void
cc_power_panel_init (CcPowerPanel *self)
{
+ g_autoptr(GUdevClient) udev_client = NULL;
+ g_autoptr(GUdevDevice) dmi_device = NULL;
g_autofree gchar *battery_label = NULL;
g_autofree gchar *device_label = NULL;
g_autofree gchar *power_profile_label = NULL;
g_autofree gchar *power_saving_label = NULL;
g_autofree gchar *general_label = NULL;
+ const char *energy_star_certification_info = NULL;
guint i;
g_resources_register (cc_power_get_resource ());
@@ -1837,6 +1843,16 @@ cc_power_panel_init (CcPowerPanel *self)
}
up_client_changed (self);
+ /* Check whether device is ENERGY STAR certified. */
+ udev_client = g_udev_client_new (NULL);
+ if (udev_client)
+ dmi_device = g_udev_client_query_by_sysfs_path (udev_client, "/sys/devices/virtual/dmi/id");
+ if (dmi_device)
+ energy_star_certification_info = g_udev_device_get_property (dmi_device, "ENERGY_STAR_CERTIFIED");
+ g_message("%s", energy_star_certification_info);
+ if (energy_star_certification_info)
+ gtk_widget_set_visible (GTK_WIDGET (self->energystar_section), TRUE);
+
self->focus_adjustment = gtk_scrolled_window_get_vadjustment (self->main_scroll);
gtk_container_set_focus_vadjustment (GTK_CONTAINER (self->main_box), self->focus_adjustment);
}
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index ea3cf9322..d2a873c2a 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -132,6 +132,33 @@
<property name="spacing">3</property>
<property name="hexpand">True</property>
<child>
+ <!-- NOTE: Be careful when making changes here, as we must
+ meet the ENERGY STAR requirements on how the logo is displayed.
+ The rules are not very strict though, basically:
+ - Must be at least 76 pixels x 78 pixels
+ - Must be shown in the power settings
+ - Must be one of the three standard colors
+ For details, see the ENERGY STAR specification and logo guidelines.
+ -->
+ <object class="GtkBox" id="energystar_section">
+ <property name="visible">False</property>
+ <property name="orientation">vertical</property>
+ <property name="margin_bottom">32</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="resource">/org/gnome/control-center/power/energy-star-logo.svg</property>
+ <property name="tooltip-text" translatable="yes" comments="Translators: The registered trademark is capitalised ENERGY STAR.">This device is ENERGY STAR Certified.</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
<object class="GtkBox" id="battery_section">
<property name="visible">True</property>
<property name="orientation">vertical</property>
diff --git a/panels/power/energy-star-logo.svg b/panels/power/energy-star-logo.svg
new file mode 100644
index 000000000..503be8a5d
--- /dev/null
+++ b/panels/power/energy-star-logo.svg
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" height="254.6" viewBox="0 0 248.87321 254.60156" width="248.87" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"><g transform="matrix(1.25 0 0 -1.25 -436.92 714.77)"><g transform="matrix(3.5 0 0 3.5 -1120 -1172.2)"><path d="m0.94336 0.92188v55.492h70.535v-55.492h-70.535zm0.001953 55.494v15.023 1.6543h1.6523 67.225 1.6543 0.002v-16.678h-1.6562v15.023h-67.225v-15.023h-1.6523z" transform="matrix(.8 0 0 -.8 419.32 498.78)" fill="#fff"/><path d="m2.5996 2.5781v23.447c7.5284-10.43 19.787-17.234 33.607-17.234 13.822 0 26.082 6.8066 33.617 17.244v-23.457h-67.225zm33.607 7.8691c-13.995 0-26.351 7.1522-33.607 17.992v26.318h67.225v-26.309c-7.257-10.844-19.618-18.001-33.618-18.001zm-33.609 45.969v15.023h67.225v-15.023h-67.225z" transform="matrix(.8 0 0 -.8 419.32 498.78)" fill="#20bbed"/><path d="m55.123 20.129c-0.32875 0-0.61898 0.19766-0.74024 0.50391 0 0-2.9104 7.4639-3.2441 8.3164-0.91375 0.05-8.873 0.46875-8.873 0.46875-0.42125 0.0225-0.75195 0.37422-0.75195 0.79297 0 0.0125 0.002 0.02797 0.002 0.04297 0.0225 0.43625 0.39664 0.77125 0.83789 0.75l9.3809-0.49609c0.30875-0.015 0.58547-0.21391 0.69922-0.50391 0 0 1.777-4.5647 2.6895-6.8984 0.90625 2.33 2.6758 6.8711 2.6758 6.8711 0.1125 0.29 0.38391 0.48516 0.69141 0.50391 0 0 4.8441 0.27617 7.3203 0.41992-1.91 1.585-5.6543 4.6992-5.6543 4.6992-0.18625 0.1525-0.28906 0.37562-0.28906 0.60938 0 0.0675 0.0072 0.13227 0.02344 0.19727 0 0 1.2035 4.6987 1.8223 7.1074-2.085-1.3438-6.1484-3.9648-6.1484-3.9648-0.25875-0.16875-0.59617-0.16961-0.85742-0.0059 0 0-4.1069 2.6175-6.2344 3.9688 0.64875-2.34 1.8145-6.5527 1.8145-6.5527 0.015-0.06875 0.02734-0.14219 0.02734-0.21094 0-0.34875-0.23023-0.66492-0.58398-0.76367-0.42125-0.11625-0.86156 0.13094-0.97656 0.55469l-2.3594 8.541c-0.0875 0.31375 0.02727 0.65266 0.29102 0.84766 0.265 0.195 0.62289 0.205 0.90039 0.03125 0 0 6.7749-4.3127 7.5449-4.8027 0.7625 0.49375 7.4238 4.7891 7.4238 4.7891 0.27625 0.1775 0.62703 0.16852 0.89453-0.02148 0.20875-0.1525 0.33203-0.39133 0.33203-0.64258 0-0.065-0.01109-0.13477-0.02734-0.19727 0 0-1.978-7.7147-2.1992-8.5859 0.68875-0.57375 6.8184-5.6641 6.8184-5.6641 0.18375-0.15375 0.28711-0.38008 0.28711-0.61133 0-0.085-0.01351-0.16484-0.04102-0.24609-0.1-0.31-0.38203-0.52617-0.70703-0.54492 0 0-7.9091-0.45406-8.8203-0.50781-0.33375-0.84875-3.2305-8.291-3.2305-8.291-0.1175-0.305-0.41328-0.50391-0.73828-0.50391zm-38.818 10.762c-1.6738-0.07625-4.5115 2.1074-7.084 7.1699-0.14125 0.2775-0.24508 0.53516-0.33008 0.78516-2.7025 0.8075-4.5011 0.08836-4.6211 0.03711-0.26875-0.1125-0.58086 0.0125-0.69336 0.28125-0.1175 0.27 0.00609 0.57836 0.27734 0.69336 0.1275 0.0575 1.9987 0.82219 4.7949 0.14844-0.00125 0.035-0.00781 0.07437-0.00781 0.10938 0 0.78625 0.33188 1.3223 0.76562 1.6035 1.2137 0.79125 3.8862 0.11695 7.7637-3.8418-0.25125 0.715-0.47539 1.4973-0.61914 2.3086-0.0063 0.035-0.0078 0.07102-0.0078 0.10352 0 0.2225 0.12914 0.42336 0.33789 0.50586 0.41875 0.17125 0.65984-0.17672 0.87109-0.48047l0.53711-0.80273c0.46625-0.7 1.5127-2.2746 2.2227-3.0996-0.08625 0.45375-0.17383 0.96352-0.17383 1.4473 0 0.655 0.15945 1.2545 0.68945 1.5645 0.44375 0.2575 1.1541 0.34844 2.6953-0.57031 0.13 0.35625 0.39102 0.52445 0.54102 0.5957 0.98375 0.45625 2.8391-0.52961 4.7754-2.3809-0.26125 0.58625-0.46242 1.0736-0.51367 1.2773-0.0125 0.05625-0.01758 0.11141-0.01758 0.16016 0 0.24625 0.14781 0.4225 0.32031 0.5 0.425 0.1875 0.69641-0.18453 0.91016-0.48828l0.58398-0.84375c0.48375-0.715 1.6221-2.3909 2.2871-3.0859 0.19625 0.48125 0.54844 1.0916 1.1797 1.4453-0.18375 0.415-0.27539 0.77227-0.27539 1.0723 0 0.37 0.13852 0.65109 0.41602 0.83984 0.4975 0.3375 1.2535 0.15141 2.041-0.27734-2.515 2.495-3.6708 4.9822-3.707 6.0859-0.0012 0.02-0.002 0.0425-0.002 0.0625 0 0.615 0.30203 0.86258 0.48828 0.95508 0.3825 0.19125 0.84867 0.07133 1.3887-0.35742 1.895-1.5037 3.2748-5.0728 3.9785-7.2578 0.945-0.77 2.051-1.5201 3.3223-2.2051-0.4125 0.72375-0.64648 1.4072-0.64648 1.9609 0 0.2 0.03039 0.38562 0.08789 0.54688 0.14625 0.3875 0.45867 0.63383 0.85742 0.67383 0.87375 0.09625 2.0809-0.81938 3.5059-2.5781-0.12125 0.35-0.24133 0.69094-0.36133 1.0234-3.9575 3.1188-5.7373 6.451-5.9648 8.2598-0.02 0.1475-0.03125 0.28516-0.03125 0.41016 0 0.72125 0.29109 1.0538 0.55859 1.2051 0.30125 0.17125 0.81195 0.25469 1.5645-0.32031 0.8375-0.64 2.8338-3.7688 4.7676-8.9238 2.5675-1.9725 6.0856-3.8586 10.766-5.1523 0.235-0.06625 0.39258-0.27867 0.39258-0.51367 0-0.045-0.009-0.09367-0.02148-0.13867-0.07875-0.28375-0.37125-0.44859-0.65625-0.37109-4.0875 1.1325-7.3248 2.7166-9.8535 4.4316 0.30125-0.895 0.60133-1.8409 0.89258-2.8359 0.01375-0.05 0.01953-0.09844 0.01953-0.14844 0-0.20375-0.11805-0.39617-0.31055-0.48242-0.24125-0.10875-0.52602-0.02398-0.66602 0.19726-2.6375 4.1412-4.1309 4.8949-4.4609 4.8887-0.01875-0.03625-0.03125-0.08711-0.03125-0.16211 0-0.4725 0.40274-1.6514 1.709-3.0352 0.0925-0.1 0.14648-0.23078 0.14648-0.36328 0-0.105-0.03516-0.21148-0.09766-0.30274-0.145-0.20375-0.41258-0.28375-0.64258-0.1875-1.665 0.705-3.1002 1.5388-4.3477 2.4238 0.01375-0.05125 0.02359-0.08922 0.02734-0.10547 0.0087-0.045 0.01953-0.08641 0.01953-0.12891 0-0.19375-0.11156-0.3775-0.28906-0.46875-0.01125-0.0038-0.01734-0.0041-0.02734-0.0078 0.365-0.2875 0.73977-0.6018 1.1348-0.9668 0.41625-0.3875 0.52344-0.74 0.52344-1 0-0.115-0.02188-0.2082-0.04687-0.2832-0.12125-0.375-0.46836-0.62024-0.94336-0.67774-1.1712-0.13625-3.027 0.85453-4.6895 3.3008-0.56625-0.30375-0.78812-1.0421-0.89062-1.3809l-0.04102-0.13672c-0.06875-0.2225-0.27211-0.36062-0.50586-0.35937-0.35875 0.0037-0.74391 0.25094-1.3477 0.96094 0.0088-0.01625 0.01539-0.03508 0.02539-0.04883 0.035-0.07375 0.05078-0.15102 0.05078-0.22852 0-0.18125-0.09336-0.35633-0.25586-0.45508-0.235-0.14125-0.53602-0.08078-0.69727 0.13672-2.955 3.9788-5.5423 5.0841-5.9473 4.8828-0.0025-0.0125-0.01172-0.04062-0.01172-0.10938 0-0.045 0.0077-0.11 0.02148-0.1875 0.66-0.4725 1.4408-1.0901 2.3633-1.8926 0.85625-0.7425 1.0527-1.344 1.0527-1.7402 0-0.18125-0.04258-0.3175-0.08008-0.40625-0.175-0.41-0.59742-0.6368-1.1074-0.5918-1.0962 0.09375-2.4662 1.377-3.1562 3.9883-1.7125 1.1688-2.1738 0.99133-2.2363 0.95508-0.2325-0.13375-0.21422-0.86648 0.05078-2.1777 0.11625-0.58125 0.16906-0.84734 0.03906-1.0898-0.1275-0.2375-0.34867-0.37812-0.60742-0.39062-0.5575-0.02625-1.188 0.5557-2.498 2.4082 0.51875-1.2338 1.0252-2.0812 1.0352-2.0938 0.0525-0.08625 0.07813-0.18164 0.07813-0.27539 0-0.16625-0.07906-0.32984-0.22656-0.43359-0.225-0.16125-0.53609-0.11859-0.71484 0.09766-4.6588 5.6875-7.8287 6.87-8.7324 6.2812-0.19375-0.1275-0.28711-0.37312-0.28711-0.70312 0-0.13625 0.022188-0.28938 0.054687-0.45312 1.7437-0.62125 3.7615-1.8139 5.8965-4.0039 1.2612-1.2875 1.9375-2.4953 1.9375-3.4141 0-0.20625-0.03281-0.39852-0.10156-0.57226-0.1875-0.47625-0.61844-0.76617-1.1797-0.79492zm-0.04883 1.0586c0.1975 0.01 0.22594 0.0875 0.24219 0.125 0.01625 0.0475 0.0293 0.11109 0.0293 0.18359 0 0.4625-0.40297 1.4145-1.6367 2.6758-1.6512 1.6925-3.2137 2.7434-4.6074 3.3809 2.4512-4.715 4.9539-6.4127 5.9727-6.3652zm22.617 0.92383c-0.0275 0.03625-0.05773 0.07766-0.11524 0.12891-1.2175 1.1288-2.2899 1.8462-3.1387 2.125 1.3288-1.7238 2.48-2.1312 2.8438-2.2188 0.19375-0.045 0.32516-0.04641 0.41016-0.03516zm-11.801 1.7461c-0.0275 0.125-0.16219 0.43031-0.67969 0.88281-0.38625 0.33375-0.74211 0.63344-1.0684 0.89844 0.53875-1.1312 1.1527-1.5524 1.3789-1.6699 0.17375-0.09375 0.29664-0.11133 0.36914-0.11133zm9.791 1.1211c-1.0262 0.9075-1.9591 1.3269-2.2891 1.3281 0.0038-0.1 0.04766-0.33102 0.25391-0.75976 0.605 0.0225 1.2802-0.16336 2.0352-0.56836zm7.2012 2.9219c-1.6238 3.8962-3.1437 6.2003-3.7012 6.6328-0.1825 0.13625-0.30945 0.1968-0.37695 0.2168-0.02-0.0475-0.03711-0.12758-0.03711-0.26758 0-0.24375 0.05445-0.63336 0.25195-1.1934 0.48625-1.3888 1.7045-3.3649 3.8633-5.3887zm-7.6113 0.01172c-0.72125 1.855-1.7434 3.9352-2.9746 4.9102-0.06 0.04875-0.11055 0.08523-0.1543 0.11524 0.055-0.76625 0.99266-2.8241 3.1289-5.0254zm-3.6602 20.875c-1.7812 0-2.6445 1.0718-2.6445 2.748v2.7598c0 2.3288 0.86328 3.25 2.6445 3.25 1.0838 0 1.888-0.25445 2.5742-0.62695v-4.0898h-2.6211v0.93164h1.5508v2.5156c-0.2225 0.1625-0.73516 0.37305-1.5039 0.37305-1.0125 0-1.5488-0.46664-1.5488-2.3066v-2.8398c0-1.76 1.2113-1.8184 1.5488-1.8184 1.0838 0 1.4922 0.53609 1.4922 1.5273h1.1172c0.07125-1.7588-0.79188-2.4238-2.6094-2.4238zm14.018 0c-1.4112 0-2.4707 0.7932-2.4707 2.2832 0 2.5288 3.7734 2.3159 3.7734 4.1797 0 1.0012-0.65195 1.3633-1.502 1.3633-0.68625 0-1.4102-0.36141-1.4102-1.5039v-0.24414h-1.0586c-0.02375 0.80375-0.02492 2.7029 2.4551 2.6816 1.3875 0 2.6113-0.57375 2.6113-2.3438 0-2.665-3.7734-2.3988-3.7734-4.25 0-0.90875 0.65172-1.2344 1.293-1.2344 1.0125 0 1.3023 0.60609 1.291 1.5273h1.1172c0.0725-1.7125-0.78992-2.459-2.3262-2.459zm-41.313 0.17383v8.4082h4.4004v-0.93164h-3.3301v-2.9102h3.0273v-0.93164h-3.0273v-2.7012h3.2598v-0.93359h-4.3301zm5.7422 0v8.4082h0.95508v-7.2891h0.02344l3.3184 7.2891h1.4688v-8.4082h-0.95508v7.1992h-0.02344l-3.2734-7.1992h-1.5137zm7.25 0v8.4082h4.4023v-0.93164h-3.3301v-2.9102h3.0293v-0.93164h-3.0293v-2.7012h3.2617v-0.93359h-4.334zm5.6934 0v8.4082h1.0703v-3.8652h1.2578c0.3625 0 1.1863 0.04727 1.2676 1.0723 0.09375 1.1175 0.02437 2.213 0.32812 2.793h1.1172c-0.16375-0.52125-0.27976-1.8392-0.29102-2.1992-0.0575-1.69-0.40555-2.0155-1.373-2.168v-0.02344c0.98875-0.17375 1.5352-0.92992 1.5352-1.9199 0-1.0487-0.52242-2.0977-2.0137-2.0977h-2.8984zm11.775 0 2.2598 5.2051v3.2031h1.0703v-3.2031l2.293-5.2051h-1.082l-1.6992 4.0645-1.6426-4.0645h-1.1992zm13.732 0v0.93359h2.2129v7.4746h1.0703v-7.4746h2.2129v-0.93359h-5.4961zm12.197 0v8.4082h1.0723v-3.8652h1.2578c0.36125 0 1.187 0.04727 1.2695 1.0723 0.0925 1.1175 0.02242 2.213 0.32617 2.793h1.1172c-0.1625-0.52125-0.27781-1.8392-0.28906-2.1992-0.05875-1.69-0.40875-2.0155-1.375-2.168v-0.02344c0.9875-0.17375 1.5352-0.92992 1.5352-1.9199 0-1.0487-0.52367-2.0977-2.0137-2.0977h-2.9004zm-4.9238 0.002-2.666 8.4062h1.082l0.62891-2.0039h3.25l0.60352 2.0039h1.2012l-2.7363-8.4062h-1.3633zm-31.711 0.93164h1.6191c0.825 0 1.1289 0.6743 1.1289 1.2793 0 0.735-0.37258 1.3984-1.1426 1.3984h-1.6055v-2.6777zm37.707 0h1.6191c0.82625 0 1.1289 0.6743 1.1289 1.2793 0 0.735-0.37312 1.3984-1.1406 1.3984h-1.6074v-2.6777zm-5.3691 0.05859h0.02539l1.3496 4.4824h-2.6895l1.3145-4.4824z" transform="matrix(.8 0 0 -.8 419.32 498.78)" fill="#fff"/></g></g></svg>
diff --git a/panels/power/meson.build b/panels/power/meson.build
index 625059dd2..e509ae206 100644
--- a/panels/power/meson.build
+++ b/panels/power/meson.build
@@ -30,7 +30,8 @@ sources += gnome.mkenums_simple(
resource_data = files(
'cc-battery-row.ui',
- 'cc-power-panel.ui'
+ 'cc-power-panel.ui',
+ 'energy-star-logo.svg'
)
sources += gnome.compile_resources(
@@ -43,7 +44,8 @@ sources += gnome.compile_resources(
deps = common_deps + [
gnome_settings_dep,
- upower_glib_dep
+ upower_glib_dep,
+ gudev_dep
]
if host_is_linux
diff --git a/panels/power/power.gresource.xml b/panels/power/power.gresource.xml
index 31e92b415..01bfc3370 100644
--- a/panels/power/power.gresource.xml
+++ b/panels/power/power.gresource.xml
@@ -6,5 +6,6 @@
<file preprocess="xml-stripblanks">cc-power-profile-row.ui</file>
<file>battery-levels.css</file>
<file>power-profiles.css</file>
+ <file>energy-star-logo.svg</file>
</gresource>
</gresources>