calendar: Try to avoid changing size when changing the year
authorTimm Bäder <mail@baedert.org>
Tue, 4 Feb 2020 11:29:54 +0000 (12:29 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 7 Feb 2020 18:16:32 +0000 (13:16 -0500)
gtk/gtkcalendar.c

index 20b3d6f0c1c08b80e592358d7c413f0561a2fb28..80d99b1e6a76aea65df4711bf564751883735261 100644 (file)
@@ -652,6 +652,7 @@ gtk_calendar_init (GtkCalendar *calendar)
 #endif
   GdkContentFormats *formats;
   GtkDropTarget *dest;
+  int min_year_width;
 
   gtk_widget_set_can_focus (widget, TRUE);
 
@@ -773,6 +774,12 @@ gtk_calendar_init (GtkCalendar *calendar)
   set_month (calendar, tm->tm_mon);
   set_year (calendar, 1900 + tm->tm_year);
 
+  /* We just initialized the year label, now add some space to it so
+   * changing the year does not increase the calendar width */
+  gtk_widget_measure (priv->year_label, GTK_ORIENTATION_HORIZONTAL, -1,
+                      &min_year_width, NULL, NULL, NULL);
+  gtk_widget_set_size_request (priv->year_label, min_year_width + 10, -1);
+
 
   for (i=0;i<31;i++)
     priv->marked_date[i] = FALSE;