LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-20-2004, 06:44 AM   #1
akhil1
LQ Newbie
 
Registered: Nov 2003
Posts: 5

Rep: Reputation: 0
GTK multi-threaded application


Hi,

I am developing a multi-threaded (pthreads) GUI application using GTK 2.0 library on Red Hat Linux 9.0.

Application has 3-4 GUI threads i.e. one window in each of the 3-4 GUI threads.

I am putting gtk_main() in my main thread for GUI messages handling for all threads. Is there any way I can process GUI messages in each of the GUI thread?

Can any one help me on this issue?

Thanks in advance.
 
Old 09-24-2008, 12:37 AM   #2
arun.tayal
LQ Newbie
 
Registered: Oct 2007
Posts: 14

Rep: Reputation: 0
Hi All,

I am also facing the same issue. I am developing a system tray application ,Which will listen to a port for any incoming connection.

Also there is a menu attached with this system tray application, through which user can perform operations.

I have forked a process which will listen to the socket for connection and then perform operations and in the parent thread I am handling the GUI of system tray by calling gtk_main().

What is happening is at the accept() function the code is getting blocked and now even the parent process is not able to function because of this the menu of system tray hangs.

Plz help.


Regards
Arun Tayal

Last edited by arun.tayal; 09-24-2008 at 12:40 AM.
 
Old 01-20-2009, 03:59 AM   #3
sarocks
LQ Newbie
 
Registered: Apr 2008
Posts: 2

Rep: Reputation: 0
Lightbulb use gdk_threads api

Hi,

Use gdk_threads APIs as follow:

main()
{
GtkWidget *window;

/* init threads */
g_thread_init(NULL);
gdk_threads_init();

/* init gtk */
gtk_init(&argc, &argv);

window = create_window();
gtk_widget_show(window);

gdk_threads_enter();
gtk_main();
gdk_threads_leave();
}


and in the other threads, wherever we are calling gtk+ apis, it should be done as follow:

gdk_threads_enter();
//code
gdk_threads_leave();
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fork()'ed or multi threaded socket I/O? thedevilsjester Programming 5 09-24-2008 12:41 AM
multi-threaded sliding window mjl3434 Programming 2 10-24-2005 04:16 PM
how to do waitpid() using a multi-threaded server? Thinking Linux - Software 1 04-13-2005 09:50 PM
how to debug multi threaded application sibtay Programming 3 10-15-2004 12:02 PM
Multi-Threaded C pragti Programming 1 06-01-2004 10:50 AM


All times are GMT -5. The time now is 01:47 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration