younes zeboudj
younes zeboudj

Reputation: 924

GtkLabel is not wrapping after updating its content

here is the code i am using :

    messageCrypte= gtk_label_new("");
    gtk_widget_set_size_request(messageCrypte, 400, 100);
    gtk_label_set_line_wrap(GTK_LABEL(messageCrypte), TRUE);
    gtk_grid_attach(GTK_GRID(cryptTab), messageCrypte, 0, ++i, 2, 1);

when i initialize the label manually by passing a string to the gtk_label_new , the text is wrapped , but when updating the GtkLabel , it increment the window size to the infinite without wrapping,

from the docs :

Note that setting line wrapping to TRUE does not make the label wrap at its parent container’s width, because GTK+ widgets conceptually can’t make their requisition depend on the parent container’s size. For a label that wraps at a specific position, set the label’s width using gtk_widget_set_size_request().

i did what it is said but no results !

Upvotes: 1

Views: 424

Answers (1)

younes zeboudj
younes zeboudj

Reputation: 924

the problem was in the wrap mode , the wrapd mode is '...WORD' by default that's mean it will wrap when : (the limit is exceeded AND there is a new word) but i was entering a string example that dont contains space so it will consider it a one word , but when setting the wrao mode to '...CHAR' it will wrap when : (the limit is exceeded AND there is a new char) the 2nd condition is always verified ofcourse ,

Upvotes: 1

Related Questions