GTK+ and my port of AMP for Windows
- From: "carlo bramix libero it" <carlo bramix libero it>
- To: gtk-app-devel-list gnome org
- Subject: GTK+ and my port of AMP for Windows
- Date: Tue, 5 Oct 2010 21:52:54 +0200 (CEST)
Hello,
I'm not expert of GTK+ and I need to solve a problem with GTK+ under Windows.
This little test programme works well:
#include <gtk/gtk.h>
#include <glib.h>
int main (int argc, char *argv[])
{
GtkWidget *window;
g_thread_init(NULL);
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(window);
gtk_main();
return 0;
}
The window is created and I can interact without problem with it.
Now, here you are another little test programme that does not work:
#include <gtk/gtk.h>
#include <glib.h>
int main (int argc, char *argv[])
{
GtkWidget *window;
g_thread_init(NULL);
gdk_threads_init(); // <--- I added this line
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(window);
gtk_main();
return 0;
}
The window is created, it's visible on the screen but it's "freezed", I cannot
interact with it and its content is never updated (the busy cursor is always
shown on top of the window).
Have you an idea about what's wrong with this piece of code?
Unfortunately, as I said I'm not expert with GTK+: I have found this trouble
with my port of Audacious Media Player (AMP) on Windows.
After some researches, I discovered that all the problems were resolved by
commenting the call to gdk_threads_init() on top of the main() function.
I compiled myself the GLib, GTK+ and all other required libraries.
Initially, I though there was something wrong in my libs, so I downloaded all
the zip files with precompiled GTK+ for Windows from GTK+ homepage.
Nothing changed: I got the same results I'm having with my libraries
(hopefully!).
I also tried both 2.20.1 and 2.16.6-3, but they show the same bad results.
After seaching for a while in the net, I found some source codes that are
calling gdk_threads_enter() after gdk_threads_init() and gdk_threads_leave()
before quitting the main() function:
int main (int argc, char *argv[])
{
GtkWidget *window;
g_thread_init(NULL);
gdk_threads_init();
gdk_threads_enter(); // <--- I added this line
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(window);
gtk_main();
gdk_threads_leave(); // <--- I added this line
return 0;
}
I must say that this fix has solved the trouble with my little test programme
and AMP too.
Is this the correct way to do?
Do I need to #ifdef the GTK+ version before using them?
Is it required to put gdk_threads_enter() before gtk_init() or I can place
later before gtk_init()?
I'm asking a bit of informations because actually the AMP works on linux even
without calling these functions, I do not know if it's luck or something else.
Last tip, at the moment I could not check my test programme on linux or other
unix dialects, I could just try on Windows.
I hope somebody could give me some good suggestions.
Sincerely,
Carlo Bramini.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]