diff options
author | Olivier Abad <oabad@noos.fr> | 2002-09-28 09:29:49 +0000 |
---|---|---|
committer | Olivier Abad <oabad@noos.fr> | 2002-09-28 09:29:49 +0000 |
commit | 4b5fa096fa891ebe2e2dd7ffa5f5f12b7fd36ee0 (patch) | |
tree | 07439db5cf1fd8a9dad64d3821a58ab605f9fbf8 /gtk2 | |
parent | 44618beae38bfc87cdda1b2a1f32c2e9194b9223 (diff) | |
download | wireshark-4b5fa096fa891ebe2e2dd7ffa5f5f12b7fd36ee0.tar.gz wireshark-4b5fa096fa891ebe2e2dd7ffa5f5f12b7fd36ee0.tar.bz2 wireshark-4b5fa096fa891ebe2e2dd7ffa5f5f12b7fd36ee0.zip |
From Ulf Lamping : patch to run the gtk2 port on win32.
- gettimeofday changed into glib's g_get_current_time (to be able to
compile)
- disabled multithreading (doesn't seem to work on win32) and used
gtk_timeout_add() as in gtk1.2 to keep tap extensions updating.
svn path=/trunk/; revision=6347
Diffstat (limited to 'gtk2')
-rw-r--r-- | gtk2/main.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/gtk2/main.c b/gtk2/main.c index 11318ef49f..e085efecdb 100644 --- a/gtk2/main.c +++ b/gtk2/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.13 2002/09/27 11:07:15 sahlberg Exp $ + * $Id: main.c,v 1.14 2002/09/28 09:29:49 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1195,6 +1195,19 @@ set_autostop_criterion(const char *autostoparg) } #endif +#ifdef WIN32 +/* + * Once every 3 seconds we get a callback here which we use to update + * the tap extensions. Since Gtk1 is single threaded we dont have to + * worry about any locking or critical regions. + * */ +static gint +update_cb(gpointer data _U_) +{ + draw_tap_listeners(FALSE); + return 1; +} +#else /* if these three functions are copied to gtk1 ethereal, since gtk1 does not use threads all updte_thread_mutex can be dropped and protect/unprotect @@ -1208,15 +1221,15 @@ gpointer update_thread(gpointer data _U_) { while(1){ - struct timeval tv1, tv2; - gettimeofday(&tv1, NULL); + GTimeVal tv1, tv2; + g_get_current_time(&tv1); g_static_mutex_lock(&update_thread_mutex); gdk_threads_enter(); draw_tap_listeners(FALSE); gdk_threads_leave(); g_static_mutex_unlock(&update_thread_mutex); g_thread_yield(); - gettimeofday(&tv2, NULL); + g_get_current_time(&tv2); if( ((tv1.tv_sec + 2) * 1000000 + tv1.tv_usec) > (tv2.tv_sec * 1000000 + tv2.tv_usec) ){ g_usleep(((tv1.tv_sec + 2) * 1000000 + tv1.tv_usec) - (tv2.tv_sec * 1000000 + tv2.tv_usec)); @@ -1224,15 +1237,21 @@ update_thread(gpointer data _U_) } return NULL; } +#endif + void protect_thread_critical_region(void) { +#ifndef WIN32 g_static_mutex_lock(&update_thread_mutex); +#endif } void unprotect_thread_critical_region(void) { +#ifndef WIN32 g_static_mutex_unlock(&update_thread_mutex); +#endif } /* And now our feature presentation... [ fade to music ] */ @@ -1376,6 +1395,8 @@ main(int argc, char *argv[]) exit(0); } + /* multithread support currently doesn't seem to work in win32 gtk2.0.6 */ +#ifndef WIN32 /* if we have thread support via glib2 try to start the low level thread to update applications asynchronously */ @@ -1386,8 +1407,12 @@ main(int argc, char *argv[]) gdk_threads_init(); ut=g_thread_create(update_thread, NULL, FALSE, NULL); g_thread_set_priority(ut, G_THREAD_PRIORITY_LOW); -#endif +#endif /* G_THREADS_ENABLED */ } +#else /* WIN32 */ + /* this is to keep tap extensions updating once every 3 seconds */ + gtk_timeout_add(3000, (GtkFunction)update_cb,(gpointer)NULL); +#endif /* WIN32 */ /* Set the current locale according to the program environment. * We haven't localized anything, but some GTK widgets are localized |