Multithreaded App.
- From: Muthu <dearestchum yahoo co in>
- To: gtk-app-devel-list gnome org
- Subject: Multithreaded App.
- Date: Fri, 7 Jan 2005 04:37:18 -0800 (PST)
Hi!
I have a problem with this GTK code.
Actually I want it to show the image, on
the X Window system, when I just pass the filename
around.
It kind of works, really, can show multiple files
on different invocations, but reports some X error,
saying program is wrongly coded etc.
I read the GTK FAQ, and some mailing list problems,
posted earlier. But please help me on this.
The code goes below.
I invoke this function many times within GNU Octave,
octave1> Display("hello.png")
octave2> Display("world.png")
octave3> Display("fubar.png")
And it does some crazy stuff [mind you, most of the
times it displays separate windows with images on it].
Thanks in advance.
Cheers
Muthu.
---------------Code ----------------------------
/* GPL'ed . see www.gnu.org*/
#include<iostream>
#include<octave/oct.h>
#include<octave/parse.h>
#include<octave/dynamic-ld.h>
#include<octave/oct-map.h>
#include<octave/oct-stream.h>
#include<octave/parse.h> /* for feval */
#include<vector>
#include<string>
using namespace std;
extern "C"
{
#include<gtk/gtk.h>
}
DEFUN_DLD(Display,args,,
"This function tries to show the image on the X
server")
{
static int entered_main=FALSE;
GtkWidget *w;
gchar *filename=args(0).string_value().c_str();
if(!gtk_init_check(NULL,NULL)){
gtk_init(NULL,NULL);
g_thread_init();
std::cout<<"GTK Type system
Initialized"<<std::endl;
}
w=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(w),filename);
g_signal_connect(G_OBJECT(w),"destroy",G_CALLBACK(gtk_main_quit),NULL);
gtk_container_add(GTK_CONTAINER(w),
gtk_image_new_from_file(filename));
gtk_widget_show_all(w);
if(!entered_main){
//Work only 1 main loop.
g_thread_create(gtk_main,NULL,TRUE,NULL);
entered_main=!entered_main;
}
return octave_value();
}
__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]