[patch] Re: mcs-manager dialog too wide
Benedikt Meurer
benedikt.meurer at unix-ag.uni-siegen.de
Tue Apr 4 09:49:57 CEST 2006
Adriano Winter Bess wrote:
> Index: xfce-mcs-manager/xfce-mcs-dialog.c
> ===================================================================
> --- xfce-mcs-manager/xfce-mcs-dialog.c (revisão 20740)
> +++ xfce-mcs-manager/xfce-mcs-dialog.c (cópia de trabalho)
> @@ -54,6 +54,8 @@
>
> #define MAX_COLUMNS 4
>
> +#define MAX_WIDTH_FACTOR 2
> +
> /*
> * To improve the responsiveness of the UI
> */
> @@ -94,6 +96,7 @@
> create_settings_button (GdkPixbuf *pb, const char *text)
> {
> GtkWidget *button, *vbox, *image, *label;
> + GtkRequisition imgreq, labreq;
>
> g_return_val_if_fail (text != NULL, NULL);
>
> @@ -107,14 +110,21 @@
> if (pb && (image = gtk_image_new_from_pixbuf (pb)))
> {
> gtk_widget_show (image);
> - gtk_box_pack_start (GTK_BOX (vbox), image, TRUE, TRUE, 0);
> + gtk_widget_size_request (image, &imgreq);
> + gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0);
> }
>
> label = gtk_label_new (text);
> gtk_widget_show (label);
> - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
> - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
> + gtk_widget_size_request (label, &labreq);
> + gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
>
> + if (labreq.width > MAX_WIDTH_FACTOR*(labreq.height+imgreq.height)) {
> + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
> + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
> + gtk_widget_set_size_request (label, MAX_WIDTH_FACTOR*(labreq.height+imgreq.height), -1);
> + }
> +
> return button;
> }
You should first add the label to the box before calculating the size
requesition.
Also, this solution is rather hacky, can't we use
gtk_label_set_max_width_chars() instead?
Benedikt
More information about the Xfce4-dev
mailing list