3

This is my code:

int main(int argc, char *argv[] ) {

    gtk_init(&argc, &argv);

    GtkWidget *window;
    GtkButton *button;

    gtk_rc_parse("style.rc");

    window = gtk_dialog_new();
    gtk_widget_set_name(window, "window");
    g_signal_connect(window, "destroy", G_CALLBACK (destroy), NULL);
    gtk_window_fullscreen(GTK_WINDOW(window));

    button = GTK_BUTTON(gtk_button_new_with_label ("Quit"));
    gtk_widget_set_name(GTK_WIDGET(button), "button");
    g_signal_connect_swapped (GTK_WIDGET(button), "clicked", G_CALLBACK (gtk_widget_destroy), window);
    gtk_widget_set_can_default (GTK_WIDGET(button), TRUE);
    gtk_box_pack_start (GTK_BOX (GTK_DIALOG(window)->vbox), GTK_WIDGET(button), FALSE, FALSE, 0);
    gtk_widget_grab_default (GTK_WIDGET(button));
    gtk_widget_show (GTK_WIDGET(button));

    gtk_widget_show (window);
    gtk_main();
}

And this is my style.rc:

style "button"
{
  fg[PRELIGHT] = { 0, 1.0, 1.0 }
  bg[PRELIGHT] = { 0, 0, 1.0 }
  bg[ACTIVE] = { 1.0, 0, 0 }
  fg[ACTIVE] = { 0, 1.0, 0 }
  bg[NORMAL] = { 1.0, 1.0, 0 }
  fg[NORMAL] = { .99, 0, .99 }
  bg[INSENSITIVE] = { 1.0, 1.0, 1.0 }
  fg[INSENSITIVE] = { 1.0, 0, 1.0 }
}
widget "*GtkButton" style "button"

But my button looks totally standard. Am I using the rc file wrong? It is copied from the official GTK tutorial. Also, there are no errors if I type in a random name instead of style.rc, so I don't know if it's being registered at all.

  • Here's the [GTK 2 tutorial](https://developer.gnome.org/gtk-tutorial/stable/x2177.html) mentioned in the question if anyone else tried looking for it like I did. It shows that RC file format and other documentation on it. Additionally, there's [this API reference](https://developer.gnome.org/gtk2/stable/gtk2-Resource-Files.html). –  Jun 17 '20 at 19:55

0 Answers0