aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-07-16 14:23:01 -0500
committerTed Gould <ted@gould.cx>2010-07-16 14:23:01 -0500
commitd231f790295d72b462ae56fcfaa211a11aeac838 (patch)
tree74337629d8aca79e4de88e4914f9925a7846ea3b /src
parentc51a8c3c5e510b05bdc8f71cd8099927ce2c7c53 (diff)
downloadayatana-indicator-datetime-d231f790295d72b462ae56fcfaa211a11aeac838.tar.gz
ayatana-indicator-datetime-d231f790295d72b462ae56fcfaa211a11aeac838.tar.bz2
ayatana-indicator-datetime-d231f790295d72b462ae56fcfaa211a11aeac838.zip
Starting to build up our new measuring algorithm. Now with just AM/PM in it.
Diffstat (limited to 'src')
-rw-r--r--src/indicator-datetime.c49
1 files changed, 33 insertions, 16 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
index 9a29324..2afe597 100644
--- a/src/indicator-datetime.c
+++ b/src/indicator-datetime.c
@@ -661,6 +661,29 @@ generate_strftime_bitmask (IndicatorDatetime * self)
return retval;
}
+/* Build an array up of all the time values that we want to check
+ for length to ensure we're in a good place */
+static void
+build_timeval_array (GArray * timevals, gint mask)
+{
+ struct tm mytm = {0};
+
+ /* Sun 12/28/8888 00:00 */
+ mytm.tm_hour = 0;
+ mytm.tm_mday = 28;
+ mytm.tm_mon = 11;
+ mytm.tm_year = 8888 - 1900;
+ mytm.tm_wday = 0;
+ mytm.tm_yday = 363;
+ g_array_append_val(timevals, mytm);
+
+ /* Sun 12/28/8888 12:00 */
+ mytm.tm_hour = 12;
+ g_array_append_val(timevals, mytm);
+
+ return;
+}
+
/* Try to get a good guess at what a maximum width of the entire
string would be. */
static void
@@ -668,24 +691,18 @@ guess_label_size (IndicatorDatetime * self)
{
GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(self->priv->label));
PangoContext * context = gtk_widget_get_pango_context(GTK_WIDGET(self->priv->label));
+ gint * max_width = &(self->priv->max_width);
+ gint posibilitymask = generate_strftime_bitmask(self);
- /* TRANSLATORS: This string is used for measuring the size of
- the font used for showing the time and is not shown to the
- user anywhere. */
- gchar * am_str = g_strdup_printf(_("%d%d:%d%d AM"), FAT_NUMBER, FAT_NUMBER, FAT_NUMBER, FAT_NUMBER);
- gint am_width = measure_string(style, context, am_str);
- g_free(am_str);
-
- /* TRANSLATORS: This string is used for measuring the size of
- the font used for showing the time and is not shown to the
- user anywhere. */
- gchar * pm_str = g_strdup_printf(_("%d%d:%d%d PM"), FAT_NUMBER, FAT_NUMBER, FAT_NUMBER, FAT_NUMBER);
- gint pm_width = measure_string(style, context, pm_str);
- g_free(pm_str);
-
- self->priv->max_width = MAX(am_width, pm_width);
- gtk_widget_set_size_request(GTK_WIDGET(self->priv->label), self->priv->max_width, -1);
+ /* Build the array of possibilities that we want to test */
+ GArray * timevals = g_array_new(FALSE, TRUE, sizeof(struct tm));
+ build_timeval_array(timevals, posibilitymask);
+ /* TODO: Check 'em all */
+
+ g_array_free(timevals, TRUE);
+
+ gtk_widget_set_size_request(GTK_WIDGET(self->priv->label), self->priv->max_width, -1);
g_debug("Guessing max time width: %d", self->priv->max_width);
return;