Can not CSS grow a GtkCheckButton

The check button can appear tiny compared to other widgets. So I tried to grow it yesterday evening for more than an hour. Initially in my Nim code, which failed. Then with GtkInspector, which worked fine. Well now I created a plain C example, and it seems to fail again.

One additional question: How would I CSS size a GtkCkeckButton that it match nicely the high of
another widget? For that I would need the pixel height of the other widget, how do I get it. Or how can I just increase the size of a GtkCheckButton without giving the exact pixel size. Something like “LARGER” in HTML?

// gcc -Wall t.c -o t `pkg-config --cflags --libs gtk4`
// GTK_DEBUG=interactive ./t
// Include gtk
#include <gtk/gtk.h>

static void on_activate (GtkApplication *app) {
  // Create a new window
  GtkWidget *window = gtk_application_window_new (app);
  // Create a new button
  GtkWidget *button = gtk_button_new_with_label ("Hello, World!");
  GtkWidget *checkbutton = gtk_check_button_new();
  GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_box_append(GTK_BOX(vbox), button);
  gtk_box_append(GTK_BOX(vbox), checkbutton);
  GtkCssProvider *cssProvider = gtk_css_provider_new ();
  const char *data = "checkbutton check {min-height: 24pt; min-width: 24pt;}";
  gtk_css_provider_load_from_data (cssProvider, data, -1);
  GtkStyleContext *context = gtk_widget_get_style_context(checkbutton);
  gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER(cssProvider), GTK_STYLE_PROVIDER_PRIORITY_USER);
  // When the button is clicked, close the window passed as an argument
  g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_close), window);
  gtk_window_set_child (GTK_WINDOW (window), vbox);
  gtk_window_present (GTK_WINDOW (window));

int main (int argc, char *argv[]) {
  // Create a new application
  GtkApplication *app = gtk_application_new ("com.example.GtkApplication",
  g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
  return g_application_run (G_APPLICATION (app), argc, argv);

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.