Multi-threaded GUI
- From: "Melvin Newman" <zexelon gmail com>
- To: gtk-list gnome org
- Subject: Multi-threaded GUI
- Date: Wed, 4 Oct 2006 23:34:59 -0400
My saga towards updating the GUI continues... the following are two code snippets:
1) My window update function. It is built into the window1 class and is supposed to update the main GUI window:
gboolean window1::updater(gpointer data)
{
/* Variables
******************************************/
Glib::RefPtr<Gdk::Window>win = get_window();
/*****************************************/
if(win)
{
Gdk::Rectangle r(0, 0, get_allocation().get_width(),get_allocation().get_height());
win->invalidate_rect(r, false);
}
return(true);
}
2) The following is my thread that calls this function through the g_idle_add() function... Unfortunately it does not compile at this line and being new to OO/C++ I have no idea why, or how to fix the problem:
void *server_connect(void *ptr)
{
/* Variables
******************************************/
int tmp=0;
int socket_id;
struct sockaddr_in address;
gpointer data;
Glib::RefPtr<Gtk::TextBuffer> buffer;
sigc::connection pipe1;
/*****************************************/
socket_id = pthread_arg.socket_id;
address = pthread_arg.address;
buffer = pthread_arg.out_put_buffer;
do
{
tmp = connect (socket_id,(struct sockaddr *) &address, sizeof(struct sockaddr));
if (tmp <0)
{
buffer->insert_at_cursor("@");
g_idle_add(window1::updater,false);
^-- Compiling stops here with: error: invalid use of non-static member function `gboolean window1::updater(void*)'
Glib::usleep(400000);
}
}while(tmp<0);
}
Unfortunately I cant seem to integrate the server_connect function into the class, because pthread then complains that it can not call it (miss mach type).
Any help would be greatly appreciated.
Sincerely
Melvin Newman
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]