Skip to content

Commit

Permalink
Merge pull request #95 from puppylinux-woof-CE/gtk3-patch1
Browse files Browse the repository at this point in the history
Attempt to improve line wrapping in text widget when built with gtk3
  • Loading branch information
01micko authored Apr 19, 2021
2 parents af1aca3 + 3c18c9e commit ef99ac5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/widget_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ GtkWidget *widget_text_create(
/* Enable line wrapping by default */
gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);

#if GTK_CHECK_VERSION(3,2,2) /* gtk3: try global max-width-chars fix */
GdkDisplay * display = gdk_display_get_default();
GdkMonitor * monitor = gdk_display_get_primary_monitor(display);
int scale = gdk_monitor_get_scale_factor(monitor);
GdkRectangle workarea = {0};
gdk_monitor_get_workarea(monitor,&workarea);
int width = workarea.width / scale;
int max_width;
if ( width >= 1920 ) { /* make gui narrrower on wide screens*/
max_width = width / 24;
} else {
max_width = width / 16;
}
gtk_label_set_max_width_chars(GTK_LABEL(widget), max_width);
#endif

#ifdef DEBUG_TRANSITS
fprintf(stderr, "%s(): Exiting.\n", __func__);
#endif
Expand Down

0 comments on commit ef99ac5

Please sign in to comment.