cgtkgladegtk2

Passing data to Glade UI before displaying


I'm using Glade GTK2 to build an about dialog (but this is extendable to any GtkWindow). This is how I show it from my code:

GtkWidget *dialog_about = GTK_WIDGET(gtk_builder_get_object(builder, "dialog_about"));
gtk_dialog_run(GTK_DIALOG(dialog_about));
gtk_widget_destroy(dialog_about);

Now, on Glade there is a label for showing the program version:

enter image description here

Is it possible to replace that "1.0" value with another one from my code before showing it?


Solution

  • Solved by using gtk_about_dialog_set_version:

    GtkWidget *dialog_about = GTK_WIDGET(gtk_builder_get_object(builder, "dialog_about"));
    gtk_about_dialog_set_version (dialog_about, MY_VERSION); // <-----
    gtk_dialog_run(GTK_DIALOG(dialog_about));
    gtk_widget_destroy(dialog_about);