views:

89

answers:

1
  1. I've a NULL gtklabel. Upon the occurrence of an event, I set a text in this label (with gtk_label_set_text). How can I reset the gtklabel after the event (reset to NULL)?
  2. How can I set the max length (characters) of a GtkTextView?
  3. What's the easiest way to set the distance from the margin of a widget in a GtkTable?
A: 
  1. As I understand from code, you can just use gtk_label_set_text (label, NULL). If that fails for any reason (e.g. earlier version doesn't allow NULL), just replace it with "".
  2. You cannot, directly. Simplest non-direct approach would be to connect to "insert-text" on the view's GtkTextBuffer and g_signal_stop_emission_by_name() when you don't want the insertion to actually happen. Never did this, so it's just what I'd try, no guarantees it will really work.
  3. Not quite sure what you mean. You could try using a GtkAlignment around your widget and set padding on it — may or may not be what you want.
doublep
1. I already tried but not working. I've a mylabel=gtk_label_new(NULL), upon the occurrence of an event, the gtklabel display a text (passed through gtk_label_set_text(GTK_LABEL(mylabel), "text")). For example, I write a sleep(5) and a new gtk_label_set_text(GTK_LABEL(mylabel), NULL), but the result is that the occurrence of the event, I only have a NULL label after five seconds.2-3. I'll try.
stdio
@stdio: "I only have a NULL label after five second" — this sounds like threading problems *or* lack of required threading. Display update only happens in a separate main loop iteration, so if you block the main thread for 5 sec after updating a label, you will *see* it updated only when main loop gets to make another iteration, i.e. after 5 sec.
doublep
1. I used button-press-event and button-release-event signal to switch null and text label.2-3. I followed your suggestion and everything is ok. Thanks!
stdio