Merge lp:~karl-qdh/indicator-datetime/fixappointmentformat into lp:indicator-datetime/0.3

Proposed by Karl Lattimer
Status: Merged
Merged at revision: 65
Proposed branch: lp:~karl-qdh/indicator-datetime/fixappointmentformat
Merge into: lp:indicator-datetime/0.3
Prerequisite: lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals
Diff against target: 64 lines (+32/-5)
2 files modified
src/datetime-service.c (+28/-5)
src/settings-shared.h (+4/-0)
To merge this branch: bzr merge lp:~karl-qdh/indicator-datetime/fixappointmentformat
Reviewer Review Type Date Requested Status
Ted Gould Pending
Review via email: mp+53215@code.launchpad.net

This proposal supersedes a proposal from 2011-03-08.

Description of the change

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal

On Tue, 2011-03-08 at 16:09 +0000, Karl Lattimer wrote:
> + gchar *time_format_str = g_settings_get_string(conf, SETTINGS_TIME_FORMAT_S);
> + gint apt_output;
> + if (g_strcmp0(time_format_str, "12-hour") == 0) {
> + apt_output = SETTINGS_TIME_12_HOUR;
> + } else if (g_strcmp0(time_format_str, "24-hour") == 0) {
> + apt_output = SETTINGS_TIME_24_HOUR;
> + } else {
> + apt_output = SETTINGS_TIME_LOCALE;
> + }

I think that you should be able to use priv->time_mode instead of
apt_output here.

> + if (apt_output == SETTINGS_TIME_12_HOUR) {
> + if ((mday == dmday) && (mon == dmon) && (year == dyear))
> + strftime(right, 20, DEFAULT_TIME_12_FORMAT, due);
> + else
> + strftime(right, 20, DEFAULT_TIME_12_FORMAT_WITH_DAY, due);
> + } else if (apt_output == SETTINGS_TIME_24_HOUR) {
> + if ((mday == dmday) && (mon == dmon) && (year == dyear))
> + strftime(right, 20, DEFAULT_TIME_24_FORMAT, due);
> + else
> + strftime(right, 20, DEFAULT_TIME_24_FORMAT_WITH_DAY, due);
> + } else {
> + if ((mday == dmday) && (mon == dmon) && (year == dyear))
> + strftime(right, 20, DEFAULT_TIME_FORMAT, due);
> + else
> + strftime(right, 20, DEFAULT_TIME_FORMAT_WITH_DAY, due);
> + }
> +

All of the strings being passed to strftime need a _() around them so
that they go through gettext.

  review needsfixing

review: Needs Fixing
Revision history for this message
Karl Lattimer (karl-qdh) wrote : Posted in a previous version of this proposal

> On Tue, 2011-03-08 at 16:09 +0000, Karl Lattimer wrote:
> > + gchar *time_format_str = g_settings_get_string(conf,
> SETTINGS_TIME_FORMAT_S);
> > + gint apt_output;
>
> I think that you should be able to use priv->time_mode instead of
> apt_output here.

priv->time_mode is in indicator-datetime.c we don't have a priv in datetime-service.c so I had to duplicate a little bit here.

> All of the strings being passed to strftime need a _() around them so
> that they go through gettext.

I thought that as they're all defined with N_() around them in settings-shared.h that they wouldn't however, I've added the _() and am resubmitting the branch now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/datetime-service.c'
2--- src/datetime-service.c 2011-03-14 10:27:57 +0000
3+++ src/datetime-service.c 2011-03-14 10:27:57 +0000
4@@ -626,6 +626,17 @@
5 if (height <= 0) height = 12;
6 if (width > 30) width = 12;
7 if (height > 30) height = 12;
8+
9+ gchar *time_format_str = g_settings_get_string(conf, SETTINGS_TIME_FORMAT_S);
10+ gint apt_output;
11+ if (g_strcmp0(time_format_str, "12-hour") == 0) {
12+ apt_output = SETTINGS_TIME_12_HOUR;
13+ } else if (g_strcmp0(time_format_str, "24-hour") == 0) {
14+ apt_output = SETTINGS_TIME_24_HOUR;
15+ } else {
16+ apt_output = SETTINGS_TIME_LOCALE;
17+ }
18+
19 i = 0;
20 for (l = sorted_comp_instances; l; l = l->next) {
21 struct comp_instance *ci = l->data;
22@@ -676,11 +687,23 @@
23 int dmon = due->tm_mon;
24 int dyear = due->tm_year;
25
26- if ((mday == dmday) && (mon == dmon) && (year == dyear))
27- strftime(right, 20, "%l:%M %p", due);
28- else
29- strftime(right, 20, "%a %l:%M %p", due);
30-
31+ if (apt_output == SETTINGS_TIME_12_HOUR) {
32+ if ((mday == dmday) && (mon == dmon) && (year == dyear))
33+ strftime(right, 20, _(DEFAULT_TIME_12_FORMAT), due);
34+ else
35+ strftime(right, 20, _(DEFAULT_TIME_12_FORMAT_WITH_DAY), due);
36+ } else if (apt_output == SETTINGS_TIME_24_HOUR) {
37+ if ((mday == dmday) && (mon == dmon) && (year == dyear))
38+ strftime(right, 20, _(DEFAULT_TIME_24_FORMAT), due);
39+ else
40+ strftime(right, 20, _(DEFAULT_TIME_24_FORMAT_WITH_DAY), due);
41+ } else {
42+ if ((mday == dmday) && (mon == dmon) && (year == dyear))
43+ strftime(right, 20, _(DEFAULT_TIME_FORMAT), due);
44+ else
45+ strftime(right, 20, _(DEFAULT_TIME_FORMAT_WITH_DAY), due);
46+ }
47+
48 g_debug("Appointment time: %s, for date %s", right, asctime(due));
49 dbusmenu_menuitem_property_set (item, APPOINTMENT_MENUITEM_PROP_RIGHT, right);
50
51
52=== modified file 'src/settings-shared.h'
53--- src/settings-shared.h 2011-02-25 14:18:57 +0000
54+++ src/settings-shared.h 2011-03-14 10:27:57 +0000
55@@ -51,5 +51,9 @@
56 #define DEFAULT_TIME_24_FORMAT N_("%H:%M")
57
58 #define DEFAULT_TIME_FORMAT DEFAULT_TIME_12_FORMAT
59+#define DEFAULT_TIME_FORMAT_WITH_DAY DEFAULT_TIME_12_FORMAT
60+
61+#define DEFAULT_TIME_12_FORMAT_WITH_DAY N_("%a %l:%M %p")
62+#define DEFAULT_TIME_24_FORMAT_WITH_DAY N_("%a %H:%M")
63
64 #endif

Subscribers

People subscribed via source and target branches