|
Lines 91-98
struct _CcPowerPanelPrivate
|
Link Here
|
|---|
|
| 91 |
|
91 |
|
| 92 |
GtkWidget *automatic_suspend_row; |
92 |
GtkWidget *automatic_suspend_row; |
| 93 |
GtkWidget *automatic_suspend_label; |
93 |
GtkWidget *automatic_suspend_label; |
| 94 |
GtkWidget *critical_battery_row; |
|
|
| 95 |
GtkWidget *critical_battery_combo; |
| 96 |
|
94 |
|
| 97 |
GDBusProxy *bt_rfkill; |
95 |
GDBusProxy *bt_rfkill; |
| 98 |
GDBusProxy *bt_properties; |
96 |
GDBusProxy *bt_properties; |
|
Lines 1123-1130
set_ac_battery_ui_mode (CcPowerPanel *self)
|
Link Here
|
|---|
|
| 1123 |
|
1121 |
|
| 1124 |
self->priv->has_batteries = has_batteries; |
1122 |
self->priv->has_batteries = has_batteries; |
| 1125 |
|
1123 |
|
| 1126 |
gtk_widget_set_visible (self->priv->critical_battery_row, has_batteries); |
|
|
| 1127 |
|
| 1128 |
if (!has_batteries) |
1124 |
if (!has_batteries) |
| 1129 |
{ |
1125 |
{ |
| 1130 |
gtk_widget_hide (WID (self->priv->builder, "suspend_on_battery_switch")); |
1126 |
gtk_widget_hide (WID (self->priv->builder, "suspend_on_battery_switch")); |
|
Lines 1753-1766
on_suspend_settings_changed (GSettings *settings,
|
Link Here
|
|---|
|
| 1753 |
CcPowerPanel *self) |
1749 |
CcPowerPanel *self) |
| 1754 |
{ |
1750 |
{ |
| 1755 |
CcPowerPanelPrivate *priv = self->priv; |
1751 |
CcPowerPanelPrivate *priv = self->priv; |
| 1756 |
gint value; |
|
|
| 1757 |
|
1752 |
|
| 1758 |
if (g_strcmp0 (key, "critical-battery-action") == 0 && |
|
|
| 1759 |
priv->critical_battery_combo != NULL) |
| 1760 |
{ |
| 1761 |
value = g_settings_get_enum (settings, "critical-battery-action"); |
| 1762 |
set_value_for_combo (GTK_COMBO_BOX (priv->critical_battery_combo), value); |
| 1763 |
} |
| 1764 |
if (g_str_has_prefix (key, "sleep-inactive-")) |
1753 |
if (g_str_has_prefix (key, "sleep-inactive-")) |
| 1765 |
{ |
1754 |
{ |
| 1766 |
update_automatic_suspend_label (self); |
1755 |
update_automatic_suspend_label (self); |
|
Lines 1923-1998
add_automatic_suspend_section (CcPowerPanel *self)
|
Link Here
|
|---|
|
| 1923 |
gtk_size_group_add_widget (priv->row_sizegroup, row); |
1912 |
gtk_size_group_add_widget (priv->row_sizegroup, row); |
| 1924 |
update_automatic_suspend_label (self); |
1913 |
update_automatic_suspend_label (self); |
| 1925 |
|
1914 |
|
| 1926 |
priv->critical_battery_row = row = gtk_list_box_row_new (); |
|
|
| 1927 |
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); |
| 1928 |
gtk_container_add (GTK_CONTAINER (row), box); |
| 1929 |
label = gtk_label_new (_("When battery power is _critical")); |
| 1930 |
gtk_widget_set_halign (label, GTK_ALIGN_START); |
| 1931 |
gtk_label_set_use_underline (GTK_LABEL (label), TRUE); |
| 1932 |
gtk_widget_set_margin_start (label, 20); |
| 1933 |
gtk_widget_set_margin_end (label, 20); |
| 1934 |
gtk_widget_set_margin_top (label, 6); |
| 1935 |
gtk_widget_set_margin_bottom (label, 6); |
| 1936 |
gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0); |
| 1937 |
|
| 1938 |
value = 0; |
| 1939 |
|
| 1940 |
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL); |
| 1941 |
result = g_dbus_connection_call_sync (connection, |
| 1942 |
"org.freedesktop.login1", |
| 1943 |
"/org/freedesktop/login1", |
| 1944 |
"org.freedesktop.login1.Manager", |
| 1945 |
"CanHibernate", |
| 1946 |
NULL, |
| 1947 |
NULL, |
| 1948 |
G_DBUS_CALL_FLAGS_NONE, |
| 1949 |
-1, |
| 1950 |
NULL, |
| 1951 |
NULL); |
| 1952 |
g_object_unref (connection); |
| 1953 |
|
| 1954 |
if (result) |
| 1955 |
{ |
| 1956 |
GVariant *result_variant = g_variant_get_child_value (result, 0); |
| 1957 |
if (g_strcmp0 (g_variant_get_string (result_variant, NULL), "yes") == 0) |
| 1958 |
value = 1; |
| 1959 |
|
| 1960 |
g_variant_unref(result_variant); |
| 1961 |
g_variant_unref(result); |
| 1962 |
} |
| 1963 |
|
| 1964 |
if (value) |
| 1965 |
{ |
| 1966 |
model = (GtkTreeModel*)gtk_builder_get_object (priv->builder, "liststore_critical"); |
| 1967 |
priv->critical_battery_combo = sw = gtk_combo_box_new_with_model (model); |
| 1968 |
gtk_label_set_mnemonic_widget (GTK_LABEL (label), sw); |
| 1969 |
cell = gtk_cell_renderer_text_new (); |
| 1970 |
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (sw), cell, TRUE); |
| 1971 |
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (sw), cell, "text", 0); |
| 1972 |
gtk_widget_set_margin_start (sw, 20); |
| 1973 |
gtk_widget_set_margin_end (sw, 20); |
| 1974 |
gtk_widget_set_valign (sw, GTK_ALIGN_CENTER); |
| 1975 |
|
| 1976 |
g_object_set_data (G_OBJECT (sw), "_gsettings_key", "critical-battery-action"); |
| 1977 |
value = g_settings_get_enum (priv->gsd_settings, "critical-battery-action"); |
| 1978 |
set_value_for_combo (GTK_COMBO_BOX (sw), value); |
| 1979 |
g_signal_connect (sw, "changed", |
| 1980 |
G_CALLBACK (combo_enum_changed_cb), self); |
| 1981 |
|
| 1982 |
gtk_box_pack_start (GTK_BOX (box), sw, FALSE, TRUE, 0); |
| 1983 |
} |
| 1984 |
else |
| 1985 |
{ |
| 1986 |
label = gtk_label_new (_("Power Off")); |
| 1987 |
gtk_widget_set_margin_start (label, 20); |
| 1988 |
gtk_widget_set_margin_end (label, 20); |
| 1989 |
gtk_widget_set_margin_top (label, 6); |
| 1990 |
gtk_widget_set_margin_bottom (label, 6); |
| 1991 |
gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0); |
| 1992 |
} |
| 1993 |
|
| 1994 |
gtk_container_add (GTK_CONTAINER (widget), row); |
| 1995 |
gtk_size_group_add_widget (priv->row_sizegroup, row); |
| 1996 |
gtk_widget_show_all (widget); |
1915 |
gtk_widget_show_all (widget); |
| 1997 |
|
1916 |
|
| 1998 |
dialog = priv->automatic_suspend_dialog; |
1917 |
dialog = priv->automatic_suspend_dialog; |