[gnome-control-center/gbsneto/gtk4: 21/35] WIP power: Port to GTK4
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gbsneto/gtk4: 21/35] WIP power: Port to GTK4
- Date: Mon, 1 Nov 2021 01:13:24 +0000 (UTC)
commit 0097b6f876c2c43623eff3277ed209865c954599
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Oct 20 23:07:53 2021 -0300
WIP power: Port to GTK4
It's crashing with combo boxes.
panels/meson.build | 2 +-
panels/power/cc-battery-row.c | 12 ++-
panels/power/cc-battery-row.ui | 33 ++-----
panels/power/cc-power-panel.c | 157 ++++++++++++++---------------
panels/power/cc-power-panel.ui | 187 ++++++++++-------------------------
panels/power/cc-power-profile-row.c | 18 ++--
panels/power/cc-power-profile-row.h | 2 +-
panels/power/cc-power-profile-row.ui | 41 ++++----
shell/cc-panel-loader.c | 4 +-
9 files changed, 174 insertions(+), 282 deletions(-)
---
diff --git a/panels/meson.build b/panels/meson.build
index a08f9a338..4d3ef476a 100644
--- a/panels/meson.build
+++ b/panels/meson.build
@@ -18,7 +18,7 @@ panels = [
# 'multitasking',
'notifications',
# 'online-accounts',
-# 'power',
+ 'power',
# 'printers',
# 'region',
'removable-media',
diff --git a/panels/power/cc-battery-row.c b/panels/power/cc-battery-row.c
index f6faca0c1..fe806224d 100644
--- a/panels/power/cc-battery-row.c
+++ b/panels/power/cc-battery-row.c
@@ -276,7 +276,7 @@ cc_battery_row_new (UpDevice *device,
/* Icon */
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));
}
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->percentage_label), !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_widget_get_accessible (GTK_WIDGET (primary ?
self->primary_percentage_label
- : self->percentage_label)));
+ /*
+ gtk_accessible_update_relation (GTK_ACCESSIBLE (self->levelbar),
+ GTK_ACCESSIBLE_RELATION_LABELLED_BY, primary ?
self->primary_percentage_label
+ : self->percentage_label,
+ NULL);
+ */
self->kind = kind;
self->primary = primary;
diff --git a/panels/power/cc-battery-row.ui b/panels/power/cc-battery-row.ui
index dec97a9fe..e219a3b57 100644
--- a/panels/power/cc-battery-row.ui
+++ b/panels/power/cc-battery-row.ui
@@ -2,12 +2,10 @@
<interface>
<!-- interface-requires gtk+ 3.0 -->
<template class="CcBatteryRow" parent="GtkListBoxRow">
- <property name="visible">True</property>
<property name="selectable">False</property>
<property name="activatable">False</property>
<child>
<object class="GtkBox">
- <property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="margin-start">12</property>
@@ -17,48 +15,40 @@
<property name="spacing">10</property>
<child>
<object class="GtkBox">
- <property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="spacing">12</property>
<child>
<object class="GtkBox" id="battery_box">
- <property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="name_label">
- <property name="visible">True</property>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
</object>
</child>
<child>
<object class="GtkImage" id="icon">
- <property name="visible">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<style>
<class name="dim-label"/>
</style>
</object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
</child>
</object>
</child>
<child>
<object class="GtkLabel" id="percentage_label">
- <property name="visible">True</property>
- <property name="halign">end</property>
- <style>
- <class name="dim-label"/>
- </style>
+ <property name="hexpand">True</property>
+ <property name="halign">end</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
</object>
</child>
<child>
<object class="GtkLevelBar" id="levelbar">
- <property name="visible">True</property>
<property name="hexpand">True</property>
<property name="halign">fill</property>
<property name="valign">center</property>
@@ -68,30 +58,21 @@
<offset name="high-battery-offset" value="1.0"/>
</offsets>
</object>
- <packing>
- <property name="expand">True</property>
- </packing>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="primary_bottom_box">
- <property name="visible">True</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkLabel" id="details_label">
- <property name="visible">True</property>
+ <property name="hexpand">True</property>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
</object>
</child>
<child>
- <object class="GtkLabel" id="primary_percentage_label">
- <property name="visible">True</property>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
+ <object class="GtkLabel" id="primary_percentage_label" />
</child>
</object>
</child>
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 15e69e3d9..b4c0f544c 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -25,10 +25,8 @@
#include <glib/gi18n.h>
#include <gnome-settings-daemon/gsd-enums.h>
#include <gio/gdesktopappinfo.h>
-#include <handy.h>
#include "shell/cc-object-storage.h"
-#include "list-box-helper.h"
#include "cc-battery-row.h"
#include "cc-power-profile-row.h"
#include "cc-power-profile-info-row.h"
@@ -64,22 +62,22 @@ struct _CcPowerPanel
GtkLabel *automatic_suspend_label;
GtkListBoxRow *automatic_suspend_row;
GtkListBox *battery_listbox;
- HdyActionRow *battery_percentage_row;
+ AdwActionRow *battery_percentage_row;
GtkSwitch *battery_percentage_switch;
GtkSizeGroup *battery_row_sizegroup;
- HdyPreferencesGroup *battery_section;
- HdyComboRow *blank_screen_row;
+ AdwPreferencesGroup *battery_section;
+ AdwComboRow *blank_screen_row;
GtkListBox *device_listbox;
- HdyPreferencesGroup *device_section;
+ AdwPreferencesGroup *device_section;
GtkListBoxRow *dim_screen_row;
GtkSwitch *dim_screen_switch;
- HdyPreferencesGroup *general_section;
+ AdwPreferencesGroup *general_section;
GtkSizeGroup *level_sizegroup;
- HdyComboRow *power_button_row;
+ AdwComboRow *power_button_row;
GtkListBox *power_profile_listbox;
GtkListBox *power_profile_info_listbox;
- HdyPreferencesGroup *power_profile_section;
- HdyActionRow *power_saver_low_battery_row;
+ AdwPreferencesGroup *power_profile_section;
+ AdwActionRow *power_saver_low_battery_row;
GtkSwitch *power_saver_low_battery_switch;
GtkSizeGroup *row_sizegroup;
GtkComboBox *suspend_on_battery_delay_combo;
@@ -126,7 +124,7 @@ cc_power_panel_dispose (GObject *object)
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 ((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);
@@ -195,9 +193,9 @@ load_custom_css (CcPowerPanel *self,
/* use custom CSS */
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, path);
- gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ gtk_style_context_add_provider_for_display (gdk_display_get_default (),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
static void
@@ -207,7 +205,7 @@ add_battery (CcPowerPanel *panel, UpDevice *device, gboolean primary)
cc_battery_row_set_level_sizegroup (row, panel->level_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);
}
@@ -218,19 +216,17 @@ add_device (CcPowerPanel *self, UpDevice *device)
cc_battery_row_set_level_sizegroup (row, self->level_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);
}
static void
empty_listbox (GtkListBox *listbox)
{
- g_autoptr(GList) children = NULL;
- GList *l;
+ GtkWidget *child;
- children = gtk_container_get_children (GTK_CONTAINER (listbox));
- for (l = children; l != NULL; l = l->next)
- gtk_container_remove (GTK_CONTAINER (listbox), l->data);
+ while ((child = gtk_widget_get_first_child (GTK_WIDGET (listbox))) != NULL)
+ gtk_list_box_remove (listbox, child);
}
static void
@@ -379,9 +375,9 @@ up_client_changed (CcPowerPanel *self)
}
if (n_batteries > 1)
- hdy_preferences_group_set_title (self->battery_section, _("Batteries"));
+ adw_preferences_group_set_title (self->battery_section, _("Batteries"));
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)
add_battery (self, composite, TRUE);
@@ -556,25 +552,25 @@ set_value_for_combo (GtkComboBox *combo_box, gint value)
}
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;
guint insert_before = 0;
guint i;
- HdyValueObject *new;
GListModel *model;
gint value_last = 0;
g_autofree gchar *text = NULL;
/* 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++)
{
- HdyValueObject *value_object = g_list_model_get_item (model, i);
- gint value_tmp = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (value_object), "value"));
+ g_autoptr (GObject) item = g_list_model_get_item (model, i);
+ gint value_tmp = GPOINTER_TO_UINT (g_object_get_data (item, "value"));
if (value_tmp == value)
{
- hdy_combo_row_set_selected_index (combo_row, i);
+ adw_combo_row_set_selected (combo_row, i);
return;
}
@@ -591,11 +587,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). */
text = cc_util_time_to_string_text (value * 1000);
- new = hdy_value_object_new_string (text);
- g_object_set_data (G_OBJECT (new), "value",
- GUINT_TO_POINTER (value));
- g_list_store_insert (G_LIST_STORE (model), insert_before, new);
- hdy_combo_row_set_selected_index (combo_row, insert_before);
+ gtk_string_list_append (GTK_STRING_LIST (model), text);
+
+ new_item = g_list_model_get_item (model, i);
+ g_object_set_data (G_OBJECT (new_item), "value", GUINT_TO_POINTER (value));
+
+ adw_combo_row_set_selected (combo_row, insert_before);
}
static void
@@ -659,15 +656,15 @@ keynav_failed_cb (CcPowerPanel *self, GtkDirectionType direction, GtkWidget *lis
static void
blank_screen_row_changed_cb (CcPowerPanel *self)
{
+ g_autoptr (GObject) item = NULL;
GListModel *model;
gint selected_index;
- HdyValueObject *value_object;
gint value;
- model = hdy_combo_row_get_model (self->blank_screen_row);
- selected_index = hdy_combo_row_get_selected_index (self->blank_screen_row);
- value_object = g_list_model_get_item (model, selected_index);
- value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (value_object), "value"));
+ model = adw_combo_row_get_model (self->blank_screen_row);
+ selected_index = adw_combo_row_get_selected (self->blank_screen_row);
+ 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);
}
@@ -675,15 +672,15 @@ blank_screen_row_changed_cb (CcPowerPanel *self)
static void
power_button_row_changed_cb (CcPowerPanel *self)
{
+ g_autoptr (GObject) item = NULL;
GListModel *model;
gint selected_index;
- HdyValueObject *value_object;
gint value;
- model = hdy_combo_row_get_model (self->power_button_row);
- selected_index = hdy_combo_row_get_selected_index (self->power_button_row);
- value_object = g_list_model_get_item (model, selected_index);
- value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (value_object), "value"));
+ model = adw_combo_row_get_model (self->power_button_row);
+ selected_index = adw_combo_row_get_selected (self->power_button_row);
+ 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);
}
@@ -737,8 +734,10 @@ static void
automatic_suspend_row_activated_cb (CcPowerPanel *self)
{
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_modal (GTK_WINDOW (self->automatic_suspend_dialog), TRUE);
gtk_window_present (GTK_WINDOW (self->automatic_suspend_dialog));
@@ -784,11 +783,11 @@ set_sleep_type (const GValue *value,
}
static void
-populate_power_button_row (HdyComboRow *combo_row,
+populate_power_button_row (AdwComboRow *combo_row,
gboolean can_suspend,
gboolean can_hibernate)
{
- g_autoptr (GListStore) list_store = NULL;
+ g_autoptr (GtkStringList) string_list = NULL;
struct {
char *name;
GsdPowerButtonActionType value;
@@ -800,10 +799,10 @@ populate_power_button_row (HdyComboRow *combo_row,
};
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++)
{
- g_autoptr (HdyValueObject) value_object = NULL;
+ g_autoptr (GObject) item = NULL;
if (!can_suspend && actions[i].value == GSD_POWER_BUTTON_ACTION_SUSPEND)
continue;
@@ -811,17 +810,13 @@ populate_power_button_row (HdyComboRow *combo_row,
if (!can_hibernate && actions[i].value == GSD_POWER_BUTTON_ACTION_HIBERNATE)
continue;
- value_object = hdy_value_object_new_string (_(actions[i].name));
- g_object_set_data (G_OBJECT (value_object),
- "value",
- GUINT_TO_POINTER (actions[i].value));
- g_list_store_append (list_store, value_object);
+ gtk_string_list_append (string_list, _(actions[i].name));
+
+ item = g_list_model_get_item (G_LIST_MODEL (string_list), i);
+ g_object_set_data (item, "value", GUINT_TO_POINTER (actions[i].value));
}
- hdy_combo_row_bind_name_model (combo_row,
- G_LIST_MODEL (list_store),
- (HdyComboRowGetNameFunc) hdy_value_object_dup_string,
- NULL, NULL);
+ adw_combo_row_set_model (combo_row, G_LIST_MODEL (string_list));
}
#define NEVER 0
@@ -957,34 +952,32 @@ got_brightness_cb (GObject *source_object,
}
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 };
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++)
{
+ g_autoptr (GObject) item = NULL;
gchar *text = NULL;
- g_autoptr (HdyValueObject) value_object = NULL;
/* Translators: Option for "Blank Screen" in "Power" panel */
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));
- g_list_store_append (list_store, value_object);
+ item = g_list_model_get_item (G_LIST_MODEL (string_list), i);
+ g_object_set_data (item, "value", GUINT_TO_POINTER (minutes[i] * 60));
}
- never_value_object = hdy_value_object_new_string (C_("Idle time", "Never"));
- g_object_set_data (G_OBJECT (never_value_object), "value", GUINT_TO_POINTER (0));
- g_list_store_append (list_store, never_value_object);
+ gtk_string_list_append (string_list, C_("Idle time", "Never"));
+ never_object = g_list_model_get_item (G_LIST_MODEL (string_list), i);
+ g_object_set_data (never_object, "value", GUINT_TO_POINTER (0));
- hdy_combo_row_bind_name_model (combo_row,
- G_LIST_MODEL (list_store),
- (HdyComboRowGetNameFunc) hdy_value_object_dup_string,
- NULL, NULL);
+ adw_combo_row_set_model (combo_row, G_LIST_MODEL (string_list));
}
static void
@@ -1063,9 +1056,10 @@ setup_power_saving (CcPowerPanel *self)
if (can_suspend_or_hibernate (self, "CanSuspend"))
{
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_settings_bind_with_mapping (self->gsd_settings, "sleep-inactive-battery-type",
@@ -1116,11 +1110,11 @@ performance_profile_set_active (CcPowerPanel *self,
const char *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]));
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
@@ -1175,8 +1169,7 @@ power_profile_update_info_boxes (CcPowerPanel *self)
text = _("Performance mode temporarily disabled.");
row = cc_power_profile_info_row_new (text);
- gtk_widget_show (GTK_WIDGET (row));
- gtk_container_add (GTK_CONTAINER (self->power_profile_info_listbox), GTK_WIDGET (row));
+ gtk_list_box_append (self->power_profile_info_listbox, GTK_WIDGET (row));
if (g_str_equal (profile, "performance"))
next_insert = 1;
}
@@ -1380,7 +1373,7 @@ setup_power_profiles (CcPowerPanel *self)
const char *performance_degraded;
const char *active_profile;
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,
G_DBUS_PROXY_FLAGS_NONE,
@@ -1443,7 +1436,7 @@ setup_power_profiles (CcPowerPanel *self)
{
g_autoptr(GVariant) profile_variant;
const char *name;
- GtkRadioButton *button;
+ GtkCheckButton *button;
CcPowerProfile profile;
CcPowerProfileRow *row;
@@ -1466,12 +1459,12 @@ setup_power_profiles (CcPowerPanel *self)
0);
self->power_profiles_row[profile] = 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));
/* Connect radio button to group */
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;
}
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index 9880f6b7e..cb81889ae 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -52,25 +52,17 @@
</data>
</object>
<template class="CcPowerPanel" parent="CcPanel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<child>
- <object class="HdyPreferencesPage">
- <property name="visible">True</property>
+ <object class="AdwPreferencesPage">
<child>
- <object class="HdyPreferencesGroup" id="battery_section">
- <property name="visible">True</property>
+ <object class="AdwPreferencesGroup" id="battery_section">
<property name="title" translatable="yes">Battery</property>
- <accessibility>
- <relation target="battery_listbox" type="label-for"/>
- </accessibility>
<child>
<object class="GtkListBox" id="battery_listbox">
- <property name="visible">True</property>
<property name="selection-mode">none</property>
<signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel" swapped="yes"/>
<accessibility>
- <relation target="battery_section" type="labelled-by"/>
+ <relation name="labelled-by">battery_section</relation>
</accessibility>
<style>
<class name="content"/>
@@ -80,19 +72,14 @@
</object>
</child>
<child>
- <object class="HdyPreferencesGroup" id="device_section">
- <property name="visible">True</property>
+ <object class="AdwPreferencesGroup" id="device_section">
<property name="title" translatable="yes">Devices</property>
- <accessibility>
- <relation target="device_listbox" type="label-for"/>
- </accessibility>
<child>
<object class="GtkListBox" id="device_listbox">
- <property name="visible">True</property>
<property name="selection-mode">none</property>
<signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel" swapped="yes"/>
<accessibility>
- <relation target="device_section" type="labelled-by"/>
+ <relation name="labelled-by">device_section</relation>
</accessibility>
<style>
<class name="content"/>
@@ -102,21 +89,17 @@
</object>
</child>
<child>
- <object class="HdyPreferencesGroup" id="power_profile_section">
+ <object class="AdwPreferencesGroup" id="power_profile_section">
<property name="visible">False</property>
<property name="title" translatable="yes">Power Mode</property>
<property name="description" translatable="yes">Affects system performance and power
usage.</property>
- <accessibility>
- <relation target="power_profile_listbox" type="label-for"/>
- </accessibility>
<child>
<object class="GtkListBox" id="power_profile_listbox">
- <property name="visible">True</property>
<property name="selection-mode">none</property>
<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"/>
<accessibility>
- <relation target="power_profile_section" type="labelled-by"/>
+ <relation name="labelled-by">power_profile_section</relation>
</accessibility>
<style>
<class name="content"/>
@@ -137,17 +120,14 @@
</object>
</child>
<child>
- <object class="HdyPreferencesGroup" id="power_saving_section">
- <property name="visible">True</property>
+ <object class="AdwPreferencesGroup" id="power_saving_section">
<property name="title" translatable="yes">Power Saving Options</property>
<child>
- <object class="HdyActionRow" id="als_row">
- <property name="visible">True</property>
+ <object class="AdwActionRow" id="als_row">
<property name="title" translatable="yes">Automatic Screen Brightness</property>
<property name="subtitle" translatable="yes">Screen brightness adjusts to the surrounding
light.</property>
<child>
<object class="GtkSwitch" id="als_switch">
- <property name="visible">True</property>
<property name="valign">center</property>
<signal name="notify::active" handler="als_switch_changed_cb" object="CcPowerPanel"
swapped="yes"/>
</object>
@@ -155,22 +135,19 @@
</object>
</child>
<child>
- <object class="HdyActionRow" id="dim_screen_row">
- <property name="visible">True</property>
+ <object class="AdwActionRow" id="dim_screen_row">
<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="activatable_widget">dim_screen_switch</property>
<child>
<object class="GtkSwitch" id="dim_screen_switch">
- <property name="visible">True</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
- <object class="HdyComboRow" id="blank_screen_row">
- <property name="visible">True</property>
+ <object class="AdwComboRow" id="blank_screen_row">
<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="use_underline">True</property>
@@ -178,7 +155,7 @@
</object>
</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="title" translatable="yes">Automatic Power Saver</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>
<child>
<object class="GtkSwitch" id="power_saver_low_battery_switch">
- <property name="visible">True</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
- <object class="HdyActionRow" id="automatic_suspend_row">
+ <object class="AdwActionRow" id="automatic_suspend_row">
<property name="visible">False</property>
<property name="title" translatable="yes">_Automatic Suspend</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"/>
<child>
<object class="GtkLabel" id="automatic_suspend_label">
- <property name="visible">True</property>
<property name="halign">end</property>
<signal name="mnemonic-activate" handler="automatic_suspend_label_mnemonic_activate_cb"
object="CcPowerPanel" swapped="yes"/>
</object>
@@ -212,11 +187,9 @@
</object>
</child>
<child>
- <object class="HdyPreferencesGroup" id="general_section">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Suspend & Power Button</property>
+ <object class="AdwPreferencesGroup" id="general_section">
<child>
- <object class="HdyComboRow" id="power_button_row">
+ <object class="AdwComboRow" id="power_button_row">
<property name="visible">False</property>
<property name="title" translatable="yes">Po_wer Button Behavior</property>
<property name="use_underline">True</property>
@@ -224,14 +197,13 @@
</object>
</child>
<child>
- <object class="HdyActionRow" id="battery_percentage_row">
+ <object class="AdwActionRow" id="battery_percentage_row">
<property name="visible">False</property>
<property name="title" translatable="yes">Show Battery _Percentage</property>
<property name="use_underline">True</property>
<property name="activatable_widget">battery_percentage_switch</property>
<child>
<object class="GtkSwitch" id="battery_percentage_switch">
- <property name="visible">True</property>
<property name="valign">center</property>
</object>
</child>
@@ -263,21 +235,19 @@
</object>
<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="type_hint">dialog</property>
<property name="resizable">False</property>
<property name="use_header_bar">1</property>
- <child internal-child="vbox">
+ <property name="hide-on-close">True</property>
+ <child>
<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="spacing">2</property>
<child>
<object class="GtkGrid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="margin_start">12</property>
<property name="margin_end">6</property>
<property name="margin_top">12</property>
@@ -286,150 +256,101 @@
<property name="column_spacing">6</property>
<child>
<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="xalign">0</property>
<property name="label" translatable="yes">_Plugged In</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">suspend_on_ac_switch</property>
+ <layout>
+ <property name="column">0</property>
+ <property name="row">2</property>
+ </layout>
</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>
<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="label" translatable="yes">On _Battery Power</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">suspend_on_battery_switch</property>
+ <layout>
+ <property name="column">0</property>
+ <property name="row">0</property>
+ </layout>
</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>
<object class="GtkSwitch" id="suspend_on_battery_switch">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
<property name="halign">end</property>
+ <layout>
+ <property name="column">2</property>
+ <property name="row">0</property>
+ </layout>
</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>
<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="id_column">1</property>
<property name="model">time_liststore</property>
+ <layout>
+ <property name="column">2</property>
+ <property name="row">1</property>
+ </layout>
</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>
<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="xalign">1</property>
<property name="label" translatable="yes">Delay</property>
<property name="mnemonic_widget">suspend_on_battery_delay_combo</property>
+ <layout>
+ <property name="column">1</property>
+ <property name="row">1</property>
+ </layout>
<style>
<class name="dim-label"/>
</style>
</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>
<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="margin_top">12</property>
+ <layout>
+ <property name="column">2</property>
+ <property name="row">2</property>
+ </layout>
</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>
<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="id_column">1</property>
<property name="model">time_liststore</property>
+ <layout>
+ <property name="column">2</property>
+ <property name="row">3</property>
+ </layout>
</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>
<object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="margin_start">20</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Delay</property>
<property name="mnemonic_widget">suspend_on_ac_delay_combo</property>
+ <layout>
+ <property name="column">1</property>
+ <property name="row">3</property>
+ </layout>
<style>
<class name="dim-label"/>
</style>
</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>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
</child>
diff --git a/panels/power/cc-power-profile-row.c b/panels/power/cc-power-profile-row.c
index f290caa10..e4b149b10 100644
--- a/panels/power/cc-power-profile-row.c
+++ b/panels/power/cc-power-profile-row.c
@@ -34,7 +34,7 @@ struct _CcPowerProfileRow
{
GtkListBoxRow parent_instance;
- GtkRadioButton *button;
+ GtkCheckButton *button;
GtkLabel *subtitle_label;
GtkLabel *title_label;
@@ -74,10 +74,8 @@ performance_profile_set_inhibited (CcPowerProfileRow *self,
if (self->power_profile != CC_POWER_PROFILE_PERFORMANCE)
return;
- gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (self->subtitle_label)),
- GTK_STYLE_CLASS_DIM_LABEL);
- gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (self->subtitle_label)),
- GTK_STYLE_CLASS_ERROR);
+ gtk_widget_remove_css_class (GTK_WIDGET (self->subtitle_label), "dim-label");
+ gtk_widget_remove_css_class (GTK_WIDGET (self->subtitle_label), "error");
text = get_performance_inhibited_text (performance_inhibited);
if (text)
@@ -86,8 +84,8 @@ performance_profile_set_inhibited (CcPowerProfileRow *self,
text = _("High performance and power usage.");
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)),
- inhibited ? GTK_STYLE_CLASS_ERROR : GTK_STYLE_CLASS_DIM_LABEL);
+ gtk_widget_add_css_class (GTK_WIDGET (self->subtitle_label),
+ inhibited ? "error" : "dim-label");
gtk_widget_set_sensitive (GTK_WIDGET (self), !inhibited);
}
@@ -133,7 +131,7 @@ cc_power_profile_row_get_profile (CcPowerProfileRow *self)
return self->power_profile;
}
-GtkRadioButton *
+GtkCheckButton *
cc_power_profile_row_get_radio_button (CcPowerProfileRow *self)
{
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));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->button), active);
+ gtk_check_button_set_active (GTK_CHECK_BUTTON (self->button), active);
}
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);
- return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->button));
+ return gtk_check_button_get_active (GTK_CHECK_BUTTON (self->button));
}
CcPowerProfileRow *
diff --git a/panels/power/cc-power-profile-row.h b/panels/power/cc-power-profile-row.h
index 96c12a5e4..6a26c44af 100644
--- a/panels/power/cc-power-profile-row.h
+++ b/panels/power/cc-power-profile-row.h
@@ -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);
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);
gboolean cc_power_profile_row_get_active (CcPowerProfileRow *row);
void cc_power_profile_row_set_performance_inhibited (CcPowerProfileRow *row,
diff --git a/panels/power/cc-power-profile-row.ui b/panels/power/cc-power-profile-row.ui
index 1391093ba..3da6bef0c 100644
--- a/panels/power/cc-power-profile-row.ui
+++ b/panels/power/cc-power-profile-row.ui
@@ -5,55 +5,57 @@
<property name="selectable">False</property>
<child>
<object class="GtkBox">
- <property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="spacing">12</property>
<child>
<object class="GtkGrid">
- <property name="visible">True</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<child>
- <object class="GtkRadioButton" id="button">
- <property name="visible">True</property>
+ <object class="GtkCheckButton" id="button">
<property name="margin-start">6</property>
<property name="margin-end">18</property>
<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>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="height">2</property>
- </packing>
</child>
<child>
<object class="GtkLabel" id="title_label">
- <property name="visible">True</property>
<property name="halign">start</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-underline">True</property>
<property name="xalign">0</property>
<property name="margin-end">6</property>
+ <layout>
+ <property name="column">1</property>
+ <property name="row">0</property>
+ </layout>
</object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
</child>
<child>
<object class="GtkLabel" id="subtitle_label">
- <property name="visible">True</property>
<property name="ellipsize">end</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-underline">True</property>
<property name="xalign">0</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>
<attribute name="scale" value="0.9"/>
</attributes>
@@ -61,11 +63,6 @@
<class name="dim-label"/>
</style>
</object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- <property name="width">2</property>
- </packing>
</child>
</object>
</child>
diff --git a/shell/cc-panel-loader.c b/shell/cc-panel-loader.c
index 97c418896..9accbf248 100644
--- a/shell/cc-panel-loader.c
+++ b/shell/cc-panel-loader.c
@@ -50,7 +50,7 @@ extern GType cc_info_overview_panel_get_type (void);
#endif /* BUILD_NETWORK */
extern GType cc_notifications_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_region_panel_get_type (void);
extern GType cc_removable_media_panel_get_type (void);
@@ -121,7 +121,7 @@ static CcPanelLoaderVtable default_panels[] =
#endif
PANEL_TYPE("notifications", cc_notifications_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("region", cc_region_panel_get_type, NULL),
PANEL_TYPE("removable-media", cc_removable_media_panel_get_type, NULL),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]