power: Port to GTK4

Extra care was needed for the combo boxes, and the way we currently
use GtkStringList is kind of hacky, but overall things seem to be
working fine.
This commit is contained in:
Georges Basile Stavracas Neto 2021-10-20 23:07:53 -03:00
parent 800cab08bf
commit a0d49cb3a8
10 changed files with 206 additions and 307 deletions

View file

@ -18,7 +18,7 @@ panels = [
# 'multitasking', # 'multitasking',
'notifications', 'notifications',
# 'online-accounts', # 'online-accounts',
# 'power', 'power',
# 'printers', # 'printers',
# 'region', # 'region',
'removable-media', 'removable-media',

View file

@ -276,7 +276,7 @@ cc_battery_row_new (UpDevice *device,
/* Icon */ /* Icon */
if (is_kind_battery && icon_name != NULL && icon_name[0] != '\0') if (is_kind_battery && icon_name != NULL && icon_name[0] != '\0')
{ {
gtk_image_set_from_icon_name (self->icon, icon_name, GTK_ICON_SIZE_BUTTON); gtk_image_set_from_icon_name (self->icon, icon_name);
gtk_widget_show (GTK_WIDGET (self->icon)); gtk_widget_show (GTK_WIDGET (self->icon));
} }
else else
@ -301,10 +301,12 @@ cc_battery_row_new (UpDevice *device,
gtk_widget_set_visible (GTK_WIDGET (self->battery_box), !primary); gtk_widget_set_visible (GTK_WIDGET (self->battery_box), !primary);
gtk_widget_set_visible (GTK_WIDGET (self->percentage_label), !primary); gtk_widget_set_visible (GTK_WIDGET (self->percentage_label), !primary);
gtk_widget_set_visible (GTK_WIDGET (self->primary_bottom_box), primary); gtk_widget_set_visible (GTK_WIDGET (self->primary_bottom_box), primary);
atk_object_add_relationship (gtk_widget_get_accessible (GTK_WIDGET (self->levelbar)), /*
ATK_RELATION_LABELLED_BY, gtk_accessible_update_relation (GTK_ACCESSIBLE (self->levelbar),
gtk_widget_get_accessible (GTK_WIDGET (primary ? self->primary_percentage_label GTK_ACCESSIBLE_RELATION_LABELLED_BY, primary ? self->primary_percentage_label
: self->percentage_label))); : self->percentage_label,
NULL);
*/
self->kind = kind; self->kind = kind;
self->primary = primary; self->primary = primary;

View file

@ -2,12 +2,10 @@
<interface> <interface>
<!-- interface-requires gtk+ 3.0 --> <!-- interface-requires gtk+ 3.0 -->
<template class="CcBatteryRow" parent="GtkListBoxRow"> <template class="CcBatteryRow" parent="GtkListBoxRow">
<property name="visible">True</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="activatable">False</property> <property name="activatable">False</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="margin-start">12</property> <property name="margin-start">12</property>
@ -17,48 +15,39 @@
<property name="spacing">10</property> <property name="spacing">10</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property> <property name="orientation">horizontal</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<child> <child>
<object class="GtkBox" id="battery_box"> <object class="GtkBox" id="battery_box">
<property name="visible">True</property>
<property name="orientation">horizontal</property> <property name="orientation">horizontal</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<child> <child>
<object class="GtkLabel" id="name_label"> <object class="GtkLabel" id="name_label">
<property name="visible">True</property>
<property name="ellipsize">end</property> <property name="ellipsize">end</property>
<property name="xalign">0</property> <property name="xalign">0</property>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkImage" id="icon"> <object class="GtkImage" id="icon">
<property name="visible">True</property>
<property name="halign">end</property> <property name="halign">end</property>
<property name="valign">center</property> <property name="valign">center</property>
<style> <style>
<class name="dim-label"/> <class name="dim-label"/>
</style> </style>
</object> </object>
<packing>
<property name="pack-type">end</property>
</packing>
</child> </child>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkLabel" id="percentage_label"> <object class="GtkLabel" id="percentage_label">
<property name="visible">True</property> <property name="halign">end</property>
<property name="halign">end</property> <style>
<style> <class name="dim-label"/>
<class name="dim-label"/> </style>
</style>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkLevelBar" id="levelbar"> <object class="GtkLevelBar" id="levelbar">
<property name="visible">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="halign">fill</property> <property name="halign">fill</property>
<property name="valign">center</property> <property name="valign">center</property>
@ -68,30 +57,21 @@
<offset name="high-battery-offset" value="1.0"/> <offset name="high-battery-offset" value="1.0"/>
</offsets> </offsets>
</object> </object>
<packing>
<property name="expand">True</property>
</packing>
</child> </child>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkBox" id="primary_bottom_box"> <object class="GtkBox" id="primary_bottom_box">
<property name="visible">True</property>
<property name="orientation">horizontal</property> <property name="orientation">horizontal</property>
<child> <child>
<object class="GtkLabel" id="details_label"> <object class="GtkLabel" id="details_label">
<property name="visible">True</property> <property name="hexpand">True</property>
<property name="ellipsize">end</property> <property name="ellipsize">end</property>
<property name="xalign">0</property> <property name="xalign">0</property>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkLabel" id="primary_percentage_label"> <object class="GtkLabel" id="primary_percentage_label" />
<property name="visible">True</property>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child> </child>
</object> </object>
</child> </child>

View file

@ -25,10 +25,8 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <gnome-settings-daemon/gsd-enums.h> #include <gnome-settings-daemon/gsd-enums.h>
#include <gio/gdesktopappinfo.h> #include <gio/gdesktopappinfo.h>
#include <handy.h>
#include "shell/cc-object-storage.h" #include "shell/cc-object-storage.h"
#include "list-box-helper.h"
#include "cc-battery-row.h" #include "cc-battery-row.h"
#include "cc-power-profile-row.h" #include "cc-power-profile-row.h"
#include "cc-power-profile-info-row.h" #include "cc-power-profile-info-row.h"
@ -64,22 +62,22 @@ struct _CcPowerPanel
GtkLabel *automatic_suspend_label; GtkLabel *automatic_suspend_label;
GtkListBoxRow *automatic_suspend_row; GtkListBoxRow *automatic_suspend_row;
GtkListBox *battery_listbox; GtkListBox *battery_listbox;
HdyActionRow *battery_percentage_row; AdwActionRow *battery_percentage_row;
GtkSwitch *battery_percentage_switch; GtkSwitch *battery_percentage_switch;
GtkSizeGroup *battery_row_sizegroup; GtkSizeGroup *battery_row_sizegroup;
HdyPreferencesGroup *battery_section; AdwPreferencesGroup *battery_section;
HdyComboRow *blank_screen_row; AdwComboRow *blank_screen_row;
GtkListBox *device_listbox; GtkListBox *device_listbox;
HdyPreferencesGroup *device_section; AdwPreferencesGroup *device_section;
GtkListBoxRow *dim_screen_row; GtkListBoxRow *dim_screen_row;
GtkSwitch *dim_screen_switch; GtkSwitch *dim_screen_switch;
HdyPreferencesGroup *general_section; AdwPreferencesGroup *general_section;
GtkSizeGroup *level_sizegroup; GtkSizeGroup *level_sizegroup;
HdyComboRow *power_button_row; AdwComboRow *power_button_row;
GtkListBox *power_profile_listbox; GtkListBox *power_profile_listbox;
GtkListBox *power_profile_info_listbox; GtkListBox *power_profile_info_listbox;
HdyPreferencesGroup *power_profile_section; AdwPreferencesGroup *power_profile_section;
HdyActionRow *power_saver_low_battery_row; AdwActionRow *power_saver_low_battery_row;
GtkSwitch *power_saver_low_battery_switch; GtkSwitch *power_saver_low_battery_switch;
GtkSizeGroup *row_sizegroup; GtkSizeGroup *row_sizegroup;
GtkComboBox *suspend_on_battery_delay_combo; GtkComboBox *suspend_on_battery_delay_combo;
@ -117,27 +115,6 @@ enum
ACTION_MODEL_VALUE ACTION_MODEL_VALUE
}; };
static void
cc_power_panel_dispose (GObject *object)
{
CcPowerPanel *self = CC_POWER_PANEL (object);
g_clear_pointer (&self->chassis_type, g_free);
g_clear_object (&self->gsd_settings);
g_clear_object (&self->session_settings);
g_clear_object (&self->interface_settings);
g_clear_pointer ((GtkWidget **) &self->automatic_suspend_dialog, gtk_widget_destroy);
g_clear_pointer (&self->devices, g_ptr_array_unref);
g_clear_object (&self->up_client);
g_clear_object (&self->iio_proxy);
g_clear_object (&self->power_profiles_proxy);
if (self->iio_proxy_watch_id != 0)
g_bus_unwatch_name (self->iio_proxy_watch_id);
self->iio_proxy_watch_id = 0;
G_OBJECT_CLASS (cc_power_panel_parent_class)->dispose (object);
}
static const char * static const char *
cc_power_panel_get_help_uri (CcPanel *panel) cc_power_panel_get_help_uri (CcPanel *panel)
{ {
@ -195,9 +172,9 @@ load_custom_css (CcPowerPanel *self,
/* use custom CSS */ /* use custom CSS */
provider = gtk_css_provider_new (); provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, path); gtk_css_provider_load_from_resource (provider, path);
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
} }
static void static void
@ -207,7 +184,7 @@ add_battery (CcPowerPanel *panel, UpDevice *device, gboolean primary)
cc_battery_row_set_level_sizegroup (row, panel->level_sizegroup); cc_battery_row_set_level_sizegroup (row, panel->level_sizegroup);
cc_battery_row_set_row_sizegroup (row, panel->battery_row_sizegroup); cc_battery_row_set_row_sizegroup (row, panel->battery_row_sizegroup);
gtk_container_add (GTK_CONTAINER (panel->battery_listbox), GTK_WIDGET (row)); gtk_list_box_append (panel->battery_listbox, GTK_WIDGET (row));
gtk_widget_set_visible (GTK_WIDGET (panel->battery_section), TRUE); gtk_widget_set_visible (GTK_WIDGET (panel->battery_section), TRUE);
} }
@ -218,19 +195,17 @@ add_device (CcPowerPanel *self, UpDevice *device)
cc_battery_row_set_level_sizegroup (row, self->level_sizegroup); cc_battery_row_set_level_sizegroup (row, self->level_sizegroup);
cc_battery_row_set_row_sizegroup (row, self->row_sizegroup); cc_battery_row_set_row_sizegroup (row, self->row_sizegroup);
gtk_container_add (GTK_CONTAINER (self->device_listbox), GTK_WIDGET (row)); gtk_list_box_append (self->device_listbox, GTK_WIDGET (row));
gtk_widget_set_visible (GTK_WIDGET (self->device_section), TRUE); gtk_widget_set_visible (GTK_WIDGET (self->device_section), TRUE);
} }
static void static void
empty_listbox (GtkListBox *listbox) empty_listbox (GtkListBox *listbox)
{ {
g_autoptr(GList) children = NULL; GtkWidget *child;
GList *l;
children = gtk_container_get_children (GTK_CONTAINER (listbox)); while ((child = gtk_widget_get_first_child (GTK_WIDGET (listbox))) != NULL)
for (l = children; l != NULL; l = l->next) gtk_list_box_remove (listbox, child);
gtk_container_remove (GTK_CONTAINER (listbox), l->data);
} }
static void static void
@ -379,9 +354,9 @@ up_client_changed (CcPowerPanel *self)
} }
if (n_batteries > 1) if (n_batteries > 1)
hdy_preferences_group_set_title (self->battery_section, _("Batteries")); adw_preferences_group_set_title (self->battery_section, _("Batteries"));
else else
hdy_preferences_group_set_title (self->battery_section, _("Battery")); adw_preferences_group_set_title (self->battery_section, _("Battery"));
if (!on_ups && n_batteries > 1) if (!on_ups && n_batteries > 1)
add_battery (self, composite, TRUE); add_battery (self, composite, TRUE);
@ -556,25 +531,25 @@ set_value_for_combo (GtkComboBox *combo_box, gint value)
} }
static void static void
set_value_for_combo_row (HdyComboRow *combo_row, gint value) set_value_for_combo_row (AdwComboRow *combo_row, gint value)
{ {
g_autoptr (GObject) new_item = NULL;
gboolean insert = FALSE; gboolean insert = FALSE;
guint insert_before = 0; guint insert_before = 0;
guint i; guint i;
HdyValueObject *new;
GListModel *model; GListModel *model;
gint value_last = 0; gint value_last = 0;
g_autofree gchar *text = NULL; g_autofree gchar *text = NULL;
/* try to make the UI match the setting */ /* try to make the UI match the setting */
model = hdy_combo_row_get_model (combo_row); model = adw_combo_row_get_model (combo_row);
for (i = 0; i < g_list_model_get_n_items (model); i++) for (i = 0; i < g_list_model_get_n_items (model); i++)
{ {
HdyValueObject *value_object = g_list_model_get_item (model, i); g_autoptr (GObject) item = g_list_model_get_item (model, i);
gint value_tmp = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (value_object), "value")); gint value_tmp = GPOINTER_TO_UINT (g_object_get_data (item, "value"));
if (value_tmp == value) if (value_tmp == value)
{ {
hdy_combo_row_set_selected_index (combo_row, i); adw_combo_row_set_selected (combo_row, i);
return; return;
} }
@ -591,11 +566,12 @@ set_value_for_combo_row (HdyComboRow *combo_row, gint value)
/* The value is not listed, so add it at the best point (or the end). */ /* The value is not listed, so add it at the best point (or the end). */
text = cc_util_time_to_string_text (value * 1000); text = cc_util_time_to_string_text (value * 1000);
new = hdy_value_object_new_string (text); gtk_string_list_append (GTK_STRING_LIST (model), text);
g_object_set_data (G_OBJECT (new), "value",
GUINT_TO_POINTER (value)); new_item = g_list_model_get_item (model, i);
g_list_store_insert (G_LIST_STORE (model), insert_before, new); g_object_set_data (G_OBJECT (new_item), "value", GUINT_TO_POINTER (value));
hdy_combo_row_set_selected_index (combo_row, insert_before);
adw_combo_row_set_selected (combo_row, insert_before);
} }
static void static void
@ -659,15 +635,18 @@ keynav_failed_cb (CcPowerPanel *self, GtkDirectionType direction, GtkWidget *lis
static void static void
blank_screen_row_changed_cb (CcPowerPanel *self) blank_screen_row_changed_cb (CcPowerPanel *self)
{ {
g_autoptr (GObject) item = NULL;
GListModel *model; GListModel *model;
gint selected_index; gint selected_index;
HdyValueObject *value_object;
gint value; gint value;
model = hdy_combo_row_get_model (self->blank_screen_row); model = adw_combo_row_get_model (self->blank_screen_row);
selected_index = hdy_combo_row_get_selected_index (self->blank_screen_row); selected_index = adw_combo_row_get_selected (self->blank_screen_row);
value_object = g_list_model_get_item (model, selected_index); if (selected_index == -1)
value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (value_object), "value")); return;
item = g_list_model_get_item (model, selected_index);
value = GPOINTER_TO_UINT (g_object_get_data (item, "value"));
g_settings_set_uint (self->session_settings, "idle-delay", value); g_settings_set_uint (self->session_settings, "idle-delay", value);
} }
@ -675,15 +654,18 @@ blank_screen_row_changed_cb (CcPowerPanel *self)
static void static void
power_button_row_changed_cb (CcPowerPanel *self) power_button_row_changed_cb (CcPowerPanel *self)
{ {
g_autoptr (GObject) item = NULL;
GListModel *model; GListModel *model;
gint selected_index; gint selected_index;
HdyValueObject *value_object;
gint value; gint value;
model = hdy_combo_row_get_model (self->power_button_row); model = adw_combo_row_get_model (self->power_button_row);
selected_index = hdy_combo_row_get_selected_index (self->power_button_row); selected_index = adw_combo_row_get_selected (self->power_button_row);
value_object = g_list_model_get_item (model, selected_index); if (selected_index == -1)
value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (value_object), "value")); return;
item = g_list_model_get_item (model, selected_index);
value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (item), "value"));
g_settings_set_enum (self->gsd_settings, "power-button-action", value); g_settings_set_enum (self->gsd_settings, "power-button-action", value);
} }
@ -737,8 +719,10 @@ static void
automatic_suspend_row_activated_cb (CcPowerPanel *self) automatic_suspend_row_activated_cb (CcPowerPanel *self)
{ {
GtkWidget *toplevel; GtkWidget *toplevel;
CcShell *shell;
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self)); shell = cc_panel_get_shell (CC_PANEL (self));
toplevel = cc_shell_get_toplevel (shell);
gtk_window_set_transient_for (GTK_WINDOW (self->automatic_suspend_dialog), GTK_WINDOW (toplevel)); gtk_window_set_transient_for (GTK_WINDOW (self->automatic_suspend_dialog), GTK_WINDOW (toplevel));
gtk_window_set_modal (GTK_WINDOW (self->automatic_suspend_dialog), TRUE); gtk_window_set_modal (GTK_WINDOW (self->automatic_suspend_dialog), TRUE);
gtk_window_present (GTK_WINDOW (self->automatic_suspend_dialog)); gtk_window_present (GTK_WINDOW (self->automatic_suspend_dialog));
@ -784,11 +768,11 @@ set_sleep_type (const GValue *value,
} }
static void static void
populate_power_button_row (HdyComboRow *combo_row, populate_power_button_row (AdwComboRow *combo_row,
gboolean can_suspend, gboolean can_suspend,
gboolean can_hibernate) gboolean can_hibernate)
{ {
g_autoptr (GListStore) list_store = NULL; g_autoptr (GtkStringList) string_list = NULL;
struct { struct {
char *name; char *name;
GsdPowerButtonActionType value; GsdPowerButtonActionType value;
@ -798,12 +782,13 @@ populate_power_button_row (HdyComboRow *combo_row,
{ N_("Hibernate"), GSD_POWER_BUTTON_ACTION_HIBERNATE }, { N_("Hibernate"), GSD_POWER_BUTTON_ACTION_HIBERNATE },
{ N_("Nothing"), GSD_POWER_BUTTON_ACTION_NOTHING } { N_("Nothing"), GSD_POWER_BUTTON_ACTION_NOTHING }
}; };
guint item_index = 0;
guint i; guint i;
list_store = g_list_store_new (HDY_TYPE_VALUE_OBJECT); string_list = gtk_string_list_new (NULL);
for (i = 0; i < G_N_ELEMENTS (actions); i++) for (i = 0; i < G_N_ELEMENTS (actions); i++)
{ {
g_autoptr (HdyValueObject) value_object = NULL; g_autoptr (GObject) item = NULL;
if (!can_suspend && actions[i].value == GSD_POWER_BUTTON_ACTION_SUSPEND) if (!can_suspend && actions[i].value == GSD_POWER_BUTTON_ACTION_SUSPEND)
continue; continue;
@ -811,17 +796,13 @@ populate_power_button_row (HdyComboRow *combo_row,
if (!can_hibernate && actions[i].value == GSD_POWER_BUTTON_ACTION_HIBERNATE) if (!can_hibernate && actions[i].value == GSD_POWER_BUTTON_ACTION_HIBERNATE)
continue; continue;
value_object = hdy_value_object_new_string (_(actions[i].name)); gtk_string_list_append (string_list, _(actions[i].name));
g_object_set_data (G_OBJECT (value_object),
"value", item = g_list_model_get_item (G_LIST_MODEL (string_list), item_index++);
GUINT_TO_POINTER (actions[i].value)); g_object_set_data (item, "value", GUINT_TO_POINTER (actions[i].value));
g_list_store_append (list_store, value_object);
} }
hdy_combo_row_bind_name_model (combo_row, adw_combo_row_set_model (combo_row, G_LIST_MODEL (string_list));
G_LIST_MODEL (list_store),
(HdyComboRowGetNameFunc) hdy_value_object_dup_string,
NULL, NULL);
} }
#define NEVER 0 #define NEVER 0
@ -957,34 +938,32 @@ got_brightness_cb (GObject *source_object,
} }
static void static void
populate_blank_screen_row (HdyComboRow *combo_row) populate_blank_screen_row (AdwComboRow *combo_row)
{ {
g_autoptr (GListStore) list_store = g_list_store_new (HDY_TYPE_VALUE_OBJECT); g_autoptr (GtkStringList) string_list = NULL;
g_autoptr (GObject) never_object = NULL;
gint minutes[] = { 1, 2, 3, 4, 5, 8, 10, 12, 15 }; gint minutes[] = { 1, 2, 3, 4, 5, 8, 10, 12, 15 };
guint i; guint i;
g_autoptr (HdyValueObject) never_value_object = NULL;
string_list = gtk_string_list_new (NULL);
for (i = 0; i < G_N_ELEMENTS (minutes); i++) for (i = 0; i < G_N_ELEMENTS (minutes); i++)
{ {
g_autoptr (GObject) item = NULL;
gchar *text = NULL; gchar *text = NULL;
g_autoptr (HdyValueObject) value_object = NULL;
/* Translators: Option for "Blank Screen" in "Power" panel */ /* Translators: Option for "Blank Screen" in "Power" panel */
text = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, "%d minute", "%d minutes", minutes[i]), minutes[i]); text = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, "%d minute", "%d minutes", minutes[i]), minutes[i]);
value_object = hdy_value_object_new_take_string (text); gtk_string_list_append (string_list, text);
g_object_set_data (G_OBJECT (value_object), "value", GUINT_TO_POINTER (minutes[i] * 60)); item = g_list_model_get_item (G_LIST_MODEL (string_list), i);
g_list_store_append (list_store, value_object); g_object_set_data (item, "value", GUINT_TO_POINTER (minutes[i] * 60));
} }
never_value_object = hdy_value_object_new_string (C_("Idle time", "Never")); gtk_string_list_append (string_list, C_("Idle time", "Never"));
g_object_set_data (G_OBJECT (never_value_object), "value", GUINT_TO_POINTER (0)); never_object = g_list_model_get_item (G_LIST_MODEL (string_list), i);
g_list_store_append (list_store, never_value_object); g_object_set_data (never_object, "value", GUINT_TO_POINTER (0));
hdy_combo_row_bind_name_model (combo_row, adw_combo_row_set_model (combo_row, G_LIST_MODEL (string_list));
G_LIST_MODEL (list_store),
(HdyComboRowGetNameFunc) hdy_value_object_dup_string,
NULL, NULL);
} }
static void static void
@ -1063,9 +1042,10 @@ setup_power_saving (CcPowerPanel *self)
if (can_suspend_or_hibernate (self, "CanSuspend")) if (can_suspend_or_hibernate (self, "CanSuspend"))
{ {
gtk_widget_show (GTK_WIDGET (self->automatic_suspend_row)); gtk_widget_show (GTK_WIDGET (self->automatic_suspend_row));
atk_object_set_name (ATK_OBJECT (gtk_widget_get_accessible (GTK_WIDGET (self->automatic_suspend_row))), _("Automatic suspend")); gtk_accessible_update_property (GTK_ACCESSIBLE (self->automatic_suspend_row),
GTK_ACCESSIBLE_PROPERTY_LABEL, _("Automatic suspend"),
-1);
g_signal_connect (self->automatic_suspend_dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
g_signal_connect_object (self->gsd_settings, "changed", G_CALLBACK (on_suspend_settings_changed), self, G_CONNECT_SWAPPED); g_signal_connect_object (self->gsd_settings, "changed", G_CALLBACK (on_suspend_settings_changed), self, G_CONNECT_SWAPPED);
g_settings_bind_with_mapping (self->gsd_settings, "sleep-inactive-battery-type", g_settings_bind_with_mapping (self->gsd_settings, "sleep-inactive-battery-type",
@ -1116,11 +1096,11 @@ performance_profile_set_active (CcPowerPanel *self,
const char *profile_str) const char *profile_str)
{ {
CcPowerProfile profile = cc_power_profile_from_str (profile_str); CcPowerProfile profile = cc_power_profile_from_str (profile_str);
GtkRadioButton *button; GtkCheckButton *button;
button = cc_power_profile_row_get_radio_button (CC_POWER_PROFILE_ROW (self->power_profiles_row[profile])); button = cc_power_profile_row_get_radio_button (CC_POWER_PROFILE_ROW (self->power_profiles_row[profile]));
g_assert (button); g_assert (button);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); gtk_check_button_set_active (GTK_CHECK_BUTTON (button), TRUE);
} }
static void static void
@ -1175,8 +1155,7 @@ power_profile_update_info_boxes (CcPowerPanel *self)
text = _("Performance mode temporarily disabled."); text = _("Performance mode temporarily disabled.");
row = cc_power_profile_info_row_new (text); row = cc_power_profile_info_row_new (text);
gtk_widget_show (GTK_WIDGET (row)); gtk_list_box_append (self->power_profile_info_listbox, GTK_WIDGET (row));
gtk_container_add (GTK_CONTAINER (self->power_profile_info_listbox), GTK_WIDGET (row));
if (g_str_equal (profile, "performance")) if (g_str_equal (profile, "performance"))
next_insert = 1; next_insert = 1;
} }
@ -1380,7 +1359,7 @@ setup_power_profiles (CcPowerPanel *self)
const char *performance_degraded; const char *performance_degraded;
const char *active_profile; const char *active_profile;
g_autoptr(GVariant) profiles = NULL; g_autoptr(GVariant) profiles = NULL;
GtkRadioButton *last_button; GtkCheckButton *last_button;
self->power_profiles_proxy = cc_object_storage_create_dbus_proxy_sync (G_BUS_TYPE_SYSTEM, self->power_profiles_proxy = cc_object_storage_create_dbus_proxy_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE, G_DBUS_PROXY_FLAGS_NONE,
@ -1443,7 +1422,7 @@ setup_power_profiles (CcPowerPanel *self)
{ {
g_autoptr(GVariant) profile_variant; g_autoptr(GVariant) profile_variant;
const char *name; const char *name;
GtkRadioButton *button; GtkCheckButton *button;
CcPowerProfile profile; CcPowerProfile profile;
CcPowerProfileRow *row; CcPowerProfileRow *row;
@ -1466,12 +1445,12 @@ setup_power_profiles (CcPowerPanel *self)
0); 0);
self->power_profiles_row[profile] = row; self->power_profiles_row[profile] = row;
gtk_widget_show (GTK_WIDGET (row)); gtk_widget_show (GTK_WIDGET (row));
gtk_container_add (GTK_CONTAINER (self->power_profile_listbox), GTK_WIDGET (row)); gtk_list_box_append (self->power_profile_listbox, GTK_WIDGET (row));
gtk_size_group_add_widget (self->row_sizegroup, GTK_WIDGET (row)); gtk_size_group_add_widget (self->row_sizegroup, GTK_WIDGET (row));
/* Connect radio button to group */ /* Connect radio button to group */
button = cc_power_profile_row_get_radio_button (row); button = cc_power_profile_row_get_radio_button (row);
gtk_radio_button_join_group (button, last_button); gtk_check_button_set_group (button, last_button);
last_button = button; last_button = button;
} }
@ -1556,6 +1535,30 @@ battery_sort_func (GtkListBoxRow *a, GtkListBoxRow *b, gpointer data)
return a_kind - b_kind; return a_kind - b_kind;
} }
static void
cc_power_panel_dispose (GObject *object)
{
CcPowerPanel *self = CC_POWER_PANEL (object);
g_signal_handlers_disconnect_by_func (self->blank_screen_row, blank_screen_row_changed_cb, self);
g_signal_handlers_disconnect_by_func (self->power_button_row, power_button_row_changed_cb, self);
g_clear_pointer (&self->chassis_type, g_free);
g_clear_object (&self->gsd_settings);
g_clear_object (&self->session_settings);
g_clear_object (&self->interface_settings);
g_clear_pointer ((GtkWindow **) &self->automatic_suspend_dialog, gtk_window_destroy);
g_clear_pointer (&self->devices, g_ptr_array_unref);
g_clear_object (&self->up_client);
g_clear_object (&self->iio_proxy);
g_clear_object (&self->power_profiles_proxy);
if (self->iio_proxy_watch_id != 0)
g_bus_unwatch_name (self->iio_proxy_watch_id);
self->iio_proxy_watch_id = 0;
G_OBJECT_CLASS (cc_power_panel_parent_class)->dispose (object);
}
static void static void
cc_power_panel_class_init (CcPowerPanelClass *klass) cc_power_panel_class_init (CcPowerPanelClass *klass)
{ {

View file

@ -52,25 +52,17 @@
</data> </data>
</object> </object>
<template class="CcPowerPanel" parent="CcPanel"> <template class="CcPowerPanel" parent="CcPanel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child> <child>
<object class="HdyPreferencesPage"> <object class="AdwPreferencesPage">
<property name="visible">True</property>
<child> <child>
<object class="HdyPreferencesGroup" id="battery_section"> <object class="AdwPreferencesGroup" id="battery_section">
<property name="visible">True</property>
<property name="title" translatable="yes">Battery</property> <property name="title" translatable="yes">Battery</property>
<accessibility>
<relation target="battery_listbox" type="label-for"/>
</accessibility>
<child> <child>
<object class="GtkListBox" id="battery_listbox"> <object class="GtkListBox" id="battery_listbox">
<property name="visible">True</property>
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
<signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel" swapped="yes"/> <signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel" swapped="yes"/>
<accessibility> <accessibility>
<relation target="battery_section" type="labelled-by"/> <relation name="labelled-by">battery_section</relation>
</accessibility> </accessibility>
<style> <style>
<class name="content"/> <class name="content"/>
@ -80,19 +72,14 @@
</object> </object>
</child> </child>
<child> <child>
<object class="HdyPreferencesGroup" id="device_section"> <object class="AdwPreferencesGroup" id="device_section">
<property name="visible">True</property>
<property name="title" translatable="yes">Devices</property> <property name="title" translatable="yes">Devices</property>
<accessibility>
<relation target="device_listbox" type="label-for"/>
</accessibility>
<child> <child>
<object class="GtkListBox" id="device_listbox"> <object class="GtkListBox" id="device_listbox">
<property name="visible">True</property>
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
<signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel" swapped="yes"/> <signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel" swapped="yes"/>
<accessibility> <accessibility>
<relation target="device_section" type="labelled-by"/> <relation name="labelled-by">device_section</relation>
</accessibility> </accessibility>
<style> <style>
<class name="content"/> <class name="content"/>
@ -102,21 +89,17 @@
</object> </object>
</child> </child>
<child> <child>
<object class="HdyPreferencesGroup" id="power_profile_section"> <object class="AdwPreferencesGroup" id="power_profile_section">
<property name="visible">False</property> <property name="visible">False</property>
<property name="title" translatable="yes">Power Mode</property> <property name="title" translatable="yes">Power Mode</property>
<property name="description" translatable="yes">Affects system performance and power usage.</property> <property name="description" translatable="yes">Affects system performance and power usage.</property>
<accessibility>
<relation target="power_profile_listbox" type="label-for"/>
</accessibility>
<child> <child>
<object class="GtkListBox" id="power_profile_listbox"> <object class="GtkListBox" id="power_profile_listbox">
<property name="visible">True</property>
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
<signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel" swapped="yes"/> <signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel" swapped="yes"/>
<signal name="row-activated" handler="power_profiles_row_activated_cb" object="CcPowerPanel" swapped="yes"/> <signal name="row-activated" handler="power_profiles_row_activated_cb" object="CcPowerPanel" swapped="yes"/>
<accessibility> <accessibility>
<relation target="power_profile_section" type="labelled-by"/> <relation name="labelled-by">power_profile_section</relation>
</accessibility> </accessibility>
<style> <style>
<class name="content"/> <class name="content"/>
@ -137,17 +120,14 @@
</object> </object>
</child> </child>
<child> <child>
<object class="HdyPreferencesGroup" id="power_saving_section"> <object class="AdwPreferencesGroup" id="power_saving_section">
<property name="visible">True</property>
<property name="title" translatable="yes">Power Saving Options</property> <property name="title" translatable="yes">Power Saving Options</property>
<child> <child>
<object class="HdyActionRow" id="als_row"> <object class="AdwActionRow" id="als_row">
<property name="visible">True</property>
<property name="title" translatable="yes">Automatic Screen Brightness</property> <property name="title" translatable="yes">Automatic Screen Brightness</property>
<property name="subtitle" translatable="yes">Screen brightness adjusts to the surrounding light.</property> <property name="subtitle" translatable="yes">Screen brightness adjusts to the surrounding light.</property>
<child> <child>
<object class="GtkSwitch" id="als_switch"> <object class="GtkSwitch" id="als_switch">
<property name="visible">True</property>
<property name="valign">center</property> <property name="valign">center</property>
<signal name="notify::active" handler="als_switch_changed_cb" object="CcPowerPanel" swapped="yes"/> <signal name="notify::active" handler="als_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
</object> </object>
@ -155,22 +135,19 @@
</object> </object>
</child> </child>
<child> <child>
<object class="HdyActionRow" id="dim_screen_row"> <object class="AdwActionRow" id="dim_screen_row">
<property name="visible">True</property>
<property name="title" translatable="yes">Dim Screen</property> <property name="title" translatable="yes">Dim Screen</property>
<property name="subtitle" translatable="yes">Reduces the screen brightness when the computer is inactive.</property> <property name="subtitle" translatable="yes">Reduces the screen brightness when the computer is inactive.</property>
<property name="activatable_widget">dim_screen_switch</property> <property name="activatable_widget">dim_screen_switch</property>
<child> <child>
<object class="GtkSwitch" id="dim_screen_switch"> <object class="GtkSwitch" id="dim_screen_switch">
<property name="visible">True</property>
<property name="valign">center</property> <property name="valign">center</property>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
<child> <child>
<object class="HdyComboRow" id="blank_screen_row"> <object class="AdwComboRow" id="blank_screen_row">
<property name="visible">True</property>
<property name="title" translatable="yes">Screen _Blank</property> <property name="title" translatable="yes">Screen _Blank</property>
<property name="subtitle" translatable="yes">Turns the screen off after a period of inactivity.</property> <property name="subtitle" translatable="yes">Turns the screen off after a period of inactivity.</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -178,7 +155,7 @@
</object> </object>
</child> </child>
<child> <child>
<object class="HdyActionRow" id="power_saver_low_battery_row"> <object class="AdwActionRow" id="power_saver_low_battery_row">
<property name="visible">False</property> <property name="visible">False</property>
<property name="title" translatable="yes">Automatic Power Saver</property> <property name="title" translatable="yes">Automatic Power Saver</property>
<property name="subtitle" translatable="yes">Enables power saver mode when battery is low.</property> <property name="subtitle" translatable="yes">Enables power saver mode when battery is low.</property>
@ -186,14 +163,13 @@
<property name="activatable_widget">power_saver_low_battery_switch</property> <property name="activatable_widget">power_saver_low_battery_switch</property>
<child> <child>
<object class="GtkSwitch" id="power_saver_low_battery_switch"> <object class="GtkSwitch" id="power_saver_low_battery_switch">
<property name="visible">True</property>
<property name="valign">center</property> <property name="valign">center</property>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
<child> <child>
<object class="HdyActionRow" id="automatic_suspend_row"> <object class="AdwActionRow" id="automatic_suspend_row">
<property name="visible">False</property> <property name="visible">False</property>
<property name="title" translatable="yes">_Automatic Suspend</property> <property name="title" translatable="yes">_Automatic Suspend</property>
<property name="subtitle" translatable="yes">Pauses the computer after a period of inactivity.</property> <property name="subtitle" translatable="yes">Pauses the computer after a period of inactivity.</property>
@ -202,7 +178,6 @@
<signal name="activated" handler="automatic_suspend_row_activated_cb" swapped="yes"/> <signal name="activated" handler="automatic_suspend_row_activated_cb" swapped="yes"/>
<child> <child>
<object class="GtkLabel" id="automatic_suspend_label"> <object class="GtkLabel" id="automatic_suspend_label">
<property name="visible">True</property>
<property name="halign">end</property> <property name="halign">end</property>
<signal name="mnemonic-activate" handler="automatic_suspend_label_mnemonic_activate_cb" object="CcPowerPanel" swapped="yes"/> <signal name="mnemonic-activate" handler="automatic_suspend_label_mnemonic_activate_cb" object="CcPowerPanel" swapped="yes"/>
</object> </object>
@ -212,11 +187,9 @@
</object> </object>
</child> </child>
<child> <child>
<object class="HdyPreferencesGroup" id="general_section"> <object class="AdwPreferencesGroup" id="general_section">
<property name="visible">True</property>
<property name="title" translatable="yes">Suspend &amp; Power Button</property>
<child> <child>
<object class="HdyComboRow" id="power_button_row"> <object class="AdwComboRow" id="power_button_row">
<property name="visible">False</property> <property name="visible">False</property>
<property name="title" translatable="yes">Po_wer Button Behavior</property> <property name="title" translatable="yes">Po_wer Button Behavior</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -224,14 +197,13 @@
</object> </object>
</child> </child>
<child> <child>
<object class="HdyActionRow" id="battery_percentage_row"> <object class="AdwActionRow" id="battery_percentage_row">
<property name="visible">False</property> <property name="visible">False</property>
<property name="title" translatable="yes">Show Battery _Percentage</property> <property name="title" translatable="yes">Show Battery _Percentage</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="activatable_widget">battery_percentage_switch</property> <property name="activatable_widget">battery_percentage_switch</property>
<child> <child>
<object class="GtkSwitch" id="battery_percentage_switch"> <object class="GtkSwitch" id="battery_percentage_switch">
<property name="visible">True</property>
<property name="valign">center</property> <property name="valign">center</property>
</object> </object>
</child> </child>
@ -263,21 +235,19 @@
</object> </object>
<object class="GtkDialog" id="automatic_suspend_dialog"> <object class="GtkDialog" id="automatic_suspend_dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Automatic Suspend</property> <property name="title" translatable="yes">Automatic Suspend</property>
<property name="type_hint">dialog</property>
<property name="resizable">False</property> <property name="resizable">False</property>
<property name="use_header_bar">1</property> <property name="use_header_bar">1</property>
<child internal-child="vbox"> <property name="hide-on-close">True</property>
<child>
<object class="GtkBox"> <object class="GtkBox">
<property name="can_focus">False</property> <property name="margin_start">6</property>
<property name="margin_end">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">2</property>
<child> <child>
<object class="GtkGrid"> <object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">12</property> <property name="margin_start">12</property>
<property name="margin_end">6</property> <property name="margin_end">6</property>
<property name="margin_top">12</property> <property name="margin_top">12</property>
@ -286,150 +256,101 @@
<property name="column_spacing">6</property> <property name="column_spacing">6</property>
<child> <child>
<object class="GtkLabel" id="suspend_on_ac_label"> <object class="GtkLabel" id="suspend_on_ac_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">12</property> <property name="margin_top">12</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">_Plugged In</property> <property name="label" translatable="yes">_Plugged In</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">suspend_on_ac_switch</property> <property name="mnemonic_widget">suspend_on_ac_switch</property>
<layout>
<property name="column">0</property>
<property name="row">2</property>
</layout>
</object> </object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="suspend_on_battery_label"> <object class="GtkLabel" id="suspend_on_battery_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">On _Battery Power</property> <property name="label" translatable="yes">On _Battery Power</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">suspend_on_battery_switch</property> <property name="mnemonic_widget">suspend_on_battery_switch</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object> </object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkSwitch" id="suspend_on_battery_switch"> <object class="GtkSwitch" id="suspend_on_battery_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property> <property name="halign">end</property>
<layout>
<property name="column">2</property>
<property name="row">0</property>
</layout>
</object> </object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkComboBoxText" id="suspend_on_battery_delay_combo"> <object class="GtkComboBoxText" id="suspend_on_battery_delay_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="entry_text_column">0</property> <property name="entry_text_column">0</property>
<property name="id_column">1</property> <property name="id_column">1</property>
<property name="model">time_liststore</property> <property name="model">time_liststore</property>
<layout>
<property name="column">2</property>
<property name="row">1</property>
</layout>
</object> </object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="suspend_on_battery_delay_label"> <object class="GtkLabel" id="suspend_on_battery_delay_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">20</property> <property name="margin_start">20</property>
<property name="xalign">1</property> <property name="xalign">1</property>
<property name="label" translatable="yes">Delay</property> <property name="label" translatable="yes">Delay</property>
<property name="mnemonic_widget">suspend_on_battery_delay_combo</property> <property name="mnemonic_widget">suspend_on_battery_delay_combo</property>
<layout>
<property name="column">1</property>
<property name="row">1</property>
</layout>
<style> <style>
<class name="dim-label"/> <class name="dim-label"/>
</style> </style>
</object> </object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkSwitch" id="suspend_on_ac_switch"> <object class="GtkSwitch" id="suspend_on_ac_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property> <property name="halign">end</property>
<property name="margin_top">12</property> <property name="margin_top">12</property>
<layout>
<property name="column">2</property>
<property name="row">2</property>
</layout>
</object> </object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkComboBoxText" id="suspend_on_ac_delay_combo"> <object class="GtkComboBoxText" id="suspend_on_ac_delay_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="entry_text_column">0</property> <property name="entry_text_column">0</property>
<property name="id_column">1</property> <property name="id_column">1</property>
<property name="model">time_liststore</property> <property name="model">time_liststore</property>
<layout>
<property name="column">2</property>
<property name="row">3</property>
</layout>
</object> </object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">20</property> <property name="margin_start">20</property>
<property name="xalign">1</property> <property name="xalign">1</property>
<property name="label" translatable="yes">Delay</property> <property name="label" translatable="yes">Delay</property>
<property name="mnemonic_widget">suspend_on_ac_delay_combo</property> <property name="mnemonic_widget">suspend_on_ac_delay_combo</property>
<layout>
<property name="column">1</property>
<property name="row">3</property>
</layout>
<style> <style>
<class name="dim-label"/> <class name="dim-label"/>
</style> </style>
</object> </object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child> </child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child> </child>
</object> </object>
</child> </child>

View file

@ -6,7 +6,6 @@
<property name="selectable">False</property> <property name="selectable">False</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property> <property name="orientation">horizontal</property>
<property name="margin-start">4</property> <property name="margin-start">4</property>
<property name="margin-end">8</property> <property name="margin-end">8</property>
@ -15,11 +14,10 @@
<property name="spacing">4</property> <property name="spacing">4</property>
<child> <child>
<object class="GtkImage" id="icon_image"> <object class="GtkImage" id="icon_image">
<property name="visible">True</property>
<property name="margin-start">6</property> <property name="margin-start">6</property>
<property name="margin-end">6</property> <property name="margin-end">6</property>
<property name="icon-name">info-symbolic</property> <property name="icon-name">info-symbolic</property>
<property name="icon-size">5</property> <property name="icon-size">large</property>
<style> <style>
<class name="dim-label"/> <class name="dim-label"/>
</style> </style>
@ -27,9 +25,9 @@
</child> </child>
<child> <child>
<object class="GtkLabel" id="title_label"> <object class="GtkLabel" id="title_label">
<property name="visible">True</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="expand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="use-markup">True</property> <property name="use-markup">True</property>
<property name="use-underline">True</property> <property name="use-underline">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>

View file

@ -34,7 +34,7 @@ struct _CcPowerProfileRow
{ {
GtkListBoxRow parent_instance; GtkListBoxRow parent_instance;
GtkRadioButton *button; GtkCheckButton *button;
GtkLabel *subtitle_label; GtkLabel *subtitle_label;
GtkLabel *title_label; GtkLabel *title_label;
@ -74,10 +74,8 @@ performance_profile_set_inhibited (CcPowerProfileRow *self,
if (self->power_profile != CC_POWER_PROFILE_PERFORMANCE) if (self->power_profile != CC_POWER_PROFILE_PERFORMANCE)
return; return;
gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (self->subtitle_label)), gtk_widget_remove_css_class (GTK_WIDGET (self->subtitle_label), "dim-label");
GTK_STYLE_CLASS_DIM_LABEL); gtk_widget_remove_css_class (GTK_WIDGET (self->subtitle_label), "error");
gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (self->subtitle_label)),
GTK_STYLE_CLASS_ERROR);
text = get_performance_inhibited_text (performance_inhibited); text = get_performance_inhibited_text (performance_inhibited);
if (text) if (text)
@ -86,8 +84,8 @@ performance_profile_set_inhibited (CcPowerProfileRow *self,
text = _("High performance and power usage."); text = _("High performance and power usage.");
gtk_label_set_text (GTK_LABEL (self->subtitle_label), text); gtk_label_set_text (GTK_LABEL (self->subtitle_label), text);
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self->subtitle_label)), gtk_widget_add_css_class (GTK_WIDGET (self->subtitle_label),
inhibited ? GTK_STYLE_CLASS_ERROR : GTK_STYLE_CLASS_DIM_LABEL); inhibited ? "error" : "dim-label");
gtk_widget_set_sensitive (GTK_WIDGET (self), !inhibited); gtk_widget_set_sensitive (GTK_WIDGET (self), !inhibited);
} }
@ -133,7 +131,7 @@ cc_power_profile_row_get_profile (CcPowerProfileRow *self)
return self->power_profile; return self->power_profile;
} }
GtkRadioButton * GtkCheckButton *
cc_power_profile_row_get_radio_button (CcPowerProfileRow *self) cc_power_profile_row_get_radio_button (CcPowerProfileRow *self)
{ {
g_return_val_if_fail (CC_IS_POWER_PROFILE_ROW (self), NULL); g_return_val_if_fail (CC_IS_POWER_PROFILE_ROW (self), NULL);
@ -147,7 +145,7 @@ cc_power_profile_row_set_active (CcPowerProfileRow *self,
{ {
g_return_if_fail (CC_IS_POWER_PROFILE_ROW (self)); g_return_if_fail (CC_IS_POWER_PROFILE_ROW (self));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->button), active); gtk_check_button_set_active (GTK_CHECK_BUTTON (self->button), active);
} }
void void
@ -166,7 +164,7 @@ cc_power_profile_row_get_active (CcPowerProfileRow *self)
{ {
g_return_val_if_fail (CC_IS_POWER_PROFILE_ROW (self), FALSE); g_return_val_if_fail (CC_IS_POWER_PROFILE_ROW (self), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->button)); return gtk_check_button_get_active (GTK_CHECK_BUTTON (self->button));
} }
CcPowerProfileRow * CcPowerProfileRow *

View file

@ -41,7 +41,7 @@ G_DECLARE_FINAL_TYPE (CcPowerProfileRow, cc_power_profile_row, CC, POWER_PROFILE
CcPowerProfileRow *cc_power_profile_row_new (CcPowerProfile power_profile); CcPowerProfileRow *cc_power_profile_row_new (CcPowerProfile power_profile);
CcPowerProfile cc_power_profile_row_get_profile (CcPowerProfileRow *row); CcPowerProfile cc_power_profile_row_get_profile (CcPowerProfileRow *row);
GtkRadioButton *cc_power_profile_row_get_radio_button (CcPowerProfileRow *row); GtkCheckButton *cc_power_profile_row_get_radio_button (CcPowerProfileRow *row);
void cc_power_profile_row_set_active (CcPowerProfileRow *row, gboolean active); void cc_power_profile_row_set_active (CcPowerProfileRow *row, gboolean active);
gboolean cc_power_profile_row_get_active (CcPowerProfileRow *row); gboolean cc_power_profile_row_get_active (CcPowerProfileRow *row);
void cc_power_profile_row_set_performance_inhibited (CcPowerProfileRow *row, void cc_power_profile_row_set_performance_inhibited (CcPowerProfileRow *row,

View file

@ -5,55 +5,57 @@
<property name="selectable">False</property> <property name="selectable">False</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property> <property name="orientation">horizontal</property>
<property name="margin-start">12</property> <property name="margin-start">12</property>
<property name="margin-end">12</property> <property name="margin-end">12</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<child> <child>
<object class="GtkGrid"> <object class="GtkGrid">
<property name="visible">True</property>
<property name="margin-top">6</property> <property name="margin-top">6</property>
<property name="margin-bottom">6</property> <property name="margin-bottom">6</property>
<child> <child>
<object class="GtkRadioButton" id="button"> <object class="GtkCheckButton" id="button">
<property name="visible">True</property>
<property name="margin-start">6</property> <property name="margin-start">6</property>
<property name="margin-end">18</property> <property name="margin-end">18</property>
<signal name="toggled" handler="cc_power_profile_row_button_toggled_cb" object="CcPowerProfileRow" swapped="yes"/> <signal name="toggled" handler="cc_power_profile_row_button_toggled_cb" object="CcPowerProfileRow" swapped="yes"/>
<layout>
<property name="column">0</property>
<property name="row">0</property>
<property name="row-span">2</property>
</layout>
</object> </object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="height">2</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="title_label"> <object class="GtkLabel" id="title_label">
<property name="visible">True</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="ellipsize">end</property> <property name="ellipsize">end</property>
<property name="expand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="use-markup">True</property> <property name="use-markup">True</property>
<property name="use-underline">True</property> <property name="use-underline">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="margin-end">6</property> <property name="margin-end">6</property>
<layout>
<property name="column">1</property>
<property name="row">0</property>
</layout>
</object> </object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="subtitle_label"> <object class="GtkLabel" id="subtitle_label">
<property name="visible">True</property>
<property name="ellipsize">end</property> <property name="ellipsize">end</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="expand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="use-markup">True</property> <property name="use-markup">True</property>
<property name="use-underline">True</property> <property name="use-underline">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="margin-end">6</property> <property name="margin-end">6</property>
<layout>
<property name="column">1</property>
<property name="row">1</property>
<property name="column-span">2</property>
</layout>
<attributes> <attributes>
<attribute name="scale" value="0.9"/> <attribute name="scale" value="0.9"/>
</attributes> </attributes>
@ -61,11 +63,6 @@
<class name="dim-label"/> <class name="dim-label"/>
</style> </style>
</object> </object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">2</property>
</packing>
</child> </child>
</object> </object>
</child> </child>

View file

@ -50,7 +50,7 @@ extern GType cc_info_overview_panel_get_type (void);
#endif /* BUILD_NETWORK */ #endif /* BUILD_NETWORK */
extern GType cc_notifications_panel_get_type (void); extern GType cc_notifications_panel_get_type (void);
//extern GType cc_goa_panel_get_type (void); //extern GType cc_goa_panel_get_type (void);
//extern GType cc_power_panel_get_type (void); extern GType cc_power_panel_get_type (void);
//extern GType cc_printers_panel_get_type (void); //extern GType cc_printers_panel_get_type (void);
//extern GType cc_region_panel_get_type (void); //extern GType cc_region_panel_get_type (void);
extern GType cc_removable_media_panel_get_type (void); extern GType cc_removable_media_panel_get_type (void);
@ -121,7 +121,7 @@ static CcPanelLoaderVtable default_panels[] =
#endif #endif
PANEL_TYPE("notifications", cc_notifications_panel_get_type, NULL), PANEL_TYPE("notifications", cc_notifications_panel_get_type, NULL),
//PANEL_TYPE("online-accounts", cc_goa_panel_get_type, NULL), //PANEL_TYPE("online-accounts", cc_goa_panel_get_type, NULL),
//PANEL_TYPE("power", cc_power_panel_get_type, NULL), PANEL_TYPE("power", cc_power_panel_get_type, NULL),
//PANEL_TYPE("printers", cc_printers_panel_get_type, NULL), //PANEL_TYPE("printers", cc_printers_panel_get_type, NULL),
//PANEL_TYPE("region", cc_region_panel_get_type, NULL), //PANEL_TYPE("region", cc_region_panel_get_type, NULL),
PANEL_TYPE("removable-media", cc_removable_media_panel_get_type, NULL), PANEL_TYPE("removable-media", cc_removable_media_panel_get_type, NULL),