From 19663dd8958f833385470c6d67f1d80923f33fd0 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 30 Oct 2013 15:29:43 -0700 Subject: Add support for showing the year in indicator-datetime --- src/service.c | 5 ++++- src/settings-shared.h | 1 + src/utils.c | 32 ++++++++++++++++++++++---------- src/utils.h | 1 + 4 files changed, 28 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/service.c b/src/service.c index 6fb2ded..0ed7d02 100644 --- a/src/service.c +++ b/src/service.c @@ -666,7 +666,8 @@ get_header_label_format_string (IndicatorDatetimeService * self) { gboolean show_day = g_settings_get_boolean (s, SETTINGS_SHOW_DAY_S); gboolean show_date = g_settings_get_boolean (s, SETTINGS_SHOW_DATE_S); - fmt = generate_full_format_string (show_day, show_date, s); + gboolean show_year = show_date && g_settings_get_boolean (s, SETTINGS_SHOW_YEAR_S); + fmt = generate_full_format_string (show_day, show_date, show_year, s); } p->header_label_format_string = fmt; @@ -1495,6 +1496,7 @@ on_desktop_settings_activated (GSimpleAction * a G_GNUC_UNUSED, #ifdef HAVE_CCPANEL execute_command ("gnome-control-center indicator-datetime"); #else +#error blah execute_command ("gnome-control-center datetime"); #endif } @@ -2182,6 +2184,7 @@ my_constructed (GObject * gself) SETTINGS_SHOW_SECONDS_S, SETTINGS_SHOW_DAY_S, SETTINGS_SHOW_DATE_S, + SETTINGS_SHOW_YEAR_S, SETTINGS_CUSTOM_TIME_FORMAT_S }; const char * const calendar_settings[] = { diff --git a/src/settings-shared.h b/src/settings-shared.h index afcccb6..4615fe8 100644 --- a/src/settings-shared.h +++ b/src/settings-shared.h @@ -37,6 +37,7 @@ TimeFormatMode; #define SETTINGS_SHOW_SECONDS_S "show-seconds" #define SETTINGS_SHOW_DAY_S "show-day" #define SETTINGS_SHOW_DATE_S "show-date" +#define SETTINGS_SHOW_YEAR_S "show-year" #define SETTINGS_CUSTOM_TIME_FORMAT_S "custom-time-format" #define SETTINGS_SHOW_CALENDAR_S "show-calendar" #define SETTINGS_SHOW_WEEK_NUMBERS_S "show-week-numbers" diff --git a/src/utils.c b/src/utils.c index d1e1fbf..5539c5c 100644 --- a/src/utils.c +++ b/src/utils.c @@ -329,19 +329,31 @@ generate_terse_format_string_at_time (GDateTime * now, GDateTime * time) ***/ static const gchar * -get_full_date_format_string (gboolean show_day, gboolean show_date) +get_full_date_format_string (gboolean show_day, gboolean show_date, gboolean show_year) { - const gchar * fmt; + const char * fmt; - if (show_date && show_day) - /* TRANSLATORS: a strftime(3) format showing the date and weekday */ + if (show_day && show_date && show_year) + /* TRANSLATORS: a strftime(3) format showing the weekday, date, and year */ + fmt = T_("%a %b %e %Y"); + else if (show_day && show_date) + /* TRANSLATORS: a strftime(3) format showing the weekday and date */ fmt = T_("%a %b %e"); + else if (show_day && show_year) + /* TRANSLATORS: a strftime(3) format showing the weekday and year. */ + fmt = T_("%a %Y"); + else if (show_day) + /* TRANSLATORS: a strftime(3) format showing the weekday. */ + fmt = T_("%a"); + else if (show_date && show_year) + /* TRANSLATORS: a strftime(3) format showing the date and year */ + fmt = T_("%b %e %Y"); else if (show_date) /* TRANSLATORS: a strftime(3) format showing the date */ fmt = T_("%b %e"); - else if (show_day) - /* TRANSLATORS: a strftime(3) format showing the weekday */ - fmt = T_("%a"); + else if (show_year) + /* TRANSLATORS: a strftime(3) format showing the year */ + fmt = T_("%Y"); else fmt = NULL; @@ -400,9 +412,9 @@ get_full_time_format_string (GSettings * settings) } gchar * -generate_full_format_string (gboolean show_day, gboolean show_date, GSettings * settings) +generate_full_format_string (gboolean show_day, gboolean show_date, gboolean show_year, GSettings * settings) { - const gchar * date_fmt = get_full_date_format_string (show_day, show_date); + const gchar * date_fmt = get_full_date_format_string (show_day, show_date, show_year); const gchar * time_fmt = get_full_time_format_string (settings); return join_date_and_time_format_strings (date_fmt, time_fmt); } @@ -436,6 +448,6 @@ generate_full_format_string_at_time (GDateTime * now, GDateTime * time, GSetting break; } - return generate_full_format_string (show_day, show_date, settings); + return generate_full_format_string (show_day, show_date, FALSE, settings); } diff --git a/src/utils.h b/src/utils.h index 24eddb6..5eacce5 100644 --- a/src/utils.h +++ b/src/utils.h @@ -54,6 +54,7 @@ gchar * generate_terse_format_string_at_time (GDateTime * now, gchar * generate_full_format_string (gboolean show_day, gboolean show_date, + gboolean show_year, GSettings * settings); gchar * generate_full_format_string_at_time (GDateTime * now, -- cgit v1.2.3 From 668658f383ae43f175a70a0fdca983c64b84fe59 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 30 Oct 2013 16:10:34 -0700 Subject: remove a debug tracer that accidentally got committed --- src/service.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/service.c b/src/service.c index 0ed7d02..4edcd1c 100644 --- a/src/service.c +++ b/src/service.c @@ -1496,7 +1496,6 @@ on_desktop_settings_activated (GSimpleAction * a G_GNUC_UNUSED, #ifdef HAVE_CCPANEL execute_command ("gnome-control-center indicator-datetime"); #else -#error blah execute_command ("gnome-control-center datetime"); #endif } -- cgit v1.2.3