From: Dmitry Sakhonchik <[email protected]>

Previously clock widget used to change its size depending on digits' width 
inside it, which caused other icons in the panel to move.

Fixes [YOCTO #15435]

Signed-off-by: Dmitry Sakhonchik <[email protected]>
---
 applets/clock/clock.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index b8057a4..3065cfc 100644
--- a/applets/clock/clock.c
+++ b/applets/clock/clock.c
@@ -73,6 +73,7 @@ mb_panel_applet_create (const char    *id,
         GtkWidget *label;
         time_t t;
         struct tm *local_time;
+        int ref_string_width;
 
         applet = g_slice_new0 (ClockApplet);
 
@@ -81,6 +82,17 @@ mb_panel_applet_create (const char    *id,
 
         gtk_widget_set_name (label, "MatchboxPanelClock");
 
+        /* Size the widget using the widest possible time string ("88:88") */
+        PangoContext *context = gtk_widget_get_pango_context(label);
+        PangoLayout *reference_string = pango_layout_new(context);
+
+        pango_layout_set_text(reference_string, "88:88", 5);
+        pango_layout_get_pixel_size(reference_string, &ref_string_width, NULL);
+
+        g_object_unref(reference_string);
+
+        gtk_widget_set_size_request(label, ref_string_width, -1);
+
         g_object_weak_ref (G_OBJECT (label),
                            (GWeakNotify) clock_applet_free,
                            applet);
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#237245): 
https://lists.openembedded.org/g/openembedded-core/message/237245
Mute This Topic: https://lists.openembedded.org/mt/119372539/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to