My current button creation, the sprintf label command is commented out as that messes up the fullscreen rendering:
static void make_toggles (GtkWidget * window) {
GtkWidget * stop_box;
GtkWidget * box_row;
short i;
stop_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
//initialise stops on this panel
char label[32]; label[0] = '\0';
short curr_row = 0;
box_row = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
gtk_box_append(GTK_BOX(stop_box), box_row);
for (i = 0; i< rnum; i++) {
if (curr_row != rstops[i].grid_y) {
box_row = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
gtk_box_append(GTK_BOX(stop_box), box_row);
curr_row += 1;
}
//sprintf(label, rstops[i].label);
sprintf(label, "%d", i);
stop = gtk_toggle_button_new_with_label(label);
gtk_widget_set_name(stop, "stop_button");
gtk_widget_set_margin_start(stop, (rstops[i].margin_left * 4) + 5);
g_signal_connect(stop, "toggled", G_CALLBACK(stop_toggle), NULL);
gtk_box_append(GTK_BOX(box_row), stop);
}
gtk_widget_set_name(stop_box, "window_main");
gtk_window_set_child (GTK_WINDOW (window), stop_box);
}
Update: the issue appears to be the font-size: xx-large
property that applies to my buttons. I can remove that variable, but then the font is rather small.
A proper fullscreen once font-size is removed:
I would like to use gtk_label_set_wrap()
to help the labels fit inside their buttons, but not sure how to extract a GTKLabel from a GTKToggleButton.
EDIT: I figured it out, just create a label and set is as the child of the GTKButton. My final issue is that the text does not center on multi-line labels.
Final EDIT: the centering can be done with gtk_set_justify().