0

I have a program like this

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

 gdk_threads_init();
 gdk_threads_enter();
 gtk_init(&argc, &argv);

 gtk_main();

 gdk_threads_leave();

return 0;
}

I wish to change the deprecated functions:

gdk_threads_init();
gdk_threads_enter();
gdk_threads_leave();

in order don't have a program with deprecated functions.

I wish to continue to use GTK library (https://www.gtk.org/support.php) in order to maintain the links with other parts of the programs.

Lilli
  • 91
  • 1
  • 8
  • What is your question? The manual tells you what to do: "All GDK and GTK+ calls should be made from the main thread" – Gerhardh Oct 27 '17 at 08:46
  • I means: I have always used these functions in order to start a program but now there are deprecated so is it possibile only jump them? I no idea to convert the code. – Lilli Oct 27 '17 at 09:10
  • Do you call GDK or GTK+ functions from other threads as the main thread? If no, then just drop those function. – Gerhardh Oct 27 '17 at 09:13
  • My code calls GDK or GTK+ functions from other threads so I wish to find a good solution in order to jump this problem. – Lilli Oct 27 '17 at 09:30
  • I'm sorry, but I think you will have to redesign according to those rules. – Gerhardh Oct 27 '17 at 10:24
  • When I used gtkmm in multi-threading applications, I strictly prevented access to gtkmm objects from any other than the "GUI" thread. For communication between other threads and GUI thread, I used [Glib::Dispatcher](https://developer.gnome.org/gtkmm-tutorial/stable/sec-using-glib-dispatcher.html.en) - a kind of signal which works between threads. (The dispatch handler aka callback is called from the main loop.) I googled to find the corresponding in GTK+ (the C API) but all I found was [Asynchronous Queues](https://developer.gnome.org/glib/2.54/glib-Asynchronous-Queues.html). – Scheff's Cat Oct 27 '17 at 10:57
  • Possible related: [GNOME doc.: Threads](https://developer.gnome.org/gdk3/stable/gdk3-Threads.html), [SO: GTK3 and multithreading, replacing deprecated functions](https://stackoverflow.com/q/30607429/7478597), [SO: GTK 3 Threads management](https://stackoverflow.com/q/24820507/7478597) or google "gdk_threads_enter decprecated" by yourself to find more... – Scheff's Cat Oct 27 '17 at 11:01
  • You have information in the GDK documentation on how to send work to be done in the main GTK thread: https://developer.gnome.org/gdk3/stable/gdk3-Threads.html#gdk3-Threads.description – liberforce Oct 27 '17 at 16:06

0 Answers0