From 0c85942be07ac17ede7fe4499db60733a3dbf801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 23 Dec 2010 00:24:51 +0100 Subject: Set label justification to center, and connect to "screen-changed" signal Update gravity on screen change! --- src/indicator-datetime.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 75b857d..5c5f6fd 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -847,6 +847,22 @@ style_changed (GtkWidget * widget, GtkStyle * oldstyle, gpointer data) return; } + +static void +update_text_gravity (GtkWidget *widget, GdkScreen *previous_screen, gpointer data) +{ + IndicatorDatetime * self = INDICATOR_DATETIME(data); + if (self->priv->label == NULL) return; + + PangoLayout *layout; + PangoContext *context; + + layout = gtk_label_get_layout (GTK_LABEL(self->priv->label)); + context = pango_layout_get_context(layout); + pango_context_set_base_gravity(context, PANGO_GRAVITY_AUTO); +} + + /* Tries to figure out what our format string should be. Lots of translator comments in here. */ static gchar * @@ -966,8 +982,10 @@ get_label (IndicatorObject * io) /* If there's not a label, we'll build ourselves one */ if (self->priv->label == NULL) { self->priv->label = GTK_LABEL(gtk_label_new("Time")); + gtk_label_set_justify (GTK_LABEL(self->priv->label), GTK_JUSTIFY_CENTER); g_object_ref(G_OBJECT(self->priv->label)); g_signal_connect(G_OBJECT(self->priv->label), "style-set", G_CALLBACK(style_changed), self); + g_signal_connect(G_OBJECT(self->priv->label), "screen-changed", G_CALLBACK(update_text_gravity), self); guess_label_size(self); update_label(self); gtk_widget_show(GTK_WIDGET(self->priv->label)); -- cgit v1.2.3