aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-datetime.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-07-16 13:17:36 -0500
committerTed Gould <ted@gould.cx>2010-07-16 13:17:36 -0500
commitc51a8c3c5e510b05bdc8f71cd8099927ce2c7c53 (patch)
tree96c3d4f9ba229d0568d08d43918f8fa6e6531dde /src/indicator-datetime.c
parent62067c9b17c53a186681325e503a7df9f145c37c (diff)
downloadayatana-indicator-datetime-c51a8c3c5e510b05bdc8f71cd8099927ce2c7c53.tar.gz
ayatana-indicator-datetime-c51a8c3c5e510b05bdc8f71cd8099927ce2c7c53.tar.bz2
ayatana-indicator-datetime-c51a8c3c5e510b05bdc8f71cd8099927ce2c7c53.zip
Generating the bitmask of posibilities from the format string.
Diffstat (limited to 'src/indicator-datetime.c')
-rw-r--r--src/indicator-datetime.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
index 171ee2f..9a29324 100644
--- a/src/indicator-datetime.c
+++ b/src/indicator-datetime.c
@@ -624,6 +624,43 @@ const static strftime_type_t strftime_type[] = {
#define FAT_NUMBER 8
+/* Looks through the characters in the format string to
+ ensure that we can figure out which of the things we
+ need to check in determining the length. */
+static gint
+generate_strftime_bitmask (IndicatorDatetime * self)
+{
+ gint retval = 0;
+ glong strlength = g_utf8_strlen(self->priv->time_string, 0);
+ gint i;
+
+ for (i = 0; i < strlength; i++) {
+ if (self->priv->time_string[i] == '%' && i + 1 < strlength) {
+ gchar evalchar = self->priv->time_string[i + 1];
+
+ /* If we're using alternate formats we need to skip those characters */
+ if (evalchar == 'E' || evalchar == 'O') {
+ if (i + 2 < strlength) {
+ evalchar = self->priv->time_string[i + 2];
+ } else {
+ continue;
+ }
+ }
+
+ /* Let's look at that character in the table */
+ int j;
+ for (j = 0; strftime_type[j].character != 0; j++) {
+ if (strftime_type[j].character == evalchar) {
+ retval |= strftime_type[j].mask;
+ break;
+ }
+ }
+ }
+ }
+
+ return retval;
+}
+
/* Try to get a good guess at what a maximum width of the entire
string would be. */
static void