3

I want to be able to change the label of a GtkButton after the widget has been shown

char *ButtonStance == "Connect";
GtkWidget *EntryButton = gtk_button_new_with_label(ButtonStance);

gtk_box_pack_start(GTK_BOX(ButtonVbox), EntryButton, TRUE, TRUE, 0);

gtk_box_pack_start(GTK_BOX(TopVbox), ButtonVbox, TRUE, TRUE, 0);

gtk_widget_show_all(TopVbox);

ButtonStance == "Disconnect";

gtk_button_set_label(GTK_BUTTON(EntryButton), ButtonStance);

gtk_main();

Does anyone know how to do this?

paultop6
  • 3,691
  • 4
  • 29
  • 37

1 Answers1

6

ptomato is right, you are using == where you should be using =.
Your code should look like this:

char *ButtonStance = "Connect";
GtkWidget *EntryButton = gtk_button_new_with_label(ButtonStance);

gtk_box_pack_start(GTK_BOX(ButtonVbox), EntryButton, TRUE, TRUE, 0);

gtk_box_pack_start(GTK_BOX(TopVbox), ButtonVbox, TRUE, TRUE, 0);

gtk_widget_show_all(TopVbox);

ButtonStance = "Disconnect";

gtk_button_set_label(GTK_BUTTON(EntryButton), ButtonStance);

gtk_main();
Isaiah
  • 4,201
  • 4
  • 27
  • 40