Signal ::expose-event is invalid for GdkWindow and GdkX11Window
Asked Answered
P

1

1

I had this following code pull from one of the tutorials on line. When I use gtk+-2.0, the following code works fine.

But when I try compile with gtk+-3.0, the code gives this error:

signal 'expose-event' is invalid for instance of type 'GtkWindow'

So I try to do the following, but still doesn't help. And it gives another error:

signal 'expose-event' is invalid for instance of type 'GdkX11Window'

gtk_widget_realize(window);
GdkWindow *gdkwin = gtk_widget_get_window(Gwindow);
int main(int argc, char *argv[])
{
  GtkWidget *window;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

  g_signal_connect(window, "expose-event",
  G_CALLBACK (on_expose_event), NULL);
  g_signal_connect(window, "destroy",
  G_CALLBACK (gtk_main_quit), NULL);

  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_window_set_default_size(GTK_WINDOW(window), 300, 230); 
  gtk_widget_set_app_paintable(window, TRUE);

  gtk_widget_show_all(window);

  gtk_main();
  return 0;
}
Planet answered 10/4, 2018 at 2:3 Comment(2)
Your title is totally redundant. Can you write a better one? And what is that 2-line fragment of code; how does it relate to main()?Gayn
Btw, "signal 'expose-event' is invalid for instance of type 'GtkWindow'" is not a compile-time error, it's runtime errorGillespie
G
3

Migrating from gtk2 to gtk3, section Changes that need to be done at the time of the switch

The GtkWidget “expose-event” signal has been replaced by a new “draw” signal, which takes a cairo_t instead of an expose event. The cairo context is being set up so that the origin at (0, 0) coincides with the upper left corner of the widget, and is properly clipped.

There is no need to connect to any signals to make your code work.

Gillespie answered 10/4, 2018 at 12:45 Comment(1)
I saw that page too. Thank you for the explanation!Planet

© 2022 - 2024 — McMap. All rights reserved.