[Glade-users] gtk_label_set_text fails, but not gtk_label_get_text
    Stuart Gilbert 
    stuart.gilbert at gmail.com
       
    Thu Nov  8 11:47:25 EST 2007
    
    
  
Hello.
I've got an application with a label and 3 buttons. When I click one of the
buttons I want the label text to change. gtk_label_set_text doesn't give me
any errors, but it also doesn't change the text at all.
gtk_label_get_text works fine when I put it in before the set_text, and then
prints a blank line if I put it after the set_text.
I get no errors or warnings during compilation with the following line: gcc
famulus.c -o fam `pkg-config gtk+-2.0 --cflags --libs` `pkg-config
libglade-2.0 --cflags --libs` -export-dynamic
I'll paste my code below because it's not very long.
Thanks in advance for any help. :)
Stuart.
---------------------------------------------------------
#include <gtk/gtk.h>
#include <glade/glade.h>
GtkWidget* getElement(const char*);
void btnIssue_clicked_cb(GtkWidget*, GdkEventAny*, gpointer);
void btnIssue_clicked_cb(GtkWidget* btnIssue, GdkEventAny* event, gpointer
data) {
  GtkWidget* lblInfo = getElement("lblInfo");
/*  g_print(gtk_label_get_text((GtkLabel*) lblInfo));
  g_print("\n");
Commented out for the moment. */
  gtk_label_set_text((GtkLabel*) lblInfo, ""); /* <--- This is the line that
fails */
}
GtkWidget* getElement(const char* name) {
  GladeXML *xml;
  xml = glade_xml_new("famulus.glade", NULL, NULL);
  glade_xml_signal_autoconnect(xml);
  GtkWidget* widget = glade_xml_get_widget(xml, name);
  g_object_unref(G_OBJECT(xml));
  return(widget);
}
int main(int argc, char *argv[]) {
  gtk_init(&argc, &argv);
  GtkWidget* wndMain = getElement("wndMain");
  gtk_widget_show_all(wndMain);
  gtk_main();
  return(0);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20071108/87ca4f40/attachment.html 
    
    
More information about the Glade-users
mailing list