Merge lp:~charlesk/gnome-control-center/icon-policy into lp:~ubuntu-desktop/gnome-control-center/ubuntu

Proposed by Charles Kerr on 2012-02-14
Status: Merged
Merged at revision: 348
Proposed branch: lp:~charlesk/gnome-control-center/icon-policy
Merge into: lp:~ubuntu-desktop/gnome-control-center/ubuntu
Diff against target: 178 lines (+165/-0)
2 files modified
debian/patches/97_power_icon_policy.patch (+164/-0)
debian/patches/series (+1/-0)
To merge this branch: bzr merge lp:~charlesk/gnome-control-center/icon-policy
Reviewer Review Type Date Requested Status
Sebastien Bacher 2012-02-14 Needs Fixing on 2012-02-14
Review via email: mp+93064@code.launchpad.net

Description of the change

add a combobox to let user choose when the power indicator will be visible.

spec: https://wiki.ubuntu.com/Power#Power_settings
ticket: https://bugs.launchpad.net/ubuntu/+source/indicator-power/+bug/811769

To post a comment you must log in.
Sebastien Bacher (seb128) wrote :

Thank you for your work there, could you handle the case where the schemas is missing there? it's different from gnome-bluetooth where the schemas was coming from the same source, the issue is that we patch gnome-control-center at the moment but the same gnome-control-center might be used under gnome-shell by users who have no indicators installed. Ideally the new ui wouldn't be displayed under non unity session but I think we can resolve that case later, the other indicators have the same issue

We will also need an indicator-power release out before uploading the gnome-control-center patch because of the schemas depends

review: Needs Fixing
Charles Kerr (charlesk) wrote :

Seb, the missing-schema case (and hiding the new UI if it's missing) is handled now in revision 348.

348. By Charles Kerr on 2012-02-14

handle missing schema case as requested by seb128

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'debian/patches/97_power_icon_policy.patch'
2--- debian/patches/97_power_icon_policy.patch 1970-01-01 00:00:00 +0000
3+++ debian/patches/97_power_icon_policy.patch 2012-02-14 22:27:17 +0000
4@@ -0,0 +1,164 @@
5+--- a/panels/power/cc-power-panel.c
6++++ b/panels/power/cc-power-panel.c
7+@@ -39,6 +39,7 @@
8+ {
9+ GSettings *lock_settings;
10+ GSettings *gsd_settings;
11++ GSettings *indicator_settings;
12+ GCancellable *cancellable;
13+ GtkBuilder *builder;
14+ GDBusProxy *proxy;
15+@@ -83,6 +84,8 @@
16+ {
17+ CcPowerPanelPrivate *priv = CC_POWER_PANEL (object)->priv;
18+
19++ g_clear_object (&priv->indicator_settings);
20++
21+ if (priv->gsd_settings)
22+ {
23+ g_object_unref (priv->gsd_settings);
24+@@ -566,6 +569,80 @@
25+ gtk_widget_set_visible (widget, has_batteries && has_lid);
26+ }
27+
28++/* these keys are from com.canonical.indicator.power */
29++static const char * icon_policy_keys[] = { "present", "charge", "never" };
30++static const int icon_policy_key_count = G_N_ELEMENTS(icon_policy_keys);
31++
32++static gboolean
33++icon_policy_map_settings_to_value (GValue * value,
34++ GVariant * variant,
35++ gpointer user_data G_GNUC_UNUSED)
36++{
37++ int i;
38++ int index;
39++ const char * needle;
40++
41++ index = -1;
42++ needle = g_variant_get_string (variant, NULL);
43++ for (i=0; i<icon_policy_key_count; ++i)
44++ if (!g_strcmp0 (needle, icon_policy_keys[i]))
45++ index = i;
46++
47++ g_value_set_int (value, index);
48++ return TRUE;
49++}
50++
51++static GVariant*
52++icon_policy_map_value_to_settings (const GValue * value,
53++ const GVariantType * expected_type,
54++ gpointer user_data G_GNUC_UNUSED)
55++{
56++ GVariant * ret;
57++
58++ const int i = g_value_get_int (value);
59++ if (0<=i && i<icon_policy_key_count)
60++ ret = g_variant_new_string (icon_policy_keys[i]);
61++ else
62++ ret = NULL;
63++
64++ return ret;
65++}
66++
67++static gboolean
68++schema_exists (const char * name)
69++{
70++ int i;
71++ const char * const * schemas = g_settings_list_schemas ();
72++
73++ for (i=0; schemas && schemas[i]; i++)
74++ if (!g_strcmp0 (name, schemas[i]))
75++ return TRUE;
76++
77++ return FALSE;
78++}
79++
80++static void
81++icon_policy_init (CcPowerPanel *self)
82++{
83++ const char * schema = "com.canonical.indicator.power";
84++
85++ if (schema_exists (schema))
86++ {
87++ GtkWidget * widget = WID (self->priv->builder, "combobox_icon_policy");
88++ self->priv->indicator_settings = g_settings_new (schema);
89++ g_settings_bind_with_mapping (self->priv->indicator_settings, "icon-policy",
90++ widget, "active",
91++ G_SETTINGS_BIND_DEFAULT,
92++ icon_policy_map_settings_to_value,
93++ icon_policy_map_value_to_settings,
94++ NULL, NULL);
95++ }
96++ else
97++ {
98++ gtk_widget_hide (WID (self->priv->builder, "row_icon_policy"));
99++ }
100++}
101++
102+ static void
103+ cc_power_panel_init (CcPowerPanel *self)
104+ {
105+@@ -664,6 +741,8 @@
106+
107+ widget = WID (self->priv->builder, "vbox_power");
108+ gtk_widget_reparent (widget, (GtkWidget *) self);
109++
110++ icon_policy_init (self);
111+ }
112+
113+ void
114+--- a/panels/power/power.ui
115++++ b/panels/power/power.ui
116+@@ -432,6 +432,52 @@
117+ <property name="position">1</property>
118+ </packing>
119+ </child>
120++ <child>
121++ <object class="GtkBox" id="row_icon_policy">
122++ <property name="visible">True</property>
123++ <property name="can_focus">False</property>
124++ <property name="spacing">9</property>
125++ <child>
126++ <object class="GtkLabel" id="label_icon_policy">
127++ <property name="visible">True</property>
128++ <property name="can_focus">False</property>
129++ <property name="xalign">1</property>
130++ <property name="label" translatable="yes">Show battery status in the _menu bar:</property>
131++ <property name="mnemonic_widget">combobox_icon_policy</property>
132++ <property name="use_underline">True</property>
133++ <property name="track_visited_links">False</property>
134++ </object>
135++ <packing>
136++ <property name="expand">False</property>
137++ <property name="fill">False</property>
138++ <property name="position">0</property>
139++ </packing>
140++ </child>
141++ <child>
142++ <object class="GtkComboBoxText" id="combobox_icon_policy">
143++ <property name="visible">True</property>
144++ <property name="can_focus">False</property>
145++ <property name="entry_text_column">0</property>
146++ <property name="id_column">1</property>
147++ <items>
148++ <item translatable="yes">When a battery is present</item>
149++ <item translatable="yes">When a battery is charging / in use</item>
150++ <item translatable="yes">Never</item>
151++ </items>
152++ </object>
153++ <packing>
154++ <property name="expand">False</property>
155++ <property name="fill">True</property>
156++ <property name="position">1</property>
157++ </packing>
158++ </child>
159++ </object>
160++ <packing>
161++ <property name="expand">False</property>
162++ <property name="fill">True</property>
163++ <property name="position">2</property>
164++ </packing>
165++ </child>
166+ </object>
167+ </child>
168+ </object>
169
170=== modified file 'debian/patches/series'
171--- debian/patches/series 2012-02-10 16:04:48 +0000
172+++ debian/patches/series 2012-02-14 22:27:17 +0000
173@@ -28,4 +28,5 @@
174 94_git_adding_shortcuts.patch
175 95_git_ctrlw_shortcut.patch
176 96_sound_nua_panel.patch
177+97_power_icon_policy.patch
178 git_extra_keywords.patch

Subscribers

People subscribed via source and target branches