Merge lp://staging/~charlesk/indicator-power/lp-1234458 into lp://staging/indicator-power/14.04

Proposed by Charles Kerr
Status: Merged
Merged at revision: 233
Proposed branch: lp://staging/~charlesk/indicator-power/lp-1234458
Merge into: lp://staging/indicator-power/14.04
Diff against target: 1086 lines (+524/-299)
5 files modified
src/device.c (+311/-195)
src/device.h (+21/-16)
src/service.c (+63/-46)
tests/Makefile.am (+1/-1)
tests/test-device.cc (+128/-41)
To merge this branch: bzr merge lp://staging/~charlesk/indicator-power/lp-1234458
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Lars Karlitski (community) Approve
Review via email: mp+209371@code.staging.launchpad.net

Commit message

Change the implementation of the title text / title accessible text / menuitem text to follow the spec changes in https://wiki.ubuntu.com/Power?action=diff&rev2=44&rev1=43#Title and update the tests accordingly.

Description of the change

Change the implementation of the title text / title accessible text / menuitem text to follow the spec changes in https://wiki.ubuntu.com/Power?action=diff&rev2=44&rev1=43#Title and update the tests accordingly.

Merge Review:

> Ensure the project compiles and the test suite executes without error

Yes

> Ensure that non-obvious code has comments explaining it

Lots of comments. Most of the spec's new text is in device.c's comments...

> If the change works on specific profiles, please include those in the merge description.

Is not profile-specific

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Lars Karlitski (larsu) wrote :

Today I learned the word 'inestimable'.

I bet you saw this question coming: Why the static sizes for strings? It's unlikely that any language will need more than 128 bytes (in some places I saw 64?) for those labels, I would feel much better if you'd just use g_strdup_printf().

There are already some (very minor) bugs related to that. For example, get_brief_time_remaining() doesn't check the 'size > 0' precondition and might write a \0 into the first byte.

Also, the readability of some functions would benefit from using GString to construct strings. get_accessible_time_remaining() has two blocks that create almost the same string except for the last part. Is this so that the full strings are translatable? I thought we tried not to put format specifiers into translatable strings. Are there languages that would have the "to charge" before the time?

review: Needs Information
231. By Charles Kerr

in the new indicator_power_device_get_*() functions, use heap-allocated strings rather than relying on g_snprintf().

Revision history for this message
Charles Kerr (charlesk) wrote :

> For example, get_brief_time_remaining() doesn't check the 'size > 0' precondition and might write a \0 into the first byte.

get_brief_time_remaining() is a private function; all the sanity checks have already been run by the public-facing API before get_brief_time_remaining() is reached.

Still, I agree with your main point -- there's no compelling reason for static sizes here.

Fixed r231

> Also, the readability of some functions would benefit from using GString to construct strings. get_accessible_time_remaining() has two blocks that create almost the same string except for the last part. Is this so that the full strings are translatable? I thought we tried not to put format specifiers into translatable strings.

I'd be happy to learn from this if I'm wrong, but that's not my understanding at all. IIUC it's preferable to give whole strings to the translators when it's reasonable to do so, and to not second-quess what they'll need. Since get_accessible_time_remaining() only had four combinations, I went ahead and wrote them all out long-form.

232. By Charles Kerr

remove INDICATOR_IS_POWER_DEVICE(device) tests from private functions

233. By Charles Kerr

copyediting: add const, fix misaligned whitespace

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Lars Karlitski (larsu) wrote :

> > For example, get_brief_time_remaining() doesn't check the 'size > 0'
> precondition and might write a \0 into the first byte.
>
> get_brief_time_remaining() is a private function; all the sanity checks have
> already been run by the public-facing API before get_brief_time_remaining() is
> reached.

Ah, I didn't notice that.

> Still, I agree with your main point -- there's no compelling reason for static
> sizes here.
>
> Fixed r231

Cool, thanks.

> I'd be happy to learn from this if I'm wrong, but that's not my understanding
> at all. IIUC it's preferable to give whole strings to the translators when
> it's reasonable to do so, and to not second-quess what they'll need. Since
> get_accessible_time_remaining() only had four combinations, I went ahead and
> wrote them all out long-form.

Yeah. It's not that important. I just wanted to mention it.

Thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
234. By Charles Kerr

in the new indicator_power_device_get_*() functions, use g_return_val_if_fail(foo, NULL) rather than g_return_if_fail(foo)

235. By Charles Kerr

when expecting a NULL string, use EXPECT_EQ(NULL, str)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
236. By Charles Kerr

add lp:~charlesk/indicator-power/lp-1256872

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches