Remove some redundant code

This commit is contained in:
Robert Fewell 2024-05-06 10:26:48 +01:00
parent fb767b6885
commit d2b01d95ad

View File

@ -185,7 +185,6 @@ struct _GncDenseCal
gdc_month_coords monthPositions[12];
guint label_width;
gint label_height; // dense cal label height
guint month_side_bar_width; // month side bar width
@ -403,59 +402,6 @@ gnc_dense_cal_init (GncDenseCal *dcal)
gtk_widget_realize (GTK_WIDGET(dcal->transPopup));
}
/* Deal with the various label sizes. */
{
PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET(dcal), NULL);
GtkStyleContext *stylectxt = gtk_widget_get_style_context (GTK_WIDGET(dcal));
GtkStateFlags state_flags = gtk_style_context_get_state (stylectxt);
gint font_size_reduction_units = 1;
PangoFontDescription *font_desc;
GtkCssProvider *provider;
gint font_size, px_size;
gint i;
gint maxWidth, maxHeight;
gchar *px_str, *widget_css;
gdouble dpi;
gtk_style_context_get (stylectxt, state_flags,
GTK_STYLE_PROPERTY_FONT, &font_desc, NULL);
font_size = pango_font_description_get_size (font_desc);
provider = gtk_css_provider_new ();
dpi = gdk_screen_get_resolution (gdk_screen_get_default ());
px_size = ((font_size / PANGO_SCALE) - font_size_reduction_units) * (dpi / 72.);
px_str = g_strdup_printf ("%i", px_size);
widget_css = g_strconcat ("*{\n font-size:", px_str, "px;\n}\n", NULL);
gtk_css_provider_load_from_data (provider, widget_css, -1, NULL);
gtk_style_context_add_provider (stylectxt, GTK_STYLE_PROVIDER(provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
g_free (px_str);
g_free (widget_css);
pango_font_description_free (font_desc);
maxWidth = maxHeight = 0;
for (i = 0; i < 12; i++)
{
gint w, h;
pango_layout_set_text (layout, month_name(i), -1);
pango_layout_get_pixel_size (layout, &w, &h);
maxWidth = MAX(maxWidth, w);
maxHeight = MAX(maxHeight, h);
}
// these two were reversed, before...
dcal->label_width = maxWidth;
dcal->label_height = maxHeight;
dcal->month_side_bar_width = dcal->label_height;
dcal->day_top_bar_height = dcal->label_height;
g_object_unref (layout);
}
dcal->month = G_DATE_JANUARY;
dcal->year = 1970;